Skip to content

Latest commit

 

History

History
725 lines (625 loc) · 57.8 KB

appliance-release.md

File metadata and controls

725 lines (625 loc) · 57.8 KB

Releasing Pithead OS

How the appliance is built, tested, released, and rolled back. The DIY channel keeps its own process in releasing.md — this document covers only pithead-os, and the two share a version number and a release manifest.

The wizard's own contracts — the stage machine and the certificate lifecycle — are in appliance-wizard.md; read that before changing anything it touches.

The updater is RAUC. The evidence for that choice, and the five defects the decision cost, are in dual-distribution-plan.md. The rejected Rugix candidate is preserved on the reference/rugix-candidate branch.

What gets built

Artifact Built by Contents
pithead-os-rootfs:vX.Y.Z + os/build/pithead-root.tar scripts/release/release.sh the published OS container image and its exported rootfs
pithead-os-vX.Y.Z.img.xz scripts/release/package-appliance.sh after os/rauc/mkimage.sh compressed bootable image: ESP + slot A only
pithead-os-vX.Y.Z.raucb os/rauc/mkbundle.sh, then scripts/release/package-appliance.sh signed A/B update bundle

The image carries only the ESP and slot A. Slot B and /data are created by systemd-repart on first boot, sized to the machine's real disk — so a 5 GB image (636 MB of it real data) becomes a full A/B appliance on whatever hardware it lands on, and /data fits a 250+ GB chain instead of the image. The layout is declared once in os/rootfs/repart.d/.

The image also carries no installer payload. pithead-install rebuilds the layout on the target and copies the running slot, so the artifact never contains a compressed copy of itself.

Rootfs Go binaries

The rootfs Dockerfile builds Docker Compose and Cosign from exact upstream commits, checks each commit against its release tag, and asserts the binaries' reported versions. Each release tag is read from a Go tools module, os/rootfs/tools/compose/go.mod and os/rootfs/tools/cosign/go.mod, through os/rootfs/tools/module-version.sh; the modules exist so Dependabot's gomod ecosystem sees both versions. A Dependabot bump moves the version only. The matching COMPOSE_COMMIT or COSIGN_COMMIT ARG moves by hand, and the build refuses a commit that is not the tagged one. Resolve it with gh api repos/<owner>/<repo>/commits/<tag> --jq .sha. The Go builder is pinned by digest at 1.27.4 to clear CVE-2026-111943 and CVE-2026-97054 in both binaries' standard library. Cosign v3.1.4 declares go 1.27, so the builder is a Go 1.27 image.

The rootfs install list names apt, gzip, libpcre2-8-0, libsqlite3-0, perl-base and zlib1g only to pull the distro's security build past the digest-pinned base (#1438, #2104, #3923); xxd stays out because the rootfs has no consumer (#1380).

Compose builds at v5.7.2, whose containerd v2.4.2 clears CVE-2026-95839. COMPOSE_GO_RAISES raises x/net to v0.62.0 for CVE-2026-78661; Compose v5.7.2 already selects x/mod v0.41.0 and grpc v1.85.0. COSIGN_GO_RAISES raises only x/net to v0.62.0: Cosign v3.1.4 already selects x/mod v0.41.0, grpc v1.84.0, klauspost/compress v1.20.1 (past the fix for CVE-2026-63209) and go-jose/v4 v4.1.6 (the fix for CVE-2026-116587), and a raise below a selected version would downgrade it. Compose already selects compress v1.19.2 from its pinned upstream source. The build asserts the compiled Go version of both binaries and Cosign's compiled compress and go-jose versions before copying them into the rootfs.

Module raises modify upstream's module graph, including transitive dependencies selected by Go's minimum-version selection. Upstream go.sum authenticates its existing entries; raised modules use Go's module checksum verification. Cosign reports a dirty tree because those raises modify its sources. Remove a raise when a pinned upstream release makes it redundant. Require the rootfs CVE scan to pass without a new ignore or a weaker severity gate, and run the KVM image-upgrade phase to check signature verification with the built Cosign binary, including rejection with the wrong key.

Host tuning baked in

An unattended headless box has to heal itself, and two of the guards live below the container layer where restart: policies and panic=60 cannot reach:

  • systemd watchdog. /etc/systemd/system.conf.d/pithead-watchdog.conf sets RuntimeWatchdogSec=20s, so systemd feeds /dev/watchdog and the platform watchdog hard-resets the machine if PID 1 stops pinging — the soft-hang case, where nothing panicked and no container died but the box is wedged. RebootWatchdogSec=2min keeps the watchdog armed through shutdown, so a reboot that itself hangs still resets. 20 s is chosen to survive a RandomX-loaded stall without a false reset while still self-healing in under a minute. On hardware with no watchdog device — a KVM guest, most bench boxes — the setting is a safe no-op; real appliance boards expose one and this is where it earns its keep.
  • CPU governor. pithead-cpu-governor.service sets the performance governor every boot, so the node, wallet, and any built-in miner run at full clock. A co-located RigForge miner sets the same performance value from its own service; the two agree, and this only establishes the baseline earlier and covers the miner-disabled box. It is a no-op where there is no cpufreq to steer.

Both are asserted by tests/os/verify-image.sh — the config is checked into the built rootfs, not the runtime effect (CI has no real watchdog device to trip).

Build variants and the variant stamp

Every build is one of two variants, decided by whether the rootfs bakes an SSH key (PITHEAD_TEST_SSH_PUBKEY at build time):

  • release — shell-less. No key, sshd disabled, the dashboard is the only management surface. The only variant that ships.
  • debug — the bench build: a root SSH key baked, sshd enabled. Never publish one; verify-image without --test refuses it.

Debug kit rootfs may carry /opt/pithead/BUILD_LABEL: one ASCII token matching ^[A-Za-z0-9.-]{1,16}$, with an optional final newline (for example rc3). The image builder seeds A_VERSION from the populated slot, the installer seeds it from the running slot, and the per-boot writer repairs that slot's menu name as 2.0.0+rc3. Invalid labels are ignored. An installed update initially records the bundle's plain version; its first boot repairs the label from the new slot. The label affects only GRUB's slot titles. VERSION, stack image tags, bundle metadata, update/downgrade comparisons and the data-migration floor remain plain. Release image and bundle builds without --dev refuse any rootfs carrying the label file, including an empty or invalid one.

The variant is stamped into the artifacts so tooling can tell them apart after the build:

Where What
/etc/pithead-variant in the rootfs — the running system and every installed slot carry it
[meta.pithead] variant= in the update bundle's manifest — rauc info shows it before anything is installed

verify-image asserts the stamp matches the mode it runs in: --test expects debug, no flag expects release.

The stamp exists because the debug→release transition is one-way and used to be silent: a debug box that installs a release bundle drops SSH by design — the channel that drove the install — and recovery needs a console. This happened live on the bench and ended in a stick reinstall. cd /data/pithead && ./pithead os-update BUNDLE is the install path that reads both stamps and warns before making that transition, requiring a y/N confirmation (or --yes). A bare rauc install bypasses the guard; use it only when you have already decided the SSH loss is acceptable.

Compatibility metadata and the data-migration floor

The bundle manifest's [meta.pithead] section carries the compatibility contract the update path reads back before it installs:

Field Meaning
version the OS version this bundle carries (from VERSION)
data_migration true if this release runs a forward-only /data (lmdb) migration
minimum_os_version the lowest OS version that can still read /data once it has migrated

Three guards consume them, because a correctly-signed bundle is not automatically a safe one:

  • No signed downgrade. os-update installs without confirmation only a clean X.Y.Z release whose version is at or newer than the running OS. It fails closed: an older bundle, a pre-release/-prep version, garbage, or an absent stamp is not proof of safety (an older image re-introduces the holes the newer one fixed, carrying our own valid signature), so any of them is refused unless --allow-downgrade is passed on purpose. The check is skipped only when the box cannot read its own version — a source checkout, never a provisioned appliance. (Deliberate A/B rollback is unaffected — rauc status mark-bad booted boots the spare slot already present; it does not re-install an old bundle.)
  • No rollback below the migration floor. When a data_migration bundle installs, os-update records its minimum_os_version as a floor on /data (.os-data-floor). Once a floor file exists it is authoritative and fails closed: an OS below it, a bundle whose version can't be parsed, or a corrupt floor file itself is refused outright — --allow-downgrade does not override any of these, because the migrated chain data is unreadable there and the failure is silent data loss, not a policy preference. The escape is a factory reset (loses the chain) or restoring a backup taken on a version at or above the floor. The floor is raised at install time, before the migration runs, and the migration itself waits for the slot to commit (#851) — so a migrating bundle that fails its boot gate falls back with the data untouched and the floor already raised. os-update therefore records the floor it replaced (or none) in .os-data-floor.prev before raising, and the fallback boot puts the floor back from that record and removes it; a box with no record keeps its floor, since a floor is never lowered without one. Until the old slot carries that boot logic, the guard tells the truth about the state instead: a floor above the running version means the migration never ran (or the slot was installed outside pithead), the floor version or newer installs, and nothing needs resetting or restoring for it (#1393).
  • No migration on a volume without room for it. A data_migration bundle is refused when the local Tari node's data volume lacks free space of data.mdb's size plus 5 GiB: a Tari major migration writes a compacted copy beside the old database, and on a full volume it fails part-way after the slot has committed (#2645). The sizing, and the sizes the refusal names, are pithead upgrade's (tari_db_space_shortfall, #2636). The guard keys on data_migration alone, since the Tari image a bundle starts is in its compose file, which cannot be read before the install. So a migrating bundle is held to the Tari bound even when only Monero's data migrates. A Tari node that is remote or off, or no Tari database, skips it, and a size or free space that cannot be read is a warning. The dashboard's verify and install steps run it too, and keep the downloaded bundle when it refuses.

The data-migration contract for release authors: a release that ships a forward-only schema bump MUST declare it, or a later rollback silently strands the migrated chain data. Build the bundle with both fields set:

PITHEAD_DATA_MIGRATION=true PITHEAD_MIN_OS_VERSION=X.Y.Z os/rauc/mkbundle.sh ...

X.Y.Z is the lowest OS version whose monerod/tari can still read /data after the migration — normally this release's own version. mkbundle.sh refuses to build a migrating bundle without it. A release build (no --dev) also refuses unless both fields are set. This prevents omitted declarations, not incorrect declarations: the builder does not compare service image majors with a previous release. --dev retains the defaults. The 2.0.0 release bundle must declare PITHEAD_DATA_MIGRATION=true and PITHEAD_MIN_OS_VERSION=2.0.0. A release that does not migrate declares that: PITHEAD_DATA_MIGRATION=false PITHEAD_MIN_OS_VERSION=.

The migration hold — how a flagged update boots. Installing a data_migration bundle also leaves a marker on /data (.os-migration-pending, stamped with the bundle's version). Before loading images or rendering configuration, the candidate boot adds its A/B slot to the marker (VERSION|A or VERSION|B). A fallback into the previous slot then restores the data floor even when both builds carry the same version; the older version-only comparison also treats the qualified marker as a mismatch. pithead-boot brings the stack up without the chain services (monerod, tari, and their wallets — the holders of forward-only lmdb migrations). Before starting the dashboard, it writes a full sync-gate reset, revoking any mining release restored from the existing database. P2Pool and the proxy stop through the ordinary sync gate while local chains are held; after commit they wait for the required chains to sync before mining resumes. Normal boots and transient outages preserve the earned release. The A/B commit decision is made on everything else first. doctor reads the same marker and judges the deliberately-held chain containers by the sync-hold rule, so the commit gate gates on what is running instead of deadlocking on the hold. Only after mark-good does the boot path remove the marker and run a plain up — the chain services start, and the migration runs on a slot a fallback can no longer leave. That up is retried, five times ten seconds apart by default: compose aborts the whole start when one container is mid-transition at that instant, and a passenger container's restart must delay the chain start by seconds, never veto it until the next reboot. If every try fails the boot still finishes — the slot is committed and nothing can undo that — and the journal carries one FAULT line saying the chain services did not start and the migration has not run, with the recovery: ./pithead up from /data/pithead. If health fails instead, the slot stays uncommitted, the machine falls back, and the old OS boots normally — its data was never touched (the old boot path ignores the slot-qualified marker). A non-migrating install clears any stale marker. The db_schema field the plan also lists stays out until something reads it — an unread manifest field is a claim, not a contract.

Where the dashboard's own migrations run (#3998). The data_migration hold covers chain data only, and every candidate boot can fall back before it commits, migrating or not. So pithead-boot defers the dashboard's SQLite migrations relative to the commit as well. After rendering, it reads the booted slot's good state from rauc status --output-format=json; until the slot is marked good it writes .os-schema-held into the dashboard's data directory. While that marker stands the dashboard keeps the payouts table in the previous release's shape — created that way on a fresh database, with the payout identity rebuild skipped, and read and written through that shape — so a fallback into the previous release finds the schema it can write and keeps recording payouts. When the health gate passes, mark-good runs first; the boot then removes the marker and restarts the dashboard, and the deferred migration runs there — after the commit, on a slot no fallback can leave. A boot onto a slot that is already committed removes a stale marker instead. An unknown slot state (no rauc.slot boot argument, a failing or unparseable rauc status, no jq) defers, a marker that cannot be written fails the boot with the slot left uncommitted, and a restart that faults after commit logs a FAULT line without uncommitting the slot. This deferral needs no bundle declaration: it arms on every uncommitted appliance boot. It currently holds one migration, the 2.0.3 payout identity rebuild; a release that ships a different schema change an earlier release cannot read safely must add it to the same hold in storage_schema.py — additive changes alone may stay outside it.

Development loop

Everything runs from the repo root on a Linux box with docker, KVM and libvirt. The bench is the KVM-capable build box; a laptop cannot run this (/dev/kvm is required).

# PITHEAD_REGISTRY is not optional while VERSION is unreleased — see the note below.
PITHEAD_REGISTRY=<host:port> PITHEAD_REGISTRY_CA=<ca.crt> PITHEAD_REGISTRY_COSIGN_PUB=<cosign.pub> os/build-image.sh --ssh &&
    sudo os/rauc/mkimage.sh --dev

A dev image pulls its services; only the wizard image is baked. At first boot the appliance pulls pithead-<service>:v$(cat VERSION) for all five first-party services, and while VERSION leads the last release those tags exist nowhere public. Build without PITHEAD_REGISTRY and the appliance provisions, publishes dashboard credentials, and then runs ZERO containers — five battery legs report it and each waits up to 25 minutes (#2043). build-image.sh refuses such a build; publish the five images to a registry the builder and the guest can both reach first.

A dev image ships the last release's compose file, not the tree's. Every image: in docker-compose.yml is pinned by STACK_VERSION, and the appliance derives that from its baked VERSION, so a tree ahead of that release would bake a compose file that assumes image content the pinned tags predate — once a healthcheck script the published image did not carry, and a container that stayed unhealthy for good (#1098). os/build-image.sh therefore stages docker-compose.yml from the tag v<VERSION> whenever that tag exists, records the choice in /opt/pithead/COMPOSE_SOURCE (tag NAME SHA, or tree) and prints it. What that costs: a compose change on the branch is not exercised on the appliance until the next cut, where the tag does not exist yet and the tree is the source. A clone that has not fetched the tag is refused rather than silently built the old way; git fetch --tags clears it. Only the appliance battery's synthetic bundle fixture may opt into an explicit compose file; ordinary builds cannot replace the tag or tree source.

--dev auto-generates a throwaway CN=pithead-dev signing key for the bench. A release build omits it and must name the real key instead (PITHEAD_RAUC_CERT + PITHEAD_RAUC_KEY) — see Cutting a release and the key custody runbook in release-server.md. The guard is what stops a throwaway dev cert from becoming the fleet's update trust root.

Two build variants, chosen by one flag:

  • Release (the artifact that ships): no flag. Shell-less — sshd stays disabled and no key is baked; tests/os/verify-image.sh refuses test material in this variant.
  • Debug/bench (--ssh [PUBKEY_FILE]): bakes the given public key (default: the builder's own ~/.ssh/id_ed25519.pub) as root's authorized key and enables sshd, for benches driven over SSH. Verify with tests/os/verify-image.sh IMAGE --test. A bench that takes an A/B update to a release bundle loses SSH — deliberate, and worth remembering before pressing install. Built with PITHEAD_REGISTRY set to a non-default namespace, a debug image also pins that registry into its boot units, the dashboard control runner and /etc/environment (so a pithead verb run by hand over SSH pulls from the same place, #1931), and tells podman how to trust it — the CA file named by PITHEAD_REGISTRY_CA for a TLS registry, or an insecure entry without one — and requires PITHEAD_REGISTRY_COSIGN_PUB for that registry's signed images. For the no-CA debug route, cosign explicitly permits HTTP too; a release image or a custom release-registry override never does. The staged five service references are digest-pinned and verified before provision; the release variant uses the shipped release key, while the debug variant replaces it with that alternate key. A failed verification refuses the pull and leaves the wizard/console error visible. The release variant never carries the debug material, and verify-image.sh checks both ways.

The updater defaults to RAUC; an image built without it cannot take another update, and the only way to get one now is to set PITHEAD_UPDATER to something else on purpose.

Updating a bench over SSH, and the signing trap that stops you

A bench appliance can be moved to a new build entirely over SSH — copy the bundle to it and run cd /data/pithead && ./pithead os-update BUNDLE, then reboot. No USB, no console, and /data is never touched, so a synced chain survives. This is proven on the physical bench: a full A/B update installed and the machine came back on the new slot with its chain intact.

The trap is signing. --dev generates the throwaway chain once per checkout and reuses it after that (os/rauc/certs/, gitignored — resolve_signing_material in populate-slot.sh only generates when nothing is there yet). So a --dev bundle installs on any machine whose keyring came from the same checkout, but a different checkout — a second clone, a fresh CI workspace, a certs/ directory you deleted — starts with no cert and generates its own, different chain on its first --dev run. Point a bundle at a machine whose keyring came from a different checkout and RAUC refuses with signature verification failed: Verify error: self-signed certificate. To update a bench you built from another checkout, name that checkout's chain instead of generating a new one:

PITHEAD_RAUC_CERT=<build>/os/rauc/certs/cert.pem \
PITHEAD_RAUC_KEY=<build>/os/rauc/certs/key.pem \
PITHEAD_DATA_MIGRATION=false PITHEAD_MIN_OS_VERSION= \
  os/rauc/mkbundle.sh   # no --dev: naming the key IS the signal, so declare the migration fields —
                        # this bundle does not migrate; a migrating one declares true and X.Y.Z

Confirm before copying anything, by comparing fingerprints — the target's trusted chain is at /etc/rauc/keyring.pem:

openssl x509 -in /etc/rauc/keyring.pem -noout -fingerprint -sha256

Check the variant first as well: an update from a debug build to a release bundle removes the SSH channel you are driving it over, and --yes skips the guard that would have asked.

The rootfs Dockerfile installs the OS, RigForge toolchain, and selected updater in one layer, then removes apt lists and downloaded packages before committing it. Marker changes reuse that package layer. On a cold or evicted cache, the builder creates one package layer without retaining the apt lists. A cache hit reuses both update and install; it cannot install from an older index. Run os/build-image.sh --fresh-index to force a new package layer with a current index. build-image.sh also prints this command after an apt fetch failure. (#929; snapshot.debian.org pinning is a deliberate non-goal here, tracked as a follow-up for full build reproducibility.)

Then the tiered battery, lowest tier first — the same rule as testing-strategy.md:

sudo env PITHEAD_REGISTRY=<host:port> PITHEAD_REGISTRY_CA=<ca.crt> PITHEAD_REGISTRY_COSIGN_PUB=<cosign.pub> \
    tests/os/run.sh --phase boot --image os/rauc/build/system.img

--phase update and --phase fault build their own v1/v2 images and need no --image. The update phase also packages its built v1 system.img and dev-signed v2 bundle, checks both asset sizes and checksums, and compares the decompressed image with the original. Its phase log retains the sizes and hashes; harness cleanup removes the packaged copies. This checks the release packaging path with test signing, not the final release-key artifacts. --phase all runs all eight — boot, update, install, provision, rig, media, fault and reset. Expect roughly 25 minutes per phase, most of it image builds, so budget an evening rather than a coffee break. It ran five of the eight until #1064, which meant a cut that followed this page ran none of the destructive phases: the power cuts, the corrupt-bundle refusal, the factory reset, the wedged-/data recovery and the whole media channel. Record the dated per-phase pass count in the release issue for the tip actually being cut — an old green standing in for a new one is the same defect wearing a different hat.

Two harness rules worth knowing before you lose an afternoon to them:

  • It refuses to run when another pithead-* domain is defined on the bench. A stray VM takes the DHCP lease the harness reads back, and the battery then drives the wrong machine and reports passes that mean nothing.
  • On failure it keeps the guest console at /tmp/pithead-os-serial.log.failed. Read it first. /dev/console is whichever console= came last on the kernel cmdline, so check which one you are reading before concluding a component is silent.
  • A failed dashboard-driven install (update phase, leg 4) also keeps the guest's own account at /tmp/pithead-os-serial.log.leg4-install: the root runner's own journal (pithead-control.service, where its "OS install failed" warning and log tail land), the boot journal's rauc and OS-install lines, rauc status, disk and memory, and any OOM kill. It reads the current boot only: if the install took the guest down, the serial log above spans the reboot. The runner deletes its install log on failure and the dashboard result carries at most rauc's last error line, or nothing, so this file is the only place the cause survives.

The automated battery

tests/os/run.sh is a release gate, not a spike artifact. It found every defect in the updater bake-off, three of which had already survived multiple passing runs, and it is the only thing standing between the hand-written boot path and a fleet.

Phase Asserts Count
boot EFI boot to userspace; first-boot wizard announces itself with a console token; wizard serves the token gate on :80; machine-id is STABLE across a plain reboot (#895 — an empty-baked id with no restore mechanism regenerates on every boot, worse than the bug it fixes) 4
update /data grew to the disk and slots did not (#784); bundle installs into the spare; spare boots; an uncommitted update reverts on reboot; a committed update persists; after the commit, the page served comes from the NEW dashboard image (marker baked into the image and read back over HTTP — the tag never changes, so "containers run" proves nothing about staleness, #798); an operator can roll back off a committed version; host identity (SSH host-key fingerprint, machine-id) survives the A/B swap (#894/#895 — both live on /data, untouched by a slot swap). Then leg 4, the dashboard OS-update action end-to-end (#976): the machine is provisioned through the wizard's real HTTP flow, the release lookup is pointed at a bench-local server through the root-owned test seam, and the flow runs check → download (a pre-staged partial must RESUME, not restart) → verify — with the /data-floor and bad-signature refusals proven against RAUC's real keyring, refused bundles deleted — → install (in-flight flag armed, state says reboot-pending — and the header badge carries reboot-pending plus the target version, so a reboot stays owed even with the modal closed — nothing auto-reboots) → the explicit reboot intent → the new slot boots and moves the persisted step to verifying before its gate decides (#3909: a planted os-reboot intent in that window is REFUSED with the "already running" reason and an audit entry, and the boot id does not change) → the health gate commits, and the persisted "updated" verdict reaches /api/state 15 + leg 4
provision A config submitted through the wizard's real HTTP flow provisions the stack: validation, cosign-verified image pulls, containers running under podman, the provisioning units finished, dashboard served through caddy. Before the successful submission, an unreachable remote node must be refused by preflight with its safe form values retained; a separate injected post-validation setup fault must return to the setup page with a useful error and the retained values for an ordinary corrected submit (#1955). The submitted config also enables the on-box miner, so the built-in RigForge worker must come up on its own, wired to the machine's own stratum, with mining held behind the sync gate cleanly. A local-miner-only apply must stop the unit and remove its derived config when disabled, then start the process and render its pool when enabled again; both directions must leave the rendered environment and boot ID unchanged and restore the original configuration. After provisioning, dashboard control applies a benign setting, refuses a disruptive setting without APPLY, accepts it with APPLY, returns doctor and log-tail reports, and creates a downloadable encrypted backup; the stack and dashboard must recover after that backup (#1931/#1965). Then a reboot with no hands on it must return the stack unaided through pithead-boot. M10 cuts that live stack three times and after EVERY cut requires every pre-cut container, image digest, non-regressing monerod height, miner, Caddy, and committed slot to survive. Finally the commit gate's honesty (#852) requires the real cd /data/pithead && ./pithead doctor --json gate to PASS on the healthy still-syncing stack yet REFUSE once a revenue service is crashed. The provisioned boot also pins hugepages sizing, migration and floor-fallback behavior, and a Tari node that dies after the migrating slot commits: status, doctor and the dashboard must report it, and ./pithead up must recover it. Printed by the run
install The image boots as removable media (usb bus — the gate keys on it); the inventory offers the internal disk and never the boot medium; the real installer runs; the machine then boots from the target alone with a complete copy (/var/lib/dpkg — the overlay made an incomplete copy easy and invisible), a fresh machine-id, /data sized to the target, and the wizard serving. Then the reinstall leg plants a sentinel in /data, installs over the same disk, and requires the sentinel afterwards. After Fresh Start returns to removable media, the harness waits up to 180 seconds for the setup page before the remaining wipe and plant writes, so firstboot's read-only target probes finish first. The keep leg reinstalls from a newer stick over /data that holds the old dashboard image and digest record; the image ID and served page must change (#798). Its setup reports the mount, load, digest, image-lookup, database-cleanup and unmount sub-steps; a failure retains captured stderr privately beside the harness's existing SSH scratch file, without requiring an exported TMPDIR, and prints at most 20 source lines plus summary metadata, clipped to 240 columns, with terminal controls removed. Database cleanup and unmount are attempted after a mounted setup fails, and either cleanup failure rejects the plant even if an image ID was found. A 1.x xmrig_proxy pre-fill must migrate to xvb without carrying the removed key (#1954). The restore leg uploads the checked-in encrypted v1.20.0 fixture to an existing appliance disk, then proves the created P2Pool container carries its configured wallet, Tor identity, opaque RPC/onion secrets, and both fixture and target chain-data sentinels without a resync; its dashboard password survives with the archived bcrypt and fingerprint kept exactly, and authenticates with them (#2001/#2230/#2579). The startup probe requires the fresh sync-gate hold first. Before its one start, it rejects prior crashes, restarts and OOM kills; a stopped exit 137 is eligible only when bounded logs from that container start show both SIGTERM and stopping. After proving the sync-gate hold, the harness pauses the dashboard, starts the restored P2Pool container once, and samples its identity, running state, exit code and restart count four times over 30 seconds. Every sample must report the same container, running with exit code zero and zero restarts. The harness then stops P2Pool, restores the dashboard and rechecks its hold; failures name the probe checkpoint and include bounded daemon and kernel diagnostics. Prior stop evidence is escaped and limited to 30 lines of 240 columns; the start bound uses the shared Go-time-to-RFC3339 converter. This is startup proof without synced mining. The fixture's removed 1.x keys migrate as configuration documents: xmrig_proxy.* moves unchanged to xvb.*, the rendered XvB endpoint and donor id use them, telegram.control is dropped, and no config.json.bak-1x is left on /data because the archive is the pre-migration copy. 38
rig The removable image installs the RigForge role, which mines from the baked binary with no stack containers and follows the A/B update contract. M13 cuts power while it mines, then requires a new boot, unattended mining, and the committed slot to return. Printed by the run
media Checked host construction must finish before attachment: readiness is bounded to 5 seconds, and formatting, mount or cleanup failure ends the phase before its product assertions. Cleanup verifies loop and mount ownership and retains resources when unmount is unproved. A valid physical-presence config stick shows the exact diff, applies after its countdown, is consumed, and cancels when removed mid-countdown. Printed by the run
fault three power cuts mid-write; a deliberately corrupted bundle is refused without crashing and without bricking; a power cut inside the commit window; operator rollback after all of it; Fault D cuts an active first-boot baked-image load and requires the wizard and repaired image store afterwards; the box is still updatable afterwards 15
reset leg 0, the real ./pithead config-reset -y off a provisioned machine, instrumented by tests/os/reset-config-probe.sh: captures reset output and the actual Compose shutdown exit status before the wipe; a failed, unrecorded or warning-bearing stop fails even if reset exits 0. After the boot-condition checks, a bounded all-state project census must be empty before re-provisioning. It clears the config and re-arms the wizard while preserving the monero chain and Tor onion identity through reconfiguration. Leg 1, the real cd /data/pithead && ./pithead factory-reset: it comes back unprovisioned at the wizard, the config is gone, the container store holds no pulled stack images, machine-id and the SSH host key are fresh (a handed-over box must not keep the old owner's identity), and the wipe is recorded on the ESP — a wiped machine must be tellable from a brand-new one (#1062). Leg 2, the wedged-/data recovery: the ext4 magic corrupted on the real data partition, the box comes back usable with /data repaired, not erased — a sentinel planted before the corruption must survive (#1087) — and the ESP wipe log must not grow, because a repair recorded as a wipe would cry wolf Printed by the run

A brick is disqualifying, not deducted — any run that leaves a machine unable to boot fails the release regardless of the rest.

Manual battery — required before every appliance release

The automated battery runs in KVM. KVM is not hardware, and the failures it cannot see are exactly the ones that strand a user: real firmware, real disks, real NICs. Run this on a physical box before publishing an image. Record the results in the release issue.

Hardware: one x86-64 machine with UEFI, ≥ 16 GiB RAM, an internal SSD/NVMe, wired ethernet, and a USB stick. A second disk makes M4 and M5 meaningful.

M1 — flash and boot. Write the image to the USB stick. Disable Secure Boot in firmware, then boot the target from it. Expected: reaches userspace. Secure Boot is unsupported by design (#2187); follow the install guide's firmware instructions. The KVM boot row records a measured non-boot as the expected state for every image version.

M2 — discovery. Read the token from the console, then find the box from another machine at http://pithead.local and at the IP it printed. Expected: both load the token gate, and the machine stays reachable by name after the monitor is unplugged.

Note what this case does not prove: it walks the non-preseeded path, where the token exists only on the console, so a monitor (or serial line) is required at least once. Pre-seeding the token or a whole config from the stick's FAT partition is built — pithead-token.txt / pithead-config.json on the ESP, read by lib/pithead/10-installer-preseed.sh and carried onto the target by os/installer/pithead-install, with the install and media phases covering it. What is still unbuilt is choosing the target disk headlessly — see KNOWN-ISSUES (#979).

KVM analog: --phase install automates the mechanics of M3, M4 and M5 (inventory with real model/serial, the wrong-disk guard against a second scsi disk, copy completeness, target boot, and reinstall preserving /data). The manual cases remain about what KVM cannot fake — real firmware's boot order, a real USB controller, and a real internal disk. M4's "ERASES everything on it" wording is pinned at tier 1 from the empty state asserted by the KVM row.

M3 — install to disk. From the browser, choose the internal disk. Confirm that the USB stick itself is not offered, that no disk is preselected, and that model, size and serial are shown. Type the disk name, install, reboot, remove the stick. Expected: the machine boots from its internal disk and serves the setup page again.

M4 — the wrong-disk guard. With a second disk present holding unrelated data, confirm it is listed as "ERASES everything on it" and that installing to the other disk leaves it untouched.

M5 — reinstall preserves the chain. Re-run the installer against a disk that already holds a Pithead data partition. Expected: listed as "holds a previous install"; choose Keep everything, and /data survives with its contents. This is the one that costs a user days of re-syncing if it is wrong.

M6 — configure by paste. Complete the wizard using copy/paste for both addresses. Confirm a pasted subaddress (8…) is rejected with an explanation before submitting. Expected: the stack provisions and the dashboard comes up.

M7 — real update. Build a v+1 bundle, copy it to the machine, and install it with cd /data/pithead && ./pithead os-update BUNDLE (the test image carries SSH for exactly this; the command wraps rauc install and compares the variant stamps first — a debug box taking a release bundle must warn before removing its own SSH). Expected: installs, reboots into the new version, and an uncommitted update reverts on the next reboot, which pithead-boot now triggers itself after a failed health gate (#1065). The dashboard-driven OS update rides the same mechanism from the header's OS-update control (Dashboard › Updating the appliance OS); the KVM update phase's leg 4 drives it end-to-end, so this manual step stays about what KVM cannot show — real firmware and a real disk under the slot write.

M8 — pull the plug. During the update's write phase, physically cut power. Repeat three times. Expected: the machine boots the old version every time. A brick here blocks the release.

M9 — bad release rollback. Ship a deliberately broken bundle (a failing health check). Expected: the machine reverts to the previous version without a human present. Then perform an operator-initiated rollback from a good version and confirm it returns.

M10 — power-loss during normal mining. Cut power at the wall with the stack running and synced, then restore it and do not touch the machine. Expected: it powers on by itself, the chain is intact, and mining resumes.

The "by itself" half is the part that gets skipped, and it is the half that matters for an unattended miner. It depends on a firmware setting — Restore on AC Power Loss, or whatever the board calls it — that defaults to staying off on most hardware. Confirm the setting is part of the setup instructions and that the machine really does return unaided; a box that needs a human to press a button after every outage is not an appliance. This was found the obvious way: a mains outage took the build bench down overnight and it was still dark in the morning.

M11–M14 are the rig-role steps: rig install and mining, dashboard-driven adopt and config push, rig power-loss and update, and run-from-USB. M11 and M13 keep a manual procedure for their physical halves — see the rig-role manual battery — because the rig KVM phase (tests/os/phases/rig.sh) covers only the virtualized subset: it proves the wizard's rig card and role select, that a rig submits toward a pool, volatile journald, an unaided plain reboot, a virsh power cut with unattended mining and slot commit recovery, and the A/B update leg committing on a rig. Its own share leg (#2063) then re-points the rig at a SECOND, concurrent guest the battery itself boots as a remote-node coordinator (the same precondition as #2062) and proves an accepted share both ways — the rig's own worker and the coordinator's built-in miner — so an accepted share at a real p2pool is no longer manual-only; #3996 added the M11 hashrate floor and the fail-closed --require-complete, and #3994 backported the adopt leg, so a dashboard-driven adopt and config push is automated too (tests/os/rig-adopt-leg.sh, M12). What it still does not prove: MSR tuning or hugepages via doctor (a KVM guest cannot take RandomX MSR writes), or firmware Restore-on-AC-Power-Loss on a real rig — those still need a real loaner box. M14 — run-from-USB, never installed — is now the rigmedia KVM phase (tests/os/phases/rigmedia.sh, #2069): it boots the image as removable media beside a blank internal disk and answers RigForge without installing, and asserts the rig mines from the stick, no containers, volatile journald, an unaided reboot returns it mining, and the blank disk stays untouched; it does not touch the bootloader "Set up again" path (#1318), which stays whatever reaches the wizard again from a stick-run rig needs by hand. No bench release e2e scenario for the rig role exists yet. What is left — M11's physical half and M13's Keep-everything pass — is tracked as #3995; the numbering here stays stable so old release records still point at the same steps once those land.

M15 — backup and restore end to end. On a provisioned machine, record the payout wallet, the dashboard's onion address, and the current time. From Backup, create a backup and save both downloads: the encrypted archive and its one-time emergency kit. Confirm the dashboard returns after its brief disconnect. Boot a fresh target into the wizard, choose restore, upload that archive with the kit's passphrase, and finish installation. Expected: the new machine runs the restored config, its payout wallet and onion address exactly match the recorded values, and the dashboard answers. Keep the timestamp with the release evidence so the archive is unambiguous.

M16 — change settings after provisioning. In Configuration, change one benign energy value, preview it, apply it, reload, and confirm it persisted. Then point one node endpoint at a reachable test node: confirm the preview warns, verify a commit without the literal APPLY is refused, type APPLY, commit, and confirm the new endpoint is live. Restore the original endpoint the same way. Never use the physical-media path for this approval check; that path remains deliberately unable to self-approve disruptive changes.

The automated battery first keeps the stable monero.out_peers CONFIRM round trip, then drives the sensitive path through the ordinary authenticated control route. It proves a commit without the typed confirmation is refused, a confirmed commit applies and audits against the signed-in actor without an approver field, and a dashboard-password repoint commits behind typed APPLY and the envelope, proves the new login, and restores the fixture password (#2367). Before each host-side cd /data/pithead && ./pithead apply it drives — the node-config restore and the onion-exposure leg — it waits, bounded, for the control spool to hold no queued or claimed request, and reds the row if it never drains. That keeps the battery's phase boundary explicit; re-provisioning in apply does not stop a runner that is working a request, so the request still writes its result (#2363). With the reserved-node environment inputs, it requires the real host preflight, rendered endpoints, the current p2pool container's narrowly extracted endpoints, an endpoint-bound current-startup uses chain_id round trip, and root-side restoration from a mode-600 raw snapshot. Reserved-node credentials must be disposable test values. The payout-address confirmation remains manual M16 evidence.

RC1 addendum, still manual after the automated rows run:

  • Post-provision apply: perform M16 in the real browser and confirm the screen reconnects after containers restart; KVM proves the host path, not browser focus or stale-page behavior.
  • Backup restart and restored identities: perform M15 and retain both downloaded files; KVM proves the runtime and restore path, not that a human saved the one-time kit.
  • Reinstall pre-fill and failed-install recovery: confirm the migration notice names the removed 1.x key without showing values, that preflight keeps safe fields after refusing a bad node, and that a separate post-validation failure returns the same safe fields for retry.
  • Diagnostics: the battery runs both controls, requires all structured doctor rows even on a real nonzero health result, caps and redacts a p2pool tail, and refuses wallet logs. Manually inspect the rendered grouping and remedies; KVM proves the host results, not that the presentation is useful.
  • xvb.enabled: its three config shapes remain tier-1 coverage; manually check only the final opt-in wording when #1855 is integrated.
  • Boot labels (#1956): the specific post-commit serial-console assertion is written on its product branch. Read the real firmware menu on hardware; do not record this row as PASS until that dependency lands in the tested image.

The custom-hostname row is now specific: the wizard's fixture-box name must agree across the kernel, rendered HOST_IP, dashboard header state, certificate DNS and LAN-IP SANs, and active Avahi with working mDNS resolution. Its day-two fixture-next preview must leave those readings unchanged; an authenticated commit without the approval envelope remains refused. A confirmed ordinary control-route commit then applies the host-generated preview, and fixture-next must survive the unaided reboot and A/B update. The reserved-node uses chain_id row is automated but still needs actual reachable node inputs; the payout and browser confirmations remain manual. #1956 has written the serial assertion for boot labels, but none of these tier-4 rows is PASS until the product branches are integrated into an image and the full battery runs.

Cutting a release

The branch mechanics are the DIY doc's (releasing.md): the prep commit carries the version bump and draft notes, and the final cut commit refreshes and dates those notes on develop. main fast-forwards only when release.sh publishes the tag. Both channels share the final cut commit, one version and one GitHub Release.

  1. On the cut date, land the final cut commit: refresh the top CHANGELOG.md section for every operator-visible change included since prep and set its heading to the current UTC date. release.sh publishes that heading verbatim. Every gate, build and tag below uses that final cut commit. Run make lint && make test. Do not hand-run the KVM battery on this commit: submit the eight bench-ci tier4-kvm jobs on this exact SHA from Releasing § Which gates are automated: the boot group, the rig group as its four splits, the provision job against the seeded baseline, the crossupdate job from the previous release and the realupgrade job. Record every job ID in the release issue. Follow the same section for wallet preparation and the final status-gated e2e leg. An e2e failure must not cancel any KVM job. Stage 1 requires a green bench-ci/tier4 status on this SHA. make lint-sh refuses to run on any shellcheck but the pinned one and names the version it found alongside the one it wants; make -s print-shellcheck-version prints the pin. A distro build reports different findings over the same files, so a skew reds the cut for nothing — install the pin from release-server.md.

  2. Confirm VERSION still holds the version set by the prep commit. The tag is v<VERSION> and every artifact derives from it — STACK_VERSION is the single place the registry tag comes from. The compose file the image ships comes from that tag whenever it already exists and from the tree only while it does not; at this step it does not, so the release build bakes the tree's copy, and the tag release.sh then creates on this commit names those same bytes.

  3. Run the release pipeline with --draft first. It builds and publishes pithead-os-rootfs:vX.Y.Z by digest, refuses a rootfs carrying the debug SSH key or BUILD_LABEL, and leaves the exact exported bytes in os/build/pithead-root.tar with its .sha256 handoff. The production image and bundle builders require that digest and refuse a changed or debug-keyed tar. Do not run os/build-image.sh again: rebuilding would re-resolve apt and make the published rootfs differ from the appliance. Then build the image and bundle from that tar with the release root and signing leaf, never the throwaway --dev chain. Point PITHEAD_RAUC_KEYRING at the root baked into the image and PITHEAD_RAUC_CERT / PITHEAD_RAUC_KEY at the leaf that signs the bundle. Without the keyring export, populate-slot.sh defaults to baking the leaf as the trust anchor:

    export PITHEAD_RAUC_KEYRING=~/.config/pithead-release/rauc-root.pem
    export PITHEAD_RAUC_CERT=~/.config/pithead-release/rauc-signer.pem
    export PITHEAD_RAUC_KEY=~/.config/pithead-release/rauc-signer.key
    # declare the data-migration contract above for this release, migrating or not
    # migrating:     export PITHEAD_DATA_MIGRATION=true PITHEAD_MIN_OS_VERSION=X.Y.Z
    # not migrating: export PITHEAD_DATA_MIGRATION=false PITHEAD_MIN_OS_VERSION=
    sudo -E os/rauc/mkimage.sh && sudo -E os/rauc/mkbundle.sh

    Key generation, storage, the trust model and the rotation runbook are in release-server.md, mirroring the cosign section beside it. Then verify the artifact, pinning the commit you meant to build:

    sudo env PITHEAD_EXPECT_COMMIT="$(git rev-parse HEAD)" tests/os/verify-image.sh <image>

    Run verify-image.sh from the repo checkout you built, because it compares the artifact against these files: the shipped pithead must match the generated root copy and the config reference must be byte-identical to the tree, the shipped compose file must be byte-identical to the source its own COMPOSE_SOURCE stamp names (the tree at a cut; the staged tag's commit in a dev build), and the baked container archive is unpacked to confirm it carries this tree's wizard/server.py. RigForge's RIGFORGE_REF record must match the Dockerfile's immutable pin and the version in the baked tree's VERSION file.

    Before publication, compare the baked keyring's SHA-256 fingerprint with the release root. Check the keyring's complete contents too: the root fingerprint alone would miss an extra certificate after the root. Verify both the release bundle and a throwaway bundle signed by the release leaf against that baked keyring. The commands below inspect slot A of the image just built and fail if any check fails:

    (
      set -e
      TMPDIR=${TMPDIR:-/var/tmp}
      work_dir=$(mktemp -d "${TMPDIR:?}/pithead-keyring.XXXXXX")
      mkdir "$work_dir/mnt" "$work_dir/probe"
      trap 'sudo umount "$work_dir/mnt" 2>/dev/null || true; if [ -n "${loop:-}" ]; then sudo losetup -d "$loop"; fi; rm -rf "$work_dir"' EXIT
      loop=$(sudo losetup -Pf --show os/rauc/build/system.img)
      source os/rauc/loop-wait.sh
      wait_loop_partitions "$loop"
      sudo mount -o ro "${loop}p2" "$work_dir/mnt"
      baked=$(sudo openssl x509 -in "$work_dir/mnt/etc/rauc/keyring.pem" -noout -fingerprint -sha256)
      root=$(openssl x509 -in "$PITHEAD_RAUC_KEYRING" -noout -fingerprint -sha256)
      test "$baked" = "$root"
      sudo cmp -s "$PITHEAD_RAUC_KEYRING" "$work_dir/mnt/etc/rauc/keyring.pem"
      printf 'Baked keyring matches release root: %s\n' "$baked"
      sudo rauc info --keyring "$work_dir/mnt/etc/rauc/keyring.pem" os/rauc/build/update.raucb
      source os/rauc/populate-slot.sh
      render_bundle_manifest "$(tr -d '[:space:]' <VERSION)" release false "" >"$work_dir/probe/manifest.raucm"
      printf 'signature probe; never install\n' >"$work_dir/probe/rootfs.ext4"
      rauc --cert "$PITHEAD_RAUC_CERT" --key "$PITHEAD_RAUC_KEY" bundle "$work_dir/probe" "$work_dir/probe.raucb"
      sudo rauc info --keyring "$work_dir/mnt/etc/rauc/keyring.pem" "$work_dir/probe.raucb"
    )

    Record the fingerprint and both bundle verification results in the release issue. A keyring mismatch or a rejected bundle stops publication.

    All of that exists because a release build once shipped a dashboard two commits stale — the release clone was pulling from an intermediate clone rather than origin, so git pull succeeded and fetched nothing. The image passed every check that existed, behaved like the previous build, and reached a bench. The commit stamp catches a stale tree; the comparisons catch a stale artifact, including inside the container image, which is where it hid. It mounts the artifact and checks everything a green boot cannot prove: no test SSH key or marker shipped, the grubenv sits where load_env reads it, the kernel root is a probed PARTUUID, slot labels carry the built version and empty-slot state, all six docker-export artefacts are fixed, the engine bridge and cosign are aboard, and pithead-boot is enabled (and podman-restart is NOT — it started the stack into its own oneshot cgroup and systemd SIGKILLed the containers it had just spawned). Every check exists because its absence shipped, or nearly shipped, once.

  4. Package the verified image and bundle. The command refuses an asset at or above GitHub's 2 GiB limit, prints both published sizes in bytes, and writes a checksum for each published file. Check the compressed image round trip against the raw image before flashing:

    sudo scripts/release/package-appliance.sh os/rauc/build/system.img os/rauc/build/update.raucb os/rauc/build/release
    tag=v$(tr -d '[:space:]' <VERSION)
    cmp os/rauc/build/system.img <(xz -dc "os/rauc/build/release/pithead-os-${tag}.img.xz")
    (cd os/rauc/build/release && sha256sum -c "pithead-os-${tag}.img.xz.sha256" "pithead-os-${tag}.raucb.sha256")

    Record both sizes and checksums in the release issue. Stop if either asset reaches 2 GiB. Run the manual battery (M1–M10, M11–M13 for any release touching the rig role, M15 and M16) on real hardware by flashing pithead-os-${tag}.img.xz with the command in the appliance guide. The soak starts from that same compressed artifact. Record results. The human half of a release — every check no harness can make, and the traps that have actually bitten — is collected in the manual QA guides; walk them alongside this list.

  5. Attach the .img.xz, .raucb, and their two .sha256 files from os/rauc/build/release/ to the version's GitHub Release while it is still a draft (the DIY cut opens it with release.sh --draft), then publish once everything is attached. Published release assets are immutable — v1.18.0 burned its tag this way — so the release publishes exactly once, with both channels' artifacts aboard. The bundle's signature is what devices verify.

  6. main fast-forwards to the tag automatically when release.sh publishes; if the push was refused, run the command it prints (see After publishing).

Shipping a bad release

Covered in full by the bad-release runbook in dual-distribution-plan.md. The short version, because it is the thing you will want at 3am:

  • It does not boot — the machine reverts itself. An uncommitted update never survives a reboot; this is the case the A/B design exists for and it needs no operator.
  • It boots but fails its health check — pithead-boot does not commit and reboots the machine itself, so the fallback happens with nobody present (#1065). Exactly once: if the slot it falls back to fails the same way the fault is on /data, not in the slot, and the machine stays up with the reason in the journal instead of looping. Publish a fixed version; the fleet takes it on the next update.
  • It boots, passes its checks, and is still wrong — this one is on us, not the updater. Publish v+1 with the fix. An operator who already committed rolls back from a root shell with rauc status mark-bad booted && reboot; the dashboard has no button.

What bounds the damage in every case: /data is never touched by an update. Wallets, config and the synced chain survive a rollback, a bad release, and a factory reset of the system slots.