Skip to content

feat(node,cli): wire on-chain rate bounds, cache eviction driver, client proxy warming (#1172, #1173, #1174) - #1357

Merged
thiras merged 2 commits into
mainfrom
feat/node-client-runtime-wiring-1172-1173-1174
Jul 21, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/node-client-runtime-wiring-1172-1173-1174

Conversation

@thiras

@thiras thiras commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1172. Closes #1173. Partially addresses #1174.

Three ADR-to-runtime wiring gaps where a lower-level primitive already existed but was never consumed, so a designed behavior silently did not happen.

#1172 — on-chain delivery-rate bounds (ADR 019 §3.1 / ADR 003)

PaymentChannel.getRateBounds() was never called; bounds came only from local config, so governance retunes were invisible to running nodes.

  • Adds getRateBounds() + RateBoundsUpdated to the alloy::sol! binding. The Solidity surface already existed — no contract change, so no gas-snapshot regen, aderyn, or slither run.
  • Authoritative startup read that refuses to boot on a U256 -> u64 overflow, overwriting the config seed before anything is served.
  • Handler bounds move from by-value u64 fields to a shared RateBounds handle that publishes (floor, ceiling) atomically via ArcSwap. This is load-bearing, not stylistic: two independent atomics let a reader observe a new floor beside an old ceiling, and u64::clamp is assert!(min <= max) — i.e. a panic on the probe/client signing path, which clippy::panic cannot catch because the assert lives in std.
  • RateBoundsUpdated watcher + hourly authoritative re-read (blockchain.rate_bounds_poll_interval_sec), wired to a liveness gauge and a panic counter — its poll-failure and undecodable-log paths deliberately return Ok (an Err would stall the cursor), so without those metrics a wedged watcher is indistinguishable from a healthy one.
  • payment.delivery_floor/delivery_ceiling are now documented as a pre-chain seed; governance owns the live clamp.

Behavioural note for operators: the live floor is now always >= MIN_DEPOSIT_FLOOR (1), where the config default was 0. This makes the voucher floor check live for the first time and clamps rate_per_mb upward for anyone relying on the old no-op default.

#1173 — cache eviction driver (appendix-blob-cache-eviction)

cache_size_mb was never enforced; the cache grew unbounded until disk-full.

  • New engine primitives: size_snapshot, total_bytes, and a soft-evict release_for_eviction kept deliberately distinct from the durable evict() DMCA path — a capacity victim must stay freely re-pullable, and an unbounded takedown log per LRU eviction would be a durability leak.
  • Async driver with a hysteresis latch and per-sweep budget, plus four governable knobs at the ADR's exact defaults/bounds (90/80/16/1; [60,95]/[40,90]/[1,256]/[1,60]) with the 5-point gap enforced as a cross-field invariant.
  • Pending-reclaim accounting is what makes it converge. release_for_eviction only drops GC protection — disk is freed later by the independent iroh-blobs GC sweep (default 300s) — while the driver ticks every 1s. Deciding against raw disk meant the latch stayed engaged for a whole GC interval and the driver re-released every tick (~4800 blobs at defaults) for a pressure event needing one sweep. Decisions now run against raw - pending_reclaim, with an observed drop crediting pending when GC lands.
  • Metrics: decdn_cache_{bytes,size_limit_bytes,pinned_count} gauges plus _evictions_total, _evictions_bytes_total, _evictions_starved_total, _evicted_operator_total, _size_measure_failures_total. Boot warns when gc_interval_sec == 0, where released blobs are never reclaimed and the ceiling is unenforceable.

#1174 — client proxy warming (ADR 037)

Node-side window-paced pull-through already shipped (#856/#823); the client trigger was absent.

  • proxy_warming_order implements the RTT-threshold + margin trigger with RTT-only ranking, wired into the CLI fetch path over probed bonded non-holders. Region is structurally excluded (WarmingCandidate has no region field), so a spoofed region cannot attract warming traffic.
  • RttMap (EWMA, staleness, capacity-bounded) lands as explicitly staged, not-yet-wired code for the map-backed path, documented as such rather than presented as live.
  • Ships opt-in (default off), deliberately diverging from ADR 037's "defaults on." ADR 037 §Fallback requires a declining proxy to fall back transparently to the next candidate and then the direct holder. That needs a second payment channel against the fallback provider — another on-chain deposit escrow, not a cheap retry — so it is follow-up work. A default-on trigger without it could fail a fetch that routing direct would have completed.

Remaining #1174 work (gossip peer-table candidate pool, background latency sweep, fallback chain) is why this only partially addresses that issue.

Review

A multi-agent review of this branch found 4 critical issues, all fixed here before commit: the RateBounds panic, the eviction non-convergence, a -D warnings clippy failure, and the proxy-warming default. Also fixed: Ok(0) no-op releases being credited as evictions, release_for_eviction forgetting the access-time entry before a fallible tag drop (which permanently retired candidates and leaked bytes), two CLI flags that were parsed but never read, a watcher retry storm, an out-of-range ceiling discarding a valid floor update, and several stale/overpromising doc comments.

Verification

  • cargo fmt --check clean
  • cargo clippy --all-targets clean workspace-wide
  • cargo doc clean (pre-commit gate)
  • 2236 tests passing across node/cache/common/client-pull/incentive/cli, 0 skipped

New tests pin the fixed bugs specifically: the [10,100] -> [200,500] retune that used to panic, the release-without-GC cycle that used to drain the cache, release_for_eviction not writing evicted.log, pinned-hash refusal, and all nine new metric series (counters _total-suffixed, gauges not).

Not covered: an eviction-driver integration test against a real CacheEngine under sustained pressure, and the rate-bounds watcher's event path end-to-end — both pinned at the logic level instead.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automatic cache eviction with configurable thresholds, sweep limits, and intervals.
    • Added cache health and eviction metrics for improved monitoring.
    • Added optional proxy warming to route requests through nearby nodes and seed regional copies.
    • Added live delivery-rate bounds sourced from the payment channel and refreshed automatically.
    • Added configuration validation and summaries for new cache and rate-bound settings.
  • Bug Fixes

    • Delivery rates now consistently honor current on-chain limits.
    • Improved handling of cache capacity, pinned content, and eviction accounting.

…ent proxy warming (#1172, #1173, #1174)

Three ADR-to-runtime wiring gaps where a lower-level primitive already existed
but was never consumed, so a designed behavior silently did not happen.

#1172 — on-chain delivery-rate bounds (ADR 019 §3.1 / ADR 003)
- Add `getRateBounds()` + `RateBoundsUpdated` to the `alloy::sol!` binding (the
  Solidity surface already existed; no contract change, no gas-snapshot regen).
- Read bounds authoritatively at startup, refusing to boot on a `U256 -> u64`
  overflow, and overwrite the config seed before anything is served.
- Replace the by-value `delivery_floor`/`delivery_ceiling` handler fields with a
  shared `RateBounds` handle publishing the pair atomically via `ArcSwap`, so a
  governance retune reaches the running probe/client handlers without a restart.
  Publishing `(floor, ceiling)` as one value is load-bearing: two independent
  atomics let a reader observe a new floor beside an old ceiling, and
  `u64::clamp` is `assert!(min <= max)` — a panic on the signing hot path.
- Track updates with a `RateBoundsUpdated` watcher plus an hourly authoritative
  re-read (`blockchain.rate_bounds_poll_interval_sec`), wired to liveness and
  panic metrics because its failure paths deliberately return `Ok`.
- The `payment.delivery_*` config knobs are now documented as a pre-chain seed;
  governance owns the live clamp.

#1173 — cache eviction driver (appendix-blob-cache-eviction)
- New cache-engine primitives: `size_snapshot`, `total_bytes`, and a soft-evict
  `release_for_eviction` deliberately distinct from the durable `evict()` DMCA
  path — a capacity victim must stay freely re-pullable and must not grow the
  `evicted.log`.
- New async driver enforcing `cache.cache_size_mb` with a hysteresis latch and
  per-sweep budget, plus four governable knobs at the ADR's exact bounds.
- Pending-reclaim accounting is what makes it converge: `release_for_eviction`
  only drops GC protection, so decisions run against `raw - pending_reclaim`
  rather than raw disk. Without it the latch stayed engaged for a whole GC
  interval and the driver re-released every tick (~4800 blobs at defaults),
  draining the cache on one high-water crossing.
- Cache-health metrics: `decdn_cache_{bytes,size_limit_bytes,pinned_count}`
  gauges and `_evictions_{,bytes_,starved_}total`, `_evicted_operator_total`,
  `_size_measure_failures_total` counters. Warn at boot when
  `gc_interval_sec == 0`, where released blobs are never reclaimed.

#1174 — client proxy warming (ADR 037)
- `proxy_warming_order`: the RTT-threshold + margin trigger with RTT-only
  ranking, wired into the CLI fetch path over probed bonded non-holders.
- `RttMap` (EWMA, staleness, capacity-bounded) landed as explicitly staged,
  not-yet-wired code for the map-backed path.
- Ships opt-in (default off), deliberately diverging from ADR 037's "defaults
  on": the mandated fallback from a declining proxy needs a second payment
  channel (another on-chain deposit escrow), so it is follow-up work, and a
  default-on trigger without it could fail a fetch that would have succeeded.

Verified: `cargo fmt --check`, `cargo clippy --all-targets` clean workspace-wide,
2236 tests passing across node/cache/common/client-pull/incentive/cli.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 21, 2026 14:05
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thiras, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 392e6363-ebf8-45c9-8283-e95a82a7a66f

📥 Commits

Reviewing files that changed from the base of the PR and between dfb0396 and b82debc.

📒 Files selected for processing (3)
  • crates/node/src/handlers/client/wire.rs
  • crates/node/src/handlers/probe.rs
  • crates/node/src/runtime/eviction.rs

Walkthrough

This change adds chain-backed delivery-rate bounds with event and polling refresh, a configurable cache eviction driver with metrics, and opt-in proxy-warming discovery with RTT-based candidate selection. It also updates configuration schemas, runtime lifecycle wiring, handlers, tests, and CLI output.

Changes

Live delivery-rate bounds

Layer / File(s) Summary
Bounds contract and atomic state
crates/incentive/src/payment_channel.rs, crates/node/src/rate_bounds.rs, crates/common/src/config/*, crates/node/src/metrics.rs
Adds getRateBounds, RateBoundsUpdated, atomic RateBounds, polling configuration, and watcher observability metrics.
Event and polling refresh
crates/node/src/rate_bounds_watcher.rs
Refreshes bounds from filtered events and periodic authoritative contract reads.
Shared handler integration
crates/node/src/handlers/*, crates/node/src/runtime/mod.rs
Uses shared live bounds for probe responses, paid-delivery clamping, and voucher validation.
Configuration and lifecycle wiring
crates/cli/src/commands/config.rs, crates/node/src/runtime/{mod.rs,reload.rs}
Seeds bounds at startup, updates reload messaging, and shuts down the watcher with the runtime.

Cache eviction driver

Layer / File(s) Summary
Cache measurement and release API
crates/cache/src/{engine.rs,metrics.rs}
Adds size snapshots, total-byte measurement, unpinned release-for-eviction, and eviction metrics.
Eviction configuration and validation
crates/common/src/config/*, crates/cli/src/commands/config.rs
Adds validated high-water, target, budget, and tick settings with template and summary output.
Eviction measurement and sweep loop
crates/node/src/runtime/eviction.rs
Implements hysteresis, pending-reclaim accounting, budgeted LRU sweeps, and metrics.
Runtime lifecycle integration
crates/node/src/runtime/mod.rs, crates/node/tests/*
Starts the driver with resolved settings and stops it through shutdown signaling.

Proxy-warming discovery

Layer / File(s) Summary
RTT candidate ordering and map
crates/client-pull/src/{discovery.rs,rtt_map.rs}
Adds finite-RTT candidate ordering and a bounded EWMA RTT map with stale-entry handling.
Proxy-warming CLI contract
crates/common/src/cli/fetch.rs, crates/cli/src/commands/{fetch.rs,bundle_pull.rs}
Adds opt-in warming parameters and passes them through discovery.
Warming-aware provider selection
crates/cli/src/commands/fetch.rs
Selects qualifying nearer non-holders as warming proxies before falling back to holder ranking.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FetchCLI
  participant Discovery
  participant Holder
  participant WarmingProxy
  FetchCLI->>Discovery: probe candidates with warming parameters
  Discovery->>Holder: measure holder RTT and availability
  Discovery->>WarmingProxy: measure bonded non-holder RTT
  Discovery-->>FetchCLI: select qualifying proxy or best holder
  FetchCLI->>WarmingProxy: route paid fetch when proxy warming qualifies
Loading
sequenceDiagram
  participant Runtime
  participant EvictionDriver
  participant CacheEngine
  participant BlobGC
  Runtime->>EvictionDriver: start with thresholds and sweep budget
  EvictionDriver->>CacheEngine: measure size and list candidates
  EvictionDriver->>CacheEngine: release unpinned candidates
  CacheEngine->>BlobGC: remove named tags
  BlobGC-->>EvictionDriver: later reclaim reflected in size measurement
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

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

Wires three previously-designed but unused primitives into the runtime: (1) on-chain delivery-rate bounds (via PaymentChannel.getRateBounds() + RateBoundsUpdated) into node handlers, (2) an async cache-eviction driver to enforce cache_size_mb, and (3) an opt-in client-side proxy-warming trigger (RTT-threshold + margin) in the CLI fetch discovery path.

Changes:

  • Add live RateBounds handle (atomic pair via ArcSwap), seed it from config then overwrite from on-chain getRateBounds() at startup, and keep it current via a watcher + periodic re-read.
  • Add cache eviction driver loop with hysteresis + budgeted sweeps, plus cache-health metrics and new engine primitives (size_snapshot, total_bytes, release_for_eviction).
  • Add opt-in proxy-warming knobs to the CLI and implement RTT-only ordering/selection of a bonded non-holder proxy candidate.

Reviewed changes

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

Show a summary per file
File Description
crates/node/tests/support/mod.rs Update test wiring to pass shared RateBounds instead of floor/ceiling scalars.
crates/node/tests/sighup_signal.rs Seed new config fields (rate_bounds_poll_interval_sec, eviction params) in unit test config literal.
crates/node/tests/self_hosted_discovery.rs Update probe handler construction to use RateBounds.
crates/node/tests/probe_loopback.rs Update handler construction paths to pass RateBounds.
crates/node/tests/probe_0rtt.rs Update handler construction to use RateBounds.
crates/node/tests/anvil_bringup_shutdown_e2e.rs Seed new blockchain/cache config knobs for e2e bringup tests.
crates/node/src/runtime/reload.rs Clarify reload semantics: config delivery bounds are now only a pre-chain seed; add cache eviction knobs to restart-required detection.
crates/node/src/runtime/mod.rs Wire on-chain rate-bounds startup read + watcher into runtime bring-up; wire eviction driver background task and shutdown handling.
crates/node/src/runtime/eviction.rs New async eviction driver loop enforcing cache_size_mb with hysteresis, pending-reclaim accounting, and metrics updates.
crates/node/src/rate_bounds.rs New RateBounds/Bounds types with atomic pair publication and non-panicking clamp.
crates/node/src/rate_bounds_watcher.rs New watcher sink for RateBoundsUpdated + periodic authoritative getRateBounds() poll.
crates/node/src/metrics.rs Add rate-bounds watcher liveness/panic metrics; expand metrics tests for new cache eviction/capacity series.
crates/node/src/lib.rs Export new rate_bounds and rate_bounds_watcher modules.
crates/node/src/handlers/probe.rs Switch probe signing clamp from scalar floor/ceiling to shared live RateBounds.
crates/node/src/handlers/client/wire.rs Switch stream signing clamp from scalar floor/ceiling to shared live RateBounds.
crates/node/src/handlers/client/voucher.rs Enforce voucher rate floor against live on-chain-sourced floor.
crates/node/src/handlers/client/mod.rs Thread RateBounds through ClientHandlerDeps/ClientHandler.
crates/incentive/src/payment_channel.rs Extend alloy bindings with getRateBounds() and RateBoundsUpdated event.
crates/common/src/config/types.rs Add TOML schema fields for rate-bounds poll cadence and eviction driver knobs; update docs to reflect seed vs live behavior.
crates/common/src/config/resolved.rs Add resolved config fields for rate-bounds poll cadence and eviction driver knobs.
crates/common/src/config/mod.rs Add defaults/bounds + validation for new blockchain/cache knobs; update payment resolve docs to “pre-chain seed”.
crates/common/src/cli/fetch.rs Add CLI flags for opt-in proxy warming and RTT threshold/margin tuning.
crates/client-pull/src/rtt_map.rs Add staged (not-yet-wired) EWMA RTT map implementation with tests.
crates/client-pull/src/lib.rs Export rtt_map module.
crates/client-pull/src/discovery.rs Add WarmingCandidate and proxy_warming_order logic + tests.
crates/cli/tests/config_validate.rs Update sample resolved config used by CLI config validation tests with new fields.
crates/cli/src/commands/fetch.rs Plumb proxy-warming params into discovery and allow selecting a near non-holder proxy when enabled.
crates/cli/src/commands/config.rs Print new blockchain/cache config fields in config validate summary; update default config template comments.
crates/cli/src/commands/bundle_pull.rs Thread proxy-warming params into bundle pull discovery path.
crates/cache/src/metrics.rs Expand cache metrics doc + add eviction/capacity gauges and counters.
crates/cache/src/engine.rs Add eviction driver primitives (size_snapshot, total_bytes, release_for_eviction) and operator-evict counter.

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

Comment thread crates/node/src/runtime/eviction.rs Resolved
Comment thread crates/node/src/runtime/eviction.rs Resolved
Comment thread crates/node/src/handlers/probe.rs Resolved
Comment thread crates/node/src/handlers/client/wire.rs Resolved

@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 several key features, including an LRU cache-eviction driver loop to enforce cache size limits, live on-chain delivery-rate bounds tracking with a dedicated watcher, and client-side proxy-warming capabilities to seed regional copies based on latency. It also stages a per-peer RTT map structure for future use and adds corresponding configuration parameters, metrics, and CLI arguments. Feedback on the changes suggests optimizing the eviction driver's tick loop to avoid redundant disk-store walks by fetching the size snapshot once and reusing it across size calculation and sweeping.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/node/src/runtime/eviction.rs Resolved
@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.49% (was 81.74%, ▼ 0.25%) — 51937/63732 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 89.86% 2428/2702 ▲ +0.14%
crates/cli/src/commands/bundle_pull.rs 57.01% 545/956 ▼ 0.06%
crates/cli/src/commands/config.rs 69.47% 182/262 ▼ 0.07%
crates/cli/src/commands/fetch.rs 36.31% 289/796 ▼ 1.78%
crates/client-pull/src/discovery.rs 84.74% 161/190 ▲ +5.45%
crates/client-pull/src/lib.rs 88.68% 909/1025 ● 0.00%
crates/client-pull/src/rtt_map.rs 100.00% 109/109 new
crates/common/src/cli/fetch.rs 100.00% 69/69 ● 0.00%
crates/common/src/config/mod.rs 96.91% 6782/6998 ▼ 0.09%
crates/common/src/config/resolved.rs 100.00% 48/48 ● 0.00%
crates/node/src/handlers/client/mod.rs 87.79% 568/647 ▼ 0.04%
crates/node/src/handlers/client/voucher.rs 80.12% 133/166 ● 0.00%
crates/node/src/handlers/client/wire.rs 94.17% 113/120 ▲ +0.05%
crates/node/src/handlers/probe.rs 87.59% 254/290 ▲ +0.26%
crates/node/src/metrics.rs 94.41% 1014/1074 ▲ +0.08%
crates/node/src/rate_bounds.rs 100.00% 73/73 new
crates/node/src/rate_bounds_watcher.rs 0.00% 0/84 new
crates/node/src/runtime/eviction.rs 37.93% 66/174 new
crates/node/src/runtime/mod.rs 45.33% 1111/2451 ▼ 0.93%
crates/node/src/runtime/reload.rs 96.87% 1518/1567 ▲ +0.04%
History
Commit Total Δ vs base
dfb0396 81.49% ▼ 0.25%
b82debc (HEAD) 81.49% ▼ 0.25%

…ds logging

Addresses automated review feedback on #1357.

Eviction driver (Copilot ×2, Gemini): `tick` called `total_bytes()` — itself a
`size_snapshot()` store walk — and then `sweep` called `size_snapshot()` again,
so sustained eviction pressure did two full walks per tick and the two readings
could disagree. Both in-code comments already claimed a single shared walk,
describing a refactor that was never completed. `tick` now takes one snapshot,
derives the footprint from it, and passes it to `sweep` by reference; the
snapshot-failure path collapses to one site.

Rate-bounds logging (Copilot ×2): `clamp()` takes an atomic snapshot internally,
but the clamp-warning then read `floor()` and `ceiling()` separately — two more
`ArcSwap` loads, and a concurrent governance update could make the logged pair
one that never produced the logged decision. Both handlers now take a single
`snapshot()` and use it for the clamp and the log.

Verified: fmt, clippy --all-targets, and cargo doc clean; 2236 tests passing.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit ed9c624 into main Jul 21, 2026
22 of 23 checks passed
@thiras
thiras deleted the feat/node-client-runtime-wiring-1172-1173-1174 branch July 21, 2026 14:37
yigitdot added a commit that referenced this pull request Jul 21, 2026
Conflicts came from #1357 (proxy warming) touching the same two files.

`crates/cli/src/commands/fetch.rs`: main threaded a `warming:
ProxyWarmingParams` argument through `discover_provider` and
`probe_and_rank` while this branch replaced `rpc_url` + `client_region`
with a single `chain: &ResolvedChain`. Kept both — `chain` for the
region and data dir, `warming` passed on to `probe_and_rank`. Main's
`#[allow(clippy::too_many_arguments)]` is dropped: the `chain`
consolidation takes the signature from 8 arguments back to 7, and
clippy confirms it is no longer needed.

`crates/client-pull/src/discovery.rs`: main's `WarmingCandidate` /
`proxy_warming_order` merged cleanly; only the test module collided,
where both sides are pure additions. Kept both sets.

`crates/cli/src/commands/bundle_pull.rs` auto-merged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request Aug 18, 2026
…1725)

Close the ADR 037 § Fallback gaps left open after the proxy-warming
trigger shipped (#1357): the fallback used only the first candidate,
there was no progress deadline, and the feature stayed default-off,
diverging from the ADR.

The "second payment channel" that blocked a real fallback is obsolete:
the shared payment pool (one pool fans out to every provider, each a
distinct lane) means failing over to another provider escrows no new
on-chain deposit, and the `ClientRangedStore` (keyed on hash + size)
resumes the partial, so a fail-over re-pays nothing already delivered.

- Classify each delivery failure (`retry_disposition`) using the retry
  dispositions already documented on `StreamError`, plus the pool
  model's global facts: payment-layer rejection, `OriginBlacklisted`,
  and an over-cap blob are terminal; every node-specific refusal, stall,
  transport fault, or bao/hash-verify failure fails over.
- `probe_and_order` returns the ordered failover list — proxy-warming
  non-holders first (nearest RTT), then holders nearest RTT — so a
  walker gets ADR 037's exact shape: proxy → next candidate → direct
  holder. `fetch` and `bundle pull` walk it, reusing the shared pool.
- Reuse the existing pull stall budget as the progress deadline; drop
  the never-implemented `proxy_warming.max_wait_ms`.
- Flip `--proxy-warming` to default-on (ADR 037): a declining or stalled
  proxy now fails over transparently, so it can no longer regress a
  fetch.
- Retire bundle pull's dormant `pick_excluding`/`fallback_candidates`
  scaffolding in favor of the shared ordered-list walk.
- Update ADR 037 to canon: pinned latency defaults (150 ms / 30 ms),
  stall-budget progress deadline, default-on with no regression.

Unit-tested: the classifier over every failure kind, and the failover
ordering (proxies-then-holders, margin filtering, region drop). An
end-to-end two-node discovery-failover test is left as follow-up.

Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

Node: implement cache eviction driver loop + cache-health metrics Node: fetch on-chain rate bounds (getRateBounds) + subscribe to RateBoundsUpdated

2 participants