Repository navigation
Description
Summary
Split the single decdn binary along the dockerd + docker line:
decdn-node— daemon only. Runs the cache node service. Effectivelydecdn-node run [--config <path>]and nothing else of substance.decdn— unified human-facing CLI. Carries everything anyone types from a terminal:pull,bundle pull,bundle create,probe,node peers/health/announce/drain/evict/reload,key-gen,config init,config validate, futurefetch/publish/channel.
The node admin commands still talk to a running daemon over loopback HTTP per ADR 025 — they just fail cleanly on a publisher's laptop where no daemon is running. ADR 012's decdn pull <hash> -o <output> UX (adr/012-client.md:251) drops in unchanged.
Motivation
- Unix pattern users already know.
dockerd+docker,containerd+nerdctl,kubelet+kubectl. Daemon is a service; CLI is a tool. One name per role. - Daemon binary is genuinely tiny. With CLI subcommands moved out,
decdn-nodeis just runtime bring-up + the existing handlers. No clap subcommand tree beyondrun. Easy to containerise, easy to systemd-unit, no surface area for users to fumble. - One human-facing CLI to learn. Operators don't have to remember which binary owns
key-genorconfig validate. Publishers don't have to install two binaries to alsoprobea node. Everything you'd type isdecdn …. - No mirror code paths. Previous draft of this issue had
decdn-node client …re-exposing the client surface. That's gone — there's only one place each command lives. - Unblocks decdn bundle subcommand: pull and create directory bundles #391.
decdn bundle …lands directly on the user CLI; no decision about which binary owns it.
Proposed shape
Binaries
| Binary | Subcommands |
|---|---|
decdn-node |
run (only) — pure daemon entry. |
decdn |
pull, bundle pull, bundle create, probe, node peers, node health, node announce, node drain, node evict, node reload, key-gen, config init, config validate, future fetch/publish/channel/wallet. |
Notes on subcommand placement
runstays ondecdn-node. It's the only thing that binary does.nodeadmin namespace moves todecdn. It's already loopback-HTTP-only (ADR 025) — the binary running it doesn't need to be the daemon, just running on the daemon's host. Same UX as today, just typed asdecdn node peersinstead ofdecdn node peers(no change for operators).key-genmoves todecdn. It produces node Ed25519 + Ethereum keystore for an operator at provisioning time; it's a human action, not a daemon action. If/when client-side wallet provisioning lands, it shares the same command tree (decdn wallet …).config init/config validatemove todecdn. They operate on the node TOML; an operator runs them, the daemon doesn't.probemoves todecdn. Already a one-shot client operation today.
Tradeoff vs. earlier "mirror" shape
The earlier version of this issue proposed a decdn-client library + thin decdn wrapper + decdn-node client … mirror. That preserved a small client binary but cost a code-mirroring layer and an integration test asserting byte-identical output between two paths.
This shape inverts the tradeoff: the user CLI gets fatter (admin HTTP client, voucher signing, all clap subcommands) but there's exactly one binary for any human-facing command and zero mirroring. The daemon binary becomes lean instead — which is the binary that actually runs in containers and gets supply-chain-audited. Net: cleaner code, slightly heavier client install, leaner daemon image.
Implementation sketch
- New crate
crates/cli/produces[[bin]] name = "decdn". Houses all human-facing subcommand parsing and dispatch. - Slim
crates/node/to daemon-only.[[bin]] name = "decdn-node". Drop the existingcli/andcommands/modules; keepruntime/,handlers/,admin.rs,dispatch.rs, etc. The binary'smainparses just--config+ a singlerunsubcommand. - Shared types crate. Config schema, identity loading, and the admin HTTP wire types are needed by both binaries. Two options:
- (a) Promote
crates/node/to expose alib.rswith these types;crates/cli/depends on it but pulls in extra deps it doesn't need. - (b) Extract
crates/common/(orcrates/config/) holding the config schema + admin RPC types; both binaries depend on it cleanly.
Prefer (b) — it keeps the daemon's dep tree out of the CLI. Pick the carving granularity in implementation; could start with onecrates/common/and split later if it grows.
- (a) Promote
- Move handlers:
cli/{probe,key_gen,config_cmd,node}.rsandcommands/{probe,key_gen,config,node_dispatch}.rsmove fromcrates/node/tocrates/cli/. The admin loopback-HTTP client moves withnode.commands::runcollapses intodecdn-node'smain. - Distribution:
cargo install --bin decdnandcargo install --bin decdn-nodework standalone from their respective crates.- Release artifacts: separate archives. Publishers grab
decdnonly; operators grab both. - Container image: only
decdn-node. Pure daemon, minimal attack surface.
- Docs / scripts:
- README split: "Run a node" (
decdn-node run) and "Use a node" (decdn pull,decdn node peers, etc.). - systemd / docker-compose / CI:
decdn run→decdn-node run. Operator commands likedecdn node drainkeep working as today. - ADR 012 examples (
decdn pull …) are correct as-is post-rename.
- README split: "Run a node" (
ADR / docs
Light touch — packaging decision, not protocol. Short note in adr/architecture.md ("Binaries" subsection) plus an adr/appendix-binaries.md (~½ page) covering: dockerd-style split, why node admin sits on decdn rather than the daemon, container-image policy. No new numbered ADR.
Non-goals
- No new client features (those land in decdn bundle subcommand: pull and create directory bundles #391 and follow-ups).
- No SDK / library extraction beyond the small shared crate needed by both binaries.
- No mobile/web client work (already non-goal per ADR 012).
- No transition aliases or shims —
decdn runstops working at the cut-over; release notes call it out.
Affected issues
- decdn bundle subcommand: pull and create directory bundles #391 (decdn bundle subcommand) — blocked by this. Bundle commands land on
decdnpost-split; without the split the daemon-binary placement question contaminates the design. - Support a
decdn node topsubcommand that polls /metrics every second and renders a live terminal table of active streams, bytes served, and cache hit rate #275 (decdn node top) — affected; subcommand becomesdecdn node top(it currently would have beendecdn node topalready, sincenodeadmin moves todecdn). No actual rewrite needed; the work is the metrics renderer. - ADR 012's
decdn pull(no current issue) — will land ondecdnpost-split; this issue is a prerequisite when that work begins.
Checklist
-
adr/appendix-binaries.md— dockerd-style split rationale, subcommand placement, distribution / container policy -
adr/architecture.md— short "Binaries" subsection - New
crates/cli/crate with[[bin]] name = "decdn" - Shared
crates/common/(or equivalent) for config schema + admin RPC types - Slim
crates/node/to daemon-only; rename binary todecdn-node; drop CLI subcommand tree beyondrun - Move
probe,key-gen,config init/validate,nodeadmin handlers fromcrates/node/tocrates/cli/ - Loopback-HTTP admin client wires up in
crates/cli/fordecdn node … - README, docker/systemd examples, CI scripts updated (
decdn run→decdn-node run) -
cargo dist/ release config ships both binaries as separate archives; container image isdecdn-nodeonly
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
docs(adr): drop pre-/post-#421 framing from appendix-binaries
refactor(node,cli)!: split decdn binary into decdn-node daemon + decd…
docs(adr): rename StablePaymentChannel -> PaymentChannel; strip pre-e…