Skip to content

refactor(client): move the paid fetch's network leg into decdn-client - #2434

Merged
thiras merged 2 commits into
mainfrom
feat/2429-client-network-leg
Oct 12, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/2429-client-network-leg

Conversation

@thiras

@thiras thiras commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

What

Part of #2429 (1 of 3). This PR moves the paid fetch's network leg out of the decdn CLI and into hidden decdn-client modules. decdn fetch and decdn bundle pull call the SDK versions and behave exactly as before.

New decdn-client module What it holds Moved from
session ChainConfig, PullSite, DepositPolicy, ChainAdoption, DiscoveryOptions, PinnedNode, ProxyWarmingParams, FetchMarks new (replaces ResolvedChain and ClientFetchArgs inside the engine)
targets probe, settle, failover order, fast path, harvest, resolve_target_node fetch.rs
lanes LaneDeps (was DriveFetchDeps), build_multi_lane, watermark queueing and persistence, SettleOnDrop fetch.rs
funding RunFunding, PoolFunder (was CliFunder), open-or-reuse, refill, adoption, delegated ctx fetch.rs
lane_sources LaneSources (was CliSources) cli_sources.rs
stream_cap LaneStreamCap bundle_pull.rs (this removes the cli_sources → bundle_pull cycle)
ordered_writes the whole file ordered_writes.rs

PR 2 moves the bundle engine onto a public decdn_client::bundle API. PR 3 wires the live CredentialSlot swap and closes #2429.

Reviewer notes

  • This is a mechanical move. Most of the diff is code relocated as-is. The edits worth reading are:
    • Store type. The lanes take Arc<dyn BuyerPoolStore> instead of RedbBuyerPoolStore. Every call was already a trait method, so the client gets no redb feature and the crate-edge table does not change.
    • Clap args. ClientFetchArgs is converted to DiscoveryOptions at the CLI boundary (fetch::discovery_options). The --node-id / --provider-address parse errors keep their wording and stay ResolveConfigFault.
    • ResolvedChain nests a ChainConfig and a PullSite.
    • ChainAdoption::for_buy becomes the CLI's chain_adoption_for_buy and is evaluated once per command through ResolvedChain::deposit_policy. Before, it ran at each lane build. A delegated run skips it.
    • Error hints. The ones that name CLI flags or commands (annotate_unbound_cache_miss, annotate_delegated_exhaustion, the top-up hint) stay in the CLI. LaneSources exposes first_lane_ctx / pool_id / is_delegated for them.
    • Timings. FetchTimings stays in the CLI and implements the SDK's FetchMarks trait.
  • Public-API snapshot is unchanged. Every new module is #[doc(hidden)], and anything only the crate itself uses is pub(crate).
  • Tests moved with their code. The total test count across cli and client is unchanged (1594 before and after).
  • tracing events from the moved code now carry decdn_client::… targets. This matters only to module-scoped RUST_LOG filters.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-client (744 passed) and -p decdn-cli (848 passed)
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • cargo nextest run -p decdn-client --features public-api-test --test public_api: passes with no snapshot update
  • python3 .github/scripts/check_crate_edges.py: no edge change
  • cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(/^cli_(bundle_pull|fetch)/)': 20/20 passed, against freshly built binaries
  • User-visible change: CHANGELOG.md entry added (Changed)
  • Design change: ADR 037's code-location sentence updated

🤖 Generated with Claude Code

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]>

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.

🟢 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.

Comment thread CHANGELOG.md Outdated
Comment on lines +2848 to +2850
`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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/client/src/targets/tests.rs Outdated
Comment on lines +325 to +329
/// `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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-code-quality

github-code-quality Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 78f8ee7 in the feat/2429-client-net... branch remains at 75%, unchanged from commit 0cfa3f2 in the main branch.

Show a line coverage summary of the most impacted files.
File main 0cfa3f2 feat/2429-client-net... 78f8ee7 +/-
crates/cli/src/...etch_timings.rs 98% 84% -14%
crates/cli/src/...mmands/fetch.rs 55% 51% -4%
crates/cli/src/.../bundle_pull.rs 60% 59% -1%
crates/client/src/lib.rs 88% 88% 0%
crates/client/s...lane_sources.rs 0% 25% +25%
crates/client/src/targets.rs 0% 51% +51%
crates/client/src/lanes.rs 0% 60% +60%
crates/client/src/funding.rs 0% 65% +65%
crates/client/s...c/stream_cap.rs 0% 86% +86%
crates/client/s...dered_writes.rs 0% 90% +90%

Updated October 12, 2026 13:10 UTC

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]>
@thiras
thiras merged commit 77649bf into main Oct 12, 2026
33 checks passed
@thiras
thiras deleted the feat/2429-client-network-leg branch October 12, 2026 13:35
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.

client: move bundle pull into decdn-client so embedders (decdn-sponsored) stop spawning the CLI

2 participants