Skip to content

id: design: Wire format & transport adapters — postcard schema, non-UDP carriers, relays/proxies #5674

Open

Description

@dezren39

Extends #2036 (ID messaging/relay protocol v1). This is an EXPANSION design: it does not replace #2036, it defines the concrete wire format #2036 assumes and the adapter family that lets ID run where native iroh/UDP cannot.

Problem

#2036 designs messaging/relay at the protocol level, but leaves open: (a) the exact bytes on the wire, (b) how ID traffic crosses interfaces that cannot natively speak the iroh UDP protocol, and (c) how relays/proxies behave as standard, high-performance infrastructure rather than ad-hoc fallbacks. Without a frozen wire contract, every adapter and every implementation invents its own framing and versioning, and forward compatibility becomes guesswork.

Goal

One canonical postcard wire schema for ID, versioned and forward-compatible, plus a family of transport adapters that carry the same ID payloads unchanged over non-UDP interfaces, with relays and proxies specified as first-class standard protocols.

Feature set — full expansion

1. Canonical postcard wire schema

  • Define the exact postcard (serde / postcard crate) schema for every ID message type carried by id: design: ID messaging/relay protocol v1 #2036: envelope, handshake/identity, direct message, relayed message, control/keepalive, error, and capability negotiation.
  • Envelope fields: schema major/minor, message type discriminator, sender/recipient IDs, stream/sequence identifiers, timestamp/clock fields, payload length, flags (compressed, encrypted, fragmented), and extension/TLV area.
  • Serialization rules: field ordering, varint encoding, optional-field encoding, maximum message size, fragmentation and reassembly when a carrier has a smaller MTU.
  • No silent coercion: unknown discriminators, truncated frames, and oversized payloads have defined error behaviour.

2. Versioning and forward-compatibility rules

  • Version negotiation at connection/session start: peers advertise supported schema range and adapter capabilities; the session settles on the highest mutually supported version.
  • Forward-compat contract: additive optional fields are ignorable by older readers; readers MUST preserve/forward unknown extension data where relaying; breaking changes require a major bump and a dual-stack transition window.
  • Deprecation policy: how a field/type is deprecated, how long both forms are accepted, and how conformance tests enforce it.
  • Golden vectors: published byte-for-byte test vectors for each message type at each supported schema version, so non-Rust implementations can prove compatibility.

3. Framing per carrier class

  • Length-prefixed framing for stream carriers (TCP, WebSocket, Unix sockets, stdio/pipes).
  • Datagram framing for packet carriers (UDP/iroh native path, WebRTC data channels, QUIC datagrams).
  • Chunking for constrained / store-and-forward carriers (HTTP request/response, file drop, QR / sneakernet-style transfer, email/SMS-sized payloads if ever used) — including reassembly, deduplication, and out-of-order tolerance.

4. Transport adapters (same payload, many carriers)

Adapters MUST NOT change ID semantics; they only carry frames. Initial adapter set to design:

  • Native iroh/UDP (the baseline, from id: design: ID messaging/relay protocol v1 #2036).
  • WebSocket / WSS (browser clients, networks that only allow 443).
  • Plain HTTPS long-poll / streaming (most restrictive web environments, corporate proxies).
  • WebRTC data channel (browser-to-browser without a relay in the middle).
  • TCP direct and TCP-over-TLS.
  • Unix domain socket / named pipe (local IPC, terminal and daemon co-location).
  • Bluetooth LE / local-network (mDNS/Bonjour discovery) for offline / LAN-only operation, if feasible within payload limits.
  • Store-and-forward file/message-queue carrier (e.g. object storage, a message queue) for intermittently connected nodes.
    Each adapter spec covers: discovery/addressing, connection lifecycle, MTU/fragmentation, ordering and reliability guarantees (and how gaps are surfaced to the layer above), NAT/firewall traversal, and how identity/authentication from id: design: ID messaging/relay protocol v1 #2036 binds to the carrier (e.g. TLS is transport encryption only, never a substitute for ID end-to-end identity).

5. Relays and proxies as first-class standard protocols

  • Relay protocol as a standard, implementable by third parties: relay handshake, authentication/authorization of relayed traffic, quota/rate-limit signalling, relay discovery and selection, multi-hop relaying, and relay health/latency advertisement.
  • Proxy modes: dumb byte-pipe proxy (no ID awareness), ID-aware relay (routes on envelope only, cannot read payloads), and store-and-forward relay (holds messages for offline recipients with defined retention and delivery receipts).
  • High-performance requirements: zero-copy forwarding where possible, connection pooling/multiplexing, backpressure signalling end-to-end (a slow recipient must not OOM a relay), and horizontal scaling of relay fleets (stateless forwarding vs. sticky sessions — pick and justify).
  • Privacy: relays learn the minimum metadata possible; specify exactly which envelope fields a relay may see and which are end-to-end encrypted.

6. Security binding

  • End-to-end encryption and signing sit above the wire schema and below no adapter: an adapter compromise cannot forge ID identity.
  • Replay protection (sequence/nonce rules), downgrade protection (an attacker forcing an old schema version or a weaker carrier must be detectable), and explicit rules for mixing encrypted and plaintext carriers.

7. Observability and diagnostics

  • Standard per-adapter metrics: bytes/frames, latency, error classes, negotiation outcomes, version distribution.
  • A diagnostic/trace frame type (opt-in, authenticated) for id ping-style path debugging across relays and adapters.

Conformance tests (required per adapter)

  • Golden-vector encode/decode tests for every message type and schema version.
  • Round-trip property tests: arbitrary valid payloads survive encode → adapter → decode unchanged.
  • Interop matrix tests: every adapter pair can exchange the same session (client on adapter A, peer on adapter B, via relay if needed).
  • Negative tests: truncated, oversized, unknown-version, and unknown-type frames fail in the specified way, never panic or hang.
  • Fragmentation/reassembly tests at carrier MTU boundaries; out-of-order and duplicate delivery tests for store-and-forward adapters.
  • Version-negotiation tests: old peer + new peer settle correctly and never silently corrupt.
  • Performance baselines per adapter (throughput/latency envelope) so a regressing adapter is caught in CI.

Non-goals

  • Re-designing the messaging semantics of id: design: ID messaging/relay protocol v1 #2036 itself.
  • Choosing a single "winner" carrier — plurality of adapters is the point.
  • Application payload formats above the ID envelope (chat, boards, notes have their own designs).

Decomposition sketch

Follow-on design tickets to be filed from this issue (each then breaks into implementation tickets):

  1. Postcard wire schema v1 — envelope, discriminators, golden vectors.
  2. Versioning, negotiation & forward-compatibility policy.
  3. Framing & fragmentation spec for stream, datagram, and store-and-forward carrier classes.
  4. Adapter spec: WebSocket/WSS + HTTPS fallback (browser/restrictive-network path).
  5. Adapter spec: WebRTC, TCP/TLS, and local IPC (Unix socket / named pipe).
  6. Relay & proxy standard protocol — ID-aware relay, store-and-forward relay, scaling/backpressure.
  7. Adapter conformance test harness & interop matrix CI.
  8. Security binding review — replay/downgrade protection across adapters and relays.

Open questions

  • Is postcard definitively the encoding for all carriers, or do browser-facing adapters need a JSON/CBOR diagnostic variant of the same schema?
  • What is the maximum canonical message size, and who owns fragmentation — the wire layer or the messaging layer in id: design: ID messaging/relay protocol v1 #2036?
  • How much metadata may an ID-aware relay legitimately see, and is envelope encryption (hiding routing metadata) in scope for v1 or deferred?
  • Which constrained/store-and-forward carriers are real requirements vs. speculative (file drop? queues? BLE?) — cut the adapter list to what will actually be built first.
  • Relay operation model: first-party fleet only, federated third-party relays, or both — and what trust/quotas does each imply?
  • Do we need a wire-schema registry/version catalogue published outside the repo for third-party implementers?

Program note: expansion-style design — a later pass breaks this into the follow-on design tickets above, then implementation tickets. Relatives: #2036.

Acceptance criteria

  • A design record (on this issue or a linked doc/PR) freezes the canonical postcard wire schema for ID messages, with versioning and forward-compatibility rules stated.
  • Framing is specified per carrier class, and each transport adapter carries the same ID payloads unchanged over its non-UDP carrier.
  • Relays and proxies are specified as standard protocols (not ad-hoc fallbacks), with the security binding and observability/diagnostics surfaces defined.
  • The conformance tests named in the body are specified per adapter, and follow-on implementation issues are filed and linked for the adapters the design calls for.

Activity

  1. added
    source/creator
    app/id
    on Nov 4, 2026
  2. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Gap pass (WS-F, 2026-11-04): this issue's decomposition sketch is now filed.

    Each follow-on design ticket named in the sketch above was filed as its own issue (label app/id), so the acceptance item “Follow-on design tickets filed from the Decomposition sketch” can now be checked:

    Exception, where applicable: any sketch item already answered by a later filing is noted in the pass worklog rather than duplicated. Design prioritisation is now independent per ticket; implementation timing is a separate decision.

  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Raw-conversation cross-link (WS-F2 mining pass, 2026-11-04). Relay/DNS semantics questions in Drew's words, from the peer-discovery plan review — this design's relay section should answer them explicitly:

    "can i enable multiple relays and does it try them all concurrnetly or one by one?(maybe there is a difference between relays to check to find nodes vs relay im published on can i be published on multiple? is the dns resolution thing something others can run or just iroh.computer)"
    — OpenCode session ses_2ec427b80ffeuCx6dCuANmiN6c ("Peer discovery plan review"), 2026-03-23

    Three concrete requirements buried in that one breath:

    1. Relay roles are distinct. A relay used to look up other nodes and the relay a node is published on (its home relay) are different jobs; the design should name them separately instead of treating "relays" as one undifferentiated list (the build-time defaults work in id: design: build-time defaults file — embed network defaults from an optional JSON file instead of only hardcoded consts #5916 also needs this distinction — a defaults file that can't tell lookup relays from publish relays can't express a private-network build).
    2. Multi-relay behaviour is specified. When several relays are configured: are lookups tried concurrently or sequentially (latency vs. chatter), and can a node be published on more than one relay at once (redundancy vs. split presence)?
    3. Discovery DNS is self-hostable, or the design says why not. The pkarr/DNS resolution path should not silently depend on one operator's infrastructure (iroh.computer); if ID nodes can run their own resolver/discovery service, that is a designed component, and if they cannot, the dependency is stated as a boundary.

    The same session also asked "can mdns be enabled?" — that half landed in code (mDNS address lookup is wired in the peers command, with a --no-mdns opt-out), which is why this comment carries only the relay/DNS remainder.

  4. added
    work/assigned
    queue/parked
    status/parked
    on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  6. added
    queue/queued
    task/triage
    on Nov 5, 2026
  7. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  8. removed
    queue/queued
    on Nov 5, 2026
  9. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  10. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  11. 93 remaining items

  12. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged — already triaged; parent design issue, children progressing

    Finding: this design issue was already triaged — task 10107's triage on 2026-11-05, re-verified 2026-11-07, and task 13844 completed as triaged on 2026-11-10 naming it. Nothing about that disposition has changed:

    Task 18331 completes as triaged.

  13. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Agent note — task 19860 triaged (lane any-t): concurrence with the triage of record

  14. removed their assignment
    on Nov 20, 2026
  15. added a commit that references this issue on Nov 23, 2026
  16. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    Second-pass verdict (openchamber lane oc-code-03, queue task 22841, 2026-11-24)

    Fresh state: #5674 OPEN, status/triaged, no hold labels. The 2026-11-17 triage of record still holds: a parent design decomposed into child design tickets under #2036. No new packet is routed.

  17. developing-today-fleet commented on Nov 26, 2026

    @developing-today-fleet
    Contributor

    agent-note:v1
    state: verified -> triaged
    task: 24864
    issue: #5674
    lane: code-i
    worker: repo-worker-code
    origin: openchamber-scheduled-lane

    Fresh revalidation (2026-11-26): #5674 OPEN, status/triaged, no hold labels — triage of record still holds. Parent design for the wire-format/transport-adapter expansion. Movement since the 2026-11-24 pass: grandparent #2036 and child decision records #5808/#5809/#5810 are now CLOSED, but live follow-ons still reference this parent — notably #13929 (transport adapter contract, multi-transport head) and #13926 (multi-transport reach epic), plus #5753 and #13880. Stays open as parent; no new packet routed. No code changed in this pass.

  18. developing-today-fleet commented on Nov 27, 2026

    @developing-today-fleet
    Contributor

    Triage concurrence (lane oc-code-01, 2026-11-27): #5674 OPEN, status/triaged, no hold labels. Triage of record still holds: parent design for wire-format/transport-adapter expansion, decomposed to child designs.

    Fresh delta since task 24864 (2026-11-26): grandparent #2036 is now CLOSED (2026-11-26); child decision records #5808/#5809/#5810 remain CLOSED. Live follow-ons referencing this parent remain OPEN: #13929, #13926, #5753, #13880. Stays open as parent tracker; no new packet routed from this task, no code changed.

  19. developing-today commented on Nov 27, 2026

    @developing-today
    Contributor

    Triage concurrence (OpenChamber scheduled lane oc-code-05, 2026-11-27): fresh revalidation confirms #5674 remains OPEN, already status/triaged, with no hold labels. Parent protocol #2036 is now CLOSED; live related follow-ons remain OPEN: #13929 (transport adapter contract), #13926 (multi-transport reach), #5753 (KDL stack research/design), and #13880 (ID apps graph). Existing disposition still holds: keep #5674 as the parent tracker for its wire-format/transport-adapter scope while related follow-ons progress. No new fix packet is appropriate; no code changed.

  20. developing-today-fleet commented on Nov 28, 2026

    @developing-today-fleet
    Contributor

    Triage recheck — lane oc-code-01, 2026-11-28 ~03:15Z. Verdict unchanged: design expansion, no immediate code fix; requires follow-on design tickets (1, 2, 3-8) to land before implementation.

  21. added
    kind/design
    priority/normal
    on Nov 29, 2026
  22. dezren39 commented on Nov 29, 2026

    @dezren39
    MemberAuthor

    🤖 Census note — 2026-11-29 (lane CEN-C04, full-census pass)

    Verdict: ready (design parent, decomposed). Rechecked firsthand. Parent protocol #2036 is CLOSED; child decision records #5808/#5809/#5810 are CLOSED. Live follow-ons carrying the implementation: #13929 (transport adapter contract), #13926 (multi-transport reach epic), #5753 (KDL stack), #13880 (ID apps graph). Blockers: none on this issue — implementation proceeds through the follow-ons; this parent closes when they land or are dispositioned.

    Census actions: added labels kind/design, priority/normal.

  23. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Census 2026-11-29 (Felix):

  24. added
    effort/l
    on Nov 29, 2026
  25. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Issue census — 2026-11-29

    Gaps found: no effort/* label and no acceptance criteria section (the body has Problem / Goal / feature set / conformance tests / non-goals / decomposition, but nothing a picker-up can check completion against).
    Strengths: thorough design brief — the wire-schema, versioning, per-carrier framing, adapter family, relay/proxy protocols, security binding and observability are all scoped, with conformance tests required per adapter and its parent (#2036) relationship stated.
    Actions: added label effort/l; appended a ## Acceptance criteria section derived from the body's own deliverables (original text untouched). Priority unchanged (normal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/ideffort/lepic/id-programkind/designpriority/normalsource/creatorstatus/triagedtask/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions