Repository navigation
refactor(client-pull): dedup empty-claim guard; drop the CLI's ignored pull cap - #1996
Conversation
…d pull cap Two review follow-ups from #1994. Share the empty-claim guard. The `total_bytes == 0 && hash != empty-root -> HashMismatch` check (#1054) lived hand-copied in `driver::drive` and the in-memory `fetch_in_memory_once` path. Extract one crate-private `reject_empty_claim_for_nonempty_root` both call, so the two verify sites for the trivial-empty-range bypass cannot drift. Drop the CLI's ignored pull hard-cap. Since #1994 the production pull path (`open_progressive_pull` / `driver::drive`) never consults `PullDeadlines`' `hard_cap`: a progressing pull is bounded only by the open bound and the stall window (#1134). The CLI's `fetch` and `bundle pull` still built `capped` deadlines carrying a `hard_cap` the pull ignores, and re-ran the cap-outlasts- stages validation `common.validate()` already performs at parse time. Switch both to `PullDeadlines::new` (functionally inert — the pull was never hard-capped) and rewrite the now-stale comments plus `ClientFetchArgs::validate` docs to state the truth: `--timeout-ms` bounds discovery, not the pull. `PullDeadlines::capped` / `hard_cap` / `whole_transfer` / `with_hard_cap` stay: the test-util in-memory wrappers still cap the whole exchange through them. Fully retiring `--timeout-ms` as a pull cap (and thus `capped`) is a separate design question, left out here. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
ClientFetchArgs::validate() still emits a user-facing error message claiming a “hard cap bounds the whole exchange,” which contradicts the updated documentation that the delivery pull is uncapped.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Refactors decdn-client-pull to deduplicate the “empty-claim for non-empty root” guard into a single shared helper, and updates the CLI fetch/bundle-pull call sites to stop constructing PullDeadlines::capped(...) (since the production pull path doesn’t consult hard_cap).
Changes:
- Extract
total_bytes == 0 && hash != empty_root => HashMismatchintoreject_empty_claim_for_nonempty_root(...)and reuse it in bothdriver::driveandfetch_in_memory_once. - Switch CLI
fetchandbundle pullto buildPullDeadlines::new(...)(dropping the previously passed but ignoredhard_cap). - Update CLI/common documentation/comments to reflect that
--timeout-msbounds discovery rather than the delivery pull.
File summaries
| File | Description |
|---|---|
| crates/common/src/cli/fetch.rs | Updates docs around ClientFetchArgs::validate and flag semantics (--timeout-ms vs delivery). |
| crates/client-pull/src/lib.rs | Adds the shared empty-claim rejection helper and uses it in the in-memory fetch path. |
| crates/client-pull/src/driver.rs | Replaces the duplicated empty-claim guard with the shared helper. |
| crates/cli/src/commands/fetch.rs | Stops constructing capped deadlines (removes ignored hard_cap) and updates comments. |
| crates/cli/src/commands/bundle_pull.rs | Same as fetch.rs: use uncapped deadlines and update comments. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.68% (was 82.68%, ● 0.00%) — 76511/92541 lines
History
|
…e pull Copilot review of #1996: `ClientFetchArgs::validate()` still errored with "the hard cap bounds the whole exchange," contradicting the updated docs that the delivery pull is uncapped. The contradiction ran wider than the one message — the `--timeout-ms` field help, the `hard_cap()` getter doc, and several validate-related test docs/names were all premised on `--timeout-ms` capping the blob fetch, which it has not since the pull path stopped consulting `PullDeadlines::hard_cap` (#1134/#1994). Bring all of them to the current truth: `--timeout-ms` bounds the CapacityBond registry read (discovery, `discovery_cap`); the delivery pull carries no overall wall-clock cap and is bounded only by `--stall-timeout-ms` and `--min-throughput-bps`, which together catch a dead or drip-feeding provider (#1797). The `validate()` check (`timeout > 2 × stall`) is preserved exactly — only its rationale is restated as a misconfiguration guard rather than a stall-detection one. Test assertions are unchanged; two tests are renamed off the old "hard cap disables stall detection" framing. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Follow-up to #1994, addressing the two cleanup findings from its review.
1. Share the empty-claim guard
The
total_bytes == 0 && hash != empty-root → HashMismatchcheck (#1054) lived hand-copied indriver::drive(production, before an empty store is finalized) and in the in-memoryfetch_in_memory_oncepath. They are genuinely separate verify sites for the trivial-empty-range bypass, so both need it — but as two copies they could drift, silently reopening the bypass on one path.Extracted into one crate-private
reject_empty_claim_for_nonempty_root(total_bytes, hash)that both call.2. Drop the CLI's ignored pull hard-cap
Since #1994 the production pull path (
open_progressive_pull/driver::drive) never consultsPullDeadlines::hard_cap: a progressing pull is bounded only by the open bound and the stall window (#1134). The CLI'sfetchandbundle pullstill builtPullDeadlines::cappeddeadlines carrying ahard_capthe pull ignores, and re-ran the "cap outlasts open+window" validation thatcommon.validate()already performs at argument-parse time.PullDeadlines::new(...). Functionally inert — the pull was never hard-capped;common.validate()?still runs before either call site and remains the parse-time guard on the flag relationship.fetch.rs/bundle_pull.rsand theClientFetchArgs::validatedocstring to state the truth:--timeout-msbounds discovery (discovery_cap), not the pull.Deliberately left in scope for a later design change
PullDeadlines::capped/hard_capfield /hard_cap()/whole_transfer/with_hard_capall stay: thetest-utilin-memorystream_fetch*wrappers still cap the whole exchange through them. Fully retiring--timeout-msas a pull cap (and with it the now production-unusedcappedconstructor and thevalidate()relation it guards) is a genuine user-facing design question about what--timeout-msshould mean now that the pull cannot be hard-capped — out of scope here rather than guessed.Verification
cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt --check,RUSTDOCFLAGS=-D warnings cargo doc --workspace --no-deps --document-private-items,cargo nextest run -p decdn-client-pull -p decdn-cli -p decdn-common(1370 passed), and the node loopbackclient_rejects_an_empty_claim_for_a_non_empty_hash— all pass. No public API changed (the shared guard ispub(crate)).🤖 Generated with Claude Code