Skip to content

docs(adr): describe the shipped client ranker in ADR 039; scope the unified score to the node pull leg - #1991

Merged
alpergundogdu merged 4 commits into
mainfrom
claude/github-issue-1989-d677b5
Sep 11, 2026
Merged

alpergundogdu merged 4 commits into
mainfrom
claude/github-issue-1989-d677b5

Conversation

@yigitdot

@yigitdot yigitdot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1989. Closes #1992.

ADR 039 § Source set and selection / § Source diversity described a client that takes candidates from cdn/dht/v1 FIND_VALUE, ranks by the ADR 001 unified score, and feeds a per-source reputation EWMA. The shipped client does none of that (peer store / CapacityBond registry candidates, RTT-only failover order, --max-rate-per-mb as a hard ceiling, latency EWMA + failure stamp as its only per-peer memory; decdn-reputation is linked by node alone). All three facts do hold for the node's cache-miss pull leg, which ADR 039 also covers — so the ADR now states each consumer's path separately instead of dropping the node-side facts.

  • ADR 039: § Source set split into client (three candidate tiers, region shortlist ≠ rank key, RTT-only failover) / node pull leg; § Source diversity and reputation → § Source diversity and per-peer memory (the client stamps a failed source only on the single-source path and the first multi-source lane; other lanes report their reason and persist nothing); failure bullet, consequences, risks, cross-ADR lines (001/008/022), and AC 2 aligned.
  • ADR 001 § Node Selection Algorithm: the score ranks the node pull leg; the client carve-out (ADR 037) is stated as fact. Settles the ADR 001:97 vs ADR 037:154 conflict in ADR 037's favour. Region-penalty lines scoped to the pulling node.
  • ADR 012 § Client Roles and § Trust Boundary, ADR 022 client-discovery row, ADR 037 § Client selection policy opener: same stale client-FIND_VALUE / client-reputation claims (ADR 012 / ADR 037 still say the client runs FIND_VALUE and keeps reputation scores #1992).
  • README, adr/architecture.md, ADR 005, 008, 030, and further lines of 022/037: remaining "clients pick by the unified score" / "clients apply a reputation penalty" wording scoped to the pulling node (found by review).
  • probe_and_order doc comment: selection reads has_blob/coverage + measured RTT; rate_per_mb is harvested into probed_samples for the peer store only.

No mechanism added.

🤖 Generated with Claude Code

…nified score to the node pull leg

ADR 039 § Source set and selection and § Source diversity described a client
that takes candidates from cdn/dht/v1 FIND_VALUE, ranks by the ADR 001 unified
score, and feeds a per-source reputation EWMA. The client does none of that:
candidates come from the peer store or the CapacityBond registry, the rank key
is measured RTT only, and the client links no reputation code. Those three
facts hold for the node's cache-miss pull leg, so the ADR now states each
consumer's path separately.

ADR 001 § Node Selection Algorithm now names the node pull leg as the score's
consumer and the client carve-out as fact; ADR 037's cross-ADR line says the
same. The probe_and_order doc comment no longer claims selection reads
rate_per_mb.

Closes #1989

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.70% (was 82.70%, ● 0.00%) — 76663/92700 lines

File Coverage Lines Δ
crates/cli/src/commands/fetch.rs 42.00% 927/2207 ● 0.00%
History
Commit Total Δ vs base
42f6f1b 82.67% ● 0.00%
86786df 82.67% ● 0.00%
e2db6c4 82.67% ● 0.00%
ab9b821 (HEAD) 82.70% ● 0.00%

yigitdot and others added 2 commits September 11, 2026 07:18
…012, 022, 037

The client picks nodes from its peer store or the CapacityBond registry,
ranks by measured RTT, and keeps no reputation score. ADR 012 § Client Roles
and § Trust Boundary, ADR 022's client-discovery impact row, and ADR 037's
client selection opener said otherwise.

Closes #1992

Co-Authored-By: Claude Opus 5 <[email protected]>
…eg; fix ADR 039 lane-memory text

The client stamps a failed source only on the single-source path and the
first multi-source lane; the scheduler's other lanes report their reason in
the fetch result and persist nothing. ADR 039 § Failure handling, its
consequences bullet, and acceptance criterion 2 now say so. The client's
region shortlist picks which registry candidates get probed; ADR 012 and ADR
039 keep it distinct from the RTT-only failover order. The stored rate_per_mb
is diagnostic; no ranker reads it.

README, adr/architecture.md, ADR 001, 005, 008, 022, 030, and 037 carried the
same client-unified-score / client-reputation claims in other lines; each is
now scoped to the pulling node.

Co-Authored-By: Claude Opus 5 <[email protected]>

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.

🟡 Changes recommended

A few updated docs still contain inaccurate or unclear statements about client discovery/ranking (notably README and ADR 037/022), so the documentation set is not yet internally consistent with the shipped behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the documentation/ADR set to accurately describe the shipped client selection behavior (registry/peer-store candidates with RTT-only ordering and limited per-peer memory) while scoping the unified selection score and reputation EWMA to the node’s cache-miss pull leg.

Changes:

  • Split ADR 039’s “source set and selection” into distinct client vs node pull-leg paths, and rename “reputation” language to “per-peer memory” where applicable.
  • Scope ADR 001’s unified score (and related region-penalty language) to the node pull leg, and propagate corresponding wording fixes across related ADRs and top-level docs.
  • Update the probe_and_order doc comment to match the shipped behavior (has_blob/coverage + RTT ordering; rate_per_mb harvested for peer-store/diagnostics and capped via --max-rate-per-mb).
File summaries
File Description
README.md Updates the high-level client selection description away from unified-score ranking.
crates/cli/src/commands/fetch.rs Fixes probe_and_order doc comment and updates an ADR section reference.
adr/architecture.md Scopes “discovery” narrative to node DHT usage; clarifies client RTT-based selection.
adr/039-multi-source-parallel-fetch.md Rewrites scheduler “source set” semantics to separate client vs node pull-leg consumers.
adr/037-regional-proxy-warming.md Updates client selection/candidate sourcing wording to match shipped discovery sources.
adr/030-node-region-self-attestation.md Scopes RTT-vs-claim penalty wording to pulling nodes.
adr/022-content-discovery.md Clarifies that clients do not query the DHT; adjusts related reputation phrasing.
adr/012-client.md Replaces stale “client DHT + reputation” claims with peer-store/registry + RTT-only behavior.
adr/008-reputation.md Scopes reputation impact to pulling-node upstream selection probability.
adr/005-protocol.md Clarifies DHT→probe→select as node-to-node behavior; notes client RTT-based pick.
adr/001-network.md Scopes unified score inputs/usage to node pull leg; reconciles with ADR 037 client carve-out.
Review details

Suppressed comments (1)

adr/037-regional-proxy-warming.md:41

  • This bullet still says the persisted rate_per_mb “pre-filters and orders candidates”, but the shipped client selection paths sort by measured RTT (store EWMA or probe RTT) and do not use the stored rate as a ranking/pre-filter input. Adjusting this wording avoids reintroducing the stale “price-aware client ranking” behavior that this PR is removing.
Proxy ranking depends on the client knowing its round-trip latency to bonded nodes that do **not** hold the requested blob — precisely the nodes the normal discovery path never contacts. The probe cache ([ADR 001 § Probe cache](001-network.md#probe-cache)) is a 15-second, hash-keyed cache of positive results, not a longitudinal latency record, and a fetch's probe round samples only the few candidates it shortlists. A client that kept no record across fetches would forget those samples and re-learn its nearby set on every fetch. The client closes this with a dedicated latency structure and an active discovery source.

- **Per-peer RTT map.** The client maintains a bounded `NodeId → (rtt_estimate_us, last_sampled_us)` map, separate from the probe cache: keyed by node rather than hash, EWMA-smoothed across samples, LRU-bounded (recommended ~4,096 entries), with entries re-sampled or evicted once older than `rtt_map.staleness_secs`. Every QUIC interaction with a bonded node contributes a sample — registry-bootstrap connections, `cdn/probe/v1` responses, and completed `cdn/client/v1` streams (warming requests included).
- **Persisted, unified store.** The RTT map is not an in-memory cache: the client persists it to a per-peer on-disk store under its data dir, one record per node, unified with the registry snapshot rather than kept as a separate cache — each record carries the node's identity (Ethereum address, region hint) alongside its latency and stats in one place. A record also carries `rate_per_mb` from the node's most recent probe or stream response, an unsigned ranking hint that pre-filters and orders candidates; it never substitutes for the signed `StreamResponse.rate_per_mb` a client actually pays against ("no surprise pricing" still holds). A short-lived client that closes and restarts keeps its map instead of rebuilding it from nothing.
  • Files reviewed: 11/11 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md Outdated

- **Nodes** bond TOKEN proportional to declared bandwidth capacity, cache content, and serve BLAKE3-addressed blobs over QUIC
- **Clients** probe candidate nodes, pick the best by the unified selection score `rate_per_mb × rtt_ms × (1 / max(reputation, 0.1)²)` ([ADR 001](adr/001-network.md)), stream content, and pay via off-chain USDC vouchers
- **Clients** probe candidate nodes from the on-chain registry, pick the RTT-nearest ([ADR 037](adr/037-regional-proxy-warming.md)), stream content, and pay via off-chain USDC vouchers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in ab9b821: README now says clients take candidates from their peer store or the on-chain registry and pick RTT-nearest from the RTT map or by probing.

Comment thread adr/022-content-discovery.md Outdated
An **origin-serve-capable** node — one that answers `has_blob` from its origin backend (an enumerable origin-held entry, or a live size probe) rather than from cache — sets every bit: it read the total size to answer at all, so it knows the block count, and it will serve any block by warming and verifying it against `H` on delivery. So `coverage` states what the sender will serve, not only what it has cached: a cache holder advertises its cached blocks, an origin advertises all of them, and a node that is both advertises all. This keeps the biconditional exact and never asks a non-origin to serve a block it lacks.

**Consistency rule.** `has_blob` and the coverage bitmap are two views of one fact, so they agree by definition: **`has_blob: true` ⟺ the bitmap is non-empty.** Either mismatch is malformed — `has_blob: false` with a non-empty bitmap, or `has_blob: true` with an empty one — and requesters MUST reject such a response and score it a protocol violation ([ADR 008](008-reputation.md#adr-008-reputation-system)), the same posture as the mandatory-`slash_sig` rule ([ADR 014](014-on-chain-verification.md#adr-014-on-chain-verification-for-slashing-evidence)). The signed bool stays authoritative: a node cannot advertise via the unsigned bitmap while keeping its signed possession claim false, because compliant clients ignore such probes and the node earns nothing without signing stream evidence.
**Consistency rule.** `has_blob` and the coverage bitmap are two views of one fact, so they agree by definition: **`has_blob: true` ⟺ the bitmap is non-empty.** Either mismatch is malformed — `has_blob: false` with a non-empty bitmap, or `has_blob: true` with an empty one — and requesters MUST reject such a response, and a node requester scores it a protocol violation ([ADR 008](008-reputation.md#adr-008-reputation-system)), the same posture as the mandatory-`slash_sig` rule ([ADR 014](014-on-chain-verification.md#adr-014-on-chain-verification-for-slashing-evidence)). The signed bool stays authoritative: a node cannot advertise via the unsigned bitmap while keeping its signed possession claim false, because compliant clients ignore such probes and the node earns nothing without signing stream evidence.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in ab9b821: split into two sentences — every requester MUST reject; a node requester additionally scores it a protocol violation, a client only rejects.

Comment thread adr/037-regional-proxy-warming.md Outdated
- **Local cache-miss serving** happens only on a node that itself received a request for `H`. Clients route to the lowest selection score ([ADR 001 § Node Selection Algorithm](001-network.md#node-selection-algorithm)), which is the London origin, so nearby cache nodes never receive the request, never record a miss, and never cache.
- **Local cache-miss serving** happens only on a node that itself received a request for `H`. Clients route to the RTT-nearest holder ([§ Client selection policy](#client-selection-policy-latency-driven-proxy-preference)), which is the London origin, so nearby cache nodes never receive the request, never record a miss, and never cache.

This is a cold-start locality trap: a nearby node cannot earn the traffic for `H` until it holds `H`, and it does not receive `H` until it has earned the traffic. The trap is self-clearing the instant *one* nearby copy exists — that node publishes a DHT STORE ([ADR 022 § STORE Flow](022-content-discovery.md#store-flow-cache-event--dht-publish)), a regional FIND_VALUE returns it, its low RTT wins the selection score, and subsequent demand reinforces it. The unsolved problem is bootstrapping the first regional copy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in ab9b821: dropped 'wins the selection score' from the bootstrap trap and 'unified selection score selects it' from loop closure; both now read as the client's RTT-nearest pick. Also fixed the suppressed rate_per_mb note — the stored rate is a diagnostics-only hint, never a ranking/pre-filter input.

…tion wording

- README: clients take candidates from peer store or registry, RTT-nearest
  via RTT map or probe (not registry-only).
- ADR 022 consistency rule: split into two sentences; every requester MUST
  reject, node requester additionally scores, client only rejects.
- ADR 037: drop 'wins the selection score' / 'unified selection score selects
  it' from the client bootstrap and loop-closure prose (client is RTT-only).
- ADR 037 RTT map: stored rate_per_mb is a diagnostics-only hint, never a
  ranking/pre-filter input; --max-rate-per-mb gates the signed stream quote.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit a86535a into main Sep 11, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/github-issue-1989-d677b5 branch September 11, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants