ARBI
Documents / docs/software/edge-runtime.md

Edge runtime and local transport 1.0

Implementation: edge controller. Decision: ADR-0008. Evidence: prototype record. arbi.local/1.0 is an app-owned transport handshake around existing @arbi/protocol 1.0 messages; it is not a new shared command protocol or production enrollment contract.

Framing and discovery

Each TLS 1.3 connection uses mutual certificate verification and ALPN arbi.local/1.0. The edge additionally verifies the server DNS name and exact enrolled certificate SHA-256; the test peer pins the edge certificate. Credentials are generated only in private temporary directories for simulation. The immutable manifest binds each certificate to one module ID/role and loopback endpoint. No browser credential or cloud API key appears in this trust domain.

Plaintext inside TLS consists of a 4-byte unsigned big-endian length followed by exactly that many strict UTF-8 JSON bytes. Zero or more than 16,384 bytes is rejected from the header before copying payload data. Fragmented and coalesced frames are allowed. Invalid UTF-8, malformed JSON, unknown handshake fields, excess message rate or write-buffer limit disconnects. No compression or bulk/media/firmware payload is supported. The decoder uses one fixed 16,384-byte payload buffer per connection, and settings/credential file reads have independent bounds.

  1. Edge sends discover: transport/kind, fresh random challenge, current edge source identity, protocol, realm, site, simulation mode and accepted configuration digest.
  2. The pinned peer replies hello: transport/kind, echoed challenge, module source identity (fresh session per connection), role, same realm/site/mode/digest and exactly supported protocol arbi/1.0. Incorrect identities/roles, scope, digest or version fail closed.
  3. Peer sends a protocol state.snapshot with matching source, configuration/capabilities revisions and projected configuration capabilities, fresh event cursor, diagnostic Ready state, supported protocol and only state.resync as supported command. Readiness waits for this snapshot. Ready here means diagnostic simulation readiness; all physical capabilities remain inhibited.
  4. Later snapshots/telemetry pass schema/semantic validation, authenticated realm/site/source/mode checks, monotonic timestamp checks and existing cursor/capability consumers. Event replay/gaps, changed boot/session or incompatible state/configuration require disconnection and negotiation; a message cannot auto-adopt a new boot. Missing/flooded/partial input cannot extend link freshness.

The initial peer emits snapshots every 250 ms. The edge requires a valid accepted frame within 1,500 ms, destroys the connection and invalidates readiness/grants on expiry, and reconnects with bounded exponential backoff/jitter. All timers are receiver monotonic. Peer deadline timestamps derive from the most recent accepted peer clock; the peer enforces its own clock independently. These are diagnostic test bounds, not commissioned actuation timing.

Diagnostic authorization and shutdown

A host certificate proves service identity. It grants no end-user permission. The only work seam issues single-use, 500 ms diagnostic grants to the explicit synthetic service actor simulation-diagnostics. Up to 16 grants bind edge source, peer source and current connection generation. Changed, expired, reused, disconnected or previous-boot grants cannot issue work. Each dispatch consumes the grant before writing and is never retried on ambiguous delivery. The peer consumes the same state.resync command contract through admitCommand; any actuator command is unsupported and rejected. This seam is not human permissions, commissioning, a cloud lease, or an installed control session.

SIGTERM/SIGINT stops admission, closes health and module sockets and cancels all pending reconnects. Startup creates new edge boot/session identity and restores only the validated synthetic applied configuration identity. The prototype has no command journal, disk job state or automatic resumption; crash restart cannot reissue previous actuator commands because no actuator dispatch exists. Local module inhibition/stop remains independent of edge/health/HTTP. Actual firmware timeout and independent cabinet protection need separate tests.

No WAN counter is inferred from these LAN payloads. No accepted diagnostic is presented as a physical effect or a person viewing content. The synthetic grant seam consumes the merged audit 1.0 vocabulary: it validates an authorization.check observation with effect: none, null command/outcome/receipt references and the synthetic service actor. A private in-memory ring retains at most 32 observations per module with an explicit dropped count and durable: false; it is a development observation seam, not a durable audit service. It never fabricates a terminal device outcome from a write, reconnect or closed socket. Durable append/admission belongs to #27, edge audit persistence/upload to #51/#46, and cloud enrollment to #21; source acceptance here does not establish those integrations.