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
aien-sovereign-core-mv / tests / gates / run.sh
| 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 | # tests/gates/run.sh: the one entry point for the local verification gates of aien-sovereign-core. |
| 18 | # Every step runs the SAME command as the hosted job it mirrors (.github/workflows/ci.yml, |
| 19 | # hardening.yml, crumb-visible-conformance.yml, verify-closure.yml, release-dry-run.yml, |
| 20 | # sovereign-inquisitor.yml). Manifests under tests/gates/ name this script plus one step word, |
| 21 | # so no manifest needs shell expansion (ADR 0028 P6). The PREFILL-E2E-2 gates under |
| 22 | # crates/aien-runtime/tests are separate and untouched. |
| 23 | # |
| 24 | # Pinned sibling sources: the hosted jobs check out omega at omega.lock, physics and aienos at |
| 25 | # omega's own locks, and aien-protocols at two fixed commits (TRN1 and CRB1 vector corpora). |
| 26 | # Here the same commits are materialised under $CARGO_TARGET_DIR/aien-pins (default target/aien-pins) from |
| 27 | # the sibling local clones ../omega ../physics ../aienos ../aien-protocols, offline. |
| 28 | set -euo pipefail |
| 29 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 30 | cd "$ROOT" |
| 31 | step="${1:?usage: tests/gates/run.sh <step>}" |
| 32 | # A read-only HOME (the sandbox's) is swapped for a fresh writable one for this step; the read-only |
| 33 | # home's models/ mount stays reachable as AIEN_MODELS_DIR (tests/gates/step-home.sh, which |
| 34 | # scripts/test-gb10-model-dir.sh exercises with a read-only HOME). |
| 35 | # shellcheck source=tests/gates/step-home.sh |
| 36 | . "$ROOT/tests/gates/step-home.sh" |
| 37 | step_home |
| 38 | obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; } |
| 39 | # Inside the user sandbox (AIEN_SANDBOX_NESTED=1, set by the worker) five aien-test self-tests that would |
| 40 | # start a sandbox themselves skip (they cannot nest); the receipt says so for the two steps that run them. |
| 41 | nested_obs() { |
| 42 | if [ "${AIEN_SANDBOX_NESTED:-}" = 1 ]; then |
| 43 | obs nested_sandbox_skips "\"5 aien-test self-tests skipped inside the user sandbox (AIEN_SANDBOX_NESTED=1)\"" |
| 44 | fi |
| 45 | } |
| 46 | # Outside the worktree when CARGO_TARGET_DIR is, and under target/ otherwise: the hosted test job |
| 47 | # has no pin checkouts in its tree, and test_t2_f65 scans the tree (minus target/) for *.pem files, |
| 48 | # which the vendored crates of a pinned aienos ship as test fixtures. |
| 49 | PINS="${CARGO_TARGET_DIR:-$ROOT/target}/aien-pins" |
| 50 | TARGET="${CARGO_TARGET_DIR:-$ROOT/target}" |
| 51 | |
| 52 | pin() { # pin <dir-name> <sibling repo> <sha40> |
| 53 | local name="$1" repo="$2" sha="$3" dir="$PINS/$1" |
| 54 | if [ ! -e "../$repo/.git" ]; then |
| 55 | echo "run.sh: ../$repo is missing; the hosted job checks out aien-dev/$repo at $sha" >&2 |
| 56 | exit 3 |
| 57 | fi |
| 58 | if [ ! -d "$dir" ] || [ "$(git -C "$dir" rev-parse HEAD 2>/dev/null)" != "$sha" ]; then |
| 59 | rm -rf "$dir"; mkdir -p "$PINS" |
| 60 | git clone --quiet --shared --no-checkout "../$repo" "$dir" |
| 61 | git -C "$dir" checkout --quiet --detach "$sha" |
| 62 | fi |
| 63 | obs "pin_${name//-/_}" "\"$sha\"" |
| 64 | } |
| 65 | |
| 66 | case "$step" in |
| 67 | # crumb-verify (gate CRUMB-VERIFY) is retired (DRA-97, 2026-11-07): Crumbs are off the active |
| 68 | # workflow, so no gate checks crumb freshness. The .crumb files and crumb.lock stay as history. |
| 69 | # ci.yml job verify ("Workspace Verification & Invariant Audit") |
| 70 | fmt) cargo fmt --all -- --check ;; |
| 71 | release-gate-negatives) |
| 72 | bash scripts/test-install-release.sh |
| 73 | bash scripts/test-offline-signing.sh |
| 74 | bash scripts/test-public-key-integration.sh |
| 75 | bash scripts/check-release-trust-config.sh |
| 76 | bash scripts/test-release-checks.sh |
| 77 | ;; |
| 78 | aien-verify-tests) sh tools/aien-verify/tests/run.sh ;; |
| 79 | pins-selftest) bash scripts/test-pins.sh ;; |
| 80 | own30b-quiet-run-selftest) bash scripts/bench/own30b-quiet-run-selftest.sh ;; |
| 81 | native-identity) bash scripts/test-native-identity.sh ;; |
| 82 | install-test) bash scripts/test-install.sh ;; |
| 83 | scoring-v5) bash docs/campaigns/scoring/test-scoring-v5.sh ;; |
| 84 | check) |
| 85 | cargo check --workspace --all-targets |
| 86 | # sc#828: the benchmarks/ and e2e_tests/ workspaces are not members of the root workspace, so |
| 87 | # the line above never resolves their lockfiles. Lock drift went unnoticed in both (sc#820, |
| 88 | # sc#837). --locked refuses any lockfile the manifests would rewrite. |
| 89 | cargo check --locked --manifest-path benchmarks/Cargo.toml --workspace --all-targets |
| 90 | cargo fetch --locked --manifest-path e2e_tests/Cargo.toml |
| 91 | ;; |
| 92 | clippy) cargo clippy --workspace --all-targets -- -D warnings ;; |
| 93 | test) |
| 94 | # GitHub Actions sets CI=true in every job. Tests that reach live services or check the |
| 95 | # branch name (spark-adapters tier1-4) skip themselves under CI, so the hosted job never runs |
| 96 | # them; without it they fail here on any branch not named feat/, fix/... or on a detached head. |
| 97 | nested_obs |
| 98 | CI=true AIEN_DEV_FALLBACK=1 cargo test --workspace --verbose -- --test-threads=1 |
| 99 | ;; |
| 100 | strict-mode) |
| 101 | cargo test -p aien-inference-abi --lib --test attention_wiring --test transformer_parity -- --test-threads=1 |
| 102 | cargo test -p aien-inference-runtime --test strict_real_model -- --test-threads=1 |
| 103 | ;; |
| 104 | zero-cuda) |
| 105 | bash scripts/zero-cuda-gate.sh --self-test |
| 106 | cargo build -p aien-cli |
| 107 | bash scripts/zero-cuda-gate.sh "$TARGET/debug/aien-cli" |
| 108 | ;; |
| 109 | preflight-guard) bash scripts/test-preflight-branch-guard.sh ;; |
| 110 | agent-preflight) |
| 111 | # Hosted: developer context on pull requests, merged-tree on pushes to main. |
| 112 | # CI=true as on GitHub (see the test step): the script runs cargo test --workspace. |
| 113 | nested_obs |
| 114 | CI=true AIEN_PROOF_OFF=1 AIEN_DEV_FALLBACK=1 AIEN_PREFLIGHT_CONTEXT="${AIEN_PREFLIGHT_CONTEXT:-developer}" bash scripts/agent-preflight.sh |
| 115 | ;; |
| 116 | zero-disk-secrets) |
| 117 | echo "Auditing repository for prohibited plaintext secret files..." |
| 118 | if find . -maxdepth 4 -name ".env*" -not -path "*/.git/*" -not -path "*/target/*" | grep -q .; then |
| 119 | echo "::error::Prohibited plaintext .env file found. Use an approved AIEN SecretProvider." |
| 120 | obs env_files_found true; exit 1 |
| 121 | fi |
| 122 | obs env_files_found false |
| 123 | echo "Zero plaintext .env files verified." |
| 124 | ;; |
| 125 | anti-slop) |
| 126 | echo "Auditing repository for em dashes, en dashes, and formulaic tropes..." |
| 127 | # Pattern is em dash OR en dash, built from UTF-8 bytes so this file never carries the |
| 128 | # characters it scans for. Same pattern and scope as the hosted step. |
| 129 | DASH_PATTERN="$(printf '\xe2\x80\x94|\xe2\x80\x93')" |
| 130 | BAD_CHARS=$(grep -rnE --exclude-dir=target --exclude-dir=.git --exclude-dir=aien-protocols --exclude="*.rs" --exclude="*.json" --exclude="*.safetensors" --exclude="FORGEJO_CI.md" "$DASH_PATTERN" crates/ docs/ README.md || true) |
| 131 | BAD_CHARS=$(printf "%s\n" "$BAD_CHARS" | grep -vE "^docs/campaigns/[^:]*/replies/[0-9a-f]{64}\.txt:" || true) |
| 132 | if [ -n "$BAD_CHARS" ]; then |
| 133 | echo "::error::Em dashes or en dashes detected:"; echo "$BAD_CHARS" |
| 134 | obs dash_hits "$(printf '%s\n' "$BAD_CHARS" | grep -c .)"; exit 1 |
| 135 | fi |
| 136 | obs dash_hits 0 |
| 137 | echo "Sovereign voice compliance verified." |
| 138 | ;; |
| 139 | # ci.yml job linked-compose |
| 140 | linked-compose) |
| 141 | omega_sha="$(tr -d '[:space:]' < omega.lock)" |
| 142 | pin omega omega "$omega_sha" |
| 143 | pin physics physics "$(tr -d '[:space:]' < "$PINS/omega/physics.lock")" |
| 144 | pin aienos aienos "$(awk 'NF && $1 !~ /^#/ {print $1; exit}' "$PINS/omega/aienos.lock")" |
| 145 | bash scripts/test-linked-compose.sh "$PINS/omega" "$PINS/physics" "$PINS/aienos" |
| 146 | ;; |
| 147 | # No hosted mirror: GitHub has no GB10. SC-GB10-SERVE-CHAT, the GPU receipt an Alpha needs |
| 148 | # (verify-bundle --require-full, NO_GPU_RECEIPT). Same pinned sources as linked-compose, from the |
| 149 | # siblings, offline; scripts/pins.sh --gpu reuses them and writes the env.sh install.sh sources. |
| 150 | gb10-serve-chat) |
| 151 | omega_sha="$(tr -d '[:space:]' < omega.lock)" |
| 152 | pin omega omega "$omega_sha" |
| 153 | pin physics physics "$(tr -d '[:space:]' < "$PINS/omega/physics.lock")" |
| 154 | pin aienos aienos "$(awk 'NF && $1 !~ /^#/ {print $1; exit}' "$PINS/omega/aienos.lock")" |
| 155 | AIEN_PINS_REMOTE_BASE="$(cd .. && pwd)" AIEN_PINS_REMOTE_SUFFIX="" bash scripts/pins.sh --gpu "$PINS" |
| 156 | bash scripts/gb10-serve-chat.sh "$PINS/env.sh" |
| 157 | ;; |
| 158 | # SC-GB10-MODEL-DIR (portable, shell only): where SC-GB10-SERVE-CHAT finds its checkpoint under a |
| 159 | # read-only HOME, and its NOT_RUN model_missing before any build or GPU start (no cargo, no GPU). |
| 160 | gb10-model-dir) bash scripts/test-gb10-model-dir.sh ;; |
| 161 | # No hosted mirror (the checkpoint is host-only). SC-EXPERT-BYTES (DRA-63, #855): per-expert bytes of the |
| 162 | # Qwen3.6-35B-A3B-FP8 headers, layers 0-39, by seeded Omega; width 768 and FP32 scales must go red. |
| 163 | expert-bytes) bash om/expert-bytes/gate.sh ;; |
| 164 | # No hosted mirror (GitHub has no GB10). SC-GB10-GOLDEN-TOKENS (DRA-52, #853): the own Omega LLM's |
| 165 | # greedy tokens on the GB10 from the aien-train tree in om/golden/ollm/aien-train.lock against the |
| 166 | # committed CPU-decoded record; a one-kernel-constant negative control in the same run must be |
| 167 | # blocked. Compilers: omega-mv e5b32567 (aien-train gb10 pin) and bf54b19f (om/golden pin). |
| 168 | gb10-golden-tokens) |
| 169 | pin omega-ollm omega e5b32567a7aff3ce594e3254a622a846a6cd190b |
| 170 | pin omega-golden omega bf54b19fa590e8ae925c0e80815516dbf41e7326 |
| 171 | pin aien-train aien-train "$(tr -d '[:space:]' < om/golden/ollm/aien-train.lock)" |
| 172 | OMC="$PINS/omega-golden/seed/out/omc" bash om/golden/build.sh "$PINS/golden-drive" om/golden/ollm/drive.om |
| 173 | AIEN_OMC_TRAIN="$PINS/omega-ollm/seed/out/omc" AIEN_OMC_GATE="$PINS/omega-golden/seed/out/omc" \ |
| 174 | AIEN_GOLDEN_TRAIN="$PINS/aien-train" "$PINS/golden-drive" core |
| 175 | ;; |
| 176 | # The controller compiler is rebuilt from Core's pinned Omega seed. |
| 177 | # Native transport/GPU qualification is recorded separately. |
| 178 | ribbon-control) |
| 179 | pin omega omega "$(tr -d '[:space:]' < omega.lock)" |
| 180 | sh "$PINS/omega/seed/omega-from-seed.sh" |
| 181 | OMEGA_OMC="$PINS/omega/seed/out/omc" bash om/ribbon/run.sh |
| 182 | obs ribbon_controller_checked true |
| 183 | python3 om/ribbon/check_evidence.py |
| 184 | obs ribbon_evidence_checked true |
| 185 | ;; |
| 186 | # hardening.yml |
| 187 | kv-props) |
| 188 | cargo fetch --manifest-path crates/aien-replay/Cargo.toml |
| 189 | cargo test --manifest-path crates/aien-replay/Cargo.toml --test kv_ownership_props |
| 190 | sh crates/aien-replay/mutations/run_mutants.sh native |
| 191 | ;; |
| 192 | miri) |
| 193 | cargo +nightly miri setup |
| 194 | cargo +nightly miri test -p aien-capability |
| 195 | cargo +nightly miri test -p aien-kv-cache |
| 196 | sh crates/aien-replay/mutations/run_mutants.sh miri |
| 197 | ;; |
| 198 | trn1) |
| 199 | pin trn1-protocols aien-protocols 353b7d4be3f00169545caec1615cffa61f7d311a |
| 200 | export TRN1_VECTORS="$PINS/trn1-protocols/specs/execution-transcript/vectors" |
| 201 | TRN1_REQUIRE=1 cargo test --manifest-path crates/aien-replay/Cargo.toml --test trn1_conformance -- --nocapture |
| 202 | sh crates/aien-replay/mutations/run_mutants.sh trn1 |
| 203 | ;; |
| 204 | # crumb-visible-conformance.yml |
| 205 | crb1) |
| 206 | pin crb1-protocols aien-protocols b50c00d737fa5c57ea7280e2aa4b0354ff166cf5 |
| 207 | export CRB1_VECTORS="$PINS/crb1-protocols/specs/crumb-visible/vectors" |
| 208 | CRB1_REQUIRE=1 cargo test -p crumbs --test visible_conformance -- --nocapture |
| 209 | ;; |
| 210 | # verify-closure.yml |
| 211 | verify-closure) |
| 212 | cargo build --locked -p aien-closure --bin verify-closure |
| 213 | cargo test --locked -p aien-closure |
| 214 | (cd crates/aien-closure/tests/fixtures/seeded && "$TARGET/debug/verify-closure" --root . --store store) |
| 215 | ;; |
| 216 | # release-dry-run.yml (pull_request only) |
| 217 | release-dry-run) |
| 218 | bash scripts/test-dry-run-workflow.sh |
| 219 | bash scripts/test-release-gate-wiring.sh |
| 220 | bash scripts/test-release-signing-workflow.sh |
| 221 | # Report only on the hosted side (continue-on-error): recorded here as an observation. |
| 222 | if out="$(scripts/check-release-candidate.sh 2>&1)"; then |
| 223 | echo "Release gate: this tree IS releasable as ${out#candidate=}"; obs tree_releasable true |
| 224 | else |
| 225 | echo "Release gate: this tree is NOT releasable as the candidate: $out"; obs tree_releasable false |
| 226 | fi |
| 227 | bash scripts/test-release-real-tree.sh |
| 228 | ;; |
| 229 | # sovereign-inquisitor.yml (pull_request_target). The hosted job fetched `gh pr diff` with GITHUB_TOKEN only to |
| 230 | # get the diff; the verdict (exit 1 unless the audit is clean) depends on nothing but the diff text, and the |
| 231 | # author, number and title only decorate the comment. The same diff is computed here from git: base...HEAD, where |
| 232 | # base is the merge base with the base line (what `gh pr diff` shows), or for a head already on the base line its |
| 233 | # first parent (the rule the worker's plan uses). The worker's base line is origin/main (AIEN_BASE_REF overrides). |
| 234 | # Posting the comment and labels stays a GitHub job; nothing here writes to GitHub. |
| 235 | inquisitor) |
| 236 | cargo build --release -p spark-inquisitor |
| 237 | base_ref="${AIEN_BASE_REF:-origin/main}" |
| 238 | if ! git rev-parse --verify -q "$base_ref^{commit}" >/dev/null; then |
| 239 | echo "run.sh: base $base_ref is not in this checkout; cannot compute the pull request diff" >&2 |
| 240 | exit 3 |
| 241 | fi |
| 242 | head="$(git rev-parse HEAD)" |
| 243 | base="$(git merge-base HEAD "$base_ref")" |
| 244 | if [ "$base" = "$head" ]; then base="$(git rev-parse HEAD^1)"; fi |
| 245 | diff_file="$(mktemp)" |
| 246 | git diff --no-color --no-ext-diff "$base" "$head" > "$diff_file" |
| 247 | obs inquisitor_base "\"$base\"" |
| 248 | obs inquisitor_diff_files "$(git diff --name-only "$base" "$head" | grep -c . || true)" |
| 249 | rc=0 |
| 250 | "$TARGET/release/spark-inquisitor" review --author local --pr 0 \ |
| 251 | --title "$(git log -1 --format=%s "$head")" --diff "$diff_file" || rc=$? |
| 252 | rm -f "$diff_file" |
| 253 | obs inquisitor_clean "$([ "$rc" = 0 ] && echo true || echo false)" |
| 254 | exit "$rc" |
| 255 | ;; |
| 256 | *) echo "run.sh: unknown step '$step'" >&2; exit 2 ;; |
| 257 | esac |