Skip to content

docs(adr): add ADR 037 — latency-driven proxy warming for regional locality - #724

Merged
alpergundogdu merged 4 commits into
mainfrom
claude/thirsty-proskuriakova-21cb73
May 30, 2026
Merged

alpergundogdu merged 4 commits into
mainfrom
claude/thirsty-proskuriakova-21cb73

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

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):

  • Client selection policy — on a cache miss where probed holders are all distant and the client's cumulative RTT map holds a nearer bonded node, the client routes its paid cdn/client/v1 request through that near non-holder. Proxy ranking is by measured RTT only, so self-attested region (ADR 030) spoofing is irrelevant by construction.
  • Node chunk-paced pull-through — the node fills a request for an unheld blob/range by pulling chunk N+1 only after voucher N, bounding per-request speculative exposure to ~1 chunk (default ~1 MB) instead of the whole blob. The StreamRequest itself is the trigger; no flag, no handshake.
  • Dual seed-leech cap — a global unrecouped-leech budget (bounds operator loss, absorbs distributed abuse) + a per-peer share ratio (bounds concentrated single-source abuse).
  • Loop closure — caching fires the existing DHT STORE; normal low-RTT selection then takes over and proxy warming disengages. Range-access locality still improves via RTT routing even when no whole-blob STORE fires.

Implementation lands with the cdn/client/v1 paid-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 entries
  • adr/Makefile — BOOK_SRCS book-build list
  • CLAUDE.md — next-ADR pointer 037 → 038, canonical list

Test plan

  • pre-commit run --all-files: ADR book-list sync + reference/anchor hygiene + markdownlint pass
  • Every numbered ADR present in BOOK_SRCS
  • ADR review (label adr-review) — confirm parameter-default modeling and the whole-blob-STORE vs range-discovery deferral

Closes #723

🤖 Generated with Claude Code

…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]>
Copilot AI review requested due to automatic review settings May 30, 2026 13:02

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

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.

Comment thread adr/037-regional-proxy-warming.md Outdated
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)).
Comment thread adr/037-regional-proxy-warming.md Outdated
- **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.
Comment thread adr/037-regional-proxy-warming.md Outdated
- **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.

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

Comment thread adr/037-regional-proxy-warming.md Outdated
- **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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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

Comment thread adr/037-regional-proxy-warming.md Outdated
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)).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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
  1. When referencing sections in Markdown ADRs, use explicit named links with GFM-compatible anchors instead of numeric section numbers or numeric anchors.

Comment thread adr/037-regional-proxy-warming.md Outdated
- **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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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
  1. 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
@alpergundogdu

Copy link
Copy Markdown
Contributor Author

Addressed the anchor-precision feedback from @copilot and @gemini-code-assist in 40e6b50.

All flagged §-named links now resolve to the specific subsection anchor instead of the target ADR's H1. Note one correction vs. the suggestions: the ADR 001 heading is "Node Discovery (Gossip)", so the correct slug is #node-discovery-gossip (not #node-discovery). Slugs were taken from the anchors already used across the ADR corpus and verified by the adr reference hygiene pre-commit hook.

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.

@alpergundogdu alpergundogdu changed the title docs(adr): ADR 037 — latency-driven proxy warming for regional locality docs(adr): add ADR 037 — latency-driven proxy warming for regional locality May 30, 2026
@alpergundogdu
alpergundogdu merged commit 782c4f8 into main May 30, 2026
37 of 39 checks passed
@alpergundogdu
alpergundogdu deleted the claude/thirsty-proskuriakova-21cb73 branch May 30, 2026 14:04
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.

Regional locality: latency-driven proxy warming bootstraps the first regional cache copy

2 participants