Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/patches/f86df6889e837671 # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aien-sovereign-core-mv#230 (code only) closed derived `f86df6889e837671` #230 Imported from GitHub aien-dev/aien-sovereign-core-mv#230 (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 `44b73d776b2b4171b34c75b51a87b6bd59767b43` · Head `b3e2bb46a0d4e5acca0a50de033f242a8a22c29d` ### Apply it ``` git checkout -b patch-f86df6889e837671 44b73d776b2b4171b34c75b51a87b6bd59767b43 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/f86df6889e837671.patch | git am ``` Raw patch (mbox) · 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 230 b3e2bb46a0d4e5acca0a50de033f242a8a22c29d ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":230,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/230","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:24Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 9c1fe1a9..70cc67e9 100644 --- a/.crumb +++ b/.crumb @@ -64,8 +64,8 @@ "generated": { "children": [ { - "digest": "8adb9b86301dab19b5d674d5ef0eba0936f76f15eeccbfa88cdfd5d11adddac0", - "last_commit": "249f31f", + "digest": "7e21bed3084195dacdd52d79c7d4c7c95837b474fd35b74dd087e6067bdeb58c", + "last_commit": "2b49c6a", "name": "scripts", "purpose": "" }, @@ -76,15 +76,15 @@ "purpose": "" } ], - "children_root": "sha256:5bc6c40c7fc034d6f7a949a438fcc78ed8c452232e3a6ab7bb6ef6b622ebaf49", - "compiled_at": "2026-10-06T18:51:57Z", + "children_root": "sha256:009593670dc7accc2b442a6a8c6f3b848ab73de4d6e61df57401bf4bf00b294a", + "compiled_at": "2026-10-06T19:07:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:54cd4945e3020f6412ee3b7aea24bb578f3f59beb74e864a4741129f4fffd7e4", + "digest": "sha256:2f8538be90622efe80d18c1976b4a7762766d603e5988d0b382a120df0494fe7", "evidence_files": 24, "evidence_root": "sha256:16192fc4be2f886385affd6e26faae4b831eb62b87ceac4ab39d662e0859d7f8", - "files": 798, - "generated_at_commit": "58e8af47cd808aa2065293df58258d0630f3a041", - "source_tree": "sha256:eed86a0ef151ec7ad3407131991f1bdcbe6a761ac64d182023b49584347daf2f" + "files": 802, + "generated_at_commit": "5dd4196023c7adadaeaeebe23078209874d559dd", + "source_tree": "sha256:3da1b7c04c4d8491c9cd29a3b3c10215064d117040493d2bdeebbea0807a5d8d" } }, "history": [], diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3468192..814ff11d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,9 @@ jobs: - name: Verify Signed Release Install run: bash scripts/test-install-release.sh + - name: Release gate negative tests (pins, digests, model inputs, signatures) + run: bash scripts/test-release-checks.sh + - name: Verify Piped Installer Bootstrap run: bash scripts/test-install.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7c2983be..afd2f506 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,11 @@ on: tags: - "v*" workflow_dispatch: + inputs: + dry_run: + description: "Dry run: build, package, sign with a throwaway key, verify, upload workflow artifacts only. Never creates a release." + type: boolean + default: true permissions: contents: write @@ -46,7 +51,9 @@ jobs: rustup toolchain install "$(sed -n 's/^channel *= *"\(.*\)"/\1/p' rust-toolchain.toml)" --profile minimal rustc --version - - name: Release gate (candidate named, omega.lock equals the candidate's omega commit) + - name: Release gate (candidate named, omega.lock and Cargo.lock pins equal the candidate's) + id: gate + continue-on-error: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }} run: scripts/check-release-candidate.sh - name: Read pins (omega.lock, then omega physics.lock) @@ -86,18 +93,35 @@ jobs: 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 + # The one recipe (docs/release/BUILD_RECIPE.md): helpers as one group, then aien-cli alone and last. + scripts/release-build.sh - name: Package Release Assets (reproducible tarball, release.toml inside) + env: + AIEN_DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run && '1' || '' }} 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: Check the package against the candidate (model inputs, files, aien-cli digest; native build also the candidate digest) + id: pkgcheck + continue-on-error: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }} + run: | + if [ "${{ matrix.native_engine }}" = "true" ]; then NATIVE=--native; else NATIVE=; fi + scripts/check-release-candidate.sh --package "${{ matrix.artifact_name }}" $NATIVE + + - name: Record dry-run status + if: always() && github.event_name == 'workflow_dispatch' && inputs.dry_run + run: | + { + echo "DRY RUN. This is not a release and must not be installed as a candidate." + echo "release gate: ${{ steps.gate.outcome }}" + echo "package check: ${{ steps.pkgcheck.outcome }}" + } > "DRY-RUN-STATUS-${{ matrix.target }}.txt" + cat "DRY-RUN-STATUS-${{ matrix.target }}.txt" + - name: Upload Artifact uses: actions/upload-artifact@v4 with: @@ -105,10 +129,47 @@ jobs: path: | ${{ matrix.artifact_name }} aien-cli-sha256-${{ matrix.target }}.txt + DRY-RUN-STATUS-${{ matrix.target }}.txt + + dry-run-sign: + name: "Dry run: sign with a throwaway key and verify" + needs: build-release + if: github.event_name == 'workflow_dispatch' && inputs.dry_run + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout Source + uses: actions/checkout@v4 + + - name: Download Build Artifacts + uses: actions/download-artifact@v4 + with: + path: release-artifacts + merge-multiple: true + + - name: Checksums, throwaway signature, verification + working-directory: release-artifacts + run: | + cat aien-cli-sha256-*.txt > aien-cli-digests.txt + sha256sum sovereign-* aien-cli-digests.txt > SHA256SUMS.txt + ssh-keygen -q -t ed25519 -N "" -C aien-dry-run-throwaway -f ../dry_key + printf "aien-release %s\n" "$(cut -d" " -f1,2 ../dry_key.pub)" > ../dry_signers + ssh-keygen -Y sign -f ../dry_key -n aien-release SHA256SUMS.txt + ../scripts/verify-release-assets.sh . ../dry_signers + rm -f ../dry_key + echo "DRY RUN: signed with a throwaway key generated in this job. Not the AIEN release key. Not a release." > DRY-RUN-NOT-A-RELEASE.txt + + - name: Upload dry-run artifacts (workflow artifacts only, no release) + uses: actions/upload-artifact@v4 + with: + name: dry-run-signed-assets + path: release-artifacts publish-release: name: Publish Release and Checksums needs: build-release + if: github.event_name == 'push' || inputs.dry_run == false runs-on: ubuntu-latest steps: - name: Checkout Source @@ -140,7 +201,7 @@ jobs: printf "%s\n" "$AIEN_RELEASE_SIGNING_KEY" > ../release_key ssh-keygen -Y sign -f ../release_key -n aien-release SHA256SUMS.txt rm -f ../release_key - ssh-keygen -Y verify -f ../docs/release/allowed_signers -I aien-release -n aien-release -s SHA256SUMS.txt.sig < SHA256SUMS.txt + ../scripts/verify-release-assets.sh . ../docs/release/allowed_signers - name: Publish GitHub Release env: diff --git a/docs/release/BUILD_RECIPE.md b/docs/release/BUILD_RECIPE.md new file mode 100644 index 00000000..1016e45b --- /dev/null +++ b/docs/release/BUILD_RECIPE.md @@ -0,0 +1,46 @@ +# Release build recipe and checks + +One recipe builds the release and one script checks it. The workflow, a person reproducing a digest and the +checks all use the same commands. + +## Build + +`scripts/release-build.sh` (needs the pinned toolchain from `rust-toolchain.toml`, `cargo fetch --locked` into the +CARGO_HOME in use, and for the native engine `AIEN_OMEGA_DIR` at `omega.lock` and `AIEN_PHYSICS_DIR` at omega's +`physics.lock`; `AIEN_DEV_FALLBACK` and `AIEN_FORCE_CPU_STUB` unset, no mojo on PATH): + +1. `scripts/repro-build.sh -p spark-cockpit-rs -p spark-inquisitor -p cortex-encoder-rs -p cortex-rs -p spark-supervisor -p spark-debugger` +2. `scripts/repro-build.sh -p aien-cli` + +`repro-build.sh` is `cargo build --release --locked` with `--remap-path-prefix` for CARGO_HOME and the repo root. +Cargo unifies features across all `-p` packages in one command, so a binary's digest depends on its group +(`F1-binary-digest-difference.md`: one seven-package command gives a different aien-cli). Packages are therefore built +in fixed groups and `aien-cli` alone and last. That aien-cli digest equals CAND-3's `aien-cli-native-release` +(F1, build A). The CAND-3 manifest `[build]` line lists `-p aien-cli -p aien-proof -p aien-test` in one command; +whether that group gives the same aien-cli digest as `-p aien-cli` alone is UNVERIFIED here, and the release does not +package aien-proof or aien-test. + +## Package and check + +- `scripts/package-release.sh ` runs the release gate itself and writes the candidate id and `[model]` + table from `release/candidate.toml` into `release.toml`. A failing gate means no package (`AIEN_DRY_RUN=1` only + labels it `NOT-RELEASABLE`, which the checks reject). +- `scripts/check-release-candidate.sh` (tree): candidate named, `omega.lock` equals `omega-commit`, `Cargo.lock` + holds exactly the `[pins]` revisions (aien-protocols, crumb-spec, spark-crumbs), `[model]` complete. +- `scripts/check-release-candidate.sh --package A.tar.gz [--native]`: candidate id, `[model]` table (model id, + safetensors, tokenizer, config, oracle fixture digests), `aien-cli-sha256` equals the digest of `bin/aien`, every + listed file, no unlisted file; with `--native` (linux aarch64, omega linked) the digest must equal + `[executables] aien-cli-native-release`. Other targets build the CPU stub and are not the candidate. +- `scripts/verify-release-assets.sh `: signature on `SHA256SUMS.txt` valid for the pinned + signer, every listed file matches, every `sovereign-*` archive is covered. +- `scripts/test-release-checks.sh` (also in CI) proves each of these rejects: wrong omega.lock or Cargo.lock pins, + executable digest mismatch, model input mismatch, missing, corrupt or foreign signature, tampered files. + +## Release workflow modes + +- Tag push `v*`: build, check, sign with the `AIEN_RELEASE_SIGNING_KEY` secret (job fails if absent), verify against + `docs/release/allowed_signers`, publish. +- Manual run (`workflow_dispatch`): input `dry_run`, default true. Builds, packages, checks, signs with a throwaway key + generated in the job (labelled in `DRY-RUN-NOT-A-RELEASE.txt`), verifies, uploads workflow artifacts only. Gate or + package-check failures are recorded in `DRY-RUN-STATUS-.txt` instead of stopping the run. It never creates a + release. With `dry_run` set to false a manual run publishes like a tag push. diff --git a/release/candidate.toml b/release/candidate.toml index e30c15b8..b980787b 100644 --- a/release/candidate.toml +++ b/release/candidate.toml @@ -17,3 +17,15 @@ geometry = "LlamaForCausalLM: layers 22, hidden 2048, heads 32, kv heads 4, head oracle-fixture-safetensors-sha256 = "4707e3ba5c75f6c953217235528b38b3dffa334f68b8356f7356f9a5f6a6a6ea" oracle-fixture-manifest-sha256 = "d9871e7834513dfff5d453e6915440e4976098a7e84bc75086a3ab7833dcefd9" + +# Source pins the release tree must consume (read from CAND-3 [commits] and [contracts]; checked against +# Cargo.lock by scripts/check-release-candidate.sh). +[pins] +aien-protocols = "7ac6facb630ca7e9a6ab4125b292203fe2bb6687" +crumb-spec = "24194d1b7917ef19244aae6bcaff510686b75fef" +spark-crumbs = "9355a92bc9adfe95a6ec5f8ac926f38a0b6e7db2" + +# Executable digest of the packaged aien (native engine linked, linux aarch64 only), CAND-3 [executables]. +# Built by scripts/release-build.sh; checked by scripts/check-release-candidate.sh --package --native. +[executables] +aien-cli-native-release = "3a17ee79a238ad223fd59f4436d98906a0144b8d5ac47809da194a9ac1d493db" diff --git a/scripts/.crumb b/scripts/.crumb index 556bf4a2..de647e08 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -4,14 +4,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-06T14:54:01Z", + "compiled_at": "2026-10-06T18:59:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:8adb9b86301dab19b5d674d5ef0eba0936f76f15eeccbfa88cdfd5d11adddac0", + "digest": "sha256:7e21bed3084195dacdd52d79c7d4c7c95837b474fd35b74dd087e6067bdeb58c", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 17, - "generated_at_commit": "ce3ef865cee16800c9e96d15534154a0bc443912", - "source_tree": "sha256:fad41b8709964e1f5e3d59f536be71c5c166d32000c8d61d1c8072cbbbf24f64" + "files": 20, + "generated_at_commit": "18737034e52a286e9e31675cdc6711fd6e564d10", + "source_tree": "sha256:ef8b0a729763826370f05efde41418ebea6d056b2260e07aa6114a569d87990d" } }, "parent": { diff --git a/scripts/check-release-candidate.sh b/scripts/check-release-candidate.sh index b2fe7b67..926fe63a 100755 --- a/scripts/check-release-candidate.sh +++ b/scripts/check-release-candidate.sh @@ -1,18 +1,88 @@ #!/usr/bin/env bash -# Fail closed unless this tree may be released as the candidate named in release/candidate.toml. -# scripts/check-release-candidate.sh check; prints "candidate=" on success -# scripts/check-release-candidate.sh --model F also write the [model] table to file F -# Checks: candidate is set and is not "unknown"; omega.lock equals omega-commit. +# Fail closed unless this tree (or a built package) may be released as the candidate in release/candidate.toml. +# scripts/check-release-candidate.sh tree check; prints "candidate=" on success +# scripts/check-release-candidate.sh --model F also write the [model] table to file F +# scripts/check-release-candidate.sh --package A.tar.gz [--native] +# also check a built package (see below) +# Tree checks: candidate is set and not "unknown"; omega.lock equals omega-commit; Cargo.lock holds exactly the +# [pins] revisions (aien-protocols, crumb-spec, spark-crumbs); the [model] table is complete (every digest is 64 hex). +# Package checks: release.toml names this candidate; its [model] table equals the candidate's (model id, safetensors, +# tokenizer, config, fixture digests); aien-cli-sha256 equals the sha256 of bin/aien in the archive; every [files] +# entry matches; with --native (the linux-aarch64 build that links the omega engine) aien-cli-sha256 must also equal +# [executables] aien-cli-native-release. Build recipe: docs/release/BUILD_RECIPE.md. +# Env: AIEN_CANDIDATE_ROOT overrides the tree root (tests). set -euo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")/.." +cd "${AIEN_CANDIDATE_ROOT:-$(dirname "${BASH_SOURCE[0]}")/..}" M=release/candidate.toml -[[ -f "$M" ]] || { echo "release gate: $M is missing" >&2; exit 1; } -get() { sed -n "s/^$1 *= *\"\(.*\)\"\$/\1/p" "$M" | head -1; } -cand="$(get candidate)"; omega="$(get omega-commit)" -[[ -n "$cand" && "$cand" != unknown ]] || { echo "release gate: candidate in $M is missing or 'unknown'" >&2; exit 1; } -[[ "$omega" =~ ^[0-9a-f]{40}$ ]] || { echo "release gate: omega-commit in $M is not a full commit hash" >&2; exit 1; } +die() { echo "release gate: $*" >&2; exit 1; } +[[ -f "$M" ]] || die "$M is missing" +MODEL_OUT=""; PKG=""; NATIVE=0 +while [[ $# -gt 0 ]]; do + case "$1" in + --model) MODEL_OUT="${2:?--model needs a file}"; shift 2 ;; + --package) PKG="${2:?--package needs an archive}"; shift 2 ;; + --native) NATIVE=1; shift ;; + *) die "unknown argument $1" ;; + esac +done +sha() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi; } +# get
: value of key = "value" inside [section] ("" = before the first section) +get() { awk -v s="$1" -v k="$2" ' + /^\[/ { cur=$0; gsub(/[\[\] \t]/,"",cur); next } + cur==s && match($0, "^" k "[ \t]*=[ \t]*\"") { v=substr($0,RLENGTH+1); sub(/"[ \t]*(#.*)?$/,"",v); print v; exit }' "$3"; } +model_table() { awk '/^\[/ { inm = ($0 ~ /^\[model\]/); next } inm && NF && $0 !~ /^#/ { print }' "$1" | sort; } + +cand="$(get "" candidate "$M")"; omega="$(get "" omega-commit "$M")" +[[ -n "$cand" && "$cand" != unknown ]] || die "candidate in $M is missing or 'unknown'" +[[ "$omega" =~ ^[0-9a-f]{40}$ ]] || die "omega-commit in $M is not a full commit hash" +[[ -f omega.lock ]] || die "omega.lock is missing" lock="$(tr -d '[:space:]' < omega.lock)" -[[ "$lock" == "$omega" ]] || { echo "release gate: omega.lock is $lock but candidate $cand names omega $omega. This tree is not $cand and cannot be released as it." >&2; exit 1; } -grep -q '^\[model\]' "$M" || { echo "release gate: no [model] table in $M" >&2; exit 1; } -if [[ "${1:-}" == --model ]]; then sed -n '/^\[model\]/,$p' "$M" | sed '/^$/q' > "${2:?file}"; fi +[[ "$lock" == "$omega" ]] || die "omega.lock is $lock but candidate $cand names omega $omega. This tree is not $cand and cannot be released as it." +grep -q '^\[model\]' "$M" || die "no [model] table in $M" +for k in model-id model-safetensors-sha256 tokenizer-json-sha256 config-json-sha256 oracle-fixture-safetensors-sha256 oracle-fixture-manifest-sha256; do + v="$(get model "$k" "$M")"; [[ -n "$v" ]] || die "[model] $k is missing in $M" + [[ "$k" == model-id || "$v" =~ ^[0-9a-f]{64}$ ]] || die "[model] $k in $M is not a sha256" +done + +# Cargo.lock source pins: each repo must resolve to exactly the candidate's revision. +[[ -f Cargo.lock ]] || die "Cargo.lock is missing" +for repo in aien-protocols crumb-spec spark-crumbs; do + want="$(get pins "$repo" "$M")" + [[ "$want" =~ ^[0-9a-f]{40}$ ]] || die "[pins] $repo in $M is missing or not a full commit hash" + have="$(grep -E "^source = \"git\+https://github\.com/aien-dev/$repo(\.git)?[?#]" Cargo.lock | grep -oE '#[0-9a-f]{40}"' | cut -c2-41 | sort -u || true)" + [[ -n "$have" ]] || die "Cargo.lock has no git source for $repo (candidate $cand pins $want)" + [[ "$(printf '%s\n' "$have" | wc -l)" -eq 1 ]] || die "Cargo.lock has several revisions of $repo: $(echo $have)" + [[ "$have" == "$want" ]] || die "Cargo.lock consumes $repo $have but candidate $cand pins $want" +done + +if [[ -n "$MODEL_OUT" ]]; then sed -n '/^\[model\]/,$p' "$M" | sed '/^$/q' > "$MODEL_OUT"; fi + +if [[ -n "$PKG" ]]; then + [[ -f "$PKG" ]] || die "package $PKG not found" + X="$(mktemp -d)"; trap 'rm -rf "$X"' EXIT + tar -xzf "$PKG" -C "$X" || die "package $PKG is not a readable archive" + R="$X/release.toml"; [[ -f "$R" ]] || die "package has no release.toml" + [[ "$(get "" schema "$R")" == AienReleaseV1 ]] || die "package release.toml schema is not AienReleaseV1" + [[ "$(get "" candidate "$R")" == "$cand" ]] || die "package names candidate '$(get "" candidate "$R")', not $cand" + [[ -z "$(get model model-id "$R")" ]] && die "package release.toml has no [model] table" + [[ "$(model_table "$R")" == "$(model_table "$M")" ]] || die "package [model] table differs from the candidate's (model id or input digests)" + want_aien="$(get "" aien-cli-sha256 "$R")" + [[ "$want_aien" =~ ^[0-9a-f]{64}$ ]] || die "package aien-cli-sha256 is missing or not a sha256" + [[ -f "$X/bin/aien" && "$(sha "$X/bin/aien")" == "$want_aien" ]] || die "package aien-cli-sha256 is not the digest of bin/aien" + n=0 + while IFS= read -r line; do + [[ "$line" =~ ^\"([^\"]+)\"[[:space:]]*=[[:space:]]*\"([0-9a-f]{64})\"$ ]] || die "bad [files] line: $line" + f="${BASH_REMATCH[1]}"; case "$f" in /*|*..*) die "unsafe path in release.toml: $f" ;; esac + [[ -f "$X/$f" && "$(sha "$X/$f")" == "${BASH_REMATCH[2]}" ]] || die "package file $f does not match release.toml" + n=$((n+1)) + done < <(sed -n '/^\[files\]/,$p' "$R" | sed '1d;/^$/d') + [[ "$n" -gt 0 ]] || die "release.toml lists no files" + have_n="$(find "$X" -type f ! -name release.toml | grep -c .)" + [[ "$have_n" -eq "$n" ]] || die "package holds $have_n files but release.toml lists $n" + if [[ "$NATIVE" -eq 1 ]]; then + exe="$(get executables aien-cli-native-release "$M")" + [[ "$exe" =~ ^[0-9a-f]{64}$ ]] || die "[executables] aien-cli-native-release missing in $M" + [[ "$want_aien" == "$exe" ]] || die "aien-cli digest $want_aien is not $cand's aien-cli-native-release $exe (build with scripts/release-build.sh, see docs/release/BUILD_RECIPE.md)" + fi +fi echo "candidate=$cand" diff --git a/scripts/package-release.sh b/scripts/package-release.sh index 96f8e90d..430e07af 100755 --- a/scripts/package-release.sh +++ b/scripts/package-release.sh @@ -4,8 +4,8 @@ # scripts/package-release.sh # # 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 +# AIEN_DRY_RUN=1 package even when the release gate fails (candidate "NOT-RELEASABLE"); never for a release +# AIEN_RELEASE_BIN_DIR directory holding the built binaries (default target/release) # SOURCE_DATE_EPOCH mtime for every entry (default 0) # # The archive carries release.toml: schema, candidate id, the sha256 of the packaged aien-cli, @@ -16,20 +16,32 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." ARTIFACT="${1:?provide output archive path}" -CANDIDATE="${AIEN_CANDIDATE_ID:-unknown}" +BIN_DIR="${AIEN_RELEASE_BIN_DIR:-target/release}" +# The candidate id and model table come from the release gate, never from the caller. A tree that fails the +# gate is not packaged, except with AIEN_DRY_RUN=1, which labels the package NOT-RELEASABLE (it then fails +# check-release-candidate.sh --package and cannot be installed as a candidate). +GATE_MODEL="$(mktemp)" +if CANDIDATE="$(bash scripts/check-release-candidate.sh --model "$GATE_MODEL" | sed -n 's/^candidate=//p')" && [[ -n "$CANDIDATE" ]]; then + AIEN_MODEL_INPUTS="$GATE_MODEL" +elif [[ "${AIEN_DRY_RUN:-}" == 1 ]]; then + echo "WARNING: release gate failed; dry run packages this tree as NOT-RELEASABLE" >&2 + CANDIDATE="NOT-RELEASABLE"; AIEN_MODEL_INPUTS="" +else + echo "release gate failed; refusing to package" >&2; exit 1 +fi 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 +trap 'rm -rf "$PACKAGE_DIR" "$GATE_MODEL"' EXIT mkdir -p "$PACKAGE_DIR/bin" for binary in aien-cli spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger; do - [[ -x "target/release/$binary" ]] || { echo "Missing release binary: $binary" >&2; exit 1; } + [[ -x "$BIN_DIR/$binary" ]] || { echo "Missing release binary: $binary" >&2; exit 1; } name="$binary" [[ "$binary" != aien-cli ]] || name=aien - cp "target/release/$binary" "$PACKAGE_DIR/bin/$name" + cp "$BIN_DIR/$binary" "$PACKAGE_DIR/bin/$name" done cp CONSTITUTION.md README.md install.sh "$PACKAGE_DIR/" if [[ -d imprints/en2-trinity ]]; then diff --git a/scripts/release-build.sh b/scripts/release-build.sh new file mode 100755 index 00000000..c8ad5151 --- /dev/null +++ b/scripts/release-build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# The one release build recipe (the CAND-3 [build] recipe, per package). Used by .github/workflows/release.yml +# and the thing to run by hand to reproduce a candidate digest. See docs/release/BUILD_RECIPE.md. +# scripts/release-build.sh [extra cargo args, e.g. --offline] +# Needs a pinned toolchain (rust-toolchain.toml), `cargo fetch --locked` done into the CARGO_HOME in use, +# and for the native engine AIEN_OMEGA_DIR and AIEN_PHYSICS_DIR at omega.lock / omega's physics.lock. +# Cargo unifies features across every -p in one command, so a digest depends on the group it was built in +# (docs/release/F1-binary-digest-difference.md). The groups are therefore fixed: the packaged helpers as one +# group first, then aien-cli alone and last, each through scripts/repro-build.sh (--locked, path remap). +set -euo pipefail +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +"$here/repro-build.sh" -p spark-cockpit-rs -p spark-inquisitor -p cortex-encoder-rs -p cortex-rs -p spark-supervisor -p spark-debugger "$@" +"$here/repro-build.sh" -p aien-cli "$@" diff --git a/scripts/test-install-release.sh b/scripts/test-install-release.sh index 1b69e9e5..f94a408b 100755 --- a/scripts/test-install-release.sh +++ b/scripts/test-install-release.sh @@ -221,7 +221,7 @@ grep -q "was not overwritten" "$WORK/log" || fail "incomplete release directory # 13. release gate: the candidate must be named and omega.lock must be the candidate's omega commit GT="$WORK/gate"; mkdir -p "$GT/scripts" "$GT/release" -cp "$ROOT/scripts/check-release-candidate.sh" "$GT/scripts/"; cp "$ROOT/release/candidate.toml" "$GT/release/" +cp "$ROOT/scripts/check-release-candidate.sh" "$GT/scripts/"; cp "$ROOT/release/candidate.toml" "$GT/release/"; cp "$ROOT/Cargo.lock" "$GT/" gate() { (cd "$GT" && bash scripts/check-release-candidate.sh "$@" > "$WORK/log-gate" 2>&1); } OM="$(sed -n 's/^omega-commit *= *"\(.*\)"$/\1/p' "$GT/release/candidate.toml")" echo "$OM" > "$GT/omega.lock" diff --git a/scripts/test-release-checks.sh b/scripts/test-release-checks.sh new file mode 100755 index 00000000..5008aad4 --- /dev/null +++ b/scripts/test-release-checks.sh @@ -0,0 +1,132 @@ +#!/usr/bin/env bash +# Negative and positive tests for the release gate (check-release-candidate.sh, package-release.sh, +# verify-release-assets.sh). Runs offline in a throwaway fixture tree; no cargo, no network. +# scripts/test-release-checks.sh +set -euo pipefail +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +W="$(mktemp -d "${TMPDIR:-/tmp}/aien-test-release-checks.XXXXXX")" +trap 'rm -rf "$W"' EXIT +fail() { echo "FAIL: $*" >&2; exit 1; } +pass() { echo "ok: $*"; } + +# fixture tree +T="$W/tree"; mkdir -p "$T/scripts" "$T/release" "$W/bins" +cp "$ROOT/scripts/check-release-candidate.sh" "$ROOT/scripts/package-release.sh" "$ROOT/scripts/verify-release-assets.sh" "$T/scripts/" +echo constitution > "$T/CONSTITUTION.md"; echo readme > "$T/README.md"; echo '#!/bin/sh' > "$T/install.sh" +OM=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +PR=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; CS=cccccccccccccccccccccccccccccccccccccccc; SC=dddddddddddddddddddddddddddddddddddddddd +H64() { printf '%064d' "$1"; } +for b in aien-cli spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger; do + printf '#!/bin/sh\necho %s\n' "$b" > "$W/bins/$b"; chmod 755 "$W/bins/$b" +done +AIEN_DIGEST="$(sha256sum "$W/bins/aien-cli" | cut -d' ' -f1)" +write_candidate() { # aien-digest + cat > "$T/release/candidate.toml" < "$T/omega.lock" + { + echo "[[package]]"; echo "source = \"git+https://github.com/aien-dev/aien-protocols?rev=$PR#$PR\"" + echo "[[package]]"; echo "source = \"git+https://github.com/aien-dev/crumb-spec?rev=$CS#$CS\"" + echo "[[package]]"; echo "source = \"git+https://github.com/aien-dev/spark-crumbs?rev=$SC#$SC\"" + } > "$T/Cargo.lock" +} +gate() { (cd "$T" && bash scripts/check-release-candidate.sh "$@" > "$W/log" 2>&1); } +must_pass() { gate "$@" || { cat "$W/log" >&2; fail "gate refused: $*"; }; } +must_fail() { # expected-text args... + local want="$1"; shift + if gate "$@"; then fail "gate accepted ($want)"; fi + grep -q -- "$want" "$W/log" || { cat "$W/log" >&2; fail "refused for the wrong reason, wanted: $want"; } +} +write_candidate "$AIEN_DIGEST"; write_locks +must_pass; pass "matching tree accepted" + +# source pins +echo "$(H64 9 | cut -c1-40)" > "$T/omega.lock"; must_fail "omega.lock is"; write_locks; pass "omega.lock mismatch rejected" +sed -i "s/crumb-spec?rev=$CS#$CS/crumb-spec?rev=$SC#$SC/" "$T/Cargo.lock"; must_fail "consumes crumb-spec"; write_locks; pass "Cargo.lock crumb-spec mismatch rejected" +sed -i "s/aien-protocols?rev=$PR#$PR/aien-protocols?rev=$CS#$CS/" "$T/Cargo.lock"; must_fail "consumes aien-protocols"; write_locks; pass "Cargo.lock aien-protocols mismatch rejected" +echo "source = \"git+https://github.com/aien-dev/spark-crumbs?rev=$PR#$PR\"" >> "$T/Cargo.lock"; must_fail "several revisions of spark-crumbs"; write_locks; pass "two revisions of one pin rejected" +grep -v spark-crumbs "$T/Cargo.lock" > "$W/cl" && mv "$W/cl" "$T/Cargo.lock"; must_fail "no git source for spark-crumbs"; write_locks; pass "missing Cargo.lock pin rejected" + +# candidate file +cp "$T/release/candidate.toml" "$W/cand.ok" +sed -i 's/^candidate = .*/candidate = "unknown"/' "$T/release/candidate.toml"; must_fail "missing or 'unknown'"; cp "$W/cand.ok" "$T/release/candidate.toml"; pass "candidate unknown rejected" +sed -i '/^config-json-sha256/d' "$T/release/candidate.toml"; must_fail "config-json-sha256 is missing"; cp "$W/cand.ok" "$T/release/candidate.toml"; pass "incomplete [model] rejected" +sed -i 's/^tokenizer-json-sha256 = .*/tokenizer-json-sha256 = "xyz"/' "$T/release/candidate.toml"; must_fail "not a sha256"; cp "$W/cand.ok" "$T/release/candidate.toml"; pass "malformed model digest rejected" + +# package: build one with the real packager +pkg() { (cd "$T" && AIEN_RELEASE_BIN_DIR="$W/bins" bash scripts/package-release.sh "$1" > "$W/plog" 2>&1) || { cat "$W/plog" >&2; fail "package-release failed"; }; } +pkg "$W/good.tar.gz" +must_pass --package "$W/good.tar.gz" --native; pass "good package accepted (native digest matches)" +# the packager refuses a tree that fails the gate, and labels a dry run +echo 0000000000000000000000000000000000000000 > "$T/omega.lock" +if (cd "$T" && AIEN_RELEASE_BIN_DIR="$W/bins" bash scripts/package-release.sh "$W/x.tar.gz" >/dev/null 2>&1); then fail "packager packaged a tree that fails the gate"; fi +(cd "$T" && AIEN_DRY_RUN=1 AIEN_RELEASE_BIN_DIR="$W/bins" bash scripts/package-release.sh "$W/dry.tar.gz" >/dev/null 2>&1) || fail "dry-run packaging failed" +write_locks +must_fail "names candidate 'NOT-RELEASABLE'" --package "$W/dry.tar.gz"; pass "dry-run package is not a releasable package" + +# executable digest mismatch: a different aien binary against the candidate's pinned digest +mkdir "$W/bins2"; cp "$W/bins/"* "$W/bins2/"; printf '#!/bin/sh\necho other build\n' > "$W/bins2/aien-cli" +(cd "$T" && AIEN_RELEASE_BIN_DIR="$W/bins2" bash scripts/package-release.sh "$W/otherbin.tar.gz" >/dev/null 2>&1) +must_fail "is not CAND-T's aien-cli-native-release" --package "$W/otherbin.tar.gz" --native; pass "executable digest mismatch rejected (--native)" +must_pass --package "$W/otherbin.tar.gz"; pass "same package accepted without --native (non-native targets are not the candidate)" + +# repack helper: edit a package then re-tar +repack() { # src dst edit-command (run inside the unpacked dir) + rm -rf "$W/u"; mkdir "$W/u"; tar -xzf "$1" -C "$W/u"; (cd "$W/u" && eval "$3"); tar -czf "$2" -C "$W/u" . +} +# release.toml lies about aien-cli digest +repack "$W/good.tar.gz" "$W/lie.tar.gz" "sed -i 's/^aien-cli-sha256 = .*/aien-cli-sha256 = \"$(H64 7)\"/' release.toml" +must_fail "not the digest of bin/aien" --package "$W/lie.tar.gz" --native; pass "release.toml digest that is not bin/aien rejected" +# model input mismatch in the package +for key in model-id model-safetensors-sha256 tokenizer-json-sha256 config-json-sha256; do + repack "$W/good.tar.gz" "$W/m.tar.gz" "sed -i 's/^$key = \"[^\"]*\"/$key = \"$(H64 8)\"/' release.toml" + must_fail "package \[model\] table differs" --package "$W/m.tar.gz" --native; pass "package $key mismatch rejected" +done +repack "$W/good.tar.gz" "$W/nomodel.tar.gz" "sed -i '/^\[model\]/,/^\$/d' release.toml" +must_fail "no \[model\] table" --package "$W/nomodel.tar.gz"; pass "package without [model] rejected" +# a file changed after packaging +repack "$W/good.tar.gz" "$W/edit.tar.gz" "echo x >> bin/cortex-rs" +must_fail "does not match release.toml" --package "$W/edit.tar.gz"; pass "tampered package file rejected" +repack "$W/good.tar.gz" "$W/extra.tar.gz" "echo x > bin/extra" +must_fail "holds" --package "$W/extra.tar.gz"; pass "unlisted extra file rejected" + +# signatures +ssh-keygen -q -t ed25519 -N '' -C t -f "$W/key"; ssh-keygen -q -t ed25519 -N '' -C o -f "$W/other" +printf 'aien-release %s\n' "$(cut -d' ' -f1,2 "$W/key.pub")" > "$W/signers" +assets() { rm -rf "$W/a"; mkdir "$W/a"; cp "$W/good.tar.gz" "$W/a/sovereign-linux-aarch64.tar.gz"; (cd "$W/a" && sha256sum sovereign-* > SHA256SUMS.txt); } +sign() { (cd "$W/a" && rm -f SHA256SUMS.txt.sig && ssh-keygen -q -Y sign -f "$1" -n aien-release SHA256SUMS.txt); } +verify() { bash "$ROOT/scripts/verify-release-assets.sh" "$W/a" "$W/signers" > "$W/log" 2>&1; } +vfail() { if verify; then fail "assets accepted ($1)"; fi; grep -q -- "$1" "$W/log" || { cat "$W/log" >&2; fail "wrong reason, wanted: $1"; }; } +assets; sign "$W/key"; verify || { cat "$W/log" >&2; fail "valid signed assets refused"; }; pass "valid signed assets accepted" +assets; vfail "SHA256SUMS.txt.sig is missing"; pass "missing signature rejected" +assets; sign "$W/other"; vfail "NOT valid"; pass "signature from another key rejected" +assets; sign "$W/key"; echo "garbage" > "$W/a/SHA256SUMS.txt.sig"; vfail "NOT valid"; pass "corrupt signature rejected" +assets; sign "$W/key"; echo tamper >> "$W/a/SHA256SUMS.txt"; vfail "NOT valid"; pass "edited checksum list rejected" +assets; sign "$W/key"; echo x >> "$W/a/sovereign-linux-aarch64.tar.gz"; vfail "does not match the signed checksum"; pass "tampered archive rejected" +assets; (cd "$W/a" && cp sovereign-linux-aarch64.tar.gz sovereign-macos-arm64.tar.gz); sign "$W/key"; vfail "not covered"; pass "archive missing from signed list rejected" +assets; : > "$W/empty"; if bash "$ROOT/scripts/verify-release-assets.sh" "$W/a" "$W/empty" >/dev/null 2>&1; then fail "empty signer file accepted"; fi; pass "empty signer file rejected" +# the production signer file is a real, non-empty key line +grep -q '^aien-release ssh-ed25519 ' "$ROOT/docs/release/allowed_signers" || fail "docs/release/allowed_signers has no aien-release key" +echo "PASS: release gate rejects inconsistent source pins, executable digest and model input mismatches, missing or invalid signatures" diff --git a/scripts/verify-release-assets.sh b/scripts/verify-release-assets.sh new file mode 100755 index 00000000..a8907f1f --- /dev/null +++ b/scripts/verify-release-assets.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Verify a release asset directory: SHA256SUMS.txt exists, carries a valid signature from the allowed +# signer, lists every sovereign-* archive, and every listed file matches its digest. +# scripts/verify-release-assets.sh +# Fails (exit 1) on a missing or invalid signature, a signer not in the file, a listed file that is missing +# or differs, and an archive that the signed list does not cover. +set -euo pipefail +d="${1:?asset directory}"; signers="${2:?allowed_signers file}" +die() { echo "release assets: $*" >&2; exit 1; } +[[ -f "$d/SHA256SUMS.txt" ]] || die "SHA256SUMS.txt is missing" +[[ -f "$d/SHA256SUMS.txt.sig" ]] || die "SHA256SUMS.txt.sig is missing: refusing an unsigned release" +[[ -s "$signers" ]] || die "allowed signers file $signers is missing or empty" +ssh-keygen -Y verify -f "$signers" -I aien-release -n aien-release -s "$d/SHA256SUMS.txt.sig" < "$d/SHA256SUMS.txt" >/dev/null 2>&1 \ + || die "SHA256SUMS.txt signature is NOT valid for $signers" +n=0 +while read -r want name; do + name="${name#\*}"; [[ -n "$name" ]] || continue + [[ -f "$d/$name" ]] || die "listed file $name is missing" + have="$(cd "$d" && { sha256sum "$name" 2>/dev/null || shasum -a 256 "$name"; } | cut -d' ' -f1)" + [[ "$have" == "$want" ]] || die "$name does not match the signed checksum" + n=$((n+1)) +done < "$d/SHA256SUMS.txt" +[[ "$n" -gt 0 ]] || die "SHA256SUMS.txt lists nothing" +for a in "$d"/sovereign-*; do + [[ -e "$a" ]] || continue + grep -qE "^[0-9a-f]{64} \*?$(basename "$a")\$" "$d/SHA256SUMS.txt" || die "$(basename "$a") is not covered by the signed checksums" +done +echo "release assets verified ($n files)" ```