Skip to content

feat(cli): decouple --provider-address (#1492) + bundle pull --channel-id / --namespace - #1503

Merged
alpergundogdu merged 8 commits into
mainfrom
claude/issue-1492-plan-6164df
Jul 29, 2026
Merged

alpergundogdu merged 8 commits into
mainfrom
claude/issue-1492-plan-6164df

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two related CLI improvements to the paid client path, surfaced from #1492 and extended per review.

Part A — #1492: decouple --provider-address from --node-id. On the decdn fetch --channel-id adopt path, --provider-address is only a mismatch guard against the channel's on-chain provider, so forcing --node-id alongside it was pointless. The clap requires = "node_id" is dropped and the pairing rule moved into the shared ClientFetchArgs::validate(): --provider-address now needs either --channel-id (guard) or --node-id (explicit node); standing alone is still rejected.

Part B — feature parity for decdn bundle pull. It gains both flags decdn fetch already has:

  • --channel-id (publisher-pays, Publisher-pays channels: open-on-behalf + adopt-by-id + reject-bundle resume #1481): adopts one publisher-opened channel and pins the whole bundle to its single on-chain provider (node derived from it, or an explicit --node-id). Every entry pays from the adopted channel; no per-entry discovery. A new Payment::{AutoOpen,Adopt} mode on PullCtx selects between auto-open and adopt; the on-chain open-lock is never taken in adopt mode. Reuses fetch's hydrate_channel_by_id / resolve_node_for_provider (widened to pub(crate)) — no logic duplicated.
  • --namespace (ADR 002): bundle-level routing. Threaded through the single fetch_from choke point so the manifest blob, DECDNMAN chunks, and every entry route their cache-miss origin pulls to the namespace's authorized origins. (The manifest format carries no per-entry namespace, so bundle-level is the only expressible shape.)

Behavior change (intended): bundle pull --channel-id was previously a silently-ignored flag; it is now honored.

Notes for reviewers

  • The keystore-password prompt stays deferred on the discovery path (a failed registry read never prompts) and is loaded up-front only on the adopt path, which needs it to guard the channel's voucherSigner. The selection logic is factored into resolve_selection for clarity.
  • Voucher-nonce safety on the adopt path is inherited for free: all entries share one provider, so the existing per-provider lock serializes their vouchers — identical to --node-id pinning.
  • No end-to-end adopt test: a live bundle pull --channel-id needs anvil, and repo convention avoids always-on anvil tests. The wiring is unit-covered and the adopt machinery is the same code fetch's tested path uses. An anvil-gated e2e case in decdn-e2e is a reasonable follow-up.

Test plan

  • cargo nextest run -p decdn-common -p decdn-cli — 830 passed (5 new tests: flag-combo validation, bundle-pull namespace parse, adopt target resolution)
  • cargo clippy -p decdn-common -p decdn-cli --all-targets — clean
  • cargo fmt -- --check — clean
  • cargo test --no-run -p decdn-e2e --features anvil-e2e — compiles

Closes #1492.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features

    • Added --namespace support to decdn bundle pull, applying routing consistently across manifests, chunks, and entries.
    • Added support for adopting an existing payment channel with --channel-id, avoiding unnecessary channel creation.
    • Improved provider selection and payment handling throughout bundle retrieval.
  • Bug Fixes

    • Updated --provider-address validation to work correctly with either --channel-id or --node-id.
    • Added validation to reject reserved or invalid namespace values.

alpergundogdu and others added 5 commits July 29, 2026 13:06
…l-id (#1492)

Relax the clap `requires = "node_id"` on `--provider-address` and move the
pairing rule into `ClientFetchArgs::validate()`: the flag may now stand alone
alongside `--channel-id` (where it only guards the adopted channel's on-chain
provider), while the auto-open path still requires an explicit `--node-id`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…l reuse

Widen hydrate_channel_by_id, resolve_node_for_provider, and attach_client_binding
to pub(crate) so bundle pull can adopt a channel by id without duplicating the logic.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add a bundle-level --namespace flag to `decdn bundle pull`, reusing fetch's
namespace parser. It threads through the single fetch_from choke point, so the
manifest blob, DECDNMAN chunks, and every entry route their cache-miss origin
pulls to the namespace's authorized origins.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
… the bundle (#1481)

Give `decdn bundle pull` the publisher-pays adopt-by-id path fetch already has: a
Payment::{AutoOpen,Adopt} mode on PullCtx, resolved once in resolve_selection. In
adopt mode the whole bundle pins to the channel's single on-chain provider (node
derived from it, or an explicit --node-id), every entry pays from the adopted
channel via hydrate_channel_by_id, and the on-chain open-lock is never taken. The
keystore prompt is ordered per path so a failed discovery still never prompts.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: c7403fda-3b69-48bb-86c3-eec488c6c601

📥 Commits

Reviewing files that changed from the base of the PR and between d143523 and d16bbd4.

📒 Files selected for processing (5)
  • crates/cli/src/commands/bundle_pull.rs
  • crates/cli/src/commands/fetch.rs
  • crates/common/src/cli/bundle.rs
  • crates/common/src/cli/fetch.rs
  • crates/e2e/tests/cli_bundle_pull_channel_id.rs

Walkthrough

Bundle pull now resolves selection, signer, payment mode, and namespace once per run. It can adopt an existing channel without opening another channel, applies namespace routing to bundle fetch stages, and updates provider-address validation for channel-based fetches.

Changes

Bundle pull flow

Layer / File(s) Summary
CLI contracts and validation
crates/common/src/cli/bundle.rs, crates/common/src/cli/fetch.rs
Adds --namespace to bundle pull and validates --provider-address against either --channel-id or --node-id.
Selection and payment resolution
crates/cli/src/commands/bundle_pull.rs, crates/cli/src/commands/fetch.rs
Resolves bundle targets and payment mode, adopting an existing channel when --channel-id is supplied and exposing shared channel helpers crate-wide.
Bundle routing and coverage tests
crates/cli/src/commands/bundle_pull.rs
Carries payment and namespace state through PullCtx, passes namespace IDs to blob fetches, and tests namespace parsing plus channel-only selection behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant bundle_pull
  participant Channel
  participant Provider
  participant fetch_blob
  CLI->>bundle_pull: parse namespace and channel options
  bundle_pull->>Channel: resolve or adopt payment channel
  Channel-->>bundle_pull: channel context and provider selection
  bundle_pull->>Provider: fetch manifest, chunks, and entries
  Provider->>fetch_blob: apply bundle namespace
  fetch_blob-->>bundle_pull: return fetched bundle data
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.76% (was 80.81%, ▼ 0.05%) — 54052/66928 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle_pull.rs 49.22% 410/833 ▼ 1.41%
crates/cli/src/commands/fetch.rs 41.12% 530/1289 ● 0.00%
crates/common/src/cli/fetch.rs 100.00% 150/150 ● 0.00%
History
Commit Total Δ vs base
d143523 80.71% ▼ 0.06%
00be430 80.74% ▼ 0.07%
75341c7 80.73% ▼ 0.08%
d16bbd4 (HEAD) 80.76% ▼ 0.05%

…n-6164df

# Conflicts:
#	crates/cli/src/commands/bundle_pull.rs

@alpergundogdu alpergundogdu left a comment

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.

Review of the --provider-address decouple + bundle-pull --channel-id/--namespace work. Flag-combination logic in validate() is sound, voucher-nonce safety on the adopt path holds (per-provider lock + per-entry re-hydrate), and the namespace parser correctly rejects 0. Inline comments below; the first is a real functional gap.

Also (can't inline — unchanged context lines):

  • [Low] bundle_pull.rs --dry-run short-circuits before args.common.validate()?, so bundle pull --dry-run --provider-address 0x.. alone now succeeds where clap previously rejected it. Fix: call validate()? before the dry-run branch (it's cheap and side-effect-free).
  • [your call] Moving the pairing rule from clap requires to validate() changes the rejected-case exit code from clap's 2 (usage) to anyhow's 1 (plain message). More helpful message, but scripts keying on exit 2 will see a difference. No fix needed — just a conscious note.

Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
Comment thread crates/common/src/cli/bundle.rs Resolved
alpergundogdu and others added 2 commits July 29, 2026 16:00
Anvil-gated journey: a buyer opens one payment channel on-chain (not recorded in
the client store), then `decdn bundle pull --channel-id` adopts it and pulls a
two-entry manifest — hydrating the channel from chain on the first entry and
reusing it for the second. Asserts both files land, the persisted watermark
advanced (the adopted channel paid), and the store row carries the opened
channel id against the node's operator. --provider-address is passed standing
alone as the mismatch guard (#1492), recovering the coverage the adopt path lost.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ce routes origins

Review fixes for PR #1503:

- [High] The AutoOpen branch returned the open_or_reuse context WITHOUT the ADR
  005 client binding, so the node's pull_authorized gate never fired a cache-miss
  origin pull on the default/--node-id path — making --namespace inert there.
  Attach the binding exactly as fetch::build_channel_ctx does (a latent pre-existing
  gap the new --namespace claim exposed).
- [Low] Move common.validate() BEFORE the --dry-run short-circuit so the #1492
  flag-combination rule (now in validate(), not clap) still rejects a dangling
  --provider-address under --dry-run. Regression test added.
- [Low] Drop the stale `DECDNMAN` chunk reference from the --namespace doc (that
  format was retired in #1507); namespace now applies to the manifest blob + entries.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu

Copy link
Copy Markdown
Contributor Author

Thanks for the review — addressed the inline threads plus the two review-body points in d16bbd4:

  • [Low] --dry-run bypassed validate() — fixed. common.validate()? now runs before the dry-run short-circuit, so bundle pull --dry-run --provider-address 0x.. alone is rejected again (the decdn fetch: decouple --provider-address from --node-id so it can guard the --channel-id adopt path #1492 rule lives in validate(), not clap, so dry-run must trigger it explicitly). Added a regression test dry_run_still_rejects_a_dangling_provider_address.
  • [your call] exit code 2 → 1 — acknowledged, left as-is. clap's requires can only express AND, not "--provider-address requires (--channel-id OR --node-id)", so the code-level check is what enables the channel-id pairing at all; the plain-message exit 1 is the inherent cost. Conscious tradeoff, no change.

All green locally: 804 unit tests + the adopt e2e (cli_bundle_pull_adopts_one_channel_for_the_whole_bundle) pass; clippy/fmt clean.

🤖 Addressed by Claude Code

@alpergundogdu
alpergundogdu merged commit 9d7cd37 into main Jul 29, 2026
24 checks passed
@alpergundogdu
alpergundogdu deleted the claude/issue-1492-plan-6164df branch July 29, 2026 15:41
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 fetch: decouple --provider-address from --node-id so it can guard the --channel-id adopt path

1 participant