Skip to content

refactor(client-pull): promote discovery/probe/endpoint/provider into public decdn-client-pull modules #1021

Closed

Description

@alpergundogdu

Context

The client fetch path is split across two crates:

  • decdn-client-pull — already a proper library: stream_fetch_tracked, open_progressive_pull, open_channel/ensure_allowance (buyer_channel.rs), and BuyerChannelStore/RedbBuyerChannelStore live here and are reusable.
  • decdn-cli (bin crate) — but discovery, probe, the client iroh-endpoint builder, and the provider builder live in crates/cli/src/commands/, which the workspace marks "only ever a dev-dependency." Nothing can depend on it.

That means there is one shared, tested "discover → probe → open/reuse channel → paid-fetch" path, but half of it (the discovery half) is unreachable as a library. Any non-CLI client is blocked on this.

Proposal (pure refactor, no behavior change)

Promote the bin-locked modules into public decdn-client-pull modules:

From (bin-locked) To (public library module)
cli/src/commands/discovery.rs (active_nodes, select_candidates, rank) client-pull/src/discovery.rs
cli/src/commands/probe_client.rs (probe_once) client-pull/src/probe.rs
cli/src/commands/client_endpoint.rs (client iroh endpoint builder) client-pull/src/endpoint.rs
cli/src/commands/chain_ctx.rs::build_provider (read-only + wallet providers) client-pull/src/provider.rs

Then repoint crates/cli/src/commands/fetch.rs and bundle_pull.rs to import from decdn-client-pull, and move the accompanying unit tests alongside the moved code.

Discovery stays registry+probe (CapacityBond.getActiveNodes → cdn/probe/v1 has_blob → rank, per ADR 019/030); cdn/dht/v1 (ADR 022) can slot behind the same discovery interface later.

Why now / value on its own

Scope

  • No ADR required — relocates existing code, records no new decision.
  • No protocol change, no node-side change.

Verification

  • cargo nextest run -p decdn-cli -p decdn-client-pull green.
  • cargo clippy --workspace --all-targets and cargo fmt -- --check clean.

Follow-up to #866 (closed; gateway product design parked out-of-repo).

Activity

  1. added a commit that references this issue on Jun 30, 2026
    44afd1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions