Skip to content

fix(cli): stop gating client fetch on blob size by default - #1891

Merged
alpergundogdu merged 3 commits into
mainfrom
claude/total-bytes-derivation-8bfbb4
Sep 1, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
claude/total-bytes-derivation-8bfbb4

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

What

Change the shared ClientFetchArgs::max_blob_mb default from 1024 MiB → 1 TiB (1,048,576 MiB), so decdn fetch and bundle pull download normal content by its hash without tuning, while an over-claimed size is still bounded.

Both commands flatten the same ClientFetchArgs, so this single-field change moves them identically.

Why

--max-blob-mb defaulted to 1024 MiB and was enforced before pulling any bytes: a delivery whose signed total_bytes exceeded the ceiling was refused with BlobTooLargeClaim. For an explicit client fetch that's the wrong default — the user named a content hash and an output file, and the common case (AI model delivery) is multi-GB blobs, so the default silently refused legitimate downloads and forced users to discover --max-blob-mb.

The ceiling's original stated purpose — guarding client memory against a provider that over-claims total_bytes — does not hold on the fetch path:

  • fetch streams to the on-disk ClientRangedStore (.partial), not a RAM buffer;
  • it buffers only received bytes in memory, so RAM stays bounded whatever the claim;
  • an over-claimed total_bytes fails bao verification against the requested hash almost immediately, so the phantom tail is never written or paid.

Why 1 TiB and not unlimited

An earlier revision defaulted to 0 (unlimited). Review flagged the remaining edge: with no ceiling the ranged store still pre-sizes a sparse bao outboard sidecar (~0.4% of total_bytes) via set_len at creation, sized from the provider-claimed total. RAM is unaffected, and verification rejects a lying size — but on a non-sparse filesystem or an apparent-size quota an absurd claim could surface a local disk error before verification runs.

1 TiB is far above any real blob (so normal fetches need no tuning) yet low enough that the existing pre-pull BlobTooLargeClaim gate refuses an over-claim before set_len, capping the outboard pre-size at ~4 GiB. 0 still disables the ceiling for anyone who wants it unbounded.

Scope

  • Default change plus a reworded help text (an optional client size ceiling / budget guard, with the on-disk outboard rationale spelled out). The gate mechanism is unchanged — it already treats 0 as unlimited and no resolver rejects any value.
  • Fixed two now-stale comments (hard_cap rationale, and the max_blob_mb_does_not_influence_the_deadlines test comment) that called the flag a "memory ceiling".
  • The node's cache.max_blob_size_mb serve/buyer ceiling is untouched — a shared cache pulling untrusted node-to-node claims still needs it.

Where the partial + sidecars live

For decdn fetch -o <output> the store sits beside the output file, fully visible (no hidden cache dir): <output>.partial (blob), <output>.partial.obao4 (outboard), <output>.partial.ranges (resume record). finalize promotes .partial in place to exactly <output> and cleans up the sidecars. Resume is location-based: re-running the same command re-pulls only the missing ranges. So the outboard pre-size the 1 TiB bound caps lands on whatever volume -o targets.

Reviewer notes

  • --max-blob-mb N still works exactly as before for anyone who wants a tighter (or looser, or 0) ceiling; only the default moved.
  • A test builder fixture (crates/cli/src/commands/fetch.rs) still constructs an explicit max_blob_mb: 1024; it's a literal, not a default assertion, so it stays valid.

Verification

  • cargo build -p decdn-common -p decdn-cli — passed
  • cargo nextest run -p decdn-common -p decdn-cli — 864 passed, 0 skipped
  • cargo clippy -p decdn-common -p decdn-cli — clean
  • pre-commit hooks (fmt, clippy, doc, deny) — passed on each commit

🤖 Generated with Claude Code

`decdn fetch` and `bundle pull` defaulted `--max-blob-mb` to 1024 MiB,
refusing to download a blob whose signed `total_bytes` exceeded that
ceiling before pulling any bytes. For an explicit client fetch that is
the wrong default: the user named a content hash and an output file, the
common case (AI model delivery) is multi-GB blobs, and the ceiling's
stated purpose — guarding client memory against an over-claimed
`total_bytes` — does not hold on this path. The fetch path streams to
the on-disk ranged store, allocates only for received bytes, and a
provider that over-claims `total_bytes` fails bao verification against
the requested hash regardless of the ceiling.

Flip the shared `ClientFetchArgs::max_blob_mb` default 1024 -> 0 (0 =
no ceiling). Both commands flatten this one field, so they behave
identically. The gate already treats 0 as unlimited and no resolver
rejects it, so this is a default change only; the flag stays as an
opt-in user budget guard. Reword its doc to describe it as a size
ceiling and budget guard rather than a memory safeguard, and fix two
comments that still called it a memory ceiling.

The node's `cache.max_blob_size_mb` serve/buyer ceiling is untouched: a
shared cache pulling untrusted node-to-node claims still needs it.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 1, 2026 10:28

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 adjusts the shared CLI fetch argument defaults so the client-side --max-blob-mb ceiling no longer blocks large content-hash downloads by default, while keeping the flag available as an opt-in size/budget guard for decdn fetch and bundle pull.

Changes:

  • Change ClientFetchArgs::max_blob_mb clap default from 1024 MiB to 0 (unlimited).
  • Reword --max-blob-mb help text to describe it as an optional size/budget ceiling rather than a memory safeguard.
  • Update related comments/tests to reflect the new semantics (no longer tying timeout rationale to --max-blob-mb).

💡 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
alpergundogdu and others added 2 commits September 1, 2026 11:32
The `--max-blob-mb` doc said the streaming pull "allocates only for
received bytes", which understated one on-disk cost: the ranged store
pre-sizes a sparse bao outboard sidecar (~0.4% of total_bytes) via
set_len before verification runs. With the unlimited default an absurd
`total_bytes` claim can still surface a local disk/quota error even
though RAM stays bounded. Say so, and point at the flag as the bound.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
An unlimited (`0`) `--max-blob-mb` leaves the ranged store pre-sizing a
sparse bao outboard sidecar (~0.4% of `total_bytes`) via `set_len` from a
provider-claimed size with no bound. RAM is unaffected (the pull buffers
only received bytes), and an over-claim fails bao verification against the
requested hash — but on a non-sparse filesystem or an apparent-size quota
an absurd claim could still surface a local disk error before verification
rejects it.

Default `--max-blob-mb` to 1 TiB (1,048,576 MiB) instead. That is far
above any real blob, so normal fetches still need no tuning, while the
existing pre-pull `BlobTooLargeClaim` gate refuses an over-claim before
`set_len` runs — capping the outboard pre-size at ~4 GiB. `0` still
disables the ceiling for anyone who wants it unbounded.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Coverage report

Total: 82.60% (was 82.59%, ● 0.00%) — 70754/85662 lines

File Coverage Lines Δ
crates/common/src/cli/fetch.rs 96.22% 178/185 ● 0.00%
History
Commit Total Δ vs base
955e907 (HEAD) 82.60% ● 0.00%

@alpergundogdu
alpergundogdu merged commit fd5ff7b into main Sep 1, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/total-bytes-derivation-8bfbb4 branch September 1, 2026 10:52
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