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.

Activity

  1. added
    source/creatorFiled by the new-issue-creator job
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    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/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  6. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 5, 2026
  7. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  8. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  9. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  10. 81 remaining items

  11. dezren39 commented on Nov 9, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    task 13844 (queue) — issue #5674 — picked up by lane code-m, execution lane assigned: opencode (lane row 5245). Handing off to the opencode claimant.
    Fresh revalidation (2026-11-09T01:31Z): issue #5674 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels. Remaining scope per task 13844: revalidate issue #5674 and all named PR state, then determine the remaining scoped work on the wire-format/transport-adapters design remainder.

  12. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · child decision record cross-reference (no parent decision changed)

  13. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    state: triaged
    task: 13844
    lane: code-f
    issue: #5674

    Task 13844 completes as triaged, naming the existing triage — not redoing it. The triage of this issue was completed on 2026-11-05 (task 10107 findings, posted on this issue) and re-verified fresh on 2026-11-07: #5674 stays open as the parent design for the wire-format / transport-adapter expansion, its decomposition sketch is filed as eight child design tickets (label app/id), and the design work proceeds through those children — most recently the #5809 versioning/negotiation decision record, opened today as PR #8199 and cross-referenced here by lane code-g. Fresh check by lane code-f confirms: issue #5674 OPEN, no hard-stop labels, parent #2036 still OPEN, status/triaged already applied. No new fix packet is enqueued from this task: the remaining scope is the children's, each already tracked as its own issue.

  14. added
    epic/id-programReprioritization program epic (2026-11-12)
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 10, 2026
  15. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    Agent note (lane code-b, task 12892): child decision record for #5808 opened for this parent — one named deviation for the parent's record to adopt, amend, or reject in the open.

  16. 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.

  17. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

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

  18. removed their assignment
    on Nov 20, 2026
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/idPackage/app: id (pkgs/ or apps/ in this repo)epic/id-programReprioritization program epic (2026-11-12)source/creatorFiled by the new-issue-creator jobstatus/triagedTriaged and routed (see agent note)task/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions