ARBI
Documents / docs/software/configuration.md

Configuration, capabilities and calibration identity

Issue #16 implements the configuration contract in @arbi/protocol: a JSON Schema 2020-12, generated TypeScript bindings, runtime/reference boundary and synthetic fixtures. The contract is arbi.configuration/1.0; existing message protocol 1.0 is unchanged. Offline schema consumers register both schemas by their canonical $id values; shared protocol definitions do not require network fetching. Configuration requests and reports are separate records, not new message kinds smuggled into that protocol.

This contract is source and host-reference evidence. The separate local commissioning consumer now implements simulation enrollment, durable multi-device staging/activation and recovery; electrical interfaces, installed measurements and physical authority remain unimplemented. ADR-0005 and ADR-0006 own the deployment and safety boundaries. The local safety interface matrix, particularly LS-01, LS-10/11, LS-18 and LS-19, remains the requirements register; every physical gate remains unverified.

Revisioned inventory and observations

A configuration identifies its environment/namespace, execution mode, site and previous configuration revision. Components have stable instance/hardware/assembly IDs and hardware/assembly revisions. A module declares its role, actual firmware version or null, and an explicit supported update interface with target kinds and evidence, or an unsupported reason. A passive component has no firmware or update fields. Drums, lines, anchors and servo mechanics therefore do not acquire software capability from their presence in inventory. Drivers may be active modules while exposing neither firmware identity nor an update interface.

Signals name the owning local module, interface ID and physical component when one exists. An unavailable reading carries a reason and no numeric value. Reported qualities require evidence; measured requires a declared physical source. The hardware digest covers both components and signal ownership/interfaces/qualities, including declared firmware/update inventory. Changing any of these invalidates the calibration binding until reviewed. An authenticated adapter must establish this digest from its independently reconciled installed inventory; it must never copy it from an incoming request.

metric optionally maps a signal to an existing protocol metric. A null metric can describe inputs outside protocol 1.0's measurement vocabulary, such as driver-local encoder visibility. configurationCapabilities projects the owning module's declared metrics into existing protocol capabilities: unavailable readings have an empty qualities array, and estimates remain estimates. A missing signal conveys no capability. Capability declarations establish supported observations; they do not establish freshness, health or actuation permission. Telemetry still requires protocol validation, source/boot/session and time checks, sample uncertainty and its own configuration/calibration provenance in the consuming runtime.

The synthetic inventory declares driver-local encoders unavailable to the Pico, per-line tension unavailable, pod rail voltage unavailable, calculated pose/line length as commanded/estimated, and servo angle as commanded. These examples do not install sensors. They preserve the current wiring and matrix's gaps. Simulation origin is explicit at configuration and message boundaries. Runtime adapters must reconcile sensor evidence, not infer global pose or tension from driver health, current or STEP counts.

Frames, mappings and calibration

Units are millimetres, degrees, mm/s, mm/s² and newtons as named in the schema. Site and pod-gimbal frame identities reuse protocol types and revisions. V1 geometry uses a horizontal axis-aligned rectangle with anchors a, b, c, d in order: minimum x/y, maximum x/minimum y, maximum x/y, minimum x/maximum y. Its site frame is right-handed x/y/z. The gimbal frame is local to the pod; this contract does not infer an observed pod pose or a moving transform from a configured origin.

Anchor identities must be distinct and registered. The workspace has positive extents inside the anchor footprint and strictly below the anchor plane. Bed volumes have positive extents inside the footprint; plant positions must lie in their named bed. IDs and mapping revisions are site scoped by the enclosing configuration. Unknown, duplicated or cross-bed mappings are rejected. Future geometry/topology needs an explicit schema/semantic revision rather than relaxing these invariants. This rectangular model is a configuration sanity check, not cable-force, structural or stopping-distance validation.

Calibration has its own revision/parent, stage scope, line-length offsets, gimbal zero offsets, positional uncertainty and revisioned evidence references with reviewer and result. It binds SHA-256 digests of the full inventory, geometry and approved limits. Offsets and uncertainty must leave positive calibrated payout throughout the workspace. Pose commands stay inside the workspace after its uncertainty margin; gimbal zero offsets cannot extend the requested ranges beyond independently loaded local limits. These checks do not prove actual length, force, repeatability or measured angle.

Evidence references are opaque IDs plus record revisions, intended to resolve to immutable review/test records. A passed string supplied by a requester cannot approve calibration. Local context must contain independently approved exact calibration digests for the correct rig/site/stage and require the independently selected local calibration scope to match. The calibration digest covers evidence, scope, offsets, uncertainty and all three bound identities. Simulation scope cannot represent hardware calibration. Bench and installed scopes remain subject to their separately accepted procedures and physical prerequisites. Geometry, limits and calibration revisions are immutable within retained history; edited content under the same revision is rejected.

Requested, committed and rebooted identity

ConfigurationRequest carries the immutable requested configuration, target boot/session, transaction ID, expected applied revision and revisioned edit context: authenticated actor, authorization/correlation IDs, reason code and prior configuration/calibration revisions. This context is available to the future audit consumer; it does not define audit vocabulary or claim device effects. Configuration, calibration or mapping changes use a new revision and the current parent. Ordinary apply cannot reuse an old configuration revision.

ConfigurationReference.apply checks schema and semantics, authenticated actor/grant, exact target, local inhibition, expected revision, immutable history, current hardware, independently approved calibration, schema readers and local limits. Requested limits must be a subset of independently loaded bounds, even when calibration approval is valid. Approved remote calibration never expands Pico/pod limits. Stable error codes and paths identify the rejected prerequisite without echoing input values.

The reference then prepares one journal candidate containing the exact request, applying module identity and full configuration digest. The synchronous persistence callback must durably commit the complete candidate before returning true. Only then does the reference advance applied state and return configuration.applied. A false result or exception returns PERSISTENCE_FAILED, preserves the prior state, and permits retry. Reentrant apply/restore during persistence returns APPLY_IN_PROGRESS. Input, persistence candidate, getter and export copies cannot mutate committed state. Repeated identical transaction IDs return the original receipt without a second persistence call; changed content conflicts. That original receipt refers to its original transaction and does not claim it is still the current revision.

The journal retains immutable commits and a pointer to its last applied transaction. It is bounded to 128 commits and 1 MiB serialized size; exhaustion rejects new work. A future durable store may implement reviewed archival while retaining revision/transaction uniqueness and rollback evidence. This in-memory implementation is a reference for ordering and failure tests. It does not establish SQLite durability, concurrent-writer correctness or power-loss behavior. Production storage must atomically commit configuration, edit context and acknowledgement/outbox state, handle lost acknowledgement after commit, and protect the journal from unauthorized edits. A digest detects accidental mismatch, not authenticated tampering.

reboot validates the durable journal, digests, transaction chain and device identity, then emits configuration.boot with the exact committed configuration revision, digest and calibration revision under the new boot/session. It remains inhibited. A hardware change does not rewrite the recorded applied identity: subsequent command checks reject the mismatch. Reboot never restores jobs, leases or motion authority, and Parked cannot authorize restart or flashing; LS-18 remains unverified. Restore is a trusted local-persistence operation, not an exposed remote rollback endpoint.

Command integration

checkConfiguredCommand is an additional configuration compatibility boundary. Use it together with existing admitCommand, current independently reconciled hardware/evidence, and local state/interlock/limit checks. It validates message structure and environment/site/target, rejects stale configuration revision or mismatched hardware, rechecks current calibration approval and local bounds, checks site/gimbal frame identity and bounded targets/speed, and applies the uncertainty margin. The returned command means compatible under these checks; it grants no authorization, dispatch, freshness or physical safety.

Stop, state resync, preview stop and cancel can pass this boundary without configuration. They still need protocol authentication/admission and target/environment matching. Configuration absence or invalidity must never block local emergency stopping. Cloud availability, audit upload, budgets and UI mode cannot own this local safety behavior. Protocol admission's existing lease/deadline semantics are unchanged.

Export, schema compatibility and rollback

All records use a closed schema; unknown fields, including credentials in nested modules/readings, are rejected. There are no URLs, endpoint secrets, arbitrary log strings or deployment credentials in ordinary configuration. Enrollment and deployment secrets belong to protected, separate stores. exportJournal exports validated configuration and revisioned context only. Site coordinates, mappings and principal IDs can still be private: authorize exports and do not publish real installations as repository fixtures. Fixture coordinates, identities and evidence are fictional.

Version 1.0 is the first implemented configuration schema. There is no accepted legacy schema and no automatic lossy migration. Unknown versions are rejected before activation; future migrations must introduce an explicit reviewed converter, fixtures, new version and reader/rollback compatibility evidence. Current readableSchemaVersions and rollbackReadableSchemaVersions are independent local module capabilities. Activation requires the requested version to be readable and both requested/prior committed versions to remain rollback readable. A firmware release that removes required readers cannot activate configuration through this boundary. Release availability is separate from installation capability and local update preflight.

Rollback is an explicit transaction naming an exact archived configuration revision. Its audit context references the current config/calibration, while its applied content is content-identical under canonical JSON hashing to the archived configuration, including its original parent/calibration. It cannot edit the archive, guess a missing revision, revive revoked calibration, ignore changed hardware, or expand newly tightened local limits. The journal preserves the rollback transaction separately from the original apply receipt. A fresh module boot/session and current local inhibition/authorization are required as for any activation.

Reproducible validation and remaining evidence

Run from the repository root with Node.js >=24 and pinned pnpm:

pnpm --filter @arbi/protocol lint
pnpm --filter @arbi/protocol typecheck
pnpm --filter @arbi/protocol test
pnpm --filter @arbi/protocol build
pnpm docs:check
git diff --check

The tests expand fixture request descriptors by replacing configurationFixture with the named valid configuration. Journal fixtures use journalTransactions in order, preserving exact expanded requests. This keeps language-neutral fixture inputs compact without duplicating configuration payloads. Fixtures/tests cover stale requests and audit parents, incompatible hardware, absent/unapproved calibration, unavailable measurements, unknown credential fields, invalid geometry/mappings, immutable revision conflicts, failed persistence, duplicates, reboot identity, unsupported schema migration, exact rollback, revoked evidence and tightened local limits. Existing protocol 1.0 fixtures and Python/C host round-trips still pass separately.

Actual durable storage and adapters belong to #23, calibration workflow to #40, cross-runtime conformance expansion to #20, and physical instrumentation/acceptance to #59 and #79. No physical gate, real module update/reboot, installed calibration or firmware validator is validated here. Recording #68 remains deferred and disabled.