Repository navigation
Description
Context
Content discovery is keyspace-routed (Kademlia XOR over the BLAKE3 hash; ADR 022), but demand is geographic. The two never meet, so a node cannot learn that nearby clients want content that currently lives only in a distant region.
Concretely: a Tokyo client requests blob H whose only holder is a London origin. Tokyo nodes have no way to learn Tokyo clients want H. The two demand signals in ADR 022 § Popularity Signals are both geo-blind:
- Signal 1 (FIND_VALUE frequency) — the "non-suppressible popularity oracle" — accrues at the K nodes closest to
Hin keyspace, which are geographically uniform-random. The node that learns "His hot" could be anywhere. - Signal 2 (local cache-miss) only fires on a node that personally received a request for
H. But clients route to the best-scoring provider (the London origin via the ADR 001 selection score), so Tokyo cache nodes never get the request, never see a miss, never cache.
Gap
This is a cold-start locality trap: a Tokyo node can't earn the traffic until it holds the data, and it doesn't get the data until it's earned the traffic. The system has no protocol path to bootstrap the first regional copy.
Once one regional copy exists, the existing machinery already closes the loop: that node fires a DHT STORE (ADR 022 § STORE Flow), regional FIND_VALUE returns it, its low RTT wins the selection score, and it becomes self-reinforcing. The entire problem is bootstrapping copy #1.
Decision / Plan
Fix it at selection time, not by broadcasting demand. A client that finds only distant holders routes its paid cdn/client/v1 request through a nearby bonded node, which cache-miss-pulls H, serves the client, and caches it — warming a regional copy as a side effect of normal paid delivery. No new demand-propagation layer, no new gossip message types, zero wire changes.
Two nearly-independent pieces:
A — Client selection policy. On a cache miss where the probed holders are all distant (best holder RTT exceeds a threshold) and the client's cumulative RTT map contains a nearer bonded node (beating the holder by a margin M), the client sends its StreamRequest to that nearer node even though it is not a holder. If no measured candidate beats the holder by M, it goes direct (no-op).
- Ranking key is measured RTT only — self-attested
region(ADR 030) is ignored, so region-spoofing cannot attract warming traffic; a far node simply has high RTT. - RTT comes from the client's cumulative probe history (every normal cache-miss probe samples RTT to whatever it probes), so no new measurement is needed.
B — Node chunk-paced pull-through (general; bounds loss for every cache-miss serve, not just warming). On a StreamRequest for a blob/range it lacks, the node:
- pulls the first chunk (
pull_chunk_bytes, default ~1MB) to serve chunk 1 and earn voucher 1; - thereafter, on voucher
N, pulls chunkN+1— always ≤ 1 chunk ahead of payment, so per-request speculative exposure is ~1 chunk, not the whole blob; - caches chunks as it pulls them (iroh-blobs partial blobs + bao verified-streaming make partial caching first-class);
- governs aggregate speculative spend with a dual seed-leech cap:
- Global unrecouped-leech budget — node-wide rolling
(pulled-for-miss − served)counter; speculative pull-through pauses pastmax_unrecouped_leech_bytesand resumes as the node recoups. Bounds operator loss; catches distributed garbage-hash floods in aggregate. - Per-peer share ratio — torrent-style; the node won't leech more than
ratio ×what it has served to that client, with a one-chunk initial allowance so new clients can be served. Bounds concentrated single-source abuse.
- Global unrecouped-leech budget — node-wide rolling
Because per-request exposure is one chunk, blind implicit pull-through is cheap enough that the StreamRequest itself is the trigger — no allow_pull_through flag, no accept/decline handshake. The probe→evict race also becomes benign (an evicted advertiser re-pulls one chunk instead of erroring).
Loop closure
Pull-through populates the cache → existing inserts_tx broadcast fires a DHT STORE → the node becomes a discoverable holder → normal low-RTT selection takes over. For partial/range-access patterns where the node never completes H, locality still improves: subsequent warming clients route to the same nearest node by RTT and hit its cached ranges directly — loop closure does not depend on the STORE firing.
Secondary decisions (open for review)
- DHT advertising stays whole-blob (STORE on completion) — keeps ADR 022 discovery range-free. Range semantics in the DHT are considered and deferred.
- Trigger = absolute holder-RTT threshold + relative margin
M; default-on, configurable off. - Parameter defaults (
pull_chunk_bytes,max_unrecouped_leech_bytes, per-peerratio, RTT threshold,M) to be modeled before locking.
Cross-ADR impact
- ADR 001 — selection gains a proxy-warming pre-step.
- ADR 005 — node handler behavior for chunk-paced pull-through on cache miss (no new field).
- ADR 012 — client warming selection policy.
- ADR 022 — locality complement to the keyspace demand signals; reuses prefetch-style guards.
- ADR 030 — this mechanism deliberately uses measured RTT, sidestepping region attestation.
Blocked on
The cdn/client/v1 paid-delivery handler does not exist yet (TODO #317, crates/node/src/runtime/mod.rs). Selection scoring (crates/node/src/selection.rs) and the origin pull-through engine (crates/cache/src/engine.rs) exist; client fetch and node-to-node serving do not. This issue records the design (ADR 037); implementation lands with the client handler.
Acceptance criteria (for the ADR)
- A client with only-distant holders and a measured nearer bonded node sends its StreamRequest to the nearest; with no qualifying candidate it goes direct.
- Node per-request speculative exposure on abandonment is bounded to ~1 chunk (
pull_chunk_bytes); chunkN+1is pulled only after voucherN. - Speculative pull-through is gated by both the global unrecouped-leech budget and the per-peer share ratio.
- After serving, the node caches
Hand (on completion) emits a DHT STORE discoverable by a subsequent regional FIND_VALUE. - Proxy selection is invariant to peers' self-attested
region(RTT-only). - A declining/timing-out proxy causes fallback to the direct holder with no error surfaced to the caller.
Out of scope
- Demand-broadcast / regional demand gossip (explicitly rejected in favor of selection-time routing).
- Range-addressed DHT discovery (deferred).
- Changes to the keyspace demand signals or prefetch in ADR 022.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon May 30, 2026
🎯 Triage report
This issue proposes ADR 037 to solve the cold-start locality trap: because content discovery is keyspace-routed (Kademlia) while demand is geographic, no protocol path exists to bootstrap the first regional copy of a blob. The fix is purely at selection time — clients route cache-miss requests through a nearby bonded node, which pull-through-serves and caches the blob as a side effect of paid delivery. Two implementation pieces are well-specified: (A) client RTT-based proxy selection policy and (B) chunk-paced pull-through with a dual seed-leech cap. The issue is blocked on the
cdn/client/v1handler (TODO #317).📊 Assessment
adr-review,blockedaddedadr-review: issue explicitly targets ADR 037 authorship;blocked: gated on #317 (cdn/client/v1handler). Existing labels (enhancement,architecture,technical,missing-decision,economics) are accurate and retained.💡 Notes and suggestions
Pre-implementation checklist:
CLAUDE.md, next ADR number is 037; file asadr/037-regional-locality-proxy-warming.md.pull_chunk_bytes(~1 MB default),max_unrecouped_leech_bytes, per-peerratio, RTT threshold, marginM. These have economic implications (operator speculative loss bounds); consider a simple simulation against realistic blob sizes and RTT distributions.cdn/client/v1handler incrates/node/src/runtime/mod.rs). Parts of piece B (chunk-paced pull-through incache/src/engine.rs) may be implementable independently once the ADR is settled, sinceengine.rsalready exists.Security note: The chunk-paced dual-cap design (global unrecouped-leech budget + per-peer share ratio) is the primary abuse-resistance mechanism. Review carefully for garbage-hash flood scenarios and whether the one-chunk initial allowance for new clients can be trivially cycled with new node identities.
ADR consistency check: ADR 022 §STORE Flow and §Popularity Signals will need a "locality complement" section pointing at ADR 037 to avoid future confusion about why the keyspace demand signals are intentionally geo-blind.
Add this agentic workflows to your repo
To install this agentic workflow, run
docs(adr): specify client RTT map + latency discovery for ADR 037 boo…
docs(adr): clarify probe roles in ADR 037 — client-optional, node-to-…
docs(adr): point ADR 037 cross-links at specific subsection anchors
docs(adr): add ADR 037 — latency-driven proxy warming for regional lo…
docs(adr): deprecate ADR 022 local cache-miss prefetch trigger (super…
docs(adr): replace one-chunk-ahead pull pacing with a bounded pull-ah…