Repository navigation
feat(client): add a public bundle pull, decdn_client::bundle - #2436
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Path-containment, reserved-state collisions, ignored region restrictions, cumulative reporting, and manifest-fetch interruption need correction.
5 open findings
Symlinked ancestors allow remote entries to escape destination · New SIGINT watcher starts too late during manifest acquisition · New Cache-owned paths are not fully reserved from remote entries · New Region allowlist is not enforced before probing candidates · New Pull counters are not reset between BundlePuller pulls · New
What changed in this PR
Moves bundle pulling from the CLI into the public decdn-client SDK while retaining CLI behavior.
Changes:
- Adds
BundlePuller, funding, outcomes, manifests, and observer APIs. - Moves bundle execution and cache logic into the client crate.
- Refactors the CLI into a thin SDK caller.
| File | Description |
|---|---|
CHANGELOG.md |
Documents the public bundle API. |
crates/cli/src/commands/bundle_pull.rs |
Adopts BundlePuller. |
crates/cli/src/commands/bundle_pull/tests.rs |
Updates CLI-focused tests. |
crates/cli/src/commands/fetch.rs |
Shares hash parsing and fault context. |
crates/cli/src/commands/mod.rs |
Removes obsolete bundle modules. |
crates/cli/src/commands/pull_progress.rs |
Implements SDK observer callbacks. |
crates/cli/src/commands/pull_progress/tests.rs |
Tests observer-based progress. |
crates/client/src/bundle.rs |
Defines the public bundle API. |
crates/client/src/bundle/engine.rs |
Houses bundle execution logic. |
crates/client/src/bundle/engine/tests.rs |
Tests bundle execution behavior. |
crates/client/src/bundle/manifest_cache.rs |
Implements manifest caching. |
crates/client/src/bundle/manifest_cache/tests.rs |
Tests manifest caching. |
crates/client/src/bundle/skip_cache.rs |
Maintains incremental skip state. |
crates/client/src/bundle/skip_cache/tests.rs |
Tests skip-cache behavior. |
crates/client/src/lane_sources.rs |
Exposes fetch fault context. |
crates/client/src/lib.rs |
Exports bundle and session modules. |
crates/client/src/session.rs |
Adds public discovery defaults. |
crates/client/tests/snapshots/public_api__public_api.snap |
Records the expanded SDK surface. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let mut comps = Path::new(seg).components(); | ||
| match (comps.next(), comps.next()) { | ||
| (Some(Component::Normal(s)), None) => out.push(s), | ||
| _ => bail!("rejected unsafe component {seg:?} in entry path {rel:?}"), | ||
| } |
There was a problem hiding this comment.
Real, but it is on main already: safe_join was lexical in the CLI too, and this PR only moves it. A manifest cannot create the symlink, so one must already exist locally, but containment should still hold against it. Tracked in #2439 (no-follow / openat-style resolution).
| // Watched from here on: the first Ctrl-C cancels the pull, which stops | ||
| // every fetch where it is and still reports what landed; a second one | ||
| // exits at once. | ||
| let mut interrupt = Interrupt::watch(); |
There was a problem hiding this comment.
On main already: Interrupt::watch started after obtain_manifest before this PR, and the PR keeps that order. Tracked in #2439: watch from before the manifest fetch, and make that fetch cancellable.
| // Reserve the staging dir: an entry resolving inside | ||
| // `<out_root>/.decdn-partial/` would collide with a per-hash staging | ||
| // file, and `remove_staging` could then delete a materialized output. | ||
| Ok(dest) if dest.starts_with(out_root.join(STAGING_DIR)) => { | ||
| Slot::Failed(EntryOutcome::failed( | ||
| &en.path, | ||
| &anyhow::anyhow!( | ||
| "manifest path {:?} is inside the reserved staging directory {STAGING_DIR}/", | ||
| en.path | ||
| ), | ||
| )) | ||
| } |
There was a problem hiding this comment.
On main already: plan_slots reserved only .decdn-partial/ before this PR. Tracked in #2439: reserve .decdn-manifest.json and .decdn-bundles/ the same way.
| fn entry_candidates(registry: &[NodeCandidate], region: Option<&str>) -> Vec<NodeCandidate> { | ||
| discovery::select_candidates(registry.to_vec(), region, discovery::SELECT_K) |
There was a problem hiding this comment.
| let dedup = DedupSummary { | ||
| spliced_bytes: self.dedup_stats.spliced_bytes.load(Ordering::Relaxed), | ||
| hints_ignored: self.dedup_stats.hints_ignored.load(Ordering::Relaxed), | ||
| }; |
There was a problem hiding this comment.
Fixed in 43fbc5d: DedupStats::take swaps both counters to zero when a pull builds its report, so each BundleReport counts only its own pull. Test: dedup_counters_are_per_pull.
Address review on #2436: a BundlePuller that runs several pulls reports only each pull's own spliced bytes and ignored hints, and PullSite::region_allowlist says the bundle path samples region-first instead of applying it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
14ddffb to
43fbc5d
Compare
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 0727829 in the Show a line coverage summary of the most impacted files.
Updated |
Part of #2429. The bundle engine moves from the decdn CLI into decdn-client behind a public API: BundlePuller (built from ChainConfig, PullSite, an endpoint, a BuyerPoolStore and Funding), select_nodes, BundleManifest, BundleObserver/FileObserver for progress, a CancellationToken to stop, and a typed BundleOutcome with a BundleReport. The inputs live in the now-public decdn_client::session module. decdn bundle pull becomes a caller of it: it keeps clap, the --include/--exclude filter, --select, dry-run, the progress bars, Ctrl-C, the summary and --json report, and its error hints, and its output and exit codes do not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address review on #2436: a BundlePuller that runs several pulls reports only each pull's own spliced bytes and ignored hints, and PullSite::region_allowlist says the bundle path samples region-first instead of applying it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
43fbc5d to
0727829
Compare


What
Part of #2429 (2 of 3). Stacked on #2434, so the base is its branch. CI runs once this is retargeted to
main.This PR moves the bundle engine from
crates/cliintodecdn-clientbehind a public API,decdn_client::bundle:Fundingis eitherSelfOwned { signer, deposit }orDelegated { slot: CredentialSlot }.BundleEndisComplete,Interrupted,FundingNeeded { needed, error }orStopped(error).BundleObserver/FileObservercarry progress: run totals, a per-blob file bar, each landed entry, warnings and pool replacement.decdn_client::sessionbecomes public and holds the inputs:ChainConfig,PullSite,DepositPolicy,DiscoveryOptions(with aDefault).decdn bundle pullis now a thin caller. It still owns:--include/--excludefilter--selectand dry-runFileObserver--jsonPullReportFaultHintshookReviewer notes
crates/client/src/bundle.rs(the public surface) and the newcrates/cli/src/commands/bundle_pull.rs.bundle/engine.rsis the oldbundle_pull.rswith its CLI parts removed. ItsPullCtxnow owns its state instead of borrowing it, and progress, cancel and the entry log go through the observer.note:,warning:,failed:) and the same--jsonfield order, and exit codes stay 0/1/75/130. The 20 anvil e2e tests that parse--jsonand stderr pass.slot.current()live and makes the funding signal cover the whole bundle.Send. This is documented in the module docs.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-client -p decdn-cli: 1594 passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemsdecdn_client::bundleanddecdn_client::session.python3 .github/scripts/check_crate_edges.py: no edge change, and the CLI/client closures stay iroh-blobs/AWS-freecargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(/^cli_(bundle_pull|fetch)/) | binary(no_inline_test_modules)': 34/34 passed, against freshly built binariesCHANGELOG.mdentry added (Added)🤖 Generated with Claude Code