Repository navigation
feat(cli): decdn self-update and a daily update notice - #2540
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.1 <[email protected]>
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]>
…be (#2537) 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]>
…2537) Co-Authored-By: Claude Fable 5.1 <[email protected]>
… directory (#2537) 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]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Contributor
Author
Maintainer keys
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.mdDeferred minors from the review (not fixed here)
Follow-up elsewhere
|
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]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
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]>
There was a problem hiding this comment.
🟡 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
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #2537
What
decdn self-updateresolves the latest GitHub release from the redirect behindreleases/latest, verifiesSHA256SUMS.minisigagainst one of the maintainers' minisign public keys embedded fromcrates/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 Windowsself-replacemoves the running.exeaside first. A failed swap keeps the verified download and names it.--checkonly reports.~/.cargo/bin(or$CARGO_HOME/bin) is refused withcargo 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.~/.decdn/self-update-check, stamped before the 2 s-bounded lookup), one stderr line:decdn <new> is available; run `decdn self-update`. Never with--jsonor piped output.[self_update] check = falseorDECDN_SELF_UPDATE_CHECK=0turns it off.sign-release.shsignsSHA256SUMSwith minisign (DECDN_MINISIGN_KEY, default~/.minisign/minisign.key), verifies it against thecrates/cli/minisign-*.pubmaintainer keys in the tag's tree (the keys the released binary embeds), uploadsSHA256SUMS.minisig;publish-crates.shrequires it. A-rcversion is created and published with--prerelease, so GitHub's "latest" never names a candidate (today nothing set that flag).adr/appendix-binaries.md, CHANGELOG.Maintainer keys
crates/cli/minisign-thiras.pub(key id111497640DE76A05) 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 itsinclude_str!toTRUSTED_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 isminisign-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 theLocationheader of a no-redirect client, so no GitHub API call or rate limit is involved.Deviations from the issue
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
~/.decdnwith umask bits (the identity code requires 0700), a silentpublish-crates.shabort, un-canonicalised cargo bin dirs defeating the cargo-install refusal through a symlinked~/.cargo, the Unix swap's reliance onself-replace's one-level symlink resolution, an extractor that accepted an empty or non-regulardecdnentry, 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 noticecargo clippy --workspace --all-targets --all-features -- -D warnings,cargo docgate,check-crate-edges,check-workspace-manifests,check-package-embeds,cargo deny: cleanpytest scripts/tests .github/scripts/tests: 266 pass, including 8 publish-path tests that drivesign-release.shto the end withgh/minisignshims--check, the real swap, the unwritable refusal, the daily notice (once, then silent; off via env), and~/.decdncreated 0700 all behave as describedzip,self-replace) is linted by CI'swindowsjob; it does not build locally (blake3's C build script needs MSVC)Follow-ups
decdn --versionagainst the pin (fix(onramp)!: stop adding -o . so decdn get keeps its overwrite guard sponsord#83 territory).🤖 Generated with Claude Code