hotswap · design

the swap moment for the gigantic primitives

Zero-downtime upgrades—hotswap moves a running tool to its next release and back, from inside the tool. packslip verifies and unpacks a release; hotswap keeps the versions and owns the moment between: drain, swap, smoke, then settle or roll back. One crate inside each tool, no daemon; a consumer needs no mise.

Why

The gigantic tools — grove, sandman, stele, routines, voice, bifrost, … — are independent primitives. bifrost, the desktop app, plugs them into one UI the way mise plugs in runtimes: install one and its UI appears — a routines tab, sandman's report page. A remote Mac runs the night shift and needs the releases the dev box gets.

jdx tooling first: jdx's standalone packslip CLI — "a vendor-neutral signed release manifest" — verifies and unpacks a release. It keeps no versions side by side and swaps nothing on a host where the tool is running: hotswap.

Release

Every tool's contract; hotswap relies on it, never owns it.

permissions:
  attestations: write   # packslip attests each archive
  contents: write       # upload release assets
  id-token: write       # keyless sigstore, the workflow identity

The two-job form builds and uploads in one job and keeps the packslip job at contents: read.

Install and upgrade

A consumer of our tools needs no mise (owner, 2026-11-17, reversing 2026-10-30's "Components stay on the machine's mise"): packslip verifies and unpacks, hotswap owns the versions, and a tool installs and upgrades with nothing else on the machine. Trigger: on a Mac with mise 2026.8.5, which has no packslip backend, bifrost showed mise ERROR [jgeschwendt/grove] plugin not installed for grove, routines and sandman.

① latestreleases/latest redirect:the tag, no API quota ② fetchpackslip install, signerpinned; staged, movedto <tool>/<V>/ ③ drain, repointa refusal swaps nothing;then current → <V>,renamed over ④ swapsetup, kickstart,smoke ⑤ settlerecord green ⑥ prunekeep current andprevious, drop the rest ⑦ roll backcurrent → previous,no network; ④'ssteps again ⑧ record redthe failed releaseheld off layout ~/.local/share/hotswap/ grove/ 2026.11.2/previous 2026.11.4/groveverified, moved in current → 2026.11.4active version packslip/1.11.4/packslip pinned sha256, checked each use; shared packslip/grove/grove's alone bin config data stage state trust state, export, the install ~/.local/bin/grove → …/current/grove what a shell and the agents run the record ~/.local/state/hotswap/grove.json current's cache, read by hotswap and bifrost newer green red
One upgrade and the layout it leaves, grove as the example; every path hangs off HOME.
jobhow
installhotswap::install(tool, &m), for bifrost (next) or a bare bootstrap: packslip bootstrapped if absent, the latest installed into the layout, then <tool> setup, whose hotswap::ensure points current and ~/.local/bin/<bin> at it and records it; a failed setup leaves the record unverified (not ok, failed the setup, nothing red), so the next tick runs the steps again
active versionthe target of <root>/<tool>/current; the record is its cache
latestcurl -q -fsSIL -w %{url_effective} https://github.com/<repo>/releases/latest → …/tag/v<V>, a renamed repo's 301 followed and ~/.curlrc ignored: only "anything newer than current?"; packslip chooses the version
fetch, verifypackslip install github.com/<repo> --pin <signer> --install-dir <root>/packslip/<tool>/stage --bin-dir <root>/packslip/<tool>/bin, killed with its process group past the manifest's fetch_timeout (600 s)
activate, roll backcurrent repointed: a fresh link renamed over it; no network
what runs the version~/.local/bin/<bin> → <root>/<tool>/current/<bin>: the agents' program and the head of every step's PATH; it needs only HOME, which every entry point refuses to run without
trust statepackslip's, per tool, under <root>/packslip/<tool>/; only the pinned binary is shared
pruneafter a green swap, current and previous kept
uninstall<tool> setup --remove, whose hotswap::forget, under the tool's lock, also deletes <root>/<tool> and <root>/packslip/<tool>; the pinned packslip, shared, stays

<root> is always ~/.local/share/hotswap (hotswap::root()), never $XDG_DATA_HOME: the agent's plist carries only HOME and PATH, so a shell, an agent and bifrost agree on it only if HOME decides.

Rejected

alternativewhy not (measured 2026-11-16 → 17)
a private mise≈40 MB download, a 138 MB binary; its shims need mise's dirs, so a bare shell cannot run the command; releases arrive through jdx's version index, which lagged one on 2026-11-16
mise linked as a crateits lib.rs: the binary "is the only intended consumer; this is not a stable public API"; 128 direct dependencies
Sigstore verification in hotswapsigstore-verify 0.16 with ring: 84 crates, +0.85 MB per tool against sandman's 1.4 MB; the trust root is baked into each tool, so a rotation strands its upgrade path; signer memory and no-downgrade would be ours to write
migration by a fresh fetchit re-verifies, but runs inside the old release's swap: a rate limit there fails setup, rolls the host back onto mise and holds the new release red until the next one
bifrost's app layer on hotswap::upgradethe shell already does the job for a different shape: two layers under Application Support, run as the shell's child, not one binary in ~/.local/bin restarted by launchd; this crate would gain a layers model and a second restart path for one consumer, and Sigstore's crates cost nothing beside Tauri's

Mechanism

One function, hotswap::upgrade, inside the tool. It reads the active version from current, speaks curl for the latest check, packslip only for install and mise only to move it back with a rollback onto mise's copy (§ install), and acts when the version to run differs from its record's; a red record stays put until a new version or --back.

<tool> upgrade           # fetch the latest, then drain, swap, smoke, settle or roll back
<tool> upgrade --check   # report what would happen; fetch nothing, touch nothing
<tool> upgrade --back    # a deliberate rollback to the previous version, no network
<tool> upgrade --retry   # a plain upgrade past the red hold
  1. Fetch — when the redirect names a release newer than current, packslip installs the one it chooses into the layout (§ install); one already there is kept.
  2. Drain — the manifest's drain commands (§ contract), before current moves; a refusal aborts: nothing swapped, nothing rolled back. A version never overwrites another's files, so only new processes see the new version; a green swap prunes all but current and previous, and a process still running from an older tree keeps its loaded binary but loses anything it opens or execs from that tree by path.
  3. Swap — current repointed, then <tool> setup, then a kick of each manifest agent except the tool's upgrade agent, whose kick would kill the running swap; setup first, since it bootstraps an agent a release adds and kicking an unloaded label fails. The kick is one shell step that reads the agent when it runs (so --check runs no launchctl and a rollback decides again). An agent loaded at login carries a managed launch constraint (launchctl print shows managed LWCR); one loaded by bootstrap never does. A swap changes the binary the constraint was made for, so the first spawn after it is killed for a code-signing launch-constraint violation, launchd repairs the constraint once through the background-task manager, and a later re-key of that item leaves the job in spawn failed, exit 78, for good. A kickstart keeps the constraint; a bootout, a wait until print fails, then a bootstrap removes it until the next login. So an agent loaded from a plist path (the print's own path = line) with the constraint, and not disabled, is reloaded from that path by the waiter's reload (five bootstrap tries, none succeeding fails the step and rolls back); anything else, a disabled one included, is kickstarted with -k.
  4. Smoke — the manifest's smoke commands, against the new processes.
  5. Settle or roll back — green: record the swap in ~/.local/state/hotswap/<tool>.json and prune to current and previous. Red: record the version red, so a crash from here on reads red; repoint to the previous version, then setup, kickstart and smoke under the same manifest; exit 1 naming the failing probe. A previous version no longer in the layout is never recorded, and one whose record is red is never rolled back onto unless it held (passed its own steps as a rollback target); the failed version then stays current, red.

The tool contract

Two verbs, owned by the tool; hotswap is a git dependency, hotswap = { git = "https://github.com/jgeschwendt/hotswap" }.

toolon this cratelatestsignerkickstarteddrainsmoke
bifrostnextplanned (§ bifrost)——quiet/health
grovegrove#39, open; unreleased2026.11.4ps1_rahbrmrvyrwx2q75yvkfebgfzydev.gigantic.grovegrove offgrove --version · GET /api/health (curl, retried while the server boots)
routinesroutines#30, open; unreleased2026.11.0ps1_t5o72jatmrlk56zmnxvdyjrvrydev.gigantic.routines.dueno routine's lock heldroutine status
sandmannext, with its cutover2026.11.1ps1_nensfiggtc7n6uctbniwf7q4amdev.gigantic.sandman.reportnone: a shift keeps its binarysandman version · sandman shift status (a report-page probe would move its read cursor)

Latest releases and the fingerprints packslip install printed for them, observed 2026-11-17.

The manifest, in code

Every field may be empty; ..Default::default() swaps with nothing to run, though an install needs repo and signer.

let m = hotswap::Manifest {
    agents: vec!["dev.gigantic.sandman.report".into()],  // kickstarted on swap
    repo: "jgeschwendt/sandman".into(),                   // its GitHub releases
    setup: vec!["sandman".into(), "setup".into()],       // run after every swap
    signer: "ps1_nensfiggtc7n6uctbniwf7q4am".into(),      // every install pins it
    smoke: vec![vec!["sandman".into(), "version".into()], vec!["sandman".into(), "shift".into(), "status".into()]],
    timeout: Some(120),  // seconds per step, the default; expiry kills the step's process group
    ..Default::default() // no drain: a shift keeps the binary it started on
};
let exe = hotswap::ensure("sandman", &m)?;            // in setup: the path the agents run
std::process::exit(hotswap::upgrade("sandman", &m, &args));

A step that exits while a background child holds its output is waited out to the deadline, then judged by its own exit code — detach daemons from stdout.

bifrost

The Components tab installs into hotswap's layout and reads each tool's record; hotswap is never a component, and no tool needs bifrost.

actiontodaynext
componentsgrove, routines, sandman
installmise use -g packslip:jgeschwendt/<tool>, then mise x <spec> -- <tool> setuphotswap::install(tool, &m), its manifest's repo, bin, signer and setup from bifrost's component table
no mise~/.local/bin/mise absent: the row says so and offers nothingnothing to say: install needs no mise
status~/.local/state/hotswap/<tool>.json — version, ok, the failing step, the red version held off
tab shownan active install in mise ls --jsonhotswap::root()'s <tool>/current resolves
upgrademise x <spec> -- <tool> upgrade~/.local/bin/<bin> upgrade

bifrost's own update stays the shell's (decided 2026-11-18): the shell links the packslip crate, verifies each release against bifrost-releases' signer and installs its two layers, the app and the Erlang runtime it pins, itself — staged, held until the app is quiet, swapped, gated on /health, rolled back, recovered after a crash. It calls no mise, and the 2026-10-30 plan of a private mise was never built. The shell .app stays on the Tauri updater. Why not this crate: § install, rejected.

Non-goals

Gate spans

Every run of mise run check is one OpenTelemetry trace through floodgate span: a check span with each step nested under it (fmt, clippy, cover, stele.check and stele.emit), so floodgate's page shows which steps cost the time and CPU.

check only wraps check:steps in its root span; the steps live there. A step is wrapped in mise run span -- <name> [--attr k=v]… -- <cmd…> (.mise/tasks/span): it execs floodgate span when floodgate is on PATH, else the command after the second --, so a machine without floodgate, CI included, gates as before. To add a step, put it in the check:steps task's run list wrapped the same way; a step left bare is time no span explains.

Next

What the next shift does first; a landing that changes it edits it here.

  1. Nothing open in this crate: grove, routines, sandman and bifrost's Components all run on it.

Landed: routines 2026.11.1, grove 2026.11.5 and sandman 2026.11.2 carry this design. A host on an older release finds them through mise's version index, which can trail a release by hours, and migrates on that upgrade; from then on the latest check asks GitHub directly.

Owner-only: bifrost's first packslip release that carries a shell bundle.