Repository navigation
feat(cli): decdn bundle pull — fetch a bundle's blobs (#391) - #945
Conversation
`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]>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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-imanifest or--hashmanifest blob) with per-entry node selection and bounded concurrency. - Extract
ClientFetchArgsout ofFetchArgsand flatten it into bothfetchandbundle pullfor shared resolution + node-selection behavior. - Promote key
fetchhelpers topub(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.
Coverage reportTotal: 84.21% (was 84.69%, ▼ 0.48%) — 38417/45619 lines
History
|
…--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]>
Closes #391 (the
bundle pullhalf —bundle createandadr/appendix-bundles.mdalready shipped).What
decdn bundle pullrealizes a bundle manifest by fetching every referenced blob over the paidcdn/client/v1path — the same kernel asdecdn fetch.--node-idevery 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.--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-taskbuffer_unordered(probe_onceisn'tSend, so nottokio::spawn).--overwriteforces a re-fetch. Entry paths are resolved with the appendix path-safety rules (../absolute/escaping rejected).--dry-runreports the plan with no network/chain/keystore activity (entries enumerable for-i;--hashcan't list them without fetching).--verifytoggle.Refactor (shared with
fetch)ClientFetchArgs(net/chain/target/limit flags) out ofFetchArgs; bothfetchandbundle pull#[command(flatten)]it, so resolution + node-selection have one definition.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
--jobsconcurrency 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, andcargo nextest run --workspace(1871 passed) all green;#578iroh-blobs-free invariant holds. Smoke-tested create → dry-run (-i+--json) and the-i/--hashmutual-exclusion + required-group errors. New unit tests coversafe_joinpath-safety, manifest parse/version-gate, and the outcome summary.Do not merge yet.
🤖 Generated with Claude Code