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-real-tree.sh

111 lines · 8240 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# Release gate against the REAL candidate manifest (release/candidate.toml, omega.lock, Cargo.lock), CPU only, offline.
18# scripts/test-release-checks.sh uses an invented candidate; this one proves the gate refuses a package or tree that
19# is not CAND-4, using the committed manifest. No signing key is read or generated; the binaries are throwaway
20# scripts, never real builds. Nothing is published.
21#
22# How the gate binds a package to the candidate revision (scripts/check-release-candidate.sh):
23# tree: omega.lock == omega-commit, Cargo.lock holds exactly the [pins] revisions.
24# package: release.toml candidate + [model] table match, and with --native the sha256 of bin/aien must equal
25# [executables] aien-cli-native-release. The binary digest is what ties a package to a source revision:
26# a build from any other sovereign-core source gives another digest and is refused.
27# NOT bound: the sovereign-core-commit field in candidate.toml is informational (candidate.toml itself changed after
28# that commit); the executable digests are the binding. A package without --native is refused (no digest).
29#
30# Mutation note: the negative "post-candidate binary refused" case passes wrongly if the line
31# [[ "$want_aien" == "$exe" ]] || die ...
32# in check-release-candidate.sh is removed or weakened (for example `true ||`). The mutation section below applies
33# that change to a copy of the gate and requires the negative check to turn red, so it cannot pass vacuously.
34set -euo pipefail
35ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
36W="$(mktemp -d "${TMPDIR:-/tmp}/aien-test-release-real.XXXXXX")"
37trap 'rm -rf "$W"' EXIT
38fail() { echo "FAIL: $*" >&2; exit 1; }
39pass() { echo "ok: $*"; }
40sha() { sha256sum "$1" | cut -d' ' -f1; }
41
42# fixture: the real manifest and locks, the real gate and packager, throwaway binaries
43T="$W/tree"; mkdir -p "$T/scripts" "$T/release" "$W/bins"
44cp "$ROOT/scripts/check-release-candidate.sh" "$ROOT/scripts/package-release.sh" "$T/scripts/"
45cp "$ROOT/release/candidate.toml" "$T/release/"; cp "$ROOT/Cargo.lock" "$T/"
46# The fixture tree is the candidate's tree: omega.lock is the candidate's omega-commit, not this revision's. Main may
47# move ahead of the candidate; whether THIS revision is releasable is reported (not enforced) by release-dry-run.yml,
48# and enforced at tag time by release.yml.
49sed -n 's/^omega-commit = "\([0-9a-f]\{40\}\)"$/\1/p' "$T/release/candidate.toml" > "$T/omega.lock"
50[[ -s "$T/omega.lock" ]] || fail "release/candidate.toml has no full omega-commit"
51echo 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"
52for b in aien-cli spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger; do
53 printf '#!/bin/sh\necho throwaway %s\n' "$b" > "$W/bins/$b"; chmod 755 "$W/bins/$b"
54done
55gate() { (cd "$T" && bash scripts/check-release-candidate.sh "$@" > "$W/log" 2>&1); }
56must_pass() { gate "$@" || { cat "$W/log" >&2; fail "gate refused: $*"; }; }
57must_fail() { local want="$1"; shift; if gate "$@"; then fail "gate accepted ($want)"; fi
58 grep -q -- "$want" "$W/log" || { cat "$W/log" >&2; fail "refused for the wrong reason, wanted: $want"; }; }
59
60CAND="$(sed -n 's/^candidate = "\(.*\)"/\1/p' "$T/release/candidate.toml")"
61NATIVE_DIGEST="$(sed -n 's/^aien-cli-native-release = "\([0-9a-f]\{64\}\)".*/\1/p' "$T/release/candidate.toml")"
62[[ "$CAND" == CAND-4 && -n "$NATIVE_DIGEST" ]] || fail "release/candidate.toml is not CAND-4 with a native digest"
63grep -Eq '^sovereign-core-commit = "[0-9a-f]{40}"' "$T/release/candidate.toml" || fail "sovereign-core-commit is not a full hash"
64
65# positive control, tree: a tree on the candidate's pins passes
66must_pass; grep -q "candidate=CAND-4" "$W/log"; pass "candidate tree passes the tree gate as CAND-4"
67
68# negative, tree: a tree on other pins than the candidate's (what a later main would look like) is refused
69cp "$T/omega.lock" "$W/omega.ok"; cp "$T/Cargo.lock" "$W/cargo.ok"
70printf '%s\n' "0000000000000000000000000000000000000000" > "$T/omega.lock"; must_fail "omega.lock is"; cp "$W/omega.ok" "$T/omega.lock"
71pass "omega.lock after the candidate refused"
72want_pr="$(sed -n 's/^aien-protocols = "\(.*\)"/\1/p' "$T/release/candidate.toml")"
73sed -i "s/$want_pr/1111111111111111111111111111111111111111/g" "$T/Cargo.lock"; must_fail "consumes aien-protocols"; cp "$W/cargo.ok" "$T/Cargo.lock"
74pass "Cargo.lock aien-protocols after the candidate refused"
75must_pass; pass "tree restored, accepted again"
76
77# packages built by the real packager from the real tree, with throwaway binaries
78(cd "$T" && AIEN_RELEASE_BIN_DIR="$W/bins" bash scripts/package-release.sh "$W/post.tar.gz" >"$W/plog" 2>&1) || { cat "$W/plog" >&2; fail "packaging failed"; }
79# negative, package: a binary that is not the candidate's (any post-candidate build) is refused on the native target
80native_negative() { # gate-script
81 (cd "$T" && bash "$1" --package "$W/post.tar.gz" --native > "$W/log" 2>&1) && return 1
82 grep -q "is not CAND-4's aien-cli-native-release" "$W/log"
83}
84native_negative scripts/check-release-candidate.sh || { cat "$W/log" >&2; fail "post-candidate binary not refused for the right reason"; }
85grep -q "$NATIVE_DIGEST" "$W/log" || fail "refusal does not name the candidate digest"
86pass "package from a non-candidate binary refused (--native): digest differs from CAND-4 aien-cli-native-release"
87# no --native: the manifest has no digest for that package kind, so it is refused (never passed)
88must_fail "no candidate digest for this package kind" --package "$W/post.tar.gz"; pass "package without --native refused: no candidate digest for the kind"
89# a package that names another candidate is refused
90rm -rf "$W/u"; mkdir "$W/u"; tar -xzf "$W/post.tar.gz" -C "$W/u"; sed -i 's/^candidate = .*/candidate = "CAND-3"/' "$W/u/release.toml"
91tar -czf "$W/cand3.tar.gz" -C "$W/u" .
92must_fail "names candidate 'CAND-3', not CAND-4" --package "$W/cand3.tar.gz"; pass "package naming CAND-3 refused"
93
94# positive control, package: manifest whose native digest is this package's binary
95GOOD="$(sha "$W/bins/aien-cli")"
96sed -i "s/^aien-cli-native-release = \"[0-9a-f]\{64\}\"/aien-cli-native-release = \"$GOOD\"/" "$T/release/candidate.toml"
97must_fail "is not CAND-4's sc-" --package "$W/post.tar.gz" --native; pass "aien-cli matches but helper digests do not: refused"
98for h in spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger; do
99 sed -i "s/^sc-$h = \"[0-9a-f]\{64\}\"/sc-$h = \"$(sha "$W/bins/$h")\"/" "$T/release/candidate.toml"
100done
101must_pass --package "$W/post.tar.gz" --native; pass "positive control: every shipped executable matches its manifest digest, package passes"
102cp "$ROOT/release/candidate.toml" "$T/release/candidate.toml"
103
104# mutation: weaken the digest comparison in a copy of the gate; the negative must turn red
105sed 's/\[\[ "\$want_aien" == "\$exe" \]\] ||/true ||/' "$T/scripts/check-release-candidate.sh" > "$T/scripts/mutant.sh"
106cmp -s "$T/scripts/mutant.sh" "$T/scripts/check-release-candidate.sh" && fail "mutation did not apply (gate text changed; update this test)"
107if native_negative scripts/mutant.sh; then fail "negative test stayed green against a gate that skips the digest comparison"; fi
108pass "mutation (digest comparison removed) is caught"
109
110bash "$ROOT/scripts/test-dry-run-workflow.sh"
111echo "PASS: release gate refuses non-candidate trees and packages against the real CAND-4 manifest"