Repository navigation
docs(adr): add ADR 037 — latency-driven proxy warming for regional locality - #724
Conversation
…lity Closes the regional-locality cold-start trap where keyspace-routed discovery never surfaces geographic demand, so a nearby node cannot bootstrap the first regional copy of distant-only content. Design: a client finding only distant holders routes its paid cdn/client/v1 request through a measured-nearby non-holder, which fills it by chunk-paced pull-through (<=1 chunk ahead of payment) and caches the blob. Proxy selection ranks by measured RTT only, sidestepping the region self-attestation surface. Speculative spend is bounded by a global unrecouped-leech budget plus a per-peer share ratio. No wire change; the StreamRequest itself is the demand signal. Indexes updated: architecture.md reading order + AD list, Makefile BOOK_SRCS, CLAUDE.md next-ADR pointer (037 -> 038, canonical list). Closes #723 Co-Authored-By: Claude Opus 4.7 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds ADR 037 to document latency-driven proxy warming as the planned design for bootstrapping the first regional cache copy when DHT discovery returns only distant holders.
Changes:
- Adds the new ADR covering client proxy selection, chunk-paced pull-through, seed-leech caps, loop closure, risks, and acceptance criteria.
- Registers ADR 037 in the ADR book reading order and architecture index.
- Updates contributor ADR metadata to point the next ADR number to 038.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
CLAUDE.md |
Updates ADR bookkeeping for the new ADR number. |
adr/Makefile |
Adds ADR 037 to the reading-order book source list. |
adr/architecture.md |
Adds ADR 037 to Chapter 2 and the numeric ADR index. |
adr/037-regional-proxy-warming.md |
Introduces the proxy-warming ADR and design details. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| On a cache miss for hash `H`, the client runs the normal FIND_VALUE → probe lookup and obtains measured RTTs to the live holders. The client then applies a proxy-warming pre-step before committing to a holder: | ||
|
|
||
| - **Trigger.** Proxy warming engages only when the best holder's RTT exceeds `proxy_warming.rtt_threshold_ms` (the holders are all distant) **and** the client's cumulative RTT map contains a bonded node whose measured RTT is lower than the best holder's by at least `proxy_warming.margin_ms`. If no measured candidate clears the margin, the client routes directly to the best holder — proxy warming is a no-op, never a gamble. | ||
| - **Candidate pool.** The bonded nodes in the client's peer table ([ADR 001 § Node Discovery](001-network.md#adr-001-network-topology-and-peer-mesh)), excluding the distant holders, filtered to reputation ≥ the client's minimum-reputation floor ([ADR 001 § Minimum-reputation rejection floor](001-network.md#node-selection-algorithm)). |
| - **Trigger.** Proxy warming engages only when the best holder's RTT exceeds `proxy_warming.rtt_threshold_ms` (the holders are all distant) **and** the client's cumulative RTT map contains a bonded node whose measured RTT is lower than the best holder's by at least `proxy_warming.margin_ms`. If no measured candidate clears the margin, the client routes directly to the best holder — proxy warming is a no-op, never a gamble. | ||
| - **Candidate pool.** The bonded nodes in the client's peer table ([ADR 001 § Node Discovery](001-network.md#adr-001-network-topology-and-peer-mesh)), excluding the distant holders, filtered to reputation ≥ the client's minimum-reputation floor ([ADR 001 § Minimum-reputation rejection floor](001-network.md#node-selection-algorithm)). | ||
| - **Ranking key is measured RTT only.** Self-attested `region` ([ADR 030](030-node-region-self-attestation.md#adr-030-node-region-self-attestation)) is not consulted. Round-trip time is ground truth and cannot be forged: a node that misreports its region to appear local simply exhibits a high measured RTT and is never selected as a proxy. The region-spoofing surface is therefore irrelevant to this mechanism by construction. | ||
| - **RTT source.** The client's cumulative probe history. Every normal cache-miss probe ([ADR 001 § Probe response collection](001-network.md#adr-001-network-topology-and-peer-mesh)) samples RTT to whatever nodes it probes; across many lookups the client accumulates RTT coverage of a broad swath of the bonded set, including nearby nodes probed for unrelated content. No new measurement traffic is introduced. A warming request itself yields a fresh RTT sample for the chosen node, refining future selection. |
| - **Global unrecouped-leech budget.** The node maintains a rolling node-wide counter of `(bytes pulled to satisfy cache misses) − (bytes served)`. When the counter exceeds `max_unrecouped_leech_bytes`, speculative pull-through pauses and resumes as the node serves bytes and recoups. This bounds the operator's aggregate speculative loss and absorbs distributed abuse — many sources each requesting one unpopular hash — in aggregate, independent of how the requests are distributed across peers. | ||
| - **Per-peer share ratio.** The node will not pull more than `share_ratio ×` the bytes it has already served *to that requesting peer*, with a one-chunk initial allowance so a peer with no service history can still be served the first chunk. This bounds concentrated abuse — a single peer attempting to drive the node into speculative pulls for content no real client wants — and mirrors a BitTorrent share ratio. | ||
|
|
||
| Both caps are operator-policy parameters. The optional `require_authorized_origin` gate and prefetch budget already specified for speculative acquisition in [ADR 022 § Recommended configuration](022-content-discovery.md#popularity-signals-and-market-dynamics) compose with these caps where an operator wants the additional restriction; the seed-leech caps are the load-bearing defense specific to this mechanism. |
There was a problem hiding this comment.
Code Review
This pull request introduces ADR 037, which outlines a latency-driven proxy warming mechanism for regional locality to solve the cold-start locality trap in content discovery. It also updates CLAUDE.md, the adr Makefile, and the architecture index to integrate this new ADR. The review feedback highlights three incorrect Markdown anchor links in the new ADR document that should be updated to point to their specific target sections rather than the main document titles.
| - **Global unrecouped-leech budget.** The node maintains a rolling node-wide counter of `(bytes pulled to satisfy cache misses) − (bytes served)`. When the counter exceeds `max_unrecouped_leech_bytes`, speculative pull-through pauses and resumes as the node serves bytes and recoups. This bounds the operator's aggregate speculative loss and absorbs distributed abuse — many sources each requesting one unpopular hash — in aggregate, independent of how the requests are distributed across peers. | ||
| - **Per-peer share ratio.** The node will not pull more than `share_ratio ×` the bytes it has already served *to that requesting peer*, with a one-chunk initial allowance so a peer with no service history can still be served the first chunk. This bounds concentrated abuse — a single peer attempting to drive the node into speculative pulls for content no real client wants — and mirrors a BitTorrent share ratio. | ||
|
|
||
| Both caps are operator-policy parameters. The optional `require_authorized_origin` gate and prefetch budget already specified for speculative acquisition in [ADR 022 § Recommended configuration](022-content-discovery.md#popularity-signals-and-market-dynamics) compose with these caps where an operator wants the additional restriction; the seed-leech caps are the load-bearing defense specific to this mechanism. |
There was a problem hiding this comment.
The link for [ADR 022 § Recommended configuration] points to #popularity-signals-and-market-dynamics instead of #recommended-configuration. This appears to be a copy-paste error from line 10. Please update the anchor to point to the correct section in 022-content-discovery.md.
References
- When linking to anchors in Markdown documents, ensure the slug points to the specific heading containing the relevant information, especially when multiple headings share similar names.
| On a cache miss for hash `H`, the client runs the normal FIND_VALUE → probe lookup and obtains measured RTTs to the live holders. The client then applies a proxy-warming pre-step before committing to a holder: | ||
|
|
||
| - **Trigger.** Proxy warming engages only when the best holder's RTT exceeds `proxy_warming.rtt_threshold_ms` (the holders are all distant) **and** the client's cumulative RTT map contains a bonded node whose measured RTT is lower than the best holder's by at least `proxy_warming.margin_ms`. If no measured candidate clears the margin, the client routes directly to the best holder — proxy warming is a no-op, never a gamble. | ||
| - **Candidate pool.** The bonded nodes in the client's peer table ([ADR 001 § Node Discovery](001-network.md#adr-001-network-topology-and-peer-mesh)), excluding the distant holders, filtered to reputation ≥ the client's minimum-reputation floor ([ADR 001 § Minimum-reputation rejection floor](001-network.md#node-selection-algorithm)). |
There was a problem hiding this comment.
The link [ADR 001 § Node Discovery] points to the main title anchor #adr-001-network-topology-and-peer-mesh instead of the specific section anchor #node-discovery. Please update the anchor to point directly to the relevant section in 001-network.md.
References
- When referencing sections in Markdown ADRs, use explicit named links with GFM-compatible anchors instead of numeric section numbers or numeric anchors.
| - **Trigger.** Proxy warming engages only when the best holder's RTT exceeds `proxy_warming.rtt_threshold_ms` (the holders are all distant) **and** the client's cumulative RTT map contains a bonded node whose measured RTT is lower than the best holder's by at least `proxy_warming.margin_ms`. If no measured candidate clears the margin, the client routes directly to the best holder — proxy warming is a no-op, never a gamble. | ||
| - **Candidate pool.** The bonded nodes in the client's peer table ([ADR 001 § Node Discovery](001-network.md#adr-001-network-topology-and-peer-mesh)), excluding the distant holders, filtered to reputation ≥ the client's minimum-reputation floor ([ADR 001 § Minimum-reputation rejection floor](001-network.md#node-selection-algorithm)). | ||
| - **Ranking key is measured RTT only.** Self-attested `region` ([ADR 030](030-node-region-self-attestation.md#adr-030-node-region-self-attestation)) is not consulted. Round-trip time is ground truth and cannot be forged: a node that misreports its region to appear local simply exhibits a high measured RTT and is never selected as a proxy. The region-spoofing surface is therefore irrelevant to this mechanism by construction. | ||
| - **RTT source.** The client's cumulative probe history. Every normal cache-miss probe ([ADR 001 § Probe response collection](001-network.md#adr-001-network-topology-and-peer-mesh)) samples RTT to whatever nodes it probes; across many lookups the client accumulates RTT coverage of a broad swath of the bonded set, including nearby nodes probed for unrelated content. No new measurement traffic is introduced. A warming request itself yields a fresh RTT sample for the chosen node, refining future selection. |
There was a problem hiding this comment.
The link [ADR 001 § Probe response collection] points to the main title anchor #adr-001-network-topology-and-peer-mesh instead of the specific section anchor #probe-response-collection. Please update the anchor to point directly to the relevant section in 001-network.md.
References
- When referencing sections in Markdown ADRs, use explicit named links with GFM-compatible anchors instead of numeric section numbers or numeric anchors.
…tstrap The first draft leaned on a "cumulative RTT map" that no ADR defined, and the FIND_VALUE → probe path only ever measures holders (the distant nodes), so a client would never learn RTT to the nearby empty nodes it must rank — the locality trap one level up. Close it inside ADR 037: - Per-peer NodeId→RTT map, distinct from the 15s hash-keyed probe cache, populated by passive sampling on every QUIC interaction plus a bounded background latency sweep (reuses cdn/probe/v1, reserved sentinel hash not counted as demand). - Cold-start behavior: route direct until the map covers a node beating the holder by margin; one warmed copy then serves the whole locale via normal discovery. Qualify ADR 005: a delivering node MAY pull through from the network (not just its own origin) to serve, gated by ADR 037 seed-leech caps; NotFound only when no provider is reachable or it declines. No message-format change (byte_offset + iroh-blobs verified streaming already suffice). Refs #723
…node load-bearing
Splits cdn/probe/v1 into two uses: node-to-node pull-through probing is
load-bearing (must confirm a full holder, carries the signed-probe
slashing evidence), while per-request client probing becomes optional —
clients default to RTT-map routing and take price from StreamResponse
("no surprise pricing"). Clients MAY still probe for cross-candidate
price/reputation selection or to retain rate-manipulation/phantom slash
leverage. The only probing a probe-less client does is the background
latency sweep that maintains its RTT map.
Updates ADR 001/012 cross-impact (client-path carve-out on the generic
FIND_VALUE → probe flow) and adds acceptance criterion 11.
Refs #723
Addresses PR review (Copilot + gemini-code-assist): several §-named links resolved to the target ADR's H1 anchor instead of the named subsection. Repointed to the proven corpus slugs: - ADR 001 § Node Discovery → #node-discovery-gossip - ADR 001 § Minimum-reputation rejection floor → #minimum-reputation-rejection-floor - ADR 001 § Probe cache → #probe-cache - ADR 001 § Probe rate limits → #probe-rate-limits - ADR 005 § cdn/probe/v1 → #cdnprobev1--latency-probe - ADR 005 § cdn/client/v1 → #cdnclientv1--paid-delivery-protocol - ADR 022 § Recommended configuration → #recommended-configuration Whole-ADR references (§ Wire Protocol, § Client Architecture) keep the H1 anchor by design. Refs #723
|
Addressed the anchor-precision feedback from @copilot and @gemini-code-assist in 40e6b50. All flagged I also fixed the same imprecision on four links the bots didn't flag (ADR 001 § Probe cache / § Probe rate limits, ADR 005 § cdn/probe/v1 / § cdn/client/v1). Whole-ADR references (§ Wire Protocol, § Client Architecture) intentionally keep the H1 anchor. |
Summary
Adds ADR 037 resolving the regional-locality cold-start trap raised in #723: content discovery is keyspace-routed (
cdn/dht/v1) while demand is geographic, so a nearby node has no protocol path to learn that local clients want content held only in a distant region — and cannot bootstrap the first regional copy.Design (no wire change):
cdn/client/v1request through that near non-holder. Proxy ranking is by measured RTT only, so self-attested region (ADR 030) spoofing is irrelevant by construction.N+1only after voucherN, bounding per-request speculative exposure to ~1 chunk (default ~1 MB) instead of the whole blob. TheStreamRequestitself is the trigger; no flag, no handshake.Implementation lands with the
cdn/client/v1paid-delivery handler (TODO #317), which does not yet exist; this ADR is the design that handler implements.Changes
adr/037-regional-proxy-warming.md(new)adr/architecture.md— reading-order (Chapter 2 Discovery) + Architectural Decisions entriesadr/Makefile—BOOK_SRCSbook-build listCLAUDE.md— next-ADR pointer 037 → 038, canonical listTest plan
pre-commit run --all-files: ADR book-list sync + reference/anchor hygiene + markdownlint passBOOK_SRCSadr-review) — confirm parameter-default modeling and the whole-blob-STORE vs range-discovery deferralCloses #723
🤖 Generated with Claude Code