diff --git a/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol.md b/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol.md new file mode 100644 index 000000000..f0772cf3a --- /dev/null +++ b/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol.md @@ -0,0 +1,153 @@ +# Design: ID relay and proxy protocol + +- Date: 2026-11-08 +- Status: **decision for the relay-service boundary**; wire integration is gated on the parent and sibling contracts below. +- Issue: #5813, child of #5674; programme #2056. +- Scope: application relay/proxy roles, routing, delivery, resource bounds, and service scaling. No implementation changes are included here. + +## Decision + +Use an **ID-aware, end-to-end opaque relay service** with separate discovery/lookup and publish/home-relay roles. The service understands authenticated routing and resource-control metadata, but it is not the source of truth for ID messages and does not become a general-purpose durable message store. + +Direct connectivity remains the first path where available. A home relay can bridge a live connection while both sides are connected. Durable application facts remain in the signed event graph defined by #2036 and are recovered through its synchronization path; the relay does not retain and replay them. Transient live traffic is best-effort and is not queued for offline peers. + +Lookup and publication are distinct operations. A client may query a bounded set of lookup services concurrently and may publish the same signed presence/route advertisement to more than one configured home relay. Each home relay grants an independent, expiring registration lease; partial success is visible and does not imply that every configured relay is current. + +Relay queues and connection state are finite and volatile. Backpressure is explicit; a relay that cannot accept within its configured limits refuses or closes the affected stream rather than silently dropping data or growing an unbounded queue. A relay receipt confirms only the named transport step, never durable storage or application acceptance. + +This decision does **not** define another application envelope, change #2036's message-validity or retention rules, or settle the pending parent wire-format and adapter decisions. Those are integration constraints, not permission to fork their contracts. + +## 1. Boundaries and dependencies + +### Existing application contract: #2036 + +`doc/2026-11-01_design_id2036.md` already owns application-message classes, the immutable origin-signed envelope, member-relay validation-before-forward, hop/loop metadata, live-session semantics, durable graph retention, and the shared 1 MiB frame limit. This record consumes those decisions: + +- The relay service cannot make an invalid origin message valid, change its stable identity, or confer group membership. +- A member that forwards application messages still applies #2036's validation-before-forward and hop rules. This document does not create a second hop chain or a second message ID. +- Durable facts and checkpoints are recovered from the event graph; ephemeral live frames are not replayed after a disconnected session. +- Framing and checked chunking stay with the shared ID frame contract. No relay-specific chunking format is introduced. + +The parent issue #5674 is still OPEN and its remainder is in progress (task 12244 was freshly handed off when this record was prepared). This record chooses the relay-service boundary only. It does not decide the postcard envelope, adapter architecture, or any other parent-owned wire choice. + +### Sibling contracts + +Fresh issue state on 2026-11-08 showed #5808 OPEN/blocked on #5674, #5809 OPEN/queued, and #5810 OPEN/queued. Their decision records have not settled the shared schema, version negotiation, or carrier framing. Consequently: + +1. Relay control/data messages use the canonical envelope and framing selected by #5674, #5808, and #5810; this record allocates no discriminants, byte layout, or independent framing rules. +2. The version/capability negotiation and unknown-field behavior come from #5809. A relay must not silently discard a field that that contract marks critical. +3. The service behavior below is the decision to carry into those records. If a parent/sibling decision makes an interface detail incompatible, record the conflict explicitly on the relevant issue and revise this record additively; do not silently override the parent. + +Issue #5795 owns broker authorization, allowlists/capabilities, metadata minimization, and the compromised-broker ceiling. It was OPEN/parked at verification. This design consumes that trust contract rather than restating its authorization policy. The relay interface assumes end-to-end protected application payloads and exposes only the routing/control metadata necessary to operate; #5795 must settle the exact authorization and metadata surface. Issue #5815 is the subsequent cross-adapter security-binding review and was already in progress; this record does not pre-empt it. + +## 2. Relay roles + +### Lookup service + +A **lookup service** resolves a node or service identity to signed, time-bounded route advertisements. It is not the node's home, does not accept publication on the node's behalf, and does not own the returned identity or message. Its result is a set of candidates, not an authorization decision. The client verifies the advertisements and applies the normal ID trust and connection rules. + +Lookup is a replaceable service boundary: the protocol does not require one operator, one DNS zone, or `iroh.computer`. Public defaults may be convenient, but deployments can configure their own lookup services and relay set. Resolver discovery and default selection remain with #5674; this record requires only that lookup be addressable/configurable rather than hard-coded as an unreplaceable authority. + +For a lookup, query a configured, bounded fan-out concurrently rather than serially waiting on every endpoint. Merge valid responses until the caller's deadline, deduplicate equivalent signed advertisements, and prefer a usable direct route when one is available. A slow, unavailable, malformed, stale, or unauthorized response contributes no candidate and must not block other responses. The configured fan-out is finite and may be tuned by deployment; it is not a wire-format constant. + +### Publish/home relay + +A **home relay** is an endpoint to which a node publishes a signed, expiring route/presence advertisement and through which an authorized peer can establish a live proxied connection when direct connection fails. Registration, renewal, and withdrawal are authenticated under the capability/authorization rules owned by #5795. A route advertisement is not a message and does not grant authority to send one. + +The home relay holds a lease mapping an authorized identity/service to the currently reachable connection or endpoint. It may forward live traffic only while the relevant endpoint/session is connected and authorized. It may not turn that lease into durable message retention. Leases expire without renewal; client restart or relay restart requires a fresh publication. + +The relay may see the routing identifiers, endpoint/lease state, timing, traffic volume, and the protocol metadata required for resource enforcement. Application payloads remain opaque to it. The exact broker-observable metadata and capability checks are finalized by #5795 and reviewed across carriers by #5815. + +### Multiple relays + +Lookup sets and home-relay sets are configured independently; a node need not publish at every service it queries. + +- **Lookup:** issue bounded concurrent queries and combine verified answers. Do not make one lookup provider authoritative or force sequential traversal of the whole configured list on the critical path. Additional endpoints may be tried within the request deadline when the initial fan-out yields no usable result. +- **Publication:** a node may publish to multiple home relays. Publish/renew/withdraw independently to every configured home in parallel. Each successful response represents only that relay's lease. One successful home is sufficient to advertise the route through that home; failure of another is reported as partial/degraded publication, not hidden as full success. +- **Use and recovery:** peers may use any currently valid advertised home. If one home fails, try another valid advertisement or the direct route. Do not merge relay-local leases into a global truth claim. After all leases expire, the node is simply not discoverable through those homes until it republishes. + +This is active multi-home publication, not quorum publication: there is no global registry transaction or cross-relay consistency protocol. Independent signed advertisements and expiry make partial availability explicit without creating a central coordinator. + +## 3. Delivery, receipts, and retention + +The protocol distinguishes three events that must not be conflated: + +1. **Accepted by relay:** the relay admitted bytes into its bounded volatile forwarding window. This is not a delivery or persistence guarantee. +2. **Forwarded by relay:** the relay handed the bytes to the next live transport connection. This is not evidence that the destination parsed, authorized, or applied them. +3. **Acknowledged by destination application:** an end-to-end protocol response, when the message class defines one, says the destination reached that class's stated acceptance point. The relay cannot synthesize this acknowledgement. + +For a durable fact, the sender relies on the signed event and its application-level confirmation; a relay receipt is only a hop-level observation. If the recipient is offline or a live route disappears, the relay drops the volatile forwarding state. The sender/recipient later reconcile durable facts through the #2036 event-graph sync contract. The relay does not promise exactly-once delivery; retransmission and deduplication use the existing message identity and application semantics. + +For transient/live traffic, forwarding is best-effort only for the lifetime of the connected session. A disconnect can lose in-flight and uncheckpointed frames. No offline mailbox, disk spool, replay window, or relay-owned retention period is provided. This matches #2036's distinction: durable facts are retained by the event graph, while live frames do not become durable merely because they traversed a relay. + +Only route leases and bounded live connection/flow-control state are retained by the relay, in volatile memory and only until expiry or session close. Lease TTL/renewal values are deployment configuration negotiated under the shared version contract; payload retention is always zero. Restart loses leases and live sessions, after which clients reconnect and republish. There is no hidden disk-backed fallback. + +## 4. Backpressure and quotas + +Every implementation has finite limits at both connection and relay scope. Flow control uses explicit byte credit: a sender may not exceed the receiver's outstanding credit, and the relay returns credit only as bounded buffer space is released. A relay never reads an unlimited stream into memory while waiting for a slower destination. + +The required quota dimensions are: + +- maximum frame size, using the existing #2036 limit of 1 MiB (or a lower negotiated limit); +- maximum bytes in flight per proxied stream and aggregate per connection/identity; +- maximum concurrent proxied streams/connections per identity; +- maximum lookup fan-out and in-progress lookups per identity; +- maximum live home leases and renewals per identity; and +- aggregate relay memory/connection ceilings, with fair scheduling so one identity cannot consume the whole service. + +All limits are hard, finite, configurable deployment values. The protocol negotiates or reports the effective limits using the shared #5809/#5810 contract; it does not encode an unbounded default. A stream that exhausts credit pauses until credit returns. A request that exceeds a quota receives a typed resource-exhausted/refused outcome; it is not silently truncated, persisted, or retried forever. Repeated abuse may be throttled or disconnected under #5795's authorization/abuse policy. + +The frame cap is the only numeric limit fixed here because it is already owned by #2036. This record deliberately does not invent universal connection counts, memory budgets, or lease durations: those depend on deployment capacity and must be selected as finite configuration with the effective values observable to clients/operators. + +## 5. State model and scaling + +Choose **stateful-at-the-edge, stateless-across-relays**: + +- Each home relay keeps only in-memory identity-to-lease bindings, live connection/session bindings, and bounded flow-control buffers. +- A relay instance owns its active connection state. Requests for a live route must reach that instance (connection affinity or an equivalent local routing mechanism); there is no shared durable session database. +- Lookup can be replicated or load-balanced because it returns signed, expiring advertisements and does not own payloads or application truth. +- Multiple home relays provide explicit client-driven redundancy. They do not share lease or queue state. A relay restart loses only its own leases and live sessions; the client republishes/reconnects to the remaining homes. +- Durable message recovery remains peer/event-graph synchronization, not relay failover or queue replay. + +A wholly stateless proxy is rejected because live forwarding requires connection and flow-control state. A durable shared relay database is also rejected: it would make availability, retention, deletion, and broker compromise part of the application-data contract, duplicating the signed event graph and the separate #5795 trust design. + +## 6. Alternatives considered + +| Option | Decision | Reason | +| --- | --- | --- | +| Dumb opaque byte pipe with no ID-aware routing/control | Reject | It cannot distinguish lookup from home publication, enforce identity-scoped quotas, or report partial multi-home registration. Payload opacity is retained, but the service still needs authenticated routing and bounded resource control. | +| ID-aware relay with bounded live forwarding and expiring leases | **Choose** | Supports lookup/home-role separation, multiple independent homes, explicit receipts and backpressure, while keeping application validity and durable truth with ID peers. | +| Durable store-and-forward broker for all traffic | Reject | Duplicates event-graph retention/sync, creates deletion and replay obligations, and makes broker storage/trust part of message validity. Live traffic is intentionally not replayed. | +| One mandatory home relay/provider | Reject | Creates a discovery and availability single point of failure and prevents private/self-hosted deployments. | +| Fully stateless relay with no session state | Reject | Cannot implement live connection mapping or bounded per-stream flow control. Keep the state local, volatile, and bounded instead. | + +## 7. Invariants and implementation acceptance + +1. **No new authority:** a route, relay receipt, transport identity, or successful lookup never grants membership or changes the validity of an origin-signed message. +2. **One application contract:** member forwarding, message IDs, hop limits, event retention, and live/durable classification follow #2036; this service adds no competing envelope or hop metadata. +3. **Separate roles:** lookup-only endpoints do not become home relays; publication to a home does not make it the global discovery authority. +4. **Explicit multi-home state:** each home lease succeeds, fails, renews, and expires independently; partial publication cannot be reported as full publication. +5. **Honest receipts:** relay acceptance/forwarding receipts are hop-local; only the destination application can produce an application acknowledgement. +6. **No relay payload retention:** data-plane buffers are volatile and bounded. Offline durable catch-up uses the event graph; offline live frames may be lost. +7. **Bounded resources:** every queue, stream, lookup, lease set, connection, and aggregate buffer has a finite cap and an explicit refusal/backpressure path. +8. **Restart is recoverable:** after relay restart, clients can detect expired/lost leases and republish; no durable message is lost solely because it was entrusted to a relay queue, because no such queue exists. +9. **Version and framing are shared:** unknown critical fields are handled per #5809; carrier framing and size limits follow #5674/#5810/#2036. No silent downgrade or relay-specific chunking is introduced. +10. **Security contract is reviewable:** broker authorization and metadata exposure are specified by #5795 and cross-adapter security binding by #5815 before implementation freezes those surfaces. + +The implementation/conformance work should test concurrent lookup with an unavailable endpoint, multi-home partial publication and lease expiry, duplicate advertisements, slow-consumer credit exhaustion, quota refusal, disconnect loss of live frames, restart/republication, and the separation between relay receipts and destination acknowledgements. #5814 owns the broader adapter conformance/interop matrix. + +## 8. Decision ledger and follow-up + +- **No parent decision is changed.** #5674 remains the owner of the shared wire-format family, transport-adapter model, resolver defaults, and any parent-level discovery decision. This record contributes the relay service boundary and makes relay lookup configurable/self-hostable rather than selecting a global resolver. +- **No #2036 decision is changed.** Its application envelope, member-relay validation, hop/loop rules, durable event graph, live-session behavior, and frame cap remain authoritative. +- **No #5795 trust policy is duplicated.** Broker identity/capability rules, allowlists, metadata minimization, and compromised-broker analysis remain for #5795; this design requires those decisions to bind the relay operations above. +- **No wire details are preempted.** #5808, #5809, and #5810 must map these operations onto the shared message schema, negotiation, and framing. Their currently blocked/queued state is an integration gate, not a reason to silently invent a second format here. +- **Review order:** carry this contract to #5815 for the planned security-binding review and to #5814 for conformance coverage. The security review should confirm the opaque-payload and metadata assumptions against #5795 before implementation interfaces are frozen. + +## Evidence map + +- #5813 body and its 2026-11-05 parent cross-link comment: distinct relay/proxy design; relay lookup vs. publish/home roles and multi-relay behavior. +- #5813 task 10216 triage (comment `issuecomment-6662324895`) and task 12313 triage (comment `issuecomment-6717275182`): the design is additive to #2036, consumes #5795, aligns with #5808–#5810, and was re-verified as real/current and not gated on 2026-11-08. +- #5674 comments `issuecomment-6647788157` and `issuecomment-6662707975`: original multi-relay questions and the parent-level ordering/boundary relative to #2036. +- `doc/2026-11-01_design_id2036.md`: existing application relay, message lifecycle, framing, and retention contract. +- Fresh GitHub state checked 2026-11-08: #5674 OPEN/parked with task 12244 handed off; #5808 OPEN/blocked; #5809 and #5810 OPEN/queued; #5795 OPEN/parked; #5815 OPEN/in progress. These states are recorded to expose integration order, not to claim that the sibling decisions have landed. diff --git a/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-09T00-07-24Z_design_id5813_relay_proxy_protocol_transport_boundary_clarification.md b/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-09T00-07-24Z_design_id5813_relay_proxy_protocol_transport_boundary_clarification.md new file mode 100644 index 000000000..fcc89fe80 --- /dev/null +++ b/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-09T00-07-24Z_design_id5813_relay_proxy_protocol_transport_boundary_clarification.md @@ -0,0 +1,26 @@ +# Addendum: transport broker boundary for the ID relay/proxy protocol + +- **Date:** 2026-11-09 (UTC) +- **Status:** Dated clarification to the original decision record; it does not replace that record. +- **Issue:** [#5813](https://github.com/developing-today/code/issues/5813) +- **Original decision:** [ID relay and proxy protocol](./2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol.md) +- **Scope:** Clarify the relationship to #5671/#5791 and record the current integration status. No implementation or wire-format decisions are added. + +## Transport broker boundary + +The transport fallback contract in #5671, refined by #5791, defines its broker/relay as a dumb authenticated pipe for opaque end-to-end-encrypted traffic. It does not provide ID lookup, presence publication, or application routing. + +The ID-aware lookup/home-relay service chosen in the original #5813 decision is a **distinct application-level role**. It may be reached over a #5791 transport, and an operator may host both roles, but they remain separate protocol layers: the transport broker forwards opaque bytes; the #5813 service handles only the minimum routable/control metadata allowed by #5795. It must not terminate application payloads or hold content keys. Co-hosting remains subject to #5795 authorization and #5815 security-binding review. + +This distinction does not change #5671's broker shape, #5791's fallback order, or the original #5813 choice of volatile live forwarding, independent multi-home leases, and no relay message retention. Durable catch-up remains the #2036 event-graph sync path. + +## Integration status snapshot + +GitHub state checked **2026-11-09 00:06 UTC**: + +- #5674 remains open; its shared wire and adapter decisions are not settled by this addendum. +- #5808 is open/blocked; #5809 and #5810 are open/parked. Their schema, negotiation, and framing decisions remain delegated to those issues. +- #5795 is open/blocked; this addendum does not define broker authorization or metadata policy. +- #5815 is open/in review; its security-binding decision remains subsequent. + +These are point-in-time integration states, not additional protocol decisions. No #2036 decision is changed. If a later parent or sibling decision is incompatible with #5813, record and reconcile that conflict before implementation. diff --git a/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-10T06-54-33Z_design_id5813_relay_proxy_protocol_sibling_alignment.md b/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-10T06-54-33Z_design_id5813_relay_proxy_protocol_sibling_alignment.md new file mode 100644 index 000000000..a7cd500a7 --- /dev/null +++ b/doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-10T06-54-33Z_design_id5813_relay_proxy_protocol_sibling_alignment.md @@ -0,0 +1,44 @@ +# Addendum: sibling contract alignment for the ID relay/proxy protocol + +- **Date:** 2026-11-10 (UTC) +- **Status:** Dated clarification to the original decision record; it does not replace that record. +- **Issue:** [#5813](https://github.com/developing-today/code/issues/5813) +- **Original decision:** [ID relay and proxy protocol](./2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol.md) +- **Prior addendum:** [transport-boundary clarification](./2026-11-09T00-07-24Z_design_id5813_relay_proxy_protocol_transport_boundary_clarification.md) +- **Scope:** Re-check the sibling design state and record how the relay/proxy contract consumes the current schema, framing, and security-binding proposals. No protocol decision is changed. + +## Sibling state re-check + +GitHub state checked **2026-11-10 06:54 UTC**: + +| Issue | State | Decision record | +| --- | --- | --- | +| #5674 (parent) | OPEN | no parent record landed; shared envelope/adapter choices still delegated | +| #5808 (postcard schema) | OPEN/blocked | none | +| #5809 (versioning/negotiation) | OPEN/parked | none | +| #5810 (framing/fragmentation) | OPEN/in review | proposal in PR #7980, not merged | +| #5795 (broker trust contract) | OPEN/blocked | none | +| #5815 (security binding) | OPEN/in review | proposal in PR #7863, not merged | + +None of these is a landed decision. The original record's rule therefore still applies: relay control/data messages use the canonical envelope, negotiation, and framing selected by the parent and siblings, and this record allocates no discriminants, byte layout, or independent framing. + +## Framing alignment (#5810 proposal) + +The #5810 proposal in PR #7980 carries **one canonical serialized postcard frame** across carriers: length-prefixed stream frames, whole-frame-or-checked-chunk datagram assembly, and opaque-object-or-checked-chunk store-and-forward assembly. That is compatible with this record as written: + +- A relay forwards the canonical frame bytes unchanged; it does not re-frame, re-encode, or reinterpret them, and it adds no relay-specific chunking. Carrier deframing and checked-chunk reassembly remain the adapter's responsibility under #5810, before any ID decode. +- The 1 MiB frame cap is shared and unchanged. A relay's byte-credit limits operate on frames and streams, not on a new message-size rule. +- #5810's **store-and-forward carrier class** and this record's **rejected durable relay retention** are different things: the carrier class stores canonical frames at an adapter's storage endpoint, while the relay service keeps zero payload retention and performs no offline mailbox, disk spool, or replay. PR #7980 states the same split and leaves relay queue/retention policy to #5813. No conflict. + +If #5810's merged wording changes carrier framing in a way that cannot carry the relay's opaque frame-forwarding unit, reconcile that additively here or in #5810 before implementation. + +## Security-binding alignment (#5815 proposal) + +The #5815 proposal in PR #7863 binds session security to the ID layer (origin signature, handshake transcript, local policy floor), classifies downgrade as a security failure, and states that relays cannot re-originate traffic. This record's invariants already require the same outcomes: relay acceptance/forwarding receipts are hop-local, only the destination application acknowledges, and a relay never becomes message authority. The proposal adds binding mechanisms without changing the relay-service choices. #5815 remains the review owner for the security binding, and #5795 still owns broker authorization metadata; this record neither duplicates nor pre-empts either. + +## Decision ledger + +- **No #2036 decision is changed.** Envelope, validation-before-forward, hop/loop rules, durable graph, live-session behavior, and the 1 MiB frame cap remain authoritative. +- **No #5674 decision is changed.** The parent still owns the wire-format family, adapter model, resolver defaults, and the final size/extension rules. +- **No sibling decision is pre-empted.** #5808/#5809 have no record; #5810 and #5815 have open proposals only. Their outcomes bind the relay operations by reference, not by a rewritten copy of their contracts. +- **No trust policy is duplicated.** #5795 continues to own authorization, allowlists/capabilities, metadata minimization, and the compromised-broker ceiling. diff --git a/planning/architecture/README.md b/planning/architecture/README.md index 57f9c0047..93d365212 100644 --- a/planning/architecture/README.md +++ b/planning/architecture/README.md @@ -67,6 +67,9 @@ records. - [Knowledge-layer sharing and permissions](../../doc/2026-11-08T08-19-40Z_design_id_knowledge_sharing_permissions/2026-11-08T08-19-40Z_design_id_knowledge_sharing_permissions.md) - [Permission UX for worlds: pre-connect disclosure, grant modes, and memory](../../doc/2026-11-08T09-06-08Z_design_id_permission_ux/2026-11-08T09-06-08Z_design_id_permission_ux.md) - [Capability observability: who can see which capability facts, where](../../doc/2026-11-08T10-40-00Z_design_id_capability_observability/2026-11-08T10-40-00Z_design_id_capability_observability.md) +- [ID relay and proxy protocol (#5813)](../../doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol.md) +- [ID relay/proxy transport-boundary clarification (#5813)](../../doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-09T00-07-24Z_design_id5813_relay_proxy_protocol_transport_boundary_clarification.md) +- [ID relay/proxy sibling contract alignment (#5813)](../../doc/2026-11-08T11-08-53Z_design_id5813_relay_proxy_protocol/2026-11-10T06-54-33Z_design_id5813_relay_proxy_protocol_sibling_alignment.md) - [Server-side invariants: budgets, observability, exploit resistance, containment](../../doc/2026-11-09T05-15-00Z_design_id_server_invariants/2026-11-09T05-15-00Z_design_id_server_invariants.md) - [Two-level metering: burst bucket + hard per-tick ceiling, per function](../../doc/2026-11-10T03-10-00Z_design_id_two_level_metering/2026-11-10T03-10-00Z_design_id_two_level_metering.md)