Skip to content

feat(cache): opt-in remote-origin prewarm, settle two deferred decisions, clear #1504/#1508 drift - #1510

Merged
thiras merged 4 commits into
mainfrom
batch/v0.1-follow-through
Jul 29, 2026
Merged

thiras merged 4 commits into
mainfrom
batch/v0.1-follow-through

Conversation

@thiras

@thiras thiras commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Follow-through on the two refactors that just landed on main — #1504 (every watcher off eth_getLogs replay onto enumeration views) and #1508 (the discovery half of #1130). Four issues close together because each is now small and self-contained against that baseline. Two are v0.1 milestone (#1130, #1470).

1. cache.prewarm — the http/s3 half of #1130 (v0.1)

CacheEngine::prewarm / prewarm_pinned pull cache.pinned_hashes into the store at startup and on decdn node reload, so the first request for pinned content doesn't pay full pull-through latency.

  • Opt-in, restart-required. It spends origin egress on bytes nobody has asked for; that must never turn itself on across an upgrade.
  • fs origins are skipped by design. Their content is already local and is advertised through the origin-held index — importing it would duplicate the bytes on the same disk, which is the storage doubling the issue set out to fix. Gated on origin kind at the call site (prewarm_enabled_for), which is unit-tested across flag × chain shape.
  • Goes through populate_local, so the Peer origin is never consulted — prewarm never fronts USDC to a peer for content nobody requested. Pinned by a spy-origin test.
  • Never re-pulls a refused hash, so a decdn node evict takedown survives it.
  • Runs detached: an unreachable origin cannot block bring-up.
  • Pinned-set budget warning. Pinned blobs are LRU-exempt, so a pin set larger than cache.cache_size_mb makes the eviction driver's high-water target permanently unreachable while the disk grows. Nothing checked this before. Warn, not fail or truncate — the pin set is a deliberate operator statement.
  • Reload passes the whole pin set rather than PinDiff's delta: prewarm no-ops on a resident hash, so the extra cost is one local presence check per pin, and in exchange a pin warmed earlier but since lost gets repaired.
  • New metrics: decdn_cache_prewarm_{blobs,bytes,failures}_total.

The fs zero-copy pass-through half is deliberately not here — it needs a ReadAt/Write-generic variant of bao-range's encode_verified_range, a new serve tier in dispatch.rs, an origin-backed sibling to export_bao_range_stream, and a decision on where a computed .obao4 is persisted. Follow-up issue to be filed; the triage comment on #1130 asked for exactly this split.

2. Candidate.stake: Option<u64> → u64 (#1470, v0.1)

The Option conflated "not looked up" with "looked up, holds no bond", and filter_map made unknown rank strictly below a known zero. That is a hazard the moment on-chain stake lookup is wired: a chain read succeeds for some peers and fails for others — a mixed population is the steady state for an RPC read, not an edge case — so one flaky call would have silently sunk a well-staked peer below an unbonded one.

Resolved at the boundary (the issue's option 1): the type can no longer express a failed read, so the lookup layer must retry or drop the candidate. Behaviour is unchanged — nothing populates stake yet. The three tests that pinned the None-vs-Some(0) distinction are gone; three_way_zero_stake_falls_through_to_random_tier is kept in adapted form as equal_stake_falls_through_to_random_tier, since "tier 2 must not short-circuit on the first max" is still real behaviour.

3. Metric reason splits: siblings, not labels (#1475)

Settled in favour of sibling counters. decdn_probe_hold_unavailable_total{reason} stays the one labeled family and is now documented as the deliberate exception — earned because its three values share a single alert and remedy axis, which is what a label serves and siblings make awkward. No metric is renamed, so no alert or dashboard changes.

The real defect this surfaced: the observability appendix documented decdn_gossip_messages_rejected_total{reason="clock_skew"}, a labeled name the node has never exported (the code emits decdn_gossip_messages_rejected_clock_skew_total). The same aspirational name also appeared in ADR 019 and in four places in appendix-peer-table-eviction.md, where reason=table_full was described as a metrics label — it is a log token; the node aggregates every gossip rejection into one counter. All corrected, and the three sibling families are now listed in the appendix registry, where previously they appeared in zero operator-facing artifacts.

4. #1493 — already fixed by #1504, no code needed

Verified on main:

  • contracts/src/ContentBlacklist.sol:221 has mapping(bytes32 region => EnumerableSet.Bytes32Set) _regionHashes, with blacklistedHashCount / blacklistedHashes(offset, limit) — the paginated form supersedes the issue's proposed per-index blacklistedHashAt, which should not be added.
  • blacklist_watcher.rs:1161 bootstraps from a pinned-block enumeration with a count-vs-seen abort on a partial read. Fail-closed, no replay.
  • ColdStart::FromBlock no longer exists anywhere in the workspace.

Its "scope to cached content at admission time" alternative was not taken: handlers/client/dispatch.rs:201 still needs a synchronous is_denied / is_chain_denied verdict for the ADR 011 §StreamRequest wire-indistinguishability requirement, so the region mirror stays.

5. Drift left by #1504 / #1508

  • chain_origin_directory.rs — the module doc still described discovery by "replaying AssignmentActivated logs from a configured start block" and a cursor "persisted (CheckpointKey::Origin)" that "resumes the replay floor". The code enumerates at a pinned block and seeds the tail with persist: None. Three sites fixed (§ Snapshot strategy, § Failure model, watcher()).
  • chain_events/backfill.rs — named the origin directory as a REORG_MARGIN_BLOCKS consumer via chain_origin_directory::replay_floor, which no longer exists; the settlement watcher is now the only one. Also dropped the dead REPLAY_WINDOW_BLOCKS / buyer-reconcile references.
  • content_deny.rs — "the watcher fills that in once it has replayed".
  • cache.fs_rescan_interval_sec (added by feat: origin-aware discovery — advertise origin-held content before pull-through (#1130) #1508) reached neither DEFAULT_CONFIG nor the config validate summary, so its resolved value was invisible to operators. Both back-filled alongside prewarm.

Verification

  • cargo fmt --check, cargo clippy --all-targets (-D warnings) — clean workspace-wide.
  • cargo nextest run — 2650 passed, 0 failed.
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --workspace, cargo test --doc — clean.
  • pre-commit run --all-files — all hooks pass on the changed files. One pre-existing failure is untouched by this branch: markdownlint MD032 on .github/workflows/issue-triage.md, which fails identically on main (last modified in ci(agentic): stop Agentic Triage reporting failures as issues #1002).
  • No contract change, so the Solidity jobs and .gas-snapshot are untouched.

New tests: 4 cache-crate prewarm integration tests (mixed present/absent pin set + idempotence, missing-from-origin failure accounting, refused-hash takedown, peer-origin spy), prewarm_enabled_for classification across flag × origin-chain shape, a config validate summary assertion for both new lines, and a resolver default test.

Noted, not fixed

adr/appendix-observability.md also lists decdn_peer_table_evicted_registry_total, which the node does not export. Same drift class, but not a reason-split, so it is out of this batch's scope.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added opt-in cache prewarming for pinned content from remote (HTTP/S3) origins at startup and reload.
    • Added cache.prewarm plus fs_rescan_interval_sec to configuration templates and decdn config validate summaries.
    • Added prewarm Prometheus metrics (including refused/failure outcomes) and reports, with cancellation and single in-flight warm behavior.
    • Added warnings when pinned content exceeds cache.cache_size_mb.
  • Bug Fixes
    • Improved candidate selection by treating stake consistently (known “no bond” as 0) and updating tie-break ordering.
  • Documentation
    • Clarified gossip/rejection and metric naming conventions, including clock-skew tracking and operator-facing registry series.

Closes #1130
Closes #1470
Closes #1475
Closes #1493

…ons, clear #1504/#1508 drift

Follow-through on the two refactors that just landed on main: #1504 (every
watcher off eth_getLogs replay onto enumeration views) and #1508 (the discovery
half of #1130). Four issues close together because each is now small and
self-contained against that baseline.

cache.prewarm (#1130, v0.1) — the http/s3 half of origin-aware serving.
`CacheEngine::prewarm`/`prewarm_pinned` pull the pinned set into the store at
startup and on reload so the first request doesn't pay full pull-through
latency. Opt-in and restart-required: it spends origin egress on bytes nobody
has asked for. fs origins are skipped by design — their content is already
local and is advertised through the origin-held index, so importing it would
duplicate the bytes on the same disk, which is what the issue set out to fix.
Goes through populate_local, so it never fronts USDC to a peer, and never
re-pulls a refused hash, so a takedown survives it. Runs detached: an
unreachable origin cannot block bring-up. A pinned set larger than
cache_size_mb now warns — pinned blobs are LRU-exempt, so the eviction driver
could otherwise never reach its target. Three new decdn_cache_prewarm_* metrics.
The fs zero-copy pass-through half is deliberately not here; it needs a
ReadAt/Write-generic bao-range API and a new serve tier.

selection stake policy (#1470, v0.1) — Candidate.stake becomes u64. The Option
conflated "not looked up" with "looked up, holds no bond", and the tie-break
ranked unknown strictly below a known zero. Once on-chain stake lookup is
wired, a chain read succeeds for some peers and fails for others, so one flaky
RPC call would have silently sunk a well-staked peer below an unbonded one. The
type can no longer express a failed read; the lookup layer must retry or drop
the candidate. Behaviour is unchanged — nothing populates stake yet.

metrics reason splits (#1475) — sibling counters are the convention;
probe_hold_unavailable{reason} is the documented exception, earned because its
values share one alert and one remedy. No metric renamed. The observability
appendix documented decdn_gossip_messages_rejected_total{reason=...}, a labeled
name the node has never exported; corrected to the real sibling, along with the
same claim in ADR 019 and appendix-peer-table-eviction, and the three sibling
families are now in the registry where they previously appeared nowhere.

#1493 needs no code: #1504 already shipped ContentBlacklist._regionHashes with
blacklistedHashCount/blacklistedHashes, blacklist_watcher bootstraps from a
pinned-block enumeration, and ColdStart::FromBlock is gone workspace-wide. Its
"scope to cached content" alternative was not taken — dispatch still needs a
synchronous verdict for ADR 011 wire-indistinguishability.

Drift left behind: chain_origin_directory's module doc still described a
start-block replay with a persisted cursor (the code seeds at the enumeration
block and persists nothing), backfill.rs cited a replay_floor that no longer
exists, content_deny said the watcher "replays", and fs_rescan_interval_sec
never reached DEFAULT_CONFIG or the config validate summary.

Closes #1130
Closes #1470
Closes #1475
Closes #1493

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 29, 2026 17:16
@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: bf6e8180-80ba-460f-87f1-0d312f320d23

📥 Commits

Reviewing files that changed from the base of the PR and between 77e9dbd and bd82ec0.

📒 Files selected for processing (20)
  • CHANGELOG.md
  • adr/appendix-observability.md
  • crates/cache/src/engine.rs
  • crates/cache/src/metrics.rs
  • crates/cache/tests/prewarm.rs
  • crates/cli/src/commands/config.rs
  • crates/cli/tests/config_validate.rs
  • crates/common/src/config/mod.rs
  • crates/common/src/config/resolved.rs
  • crates/common/src/config/types.rs
  • crates/gossip/src/metrics.rs
  • crates/incentive/src/channel_open_error.rs
  • crates/node/src/dht/chain_origin_directory.rs
  • crates/node/src/dispatch.rs
  • crates/node/src/metrics.rs
  • crates/node/src/node_origin.rs
  • crates/node/src/rate_limit.rs
  • crates/node/src/runtime/mod.rs
  • crates/node/src/runtime/reload.rs
  • crates/node/src/selection.rs
🚧 Files skipped from review as they are similar to previous changes (16)
  • crates/common/src/config/resolved.rs
  • crates/common/src/config/types.rs
  • crates/gossip/src/metrics.rs
  • crates/cli/src/commands/config.rs
  • adr/appendix-observability.md
  • crates/incentive/src/channel_open_error.rs
  • crates/node/src/node_origin.rs
  • crates/node/src/dispatch.rs
  • crates/node/src/runtime/reload.rs
  • crates/node/src/rate_limit.rs
  • crates/common/src/config/mod.rs
  • crates/node/src/runtime/mod.rs
  • CHANGELOG.md
  • crates/cli/tests/config_validate.rs
  • crates/node/src/dht/chain_origin_directory.rs
  • crates/node/src/selection.rs

Walkthrough

The change adds remote-origin cache prewarming at startup and pinned-hash reloads, introduces prewarm reporting and metrics, changes candidate stake to a required u64, and updates configuration, tests, ADRs, changelog entries, and observability documentation.

Changes

Cache prewarming

Layer / File(s) Summary
Prewarm configuration and runtime flow
crates/common/src/config/..., crates/node/src/runtime/..., crates/cli/...
cache.prewarm defaults to disabled, is enabled only for remote origins, runs at startup and reload, supports coalescing and cancellation, and is exposed in configuration summaries and templates.
Prewarm engine accounting and validation
crates/cache/..., crates/node/src/metrics.rs, crates/cache/tests/prewarm.rs
CacheEngine reports fetched, present, refused, failed, cancelled, and byte outcomes; metrics and tests cover fetches, idempotence, cancellation, origin filtering, and overlapping warms.

Numeric candidate stake

Layer / File(s) Summary
Stake representation and selection
crates/node/src/selection.rs, crates/node/src/node_origin.rs
Candidate.stake changes from Option<u64> to u64; zero denotes no bond, stake tie-breaking uses numeric maxima, and probe/cache construction supplies zero values with updated tests.

Observability and node documentation

Layer / File(s) Summary
Metric naming and operational documentation
adr/..., CHANGELOG.md, crates/gossip/..., crates/incentive/..., crates/node/src/{dispatch,metrics,rate_limit}.rs
Documentation standardizes sibling counters, records the labeled exception, corrects gossip rejection metric names, and documents table_full as a log token.
Chain and origin-directory documentation
crates/node/src/chain_events/backfill.rs, crates/node/src/content_deny.rs, crates/node/src/dht/chain_origin_directory.rs
Comments describe enumeration-based origin bootstrapping, non-persistent live-tail cursors, retry rescans, and settlement-watcher-only durable cursor rewind.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Runtime
  participant CacheEngine
  participant RemoteOrigin
  Runtime->>CacheEngine: start prewarm_pinned
  CacheEngine->>RemoteOrigin: fetch missing pinned hashes
  RemoteOrigin-->>CacheEngine: blob or failure
  CacheEngine-->>Runtime: return PrewarmReport
  Runtime->>CacheEngine: prewarm after pinned-hash reload
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.

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.22% (was 80.21%, ▲ +0.01%) — 54188/67550 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 90.91% 2889/3178 ▲ +0.01%
crates/cache/src/lib.rs 100.00% 28/28 ● 0.00%
crates/cli/src/commands/config.rs 75.47% 243/322 ▲ +0.63%
crates/common/src/config/mod.rs 97.05% 6853/7061 ▲ +0.01%
crates/common/src/config/resolved.rs 100.00% 33/33 ● 0.00%
crates/gossip/src/metrics.rs 50.00% 3/6 ● 0.00%
crates/gossip/src/service.rs 87.72% 457/521 ● 0.00%
crates/gossip/src/validation.rs 100.00% 343/343 ● 0.00%
crates/incentive/src/channel_open_error.rs 96.05% 73/76 ● 0.00%
crates/node/src/chain_events/backfill.rs 97.56% 40/41 ● 0.00%
crates/node/src/content_deny.rs 96.74% 89/92 ● 0.00%
crates/node/src/dht/chain_origin_directory.rs 70.73% 575/813 ● 0.00%
crates/node/src/dispatch.rs 94.80% 583/615 ● 0.00%
crates/node/src/metrics.rs 95.39% 972/1019 ▲ +0.03%
crates/node/src/node_origin.rs 91.28% 932/1021 ▲ +0.05%
crates/node/src/rate_limit.rs 98.70% 303/307 ▲ +1.95%
crates/node/src/runtime/mod.rs 46.35% 1104/2382 ▼ 0.17%
crates/node/src/runtime/reload.rs 96.13% 1762/1833 ▼ 0.40%
crates/node/src/selection.rs 97.29% 430/442 ▼ 0.24%
History
Commit Total Δ vs base
77e9dbd 80.18% ▼ 0.03%
1ad4c31 80.19% ▼ 0.02%
fce6a9d 80.18% ▼ 0.02%
bd82ec0 (HEAD) 80.22% ▲ +0.01%

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

This PR adds an opt-in remote-origin prewarm path for pinned content (to reduce first-request latency for http/s3 origins), updates node-selection stake handling to remove the ambiguous “unknown stake” state, and fixes/clarifies several observability and watcher-era documentation drifts after the watcher enumeration refactors.

Changes:

  • Add cache.prewarm (default off, restart-required) that prefetches cache.pinned_hashes from remote origins at startup and on reload; add cache prewarm metrics and integration tests.
  • Change Candidate.stake from Option<u64> to u64 and update selection logic/tests and candidate construction sites accordingly.
  • Settle and document “reason splits use sibling counters (not labels)” across code + ADR appendices; fix multiple metrics/docs drifts and config-validate summary output.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/node/tests/sighup_signal.rs Update cache config test fixture to include prewarm.
crates/node/tests/anvil_bringup_shutdown_e2e.rs Update e2e config fixture to include prewarm.
crates/node/src/selection.rs Make Candidate.stake a u64; update tier-2 ranking and tests.
crates/node/src/runtime/reload.rs Persist boot-time prewarm enablement; trigger rescan + optional prewarm on reload.
crates/node/src/runtime/mod.rs Add origin-kind-aware prewarm gating + pinned-set budget warning + startup prewarm task.
crates/node/src/rate_limit.rs Document sibling-counter convention for probe rate-limit rejection metrics.
crates/node/src/node_origin.rs Set stake to 0 (known-no-bond) at candidate construction sites; clarify future lookup boundary.
crates/node/src/metrics.rs Document sibling-counter convention and the labeled probe-hold exception.
crates/node/src/dispatch.rs Document sibling-counter convention for dispatch rejection metrics.
crates/node/src/dht/chain_origin_directory.rs Update module docs to match enumerate-at-pinned-block + non-persisted cursor model.
crates/node/src/content_deny.rs Update watcher bootstrapping comment to “bootstrap enumeration” (not replay).
crates/node/src/chain_events/backfill.rs Update module docs after replay consumers removal; clarify remaining reorg-margin usage.
crates/incentive/src/channel_open_error.rs Document sibling-counter convention and why labels are not used for these reason splits.
crates/gossip/src/validation.rs Clarify that rejection “labels” are log-stable tokens, not currently used as Prometheus labels.
crates/gossip/src/service.rs Fix docs: table_full is a log token; gossip rejections are aggregated metrics-wise.
crates/gossip/src/metrics.rs Document sibling-counter convention and probe-hold labeled exception.
crates/common/src/config/types.rs Add cache.prewarm config knob with detailed semantics and restart-required note.
crates/common/src/config/resolved.rs Add resolved prewarm: bool to ResolvedCache.
crates/common/src/config/mod.rs Add DEFAULT_PREWARM=false, resolve cache.prewarm, and add resolver default test.
crates/cli/tests/config_validate.rs Add assertions that validate-summary prints fs_rescan_interval_sec and prewarm.
crates/cli/src/commands/config.rs Print fs_rescan_interval_sec and prewarm in decdn config validate summary; document both in template.
crates/cache/tests/prewarm.rs Add integration tests covering prewarm idempotence, failures, refused hashes, and peer-origin exclusion.
crates/cache/src/metrics.rs Add decdn_cache_prewarm_{blobs,bytes,failures}_total counters.
crates/cache/src/lib.rs Re-export PrewarmReport.
crates/cache/src/engine.rs Implement CacheEngine::prewarm / prewarm_pinned + PrewarmReport.
CHANGELOG.md Document prewarm feature, stake type change, and metrics reason-split convention settlement.
adr/appendix-peer-table-eviction.md Fix observability text to match aggregate gossip rejection counter + log token behavior.
adr/appendix-observability.md Add “reason splits” convention section; add prewarm metrics; correct gossip metric names.
adr/019-node-onboarding.md Update onboarding metric reference to decdn_gossip_messages_rejected_clock_skew_total sibling counter.

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

Comment thread crates/node/src/runtime/reload.rs Resolved
Comment thread crates/cache/src/engine.rs Resolved
thiras and others added 2 commits July 29, 2026 20:27
…d on reload

Both from PR review.

`prewarm_pinned`'s doc told reload callers to pass `PinDiff`'s added hashes
instead of re-walking every pin — leftover from an earlier design. The reload
path deliberately does the opposite, and says why: `prewarm` no-ops on a
resident hash, so the delta saves no origin egress, and the wholesale run
additionally repairs a pin warmed earlier but since lost. As written the doc
pointed the next reader at "fixing" working code. Now states the idempotence
guarantee and demotes the delta to an optional optimization.

The reload prewarm log omitted `report.refused` while the startup log carries
it. Reload is where that field earns its place most: it is exactly when an
operator pins a hash that is already denylisted or operator-evicted, and
without it that pin silently never warms.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… doc claims from review

Multi-agent review of this PR surfaced defects in the prewarm work and, more
awkwardly, claims in the de-rot half that were themselves wrong. Verified each
against source before acting.

Behavioural:

- Metrics counted a coalesced waiter as a real fetch. `populate_inner` returns
  `Ok(())` both when it ran the pull and when it waited on someone else's, so
  two overlapping prewarms counted 2 blobs and 2x bytes for one unit of paid
  egress. It now reports `FillOwnership`; only the owner is counted. Pinned by a
  test that asserts the counter against the origin's actual request count, and
  verified to fail against the previous behaviour.
- Prewarm ran through shutdown. It was the only store-writing JoinSet task with
  no stop signal, so a restart mid-warm left it pulling against a store closed
  underneath it: every remaining pin failed its presence check and
  prewarm_failures_total landed at ~the pin-set size — exactly the signature
  that counter documents as "your pinned_hashes are wrong". Now cancelled before
  cache.shutdown(), same rationale as pull_through_bg_shutdown.
- The pin-budget warning was gated behind `prewarm`, which defaults off. An
  oversized pin set starves the eviction driver on every node however the
  content arrived, so the check never ran where it mattered. Hoisted to
  unconditional bring-up and added to the reload path.
- Reload spawned an unbounded detached warm on every SIGHUP regardless of
  whether pins changed. Now gated on a non-empty diff and single-flighted;
  rescan HEADs are not coalesced, so overlapping passes cost N x pin-set HEADs.
- `refused` was unmetered, so a pin set fully covered by a blacklist was
  metrically identical to a healthy no-op — the one outcome meaning an operator
  instruction is being actively overridden. Added the sibling counter.
- The fs-skip log blamed filesystem origins when zero origins were configured.
- `decdn config validate` echoed the raw flag, printing `enabled` for configs
  where prewarm provably cannot run. `prewarm_enabled_for` moved to
  decdn-common so validate evaluates the real predicate and reports INERT.

Doc claims corrected (this PR's own purpose is removing such claims):

- "the one labeled family" is false — `streams_active` is a Family too. main
  said "the one labeled Counter in this group", which was precise; restored as
  "the one labeled reason split" across all six sites.
- The exception's rationale claimed the three probe-hold values "share one
  alert". `Disabled`'s own doc says alerting on it would be nonsensical, and the
  alert filters to reason="exhausted". Reworded to what is true: one aggregate,
  one budget axis.
- "fs origins ignore the flag" is only true for an fs-ONLY chain; a mixed chain
  warms and imports the fs-served pins. Corrected at all five sites.
- `prewarm_bytes` was documented as wire egress; it sums stored size, which
  differs under DecompressMode::Auto. `failed == input` was stated as a
  diagnosis when it merges three causes.
- selection.rs claimed the type "cannot carry a failed read" — it cannot
  *distinguish* one; nothing enforces the boundary yet. Also fixed a dangling
  ADR 001 citation carried forward verbatim.

Drift the first sweep missed, in the files it claimed to have cleared:
chain_origin_directory.rs still described flushing an origin checkpoint, a
persisted cursor, and a replay floor in bootstrap_cache; runtime/mod.rs still
listed the Origin checkpoint flush as load-bearing shutdown ordering.

Tests: the replacement for the deleted three-way stake test flattened every
stake, so tier 2's retain never dropped anyone and the tier2->tier3 handoff went
uncovered; restored. The refused-hash test asserted `!has`, which restates has's
own short-circuit rather than proving no re-pull; now counts origin requests.
Added coverage for the generic prewarm entry, its dedup guarantee and the
partition identity, overlapping-pass accounting, the reload prewarm flag, the
restart-notice gate, and the [Http, Peer] chain the node actually builds.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…t claims the last round got wrong

Second review round on the fix commit. Two of its fixes were incomplete and two
of its doc "corrections" were themselves wrong — verified each against source
this time rather than against the previous commit message.

Behavioural:

- The reload single-flight dropped the losing reload outright, and its comment
  claimed the in-flight pass "re-reads the live pin set". It does not: both
  rescan_origins and prewarm_pinned snapshot the pinned set when they start, so
  a pin added afterwards is invisible. Worse, `warm` was computed per task, so a
  reload that only REMOVED a pin would hold the lock through its rescan while a
  concurrent reload that ADDED one was dropped entirely — deterministic, not a
  race, and never retried until restart. The skip also dropped the rescan half,
  silently breaking the documented "startup and reload still rescan" guarantee
  that `fs_rescan_interval_sec = 0` relies on. Replaced with dirty/wanted flags
  set before the lock attempt and consumed by the holder in a loop, so a losing
  reload's pin set is genuinely covered and the comment is now true.

- The shutdown-cancellation fix was applied to the startup warm only; the reload
  warm still called the uncancellable entry point from a bare spawn, so it kept
  the exact bug the last commit claimed to fix. Both legs now share one token,
  owned by RuntimeReloadState.

- PrewarmReport gains `cancelled`, recorded where the fact is known. The runtime
  was sampling `token.is_cancelled()` after awaiting, which reports a completed
  warm as truncated if the cancel lands in between. The partition identity is
  restated against a new `attempted()` accessor, since a cancelled run leaves
  unreached hashes in no bin — the type doc asserted it unconditionally while
  prewarm_cancellable's doc said the opposite, 860 lines apart in one file.

- `local_only = true` had become a bare literal at the prewarm call site,
  duplicating the never-front-USDC-to-a-peer guarantee. `populate_local_reporting`
  is now its single owner.

Wrong claims from the previous round:

- The `prewarm_bytes` rationale was inverted. It said `pull_through_bytes` meters
  wire bytes and the two diverge under DecompressMode::Auto. HttpOrigin disables
  reqwest decompression and decodes itself, and the pull meter sits downstream of
  that decoder — both count content bytes, as engine.rs already documented. The
  real divergences are failed pulls, coalesced fills, and a failed size lookup.

- CHANGELOG cited `decdn_streams_failed_total` as evidence for a claim about
  which metrics are labelled. That metric exists in no crate.

Three ADR edits from the previous round never landed at all — the batch script
aborted on a failed assertion before writing — so the appendix, which CLAUDE.md
makes the source of truth, still carried the "shares one alert" rationale, the
probe-only RejectLayer row, and both retracted prewarm claims. Applied
independently this time.

Also corrected: node_origin's comment contradicted the one it cross-referenced;
the chain_origin_directory analogy cited a path that propagates as an example of
one that degrades; channel_open_error kept a premise the same edit undercut;
prewarm's doc named a function it no longer calls; `prewarm_failures` claimed
three causes when there are more; and a superseded CHANGELOG entry described
replay machinery #1504 deleted.

Tests: cancellation had zero coverage — added pre-cancelled and mid-set cases,
the latter driven by an origin that cancels from inside its own fetch so there
is no timing. The peer spy now serves real bytes, so a regression fails the
report rather than only the fetch counter. Added the refused-metric assertion,
the mixed fs+remote chain every doc correction is about, and a single-flight
test that holds the guard to prove a losing reload leaves its work flagged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@thiras
thiras merged commit 3807c0d into main Jul 29, 2026
25 checks passed
@thiras
thiras deleted the batch/v0.1-follow-through branch July 29, 2026 18:33
alpergundogdu added a commit that referenced this pull request Jul 30, 2026
PR #1510 bundled five changes; this removes only the `cache.prewarm`
feature (its item #1) and leaves the other four intact — the #1470
`Candidate.stake: u64` change, the #1475 metric sibling-counter
convention docs, and the #1504/#1508 watcher-drift fixes.

Removed:
- `CacheEngine::prewarm` / `prewarm_cancellable` / `prewarm_pinned` and
  the `PrewarmReport` / `PrewarmOutcome` / `FillOwnership` types.
  `populate_inner` reverts to `CacheResult<()>` (the `FillOwnership`
  metering existed only to feed prewarm's coalesced-vs-fetched counts).
- The four `decdn_cache_prewarm_*` counters.
- `cache.prewarm` config field, `DEFAULT_PREWARM`, `prewarm_enabled_for`,
  and the `decdn config validate` / template reporting of the flag.
- Startup prewarm spawn, shutdown cancellation, and the reload-time
  single-flight warm machinery (`warm_in_flight` / `warm_dirty` /
  `warm_wanted` / `prewarm_stop`).
- The prewarm integration-test file and all prewarm unit tests, plus the
  observability-appendix rows and CHANGELOG entry.

Kept (per request): the oversized-pin-set warning
(`warn_if_pins_exceed_cache`), which is independent of prewarm — it runs
unconditionally at startup and on reload. The reload path reverts to a
plain detached `rescan_origins` + budget-warn spawn. The
`fs_rescan_interval_sec` `config validate` reporting (a #1508 drift fix)
is also kept.

Verification: cargo build, clippy --all-targets, fmt --check clean;
cache/common/cli 1096 tests and node 897 tests pass; anvil-e2e compile
gate and RUSTDOCFLAGS=-D warnings doc clean.

Co-authored-by: Claude Opus 4.8 <[email protected]>
thiras added a commit that referenced this pull request Jul 30, 2026
Closes #1517. Closes #1513.

Two issues from the #1510 review, both the same defect: the node's observability
surface made claims nobody checked.

**#1517 — a poisoned coalescing mutex cost egress and USDC in silence.** Three of
the six `inflight` lock sites discarded the `PoisonError`; nothing cleared the
poison, so one panic permanently disabled fill-coalescing — unbounded egress on a
metered http/s3 origin, and duplicate USDC vouchers upstream on the `Peer` origin.
All six now route through one `Inner::lock_inflight` that recovers the guard and
calls `Mutex::clear_poison`, so coalescing *survives* poison rather than the loss
merely being reported, and the new counter measures incidents rather than requests
that followed one. Two bugs surfaced that neither issue recorded: `InflightGuard::drop`
leaked the map entry (parking every later request for that hash on a dead `Notify`),
and `populate` — the path that actually spends USDC — had no poison coverage at all.

**#1513 — the registry documented series the exporter never emitted.** The appendix
had no way to say "specified, not built", so ~a third of its rows read as shipped;
`monitoring/` had inherited the rot, including an alert that could never fire. A new
`Status` column (live/planned) is the root-cause fix and doubles as the gate's
allowlist: 47 live rows are now CI-enforced against the encoder output, 18 planned
rows explicitly marked.

**Monitoring-breaking:** forked dashboards need the `decdn_gossip_peer_table_size`
rename; six alerts were deleted or replaced and six panels repointed. See the
CHANGELOG for the full list.

Reviewed by four agents plus Copilot; the fixes that came out of that — including
`clear_poison` (my "cannot be cleared" claim was wrong on this MSRV), a falsehood
left in `crates/node/src/rate_limit.rs`, invalid PromQL in six doc comments, and a
runbook section that misdescribed hash-mismatch metering — are folded in.

No wire, config, ABI, or contract change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants