Skip to content

docs(airc-rust): replace body_hint field with HTTP-style Headers dictionary - #658

Closed
joelteply wants to merge 1 commit into
canaryfrom
docs/airc-rust-envelope-headers
Closed

joelteply wants to merge 1 commit into
canaryfrom
docs/airc-rust-envelope-headers

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Reshapes the envelope-metadata model per the iterative refinement with Joel and Codex on AIRC:

  • `body_hint` as a single typed field → `Headers` as a string-keyed dictionary (HTTP-style)
  • `BTreeMap<String, String>` for deterministic ordering, stable signatures, unknown-header pass-through, no schema churn
  • Namespace convention: `airc.` (substrate-owned), `forge.` (alloy/contract — includes `forge.body_hint`), `continuum.` / `openclaw.` / `hermes.` (consumer ecosystems), `x-` (experimental)

Why the dictionary won over a typed struct

Joel's framing made this concrete: this is the same pattern web HTTP has used for decades. X-headers, Content-Type, middleware that reads only what it understands and passes the rest through unchanged. Typed top-level fields hard-code every concern into the substrate schema; a string-keyed dictionary stays extensible.

Routing/middleware never parses the body — it inspects headers. Even with E2E encryption (body encrypted under recipient key) the headers stay accessible because they're authenticated by signature, not encrypted. That's how routing efficiency survives under double-ratchet.

Rules locked

  • Authority rule: routing/admission trust the headers. Body MAY have its own `kind` field as consumer ergonomics — substrate never consults body fields. Headers canonical.
  • Extensibility rule: consumers add headers without coordinating with airc-rust. Other consumers ignore unknowns.
  • Ergonomic helpers, plain strings underneath: typed Rust API (`envelope.body_hint() -> Option<&str>`) is layered over the `BTreeMap<String, String>` wire shape. Wire stable; API evolves.

What changed in the doc

  • Envelope struct: single `body_hint` → `headers: Headers`
  • Subscription struct: `body_hint` filter → header-keyed match patterns (`Exact` / `Prefix`)
  • Storage tables: `messages.body_hint` column → `messages.headers` JSONB; `subscriptions.body_hint_or_null` → `subscriptions.header_filters`
  • All `body_hint` examples through the doc updated to `forge.body_hint` header form
  • New "Headers — HTTP-style envelope metadata" section in The Protocol
  • New "Authority rule" / "Extensibility rule" / "Encryption note" / "Ergonomic helpers" callouts

Test plan

  • No code changes — docs only
  • grep confirms no stale standalone `body_hint` references; all are namespaced (`forge.body_hint`) or `headers["forge.body_hint"]`

🤖 Generated with Claude Code

…rs dictionary

Per the real-time conversation with Codex + Joel: body_hint was the
right idea but the wrong shape. The clean primitive is a string-keyed
headers map on the envelope (HTTP analogy), not a single typed field.

Changes:

  - Envelope.body_hint (single optional field) → Envelope.headers
    (`BTreeMap<String, String>`)
  - Subscription.body_hint → Subscription.headers (header-keyed
    match patterns with Exact/Prefix variants)
  - Storage `messages.body_hint` column → `messages.headers` JSONB
  - Storage `subscriptions.body_hint_or_null` → `subscriptions.header_filters`

Namespace convention (no schema coordination needed):

  - airc.*       — substrate-owned: trace_id, priority, reply_to,
                   content_encoding, deadline, lease, auth_scope, pii
  - forge.*      — alloy/contract: body_hint (e.g. "forge.work.offer"),
                   requires_capability (e.g. "render.gpu"), persona.tier
  - continuum.*  — continuum-specific: persona_id, activity
  - openclaw.*, hermes.*, etc. — other consumer ecosystems
  - x-*          — experimental / private headers

BTreeMap chosen over HashMap for:
  - deterministic ordering (signatures + replay + diff-tests stable)
  - simple serialization (sorted keys, predictable JSON)
  - unknown-header pass-through (transports just copy the map)
  - no schema churn when middleware adds new headers

Rules added:

  - "Authority rule": routing/admission decisions trust the headers.
    Body MAY contain its own kind field as local ergonomics for
    consumers that already parse the body — substrate never consults
    body fields. Headers are canonical.
  - "Extensibility rule": consumers add new headers without
    coordinating with airc-rust. Other consumers ignore unknown
    headers.
  - "Encryption note": when body is encrypted under recipient key
    (double-ratchet), routers can't read body. Headers stay
    accessible (only authenticated via signature, not encrypted).
    That's how routing remains efficient under E2E encryption.
  - "Ergonomic helpers, plain strings underneath": Rust API exposes
    typed accessors (e.g. `envelope.body_hint() -> Option<&str>`
    reads `forge.body_hint`) without changing the wire format.
    Storage/transport see plain BTreeMap.

Sweep: all body_hint references through the doc (Subscription
examples, security PII tagging, presence announce, WebRTC signaling,
appendix C automation engine) now use the headers map shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@joelteply joelteply closed this May 18, 2026
@joelteply
joelteply deleted the docs/airc-rust-envelope-headers branch May 18, 2026 21:39
joelteply added a commit that referenced this pull request May 19, 2026
… (reopen of #658) (#662)

docs(airc-rust): replace single body_hint field with HTTP-style Headers dictionary

Per the real-time conversation with Codex + Joel: body_hint was the
right idea but the wrong shape. The clean primitive is a string-keyed
headers map on the envelope (HTTP analogy), not a single typed field.

Changes:

  - Envelope.body_hint (single optional field) → Envelope.headers
    (`BTreeMap<String, String>`)
  - Subscription.body_hint → Subscription.headers (header-keyed
    match patterns with Exact/Prefix variants)
  - Storage `messages.body_hint` column → `messages.headers` JSONB
  - Storage `subscriptions.body_hint_or_null` → `subscriptions.header_filters`

Namespace convention (no schema coordination needed):

  - airc.*       — substrate-owned: trace_id, priority, reply_to,
                   content_encoding, deadline, lease, auth_scope, pii
  - forge.*      — alloy/contract: body_hint (e.g. "forge.work.offer"),
                   requires_capability (e.g. "render.gpu"), persona.tier
  - continuum.*  — continuum-specific: persona_id, activity
  - openclaw.*, hermes.*, etc. — other consumer ecosystems
  - x-*          — experimental / private headers

BTreeMap chosen over HashMap for:
  - deterministic ordering (signatures + replay + diff-tests stable)
  - simple serialization (sorted keys, predictable JSON)
  - unknown-header pass-through (transports just copy the map)
  - no schema churn when middleware adds new headers

Rules added:

  - "Authority rule": routing/admission decisions trust the headers.
    Body MAY contain its own kind field as local ergonomics for
    consumers that already parse the body — substrate never consults
    body fields. Headers are canonical.
  - "Extensibility rule": consumers add new headers without
    coordinating with airc-rust. Other consumers ignore unknown
    headers.
  - "Encryption note": when body is encrypted under recipient key
    (double-ratchet), routers can't read body. Headers stay
    accessible (only authenticated via signature, not encrypted).
    That's how routing remains efficient under E2E encryption.
  - "Ergonomic helpers, plain strings underneath": Rust API exposes
    typed accessors (e.g. `envelope.body_hint() -> Option<&str>`
    reads `forge.body_hint`) without changing the wire format.
    Storage/transport see plain BTreeMap.

Sweep: all body_hint references through the doc (Subscription
examples, security PII tagging, presence announce, WebRTC signaling,
appendix C automation engine) now use the headers map shape.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 19, 2026
…odel (reopen of #659) (#663)

* docs(airc-rust): UUIDv4 for every internal identifier — mesh-native discipline

Per Joel's directive: "use the hell out of uuidv4 — uuid is so much
cleaner for the global nature of this system, literally p2p mesh based."

Adds an "Identifiers — UUIDv4 everywhere" section documenting the
identifier policy:

  - Every internal id (EventId, IdentityId, ClientId, ChannelId,
    RoomId, FileId, LeaseId, SubscriptionId) is UUIDv4
  - Non-negotiable for P2P mesh: peers generate locally without a
    coordinator, 122 bits of entropy makes collision negligible,
    privacy-friendly (no timestamp/MAC leakage)
  - Wire: serde encodes Uuid as the canonical hyphenated string for
    JSON envelopes + cross-language interop
  - Rust API: `uuid` crate, `Uuid::new_v4()` at generation,
    newtype wrappers (e.g. `EventId(pub Uuid)`) for compile-time
    type safety
  - What changes from existing airc-core: tighter typing
    (currently `EventId(pub String)`), parse-on-ingest (malformed
    id fails at envelope deserialization, not later in routing),
    clear policy
  - No alternative id schemes: no timestamp-prefixed ids, no
    human-hash-derived runtime ids (those stay for display nicks
    only), no content-addressed runtime ids (those are blobs only
    via ContentHash)

Inserted before "Names + identity" section since IDs underlie the
identity model.

Lands on canary independently — no dependency on the headers PR
(#658). Implementation work (changing the existing `EventId(String)`
newtypes to `EventId(Uuid)` and adding the uuid crate dep to
airc-core) follows as its own PR after this doc lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(airc-rust): names as mutable handles, UUIDs as identity

Per Codex's framing: human-readable names (#general, helper,
foundry-mac, forge.work.offer) remain throughout the system, but they
are mutable handles on top of immutable UUIDv4 identity.

A channel #general is displayed by name but referenced internally by
its ChannelId(Uuid). A peer "helper" is the same identity even after
a NICK rename. Renaming a forge contract from work.offer to work.bid
is a name-layer concern; the internal UUIDs that referenced it stay
valid.

Plus the full UUIDv4 application list (identities, channels/rooms,
envelopes/events, blob manifests, sessions/calls, commands/tasks,
replay fixtures, work leases) for clarity.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(airc-rust): three-field identity model (id + nick + role)

Per Codex's framing: an airc Identity carries three load-bearing
fields plus the existing display metadata.

  identity_id : 9d8c4f7e-... — UUIDv4, mesh-stable, immutable
  nick        : helper-ai     — mutable display, room-scoped, can collide
  role        : persona       — kind classifier (human|persona|agent|...)

The three are intentionally orthogonal:
  - identity_id is the cross-machine pointer (leases, permissions,
    audit, replay all cite this — never changes for life of identity)
  - nick is the human-readable handle (mutable, renames normal,
    collisions tolerable — substrate disambiguates via identity_id)
  - role is the kind classifier (consumer UI renders appropriately;
    substrate doesn't interpret beyond pass-through)

Folded as a subsection of "Names vs identity" within the UUIDv4
section since it's the concrete model the names-vs-identity rule
manifests as.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant