interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

GitHub aien-dev/aien-sovereign-core-mv#222 (code only)

closed derived acb75ef7f8ebc0e9 #222

Imported from GitHub aien-dev/aien-sovereign-core-mv#222 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 96d97af7e0ef7036de49f2926e659b4391af26e1 · Head 9a5b4d0301b3a1c7c3abcb3046d62cbafc87bb7d

Fetch it

A git bundle of the pull request's head, 24488 bytes.

curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/acb75ef7f8ebc0e9.bundle -o acb75ef7f8ebc0e9.bundle
git fetch acb75ef7f8ebc0e9.bundle refs/pull/222/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-sovereign-core-mv
222
9a5b4d0301b3a1c7c3abcb3046d62cbafc87bb7d
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":222,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/222","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:21Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index fab59092..a2818a8b 100644
--- a/.crumb
+++ b/.crumb
@@ -64,8 +64,8 @@
     "generated": {
       "children": [
         {
-          "digest": "56f591ac6ff77c0909109f9186e454416a9e90faf63499912ec060c4e121faa4",
-          "last_commit": "69340c7",
+          "digest": "e0b44c224e311bd7a834d7e3161863f4ef041b54809ba80ff46e15832797c02a",
+          "last_commit": "adb419e",
           "name": "scripts",
           "purpose": ""
         },
@@ -76,15 +76,15 @@
           "purpose": ""
         }
       ],
-      "children_root": "sha256:10d81c6270915316b54eee21734bb8e8f2716ffdc567100fb347a5f22ed95e24",
-      "compiled_at": "2026-10-06T14:04:39Z",
+      "children_root": "sha256:072aa626d2f91f969d5e1c07254222ec0cec0a84310fa983fe8a989228fe1e84",
+      "compiled_at": "2026-10-06T14:19:35Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:01c72768b6e5a60d7e282ce83e983f0487b7102c6626cbfef13e0d512cc6bc17",
-      "evidence_files": 20,
-      "evidence_root": "sha256:1ef4526f6fe1ba0cee21a89c3313d37bf2e94e1aa2e9bd1a364225e52882d170",
-      "files": 720,
-      "generated_at_commit": "9dba4e054f4aa259952973e5e9e760c86c94c26e",
-      "source_tree": "sha256:e0ffe4503121289b3c423ba1da31e69af6369862e952dbe4a3c799b9587ae4db"
+      "digest": "sha256:c988c68866c4cec4d4a30948ab648dd17e7ba9479fbb7980729531e0fd48ee49",
+      "evidence_files": 24,
+      "evidence_root": "sha256:16192fc4be2f886385affd6e26faae4b831eb62b87ceac4ab39d662e0859d7f8",
+      "files": 725,
+      "generated_at_commit": "a57da1982d90c97116cb2c2490eeecf0211008aa",
+      "source_tree": "sha256:e4746dac6c9de08848a1805c472002d64f1eac90c07601fa8a6aeaaea446e44f"
     }
   },
   "history": [],
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 180c5ed6..b4bad08f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -21,35 +21,89 @@ jobs:
             target: x86_64-unknown-linux-gnu
             artifact_name: sovereign-linux-x86_64.tar.gz
             use_tar: true
+            native_engine: false
           - os: ubuntu-24.04-arm
             target: aarch64-unknown-linux-gnu
             artifact_name: sovereign-linux-aarch64.tar.gz
             use_tar: true
+            native_engine: true
           - os: macos-latest
             target: aarch64-apple-darwin
             artifact_name: sovereign-macos-arm64.tar.gz
             use_tar: true
+            native_engine: false
 
     steps:
       - name: Checkout Source
         uses: actions/checkout@v4
 
-      - name: Install Rust Toolchain
-        uses: dtolnay/rust-toolchain@stable
+      - name: GNU tar (reproducible packages need it)
+        if: runner.os == 'macOS'
+        run: brew install gnu-tar
+
+      - name: Install pinned Rust toolchain (rust-toolchain.toml)
+        run: |
+          rustup toolchain install "$(sed -n 's/^channel *= *"\(.*\)"/\1/p' rust-toolchain.toml)" --profile minimal
+          rustc --version
+
+      - name: Read pins (omega.lock, then omega physics.lock)
+        id: pins
+        run: echo "omega=$(tr -d '[:space:]' < omega.lock)" >> "$GITHUB_OUTPUT"
+
+      # The native engine is linked only on the candidate target (linux aarch64, the GB10 host class).
+      # Other targets build the CPU stub, are labelled as such in the release notes, and are not the candidate.
+      - name: Checkout omega at omega.lock
+        if: matrix.native_engine
+        uses: actions/checkout@v4
         with:
-          targets: ${{ matrix.target }}
+          repository: aien-dev/omega
+          ref: ${{ steps.pins.outputs.omega }}
+          path: omega
 
-      - name: Build Workspace
-        run: cargo build --locked --release --workspace
+      - name: Read physics pin and checkout physics
+        if: matrix.native_engine
+        id: physpin
+        run: echo "physics=$(tr -d '[:space:]' < omega/physics.lock)" >> "$GITHUB_OUTPUT"
 
-      - name: Package Release Assets
-        run: bash scripts/package-release.sh "${{ matrix.artifact_name }}"
+      - name: Checkout physics at omega's physics.lock
+        if: matrix.native_engine
+        uses: actions/checkout@v4
+        with:
+          repository: aien-dev/physics
+          ref: ${{ steps.physpin.outputs.physics }}
+          path: physics
+
+      - name: Build the candidate way (scripts/repro-build.sh, fresh CARGO_HOME, no mojo)
+        env:
+          CARGO_HOME: ${{ runner.temp }}/cargo-home
+        run: |
+          if command -v mojo >/dev/null 2>&1; then echo "mojo is on PATH; the candidate build runs without it" >&2; exit 1; fi
+          if [ "${{ matrix.native_engine }}" = "true" ]; then
+            export AIEN_OMEGA_DIR="$GITHUB_WORKSPACE/omega" AIEN_PHYSICS_DIR="$GITHUB_WORKSPACE/physics"
+          fi
+          rm -rf "$CARGO_HOME"
+          cargo fetch --locked
+          # The other binaries first; aien-cli alone and last (a multi-crate build gives a different
+          # aien-cli digest, see docs/release/receipts/2026-10-06-install-upgrade-rollback-v2.md, F1).
+          scripts/repro-build.sh -p spark-cockpit-rs -p spark-inquisitor -p cortex-encoder-rs -p cortex-rs -p spark-supervisor -p spark-debugger
+          scripts/repro-build.sh -p aien-cli
+
+      - name: Package Release Assets (reproducible tarball, release.toml inside)
+        env:
+          AIEN_CANDIDATE_ID: ${{ vars.AIEN_CANDIDATE_ID }}
+        run: |
+          bash scripts/package-release.sh "${{ matrix.artifact_name }}"
+          AIEN_SHA="$(sha256sum target/release/aien-cli 2>/dev/null || shasum -a 256 target/release/aien-cli)"
+          printf '%s  %s  native_engine=%s\n' "${AIEN_SHA%% *}" "${{ matrix.artifact_name }}" "${{ matrix.native_engine }}" > "aien-cli-sha256-${{ matrix.target }}.txt"
+          cat "aien-cli-sha256-${{ matrix.target }}.txt"
 
       - name: Upload Artifact
         uses: actions/upload-artifact@v4
         with:
           name: ${{ matrix.target }}
-          path: ${{ matrix.artifact_name }}
+          path: |
+            ${{ matrix.artifact_name }}
+            aien-cli-sha256-${{ matrix.target }}.txt
 
   publish-release:
     name: Publish Release and Checksums
@@ -68,7 +122,8 @@ jobs:
       - name: Generate Checksums
         working-directory: release-artifacts
         run: |
-          sha256sum sovereign-* > SHA256SUMS.txt
+          cat aien-cli-sha256-*.txt > aien-cli-digests.txt
+          sha256sum sovereign-* aien-cli-digests.txt > SHA256SUMS.txt
           cat SHA256SUMS.txt
 
       - name: Sign Checksums (when the release key secret is configured)
@@ -102,12 +157,25 @@ jobs:
             echo "Official release of the AIEN Sovereign Native Systems Architecture." >> "$NOTES_FILE"
           fi
 
+          {
+            cat "$NOTES_FILE"
+            echo
+            echo "## aien-cli digests (compare with the candidate manifest [executables] aien-cli-native-release)"
+            echo
+            echo "Columns: sha256 of target/release/aien-cli, archive, whether the native engine (omega at omega.lock) is linked. Only the native_engine=true linux-aarch64 row is the candidate binary."
+            echo
+            echo '```'
+            cat release-artifacts/aien-cli-digests.txt
+            echo '```'
+          } > release-notes-with-digests.md
+          NOTES_FILE=release-notes-with-digests.md
+
           cd release-artifacts
           SIG=""
           [ ! -f SHA256SUMS.txt.sig ] || SIG="SHA256SUMS.txt.sig"
-          gh release create "$TAG" sovereign-* SHA256SUMS.txt $SIG \
+          gh release create "$TAG" sovereign-* aien-cli-digests.txt SHA256SUMS.txt $SIG \
             --title "AIEN Sovereign Core ${TAG}" \
             --notes-file ../"$NOTES_FILE" \
             --draft=false \
             --prerelease=false || \
-          gh release upload "$TAG" sovereign-* SHA256SUMS.txt $SIG --clobber
+          gh release upload "$TAG" sovereign-* aien-cli-digests.txt SHA256SUMS.txt $SIG --clobber
diff --git a/docs/release/receipts/2026-10-06-install-upgrade-rollback-v2.md b/docs/release/receipts/2026-10-06-install-upgrade-rollback-v2.md
new file mode 100644
index 00000000..fe887ab8
--- /dev/null
+++ b/docs/release/receipts/2026-10-06-install-upgrade-rollback-v2.md
@@ -0,0 +1,58 @@
+# Receipt v2: atomic upgrade, one-version rollback, reproducible packages, 2026-10-06 (NEXT-PHASE-4 cut 2)
+
+Supersedes the v1 receipt (`2026-10-06-install-upgrade-rollback.md`, kept unchanged as the record of the gaps this cut closes).
+Machine: NVIDIA DGX Spark (aarch64), host CPU only. No GPU or chip work was run. Everything ran in a scratch prefix,
+`env -i`, empty HOME, `AIEN_INSTALL_NO_PROFILE=1`, no sudo. Evidence: `np4-v2-evidence/demo.sh` and `np4-v2-evidence/demo-log.txt`
+(scratch path shortened to `<scratch>` in the log).
+
+## How the four releases in the demo were made (honest labelling)
+
+- relA: real build of CAND-3 pins, `aien-cli` = 3a17ee79... (the CAND-3 `aien-cli-native-release` digest), candidate CAND-3.
+- relB: real rebuild after the one-line `--version` change (`+np4-upgrade`), `aien-cli` = e789c04d..., candidate CAND-3 (log build-v2 and
+  the sha256 of the build tree binary match e789c04d, checked in this job).
+- relC: the relB binary with `+np4-upgrade` byte-replaced by `+np4-third-r` (same length), repackaged with `scripts/package-release.sh`,
+  `aien-cli` = 01cac51b... It is a test fixture, not a build of any source. Candidate id CAND-3.
+- relOld: the relA binary repackaged with candidate id CAND-2, to exercise the downgrade guard.
+- All signed with a throwaway key (not the pinned release key): NOT_RUN for a release signed by the pinned key.
+
+## Steps (demo-log.txt)
+
+| Step | Result | Evidence |
+|---|---|---|
+| 1 install relA | PASS | "Verifying every package file against release.toml", "Verifying the staged copy", live release 3a17ee79a238; seven symlinks in bin point at `releases/current/bin/...`; `installed.toml` has current=3a17ee79a238, previous empty |
+| 2 execute | PASS | `aien --version` from empty dir and empty PATH works; `zero-cuda-gate.sh` ZERO_CUDA PASS. `aien doctor` and any GPU probe: NOT_RUN |
+| 3 upgrade to relB | PASS | live e789c04d55b1, previous 3a17ee79a238, `--version` shows `+np4-upgrade`; user edit in operator.toml survived (sha256 check OK) |
+| 3b downgrade guard (relOld, CAND-2) | PASS | "not known to be newer than installed 'CAND-3' ... Nothing was installed."; live unchanged |
+| 4 rollback | PASS | `--rollback` gave live 3a17ee79a238 (was e789c04d55b1), binary sha256 equals step 1, `last-action = "rollback"`, operator.toml unchanged |
+| 5 interrupted upgrade to relC, kill -9 at mid-copy, after-copy, before-swap | PASS | See below |
+| 6 pinned-key refusal (no signer override) | PASS | "SHA256SUMS.txt signature is NOT valid. Nothing was installed." |
+| `scripts/test-install-release.sh` | PASS | re-run in this job; includes its own kill -9 points |
+
+Step 5 detail. This replaces the first demo (demo-v2), whose interrupt section was invalid: the second release was already
+staged so the installer never reached the pause point ("NEVER PAUSED") and the kills hit nothing. The fixed run uses a never-before-installed
+release (relC), and each kill landed (the "paused at <point>" line was seen before the kill). After each kill the live release stayed
+3a17ee79a238, the installed `aien` stayed 3a17ee79a238 and ran. Leftovers: a `.stage.01cac51b2bc9.<pid>` directory after mid-copy and
+after-copy (not live, not a release name); after before-swap a complete digest-named directory `01cac51b2bc9` that is staged but not
+live. Rerunning the install of relC made 01cac51b2bc9 live, `aien --version` shows `+np4-third-r`, and the release list was
+01cac51b2bc9, 3a17ee79a238, current (the old e789 was rotated out as designed: one previous release kept). Not tested:
+a kill during the single rename itself (kill after-swap is a pause point in install.sh but was not in this demo).
+
+## F1: the two `aien-cli` digests (from v1 receipt and build logs, nothing new measured)
+
+- `3a17ee79a238...` is `repro-build.sh -p aien-cli` built on its own. It equals the CAND-3 manifest digest `aien-cli-native-release`.
+  `package-release.sh` now packages this one, and its build recipe in release.yml builds per package, last, `aien-cli` alone.
+- `ccecf9a13ef2c7a1...` is `aien-cli` taken from a single cargo command that builds all seven packaged crates together
+  (np4-logs/build1.log line 876). Same size, 6,399,222 differing bytes, not the CAND-3 digest. Cause UNVERIFIED (v1 guessed
+  dependency feature unification; not investigated).
+
+## UNVERIFIED / NOT_RUN
+
+- `.github/workflows/release.yml`: YAML parses (PyYAML safe_load run from a scratch interpreter outside the repo, nothing added to the repo: jobs build-release and
+  publish-release, triggers push and workflow_dispatch). The workflow itself was NEVER RUN, so the CI build digest equals CAND-3: UNVERIFIED.
+  actionlint not available: NOT_RUN.
+- macOS: `mv -fh` path in install.sh and GNU-tar handling (`gtar`) in package-release.sh: UNVERIFIED, run on Linux only.
+- Reproducible packaging: two packagings were equal (sha256 b0aa34a6...) per the previous worker; not re-run in this job.
+- Release signed by the pinned AIEN release key: NOT_RUN (key unavailable).
+- Kill during the final rename (after-swap): NOT_RUN. Power loss or filesystem-level failure: NOT_RUN.
+- Published linux-aarch64 asset on the Spark: NOT_RUN (inherited from the 2026-10-04 receipt).
+- Other six binaries were verified only through `release.toml` file hashes, not against CAND-3 digests (only `aien-cli` has one).
diff --git a/docs/release/receipts/2026-10-06-install-upgrade-rollback.md b/docs/release/receipts/2026-10-06-install-upgrade-rollback.md
new file mode 100644
index 00000000..9c01c63b
--- /dev/null
+++ b/docs/release/receipts/2026-10-06-install-upgrade-rollback.md
@@ -0,0 +1,113 @@
+# Receipt: install, execute, upgrade, rollback, 2026-10-06 (NEXT-PHASE-4)
+
+Machine: NVIDIA DGX Spark (aarch64, Linux 7.0.0-1019-nvidia), host CPU only. No model was loaded and
+no GPU work was run (see step 2 for how `--version` was kept off nvidia-smi). Repository: aien-sovereign-core
+main at 80e071a (the CAND-3 sovereign-core pin). Nothing was written outside a scratch prefix; `$HOME` for the
+installer was an empty temporary directory, no `sudo`, no PATH profile edits (`AIEN_INSTALL_NO_PROFILE=1`).
+
+## Candidate (CAND-3 pins, frozen manifest qualification/candidates/CAND-3.toml)
+
+- sovereign-core 80e071a3ef700dbe31b1b081a957eebdcbf5ffc3
+- omega f816473df391bc4fbcf99df722edd70ed26ebef1 (checked out at that commit, `AIEN_OMEGA_DIR`)
+- physics 6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf (equals omega `physics.lock`, `AIEN_PHYSICS_DIR`)
+- toolchain: rust-toolchain.toml, 1.98.1; fresh `CARGO_HOME`, `cargo fetch --locked`; `mojo` not on PATH
+- manifest digest `aien-cli-native-release` = 3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db
+
+Signing note (limit of this receipt): the private half of the AIEN release key is not available to this job
+and none was created or imported. The archives were signed with a throwaway key made inside the scratch prefix
+(`ssh-keygen -t ed25519`, comment np4-throwaway) and `AIEN_ALLOWED_SIGNERS` pointed at its public line, the same
+mechanism `scripts/test-install-release.sh` uses. So the signature-and-checksum path ran for real, but against a
+throwaway key, not the pinned release key. NOT_RUN: verification of a release signed by the pinned key. The
+refusal side was run: the same install with no signer override (pinned key from install.sh) printed
+"SHA256SUMS.txt signature is NOT valid. Nothing was installed." and created no bin directory.
+
+## 1. INSTALL: PASS
+
+Build (log np4-logs/build1.log):
+
+```
+cargo fetch --locked      (CARGO_HOME = fresh directory in the prefix)
+scripts/repro-build.sh -p aien-cli
+scripts/repro-build.sh -p spark-cockpit-rs -p spark-inquisitor -p cortex-encoder-rs -p cortex-rs -p spark-supervisor -p spark-debugger -p aien-cli
+scripts/repro-build.sh -p aien-cli     (again, last, see finding F1)
+scripts/package-release.sh <rel1>/sovereign-linux-aarch64.tar.gz
+(sign SHA256SUMS.txt with the throwaway key, namespace aien-release)
+AIEN_RELEASE_TAG=v0.0.0-np4 AIEN_RELEASE_BASE_URL=file://<rel1> AIEN_BIN_DIR=... AIEN_CONFIG_DIR=... \
+  AIEN_ALLOWED_SIGNERS=... AIEN_INSTALL_NO_PROFILE=1 bash <standalone copy of install.sh>   (env -i, empty HOME)
+```
+
+Results:
+
+- install.sh: "Release mode without a source tree", "Signature and checksum verified", 7 binaries installed
+  (aien, cortex, cortex-encoder-rs, spark-cockpit, spark-debugger, spark-inquisitor, spark-supervisor), config and
+  EN2 imprint written to the config directory. Empty HOME stayed empty.
+- archive sha256 e7411c7f9c0a4147... (archives are not byte-reproducible, tar stores mtimes; the binaries inside are)
+- installed `aien` sha256 3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db
+- Digest comparison to CAND-3 `aien-cli-native-release`: **EQUAL**.
+
+Finding F1 (measured, cause UNVERIFIED): `repro-build.sh -p aien-cli` alone gives 3a17ee79... (EQUAL to CAND-3).
+Building the seven packaged crates in one cargo command and taking that `aien-cli` gives
+ccecf9a13ef2c7a17eb54375b1f35efba2782b967635737bd19d34298b406ac9 (same size, 6,399,222 differing bytes). I believe
+dependency feature unification or code layout differs when more packages are in one invocation (UNVERIFIED, not
+investigated). The CAND-3 recipe is per-package, so the last command above rebuilt `aien-cli` alone before packaging.
+Also, `.github/workflows/release.yml` builds `cargo build --locked --release --workspace` (no repro-build, no
+`AIEN_OMEGA_DIR`), so a published release binary is not the candidate binary (UNVERIFIED which digest it yields;
+not built here).
+
+## 2. EXECUTE: PASS
+
+Run from an empty directory with `env -i`, no source tree. `--version` calls `nvidia-smi` when it is on PATH
+(crates/aien-inference-abi `ExecutionSurface::detect`), so it was run with PATH set to an empty directory.
+
+- `aien --version` -> `AIEN CLI v0.1.0 (Host: Linux CPU (20 Cores, 121 GB RAM))`, exit 0
+- `aien --help` -> slash command list, exit 0
+- `ldd` lists no cuda or nvidia library; `scripts/zero-cuda-gate.sh <installed aien>` -> ZERO_CUDA PASS; `--self-test` -> PASS
+  (negative control rejected a CUDA probe)
+- Not run: `aien doctor` and anything that probes the GB10 or loads a model (NOT_RUN, no-GPU rule).
+
+## 3. UPGRADE: PASS (by overwrite; no dedicated upgrade path exists)
+
+Change (scratch worktree only, not in this PR): one README line and the `--version` string
+`v0.1.0` -> `v0.1.0+np4-upgrade` in crates/aien-cli/src/main.rs. Rebuilt `-p aien-cli`, packaged release 2
+(archive sha256 8dec09b3f088fa9b...), signed with the same throwaway key, and ran the same install command over
+the first install after appending `# user edit` to operator.toml.
+
+- installed `aien` sha256 e789c04d55b1963efc5b766d23d9c7693863cc37200dbca51adb44d5fee7db46, changed from step 1
+- `aien --version` -> `AIEN CLI v0.1.0+np4-upgrade (Host: Linux CPU ...)`, exit 0
+- operator.toml kept (log: "Existing configuration found"), the user edit survived
+
+## 4. ROLLBACK: PASS as a fallback, MISSING: no native rollback
+
+install.sh keeps no previous version. Fallback used, labelled as such: run the same install command against the
+release 1 assets again.
+
+- installed `aien` sha256 3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db, equal to step 1 and to the
+  CAND-3 digest; `cmp` against the binary inside the release 1 archive: byte-equal
+- `aien --version` back to the step 1 output; zero-CUDA gate PASS; operator.toml unchanged by the rollback
+- Only `aien` was compared to a CAND-3 digest. The other six binaries came from the same archive; they were not in the
+  manifest and were not individually re-hashed after rollback beyond the archive match.
+
+## Gaps (the supported procedure lacks these; not implemented here)
+
+1. MISSING: no native rollback. No previous-version copy, no `--rollback`, no backup of the replaced binaries.
+   Rollback needs the old signed assets to still be available.
+2. MISSING: no recorded installed version. Nothing in the bin or config directory says which release is installed;
+   the same tag with different content installed without complaint (test used one tag for both releases), and there is
+   no downgrade or same-version guard.
+3. MISSING: no atomic replace. `cp` writes over each binary in place. Replacing a running binary may fail with
+   "Text file busy" or leave a half-written file on interruption (UNVERIFIED, not tested here). No `install -m` to temp
+   plus `mv`, and no all-or-nothing across the seven files.
+4. MISSING: no uninstall, and no list of installed files; a binary dropped from a later release (or `spark-cockpit-rs`
+   renamed `spark-cockpit`) is never removed. Also `cortex-encoder-rs` is installed under its crate name while the
+   others are renamed.
+5. GAP: EN2 imprint is copied with `cp -r` over the existing imprint every run, so local edits there are overwritten
+   (read from install.sh, not tested). operator.toml is preserved.
+6. GAP: published releases are not the candidate. release.yml builds `--workspace` without repro-build.sh or the omega pins
+   (finding F1). Next cut: make the release workflow build per the CAND recipe and publish the CAND digest list.
+7. GAP: no published linux-aarch64 asset has been verified on the Spark (inherited from the 2026-10-04 receipt), and the
+   pinned release key was never exercised here (NOT_RUN above).
+8. GAP: `package-release.sh` output is not byte-reproducible (tar mtimes, owner); only the binaries inside are.
+
+Next cut: one script (`scripts/upgrade-release.sh` or a mode of install.sh) that stages the new release, verifies, swaps
+atomically, records the installed tag and digests in a manifest file, and keeps one previous version for `--rollback`;
+plus the release workflow change in gap 6.
diff --git a/docs/release/receipts/np4-v2-evidence/demo-log.txt b/docs/release/receipts/np4-v2-evidence/demo-log.txt
new file mode 100644
index 00000000..044077b0
--- /dev/null
+++ b/docs/release/receipts/np4-v2-evidence/demo-log.txt
@@ -0,0 +1,104 @@
+## 1 INSTALL
+[*] Downloading v0.0.0-np4: sovereign-linux-aarch64.tar.gz, SHA256SUMS.txt, SHA256SUMS.txt.sig
+[*] Verifying signature against <scratch>/keys/allowed_signers
+[+] Signature and checksum verified for sovereign-linux-aarch64.tar.gz
+[*] Verifying every package file against release.toml
+[*] Verifying the staged copy
+[+] Live release is now 3a17ee79a238 (candidate CAND-3); binaries:
+    - aien -> <scratch>/v3/bin/aien
+    - cortex-encoder-rs -> <scratch>/v3/bin/cortex-encoder-rs
+    - cortex -> <scratch>/v3/bin/cortex
+    - spark-cockpit -> <scratch>/v3/bin/spark-cockpit
+    - spark-debugger -> <scratch>/v3/bin/spark-debugger
+    - spark-inquisitor -> <scratch>/v3/bin/spark-inquisitor
+    - spark-supervisor -> <scratch>/v3/bin/spark-supervisor
+[*] Initializing Sovereign Operator Profile...
+[+] Generated default configuration at <scratch>/v3/config/operator.toml
+[*] Installing Free EN2 Trinity Imprint...
+[+] EN2 Trinity Imprint installed locally to <scratch>/v3/config/imprints/en2
+  ⚡ Portable binaries installed. Model and access-token provisioning remain.
+  Primary Command: aien
+
+3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db  <scratch>/v3/config/releases/3a17ee79a238/bin/aien
+total 28
+aien -> <scratch>/v3/config/releases/current/bin/aien
+cortex -> <scratch>/v3/config/releases/current/bin/cortex-rs
+cortex-encoder-rs -> <scratch>/v3/config/releases/current/bin/cortex-encoder-rs
+spark-cockpit -> <scratch>/v3/config/releases/current/bin/spark-cockpit-rs
+spark-debugger -> <scratch>/v3/config/releases/current/bin/spark-debugger
+spark-inquisitor -> <scratch>/v3/config/releases/current/bin/spark-inquisitor
+spark-supervisor -> <scratch>/v3/config/releases/current/bin/spark-supervisor
+live=3a17ee79a238
+schema = "AienInstalledV1"
+current = "3a17ee79a238"
+previous = ""
+last-action = "install"
+last-action-at = "2026-10-06T14:00:01Z"
+
+[version.3a17ee79a238]
+candidate = "CAND-3"
+aien-cli-sha256 = "3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db"
+installed-at = "2026-10-06T14:00:01Z"
+## 2 EXECUTE
+AIEN CLI v0.1.0 (Host: Linux CPU (20 Cores, 121 GB RAM))
+ZERO_CUDA PASS /home/drakestapleton/.claude/jobs/9bfe8553/tmp/np4-pref
+## 3 UPGRADE (candidate equal CAND-3, harmless version string change)
+7:[*] Verifying signature against <scratch>/keys/allowed_signers
+9:[*] Verifying every package file against release.toml
+10:[*] Verifying the staged copy
+11:[+] Live release is now e789c04d55b1 (candidate CAND-3); binaries:
+e789c04d55b1963efc5b766d23d9c7693863cc37200dbca51adb44d5fee7db46  <scratch>/v3/config/releases/e789c04d55b1/bin/aien
+AIEN CLI v0.1.0+np4-upgrade (Host: Linux CPU (20 Cores, 121 GB RAM))
+live=e789c04d55b1
+schema = "AienInstalledV1"
+current = "e789c04d55b1"
+previous = "3a17ee79a238"
+last-action = "install"
+last-action-at = "2026-10-06T14:00:02Z"
+
+[version.e789c04d55b1]
+candidate = "CAND-3"
+aien-cli-sha256 = "e789c04d55b1963efc5b766d23d9c7693863cc37200dbca51adb44d5fee7db46"
+installed-at = "2026-10-06T14:00:02Z"
+
+[version.3a17ee79a238]
+candidate = "CAND-3"
+aien-cli-sha256 = "3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db"
+installed-at = "2026-10-06T14:00:01Z"
+3a17ee79a238
+current
+e789c04d55b1
+<scratch>/v3/config/operator.toml: OK
+## 3b DOWNGRADE GUARD (repackaged as CAND-2)
+Error: package candidate 'CAND-2' is not known to be newer than installed 'CAND-3'. Use --allow-downgrade to install it anyway. Nothing was installed.
+live still e789c04d55b1
+## 4 ROLLBACK
+[+] Rolled back: live release is now 3a17ee79a238 (was e789c04d55b1); binaries:
+    - aien -> <scratch>/v3/bin/aien
+    - cortex-encoder-rs -> <scratch>/v3/bin/cortex-encoder-rs
+    - cortex -> <scratch>/v3/bin/cortex
+    - spark-cockpit -> <scratch>/v3/bin/spark-cockpit
+    - spark-debugger -> <scratch>/v3/bin/spark-debugger
+    - spark-inquisitor -> <scratch>/v3/bin/spark-inquisitor
+    - spark-supervisor -> <scratch>/v3/bin/spark-supervisor
+3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db  <scratch>/v3/config/releases/3a17ee79a238/bin/aien
+AIEN CLI v0.1.0 (Host: Linux CPU (20 Cores, 121 GB RAM))
+live=3a17ee79a238
+current = "3a17ee79a238"
+previous = "e789c04d55b1"
+last-action = "rollback"
+last-action-at = "2026-10-06T14:00:03Z"
+<scratch>/v3/config/operator.toml: OK
+## 5 INTERRUPTED UPGRADE to a fresh third release relC (kill -9 at three points, then rerun)
+killed at mid-copy: live=3a17ee79a238 (was 3a17ee79a238) aien=3a17ee79a238 (was 3a17ee79a238) runs: AIEN CLI v0.1.0 (Host: Linux CPU (20 Cores, 121 GB RAM)) | leftovers: 3a17ee79a238 current e789c04d55b1 .stage.01cac51b2bc9.972430 
+killed at after-copy: live=3a17ee79a238 (was 3a17ee79a238) aien=3a17ee79a238 (was 3a17ee79a238) runs: AIEN CLI v0.1.0 (Host: Linux CPU (20 Cores, 121 GB RAM)) | leftovers: 3a17ee79a238 current e789c04d55b1 .stage.01cac51b2bc9.972859 
+killed at before-swap: live=3a17ee79a238 (was 3a17ee79a238) aien=3a17ee79a238 (was 3a17ee79a238) runs: AIEN CLI v0.1.0 (Host: Linux CPU (20 Cores, 121 GB RAM)) | leftovers: 01cac51b2bc9 3a17ee79a238 current e789c04d55b1 
+rerun after interruption (relC):
+[+] Live release is now 01cac51b2bc9 (candidate CAND-3); binaries:
+live=01cac51b2bc9 aien=01cac51b2bc9
+AIEN CLI v0.1.0+np4-third-r (Host: Linux CPU (20 Cores, 121 GB RAM))
+01cac51b2bc9
+3a17ee79a238
+current
+## 6 pinned key refusal (no signer override)
+Error: SHA256SUMS.txt signature is NOT valid. Nothing was installed.
diff --git a/docs/release/receipts/np4-v2-evidence/demo.sh b/docs/release/receipts/np4-v2-evidence/demo.sh
new file mode 100644
index 00000000..9e25e423
--- /dev/null
+++ b/docs/release/receipts/np4-v2-evidence/demo.sh
@@ -0,0 +1,25 @@
+V=$1; P=$2
+BIN=$V/bin; CFG=$V/config; SA=$V/standalone/install.sh
+inst(){ rel=$1; shift; env -i PATH=/usr/bin:/bin HOME=$V/home AIEN_RELEASE_TAG=v0.0.0-np4 AIEN_RELEASE_BASE_URL=file://$V/$rel AIEN_BIN_DIR=$BIN AIEN_CONFIG_DIR=$CFG AIEN_INSTALL_NO_PROFILE=1 AIEN_ALLOWED_SIGNERS=$P/keys/allowed_signers "$@" ; }
+run_aien(){ (cd $V/empty && env -i PATH=$V/empty HOME=$V/home $BIN/aien --version); }
+live(){ readlink $CFG/releases/current; }
+echo "## 1 INSTALL"; inst relA bash $SA 2>&1 | grep -v '^ *aien \|^  *Quick\|====' | sed -n 4,30p
+sha256sum $(readlink -f $BIN/aien); ls -l $BIN | sed 's/.* \([^ ]* -> .*\)/\1/' | head -9; echo "live=$(live)"; cat $CFG/installed.toml
+echo "## 2 EXECUTE"; run_aien; bash $P/build2/scripts/zero-cuda-gate.sh $BIN/aien | cut -c1-70
+echo "# user edit" >> $CFG/operator.toml; sha256sum $CFG/operator.toml > $V/op.sum
+echo "## 3 UPGRADE (candidate equal CAND-3, harmless version string change)"; inst relB bash $SA 2>&1 | grep -n 'Live release\|Verifying\|Error'
+sha256sum $(readlink -f $BIN/aien); run_aien; echo "live=$(live)"; cat $CFG/installed.toml; ls $CFG/releases; (cd $V; sha256sum -c op.sum)
+echo "## 3b DOWNGRADE GUARD (repackaged as CAND-2)"; inst relOld bash $SA 2>&1 | grep 'Error'; echo "live still $(live)"
+echo "## 4 ROLLBACK"; env -i PATH=/usr/bin:/bin HOME=$V/home AIEN_BIN_DIR=$BIN AIEN_CONFIG_DIR=$CFG bash $SA --rollback 2>&1 | grep -v '====\|⚡'
+sha256sum $(readlink -f $BIN/aien); run_aien; echo "live=$(live)"; grep '^current\|^previous\|^last-action' $CFG/installed.toml; (cd $V; sha256sum -c op.sum)
+echo "## 5 INTERRUPTED UPGRADE to a fresh third release relC (kill -9 at three points, then rerun)"
+for point in mid-copy after-copy before-swap; do
+  OLD=$(live); OLDSHA=$(sha256sum $(readlink -f $BIN/aien)|cut -c1-12)
+  inst relC env AIEN_TEST_PAUSE_AT=$point bash $SA > $V/int.log 2>&1 &
+  pid=$!; for i in $(seq 1 100); do grep -q "paused at $point" $V/int.log && break; sleep 0.1; done
+  grep -q "paused at $point" $V/int.log || echo "NEVER PAUSED"
+  pkill -9 -P $pid; kill -9 $pid; wait $pid 2>/dev/null
+  echo "killed at $point: live=$(live) (was $OLD) aien=$(sha256sum $(readlink -f $BIN/aien)|cut -c1-12) (was $OLDSHA) runs: $(run_aien) | leftovers: $(ls -A $CFG/releases | tr '\n' ' ')"
+done
+echo "rerun after interruption (relC):"; inst relC bash $SA 2>&1 | grep 'Live release\|Error'; echo "live=$(live) aien=$(sha256sum $(readlink -f $BIN/aien)|cut -c1-12)"; run_aien; ls -A $CFG/releases
+echo "## 6 pinned key refusal (no signer override)"; env -i PATH=/usr/bin:/bin HOME=$V/home AIEN_RELEASE_TAG=v0.0.0-np4 AIEN_RELEASE_BASE_URL=file://$V/relA AIEN_BIN_DIR=$V/binX AIEN_CONFIG_DIR=$V/cfgX AIEN_INSTALL_NO_PROFILE=1 bash $SA 2>&1 | tail -1; ls $V/binX 2>&1 | head -1
diff --git a/install.sh b/install.sh
index b60af49c..3470537a 100755
--- a/install.sh
+++ b/install.sh
@@ -15,6 +15,234 @@ echo "=================================================================="
 # needs no source tree and no network beyond the three release assets.
 RELEASE_TAG="${AIEN_RELEASE_TAG:-}"
 
+ACTION="install"
+ALLOW_DOWNGRADE=0
+for arg in "$@"; do
+    case "$arg" in
+        --rollback) ACTION="rollback" ;;
+        --allow-downgrade) ALLOW_DOWNGRADE=1 ;;
+        -h|--help)
+            echo "usage: install.sh [--rollback] [--allow-downgrade]"
+            echo "  (none)             source build, or with AIEN_RELEASE_TAG=vX.Y.Z a signed release install"
+            echo "  --rollback         switch back to the one previous release kept by the last upgrade"
+            echo "  --allow-downgrade  accept a release whose candidate is older than the installed one"
+            exit 0 ;;
+        *) echo "Error: unknown argument: $arg" >&2; exit 2 ;;
+    esac
+done
+
+BIN_DIR="${AIEN_BIN_DIR:-$HOME/.local/bin}"
+CONFIG_DIR="${AIEN_CONFIG_DIR:-$HOME/.config/sovereign}"
+# Release layout: $REL_DIR/<first 12 hex of the package aien-cli sha256>/ holds one complete
+# release; $REL_DIR/current is a symlink to the live one and is the only thing an install or a
+# rollback switches (one rename). $BIN_DIR entries are stable symlinks through current. At most
+# the live release and one previous release are kept. $RECORD lists what is installed.
+REL_DIR="$CONFIG_DIR/releases"
+RECORD="$CONFIG_DIR/installed.toml"
+
+sha256_of() {
+    if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1
+    else shasum -a 256 "$1" | cut -d' ' -f1; fi
+}
+
+# Test hook: AIEN_TEST_PAUSE_AT=<point> makes the installer stop there until it is killed.
+pause_at() {
+    [[ "${AIEN_TEST_PAUSE_AT:-}" == "$1" ]] || return 0
+    echo "[test] paused at $1" >&2
+    while :; do sleep 1; done
+}
+
+# toml_get <file> <section|""> <key>: first value of key in the [section] table ("" = top level).
+toml_get() {
+    [[ -f "$1" ]] || return 0
+    awk -v sec="$2" -v key="$3" '
+        /^\[.*\]$/ { cur = substr($0, 2, length($0) - 2); next }
+        cur == sec {
+            i = index($0, " = "); if (i == 0) next
+            k = substr($0, 1, i - 1); gsub(/"/, "", k)
+            if (k == key) { v = substr($0, i + 3); gsub(/^"|"$/, "", v); print v; exit }
+        }' "$1"
+}
+
+# toml_lines <file> <section>: the raw lines of one table.
+toml_lines() {
+    [[ -f "$1" ]] || return 0
+    awk -v sec="$2" '
+        /^\[.*\]$/ { cur = substr($0, 2, length($0) - 2); next }
+        cur == sec && NF { print }' "$1"
+}
+
+# verify_release_dir <dir>: every file listed in release.toml [files] exists with its digest,
+# nothing else is present, and the recorded aien-cli digest is that of bin/aien.
+verify_release_dir() {
+    local d="$1" line f want n=0 have aien
+    [[ -f "$d/release.toml" ]] || { echo "  no release.toml in $d" >&2; return 1; }
+    while IFS= read -r line; do
+        f="${line%%\" = \"*}"; f="${f#\"}"
+        want="${line##*\" = \"}"; want="${want%\"}"
+        case "$f" in /*|*..*) echo "  unsafe path in release.toml: $f" >&2; return 1 ;; esac
+        [[ -f "$d/$f" && ! -L "$d/$f" ]] || { echo "  missing file: $f" >&2; return 1; }
+        [[ "$(sha256_of "$d/$f")" == "$want" ]] || { echo "  digest mismatch: $f" >&2; return 1; }
+        n=$((n + 1))
+    done < <(toml_lines "$d/release.toml" files)
+    [[ "$n" -gt 0 ]] || { echo "  release.toml lists no files" >&2; return 1; }
+    have="$(find "$d" \( -type f -o -type l \) ! -path "$d/release.toml" | grep -c . || true)"
+    [[ "$have" -eq "$n" ]] || { echo "  $have files present, $n listed" >&2; return 1; }
+    aien="$(toml_get "$d/release.toml" "" aien-cli-sha256)"
+    [[ "$aien" =~ ^[0-9a-f]{64}$ && "$(sha256_of "$d/bin/aien")" == "$aien" ]] \
+        || { echo "  aien-cli-sha256 in release.toml is not the digest of bin/aien" >&2; return 1; }
+}
+
+# Switch $REL_DIR/current to <id> with one rename.
+set_current() {
+    local id="$1" tmp="$REL_DIR/.current.new.$$"
+    rm -f "$tmp"
+    ln -s "$id" "$tmp"
+    if mv --help 2>&1 | grep -q -- ' -T'; then mv -T "$tmp" "$REL_DIR/current"; else mv -fh "$tmp" "$REL_DIR/current"; fi
+}
+
+# bin name as installed (the archive keeps crate names for two of them).
+installed_name() {
+    case "$1" in spark-cockpit-rs) echo spark-cockpit ;; cortex-rs) echo cortex ;; *) echo "$1" ;; esac
+}
+
+# link_bins <old-id|""> <new-id>: BIN_DIR entries are symlinks through current; links for
+# binaries that the new release no longer ships are removed.
+link_bins() {
+    local old="$1" new="$2" b name tmp
+    mkdir -p "$BIN_DIR"
+    if [[ -n "$old" && -d "$REL_DIR/$old/bin" ]]; then
+        for b in "$REL_DIR/$old/bin/"*; do
+            [[ -e "$REL_DIR/$new/bin/$(basename "$b")" ]] && continue
+            name="$(installed_name "$(basename "$b")")"
+            if [[ -L "$BIN_DIR/$name" && "$(readlink "$BIN_DIR/$name")" == "$REL_DIR/current/bin/"* ]]; then rm -f "$BIN_DIR/$name"; fi
+        done
+    fi
+    for b in "$REL_DIR/$new/bin/"*; do
+        name="$(installed_name "$(basename "$b")")"
+        [[ ! -d "$BIN_DIR/$name" || -L "$BIN_DIR/$name" ]] || { echo "Error: $BIN_DIR/$name is a directory" >&2; exit 1; }
+        tmp="$BIN_DIR/.$name.new.$$"
+        rm -f "$tmp"
+        ln -s "$REL_DIR/current/bin/$(basename "$b")" "$tmp"
+        mv -f "$tmp" "$BIN_DIR/$name"
+        echo "    - $name -> $BIN_DIR/$name"
+    done
+}
+
+# write_record <current-id> <previous-id|""> <action>: rewrite installed.toml atomically.
+write_record() {
+    local cur="$1" prev="$2" action="$3" now id at tmp="$CONFIG_DIR/.installed.toml.new.$$"
+    now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+    {
+        echo 'schema = "AienInstalledV1"'
+        echo "current = \"$cur\""
+        echo "previous = \"$prev\""
+        echo "last-action = \"$action\""
+        echo "last-action-at = \"$now\""
+        for id in "$cur" "$prev"; do
+            [[ -n "$id" ]] || continue
+            at="$(toml_get "$RECORD" "version.$id" installed-at)"
+            echo
+            echo "[version.$id]"
+            echo "candidate = \"$(toml_get "$REL_DIR/$id/release.toml" "" candidate)\""
+            echo "aien-cli-sha256 = \"$(toml_get "$REL_DIR/$id/release.toml" "" aien-cli-sha256)\""
+            echo "installed-at = \"${at:-$now}\""
+            if [[ -n "$(toml_lines "$REL_DIR/$id/release.toml" model)" ]]; then
+                echo
+                echo "[version.$id.model]"
+                toml_lines "$REL_DIR/$id/release.toml" model
+            fi
+        done
+    } > "$tmp"
+    mv -f "$tmp" "$RECORD"
+}
+
+# Keep only the live and the previous release.
+prune_releases() {
+    local keep1="$1" keep2="$2" d
+    for d in "$REL_DIR"/*/; do
+        d="$(basename "$d")"
+        [[ "$d" == current || "$d" == "$keep1" || "$d" == "$keep2" ]] || rm -rf "${REL_DIR:?}/$d"
+    done
+}
+
+cand_num() { [[ "$1" =~ ^CAND-([0-9]+)$ ]] && echo "${BASH_REMATCH[1]}" || true; }
+
+# activate_release <extracted-package-dir>: verify, stage, then switch with one rename.
+activate_release() {
+    local x="$1" aien id cand cur curcand a b stage
+    echo "[*] Verifying every package file against release.toml"
+    verify_release_dir "$x" || { echo "Error: package does not match its release.toml. Nothing was installed." >&2; exit 1; }
+    aien="$(toml_get "$x/release.toml" "" aien-cli-sha256)"; id="${aien:0:12}"
+    cand="$(toml_get "$x/release.toml" "" candidate)"
+    mkdir -p "$REL_DIR"
+    cur="$(toml_get "$RECORD" "" current)"
+    if [[ -n "$cur" ]]; then
+        curcand="$(toml_get "$RECORD" "version.$cur" candidate)"
+        if [[ "$cand" != "$curcand" && "$ALLOW_DOWNGRADE" != 1 ]]; then
+            a="$(cand_num "$cand")"; b="$(cand_num "$curcand")"
+            if [[ -z "$a" || -z "$b" || "$a" -lt "$b" ]]; then
+                echo "Error: package candidate '$cand' is not known to be newer than installed '$curcand'. Use --allow-downgrade to install it anyway. Nothing was installed." >&2
+                exit 1
+            fi
+        fi
+    fi
+    rm -rf "$REL_DIR"/.stage.*   # leftovers of an interrupted install; never live
+    if [[ -d "$REL_DIR/$id" ]]; then
+        if verify_release_dir "$REL_DIR/$id" && cmp -s "$x/release.toml" "$REL_DIR/$id/release.toml"; then
+            echo "[+] Release $id is already staged and complete"
+        else
+            echo "Error: $REL_DIR/$id exists but is incomplete or differs from this package. It was not overwritten. Remove it and rerun. Nothing was installed." >&2
+            exit 1
+        fi
+    else
+        stage="$REL_DIR/.stage.$id.$$"
+        mkdir -p "$stage"
+        local line f first=1
+        while IFS= read -r line; do
+            f="${line%%\" = \"*}"; f="${f#\"}"
+            mkdir -p "$stage/$(dirname "$f")"
+            cp "$x/$f" "$stage/$f"
+            if [[ "$first" == 1 ]]; then first=0; pause_at mid-copy; fi
+        done < <(toml_lines "$x/release.toml" files)
+        cp "$x/release.toml" "$stage/release.toml"
+        pause_at after-copy
+        chmod 755 "$stage/bin/"*
+        echo "[*] Verifying the staged copy"
+        verify_release_dir "$stage" || { echo "Error: staged copy is not complete. Nothing was installed." >&2; exit 1; }
+        mv "$stage" "$REL_DIR/$id"
+        pause_at before-swap
+    fi
+    set_current "$id"
+    pause_at after-swap
+    echo "[+] Live release is now $id (candidate $cand); binaries:"
+    link_bins "$cur" "$id"
+    if [[ -n "$cur" && "$cur" != "$id" ]]; then
+        write_record "$id" "$cur" install
+        prune_releases "$id" "$cur"
+    else
+        write_record "$id" "$(toml_get "$RECORD" "" previous)" install
+        prune_releases "$id" "$(toml_get "$RECORD" "" previous)"
+    fi
+}
+
+do_rollback() {
+    local cur prev
+    cur="$(toml_get "$RECORD" "" current)"; prev="$(toml_get "$RECORD" "" previous)"
+    [[ -n "$cur" && -n "$prev" ]] || { echo "Error: no previous release is recorded in $RECORD. Nothing to roll back to." >&2; exit 1; }
+    [[ -d "$REL_DIR/$prev" ]] || { echo "Error: previous release $prev is missing from $REL_DIR." >&2; exit 1; }
+    verify_release_dir "$REL_DIR/$prev" || { echo "Error: previous release $prev failed verification. Nothing was changed." >&2; exit 1; }
+    set_current "$prev"
+    echo "[+] Rolled back: live release is now $prev (was $cur); binaries:"
+    link_bins "$cur" "$prev"
+    write_record "$prev" "$cur" rollback
+}
+
+if [[ "$ACTION" == "rollback" ]]; then
+    do_rollback
+    exit 0
+fi
+
 # Release signing key, pinned here so a release can be verified with nothing but
 # this file and the assets (offline). Must equal docs/release/allowed_signers;
 # scripts/test-install-release.sh checks that they match.
@@ -70,10 +298,6 @@ RELEASE_ARCH="$TARGET_ARCH"
 # instead of building from source. Fails closed: nothing is installed unless
 # SHA256SUMS.txt carries a valid signature from the key pinned in
 # docs/release/allowed_signers and the archive matches its listed checksum.
-sha256_of() {
-    if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1
-    else shasum -a 256 "$1" | cut -d' ' -f1; fi
-}
 
 install_release() {
     local tag="$1"
@@ -116,17 +340,7 @@ install_release() {
     tar -xzf "$DL_DIR/$asset" -C "$DL_DIR/x"
     [[ -d "$DL_DIR/x/bin" ]] || { echo "Error: archive has no bin/ directory" >&2; exit 1; }
     [[ ! -d "$DL_DIR/x/imprints/en2-trinity" ]] || IMPRINT_SRC="$DL_DIR/x/imprints/en2-trinity"
-    local b name
-    for b in "$DL_DIR/x/bin/"*; do
-        name="$(basename "$b")"
-        case "$name" in
-            spark-cockpit-rs) name=spark-cockpit ;;
-            cortex-rs) name=cortex ;;
-        esac
-        cp "$b" "$BIN_DIR/$name"
-        chmod +x "$BIN_DIR/$name"
-        echo "    - $name -> $BIN_DIR/$name"
-    done
+    activate_release "$DL_DIR/x"
 }
 
 # Verify Rust Toolchain (source builds only)
diff --git a/scripts/.crumb b/scripts/.crumb
index 4e461035..b2eec9a9 100644
--- a/scripts/.crumb
+++ b/scripts/.crumb
@@ -4,14 +4,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-05T04:17:52Z",
+      "compiled_at": "2026-10-06T14:00:58Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:56f591ac6ff77c0909109f9186e454416a9e90faf63499912ec060c4e121faa4",
+      "digest": "sha256:e0b44c224e311bd7a834d7e3161863f4ef041b54809ba80ff46e15832797c02a",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 16,
-      "generated_at_commit": "f4460c7943025f806f60839d36584546f28404c1",
-      "source_tree": "sha256:a683f6d347163245e0f2100543c424c01795592f3b24414e5848c35a4dd2319c"
+      "generated_at_commit": "4d7b90715cbf4cb2549309b2179c3c6dca86cbda",
+      "source_tree": "sha256:a433c669fb4f7d93d5a5f6be9a96b04eb23cf77d4cc6f919bbb18b8215cb38b6"
     }
   },
   "parent": {
diff --git a/scripts/package-release.sh b/scripts/package-release.sh
index cc38b8d4..96f8e90d 100755
--- a/scripts/package-release.sh
+++ b/scripts/package-release.sh
@@ -1,7 +1,27 @@
 #!/usr/bin/env bash
+# Package the release binaries into a byte-reproducible tarball.
+#
+#   scripts/package-release.sh <output.tar.gz>
+#
+# Environment:
+#   AIEN_CANDIDATE_ID     candidate the binaries were built for, e.g. CAND-3 (recorded in release.toml)
+#   AIEN_MODEL_INPUTS     optional file holding a "[model]" TOML fragment (model input digests); copied in
+#   SOURCE_DATE_EPOCH     mtime for every entry (default 0)
+#
+# The archive carries release.toml: schema, candidate id, the sha256 of the packaged aien-cli,
+# the optional [model] table and a [files] table with the sha256 of every other file. install.sh
+# verifies every listed file against it before it activates a release.
+# Same inputs give the same bytes: sorted entries, fixed mtime, owner 0, no atime (gnu format),
+# normalised modes, gzip -n (no name or time in the gzip header).
 set -euo pipefail
 cd "$(dirname "${BASH_SOURCE[0]}")/.."
 ARTIFACT="${1:?provide output archive path}"
+CANDIDATE="${AIEN_CANDIDATE_ID:-unknown}"
+EPOCH="${SOURCE_DATE_EPOCH:-0}"
+TAR=tar
+command -v gtar >/dev/null 2>&1 && TAR=gtar
+"$TAR" --version 2>/dev/null | grep -q 'GNU tar' || { echo "GNU tar is required (on macOS: brew install gnu-tar)" >&2; exit 1; }
+sha() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi; }
 PACKAGE_DIR="$(mktemp -d)"
 trap 'rm -rf "$PACKAGE_DIR"' EXIT
 mkdir -p "$PACKAGE_DIR/bin"
@@ -16,4 +36,25 @@ if [[ -d imprints/en2-trinity ]]; then
     mkdir -p "$PACKAGE_DIR/imprints"
     cp -R imprints/en2-trinity "$PACKAGE_DIR/imprints/"
 fi
-tar -czf "$ARTIFACT" -C "$PACKAGE_DIR" .
+find "$PACKAGE_DIR" -type d -exec chmod 755 {} +
+find "$PACKAGE_DIR" -type f -exec chmod 644 {} +
+chmod 755 "$PACKAGE_DIR/bin/"* "$PACKAGE_DIR/install.sh"
+{
+    echo 'schema = "AienReleaseV1"'
+    echo "candidate = \"$CANDIDATE\""
+    echo "aien-cli-sha256 = \"$(sha "$PACKAGE_DIR/bin/aien")\""
+    if [[ -n "${AIEN_MODEL_INPUTS:-}" ]]; then
+        echo
+        grep -q '^\[model\]' "$AIEN_MODEL_INPUTS" || { echo "AIEN_MODEL_INPUTS must start with [model]" >&2; exit 1; }
+        cat "$AIEN_MODEL_INPUTS"
+    fi
+    echo
+    echo '[files]'
+    (cd "$PACKAGE_DIR" && find . -type f ! -name release.toml | LC_ALL=C sort | sed 's|^\./||') | while read -r f; do
+        printf '"%s" = "%s"\n' "$f" "$(sha "$PACKAGE_DIR/$f")"
+    done
+} > "$PACKAGE_DIR/release.toml"
+chmod 644 "$PACKAGE_DIR/release.toml"
+(cd "$PACKAGE_DIR" && "$TAR" --sort=name --mtime="@$EPOCH" --owner=0 --group=0 --numeric-owner \
+    --format=gnu -cf - .) | gzip -n -9 > "$ARTIFACT"
+echo "packaged $ARTIFACT sha256 $(sha "$ARTIFACT")"
diff --git a/scripts/test-install-release.sh b/scripts/test-install-release.sh
index 65875e59..35f17b06 100755
--- a/scripts/test-install-release.sh
+++ b/scripts/test-install-release.sh
@@ -13,8 +13,8 @@ set -euo pipefail
 
 ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
 WORK="$(mktemp -d "${TMPDIR:-/tmp}/aien-test-install-release.XXXXXX")"
-trap 'rm -rf "$WORK"' EXIT
-fail() { echo "FAIL: $*" >&2; exit 1; }
+[[ -n "${KEEP:-}" ]] || trap 'rm -rf "$WORK"' EXIT
+fail() { echo "FAIL: $*" >&2; [[ -z "${KEEP:-}" ]] || echo "WORK=$WORK" >&2; exit 1; }
 
 case "$(uname -s)" in Linux) OS=linux ;; Darwin) OS=macos ;; *) fail "unsupported OS" ;; esac
 case "$(uname -m)" in x86_64|amd64) ARCH=x86_64 ;; aarch64|arm64) ARCH=aarch64 ;; *) fail "unsupported arch" ;; esac
@@ -31,14 +31,21 @@ ssh-keygen -q -t ed25519 -N '' -C test -f "$WORK/key"
 ssh-keygen -q -t ed25519 -N '' -C other -f "$WORK/other"
 printf 'aien-release %s\n' "$(cut -d' ' -f1,2 "$WORK/key.pub")" > "$WORK/allowed_signers"
 
-make_release() { # dir signing-key
-    local d="$1" k="$2"
+make_release() { # dir signing-key [candidate] [variant]
+    local d="$1" k="$2" cand="${3:-CAND-1}" variant="${4:-a}" f aien
     rm -rf "$WORK/pkg"
     mkdir -p "$d" "$WORK/pkg/bin" "$WORK/pkg/imprints/en2-trinity"
-    printf '#!/bin/sh\nexit 0\n' > "$WORK/pkg/bin/aien"
+    printf '#!/bin/sh\necho aien-%s\nexit 0\n' "$variant" > "$WORK/pkg/bin/aien"
     printf '#!/bin/sh\nexit 0\n' > "$WORK/pkg/bin/cortex-rs"
     printf 'fixture imprint\n' > "$WORK/pkg/imprints/en2-trinity/soul.md"
     chmod 755 "$WORK/pkg/bin/"*
+    aien="$(sha256sum "$WORK/pkg/bin/aien" 2>/dev/null | cut -d' ' -f1 || shasum -a 256 "$WORK/pkg/bin/aien" | cut -d' ' -f1)"
+    {
+        printf 'schema = "AienReleaseV1"\ncandidate = "%s"\naien-cli-sha256 = "%s"\n\n[files]\n' "$cand" "$aien"
+        (cd "$WORK/pkg" && find . -type f ! -name release.toml | LC_ALL=C sort | sed 's|^\./||') | while read -r f; do
+            printf '"%s" = "%s"\n' "$f" "$(sha256sum "$WORK/pkg/$f" | cut -d' ' -f1)"
+        done
+    } > "$WORK/pkg/release.toml"
     tar -czf "$d/$ASSET" -C "$WORK/pkg" .
     (cd "$d" && sha256sum "$ASSET" 2>/dev/null > SHA256SUMS.txt || shasum -a 256 "$ASSET" > SHA256SUMS.txt)
     ssh-keygen -q -Y sign -f "$k" -n aien-release "$d/SHA256SUMS.txt"
@@ -97,4 +104,99 @@ fi
 grep -q "signature is NOT valid" "$WORK/log" || fail "pinned-signer fallback did not reject the fixture"
 [[ ! -e "$WORK/bin-pinned/aien" ]] || fail "pinned-signer refusal left a binary"
 
-echo "PASS: release install verifies signature and checksum, rejects tampered and forged releases, installs standalone offline, pinned key matches allowed_signers"
+
+# 7. upgrade: a newer candidate installs over the first; one previous release is kept; the
+#    record names both; operator.toml is untouched
+SIGN_ENV=(AIEN_SOURCE_DIR="$ROOT" AIEN_ALLOWED_SIGNERS="$WORK/allowed_signers")
+live() { readlink "$1/releases/current"; }
+inst_args() { # bin cfg args... : run install.sh with arguments in explicit dirs
+    local bin="$1" cfg="$2"; shift 2
+    env AIEN_BIN_DIR="$bin" AIEN_CONFIG_DIR="$cfg" AIEN_INSTALL_NO_PROFILE=1 HOME="$WORK/home" \
+        bash "$ROOT/install.sh" "$@" > "$WORK/log" 2>&1
+}
+echo '# local edit' >> "$WORK/cfg-good/operator.toml"
+OP_BEFORE="$(sha256sum "$WORK/cfg-good/operator.toml" | cut -d' ' -f1)"
+ID1="$(live "$WORK/cfg-good")"
+[[ -n "$ID1" && -f "$WORK/cfg-good/installed.toml" ]] || fail "first install left no live release or record"
+[[ "$("$WORK/bin-good/aien")" == "aien-a" ]] || fail "first install does not run"
+make_release "$WORK/rel2" "$WORK/key" CAND-2 b
+run_install "$WORK/rel2" "$WORK/bin-good" "$WORK/cfg-good" "$ROOT/install.sh" "${SIGN_ENV[@]}" \
+    || { cat "$WORK/log" >&2; fail "upgrade did not install"; }
+ID2="$(live "$WORK/cfg-good")"
+[[ "$ID2" != "$ID1" ]] || fail "upgrade did not change the live release"
+[[ "$("$WORK/bin-good/aien")" == "aien-b" ]] || fail "installed aien is not the upgraded one"
+grep -q "^previous = \"$ID1\"" "$WORK/cfg-good/installed.toml" || fail "record does not name the previous release"
+grep -q 'candidate = "CAND-2"' "$WORK/cfg-good/installed.toml" || fail "record lacks the new candidate"
+[[ "$(sha256sum "$WORK/cfg-good/operator.toml" | cut -d' ' -f1)" == "$OP_BEFORE" ]] || fail "upgrade changed operator.toml"
+[[ "$(ls "$WORK/cfg-good/releases" | grep -vc '^current$')" -eq 2 ]] || fail "expected exactly two releases kept"
+
+# 8. rollback returns to the first release and records it; a second rollback goes forward again
+inst_args "$WORK/bin-good" "$WORK/cfg-good" --rollback || { cat "$WORK/log" >&2; fail "rollback failed"; }
+[[ "$(live "$WORK/cfg-good")" == "$ID1" && "$("$WORK/bin-good/aien")" == "aien-a" ]] || fail "rollback did not restore the first release"
+grep -q '^last-action = "rollback"' "$WORK/cfg-good/installed.toml" || fail "rollback not recorded"
+grep -q "^previous = \"$ID2\"" "$WORK/cfg-good/installed.toml" || fail "record does not name the rolled-back-from release"
+inst_args "$WORK/bin-good" "$WORK/cfg-good" --rollback || fail "second rollback failed"
+[[ "$(live "$WORK/cfg-good")" == "$ID2" ]] || fail "second rollback did not swap forward"
+inst_args "$WORK/bin-good" "$WORK/cfg-good" --rollback || fail "third rollback failed"
+if inst_args "$WORK/bin-none" "$WORK/cfg-none" --rollback; then fail "rollback with nothing installed succeeded"; fi
+grep -q "no previous release" "$WORK/log" || fail "rollback with nothing installed not explained"
+
+# 9. downgrade guard: an older candidate is refused unless --allow-downgrade
+inst_args "$WORK/bin-good" "$WORK/cfg-good" --rollback >/dev/null || true   # live = ID2 (CAND-2)
+[[ "$(live "$WORK/cfg-good")" == "$ID2" ]] || fail "setup for the downgrade case failed"
+make_release "$WORK/rel0" "$WORK/key" CAND-1 c
+if run_install "$WORK/rel0" "$WORK/bin-good" "$WORK/cfg-good" "$ROOT/install.sh" "${SIGN_ENV[@]}"; then
+    fail "older candidate installed without --allow-downgrade"
+fi
+grep -q "allow-downgrade" "$WORK/log" || fail "downgrade refusal not explained"
+[[ "$(live "$WORK/cfg-good")" == "$ID2" ]] || fail "refused downgrade changed the live release"
+env AIEN_RELEASE_TAG=v0.0.0-test AIEN_RELEASE_BASE_URL="file://$WORK/rel0" AIEN_BIN_DIR="$WORK/bin-good" \
+    AIEN_CONFIG_DIR="$WORK/cfg-good" AIEN_INSTALL_NO_PROFILE=1 "${SIGN_ENV[@]}" \
+    bash "$ROOT/install.sh" --allow-downgrade > "$WORK/log" 2>&1 \
+    || { cat "$WORK/log" >&2; fail "downgrade with --allow-downgrade failed"; }
+
+# 10. package that does not match its own release.toml installs nothing
+make_release "$WORK/badpkg" "$WORK/key" CAND-9 d
+mkdir -p "$WORK/unp"; tar -xzf "$WORK/badpkg/$ASSET" -C "$WORK/unp"; printf 'x' >> "$WORK/unp/bin/cortex-rs"
+tar -czf "$WORK/badpkg/$ASSET" -C "$WORK/unp" .
+(cd "$WORK/badpkg" && sha256sum "$ASSET" > SHA256SUMS.txt && rm -f SHA256SUMS.txt.sig \
+    && ssh-keygen -q -Y sign -f "$WORK/key" -n aien-release SHA256SUMS.txt)
+LIVE_BEFORE="$(live "$WORK/cfg-good")"
+if run_install "$WORK/badpkg" "$WORK/bin-good" "$WORK/cfg-good" "$ROOT/install.sh" "${SIGN_ENV[@]}"; then
+    fail "package with a file that does not match release.toml was installed"
+fi
+grep -q "does not match its release.toml" "$WORK/log" || fail "manifest mismatch not reported"
+[[ "$(live "$WORK/cfg-good")" == "$LIVE_BEFORE" ]] || fail "rejected package changed the live release"
+
+# 11. interrupted install: kill the installer mid-copy and before the swap; the live install is
+#     still the old version, runs, and a rerun completes the upgrade
+make_release "$WORK/rel3" "$WORK/key" CAND-3 e
+for point in mid-copy after-copy before-swap; do
+    OLD="$(live "$WORK/cfg-good")"
+    env AIEN_TEST_PAUSE_AT="$point" AIEN_RELEASE_TAG=v0.0.0-test AIEN_RELEASE_BASE_URL="file://$WORK/rel3" \
+        AIEN_BIN_DIR="$WORK/bin-good" AIEN_CONFIG_DIR="$WORK/cfg-good" AIEN_INSTALL_NO_PROFILE=1 \
+        AIEN_SOURCE_DIR="$ROOT" AIEN_ALLOWED_SIGNERS="$WORK/allowed_signers" \
+        bash "$ROOT/install.sh" > "$WORK/log-int" 2>&1 &
+    IPID=$!
+    for _ in $(seq 1 100); do grep -q "paused at $point" "$WORK/log-int" 2>/dev/null && break; sleep 0.1; done
+    grep -q "paused at $point" "$WORK/log-int" || fail "installer never reached $point"
+    pkill -9 -P "$IPID" 2>/dev/null || true; kill -9 "$IPID"; wait "$IPID" 2>/dev/null || true
+    [[ "$(live "$WORK/cfg-good")" == "$OLD" ]] || fail "killed at $point changed the live release"
+    out="$("$WORK/bin-good/aien")"; [[ "$out" == "aien-b" || "$out" == "aien-c" ]] || fail "live install does not run after kill at $point ($out)"
+done
+run_install "$WORK/rel3" "$WORK/bin-good" "$WORK/cfg-good" "$ROOT/install.sh" "${SIGN_ENV[@]}" \
+    || { cat "$WORK/log" >&2; fail "rerun after interruption failed"; }
+[[ "$("$WORK/bin-good/aien")" == "aien-e" ]] || fail "rerun did not install the new release"
+[[ -z "$(ls -A "$WORK/cfg-good/releases" | grep '^\.stage\.' || true)" ]] || fail "leftover stage after rerun"
+
+# 12. an existing release directory that is incomplete is never overwritten
+ID3="$(live "$WORK/cfg-good")"
+make_release "$WORK/rel4" "$WORK/key" CAND-4 f
+ID4="$(sha256sum "$WORK/pkg/bin/aien" | cut -c1-12)"
+mkdir -p "$WORK/cfg-good/releases/$ID4"; echo partial > "$WORK/cfg-good/releases/$ID4/junk"
+if run_install "$WORK/rel4" "$WORK/bin-good" "$WORK/cfg-good" "$ROOT/install.sh" "${SIGN_ENV[@]}"; then
+    fail "install over an incomplete release directory succeeded"
+fi
+grep -q "was not overwritten" "$WORK/log" || fail "incomplete release directory not reported"
+[[ "$(live "$WORK/cfg-good")" == "$ID3" && -f "$WORK/cfg-good/releases/$ID4/junk" ]] || fail "refusal changed state"
+echo "PASS: release install verifies signature, checksum and every package file, rejects tampered and forged releases, installs standalone offline, pinned key matches allowed_signers, upgrades atomically, keeps one previous release, rolls back, refuses downgrades, survives an interrupted install"