Documentation/Under the hood
Gateway routing format2 min read

Gateway routing ledger v1

This format is independent of repository, object, and workspace formats. Adding a gateway changes none of their bytes. The gateway root contains:

  • SCRIBE_GATEWAY: exact UTF-8 bytes scribe-gateway\n1\n.
  • LOCK: exclusive OS ownership lock.
  • routes.redb: redb 4 database containing routes and instances tables.
  • status.json: disposable observation snapshot, never authoritative routing.

routes maps a repository name string to a scribe_format::gateway::RouteRecord:

FieldEncoding
Record versionu8 = 1
Instance nameu16 LE byte length, then UTF-8; 1–64 ASCII letters/digits/hyphens/underscores
Storage compressionu8: 0 none, 1 LZ4
Has repository IDu8: 0 or 1
Repository ID16 exact bytes, present only when the preceding flag is 1
Conflict flagu8: 0 or 1

Unknown versions, invalid flags, invalid compression, invalid names, truncated records, and trailing bytes are rejected. A record without an ID is a durable pending name reservation. A conflict flag prevents routing that name. Golden bytes and strict decoding tests live in scribe-format/src/gateway.rs.

instances maps a configured instance-name string to its exact 16-byte data-root incarnation. An identity is pinned after successful inventory. A different identity at the same name or the same identity under another name is rejected.

Both placement reservations and completed assignments commit with Durability::Immediate. Payload encoding, authentication, inventory collection, and upstream requests happen outside database write transactions. Routing state is never inferred from the disposable JSON snapshot. There is no format migration or legacy fallback.

Source docs/gateway-format.mdSnapshot 93d02b17