Repository navigation
refactor(client): move the paid fetch's network leg into decdn-client - #2434
Conversation
Part of #2429. Holder discovery and probing, lane building, pool open-or-reuse and refill, the funding recovery step, watermark persistence and the per-provider stream cap move from the decdn CLI into hidden decdn-client modules (session, targets, lanes, funding, lane_sources, stream_cap, ordered_writes). decdn fetch and decdn bundle pull drive them and behave as before. The lanes take any BuyerPoolStore, so the client needs no redb feature, and the clap args become SDK option structs at the CLI boundary. Error hints that name CLI flags or commands stay in the CLI. The public-API snapshot does not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The mechanical relocation is well-tested and behaviorally consistent; only minor documentation corrections remain.
2 open findings
What changed in this PR
Moves paid-fetch networking internals from the CLI into hidden decdn-client modules while preserving CLI behavior and crate boundaries.
Changes:
- Relocates discovery, funding, lanes, stream caps, and ordered writes.
- Adapts CLI configuration and buyer-store handling to SDK types.
- Moves associated tests and updates documentation.
| File | Description |
|---|---|
crates/e2e/tests/peer_store_probeless.rs |
Updates helper reference. |
crates/client/src/targets/tests.rs |
Moves target-selection tests. |
crates/client/src/targets/tests_support.rs |
Adds shared target fixtures. |
crates/client/src/stream_cap/tests.rs |
Moves stream-cap tests. |
crates/client/src/stream_cap.rs |
Adds per-provider stream caps. |
crates/client/src/source.rs |
Updates funder documentation. |
crates/client/src/session.rs |
Adds paid-pull configuration types. |
crates/client/src/ordered_writes/tests.rs |
Moves write-queue tests. |
crates/client/src/ordered_writes.rs |
Exposes hidden ordered writes. |
crates/client/src/lib.rs |
Registers hidden SDK modules. |
crates/client/src/lanes/tests.rs |
Moves lane and settlement tests. |
crates/client/src/lanes.rs |
Adds lane construction and persistence. |
crates/client/src/lane_sources/tests.rs |
Adapts source-provider tests. |
crates/client/src/lane_sources.rs |
Moves source orchestration into SDK. |
crates/client/src/funding/tests.rs |
Adds funding helper tests. |
crates/client/src/funding/adoption_tests.rs |
Adapts pool-adoption tests. |
crates/client/Cargo.toml |
Adds test-only JSON-RPC dependency. |
crates/cli/src/commands/mod.rs |
Removes relocated CLI modules. |
crates/cli/src/commands/fetch_timings.rs |
Implements SDK timing callbacks. |
crates/cli/src/commands/buyer_store/tests.rs |
Updates adoption helper tests. |
crates/cli/src/commands/buyer_store.rs |
Keeps adoption policy at CLI boundary. |
crates/cli/src/commands/bundle_pull/tests.rs |
Removes relocated tests. |
crates/cli/src/commands/bundle_pull.rs |
Drives the new client seams. |
CHANGELOG.md |
Documents the refactor. |
Cargo.lock |
Records the added dev dependency. |
adr/037-regional-proxy-warming.md |
Updates implementation locations. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| `ordered_writes`). `decdn fetch` and `decdn bundle pull` drive them, and | ||
| behave as before. The lanes take any `BuyerPoolStore`, so the client needs | ||
| no `redb` feature. The public API does not change. |
There was a problem hiding this comment.
Fixed in 78f8ee7: the entry now names the exception. The moved code logs under decdn_client::… targets, so a module-scoped RUST_LOG filter has to name the new module.
| /// `spawn_harvest`/`NodeCandidate` are `pub(crate)`, unreachable from an | ||
| /// integration test in `crates/cli/tests/` — so this lives in-crate | ||
| /// instead of `crates/cli/tests/peer_store_harvest.rs`. The test awaits | ||
| /// the returned `JoinHandle` (never done on the real fetch path) purely | ||
| /// for determinism. |
There was a problem hiding this comment.
Fixed in 78f8ee7: the comment states the current constraint (spawn_harvest is pub(crate), so the tests live in-crate) and no longer names the old CLI location.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 78f8ee7 in the Show a line coverage summary of the most impacted files.
Updated |
Address review on #2434: the CHANGELOG entry names the RUST_LOG target change, and the harvest test comment states the current visibility constraint instead of the old CLI location. Co-Authored-By: Claude Opus 5.5 <[email protected]>

What
Part of #2429 (1 of 3). This PR moves the paid fetch's network leg out of the
decdnCLI and into hiddendecdn-clientmodules.decdn fetchanddecdn bundle pullcall the SDK versions and behave exactly as before.decdn-clientmodulesessionChainConfig,PullSite,DepositPolicy,ChainAdoption,DiscoveryOptions,PinnedNode,ProxyWarmingParams,FetchMarksResolvedChainandClientFetchArgsinside the engine)targetsresolve_target_nodefetch.rslanesLaneDeps(wasDriveFetchDeps),build_multi_lane, watermark queueing and persistence,SettleOnDropfetch.rsfundingRunFunding,PoolFunder(wasCliFunder), open-or-reuse, refill, adoption, delegated ctxfetch.rslane_sourcesLaneSources(wasCliSources)cli_sources.rsstream_capLaneStreamCapbundle_pull.rs(this removes thecli_sources → bundle_pullcycle)ordered_writesordered_writes.rsPR 2 moves the bundle engine onto a public
decdn_client::bundleAPI. PR 3 wires the liveCredentialSlotswap and closes #2429.Reviewer notes
Arc<dyn BuyerPoolStore>instead ofRedbBuyerPoolStore. Every call was already a trait method, so the client gets noredbfeature and the crate-edge table does not change.ClientFetchArgsis converted toDiscoveryOptionsat the CLI boundary (fetch::discovery_options). The--node-id/--provider-addressparse errors keep their wording and stayResolveConfigFault.ResolvedChainnests aChainConfigand aPullSite.ChainAdoption::for_buybecomes the CLI'schain_adoption_for_buyand is evaluated once per command throughResolvedChain::deposit_policy. Before, it ran at each lane build. A delegated run skips it.annotate_unbound_cache_miss,annotate_delegated_exhaustion, the top-up hint) stay in the CLI.LaneSourcesexposesfirst_lane_ctx/pool_id/is_delegatedfor them.FetchTimingsstays in the CLI and implements the SDK'sFetchMarkstrait.#[doc(hidden)], and anything only the crate itself uses ispub(crate).cliandclientis unchanged (1594 before and after).tracingevents from the moved code now carrydecdn_client::…targets. This matters only to module-scopedRUST_LOGfilters.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-client(744 passed) and-p decdn-cli(848 passed)CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemscargo nextest run -p decdn-client --features public-api-test --test public_api: passes with no snapshot updatepython3 .github/scripts/check_crate_edges.py: no edge changecargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(/^cli_(bundle_pull|fetch)/)': 20/20 passed, against freshly built binariesCHANGELOG.mdentry added (Changed)🤖 Generated with Claude Code