Skip to content

Split decdn into separate node and client binaries #421

Closed

Description

@thiras

Summary

Split the single decdn binary along the dockerd + docker line:

  • decdn-node — daemon only. Runs the cache node service. Effectively decdn-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, future fetch/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-node is just runtime bring-up + the existing handlers. No clap subcommand tree beyond run. 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-gen or config validate. Publishers don't have to install two binaries to also probe a node. Everything you'd type is decdn ….
  • 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

  • run stays on decdn-node. It's the only thing that binary does.
  • node admin namespace moves to decdn. 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 as decdn node peers instead of decdn node peers (no change for operators).
  • key-gen moves to decdn. 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 validate move to decdn. They operate on the node TOML; an operator runs them, the daemon doesn't.
  • probe moves to decdn. 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

  1. New crate crates/cli/ produces [[bin]] name = "decdn". Houses all human-facing subcommand parsing and dispatch.
  2. Slim crates/node/ to daemon-only. [[bin]] name = "decdn-node". Drop the existing cli/ and commands/ modules; keep runtime/, handlers/, admin.rs, dispatch.rs, etc. The binary's main parses just --config + a single run subcommand.
  3. 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 a lib.rs with these types; crates/cli/ depends on it but pulls in extra deps it doesn't need.
    • (b) Extract crates/common/ (or crates/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 one crates/common/ and split later if it grows.
  4. Move handlers: cli/{probe,key_gen,config_cmd,node}.rs and commands/{probe,key_gen,config,node_dispatch}.rs move from crates/node/ to crates/cli/. The admin loopback-HTTP client moves with node. commands::run collapses into decdn-node's main.
  5. Distribution:
    • cargo install --bin decdn and cargo install --bin decdn-node work standalone from their respective crates.
    • Release artifacts: separate archives. Publishers grab decdn only; operators grab both.
    • Container image: only decdn-node. Pure daemon, minimal attack surface.
  6. 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 like decdn node drain keep working as today.
    • ADR 012 examples (decdn pull …) are correct as-is post-rename.

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 run stops working at the cut-over; release notes call it out.

Affected issues

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 to decdn-node; drop CLI subcommand tree beyond run
  • Move probe, key-gen, config init/validate, node admin handlers from crates/node/ to crates/cli/
  • Loopback-HTTP admin client wires up in crates/cli/ for decdn 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 is decdn-node only

Activity

  1. added
    kind:feature
    area:cli
    on May 6, 2026
  2. self-assigned this
    on May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:feature

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions