Skip to content

docs: deliver epoch keys over iroh QUIC (cdn/keys/v1) - #47

Closed
thiras wants to merge 2 commits into
mainfrom
feat/quic-key-delivery
Closed

thiras wants to merge 2 commits into
mainfrom
feat/quic-key-delivery

Conversation

@thiras

@thiras thiras commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace WebSocket/SSE epoch key delivery in ADR 006 with a new cdn/keys/v1 ALPN over iroh QUIC, eliminating the second transport stack flagged in ADR 006: WebSocket/SSE for epoch keys adds significant unspecified app server component #26
  • Define protocol messages (KeySessionOpen, EpochKeyUpdate, EnvelopeRequest, etc.) using two QUIC stream patterns: long-lived epoch key push + short-lived envelope request/response
  • Add cdn/keys/v1 to ADR 005 (ALPN table, stream limits, connection lifetime) and update architecture.md and CLAUDE.md
  • Also adds previously missing cdn/watchtower/v1 to architecture.md and CLAUDE.md ALPN tables

Closes #26

Test plan

  • Review ADR 006 mermaid diagrams render correctly
  • Verify all cross-references between ADR 005, 006, 007, and architecture.md are consistent
  • Confirm no stale WebSocket/SSE references remain (only in consequence notes explaining the migration)

🤖 Generated with Claude Code

…iroh QUIC, closes #26

The app server now runs as an iroh peer with its own NodeId and serves
epoch keys + sealed envelopes over a dedicated ALPN (cdn/keys/v1),
eliminating the need for a second transport stack.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings March 30, 2026 18:16

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the CDN architecture and protocol documentation to formally define the cdn/keys/v1 and cdn/watchtower/v1 protocols. Key changes include replacing WebSocket-based key delivery with a long-lived iroh QUIC stream for epoch keys and sealed envelope requests. The documentation now details the specific protocol messages, authentication mechanisms using session tokens and NodeIds, and stream concurrency limits. One piece of feedback suggests removing the client_pubkey from the KeySessionOpen message, as it is redundant with the identity already provided by the underlying QUIC connection.

Comment thread adr/006-e2e-encryption.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the ADR documentation to move epoch key delivery from WebSocket/SSE to an iroh QUIC protocol (cdn/keys/v1), reducing the system to a single transport stack and aligning the wire-protocol/architecture docs accordingly.

Changes:

  • Introduce and document cdn/keys/v1 (ALPN) for long-lived epoch key push plus short-lived sealed-envelope request/response streams (ADR 006).
  • Update ADR 005 protocol tables for cdn/keys/v1 (ALPN list, stream limits, connection lifetime exception).
  • Update architecture-facing docs (architecture.md, CLAUDE.md) to include cdn/keys/v1 and the previously missing cdn/watchtower/v1.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
adr/architecture.md Updates the architecture overview to include cdn/keys/v1 and cdn/watchtower/v1, and revises the encryption/key distribution description to reference QUIC key delivery.
adr/006-e2e-encryption.md Replaces WebSocket/SSE key delivery with a cdn/keys/v1 QUIC-based protocol, adds message definitions and stream patterns, and updates diagrams/flows accordingly.
adr/005-protocol.md Adds cdn/keys/v1 to the ALPN/protocol decision tables and defines stream/connections parameters for the new protocol.
CLAUDE.md Updates the ALPN/protocol table to include cdn/keys/v1 and cdn/watchtower/v1 for repository guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adr/005-protocol.md Resolved
Comment thread adr/architecture.md Resolved
Comment thread CLAUDE.md Resolved
Comment thread adr/architecture.md Resolved
Comment thread adr/006-e2e-encryption.md Resolved
Comment thread adr/006-e2e-encryption.md Resolved
…LPN/gossip wording, clarify stream vs connection

- Remove client_pubkey from KeySessionOpen; server derives X25519 key from NodeId
- Clarify "four ALPN protocols + iroh-gossip" (gossip isn't ALPN-negotiated)
- Fix architecture.md to say "closing the stream" not "closing the connection"
- Update section heading to reflect session + per-request nature

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
thiras added a commit that referenced this pull request Mar 31, 2026
Moves the detailed cdn/keys/v1 spec from PR #47 into this batch fix:
- ADR 006: Full protocol messages (KeySessionOpen, EpochKeyUpdate,
  EnvelopeRequest/Response), app server as iroh Endpoint, dual-stream
  pattern, authentication model, concurrent session limiting
- ADR 005: cdn/keys/v1 in ALPN table (five protocols), stream limits
  (10: 1 epoch + 9 envelopes), connection lifetime exception
- architecture.md: cdn/keys/v1 in ALPN table, updated ADR 006 summary
- CLAUDE.md: cdn/keys/v1 and cdn/watchtower/v1 in ALPN table

Supersedes #47

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

thiras commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #85 — the cdn/keys/v1 protocol detail (message types, stream patterns, authentication model, app server description) has been integrated into the batch fix PR.

@thiras thiras closed this Mar 31, 2026
thiras added a commit that referenced this pull request Mar 31, 2026
…85)

* docs: add design spec for separated node/content discovery

Replaces CacheAnnounce gossip with probe-based content discovery,
resolving issue #25 (Bloom filter parameter problems) by eliminating
Bloom filters and hash list broadcasts entirely.

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

* docs: address review feedback on discovery design spec

- Fix local demand tracking: use VecDeque<u64> timestamps instead of
  (count, last_seen) to support sliding window threshold
- Fix network popularity tracking: store per-peer announcement timestamps
- Clarify routing table removal vs probe cache distinction
- Fix architecture.md path reference to adr/architecture.md
- Reword privacy trade-off: popularity is a new gossiped signal,
  content availability is now probe-discoverable only
- Note probe cache TTL overlap with slashing evidence window

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

* docs: add implementation plan for separated discovery ADR updates

Plan covers updates to ADR 001, 005, 008, and architecture.md to
replace CacheAnnounce with NodeAnnounce and probe fan-out content
discovery.

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

* docs(adr-001): replace CacheAnnounce with NodeAnnounce and probe fan-out

Remove Bloom filters, hash lists, and gossip-derived routing tables.
Add NodeAnnounce gossip, probe fan-out content discovery, probe cache,
and dual-signal prefetching. Reframe DHT future work for scaling
probe fan-out. Resolves #25.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* docs(adr-005): update gossip section from CacheAnnounce to NodeAnnounce

Gossip now carries node metadata (NodeAnnounce) instead of content
inventories. Content discovery handled via cdn/probe/v1 fan-out.

* docs(adr-008): make LoadHint cross-reference to ADR 001 concrete

* docs(architecture): update for separated node/content discovery

Replace CacheAnnounce with NodeAnnounce in system diagram and ADR
summaries. Update cache miss flow to probe fan-out model. Update
prefetching to dual-signal model. Update future work section.

* docs: fix remaining stale references from CacheAnnounce migration

Update routing table → peer table in ADR 003, 004, 005.
Update CacheAnnounce → NodeAnnounce in ADR 003 gossip flooding.
Update cache miss flowchart in architecture.md to probe fan-out.
Update ADR 005 probe section to reference peer probing not routing table.

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

* chore: remove superpowers working artifacts

Design specs and implementation plans are working artifacts,
not permanent repo content.

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

* docs: fix review findings across ADRs

- Fix stale "content availability broadcast via gossip" in ADR 003
- Fix "announced content" and "deprioritized in routing" in ADR 003
- Fix "content routing announces" in ADR 004 auto-ejection
- Clarify "routing table" references in ADR 001 consequences
- Clarify probe cache TTL = slashing window overlap in ADR 001
- Fix "observe probe traffic" in architecture.md future work
- Update ADR 000 gossip description to NodeAnnounce
- Add NodeAnnounce struct cross-reference in ADR 005

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

* docs: address second-round review feedback

- Rename NodeAnnounce timestamp → timestamp_us for protocol consistency
- Specify signature covers all fields via postcard serialization
- Add gossip validation rules (signature + registry check) to ADR 001
- Store full signed ProbeResponse in probe cache for slashing evidence
- Cross-reference ADR 001 validation from ADR 004 auto-ejection

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

* docs: document app server as external component in ADR 006 and architecture

Clarify that the app server (key delivery, subscription auth) is a
traditional web service operated by content providers, not part of the
CDN protocol or crate structure. Add External Components section to
architecture.md, update network diagram to show provider infrastructure,
and detail the app server's API surface and scaling model in ADR 006.

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

* docs: add NodeId-to-Ethereum binding spec and PoC challenge bond (#57, #58)

- ADR 003: Add full NodeId-to-Ethereum binding section with EIP-712
  typed data, on-chain registration via StakingRegistry.bindNodeId(),
  and ephemeral off-chain binding for clients
- ADR 004: Add 100 TOKEN challenge bond for PoC (was N/A), preventing
  zero-cost griefing via fabricated slash claims
- ADR 005: Reference challenge bond requirement in probe slashing section

Closes #57, closes #58

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

* docs: fix ADR 003 payment channel gaps (#73, #72, #67, #66, #61)

- Reject probe-requires-channel option (bootstrap catch-22)
- Clarify clock skew immunity in rate manipulation detection
- Define channel expiry (maxChannelDuration: 90 days) and reclaimExpired
- Specify nonce as on-chain per-client monotonic counter with pre-computation
- Add Concurrent Streams subsection with rules, example, and isolation advice

Closes #73, closes #72, closes #67, closes #66, closes #61

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

* docs: fix network and reputation issues (#71, #70, #25, #6, #77, #63, #62)

ADR 001:
- Add registry unavailability fallback with retry and cached peer list
- Document region hint limitations and PoC latency-based detection
- Specify Bloom filter parameters (1% FPR, k=10, 14.4 bits/item)
- Define unified node selection algorithm: rate × rtt × (1/reputation²)

ADR 008:
- Add 1-hour recency validation for gossip reputation reports
- Fix bootstrap division-by-zero with max(1, ...) guard
- Switch reporter weight from channel count to settled USDC value

Closes #71, closes #70, closes #25, closes #6, closes #77, closes #63, closes #62

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

* docs: fix ADR 005 protocol gaps (#75, #69, #29, #24)

- Document dual-connection overhead and production optimization path
- Add redirect loop prevention (max 3 hops, cycle detection)
- Add Error Handling section with StreamError enum, retry semantics, timeouts
- Define postcard schema evolution strategy (trailing Option<T> for non-breaking, new ALPN for breaking)
- Update challenge bond references to reflect PoC implementation

Closes #75, closes #69, closes #29, closes #24

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

* docs: fix encryption and governance issues (#76, #68, #26, #16, #78, #65)

ADR 006:
- Reduce offline lease TTL from 30 to 7 days with mandatory daily check-in
- Add key rotation notification via iroh-gossip EpochRotated message
- Use iroh QUIC stream for PoC epoch key delivery (not WebSocket/SSE)
- Add key hierarchy: per-content epoch keys derived from server_secret

ADR 009:
- Define pause sunset as immutable constructor deadline with upgrade-only extension
- Tighten safety bounds: slash 5-50%, dispute window 12h-72h, rate floor >= 1

ADR 003 (consistency):
- Update dispute window safety bounds to match ADR 009 (12h-72h)

Closes #76, closes #68, closes #26, closes #16, closes #78, closes #65

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

* docs: fix multi-token, takedown, and tokenomics issues (#59, #84, #80, #81, #64, #60, #74)

ADR 010:
- Resolve slashing denomination: always in TOKEN stake, no cross-token conversion
- Fix backward-compat contradiction: payment_token requires cdn/client/v2
- Clarify SafeERC20 rationale (USDT non-returning transfer pattern)

ADR 011:
- Add blacklist version sync recovery (delta, full re-sync, cache scan fallback)
- Document self-reported region limitation with production mitigation path

ADR 004:
- Restrict PoC mint() to onlyOwner, document production removal
- Define PoC slash counter reset: 30 days without incidents

Closes #59, closes #84, closes #80, closes #81, closes #64, closes #60, closes #74

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

* docs: cross-ADR analysis and architecture sync (#17, #11, #45, #15)

ADR 007:
- Add Fee Accountability section: PoC trust-based, production escrow with heartbeats

ADR 004:
- Add production bootstrap modeling table (100/500/1000 nodes)
- Document reflexive TOKEN price dependency risk

architecture.md:
- Add Gossip Bandwidth Budget section (~6 KB/s per node at PoC scale)
- Add Privacy Surface section consolidating all privacy tradeoffs
- Sync overview sections: unified selection score, 4 ALPNs, value-weighted
  reputation, tightened safety bounds, NodeId binding, challenge bonds

Closes #17, closes #11, closes #45, closes #15

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

* docs: remove blocked issues #24, #11, #45 from batch fix

Revert changes for blocked issues:
- #24: Remove Schema Evolution Strategy section from ADR 005
- #11: Remove Gossip Bandwidth Budget section from architecture.md
- #45: Remove Privacy Surface section from architecture.md

Update #84 cross-reference to not depend on removed #24 section.

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

* docs: fix cross-ADR consistency issues found in PR review

- Fix slash 100% exceeding governance max 50%: production third offense
  now 50% (cumulative slashing triggers auto-ejection)
- Fix rate floor: ADR 003 safety bounds now >= 1 base unit (was 0),
  matching ADR 009
- Fix channel expiry: ADR 010 references updated from 30 to 90 days
- Fix dispute window: "24-hour" hardcoded references now say
  "default 24h, governable 12h-72h"
- Update ADR 005 and architecture.md to reference unified selection score
- Fix "Three ALPN" heading to "Four ALPN" (watchtower was added)
- Disambiguate cdn/keys/v1 ALPN from cdn/keys/rotation/v1 gossip topic

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

* docs: address remaining PR review findings

- ADR 005: Update mermaid diagram to reference unified selection score
- ADR 003: Add ChannelExpiredReclaimed event for reclaimExpired
- ADR 003: Add reclaimExpired to channel close lifecycle documentation

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

* docs: address Copilot and Gemini review comments

- ADR 003: Reject bindNodeId if nodeId already bound to different address
- ADR 003: Clarify nonce read-then-increment ordering for channelId
- ADR 004: Fix challenge bond rationale (testnet token has no economic cost)
- ADR 008: Add future-timestamp rejection + clock sync dependency note
- ADR 001: Clamp reputation to min 0.1 in selection score (avoid div-by-zero)
- ADR 001: Correct Bloom filter FPR from 1% to 0.1% (matches k=10, m=14.4)
- ADR 009: Add Min deposit row to governance parameters table

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

* docs: address second round of review comments

- ADR 003: Remove duplicate reclaimExpired lifecycle entry
- ADR 005: Add error? field to StreamResponse wire format diagram
- ADR 006: Fix key hierarchy opening sentence (limits client-key
  compromise blast radius, not server_secret compromise)
- architecture.md: Link to ADR 001 for selection score instead of
  inlining formula without clamp

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

* docs: integrate cdn/keys/v1 protocol detail from PR #47

Moves the detailed cdn/keys/v1 spec from PR #47 into this batch fix:
- ADR 006: Full protocol messages (KeySessionOpen, EpochKeyUpdate,
  EnvelopeRequest/Response), app server as iroh Endpoint, dual-stream
  pattern, authentication model, concurrent session limiting
- ADR 005: cdn/keys/v1 in ALPN table (five protocols), stream limits
  (10: 1 epoch + 9 envelopes), connection lifetime exception
- architecture.md: cdn/keys/v1 in ALPN table, updated ADR 006 summary
- CLAUDE.md: cdn/keys/v1 and cdn/watchtower/v1 in ALPN table

Supersedes #47

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

* docs: revert Bloom filter parameter changes (#25)

Remove Bloom filter spec from ADR 001 — PR #44 proposes a broader
discovery redesign that may eliminate Bloom filters entirely.
Leaving #25 for that PR to resolve.

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

* docs: remove premature backward-compat complexity from ADR 010

ADR 010 is a draft for a post-PoC feature with no deployed v1 to be
backward-compatible with. Simplify:
- Revert cdn/client/v1→v2 versioning back to just cdn/client/v1
- Replace 3-phase migration plan with simple contract replacement
- Remove "old nodes"/"legacy"/"backward-compatible" framing

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

* docs: address Alper's review feedback on probe and gossip design

- Commit to 15s probe cache TTL (half the 30s slashing window)
- Add NodeAnnounce replay prevention (timestamp freshness ±60s + monotonic check)
- Increase probe timeout from 200ms to 500ms for inter-continental coverage
- Add registry freshness check before paid pulls (new step 5)
- Add probe rate limits (10 outbound fan-outs/s, 20 inbound/peer/s)
- Try next cached provider before falling back to full fan-out

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
@thiras
thiras deleted the feat/quic-key-delivery branch March 31, 2026 21:19
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.

ADR 006: WebSocket/SSE for epoch keys adds significant unspecified app server component

2 participants