Skip to content

Latest commit

 

History

History
543 lines (455 loc) · 38.6 KB

release-server.md

File metadata and controls

543 lines (455 loc) · 38.6 KB

The Release / Validation Server

How a build is validated end-to-end before release, why that needs a dedicated server, what GitHub Actions runs on every PR, and how to harden the server. Operational companion to Releasing (the version/promote pipeline) and Integration Testing (the harness it runs).

Can GitHub Actions do the full end-to-end? (no)

GitHub-hosted runners can't do the real-chain tier. On a public repo the hosted Ubuntu runners are free (4 vCPU / 16 GiB RAM), but they are ephemeral: a fresh VM per job, ~14 GiB of free disk, and a 6-hour job ceiling. A pruned Monero chain measures ~258 GiB on our own bench (#1446) and an unpruned one is larger still [TODO: verify upstream — no full-chain measurement exists on this bench]; either takes days to sync, and Tari adds ~50 GiB. There is nowhere to keep that synced state between runs, and no time to sync it inside a job. So the real-daemon, real merge-mining tier (tier 4) is not possible on hosted runners. That's the reason a dedicated, already-synced server exists (#54).

GitHub already runs almost everything else, free, on every PR. Tiers 1–3 of the testing strategy need no real chain and run on the hosted runners in minutes:

  • Tier 1, unit/component (dashboard pytest + coverage gate, frontend, the pithead shell suite, compose interpolation, and the #90 security/hardening invariants).
  • Tier 2, contract (the real Monero/Tari clients vs. controllable fakes).
  • Tier 3, the fake-daemon mini-stack (the real dashboard + docker-control proxy driven against fake daemons, with real Docker on the hosted runner). This proves the control plane end-to-end (sync hold/release, reject/readmit) on every PR.

So the split is clean:

Runs Cost Triggered
Tiers 1–3 (logic, wiring, control plane, hardening) GitHub-hosted runners free (public repo) every PR, the merge gate
Tier 4 (real synced Monero+Tari, real merge-mining, prune/full DB, TLS/Tor, the config matrix, the staging smoke test) the dedicated server your hardware pre-release / on-demand, the release gate

The hosted runners catch most regressions before merge. The dedicated server proves what only real chains can, and it is the blocking pre-release gate.

Validating protected updates

release.sh enforces a release status gate: the exact release SHA must carry a successful commit status whose context, publishing App numeric id and publishing App slug are configured through RELEASE_REQUIRED_STATUS_CONTEXT, RELEASE_REQUIRED_STATUS_APP_ID and RELEASE_REQUIRED_STATUS_APP_SLUG (settable in the release env file below, or in the environment). The gate is optional — with all three unset it logs a skip and the cut relies on the operator's manual attestation (Releasing). This repo's lane sets them to the bench-ci/tier4 context published by the pithead-bench-ci App: the dedicated server is not a GitHub Actions self-hosted runner, so tier 4 runs through bench-ci, which owns the reservation, runs the full suite against an exact SHA, and publishes that status through its dedicated GitHub App. The main ruleset requires the same context pinned to that App's integration_id; both were provisioned under #2237; an identical context from any other App does not satisfy a pinned entry.

NOTE: GitHub explicitly recommends against self-hosted runners on public repositories. Any user can open a pull request, and a malicious PR can run arbitrary code on the runner. The server holds real wallet payout addresses, Tor onion private keys, and RPC credentials, so a compromised runner is a key-theft / persistent-backdoor event, not a flaky build.

The checked-in release-gate.yml keeps workflow_dispatch as an operator tool, but no runner is registered for it. It is not the protected-update gate and never runs on pull requests or pushes.

Provisioning the server

Target an LTS Ubuntu (22.04 / 24.04). One-time:

  1. Install Pithead and let it fully sync (Getting Started): full Monero + full Tari, all containers healthy, a worker (ideally two) mining. The synced monero.data_dir / tari.data_dir are the asset the harness reuses.
  2. Keep the active chain on fast storage (SSD/NVMe). monerod is random-I/O heavy, so the chain it runs against must not sit on a spinning HDD; that alone makes every scenario crawl. A snapshot/reflink-capable filesystem (btrfs/zfs/xfs reflink) is a bonus for the prune axis: it lets the harness snapshot/restore a chain cheaply. It is a hard requirement only when this server runs tests/integration/run.sh --image-upgrade directly, because that command takes cp --reflink=always snapshots of every bind mount (chain, data dirs and the install dir's own data/) while the stack is stopped and refuses on a filesystem that cannot clone them, so the install dir and every data dir need one reflink-capable filesystem (only the small named volumes are copied, #2057). The tier4-kvm image-upgrade phase instead creates and removes a sparse reflink XFS inside its disposable guest; it does not require reflinks on the bench filesystem. On plain ext4-on-SSD the matrix only edits config.json and reuses one chain, with --safety-backup isolating destructive runs. See the recipe below for the prune-axis details.
  3. Disk headroom: enough for the chains plus a snapshot / second DB (budget ≥ ~150 GiB free beyond the live chains).
  4. Tools: jq, curl, docker (compose v2), sha256sum, git, tar.

Check the box is fit at any time, non-destructively:

tests/integration/run.sh --host you@server --dir pithead --readiness

It asserts: Monero caught up and Tari dashboard sync done, each polled every 5 s for up to 240 s (chains reusable). Monero expiry distinguishes a node that answered “not caught up” from one that could not be asked. It also checks that pithead status becomes healthy within 240 s (a failure lists each service's last verdict), the prune axis is exercisable (the live chain FS is snapshot-capable or a pre-built variant chain is supplied), disk headroom, .env is owner-only, the dashboard is bound to localhost, and the backup/rollback net is usable. A Tari-only timeout is reported to bench-ci as a retryable environment wait after baseline restore.

The lint/release toolchain

make release's blocking test gate runs make lint, which shells out to shellcheck, shfmt, node/npx, and uv/uvx; its test-stack leg also runs the Go module raise watch self-test, which needs Go 1.21 or newer on PATH (offline, against a fixture module graph; the preflight checks the version; Ubuntu 24.04's golang-go is 1.22, Debian 12's is 1.19 and fails the check). A reimaged box loses these, so the release preflight (#426) stops early and names the missing tools and their effective PATH rather than dying mid-gate. The check runs in a dry run and a real cut whenever the test gate is enabled; each resolved tool path is printed. Restore them with the same pinned versions CI uses (.github/workflows/shell.yml) — apt's shellcheck/shfmt are older and reformat differently, so a version skew would fail make lint on the box for diffs the merge gate never saw. Both pins live in the Makefile — SHELLCHECK_VERSION and SHFMT_VERSION — and each is what shell.yml installs and what make lint-sh refuses to run without; make -s print-shellcheck-version and make -s print-shfmt-version print them, and the block below calls those commands rather than copying what they print, so it cannot go stale against the pins. One wrinkle worth knowing when you check by hand: shfmt --version prints a leading v on the upstream release builds while some distro builds print a bare number, so the gate strips it before comparing.

# node 20 (brings npx) + the basics the harness also needs (golang-go: the go-raise-watch self-test)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs jq curl git tar make golang-go

# shellcheck + shfmt, read from the Makefile pins instead of copied. This block reads the repo, so
# it needs a checkout and runs from its root. If it does not, the two guards name that as the cause.
# Run as a script they also stop it; pasted into an interactive shell they do not, so what follows
# is a 404 you can interpret rather than one you cannot.
SC=$(make -s print-shellcheck-version)
SF=$(make -s print-shfmt-version)
: "${SC:?not in a checkout - run this block from the repo root}"
: "${SF:?not in a checkout - run this block from the repo root}"
curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/v$SC/shellcheck-v$SC.linux.x86_64.tar.xz" | tar -xJ -C /tmp
sudo install -m 0755 "/tmp/shellcheck-v$SC/shellcheck" /usr/local/bin/shellcheck
sudo curl -fsSL -o /usr/local/bin/shfmt "https://github.com/mvdan/sh/releases/download/v$SF/shfmt_v${SF}_linux_amd64"
sudo chmod 0755 /usr/local/bin/shfmt

# uv 0.12.13 (pinned installer; brings uvx; updates login-shell PATH)
curl -LsSf https://astral.sh/uv/0.12.13/install.sh | sh

The uv installer's bin directory is on a login shell's PATH only. Install the tools to a directory and set RELEASE_TOOL_PATH in the environment or the release env file so non-interactive runs see them too. It is a colon-separated list of absolute, existing directories, prepended to the exported PATH inherited by make test and every child process. Empty, relative, missing, or group/world-writable directories stop preflight. A dry run now fails on the same missing tool as the real cut; it still prints make test and the integration matrix rather than running them.

Preflight reads ${PITHEAD_RELEASE_ENV:-$RELEASE_KEY_DIR/env}; RELEASE_KEY_DIR defaults to the signing-key directory described below. A missing default file is ignored; a missing explicit PITHEAD_RELEASE_ENV target stops the run. Keep the file owned by the invoking user and not writable by group or world (0600 is recommended; 0644 is accepted). Symlinks are refused.

The file accepts only RELEASE_REQUIRED_STATUS_CONTEXT, RELEASE_REQUIRED_STATUS_APP_ID, RELEASE_REQUIRED_STATUS_APP_SLUG, RELEASE_INTEGRATION_ARGS, and RELEASE_TOOL_PATH, one NAME=value per line. Blank lines, comments beginning with #, an optional export prefix followed by a space, and matching single or double quotes are accepted. Values are literal: $, backticks, and ~ are not expanded, so write absolute paths. Existing environment settings win, including empty values. Preflight logs names and counts, never values. Any other name or malformed assignment stops the run with the file's basename and line number. Keep secrets in the signing-key and passphrase files; registry credentials and smoke commands cannot be put in this env file.

The release signing key

The pipeline signs every promoted image digest and the install bundle with cosign (#376, key-based — see Releasing › Signed releases for what installs verify and how). The private key lives only on this box, like the GHCR token; the public key is committed in the repo as cosign.pub. The release preflight refuses to run without cosign, COSIGN_KEY, COSIGN_PASSWORD, and cosign.pub all in place — signing is mandatory to publish because it is mandatory to consume (#960), so a missing piece aborts the cut rather than warning past it. --dry-run reaches the same decision and skips only the signing, so a rehearsal on this box tells you whether the real cut would sign.

Preflight then proves the key end to end: it signs a probe blob and verifies it through the same digest-pinned cosign container installs use. A cosign.pub that is no longer the public half of COSIGN_KEY fails here rather than in the field (#1084).

Install cosign (pinned — there is no Ubuntu apt package; the same snippet works on any host that wants to verify). Take v2.6.3, not the newest: cosign v3 removed the --tlog-upload flag both signing calls pass, and a drifted box would otherwise pass every other check and die at the signing stage with the images already promoted. Preflight probes for the flag and aborts early if it is gone.

curl -fsSL -o /tmp/cosign https://github.com/sigstore/cosign/releases/download/v2.6.3/cosign-linux-amd64
echo '7c78a7f2efc00088bd788a758db6e0928e79f3e0eb83eb5d3c499ed98da4c4f4  /tmp/cosign' | sha256sum -c
sudo install -m 0755 /tmp/cosign /usr/local/bin/cosign

Generate the key pair once, on this box:

cosign generate-key-pair      # prompts for a passphrase; writes cosign.key + cosign.pub
mkdir -p ~/.config/pithead-release
mv cosign.key ~/.config/pithead-release/cosign.key
chmod 600 ~/.config/pithead-release/cosign.key

Commit the cosign.pub it wrote at the repo root (it is the only half that ever enters the repo), and point the release shell at the private half:

export COSIGN_KEY=~/.config/pithead-release/cosign.key
read -rs COSIGN_PASSWORD && export COSIGN_PASSWORD   # typed, not in shell history

Both are also defaults now: the preflight falls back to ~/.config/pithead-release/cosign.key when COSIGN_KEY is unset, and reads ~/.config/pithead-release/cosign.passphrase (a chmod 600 file) when COSIGN_PASSWORD is unset — so a cut on this box needs no signing exports at all. The passphrase file is optional: delete it to be prompted per cut via the read -rs line above.

cosign reads COSIGN_PASSWORD from the environment to decrypt the key; neither the key nor the passphrase ever appears on a command line, in the repo, in an image, or in the release log. Keep an offline backup of cosign.key with the passphrase stored separately — losing it means rotating the key. To rotate: generate a new pair the same way, commit the new cosign.pub, and cut a transition release signed with the old key (leave COSIGN_KEY on the old key for that one cut) — installs verify the bundle with the key they already hold and come out holding the new one; switch COSIGN_KEY to the new key for the next release. If the old key is lost or compromised, sign with the new key immediately: the transition release then fails the bundle check on existing installs, so call it out in the release notes and have operators verify that one by hand against the new committed key.

The RAUC update-signing key

cosign signs the GHCR image digests and the install bundle. The appliance takes a second, independent signature: every A/B update bundle (os/rauc/mkbundle.sh → *.raucb) is signed, and RAUC on the device refuses any bundle that does not verify against the keyring baked into the running slot (os/rauc/system.conf → [keyring] path=/etc/rauc/keyring.pem). This key is the appliance fleet's update trust root: whoever holds it can push a bundle every fielded box will install as authentic. Treat it exactly as you treat cosign.key.

The tooling refuses to invent one. mkimage.sh / mkbundle.sh auto-generate a throwaway CN=pithead-dev key only for a build explicitly marked --dev; a release build (no --dev) exits non-zero unless the key is named:

  • PITHEAD_RAUC_KEY / PITHEAD_RAUC_CERT — the leaf that signs the bundle (private key + its cert/chain).
  • PITHEAD_RAUC_KEYRING — the cert(s) baked into every slot as the device trust anchor. Defaults to PITHEAD_RAUC_CERT; for the root+leaf model below, set it to the root so a leaf can be rotated without re-imaging.

So a dev cert can never silently become a shipped keyring — the guard, not memory of this page, is what enforces it.

Trust model: root + leaf, only the root baked. Use a two-cert chain, not one self-signed cert doing both jobs. A single self-signed cert used as both trust anchor and signer is the shape the bake-off found stricter verifiers reject (CaUsedAsEndEntity), and it couples the two rotations that should be independent: the root that every device trusts is baked into the image and cannot change without re-imaging, while the leaf that signs day-to-day should be cheap to replace. Bake the root as the keyring; sign bundles with a leaf issued from it. RAUC verifies the bundle's leaf against the baked root, so a leaf reissued from the same root is trusted by every fielded box with no image change.

Generate the pair once, on this box (RSA-4096 mirrors the dev chain; the root is a CA, the leaf is a digitalSignature end entity):

mkdir -p ~/.config/pithead-release && cd ~/.config/pithead-release

# Root — the device trust anchor. Baked into every slot; its private key is used ONLY to issue
# leaves, so keep it offline and out of the release shell's environment.
openssl req -x509 -newkey rsa:4096 -keyout rauc-root.key -out rauc-root.pem \
    -days 3650 -subj "/CN=pithead-update-root" \
    -addext "basicConstraints=critical,CA:TRUE"        # prompts for a passphrase

# Leaf — the day-to-day signer, issued from the root.
openssl req -newkey rsa:4096 -nodes -keyout rauc-signer.key -out rauc-signer.csr \
    -subj "/CN=pithead-update-signer"
openssl x509 -req -in rauc-signer.csr -CA rauc-root.pem -CAkey rauc-root.key \
    -CAcreateserial -out rauc-signer.pem -days 825 \
    -extfile <(printf 'basicConstraints=critical,CA:FALSE\nkeyUsage=critical,digitalSignature\n')

chmod 600 rauc-root.key rauc-signer.key
chmod 700 ~/.config/pithead-release

Storage. The root private key (rauc-root.key) is the crown jewel: keep it offline (an encrypted volume or a hardware token), passphrase-protected, and off this box between rotations — it is needed only to mint a new leaf, never to cut a routine release. The leaf key (rauc-signer.key) lives on this box like cosign.key, chmod 600, owner-only, with an offline backup. Only the certs (rauc-root.pem, the leaf .pem) are ever safe to hand out; neither private key enters the repo, an image, or a log. Point the release shell at the release material:

export PITHEAD_RAUC_KEYRING=~/.config/pithead-release/rauc-root.pem     # baked as the device keyring
export PITHEAD_RAUC_CERT=~/.config/pithead-release/rauc-signer.pem      # leaf that signs the bundle
export PITHEAD_RAUC_KEY=~/.config/pithead-release/rauc-signer.key

mkimage.sh bakes the keyring cert into slot A; mkbundle.sh signs the bundle with the leaf. A release build refuses an unset leaf cert or key, but an unset PITHEAD_RAUC_KEYRING defaults to the leaf cert. Export the root keyring explicitly for every release cut.

Rotation. The constraint that shapes the whole runbook: RAUC trusts the keyring baked at image build time, so a device only ever trusts what shipped in its running slot. A new trust anchor therefore has to reach devices inside an OS update they already trust, before any bundle is signed under it — a keyring is not something a device can be told to add out of band.

  • Routine, or a leaf compromise (root intact). Issue a fresh leaf from the same root (the second openssl pair above), and sign with it. Every fielded box already trusts the root, so nothing needs re-imaging. This is the case root+leaf exists for, and it should be the only one you ever hit in practice.

  • Root rotation (planned key change, or a suspected root compromise you can still sign around). You cannot swap the anchor in one step. Build a transition OS update whose baked keyring contains both the old and new roots (concatenate the PEMs), and sign that bundle with a leaf under the old root so existing boxes accept it:

    cat rauc-root.pem rauc-root-new.pem > rauc-keyring-transition.pem
    PITHEAD_RAUC_KEYRING=~/.config/pithead-release/rauc-keyring-transition.pem \
      PITHEAD_RAUC_CERT=~/.config/pithead-release/rauc-signer.pem \
      PITHEAD_RAUC_KEY=~/.config/pithead-release/rauc-signer.key \
      ...build image + bundle...

    Ship it and wait for the fleet to take it. Only once a box is running that slot does its keyring trust the new root; from then on you may sign with a leaf under the new root. A later update can bake the new root alone and drop the old one. Sequencing is everything — sign under the new root before the fleet has taken the transition update and those boxes reject the bundle.

  • Root lost or compromised beyond signing (you can no longer produce a bundle the fleet trusts). There is no remote recovery, the same dead end as a lost cosign.key: fielded devices trust only the baked root, so a bundle signed by anything else is refused. Recovery is a hands-on re-image of each box with a fresh keyring. Call it out in the release notes and, as with cosign, have operators verify the first post-incident image by hand against the new published root.

Signing key lifetime and rotation

A rig, including a stick rig that updates only on request, verifies a bundle against the root baked into its running slot and nothing else. The calendar therefore has to run ahead of the oldest image still in the field. The rules:

  • Lifetimes. The root is valid for 3650 days and the leaf for 825 days, as in the commands above. Neither number changes without an owner decision.
  • No certificate dated ahead of the build. The clock floor below is the newest notBefore among the keyring's certificates, so never bake a certificate whose notBefore is later than the image build: every rig on that image would refuse every update until that date arrives.
  • Custody. The root private key stays offline and out of the release shell, as under Storage. Only the operator signs bundles, with the leaf.
  • Leaf lead time. Issue the next leaf at least 90 days before the current one expires. A reissue needs no image change (Routine, or a leaf compromise).
  • Root lead time. Start the root transition at least two years before the root expires, so a new root is in a released image well before any rig needs it. Ship the transition bundle first, then wait until the fleet has taken it (Root rotation). Drop the old root only in a later bundle, and only once the oldest image you still support carries the transition keyring.
  • Never ship the cliff. A release whose signing leaf expires within 90 days, or whose baked root expires within two years and has no transition keyring in the same or an earlier release, is not cut.

A wrong clock. RAUC checks the signer's validity period against the system time, and a stick rig may boot with no reliable RTC. The checks stay on, because switching them off would make an expired or retired leaf verify forever (RAUC's --no-check-time and use-bundle-signing-time both do that, and neither is used). pithead os-update and the dashboard's update verbs instead apply one bounded rule: the floor is the newest notBefore among the certificates of the baked keyring, and a clock earlier than that is certainly wrong, so the update is refused before RAUC runs, with a message that names the clock and says to let the rig set its time or run timedatectl set-time. A rig that is offline and ahead of the true time can still see a valid certificate as expired; RAUC's verdict (certificate has expired or not yet valid) is then reported with the clock reading and a pointer to this section, and the dashboard keeps the staged download rather than deleting it as a bad signature. The rig is never told to trust a time source it cannot check.

The rotated and transition keyrings, the refusal on an expired certificate with a correct clock and the real RAUC verdict text are exercised by legs 8 and 9 of the update phase (tests/os/phases/update-signing-legs.sh); the clock rule is a tier-1 case in tests/os/selftest-os-update-clock.sh.

The dev/bench loop is unchanged — os/rauc/mkimage.sh --dev still auto-generates a throwaway into the gitignored os/rauc/certs/ and needs none of the above.

Recipe: prune-axis coverage, and the storage that matters

Put the active chain on fast storage. The biggest factor is the disk, not the filesystem: monerod does heavy random LMDB I/O, so a chain on a 7200 rpm HDD makes every scenario crawl. Check what you have before placing chains:

lsblk -d -o NAME,ROTA,SIZE,MODEL   # ROTA=0 is SSD/NVMe, ROTA=1 is a spinning HDD

Keep the chain monerod runs against on an SSD/NVMe. A spare HDD is fine for cold backups and pithead backup archives, but not for an active test chain.

A CoW filesystem (btrfs/zfs/xfs-reflink) is a bonus for the config matrix and a requirement for a direct tests/integration/run.sh --image-upgrade run, which cannot take its rollback snapshots of the data-dir bind mounts without cp --reflink=always and refuses rather than fully copying a chain (#2057). The tier4-kvm image-upgrade phase supplies its own guest-local reflink XFS and does not depend on the bench filesystem. On a CoW volume the harness can snapshot/restore a chain cheaply for per-scenario isolation, but only if it's on fast storage. A loopback btrfs on a spare HDD gives you CoW semantics at HDD speed, which is the wrong trade for an active chain. If your root FS is ext4 on an SSD (the common case) you don't need CoW at all: the matrix only edits config.json and reuses one chain, and --safety-backup (a pithead backup + auto-rollback) isolates the destructive scenarios.

Covering both prune modes. The box mines one mode (its real config). The harness exercises that mode against the live chain and skips the other unless you supply a chain for it (--full-data-dir / --pruned-data-dir). You usually don't need to: the opposite mode is covered by the fake mini-stack (integration-testing) plus the compose/config tests, which need no real chain. Supply the opposite-mode chain only to exercise it end-to-end, and build it on fast storage:

  • Pruned chain next to a full one? build-pruned-chain.sh copies the LMDB consistently (brief monerod stop, then immediate restart) and prunes the copy, leaving the canonical chain untouched. Fetch monero-blockchain-prune at the same version as the running monerod and verify it against the hash the image pins (build/monero/Dockerfile → MONERO_VERSION / MONERO_HASH).
  • Full chain? Pruning is irreversible, so a full chain means a fresh full sync (MONERO_PRUNE=0, ~1–3 days), rarely worth it just for test coverage.

The reference box is a pruned node on NVMe: it validates pruned mode live with --safety-backup, and full mode comes from the fakes. --readiness reports exactly this:

tests/integration/run.sh --host you@server --dir pithead --readiness

NOTE: a pruned chain's file stays large. An in-place prune does not shrink the LMDB file: it stays at the full-chain high-water mark, with the freed space sitting as internal free pages (Monero reuses them as the chain grows). How much is actually reclaimable is a measurement, not an assumption — mdb_stat -ef on an idle copy reports the freelist, and on this bench it is 10 pages out of 67,605,667, so there is nothing to reclaim (#1446). To reclaim it where there is, you must rewrite the DB with monero-blockchain-prune (see compact-chain.sh). It's slow (it copies every block over hours), though it reads through a snapshot so monerod keeps mining.

The tool is copy-then-swap, so it does not leave the swap to you. It renames <data-dir>/lmdb aside and moves the pruned DB into place — pointed at a live node's data dir that renames the live chain out from under a running monerod, silently until the next restart. To run it against a live chain, bind-mount the source so the kernel refuses the rename; the recipe and its guard are in compact-chain.sh's header.

MDB_VERSION_MISMATCH from a stock LMDB tool is the lock-file format, not a patched on-disk format: it appears while monerod holds the environment, and the same tool opens an idle copy of the same chain. Measured here on monerod 0.18.5.1, where both DBs read magic 0xbeefc0de, version 1 (#1446) — one bench, one build, so treat the reading as ours rather than universal. It is not corruption — do not stop monerod over it. Often the best move is to leave the free pages alone.

Bench allocation and the rig lock

The bench boxes are shared between this repo's tier-4 harness, RigForge's release gates, and production mining. Two automations cycling the same rig's services corrupt each other's results (a real 2026-07 incident: an operator "fixed" a service an e2e run had deliberately stopped), so ownership is static and every run takes a kernel lock.

Static allocation — each box states its owner in /etc/bench-role, and each box's own ~/README.md carries its specifics (hostname, role, data roots):

Box role Owner Use
RigForge bench rig RigForge e2e-real / tune gates. Pithead never touches its services.
Loaner rigs (two) Pithead Tier-4: e2e.sh repoints one at the test bench for a run, then reverts it. Verify systemctl is-active xmrig after any remote restart.
Fleet rigs Production Mining only. No test traffic.
Test bench Pithead Test bench + release box (the tier-4 target).
Production host Production Production stack; deploys only.

The run lock — RESERVE. Both harnesses take a flock on /var/lock/rig-e2e.lock before the first service-touching action and hold it on an inherited FD for the whole run, so the kernel releases it the moment the run dies — kill -9 included, no stale-lock cleanup. rigforge#183 defines the mechanism; #430 is this repo's mirror; the shared path on every box is the protocol. Mutating runs hold it exclusive; read-only runs (run.sh --check / --readiness) hold it shared, so concurrent readers coexist but still exclude mutators. tests/integration/run.sh takes it on the target box (over SSH for --host); e2e.sh also takes it on the loaner rig it borrows. A busy box makes the run exit 75 (EX_TEMPFAIL) naming the holder; set RIG_LOCK_WAIT=1 to queue instead. /run/rig-e2e.holder is a display-only sidecar naming the holder — the flock is authoritative, and a stale sidecar is harmless. The bench runner sets that wait during its reserved-lock handoff, and the harness forwards it to both pre-gates and its detached run; other callers keep the opt-in exit-75 default.

CHECK — and FREE, which is not a step for anyone. A harness frees the lock by dying: it holds it on an inherited descriptor, so the kernel drops it when the run ends, however it ends, and a holder that has to remember to free is a holder that eventually does not. An off-box actor (a human or an agent over SSH) never holds it at all — the command below is a probe. true returns at once and the lock goes with the ssh session, so it reports that the box was free at that instant and nothing more. For however long the work then takes, the actor is unprotected and a harness run can take the lock underneath it:

ssh <box> 'flock -n -x /var/lock/rig-e2e.lock true' || ssh <box> 'cat /run/rig-e2e.holder'
ssh <box> 'cat /etc/bench-role'   # the box's static owner

Hardening checklist (the pitfalls)

Treat the box as production-sensitive. It holds keys and it's the thing that signs off releases.

  • Secrets. .env (RPC creds), config.json (wallet addresses), and the Tor data dir (onion private keys) must be owner-only (chmod 600 .env; the --readiness check verifies this). Never print secrets in logs; the harness hashes them on the box and redacts artifacts. If the box also publishes releases, the GHCR token lives in the environment / a secret store, never in the repo — and so do the release signing keys: cosign.key + COSIGN_PASSWORD (#376), and the RAUC update leaf key (rauc-signer.key) with the RAUC root key kept offline entirely — all owner-only on this box, only their certs/public halves ever committed or handed out (see the signing-key sections above).
  • Network. Firewall to least exposure: inbound SSH (key-only, no root login, fail2ban) and the stratum port scoped to the LAN (workers › firewall); the dashboard stays on localhost behind Caddy and the monerod RPC on localhost (both asserted by --readiness). Nothing else should be reachable from the internet.
  • Untrusted code. Keep GitHub Actions off this box. Bench-ci runs only the exact SHA selected for the release gate and owns the reservation and cleanup.
  • Least privilege. A dedicated unprivileged user; the stack already runs least-privilege containers (no-new-privileges, cap_drop, read-only roots, scoped Docker socket proxies, regression-guarded in tests/stack/standalone/test_compose.sh).
  • Reproducible, clean baseline. The matrix reuses the synced read/write chains, which may advance normally; it does not replace them during config-only cases. The image-upgrade gate takes private reflink snapshots of every writable bind mount (a plain copy of the small named volumes) and restores them, restores the original config.json at the end, and --safety-backup takes a pithead backup first and rolls the box back (down → restore → up) if anything fails.
  • Build isolation and integrity. Build images in containers with pinned upstream versions and SHA256-verified binaries (the stack already does this). The gate authenticates its private candidate archive and image digests; later publication preserves those image digests but creates a separate release bundle (Releasing).

How a release is validated end-to-end

  1. Every PR → GitHub-hosted runners run tiers 1–3 (the merge gate). Cheap, free, fast.
  2. Pre-release → tiers 1–3 run in normal CI. A maintainer separately dispatches the protected release-gate workflow: every mode runs readiness and --check; matrix, xvb, and combined opt into their named destructive legs. Candidate production/signing remains an external private prerequisite. Per Releasing, the later staging smoke pulls promoted-by-digest images and verifies labels/platforms; a functional staged-tag run is opt-in via RELEASE_SMOKE_CMD.
  3. Nothing is tagged or published until that's green, and promotion is by digest, so the version users get is the exact bundle the server validated.

End-to-end coverage & gaps

What the live tier-4 gate exercises, and what it doesn't, so a release decision is made with eyes open. (The reference box is a pruned Monero node on NVMe; its own snapshot and this table also live at ~/pithead-testbench/ on the box, for operators and AI agents.)

Historical live coverage (not current exact-head release evidence): the config matrix (remote/local node, dashboard secure/insecure, Tari required/optional, RPC LAN access, XvB on/off) applied + asserted; lifecycle (restart, secret-preserving apply, same-version backup→restore round-trip); node-down failover → recovery; release readiness; pruned monerod (the real prod config); and the privacy egress assertions. #274 promoted the persistent direct-IPv4-TCP bridge-container observation into run.sh, and #206 added the running XvB-over-Tor configuration assertion. Together with the historical live evidence from #274, privacy egress is covered, with the stated IPv4-TCP/bridge-network limit, not a residual gap. Covered without a real chain (tiers 1–3): client↔daemon contract tests, the fake-daemon mini-stack (incl. full-prune behavior), compose hardening, config rendering, dashboard tests.

Gap (not tested live) Worth filling before release?
Full (unpruned) Monero live, which a pruned box can't exercise Low. Stack paths don't differ by prune mode; fakes/config cover it. A multi-day full sync isn't justified.
Protected pre-release gate Wired: the release status gate requires the configured status (here bench-ci/tier4, from the pinned App id provisioned under #2237) on the exact release SHA before stage 1, and the main ruleset pins the same context.
Cross-version self-deploy upgrade Medium. Run the upgrade proof tracked by #1997, which is blocked by its runnable-environment issue #2057. It proves authenticated manifest/image identity, mounts, captured chain anchors, durable state, secrets, workers/mining, derived state, and old-baseline restoration.
Cross-version appliance/RAUC upgrade Medium. The current KVM update builds both slots from one tree; #2056 tracks an upgrade from a real previous appliance release with provisioned state.
N-1 encrypted backup restore on the appliance Medium. Same-version restore is covered; #2001 tracks restoring a supported prior-release backup through the current wizard without a forced resync.
XvB route record Medium. Run the gate tracked by #1998. The enabled route starts only with hooked DROP rules; the routing transition has no recorded live proof.
Caddy-fronted /metrics with dashboard authentication Medium. Supply the live credential input and record the missing leg tracked by #2058.
Multi-worker scale: the harness assumes ~2 workers Medium. Add a load-gen worker + assert proxy routing/hashrate for perf confidence; #1999 tracks it.
Real Tari merge-mined block acceptance Low. Probabilistic; rely on template/connectivity checks.
Fault injection between two machines Low-Medium. --harness-arg --fault-injection-ssh exercises the rx() SSH branch and its extra shell quoting by dialing the reserved bench's own alias; it does not prove a second machine's network. See #2000 for the managed phase's exact-head stop, SIGSTOP, remove, cleanup and restoration evidence.

Recommended before release: record the new combined upgrade/XvB run. The remaining rows are explicit residual gaps.