Expand description
Claude-Code-style update check for sovereign binaries (EPIC #4232, #4242).
startup— call first thing inmain. Prints at most one stderr line from the cache, and refreshes a stale cache (24 h) on a detached thread. It never blocks, never fails the command, and is silent on every error. It is skipped bySOVEREIGN_DISABLE_UPDATE_CHECK=1,CI, a non-TTY stderr, or--json/--quiet.update_command— the body of<bin> update [--check]. It installs the NEWER of the latest release and the green nightly (#4189 manifest), by main ancestry, and never downgrades. It verifies the sha256 (fail closed), smoke-tests--version, and renames the new binary over the running one, keeping<exe>.prev. Fleet hosts report and do not install.
const PRODUCT: sovereign_update::Product = sovereign_update::Product {
bin: "pv",
repo: "paiml/aprender",
version: env!("CARGO_PKG_VERSION"),
build_sha: None,
release_asset: Some("{bin}-{tag}-{target}.tar.gz"),
nightly: true,
};
sovereign_update::startup(&PRODUCT, &std::env::args().collect::<Vec<_>>());Modules§
- cache
~/.cache/<bin>/update-check.json: what the last check found, and when.- decide
- The pure decision: is there a build newer than the running one, and which?
- fetch
- What is published: the latest release, the green nightly, and ancestry.
- install
<bin> update: download, verify (fail closed), smoke, swap atomically.- policy
- When the check may run, and whether this host may install.
Structs§
- Product
- What a binary says about itself. All fields are compile-time constants.
Enums§
- Update
Args - What
<bin> update <args>asked for.
Functions§
- check
- Fresh check against the network: the release, the nightly, and ancestry.
- host_
target - The target triple this binary was built for, as release assets name it.
- parse_
update_ args - Parse the arguments after
update. - refresh
- Run a check and record it. A failure keeps the previous
available, so a flaky network neither hides a known update nor retries more than daily. - startup
- Call at the top of
main. Never blocks, never fails, never errors aloud. - startup_
with - The startup check after the skip rules. It takes no
Net: it cannot block on the network by construction. It reads the cache, claims the day and hands the refresh tospawn. Returns the notice to print, if any. - update_
command <bin> update [--check]against the real network and the running exe.- update_
main - Entry for a binary that dispatches
updatebefore its own CLI parser:if args.get(1) == Some("update") { exit(update_main(&P, &args[2..])) }. Intercepting in the binary’s ownmainmeans the executable replaced is always the one namedp.bin, never a host binary that embeds its library. - update_
with - Body of
<bin> update [--check], with every effect injected. Returns the exit code and the lines to print (stdout).