Skip to main content

Crate sovereign_update

Crate sovereign_update 

Source
Expand description

Claude-Code-style update check for sovereign binaries (EPIC #4232, #4242).

  • startup — call first thing in main. 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 by SOVEREIGN_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§

UpdateArgs
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 to spawn. 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 update before its own CLI parser: if args.get(1) == Some("update") { exit(update_main(&P, &args[2..])) }. Intercepting in the binary’s own main means the executable replaced is always the one named p.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).