Developer Reference

This chapter is a compact lookup for Automata Lab's public development contracts. The earlier Developer Guide chapters explain ownership, invariants, and workflows in context; this page collects commands, identities, bounds, codes, and terms that are useful during implementation and review.

When a summary here and an executable contract disagree, treat the checked-in package metadata, types, schema, codecs, and tests as the implementation evidence, then update the affected guide in the same change.

npm Commands

Use the exact Node.js and npm versions declared by each package, install with npm ci, and run application commands from automata-web/. Run the npm --prefix documentation ... commands below from the repository root, where documentation/ and automata-web/ are siblings. Lifecycle hooks run automatically: dev first checks icons and schema and builds the hardened documentation preview, while build checks icons, schema, and the runtime notice.

Application development and build

CommandPurpose
npm run devStart the loopback application server and same-origin hardened documentation preview.
npm run previewServe the completed application artifact locally.
npm run typecheckRun TypeScript without emitting JavaScript.
npm run lintRun ESLint across the application package.
npm run buildBuild and verify the application artifact.
npm run build:pagesBuild and verify the combined application/documentation Pages artifact.
npm run test:artifactVerify an existing application artifact.
npm run verifyRun application, locked documentation, combined-artifact, and browser gates.

Application tests

CommandPurpose
npm run test:unitRun the complete Vitest suite.
npm run test:modelRun model, runtime, Solver-domain, application, and infrastructure suites.
npm run test:serverRun server contracts, gateway, workspace, Worker, and shell integration tests.
npm run test:solverRun Solver domain, workspace, Worker, and shell integration tests.
npm run test:shellRun presentation and shell tests.
npm run test:performanceRun the general performance suite.
npm run test:routing-performanceRun the exact Chart routing benchmark suite.
npm run test:browser:installInstall Playwright's Chromium, Firefox, and WebKit browsers.
npm run test:browserRun the complete Playwright browser suite.
npm run test:accessibilityRun the focused Playwright accessibility specification.

Generated contracts and audits

CommandPurpose
npm run schema:checkVerify that the generated file-schema validator matches its source.
npm run schema:generateRegenerate the checked-in file-schema validator.
npm run icons:checkVerify the selected Fluent icon set, manifest, and hashes.
npm run icons:import -- --source <directory>Refresh selected icons from a complete local Fluent collection.
npm run audit:runtimeVerify the production dependency closure and committed runtime notice.
npm run audit:runtime:writeRegenerate the runtime notice, which must then be reviewed.
npm run audit:advisories:offlineCheck cached production advisories without network access.
npm run chart:lockDeliberately restamp the Chart algorithm lock after an approved change.

The Chart lock command is not a formatting or routine update command. Read State Chart Architecture before changing locked layout or routing sources.

Documentation package

CommandPurpose
npm --prefix documentation run devStart the VitePress authoring server.
npm --prefix documentation run buildBuild and CSP-harden the standalone documentation site.
npm --prefix documentation run build:combinedBuild hardened documentation beneath the application artifact's docs/ directory.
npm --prefix documentation run testBuild and verify routes, links, fragments, search, CSP, local assets, and leakage gates.
npm --prefix documentation run previewServe the completed documentation artifact locally.
npm --prefix documentation run audit:dependenciesVerify the locked documentation closure and committed dependency inventory.
npm --prefix documentation run audit:dependencies:writeRegenerate the dependency inventory, which must then be reviewed.

See Testing, Building and Deployment, and Writing the Documentation for gate selection and artifact integration.

File-Format Reference

ItemContract
EncodingUTF-8 JSON, bounded to 5 MiB before parsing.
Identityfile_id: "automata-lab-state-machine".
VersionStrict 1.0.0, 1.1.0, 1.2.0, 1.3.0, or 1.4.0; independent of application and model versions.
Required sectionssettings, state_machine, chart, solver, and simulator.
StructureClosed JSON Schema; unknown properties and duplicate JSON members are rejected.
SemanticsUnique names and identifiers, valid references, deterministic transition keys, and bounded collections.
Canonical outputSchema order, preserved meaningful array order, two-space indentation, and one trailing newline.
Public schemasOne versioned schema for each supported format under automata-web/public/schema/.

AuthoringDocumentCodec accepts a structurally and referentially sound draft with zero states or no initial state and returns explicit completeness warnings. AutomataDocumentCodec requires a complete valid model and owns Pull, Push, hosting, compilation, and runtime boundaries. Both reject invalid structure/references and apply the documented terminal-notation migration/preparation boundary.

The source schema is automata-web/src/infrastructure/files/schema-v1.ts; its generated validator is checked in beneath src/infrastructure/files/generated/. See File and Data Contracts for validation order, compatibility reads, canonical serialization, and adapter behavior. State attachments require at least 1.1.0; remembered event/order metadata requires 1.2.0, even when both ends are free. Indicator attachments and direct initial-to-terminal connections require 1.3.0. Earlier formats reject later fields even when null. Save omits null optional references and always writes 1.4.0, including required terminal_state booleans. Legacy configured terminal connections migrate to flags; modern explicit flags govern notation repair.

CSV Reference

CollectionCanonical headerImport behavior
Model Metadataname,description,version,initial_stateApply the first non-empty row; warn about later rows.
Statesname,description,terminal_stateReplace collisions in place and append new declarations in row order.
Eventsname,descriptionReplace collisions in place and append new declarations in row order.
Actionsname,descriptionReplace collisions in place and append new declarations in row order.
State Actionsstate,action,schedulePreserve order and duplicates; absent schedule means entry.
Transition Tablestate,event,next_stateReplace the same deterministic key; validate all references first.
Solver Observation Sequencename,typeAccept event, state, or action and canonicalize the prefix.
Simulator Event SequencenamePreserve undeclared events as intentional negative-test input.

Header matching ignores case and surrounding whitespace. Unknown columns are ignored, but duplicate or missing required headers fail. Import accepts quoted fields, escaped quotes, commas, embedded newlines, and CRLF or LF records. Export uses RFC 4180 escaping, canonical column order, CRLF records, and one final CRLF.

Every import validates the complete candidate before one revision-checked command. Invalid rows, rejected collision confirmation, cancellation, or a stale revision leave the document unchanged.

Server Protocol Reference

The built-in Worker protocol is automata-lab-server/2. Every request contains exactly these seven keys: protocol, kind, requestId, operation, conditionalModelRevision, sessionId, and payload.

FamilyOperations
Negotiation and healthserver.hello, health.live, health.ready
Hosted documentmodel.get, model.put
Simulation lifecyclesimulation.start, simulation.reset, simulation.close
Simulation executionsimulation.run, simulation.step

Success and error responses correlate their request. Unsolicited server.lifecycle, server.diagnostic, and model.changed events carry a strictly increasing server sequence. Both sides reject unknown keys, malformed values, operation-specific shape mismatches, and oversized payloads.

Only the idempotent hello, health, and model-read operations may be retried automatically after timeout. A timed-out model.put is reconciled through a fresh read; session mutations are never replayed blindly. model.put uses compare-and-set against the expected semantic model revision.

See Server and Simulator Architecture for revision hashing, pinned sessions, runtime semantics, recovery, and the future HTTP adapter boundary.

Configuration Reference

OwnerLocation and responsibility
Compile-time configurationsrc/configuration/compile-time-configuration.ts: defaults, bounds, tuning, and switches.
Presentation spacingCOMPILE_TIME_CONFIGURATION.presentation.spacing: page/modal insets, splitter/scroll gaps, and independent additional group-box margins; exposed through live-shell CSS properties.
Application preferencesTyped content-independent allowlist projected from central defaults.
Button color allowlistsrc/application/button-colors.ts: names and decoding; defaults remain in central configuration.
Button color presentationsrc/presentation/shared/button-colors.ts: palette tokens; src/application.css: scopes, borders, and geometry.
Domain limitssrc/domain/model/limits.ts: file, model, Solver, and sequence capacities.
Interactive Chart limitssrc/application/chart-layout-limits.ts: accepted node and relation counts.
Server protocol limitssrc/workers/server/protocol.ts: payload, session, trace, request, and diagnostic bounds.
Vite configurationautomata-web/vite.config.ts: application base path and production build behavior.
Documentation configurationdocumentation/.vitepress/config.mts: docs base path, navigation, and local search.

Use DEFAULT_APPLICATION_PREFERENCES wherever a consumer needs a preference default. Do not repeat a default or bound in a component, dialog, adapter, or test helper. Developer spacing settings and diagnostic switches are compile-time, non-persisted values; they do not belong to application settings or project files.

See Configuration and Preferences for the persistence envelope, recovery, and transaction rules.

Capacity Limits

ResourceMaximum
JSON or CSV input; server document or payload5 MiB
Name or Solver token128 Unicode code points
Description4,096 Unicode code points
States10,000
Events256
Actions1,000
Transitions, entry mappings, or exit mappings50,000 each
Terminal indicators, terminal relations, or Chart drafts10,000 each
Solver sequences; Simulator sequences1,000 each
Solver tokens across the saved library50,000
Events in one Simulator sequence or server Run request10,000
Interactive Chart nodes; relations1,000 nodes; 10,000 relations
Built-in live sessions; retained entries in one trace64 sessions; 50,000 entries
Console history; details from one diagnostic result1,000 entries; 100 details plus summary

Worker routing and output bounds add narrower per-request protections. See Limits, Privacy, and Security for the user-facing limit contract and Security and Privacy for boundary enforcement.

Diagnostic Codes

Codes are stable identifiers for tests, support, and Console filtering. The accompanying severity, source, message, path or context, and remediation remain part of the diagnostic; do not branch on human-readable message text.

FamilyRepresentative codes
Document and validationDOCUMENT_INVALID, STATE_REQUIRED, INITIAL_STATE_REQUIRED, DETERMINISM_CONFLICT
JSON and file I/OJSON_MALFORMED, DUPLICATE_JSON_MEMBER, FILE_SCHEMA_INVALID, FILE_READ_FAILED
CSVCSV_HEADER_MISSING, CSV_REFERENCE_INVALID, CSV_CAPACITY_EXCEEDED, CSV_IMPORT_COMPLETED
Commands and ChartCOMMAND_INVALID, REVISION_MISMATCH, CHART_ROUTING_FALLBACK, CHART_IMAGE_EXPORTED
SolverNO_OBSERVATIONS, ACTION_WORD_CONFLICT, SOLVER_CANDIDATE_READY, SOLVER_CANDIDATE_STALE
Server and revisionsSERVER_PROTOCOL_FAILURE, HOSTED_MODEL_CONFLICT, HOSTED_MODEL_PUSHED, PULL_REVISION_MISMATCH
SimulatorSIMULATION_SESSION_STALE, UNKNOWN_EVENT, NO_TRANSITION, SIMULATION_TRACE_TRUNCATED
Preferences and printPREFERENCE_CORRUPT, PREFERENCE_SAVE_FAILED, PRINT_FAILED
Console boundingDIAGNOSTICS_TRUNCATED

Add a code at the layer that owns the condition, keep its spelling stable, localize presentation text separately, and test severity plus transactional outcome. See Console and Diagnostics and User Reference for the common user-facing lookup.

Glossary

TermDeveloper meaning
Authoring draftEditable project that may lack states or an initial state but remains structurally sound.
Canonical documentDeterministic strict file 1.4.0 with explicit terminal-state flags.
Command planImmutable validated description of one atomic, revision-checked document mutation.
Derived scenePresentation-only Chart geometry computed from document data and preferences.
Hosted revisionImmutable hosted snapshot identified by the semantic hash of settings and state machine.
Partial transition functionDeterministic mapping in which an unlisted state-and-event pair remains undefined.
PortApplication-owned capability contract implemented by infrastructure or a test adapter.
Pinned sessionServer-owned Simulator session that keeps the hosted snapshot on which it started.
Solver candidateImmutable inferred model requiring review and explicit confirmed application.
Stale resultWorker, candidate, command, or response whose source revision no longer matches.
Transactional boundaryOperation that commits its complete validated result or leaves prior state unchanged.
Worker generationIdentity used to reject late messages from a replaced Solver, Server, layout, or routing Worker.

The User Reference glossary defines model and interface terms such as action, Chart draft, initial indicator, terminal indicator, transition, and stale session.

Previous: Contributing

Next: Licenses and Acknowledgements