Repository navigation
fix(cache): quarantine a held blob when its serve trips a stored hash mismatch - #2002
Conversation
… mismatch (#1984) Every serve export already validates held bytes against the content root (iroh-blobs traverse_ranges_validated), so a rotten or tampered chunk group aborts the serve and is never billed. The node never acted on that mismatch: the hash stayed served and announced until a permanent operator evict. A LeafHashMismatch/ParentHashMismatch from export_bao_range_stream or outboard_pairs now quarantines the hash in memory. refuses() withholds it from serve, announce, and re-acquisition; its tags drop (pin included) so GC reclaims the entry; the quarantine lifts once the store no longer holds the hash (lazily on has/serve_audit/pull_through_range and on each origin rescan), and a pull-through re-admits a verified copy. Adds decdn_cache_held_corruption_quarantined_total and corrects ADR 038 / engine docs that claimed held content is never re-hashed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
Coverage reportTotal: 82.75% (was 82.75%, ● 0.00%) — 77118/93194 lines
History
|
…l re-protection Review follow-ups on the #1984 quarantine: - ServeAudit::Unavailable { evicted } becomes { withdrawn } and covers a quarantine, so dispatch answers EvictedSinceProbe instead of running the paid miss-path fill, which re-tagged the corrupt entry and wedged the quarantine. - protect_partial and the streaming commit skip the tag for a quarantined hash; each origin rescan re-drops the tags of a still-held quarantined entry, which also retries a failed tag drop. - A short read over a complete blob quarantines. A partial blob quarantines only when the failing groups lie inside its present ranges, so a sparse absent range never withdraws healthy content. - Log when GC is disabled and when the lift's status check fails. - Docs: stop naming evict as corruption recovery (CLI help, admin RPC, protocol EvictedSinceProbe, ADR 011); fix pin wording, validation scope, lazy lift, and ASD-STE100 splits in ADR 038/040. - Tests: parent mismatch via .obao4, truncation, partial present/absent ranges, serve_audit withdrawn + lift, rescan bulk lift. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate findings remain in partial-blob quarantine classification and paid miss-path validation; documentation nits also remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds serve-triggered quarantine for held blobs whose validated serving detects stored corruption, allowing GC-based recovery and later re-admission.
Changes:
- Adds quarantine lifecycle, withdrawal gates, tag release/retry logic, and recovery checks.
- Adds corruption metrics and coverage for mismatches, truncation, partial ranges, and GC recovery.
- Updates protocol semantics, operator documentation, ADRs, and changelog.
Final review comments identify three moderate findings in engine.rs (votes: 3, 1, 1), one moderate finding in dispatch.rs (1 vote), and documentation nits in engine.rs, protocol/src/client.rs, and adr/040-cache-policy.md (1, 2, and 1 votes respectively).
File summaries
| File | Reviewed change |
|---|---|
crates/protocol/src/client.rs |
Documents quarantine withdrawal response semantics. |
crates/node/src/metrics.rs |
Exposes the quarantine metric. |
crates/node/src/handlers/client/serve_encoder.rs |
Updates serve refusal documentation. |
crates/node/src/handlers/client/dispatch.rs |
Handles withdrawn hashes during miss fills. |
crates/common/src/cli/node.rs |
Updates eviction help text. |
crates/common/src/admin.rs |
Updates administrative eviction documentation. |
crates/cache/tests/held_corruption.rs |
Tests corruption detection, quarantine, truncation, partial ranges, and recovery. |
crates/cache/src/ranged_store.rs |
Applies quarantine refusal behavior. |
crates/cache/src/metrics.rs |
Adds the quarantine counter. |
crates/cache/src/engine.rs |
Implements quarantine detection, lifecycle, tag handling, and lifting. |
CHANGELOG.md |
Records the quarantine behavior. |
adr/appendix-observability.md |
Documents the new metric. |
adr/040-cache-policy.md |
Specifies the cache quarantine policy. |
adr/038-bao-verified-range-streaming.md |
Documents validated range streaming. |
adr/011-content-takedown.md |
Clarifies withdrawal and takedown semantics. |
Review details
Suppressed comments (5)
adr/040-cache-policy.md:341
- This ADR overstates the short-read trigger for partial blobs. The implementation deliberately does not quarantine a partial blob on
UnexpectedEof, because an absent sparse range can produce the same error; only a complete blob always quarantines, and partial mismatches are quarantined only when their failing groups are present. Please state that exception here so the policy matchesquarantine_on_mismatch.
content root. A hash mismatch or a short read over held content means that the
stored copy changed after admission, from disk rot or tampering. The engine
then quarantines the hash. The node stops serving, announcing, and
re-acquiring the hash. A stream request for it answers `EvictedSinceProbe`.
crates/cache/src/engine.rs:625
- This documentation now contradicts the dispatch behavior introduced in this PR:
dispatchrejects everywithdrawnaudit before entering the fill path, so a fill cannot undo an operator eviction. Please describe re-acquisition only for a quarantine after GC has reclaimed the entry; otherwise callers reading this public enum may assume an evicted hash can be restored by a normal fill.
/// miss path must not fill a withdrawn hash. A fill of an evicted hash
/// undoes the takedown. A fill of a quarantined hash lands on the
/// corrupt entry and pays for bytes it can never serve.
crates/cache/src/engine.rs:2765
- A partial blob can have a real short read in a range it does hold—for example, truncating its data file and serving that present range.
UnexpectedEofis mapped toChunkRanges::all(), so the containment check necessarily overlaps the absent ranges and leaves the hash unquarantined; later serves of the still-present ranges repeat the failure. Keep the absent-sparse-range false-positive guard, but pass the requested/failing range (or its location) into this classification so an EOF in a present range is quarantined; add a regression for a truncated partial range.
/// so any of the three errors quarantines it. A partial blob is
/// quarantined only when the failing chunk groups lie inside its present
/// ranges; a short read never quarantines a partial blob. Every other
crates/cache/src/engine.rs:4408
- This quarantine hook only handles errors emitted by
export_bao. The paid cache-miss serve path usesCoherentFrameProducer/encode_ranges_validatedoverNodeRangedStore::read, so a held range corrupted afterseed_held_outboardcan abort that serve without enteringquarantine_on_mismatch; the next request can repeat the same failure. Route that validation failure through the quarantine path (or use the same exporting path for the miss serve).
Some(EncodedItem::Error(cause)) => {
engine.quarantine_on_mismatch(hash, &cause).await;
crates/node/src/handlers/client/dispatch.rs:621
- This only checks the initial
serve_auditsnapshot. In the miss path,windowopens the paid pull leg beforeseed_held_outboard, whoseoutboard_pairscall can quarantine a corrupt held range. A partial blob with a missing requested span therefore still proceeds into the fill, then gets withdrawn during seeding. Validate held ranges before opening the pull or re-checkrefusesat that boundary so a quarantined hash cannot start a paid fill.
if audit.is_withdrawn() {
- Files reviewed: 15/15 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ll after seeding withdraws the hash Copilot review follow-ups on #2002: - ParentHashMismatch names a node whose chunk_range() is already in 1 KiB chunks; the extra << chunk_log widened it 16x, so a real parent mismatch on a partial blob overlapped absent ranges and went unquarantined. - A short read now counts over the requested export range, so an EOF inside a partial blob's present ranges quarantines instead of never counting. - The serve-miss window paths check refuses() right after seed_held_outboard and skip spawning the paid pull (upstream or origin egress) when seeding quarantined the hash; the owner fails the session, releases leases, and frees the floor reservation. - Docs: EvictedSinceProbe summary says "withdrew"; ADR 040 states the partial exceptions; ServeAudit::withdrawn wording is conditional. - Tests: parent mismatch inside a partial's present ranges; short read over a partial's present range. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
|
Response to the Copilot review's suppressed findings (all in 661430b unless noted):
|
Closes #1984
Summary
The issue's verification comment showed that serve legs never emit unverified bytes. iroh-blobs
export_baorunstraverse_ranges_validated, so a rotten or tampered group aborts the serve before it is billed. The real gap: the node never acted on that mismatch. The hash stayed served and announced, and every buyer tripped it again until an operator ranevict. That is a permanent takedown, which is the wrong recovery for a legitimate hash.This PR adds a serve-trip quarantine and no periodic scrub. A sampled scrub would re-derive a signal the validated serve export already gives more freshly (spec-discipline gate 5). It would also add a knob and idle disk IO.
Trigger.
export_bao_range_streamoroutboard_pairshits one of:LeafHashMismatchorParentHashMismatchIo(UnexpectedEof), a short fileA complete blob always quarantines. A partial blob quarantines only when the failing chunk groups lie inside its present ranges; an absent sparse range reads back as zeros or EOF, so it is not proof of corruption.
Withdrawal.
refuses()includes the quarantine. The hash is withheld from serve, probe, DHT announce, the origin-held index, and re-acquisition.ServeAudit::Unavailable { evicted }is renamed{ withdrawn }and covers the quarantine, so dispatch answersEvictedSinceProbeand never runs a paid miss-path fill for it.Release. The quarantine drops the protecting tags (also for pinned hashes) so GC reclaims the entry.
protect_partialand the streaming commit skip the tag for a quarantined hash.Lift. The quarantine lifts once the store reports
NotFound. The check runs inhas,serve_audit,pull_through_range, and each origin rescan. A pull-through then re-admits a verified copy.Observability.
decdn_cache_held_corruption_quarantined_total, with a registry row and the fresh-registry exposure test.Docs.
evictis no longer described as corruption recovery in the CLI help, the admin RPC, protocolEvictedSinceProbe, or ADR 011.Review follow-ups (pr-review-toolkit)
Fixed in 1e905bd:
NotFoundafter a signed probe.Io) did not quarantine.Deferred, not in this PR:
CacheError::StoredCorruptionso callers such asseed_held_outboardcan log a quarantine distinctly (today it isCacheError::Store+ the engine warn).inspect/evict --dry-runreporting quarantine.fs_rescan_interval_sec = 0, a reclaimed origin-held hash re-enters the DHT set only when a lookup lifts it.Out of scope: the ADR 003 voucher claim (#1985). The issue's items 2 and 3 lose their motivation per the verification comment.
Test plan
crates/cache/tests/held_corruption.rs(8 tests), which tamper with the live store:refuses,hasfalse,serve_auditwithdrawn, gone fromiter_hashes,getrefused, idempotent counter, not evictedoutboard_pairstrip.obao4serve_auditlifts, and a re-pull servescargo nextest run -p decdn-cache -p decdn-node -p decdn-common -p decdn-protocol: 2156 passed-D warnings --all-targets,cargo doc -D warnings, pre-commitSuggest retitling #1984 per the verification comment: "cache: no post-admission scrub; rotten blobs stay advertised until a serve trips".
🤖 Generated with Claude Code
https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j