Skip to content

feat(cli): decdn self-update and a daily update notice - #2540

Merged
thiras merged 14 commits into
mainfrom
feat/self-update
Oct 19, 2026
Merged

thiras merged 14 commits into
mainfrom
feat/self-update

Conversation

@thiras

@thiras thiras commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2537

What

  • decdn self-update resolves the latest GitHub release from the redirect behind releases/latest, verifies SHA256SUMS.minisig against one of the maintainers' minisign public keys embedded from crates/cli/minisign-<maintainer>.pub, checks the archive against the signed manifest, unpacks it, stages the binary beside the running one and renames it into place (Unix); on Windows self-replace moves the running .exe aside first. A failed swap keeps the verified download and names it. --check only reports.
    • Ownership: a binary under ~/.cargo/bin (or $CARGO_HOME/bin) is refused with cargo install --locked decdn-cli; one in a directory the user cannot write (the container image's /usr/local/bin, an Ansible-managed fleet path) is refused by path and OS reason. No container detection needed.
    • A downgrade or a pre-release is never applied. The sponsored installer's marker is deliberately left alone: with a lagging onramp pin, rewriting it would make the next one-liner run reinstall the pinned older release, while an untouched marker makes it skip (deviation from the issue's acceptance list, see below).
  • Daily notice: after any other command succeeds on a terminal, at most once a day (~/.decdn/self-update-check, stamped before the 2 s-bounded lookup), one stderr line: decdn <new> is available; run `decdn self-update` . Never with --json or piped output. [self_update] check = false or DECDN_SELF_UPDATE_CHECK=0 turns it off.
  • Release pipeline: sign-release.sh signs SHA256SUMS with minisign (DECDN_MINISIGN_KEY, default ~/.minisign/minisign.key), verifies it against the crates/cli/minisign-*.pub maintainer keys in the tag's tree (the keys the released binary embeds), uploads SHA256SUMS.minisig; publish-crates.sh requires it. A -rc version is created and published with --prerelease, so GitHub's "latest" never names a candidate (today nothing set that flag).
  • Docs: README (Install, one-liner, Commands), SECURITY.md (a minisign line per maintainer beside the GPG fingerprints), RELEASING.md (one-time setup per maintainer, env table, § The minisign keys: add, remove, rotate), adr/appendix-binaries.md, CHANGELOG.

Maintainer keys

crates/cli/minisign-thiras.pub (key id 111497640DE76A05) is the first maintainer key; the placeholder is gone. Every maintainer adds their own the same way (RELEASING.md § One-time setup, step 2): generate, commit the .pub, add its include_str! to TRUSTED_KEYS, list the key id in SECURITY.md. A key signs releases from the first one built after it lands.

Design notes (spec discipline)

Kept out: self_update.auto, --pre-release, container detection, any runtime/debug override of the trusted key set, any self-update stamp beyond the installer marker. The verifier is minisign-verify (zero deps) rather than an OpenPGP crate, keeping the client crate graph lean; GPG stays the human channel. The release lookup reads the tag from the Location header of a no-redirect client, so no GitHub API call or rate limit is involved.

Deviations from the issue

  • No installer-marker rewrite (reason above; sponsord follow-up below).
  • No self_update.auto, no --pre-release, no container detection, no CLI flag for the check: cut under the spec-discipline skill; each is a mechanism with no live consumer or a less-than-neutral effect.

Review

Six review passes ran on the branch (a fresh whole-branch reviewer plus code, tests, silent-failure, comment, and type-design reviewers). Every Critical and Important finding was fixed test-first in one pass, among them: the notice's stamp creating ~/.decdn with umask bits (the identity code requires 0700), a silent publish-crates.sh abort, un-canonicalised cargo bin dirs defeating the cargo-install refusal through a symlinked ~/.cargo, the Unix swap's reliance on self-replace's one-level symlink resolution, an extractor that accepted an empty or non-regular decdn entry, and the Windows zip path having no test. Deferred minors are listed in the ledger and the PR comment thread will carry them.

Verification

  • cargo nextest run -p decdn-cli -p decdn-common: 1395/1395; the self-update modules carry 60+ unit tests, 4 subprocess tests, 6 in-process install-pipeline tests, and a pty test of the daily notice
  • cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo doc gate, check-crate-edges, check-workspace-manifests, check-package-embeds, cargo deny: clean
  • pytest scripts/tests .github/scripts/tests: 266 pass, including 8 publish-path tests that drive sign-release.sh to the end with gh/minisign shims
  • Manual smoke with a throwaway key and a local release server, run before and after the review fixes: --check, the real swap, the unwritable refusal, the daily notice (once, then silent; off via env), and ~/.decdn created 0700 all behave as described
  • Windows-only code (zip, self-replace) is linted by CI's windows job; it does not build locally (blake3's C build script needs MSVC)

Follow-ups

🤖 Generated with Claude Code

thiras and others added 9 commits October 19, 2026 15:14
minisign-verify, sha2, semver, flate2, tar (no xattr), self-replace, and
zip (deflate-flate2 only, Windows targets) for `decdn self-update`;
wiremock for its tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
`decdn self-update` resolves the latest release from the redirect GitHub
answers for releases/latest, verifies SHA256SUMS.minisig against the
minisign key embedded from crates/cli/minisign.pub, checks the archive
against the signed manifest, and swaps the running binary in place. A
binary cargo installed, or one in a directory the user cannot write, is
refused with the command to run instead; a downgrade or a pre-release is
never applied. After any other command succeeds on a terminal, at most
once a day, the CLI prints one line when a newer release exists;
[self_update] check and DECDN_SELF_UPDATE_CHECK turn that off.

crates/cli/minisign.pub is a placeholder whose secret is discarded; the
guard test embedded_key_is_not_the_placeholder fails until the maintainer
key replaces it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…2537)

sign-release.sh signs SHA256SUMS with the minisign key DECDN_MINISIGN_KEY
names, verifies the signature against the committed crates/cli/minisign*.pub
set the decdn binary embeds, and uploads SHA256SUMS.minisig beside the .asc
files. A version with a pre-release suffix is published with --prerelease,
in the draft and at publish, so it never becomes GitHub's "latest".
publish-crates.sh requires the .minisig as it requires the .asc.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The daily notice creates ~/.decdn private (0700) and its stamp 0600, so
the identity code keeps accepting the directory. Cargo bin directories
are canonicalised and CARGO_INSTALL_ROOT is honoured, so a symlinked
cargo home still refuses a cargo install. The Unix swap is one rename of
the staged sibling over the canonical binary; self-replace stays for
Windows; a failed swap keeps the verified download and names it. The
extractor refuses an empty or non-regular `decdn` entry, and the zip
reader is compiled and tested on every platform. The manifest parser
accepts GNU binary-mode lines as its doc says. The installer marker is
left alone: rewriting it made a lagging one-liner pin reinstall an older
release. Target is a closed enum; the signature check returns the parsed
manifest; apply() takes the swap as a closure and is tested in-process;
a pty test covers the notice end to end; subprocess tests seal the check
off. sign-release.sh verifies SHA256SUMS.minisig against the keys in the
tag's tree and reports minisign's reason; publish-crates.sh names a
failed asset lookup instead of exiting silently.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@thiras

thiras commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Maintainer keys

crates/cli/minisign-thiras.pub (key id 111497640DE76A05) is committed and embedded; the placeholder is gone, so a release can be cut from this branch. Other maintainers add theirs per RELEASING.md § One-time setup, step 2:

minisign -G -p crates/cli/minisign-<you>.pub -s ~/.minisign/minisign.key
# add its include_str! to TRUSTED_KEYS in crates/cli/src/commands/self_update/verify.rs,
# add the key id beside your fingerprint in SECURITY.md

Deferred minors from the review (not fixed here)

  • env_flag ignores an unrecognised DECDN_SELF_UPDATE_CHECK value (the check stays on); off/0/false/no work.
  • json_requested reads a --json <value> option (none exists today) as "not requested".
  • A non-ASCII Location header is reported as "without a Location header".
  • Clients could own the base URL so a cross-base fetch is unrepresentable.
  • No scripts/tests case drives publish-crates.sh to its SHA256SUMS.minisig gate (needs a cargo-token + signed-tag harness).

Follow-up elsewhere

  • sponsord: once a user self-updates past the onramp's pinned release, re-running the one-liner reinstalls the pinned older version. The installer should compare the installed decdn --version against its pin instead of relying on the marker alone.

thiras and others added 2 commits October 19, 2026 16:35
sign-release.sh reads the minisign public keys out of the tag's tree
before signing and stops when one is a placeholder, so a release can
never ship a binary that trusts no real key. The unit test that failed
on the placeholder is gone: on CI its failure cancelled the rest of the
workspace suite, and the release script is where the check belongs.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
awk exited at the first match while sed still had output buffered, which
killed sed with SIGPIPE under pipefail once release.yml grew past the
pipe buffer the runner hands the pair. awk now reads the whole file.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 0f7de48 feat/self-update 959d36e +/-
76% 76% 0%
View coverage of the 10 most impacted files.
File main 0f7de48 feat/self-update 959d36e +/-
crates/node/src...s/client/mod.rs 91% 91% 0%
crates/protocol/src/framing.rs 92% 93% +1%
crates/cli/src/...mands/config.rs 78% 84% +6%
crates/cli/src/main.rs 75% 82% +7%
crates/cli/src/...f_update/mod.rs 0% 88% +88%
crates/cli/src/...date/release.rs 0% 93% +93%
crates/cli/src/...date/install.rs 0% 96% +96%
crates/cli/src/...update/check.rs 0% 98% +98%
crates/cli/src/...pdate/verify.rs 0% 100% +100%
crates/common/src/cli/mod.rs 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 19, 2026 14:25 UTC

thiras and others added 2 commits October 19, 2026 16:53
The trusted minisign keys follow the KEYS model: each maintainer commits
crates/cli/minisign-<name>.pub, the binary embeds every one of them, and a
release signed by any of them verifies. RELEASING.md covers adding,
removing and rotating a key; SECURITY.md lists each maintainer's key beside
their GPG fingerprint. The placeholder is renamed to say what it is.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
crates/cli/minisign-thiras.pub (key id 111497640DE76A05) replaces the
placeholder in TRUSTED_KEYS and is listed in SECURITY.md beside the GPG
fingerprint.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@thiras
thiras marked this pull request as ready for review October 19, 2026 13:59
Copilot AI balanced review requested due to automatic review settings October 19, 2026 13:59

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.

🟡 Changes recommended

Release-signing path handling and update-notice behavior have unresolved correctness issues.

4 open issues
What changed in this PR

Adds signed self-updates to the user-facing CLI, helping installed clients stay current without changing daemon deployment.

Changes:

  • Adds verified downloads, binary replacement, and --check.
  • Adds configurable daily update notices.
  • Extends release signing, prerelease handling, documentation, and tests.
File Description
SECURITY.md Documents minisign verification.
scripts/​tests/​test_sign_release_publish.py Tests signing and publication.
scripts/​tests/​test_sign_release_key_selection.py Supplies minisign test prerequisites.
scripts/​sign-release.sh Signs manifests and marks prereleases.
scripts/​publish-crates.sh Requires both manifest signatures.
RELEASING.md Documents signing and key rollout.
README.md Introduces updates and notices.
crates/​common/​src/​config/​types/​tests.rs Tests update configuration parsing.
crates/​common/​src/​config/​types.rs Defines update settings.
crates/​common/​src/​cli/​tests.rs Tests arguments and JSON detection.
crates/​common/​src/​cli/​self_update.rs Defines self-update arguments.
crates/​common/​src/​cli/​mod.rs Registers command and JSON detection.
crates/​cli/​tests/​self_update_nudge_pty.rs Tests terminal notices.
crates/​cli/​tests/​self_update_cli.rs Tests command-level update refusals.
crates/​cli/​tests/​common/​mod.rs Disables notices in unrelated tests.
crates/​cli/​src/​main.rs Dispatches updates and post-command notices.
crates/​cli/​src/​commands/​self_update/​verify/​tests.rs Tests signatures and archive checksums.
crates/​cli/​src/​commands/​self_update/​verify.rs Verifies manifests and archives.
crates/​cli/​src/​commands/​self_update/​tests.rs Tests the installation pipeline.
crates/​cli/​src/​commands/​self_update/​testdata/​SHA256SUMS.minisig Supplies a fixture signature.
crates/​cli/​src/​commands/​self_update/​testdata/​SHA256SUMS Supplies fixture checksums.
crates/​cli/​src/​commands/​self_update/​testdata/​minisign-test.pub Supplies the test verification key.
crates/​cli/​src/​commands/​self_update/​testdata/​install/​SHA256SUMS.minisig Signs installation fixtures.
crates/​cli/​src/​commands/​self_update/​testdata/​install/​SHA256SUMS Lists installation fixture checksums.
crates/​cli/​src/​commands/​self_update/​release/​tests.rs Tests release resolution and downloads.
crates/​cli/​src/​commands/​self_update/​release.rs Resolves versions and release assets.
crates/​cli/​src/​commands/​self_update/​mod.rs Coordinates verified updates.
crates/​cli/​src/​commands/​self_update/​install/​tests.rs Tests extraction, ownership, and replacement.
crates/​cli/​src/​commands/​self_update/​install.rs Stages and replaces binaries.
crates/​cli/​src/​commands/​self_update/​check/​tests.rs Tests notice timing and settings.
crates/​cli/​src/​commands/​self_update/​check.rs Implements daily notices.
crates/​cli/​src/​commands/​mod.rs Exposes the update module.
crates/​cli/​src/​commands/​config/​tests.rs Checks template section coverage.
crates/​cli/​src/​commands/​config.rs Adds update configuration examples.
crates/​cli/​README.md Updates command documentation.
crates/​cli/​minisign-thiras.pub Supplies a maintainer verification key.
crates/​cli/​Cargo.toml Adds updater and test dependencies.
CLAUDE.md Lists the new CLI command.
CHANGELOG.md Records updater and release-tooling changes.
Cargo.toml Defines shared updater dependencies.
Cargo.lock Locks added dependencies.
adr/​appendix-binaries.md Documents the CLI update channel.
.github/​workflows/​release.yml Marks candidate release drafts as prereleases.
.github/​scripts/​check-image-name.sh Avoids early-exit pipe failures.

Review effort: Balanced

Comment thread scripts/sign-release.sh Resolved
Comment thread crates/cli/src/main.rs Resolved
Comment thread RELEASING.md Resolved
…2537)

The daily lookup starts alongside the command and the command waits at
most one second for it once it has succeeded, so a `get` pays nothing;
it runs only when stdout and stderr are both terminals, so a pipeline
never waits on it or receives its line. sign-release.sh resolves a
relative DECDN_MINISIGN_KEY before it changes directory, and verifies
SHA256SUMS.minisig against the previous tag's keys too, so a key new in
a release cannot sign the release that introduces it; RELEASING.md says
the same.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@thiras
thiras merged commit 22091d2 into main Oct 19, 2026
33 checks passed
@thiras
thiras deleted the feat/self-update branch October 19, 2026 14:37
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.

cli: decdn self-update and an update check on run

2 participants