Skip to content

feat(cli): decdn bundle pull — fetch a bundle's blobs (#391) - #945

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/bundle-pull-391
Jun 18, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/bundle-pull-391

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #391 (the bundle pull half — bundle create and adr/appendix-bundles.md already shipped).

What

decdn bundle pull realizes a bundle manifest by fetching every referenced blob over the paid cdn/client/v1 path — the same kernel as decdn fetch.

decdn bundle pull -i ./site.bundle.json -o ./out/        # local manifest
decdn bundle pull --hash b3:abc…        -o ./out/        # fetch manifest blob first, then its entries
# flags: [--jobs N] [--overwrite] [--dry-run] [--json] + the usual fetch/chain/network flags
  • Per-entry node selection (Client-side node discovery: a client has no way to find a node to fetch from #936): with --node-id every entry is pulled from that one node; otherwise each entry independently discovers a holder among the region-nearest active nodes (CapacityBond, read once), so different entries can come from different nodes.
  • Concurrency (--jobs, default 4): a payment channel's vouchers use a strictly-increasing nonce, so a per-provider async mutex serializes fetches that share a channel (which also makes the lazy open-or-reuse first-touch race-free); distinct providers run in parallel. Implemented with single-task buffer_unordered (probe_once isn't Send, so not tokio::spawn).
  • Resume-friendly: output writes are atomic (temp-then-rename, after the fetch path's BLAKE3 check), so a present file is verified-good — pull skips existing files by default, --overwrite forces a re-fetch. Entry paths are resolved with the appendix path-safety rules (../absolute/escaping rejected).
  • --dry-run reports the plan with no network/chain/keystore activity (entries enumerable for -i; --hash can't list them without fetching).
  • Verification is intrinsic — content addressing BLAKE3-checks every blob, so there's no separate --verify toggle.

Refactor (shared with fetch)

  • Extracted ClientFetchArgs (net/chain/target/limit flags) out of FetchArgs; both fetch and bundle pull #[command(flatten)] it, so resolution + node-selection have one definition.
  • Promoted the fetch kernel to pub(crate) (resolve_chain, resolve_target_node, probe_and_rank, open_or_reuse, fetch_blob, write_blob_atomic, parse_hash) so both commands share one paid-fetch path.

Design choices (confirmed with the issue owner)

Per-entry discovery, shared flattened args, and full --jobs concurrency were the chosen options over the lighter alternatives.

Deferred

Coverage is the region-nearest candidate set probed per entry; an entry no probed node holds fails (re-runnable). Broadening beyond that set is a follow-up.

Verification

cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo doc, cargo deny, and cargo nextest run --workspace (1871 passed) all green; #578 iroh-blobs-free invariant holds. Smoke-tested create → dry-run (-i + --json) and the -i/--hash mutual-exclusion + required-group errors. New unit tests cover safe_join path-safety, manifest parse/version-gate, and the outcome summary.

Do not merge yet.

🤖 Generated with Claude Code

`decdn bundle pull` realizes a bundle manifest: read it from a local file
(`-i`) or fetch it first by its own hash (`--hash`, mutually exclusive), then
fetch every entry over the paid `cdn/client/v1` path into `-o <dir>`.

Node selection is per-entry (#936): with `--node-id` every entry is pulled from
that node, otherwise each entry discovers its own holder among the region-nearest
active nodes (CapacityBond, read once). Entries fetch with `--jobs` concurrency.

Voucher-nonce safety: a channel's vouchers use a strictly increasing nonce, so a
per-provider async mutex serializes fetches sharing a channel (also making the
lazy open-or-reuse first-touch race-free); distinct providers run in parallel.
`--jobs` caps total in-flight entries. Concurrency uses single-task
`buffer_unordered` (probe_once isn't Send), not tokio::spawn.

Output writes are atomic (temp-then-rename after the fetch path's BLAKE3 check),
so a present file is verified-good: pull skips existing files by default
(re-runs resume), `--overwrite` forces re-fetch. Entry paths are resolved with
the appendix path-safety rules (`..`/absolute/escaping rejected). `--dry-run`
reports the plan with no network/chain activity.

Refactor: extracted `ClientFetchArgs` (net/chain/target/limit flags) from
`FetchArgs`, flattened into both `fetch` and `bundle pull`; promoted the
fetch kernel (`resolve_chain`, `resolve_target_node`, `probe_and_rank`,
`open_or_reuse`, `fetch_blob`, `write_blob_atomic`, `parse_hash`) to
`pub(crate)` so both commands share one paid-fetch path.

adr/appendix-bundles.md: documents the implemented pull (was "deferred").

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 18, 2026 11:39

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request implements the decdn bundle pull command, allowing users to fetch all blobs referenced in a bundle manifest into an output directory over the paid cdn/client/v1 path. It refactors the existing fetch logic to share core functions (such as chain resolution, node discovery, and blob fetching) between the single-blob fetch and multi-blob bundle pull commands. Feedback on the changes suggests adding .multiple(false) to the bundle_source ArgGroup in BundlePullArgs to properly enforce mutual exclusion between the -i and --hash arguments at the parser level.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/common/src/cli/bundle.rs Resolved

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

Adds the missing client-side “bundle realization” workflow by implementing decdn bundle pull, and refactors the existing paid-fetch CLI surfaces so fetch and bundle pull share a single set of network/chain/target/limit flags and the same paid-fetch kernel.

Changes:

  • Introduce decdn bundle pull (local -i manifest or --hash manifest blob) with per-entry node selection and bounded concurrency.
  • Extract ClientFetchArgs out of FetchArgs and flatten it into both fetch and bundle pull for shared resolution + node-selection behavior.
  • Promote key fetch helpers to pub(crate) so bundle pulling reuses the same paid-fetch path (chain resolution, probing/ranking, open-or-reuse, atomic write).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/common/src/cli/mod.rs Re-exports new CLI arg types (BundlePullArgs, ClientFetchArgs).
crates/common/src/cli/fetch.rs Splits shared paid-fetch flags into ClientFetchArgs, keeps FetchArgs as a thin wrapper.
crates/common/src/cli/bundle.rs Adds bundle pull subcommand + args, flattening ClientFetchArgs.
crates/cli/src/main.rs Passes global --config path through to bundle dispatch (needed for pull).
crates/cli/src/commands/mod.rs Registers new bundle_pull command module.
crates/cli/src/commands/fetch.rs Refactors fetch logic into reusable pub(crate) kernels for bundle pull.
crates/cli/src/commands/bundle.rs Dispatches bundle pull to the new implementation and wires config path.
crates/cli/src/commands/bundle_pull.rs Implements decdn bundle pull (manifest load/fetch, safe path join, per-provider locking, concurrency, reporting).
adr/appendix-bundles.md Updates the bundle appendix to document the now-implemented pull behavior.

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

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

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 84.21% (was 84.69%, ▼ 0.48%) — 38417/45619 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle.rs 92.43% 391/423 ▼ 0.44%
crates/cli/src/commands/bundle_pull.rs 29.36% 101/344 new
crates/cli/src/commands/fetch.rs 36.63% 174/475 ▼ 1.71%
crates/cli/src/main.rs 71.88% 23/32 ▲ +2.91%
History
Commit Total Δ vs base
833a1e9 84.21% ▼ 0.48%
64f0758 (HEAD) 84.21% ▼ 0.48%

…--hash

- bundle pull: the human summary printed the output dir twice
  ("pulled <out> -> <out>"); now reads "pulled into <out> (...)". (Copilot)
- fetch: `--hash` help now mentions the `b3:` prefix `parse_hash` accepts, not
  just `0x`. (Copilot)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu merged commit 9c8b971 into main Jun 18, 2026
20 checks passed
@alpergundogdu
alpergundogdu deleted the claude/bundle-pull-391 branch June 18, 2026 13:34
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.

decdn bundle subcommand: pull and create directory bundles

2 participants