Skip to content

refactor(client-pull): dedup empty-claim guard; drop the CLI's ignored pull cap - #1996

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/client-pull-followup-cleanup
Sep 11, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/client-pull-followup-cleanup

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

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 → HashMismatch check (#1054) lived hand-copied in driver::drive (production, before an empty store is finalized) and in the in-memory fetch_in_memory_once path. 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 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 PullDeadlines::capped deadlines carrying a hard_cap the pull ignores, and re-ran the "cap outlasts open+window" validation that common.validate() already performs at argument-parse time.

  • Switched both call sites to 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.
  • Rewrote the now-stale comments in fetch.rs / bundle_pull.rs and the ClientFetchArgs::validate docstring to state the truth: --timeout-ms bounds discovery (discovery_cap), not the pull.

Deliberately left in scope for a later design change

PullDeadlines::capped / hard_cap field / hard_cap() / whole_transfer / with_hard_cap all stay: the test-util in-memory stream_fetch* wrappers still cap the whole exchange through them. Fully retiring --timeout-ms as a pull cap (and with it the now production-unused capped constructor and the validate() relation it guards) is a genuine user-facing design question about what --timeout-ms should 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 loopback client_rejects_an_empty_claim_for_a_non_empty_hash — all pass. No public API changed (the shared guard is pub(crate)).

🤖 Generated with Claude Code

…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]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 08:47

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

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 => HashMismatch into reject_empty_claim_for_nonempty_root(...) and reuse it in both driver::drive and fetch_in_memory_once.
  • Switch CLI fetch and bundle pull to build PullDeadlines::new(...) (dropping the previously passed but ignored hard_cap).
  • Update CLI/common documentation/comments to reflect that --timeout-ms bounds 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.

Comment thread crates/common/src/cli/fetch.rs Resolved
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.68% (was 82.68%, ● 0.00%) — 76511/92541 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle_pull.rs 54.84% 980/1787 ▲ +0.03%
crates/cli/src/commands/fetch.rs 42.00% 927/2207 ▲ +0.02%
crates/client-pull/src/driver.rs 92.73% 1148/1238 ▼ 0.01%
crates/client-pull/src/lib.rs 89.46% 1697/1897 ▲ +0.04%
crates/common/src/cli/fetch.rs 96.41% 188/195 ● 0.00%
History
Commit Total Δ vs base
df3e09b 82.68% ● 0.00%
fb69f45 (HEAD) 82.68% ● 0.00%

…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]>
@alpergundogdu
alpergundogdu merged commit 923b172 into main Sep 11, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/client-pull-followup-cleanup branch September 11, 2026 09:15
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.

2 participants