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

branch main Branches Tags History

aien-sovereign-core-mv / scripts / test-release-checks.sh

170 lines · 12017 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Negative and positive tests for the release gate (check-release-candidate.sh, package-release.sh,
18# verify-release-assets.sh). Runs offline in a throwaway fixture tree; no cargo, no network.
19# scripts/test-release-checks.sh
20set -euo pipefail
21ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
22W="$(mktemp -d "${TMPDIR:-/tmp}/aien-test-release-checks.XXXXXX")"
23trap 'rm -rf "$W"' EXIT
24fail() { echo "FAIL: $*" >&2; exit 1; }
25pass() { echo "ok: $*"; }
26
27# fixture tree
28T="$W/tree"; mkdir -p "$T/scripts" "$T/release" "$W/bins"
29cp "$ROOT/scripts/check-release-candidate.sh" "$ROOT/scripts/package-release.sh" "$ROOT/scripts/verify-release-assets.sh" "$T/scripts/"
30echo licence > "$T/LICENSE"; echo notice > "$T/NOTICE"; echo third > "$T/THIRD_PARTY.md"; echo constitution > "$T/CONSTITUTION.md"; echo readme > "$T/README.md"; echo '#!/bin/sh' > "$T/install.sh"
31OM=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
32PR=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; CS=cccccccccccccccccccccccccccccccccccccccc; SC=dddddddddddddddddddddddddddddddddddddddd
33H64() { printf '%064d' "$1"; }
34for b in aien-cli spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger; do
35 printf '#!/bin/sh\necho %s\n' "$b" > "$W/bins/$b"; chmod 755 "$W/bins/$b"
36done
37AIEN_DIGEST="$(sha256sum "$W/bins/aien-cli" | cut -d' ' -f1)"
38write_candidate() { # aien-digest
39 cat > "$T/release/candidate.toml" <<EOT
40candidate = "CAND-T"
41omega-commit = "$OM"
42source-manifest = "fixture"
43
44[model]
45model-id = "Fixture/Model"
46format = "safetensors"
47model-safetensors-sha256 = "$(H64 1)"
48tokenizer-json-sha256 = "$(H64 2)"
49config-json-sha256 = "$(H64 3)"
50oracle-fixture-safetensors-sha256 = "$(H64 4)"
51oracle-fixture-manifest-sha256 = "$(H64 5)"
52
53[pins]
54aien-protocols = "$PR"
55crumb-spec = "$CS"
56spark-crumbs = "$SC"
57
58[executables]
59aien-cli-native-release = "$1"
60$(for b in spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger; do echo "sc-$b = \"$(sha256sum "$W/bins/$b" | cut -d" " -f1)\""; done)
61EOT
62}
63write_locks() {
64 echo "$OM" > "$T/omega.lock"
65 {
66 echo "[[package]]"; echo "source = \"git+https://github.com/aien-dev/aien-protocols?rev=$PR#$PR\""
67 echo "[[package]]"; echo "source = \"git+https://github.com/aien-dev/crumb-spec?rev=$CS#$CS\""
68 echo "[[package]]"; echo "source = \"git+https://github.com/aien-dev/spark-crumbs?rev=$SC#$SC\""
69 } > "$T/Cargo.lock"
70}
71gate() { (cd "$T" && bash scripts/check-release-candidate.sh "$@" > "$W/log" 2>&1); }
72must_pass() { gate "$@" || { cat "$W/log" >&2; fail "gate refused: $*"; }; }
73must_fail() { # expected-text args...
74 local want="$1"; shift
75 if gate "$@"; then fail "gate accepted ($want)"; fi
76 grep -q -- "$want" "$W/log" || { cat "$W/log" >&2; fail "refused for the wrong reason, wanted: $want"; }
77}
78write_candidate "$AIEN_DIGEST"; write_locks
79must_pass; pass "matching tree accepted"
80sed -i \
81 -e "s|github.com/aien-dev/crumb-spec?|github.com/aien-dev/crumb-spec-mv?|" \
82 -e "s|github.com/aien-dev/spark-crumbs?|github.com/aien-dev/spark-crumbs-mv?|" \
83 "$T/Cargo.lock"
84must_pass; pass "-mv repo URLs accepted at the pinned revisions"
85write_locks
86
87# source pins
88echo "$(H64 9 | cut -c1-40)" > "$T/omega.lock"; must_fail "omega.lock is"; write_locks; pass "omega.lock mismatch rejected"
89sed -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"
90sed -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"
91echo "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"
92grep -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"
93
94# candidate file
95cp "$T/release/candidate.toml" "$W/cand.ok"
96sed -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"
97sed -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"
98sed -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"
99
100# package: build one with the real packager
101pkg() { (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"; }; }
102pkg "$W/good.tar.gz"
103must_pass --package "$W/good.tar.gz" --native; pass "good package accepted (native digest matches)"
104# the packager refuses a tree that fails the gate, and labels a dry run
105echo 0000000000000000000000000000000000000000 > "$T/omega.lock"
106if (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
107(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"
108write_locks
109must_fail "names candidate 'NOT-RELEASABLE'" --package "$W/dry.tar.gz"; pass "dry-run package is not a releasable package"
110tar -xzOf "$W/dry.tar.gz" ./release.toml | grep -qx 'dry-run = true' || fail "dry-run package manifest is not labelled dry-run"
111! tar -xzOf "$W/good.tar.gz" ./release.toml | grep -q '^dry-run' || fail "release package manifest carries a dry-run label"
112pass "dry-run package manifest labelled dry-run = true; release package is not"
113
114# executable digest mismatch: a different aien binary against the candidate's pinned digest
115mkdir "$W/bins2"; cp "$W/bins/"* "$W/bins2/"; printf '#!/bin/sh\necho other build\n' > "$W/bins2/aien-cli"
116(cd "$T" && AIEN_RELEASE_BIN_DIR="$W/bins2" bash scripts/package-release.sh "$W/otherbin.tar.gz" >/dev/null 2>&1)
117must_fail "is not CAND-T's aien-cli-native-release" --package "$W/otherbin.tar.gz" --native; pass "executable digest mismatch rejected (--native)"
118must_fail "no candidate digest for this package kind" --package "$W/otherbin.tar.gz"; pass "package without --native refused (no candidate digest for the kind)"
119must_fail "no candidate digest for this package kind" --package "$W/good.tar.gz"; pass "even a matching package is refused without --native"
120# a helper binary changed after the candidate: its sc-<name> digest differs
121mkdir "$W/bins3"; cp "$W/bins/"* "$W/bins3/"; printf "#!/bin/sh\necho other cortex\n" > "$W/bins3/cortex-rs"
122(cd "$T" && AIEN_RELEASE_BIN_DIR="$W/bins3" bash scripts/package-release.sh "$W/otherhelper.tar.gz" >/dev/null 2>&1)
123must_fail "is not CAND-T's sc-cortex-rs" --package "$W/otherhelper.tar.gz" --native; pass "helper binary digest mismatch rejected"
124
125# repack helper: edit a package then re-tar
126repack() { # src dst edit-command (run inside the unpacked dir)
127 rm -rf "$W/u"; mkdir "$W/u"; tar -xzf "$1" -C "$W/u"; (cd "$W/u" && eval "$3"); tar -czf "$2" -C "$W/u" .
128}
129# release.toml lies about aien-cli digest
130repack "$W/good.tar.gz" "$W/lie.tar.gz" "sed -i 's/^aien-cli-sha256 = .*/aien-cli-sha256 = \"$(H64 7)\"/' release.toml"
131must_fail "not the digest of bin/aien" --package "$W/lie.tar.gz" --native; pass "release.toml digest that is not bin/aien rejected"
132# model input mismatch in the package
133for key in model-id model-safetensors-sha256 tokenizer-json-sha256 config-json-sha256; do
134 repack "$W/good.tar.gz" "$W/m.tar.gz" "sed -i 's/^$key = \"[^\"]*\"/$key = \"$(H64 8)\"/' release.toml"
135 must_fail "package \[model\] table differs" --package "$W/m.tar.gz" --native; pass "package $key mismatch rejected"
136done
137repack "$W/good.tar.gz" "$W/nomodel.tar.gz" "sed -i '/^\[model\]/,/^\$/d' release.toml"
138must_fail "no \[model\] table" --package "$W/nomodel.tar.gz"; pass "package without [model] rejected"
139# a file changed after packaging
140repack "$W/good.tar.gz" "$W/edit.tar.gz" "echo x >> bin/cortex-rs"
141must_fail "does not match release.toml" --package "$W/edit.tar.gz"; pass "tampered package file rejected"
142repack "$W/good.tar.gz" "$W/extra.tar.gz" "echo x > bin/extra"
143must_fail "holds" --package "$W/extra.tar.gz"; pass "unlisted extra file rejected"
144
145# signatures
146ssh-keygen -q -t ed25519 -N '' -C t -f "$W/key"; ssh-keygen -q -t ed25519 -N '' -C o -f "$W/other"
147printf 'aien-release %s\n' "$(cut -d' ' -f1,2 "$W/key.pub")" > "$W/signers"
148assets() { 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); }
149sign() { (cd "$W/a" && rm -f SHA256SUMS.txt.sig && ssh-keygen -q -Y sign -f "$1" -n aien-release SHA256SUMS.txt); }
150verify() { bash "$ROOT/scripts/verify-release-assets.sh" "$W/a" "$W/signers" > "$W/log" 2>&1; }
151vfail() { if verify; then fail "assets accepted ($1)"; fi; grep -q -- "$1" "$W/log" || { cat "$W/log" >&2; fail "wrong reason, wanted: $1"; }; }
152assets; sign "$W/key"; verify || { cat "$W/log" >&2; fail "valid signed assets refused"; }; pass "valid signed assets accepted"
153assets; vfail "SHA256SUMS.txt.sig is missing"; pass "missing signature rejected"
154assets; sign "$W/other"; vfail "NOT valid"; pass "signature from another key rejected"
155assets; sign "$W/key"; echo "garbage" > "$W/a/SHA256SUMS.txt.sig"; vfail "NOT valid"; pass "corrupt signature rejected"
156assets; sign "$W/key"; echo tamper >> "$W/a/SHA256SUMS.txt"; vfail "NOT valid"; pass "edited checksum list rejected"
157assets; sign "$W/key"; echo x >> "$W/a/sovereign-linux-aarch64.tar.gz"; vfail "does not match the signed checksum"; pass "tampered archive rejected"
158assets; (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"
159assets; : > "$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"
160# the production signer file holds exactly one aien-release key, or (until the key ceremony) only a labelled
161# PLACEHOLDER that verify-release-assets.sh refuses by name; the internal test key is never in it
162PROD="$ROOT/docs/release/allowed_signers"; KEYS="$(grep -cvE '^[[:space:]]*(#|$)' "$PROD" || true)"
163if [[ "$KEYS" -eq 0 ]]; then
164 grep -q PLACEHOLDER "$PROD" || fail "allowed_signers has no key and no PLACEHOLDER label"
165 assets; sign "$W/key"; cp "$PROD" "$W/signers"; vfail "PLACEHOLDER"; pass "placeholder allowed_signers refuses a signed release by name"
166else
167 [[ "$KEYS" -eq 1 ]] && grep -qE '^aien-release ssh-ed25519 [A-Za-z0-9+/=]+$' "$PROD" || fail "allowed_signers must hold exactly one aien-release ed25519 key"
168fi
169! grep -qF "$(grep -vE '^[[:space:]]*(#|$)' "$ROOT/docs/release/internal_test_signers" | cut -d' ' -f3)" "$PROD" || fail "the internal test key is in allowed_signers"
170echo "PASS: release gate rejects inconsistent source pins, executable digest and model input mismatches, missing or invalid signatures"