interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tests / gates / run.sh

844 lines · 60046 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# tests/gates/run.sh: the one entry point for the local verification gates of omega.
18# Every step runs the SAME command as the hosted job it mirrors (.github/workflows/pr-smoke.yml,
19# host-suites.yml, host-suites-2.yml, host-suites-3.yml, rx-host.yml, turing-yield.yml,
20# evidence-immutable.yml, crumb.yml). Manifests under tests/gates/ name this script plus one
21# step word, so no manifest needs shell expansion (ADR 0028 P6).
22#
23# Pinned sibling sources. The hosted jobs checked out aien-spark/physics at physics.lock,
24# aien-dev/aienux at aienos.lock and aien-dev/aienux at
25# argus.lock, as physics-src/, aienos-src/ and aienos-argus/ next to the Makefile, and exclude
26# them from git status. Here the same commits are materialised as private, read-only checkouts
27# under build/pins/ (build/ is gitignored) from the sibling clones, offline. Each invocation
28# gets fresh source bytes proven against the locked commit's objects; no gate consumes a shared
29# mutable dependency worktree.
30set -euo pipefail
31# Reviewer 2026-11-15 (P1032): an inherited MAKEFLAGS (e.g. -i/-k) or MAKEFILES (e.g. a file with .IGNORE:) would let a failing gate pass; gates run with a clean make.
32unset MAKEFLAGS MFLAGS GNUMAKEFLAGS MAKEFILES
33ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
34cd "$ROOT"
35python3 tools/uxl/windows_paths.py
36step="${1:?usage: tests/gates/run.sh <step>}"
37
38# Every step builds in its own directory. The Spark judge (aien-test) runs a repository's host gates
39# at the same moment in one worktree; with one shared build/ a gate links an object another gate's
40# compiler is still writing (omega#511: OMEGA-M12 "undefined reference to omega_tern_*" with the
41# object on the link line). OUT_DIR is read by the Makefile (?=) and by every make it spawns.
42# Each invocation's pins stay in a private random directory under build/pins. The step directory
43# name keeps only [A-Za-z0-9_.-] from the step word: "spark:test-r13-host" would put a colon in
44# a make target ("multiple target patterns").
45step_key="$(printf '%s' "$step" | tr -c 'A-Za-z0-9_.-' '-')"
46export OUT_DIR="build/step-$step_key"
47mkdir -p "$OUT_DIR" "$ROOT/build/pins"
48obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; }
49
50PINS="$(mktemp -d "$ROOT/build/pins/$step_key.XXXXXX")"
51STEP_MARK=""
52cleanup() {
53 if [ -n "$STEP_MARK" ]; then rm -f -- "$STEP_MARK"; fi
54 case "$PINS" in
55 "$ROOT/build/pins/$step_key".*)
56 chmod -R u+w -- "$PINS" 2>/dev/null || true
57 rm -rf -- "$PINS" ;;
58 esac
59}
60trap cleanup EXIT
61NOPHYS="PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0"
62lock() { awk 'NF && $1 !~ /^#/ {print $1; exit}' "$1"; }
63
64# pin <dir-name> <sibling repo> <sha40>: materialize a fresh detached checkout of <sha40>
65# from ../<sibling repo>. pinned_checkout.sh disables replacement objects and grafts, copies
66# the commit graph into this invocation's repository, re-hashes commit/tree/blob identities,
67# verifies raw worktree bytes and modes, and makes the result read-only before returning it.
68pin() {
69 local name="$1" repo="$2" sha="$3" dir="$PINS/$1" tree
70 if [ ! -d "../$repo/.git" ] && [ ! -f "../$repo/.git" ]; then
71 echo "run.sh: ../$repo is missing; the hosted job checks out aien-dev/$repo at $sha" >&2
72 exit 3
73 fi
74 chmod u+w -- "$PINS"
75 tree="$(tools/pinned_checkout.sh materialize "../$repo" "$sha" "$dir")"
76 chmod a-w -- "$PINS"
77 obs "pin_${name//-/_}" "\"$sha\""
78 obs "pin_${name//-/_}_tree" "\"$tree\""
79}
80# Every step that builds against physics takes the commit from physics.lock, never a literal:
81# the Makefile's check-physics-lock refuses any other commit, so a literal here goes red on
82# the next lock bump (it did for the e95e3ed bump, omega#508, and again for 048e5f5, omega#523).
83physics_pin() { pin physics-src physics "$(lock physics.lock)"; export PHYSICS_DIR="$PINS/physics-src"; }
84aienos_pin() { pin aienos-src aienos "$(lock aienos.lock)"; export AIENOS_R7_DIR="$PINS/aienos-src"; export AIENOS_COMMIT="$(lock aienos.lock)"; }
85argus_pin() { pin aienos-argus aienos "$(lock argus.lock)"; export ARGUS_REPO="$PINS/aienos-argus"; }
86export OMEGA_CANDIDATE_COMMIT="$(git rev-parse HEAD)"
87
88# receipt <file name or glob> <grep pattern>...: the hosted "Show ... receipt" steps.
89# Only receipts written during this step count: a hosted job starts from a fresh checkout, so it
90# can only see its own run, while a reused local tree keeps build/qual-runs from earlier runs.
91STEP_MARK="$(mktemp /tmp/omega-gate-step.XXXXXX)"
92receipt() {
93 local r; r="$(find build/qual-runs -name "$1" -type f -newer "$STEP_MARK" | head -n 1)"; shift
94 test -n "$r"
95 local p; for p in "$@"; do grep -q "$p" "$r"; done
96 sha256sum "$r"
97}
98gates_pass() { grep -E 'TOTAL GATES: [0-9]+ \| PASSED: [0-9]+ \| FAILED: 0' "$1" && ! grep -E 'FAILED: [1-9]' "$1"; }
99
100# speed <make target> <receipt file> <gate word>: a speed test (tests/runtime/rx_quiet_reps.h) that found
101# the machine too busy to time, or a leg it claims faster disturbed significantly more often than the
102# other leg, ends with `AIEN-OBS not_run_reason "cpu_busy"` (or "leg_skew") and exit 77; make reports
103# any failing recipe as 2, so the refusal is read from the test's own receipt for this step: "failures": 0
104# and the gate word NOT_RUN, which the test writes only when nothing it judged failed. Then the step goes
105# on, so every other check is still judged, and ends NOT_RUN (exit 77) only if nothing else failed, with
106# reason leg_skew when any refused receipt says so, else cpu_busy.
107# Anything else is the failure it was. A passing run gets the receipt check it always had.
108BUSY=0
109BUSY_REASON=cpu_busy
110speed() {
111 local target="$1" file="$2" word="$3" rc=0 r f bad=1
112 make "$target" || rc=$?
113 if [ "$rc" -eq 0 ]; then
114 receipt "$file" '"failures": 0,' '"candidate_bound": true,' "\"$word\": \"PASS\""
115 return
116 fi
117 # Every receipt of that name written during this step must say so; any other one keeps the failure.
118 r="$(find build/qual-runs -name "$file" -type f -newer "$STEP_MARK")"
119 if [ -n "$r" ]; then
120 bad=0
121 while IFS= read -r f; do
122 grep -q '"failures": 0,' "$f" && grep -q '"candidate_bound": true,' "$f" &&
123 grep -q "\"$word\": \"NOT_RUN\"" "$f" || bad=1
124 if grep -q '"not_run_reason": "leg_skew"' "$f"; then BUSY_REASON=leg_skew; fi
125 done <<< "$r"
126 fi
127 if [ "$bad" = 0 ]; then
128 echo "run.sh: $target: refused to time ($BUSY_REASON; the test's NOT RUN lines say why); not judged, the rest of the step runs" >&2
129 printf '%s\n' "$r" | xargs sha256sum
130 BUSY=1
131 return 0
132 fi
133 return "$rc"
134}
135
136case "$step" in
137 # crumb-verify (gate CRUMB-VERIFY) is retired (DRA-97, 2026-11-07). Crumb files were removed
138 # (2026-11-08) except two already under evidence/, which stay (additions-only). FOLDERS.md keeps the notes.
139 # pr-smoke.yml
140 base)
141 physics_pin; set -o pipefail
142 make test | tee build/base.log
143 grep -E 'TOTAL GATES: ([0-9]+) \| PASSED: \1 \| FAILED: 0' build/base.log
144 ! grep -qE 'FAILED: [1-9]|\[FAIL\]|\(FAIL\)' build/base.log
145 ;;
146 gpu-tgemm) # pr-smoke.yml smoke job, "Training GEMM host proofs" step: physics-src at physics.lock;
147 # budgets and warp simulator, no GPU
148 physics_pin; set -o pipefail; mkdir -p build
149 make test-gpu-tgemm | tee build/tgemm.log
150 test "$(grep -c '^GPU_TGEMM: PASS' build/tgemm.log)" = 2
151 ;;
152 language) # pr-smoke.yml and host-suites-3.yml (same command)
153 set -o pipefail; mkdir -p build
154 make $NOPHYS test-language | tee build/lang.log
155 grep -E '^PASS ([0-9]+)/\1$' build/lang.log
156 ! grep -q '^FAIL' build/lang.log
157 ;;
158 numeric-transc) # pr-smoke.yml and host-suites-3.yml (same command and checks)
159 set -o pipefail; mkdir -p build
160 make $NOPHYS test-numeric-transc | tee build/transc.log
161 test "$(grep -cE '^mutant [0-9]+ killed' build/transc.log)" -eq 10
162 grep -qE '^test-numeric-transc: PASS \(all 10 mutants killed\)' build/transc.log
163 ! grep -q '^FAIL' build/transc.log
164 obs mutants_killed 10
165 ;;
166 gpu-tern) # pr-smoke.yml smoke job, KT1 ternary GEMV step: physics-src at physics.lock; host battery
167 # and warp simulator, no chip
168 physics_pin; set -o pipefail; mkdir -p build
169 make test-gpu-tern | tee build/tern.log
170 test "$(grep -cE '^gpu_tern_test: [0-9]+ checks, 0 failed: PASS$' build/tern.log)" -eq 2
171 ! grep -q '^FAIL' build/tern.log
172 ;;
173 # host-suites.yml
174 searchtrace) make $NOPHYS test-searchtrace ;;
175 estimation) for t in test-estimation test-est-tools test-estimation-v3 test-est3c-tools; do make $NOPHYS $t; done ;;
176 ans) make $NOPHYS test-inertial-alignment ;;
177 numeric-cpu) for t in test-numeric-cpu test-numeric-qualify test-e1-combine test-chipwait-campaign test-gpu-wait test-gpu-wait-mutants test-gpu-code-alloc test-mufu-ftz; do make $NOPHYS $t; done ;;
178 train) make $NOPHYS test-train ;;
179 compiler) make $NOPHYS test-compiler-quick; make $NOPHYS test-compiler-full ;;
180 one-layer-acceptance) make $NOPHYS test-one-layer-acceptance ;;
181 physics0) make $NOPHYS physics0-test ;;
182 chip-tool-selftests) for t in test-m19r-qualify test-gate14-combine test-gate-physics-pin test-window-lane-guard test-unwritten-trap-host test-ldst-host test-dgraph-receipt; do make $NOPHYS $t; done ;;
183 # seed compiler (no hosted mirror; Spark only): rebuild from the loader, full qualification, IR oracles required
184 seed) make OUT_DIR=build build/omegese/omegese build/omega_emit/omega_emit build/checker2/checker2
185 sh seed/omega-from-seed.sh
186 # A change that adds, removes or renumbers a host keyword runs `seed/effects/check.sh` inside `tests/gates/run.sh seed`, before that gate's final PASS. The run counts only if it prints the closure line (`host keywords == table`, or `closure: host keywords differ from table`). Exit 3, `NOT_RUN`, or any other exit that does not print that line is not a pass and is not proof the closure was checked. A closure diff is a failing seed gate. A step that exists only in a driver outside this repository does not count.
187 sh seed/effects/check.sh 2>&1 | tee "$OUT_DIR.seed-effects.log"
188 if ! grep -qE '^ok +closure: [0-9]+ host keywords == table$' "$OUT_DIR.seed-effects.log" ||
189 grep -q 'NOT_RUN' "$OUT_DIR.seed-effects.log"; then
190 echo "OMEGA-SEED: effects closure did not pass" >&2
191 exit 1
192 fi
193 sh seed/host/check.sh 2>&1 | tee "$OUT_DIR.seed-check.log"
194 if grep -q "^SKIP" "$OUT_DIR.seed-check.log"; then echo "OMEGA-SEED: a seed gate was skipped" >&2; exit 1; fi
195 # gate5 checks that seed/omc/size-history.tsv ends with a row for this omc; check.sh does not run it
196 sh seed/omc/gate5.sh 2>&1 | tee "$OUT_DIR.seed-gate5.log"
197 grep -q "^PASS native-host qualification" "$OUT_DIR.seed-check.log" || { echo "OMEGA-SEED: native-host qualification did not pass" >&2; exit 1; }
198 tail -1 "$OUT_DIR.seed-gate5.log" | grep -q "^GATE5 PASS" || { echo "OMEGA-SEED: gate5 failed" >&2; exit 1; } ;;
199 # AMD gfx942 back end (gpu/amd): the gate is seeded Omega, gpu/amd/gate.om, built with seed/ng/sha256.om by
200 # seed/out/omc after that compiler's digest is checked; the gate checks it again before building anything.
201 # The expected counts below follow gpu/amd/card.tsv and the unit table in gate.om; a change to either changes
202 # them in the same commit, so a truncated card or unit table fails here.
203 gpu-amd)
204 sha256sum -c --quiet seed/out/omc.sha256 || { echo "OMEGA-GPU-AMD REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
205 rm -rf "$OUT_DIR/gate" "$OUT_DIR/work"
206 { printf 'om2\n'; cat seed/ng/sha256.om gpu/amd/gate.om; } | seed/out/omc > "$OUT_DIR/gate"
207 chmod 700 "$OUT_DIR/gate"
208 rc=0; "$OUT_DIR/gate" seed/out/omc "$OUT_DIR/work" > "$OUT_DIR/gate.log" || rc=$?
209 cat "$OUT_DIR/gate.log"
210 [ "$rc" -eq 0 ] || exit "$rc"
211 grep -qx 'OMEGA-GPU-AMD PASS units=15 objects=19 binaries=1 references=1 controls=3 caught=3 hardware=NOT_RUN' "$OUT_DIR/gate.log" ||
212 { echo "OMEGA-GPU-AMD FAIL: the summary line does not show the expected units, objects, binaries, references and controls" >&2; exit 1; } ;;
213 gpu-amd-rest)
214 sha256sum -c --quiet seed/out/omc.sha256 || { echo "OMEGA-GPU-AMD-REST REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
215 rm -rf "$OUT_DIR/gate" "$OUT_DIR/work"
216 { printf 'om2\n'; cat seed/ng/sha256.om gpu/amd/rest/gate.om; } | seed/out/omc > "$OUT_DIR/gate"
217 chmod 700 "$OUT_DIR/gate"
218 rc=0; "$OUT_DIR/gate" seed/out/omc "$OUT_DIR/work" > "$OUT_DIR/gate.log" || rc=$?
219 cat "$OUT_DIR/gate.log"
220 [ "$rc" -eq 0 ] || exit "$rc"
221 grep -qx 'OMEGA-GPU-AMD-REST PASS sections=34 objects=34 verdicts=377 not_run=120 writer=19 kfd=103 plan=200 controls=14 caught=14 hardware=NOT_RUN' "$OUT_DIR/gate.log" ||
222 { echo "OMEGA-GPU-AMD-REST FAIL: the summary line does not show the expected sections, verdicts, plan rows and controls" >&2; exit 1; } ;;
223 # Omega GPU units (gpu/units.tsv, moved from CUDApp om/ and backend/): the gate is seeded Omega, gpu/units-gate.om,
224 # Omega GPU units (gpu/units.tsv, moved from CUDApp om/, backend/ and native/): the gate is seeded Omega, gpu/units-gate.om,
225 # built with seed/ng/sha256.om by seed/out/omc after that compiler's digest is checked; the gate checks it again.
226 # The expected count follows gpu/units.tsv; a change to the table changes it in the same commit.
227 gpu-units)
228 sha256sum -c --quiet seed/out/omc.sha256 || { echo "OMEGA-GPU-UNITS REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
229 rm -rf "$OUT_DIR/gate" "$OUT_DIR/work"
230 { printf 'om2\n'; cat seed/ng/sha256.om gpu/units-gate.om; } | seed/out/omc > "$OUT_DIR/gate"
231 chmod 700 "$OUT_DIR/gate"
232 rc=0; "$OUT_DIR/gate" seed/out/omc "$OUT_DIR/work" > "$OUT_DIR/gate.log" || rc=$?
233 cat "$OUT_DIR/gate.log"
234 [ "$rc" -eq 0 ] || exit "$rc"
235 grep -qx 'OMEGA-GPU-UNITS PASS units=405 controls=1 caught=1 hardware=NOT_RUN' "$OUT_DIR/gate.log" ||
236 { echo "OMEGA-GPU-UNITS FAIL: the summary line does not show the expected units and controls" >&2; exit 1; } ;;
237 # One slice of the CUDApp merge: new Omega for part of the C decision logic of CUDApp nvrm/ and m16/ (gpu/nvidia/driver/). The gate is seeded Omega,
238 # gpu/nvidia/driver/gate.om, composed in the order of gpu/nvidia/driver/parts.txt and built by seed/out/omc after its
239 # digest is checked. It recomputes every case the C oracle printed (oracle-cases.tsv) and runs one changed-answer
240 # control per case kind. The expected case count is counted from the table. Host only; it opens no device.
241 gpu-driver)
242 sha256sum -c --quiet seed/out/omc.sha256 || { echo "OMEGA-GPU-DRIVER REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
243 rm -f "$OUT_DIR/gate"
244 parts=()
245 while IFS= read -r p; do parts+=("$p"); done < gpu/nvidia/driver/parts.txt
246 cat "${parts[@]}" | seed/out/omc > "$OUT_DIR/gate"
247 chmod 700 "$OUT_DIR/gate"
248 cases="$(grep -cv -e '^#' -e '^$' gpu/nvidia/driver/oracle-cases.tsv)"
249 kinds="$(grep -v -e '^#' -e '^$' gpu/nvidia/driver/oracle-cases.tsv | cut -f1 | sort -u | wc -l)"
250 rc=0; "$OUT_DIR/gate" gpu/nvidia/driver/oracle-cases.tsv > "$OUT_DIR/gate.log" || rc=$?
251 cat "$OUT_DIR/gate.log"
252 [ "$rc" -eq 0 ] || exit "$rc"
253 grep -qx "OMEGA-GPU-DRIVER PASS cases=$cases controls=$kinds caught=$kinds hardware=NOT_RUN" "$OUT_DIR/gate.log" ||
254 { echo "OMEGA-GPU-DRIVER FAIL: the summary line does not show every case and control of the table" >&2; exit 1; }
255 # The sequence gate: client.om (the setup and teardown of nvrm/ and m16/, ported from C) against the command
256 # sequences the C oracle recorded (seq-cases.tsv), with two controls for each distinct program.
257 rm -f "$OUT_DIR/seqgate"
258 parts=()
259 while IFS= read -r p; do parts+=("$p"); done < gpu/nvidia/driver/seqparts.txt
260 cat "${parts[@]}" | seed/out/omc > "$OUT_DIR/seqgate"
261 chmod 700 "$OUT_DIR/seqgate"
262 cases="$(grep -cv -e '^#' -e '^$' gpu/nvidia/driver/seq-cases.tsv)"
263 progs="$(grep -v -e '^#' -e '^$' gpu/nvidia/driver/seq-cases.tsv | cut -f2 | sort -u | wc -l)"
264 # seqgate reads a line into a 65536-byte array fixed at compile time and refuses a longer one; warn at half.
265 longest="$(awk '{ if (length($0) > m) m = length($0) } END { print m + 0 }' gpu/nvidia/driver/seq-cases.tsv)"
266 [ "$longest" -le 32768 ] ||
267 echo "OMEGA-GPU-DRIVER-SEQ ALARM: longest seq-cases.tsv line is $longest bytes, over half of seqgate's 65536-byte line array" >&2
268 rc=0; "$OUT_DIR/seqgate" gpu/nvidia/driver/seq-cases.tsv > "$OUT_DIR/seqgate.log" || rc=$?
269 tail -n 20 "$OUT_DIR/seqgate.log"
270 [ "$rc" -eq 0 ] || exit "$rc"
271 grep -qx "OMEGA-GPU-DRIVER-SEQ PASS cases=$cases programs=$progs controls=$((2 * progs)) caught=$((2 * progs)) hardware=NOT_RUN" "$OUT_DIR/seqgate.log" ||
272 { echo "OMEGA-GPU-DRIVER-SEQ FAIL: the summary line does not show every case and control of the table" >&2; exit 1; } ;;
273 # gpu/runtime/ (one slice of the work on CUDApp src/, the C runtime): the gate is seeded Omega, gpu/runtime/gate.om, built with
274 # seed/ng/sha256.om and gpu/runtime/zsha.om by seed/out/omc after that compiler's digest is checked; the gate checks
275 # it again. Its counts follow gpu/runtime/checks.tsv and controls.tsv, so the line is matched by its form.
276 gpu-runtime)
277 sha256sum -c --quiet seed/out/omc.sha256 || { echo "OMEGA-GPU-RUNTIME REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
278 rm -rf "$OUT_DIR/gate" "$OUT_DIR/work"
279 { printf 'om2\n'; cat seed/ng/sha256.om gpu/runtime/zsha.om gpu/runtime/gate.om; } | seed/out/omc > "$OUT_DIR/gate"
280 chmod 700 "$OUT_DIR/gate"
281 rc=0; "$OUT_DIR/gate" seed/out/omc "$OUT_DIR/work" > "$OUT_DIR/gate.log" || rc=$?
282 cat "$OUT_DIR/gate.log"
283 [ "$rc" -eq 0 ] || exit "$rc"
284 tail -1 "$OUT_DIR/gate.log" | grep -Eqx 'OMEGA-GPU-RUNTIME PASS checks=[1-9][0-9]* controls=([1-9][0-9]*) caught=\1 hardware=NOT_RUN' ||
285 { echo "OMEGA-GPU-RUNTIME FAIL: the summary line is not a PASS with every control caught" >&2; exit 1; } ;;
286 gpu-checks)
287 # The behaviour checks that replace CUDApp tests/ and tools/ (gpu/nvidia/checks/README.md). The expected
288 # counts come from checks.tsv (one row per check, one table control each) and mutants.tsv (one source-mutant
289 # control per row), so a row the gate skipped cannot pass unseen.
290 sha256sum -c --quiet seed/out/omc.sha256 || { echo "OMEGA-GPU-CHECKS REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
291 rm -rf "$OUT_DIR/gate" "$OUT_DIR/work"
292 { printf 'om2\n'; cat seed/ng/sha256.om gpu/nvidia/checks/gate.om; } | seed/out/omc > "$OUT_DIR/gate"
293 chmod 700 "$OUT_DIR/gate"
294 rc=0; "$OUT_DIR/gate" seed/out/omc "$OUT_DIR/work" > "$OUT_DIR/gate.log" || rc=$?
295 cat "$OUT_DIR/gate.log"
296 [ "$rc" -eq 0 ] || exit "$rc"
297 n=$(grep -c '^[A-Za-z0-9_]' gpu/nvidia/checks/checks.tsv)
298 m=$(grep -c '^[A-Za-z0-9_]' gpu/nvidia/checks/mutants.tsv)
299 c=$((n + m + 1))
300 grep -qx "OMEGA-GPU-CHECKS PASS checks=$n controls=$c caught=$c hardware=NOT_RUN" "$OUT_DIR/gate.log" ||
301 { echo "OMEGA-GPU-CHECKS FAIL: the summary line does not show $n checks and $c caught controls" >&2; exit 1; } ;;
302 # CUDA compatibility bridge (bridge/cuda/, one slice of CUDApp compat/: the compat/cuda profile): seeded Omega only. c0_check.om is the
303 # profile checker; fixture.om writes the PTX kernel, the link-only libcuda.so.1 stub and synthetic executables;
304 # gate.om replays CUDApp's compat/cuda/test.sh and compares its transcript with bridge/cuda/test-sh-84b524ca.txt.
305 # The control rebuilds c0_check with its "missing row" refusal removed; the gate must then fail.
306 # With BRIDGE_CUDA_CUDAPP (a CUDApp checkout at 84b524ca) and BRIDGE_CUDA_OLDOMC (omc 2c824805...) set, the gate also
307 # runs the old test.sh and gcc builds against the Omega stub, and requires oracle=PASS. Hardware stays NOT_RUN.
308 # The check counts in want= are pinned, as gpu-units pins its unit count; a change in gate.om's checks changes them here.
309 bridge-cuda)
310 sha256sum -c --quiet seed/out/omc.sha256 || { echo "BRIDGE-CUDA REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
311 rm -rf "$OUT_DIR"; mkdir -p "$OUT_DIR"
312 cat gpu/nvidia/om/cache/digest.om bridge/cuda/c0_check.om | seed/out/omc > "$OUT_DIR/c0_check"
313 seed/out/omc < bridge/cuda/fixture.om > "$OUT_DIR/fixture"
314 { printf 'om2\n'; cat seed/ng/sha256.om bridge/cuda/gate.om; } | seed/out/omc > "$OUT_DIR/gate"
315 sed 's/^rfl 55 l 1$/note rfl 55 l 1/' bridge/cuda/c0_check.om > "$OUT_DIR/mutant.om"
316 cmp -s bridge/cuda/c0_check.om "$OUT_DIR/mutant.om" && { echo "BRIDGE-CUDA FAIL: the control mutation did not apply" >&2; exit 1; }
317 cat gpu/nvidia/om/cache/digest.om "$OUT_DIR/mutant.om" | seed/out/omc > "$OUT_DIR/c0_mutant"
318 chmod 700 "$OUT_DIR/c0_check" "$OUT_DIR/fixture" "$OUT_DIR/gate" "$OUT_DIR/c0_mutant"
319 oracle=(); want='checks=27 failed=0 oracle=NOT_RUN'
320 if [ -n "${BRIDGE_CUDA_CUDAPP:-}" ] && [ -n "${BRIDGE_CUDA_OLDOMC:-}" ]; then
321 oracle=("$BRIDGE_CUDA_CUDAPP" "$BRIDGE_CUDA_OLDOMC" "${BRIDGE_CUDA_CC_AARCH64:-/usr/bin/gcc}" "${BRIDGE_CUDA_CC_X86_64:-/usr/bin/x86_64-linux-gnu-gcc}")
322 want='checks=34 failed=0 oracle=PASS'
323 fi
324 rc=0; "$OUT_DIR/gate" "$ROOT/$OUT_DIR/work" "$ROOT/$OUT_DIR/c0_check" "$ROOT/$OUT_DIR/fixture" "${oracle[@]}" > "$OUT_DIR/gate.log" 2>&1 || rc=$?
325 cat "$OUT_DIR/gate.log"
326 [ "$rc" -eq 0 ] || exit "$rc"
327 tail -1 "$OUT_DIR/gate.log" | grep -qx "BRIDGE-CUDA PASS $want hardware=NOT_RUN" ||
328 { echo "BRIDGE-CUDA FAIL: the summary line is not PASS with $want" >&2; exit 1; }
329 crc=0; "$OUT_DIR/gate" "$ROOT/$OUT_DIR/control" "$ROOT/$OUT_DIR/c0_mutant" "$ROOT/$OUT_DIR/fixture" > "$OUT_DIR/control.log" 2>&1 || crc=$?
330 if [ "$crc" -eq 0 ] || ! tail -1 "$OUT_DIR/control.log" | grep -q '^BRIDGE-CUDA FAIL '; then
331 echo "BRIDGE-CUDA FAIL: the mutant c0_check was not caught (rc=$crc)" >&2; exit 1
332 fi
333 echo "BRIDGE-CUDA CONTROL caught: $(tail -1 "$OUT_DIR/control.log")"
334 rm -rf "$OUT_DIR/work" "$OUT_DIR/control" ;;
335 # NVML library slice (bridge/nvml/, one slice of CUDApp compat/: compat/nvml): libnvidia-ml.c, nvml.h and
336 # libnvidia-ml.map are derived files, listed in bridge/nvml/derived.tsv and never stored here. gate.om (seeded Omega)
337 # checks the table and the source digests and compiles the source. With BRIDGE_NVML_TOC set (one or more omega-bridge
338 # src/toc.om paths, ':'-separated) it compiles each emitter and requires the pinned output digests; with
339 # BRIDGE_NVML_CUDAPP (a CUDApp checkout at 84b524ca) it requires CUDApp's committed files to have them too.
340 # Controls: a table with one source digest changed (always); with BRIDGE_NVML_TOC, api.om with one value changed
341 # (its digest re-pinned, so only the emitted bytes can catch it) and the first toc.om with one line added.
342 bridge-nvml)
343 sha256sum -c --quiet seed/out/omc.sha256 || { echo "BRIDGE-NVML REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
344 rm -rf "$OUT_DIR"; mkdir -p "$OUT_DIR"
345 { printf 'om2\n'; cat seed/ng/sha256.om bridge/nvml/gate.om; } | seed/out/omc > "$OUT_DIR/gate"
346 chmod 700 "$OUT_DIR/gate"
347 extra=(); emit=NOT_RUN; orc=NOT_RUN; tocs=()
348 if [ -n "${BRIDGE_NVML_TOC:-}" ]; then
349 IFS=: read -r -a tocs <<< "$BRIDGE_NVML_TOC"
350 for t in "${tocs[@]}"; do extra+=("toc=$t"); done; emit=PASS
351 fi
352 if [ -n "${BRIDGE_NVML_CUDAPP:-}" ]; then extra+=("cudapp=$BRIDGE_NVML_CUDAPP"); orc=PASS; fi
353 rc=0; "$OUT_DIR/gate" "$OUT_DIR/work" seed/out/omc bridge/nvml/derived.tsv "${extra[@]}" > "$OUT_DIR/gate.log" 2>&1 || rc=$?
354 cat "$OUT_DIR/gate.log"
355 [ "$rc" -eq 0 ] || exit "$rc"
356 tail -1 "$OUT_DIR/gate.log" | grep -qE "^BRIDGE-NVML PASS checks=[0-9]+ failed=0 emitter=$emit oracle=$orc\$" ||
357 { echo "BRIDGE-NVML FAIL: the summary line is not PASS with emitter=$emit oracle=$orc" >&2; exit 1; }
358 nvml_control() { # name table [args...]: the gate must report FAIL
359 local name="$1" table="$2"; shift 2
360 local crc=0; "$OUT_DIR/gate" "$OUT_DIR/c-$name" seed/out/omc "$table" "$@" > "$OUT_DIR/c-$name.log" 2>&1 || crc=$?
361 if [ "$crc" -ne 1 ] || ! tail -1 "$OUT_DIR/c-$name.log" | grep -q '^BRIDGE-NVML FAIL '; then
362 echo "BRIDGE-NVML FAIL: control $name was not caught (rc=$crc)" >&2; exit 1
363 fi
364 echo "BRIDGE-NVML CONTROL $name caught: $(grep -m1 '^FAIL ' "$OUT_DIR/c-$name.log" | cut -c1-160) | $(tail -1 "$OUT_DIR/c-$name.log")"
365 }
366 src=gpu/nvidia/native/nvml/api.om; ssum="$(sha256sum "$src" | cut -d' ' -f1)"
367 sed "0,/\t$ssum\t/s//\t0${ssum:1}\t/" bridge/nvml/derived.tsv > "$OUT_DIR/pin.tsv"
368 cmp -s bridge/nvml/derived.tsv "$OUT_DIR/pin.tsv" && { echo "BRIDGE-NVML FAIL: the table mutation did not apply" >&2; exit 1; }
369 nvml_control pin "$OUT_DIR/pin.tsv"
370 if [ "${#tocs[@]}" -gt 0 ]; then
371 sed 's/^note cabi value nvmlReturn_t NVML_ERROR_IRQ_ISSUE 11$/note cabi value nvmlReturn_t NVML_ERROR_IRQ_ISSUE 111/' "$src" > "$OUT_DIR/api-mutant.om"
372 cmp -s "$src" "$OUT_DIR/api-mutant.om" && { echo "BRIDGE-NVML FAIL: the source mutation did not apply" >&2; exit 1; }
373 msum="$(sha256sum "$OUT_DIR/api-mutant.om" | cut -d' ' -f1)"
374 sed "s|\t$src\t$ssum\t|\t$OUT_DIR/api-mutant.om\t$msum\t|" bridge/nvml/derived.tsv > "$OUT_DIR/source.tsv"
375 nvml_control source "$OUT_DIR/source.tsv" "${extra[@]}"
376 { cat "${tocs[0]}"; printf 'note bridge-nvml control: one added line\n'; } > "$OUT_DIR/toc-mutant.om"
377 nvml_control toc bridge/nvml/derived.tsv "toc=$OUT_DIR/toc-mutant.om"
378 fi
379 rm -rf "$OUT_DIR"/work "$OUT_DIR"/c-* ;;
380 # Omega-built shared libraries (bridge/shlib): the generator bridge/shlib/shlib.om and the gate
381 # bridge/shlib/gate.om, both seeded Omega built by seed/out/omc after its digest is checked; the gate checks it
382 # again. Host only: the probes load the libraries through the system's dynamic loader; no device is opened.
383 shlib)
384 sha256sum -c --quiet seed/out/omc.sha256 || { echo "OMEGA-SHLIB REFUSED: seed/out/omc differs from seed/out/omc.sha256" >&2; exit 69; }
385 rm -rf "$OUT_DIR/gate" "$OUT_DIR/shlib" "$OUT_DIR/work"
386 mkdir -p "$OUT_DIR"
387 { printf 'om2\n'; cat seed/ng/sha256.om bridge/shlib/gate.om; } | seed/out/omc > "$OUT_DIR/gate"
388 seed/out/omc < bridge/shlib/shlib.om > "$OUT_DIR/shlib"
389 chmod 700 "$OUT_DIR/gate" "$OUT_DIR/shlib"
390 rc=0; "$OUT_DIR/gate" seed/out/omc "$OUT_DIR/shlib" "$OUT_DIR/work" > "$OUT_DIR/gate.log" || rc=$?
391 cat "$OUT_DIR/gate.log"
392 [ "$rc" -eq 0 ] || exit "$rc"
393 grep -qx 'OMEGA-SHLIB PASS checks=34 controls=34 caught=34' "$OUT_DIR/gate.log" ||
394 { echo "OMEGA-SHLIB FAIL: the summary line does not show the expected checks and controls" >&2; exit 1; } ;;
395 # Standalone backend qualification: these execute the current sources, never
396 # accept an old receipt, and leave unavailable dependencies nonpassing (exit 3).
397 # They are separate from seed so CPU OpenCL is not required by every host check.
398 irwasm)
399 sh seed/wasm/gate-irwasm.sh 2>&1 | tee "$OUT_DIR/qualification.log"
400 if ! grep -q '^PASS IRWASM native parity cases=' "$OUT_DIR/qualification.log" ||
401 ! grep -q '^PASS v7 run parity cases=' "$OUT_DIR/qualification.log" ||
402 ! grep -q '^PASS v7 OOB traps=.*no-bounds mutant caught' "$OUT_DIR/qualification.log"; then
403 echo "FAIL IRWASM incomplete qualification evidence" >&2
404 exit 1
405 fi
406 ;;
407 irspirv)
408 # CPU OpenCL only. This is not Vulkan or physical GPU qualification.
409 sh seed/spirv/gate-irspirv.sh 2>&1 | tee "$OUT_DIR/qualification.log"
410 if ! grep -q '^PASS IRSPIRV CPU OpenCL parity cases=' "$OUT_DIR/qualification.log"; then
411 echo "FAIL IRSPIRV incomplete qualification evidence" >&2
412 exit 1
413 fi
414 ;;
415 # omega-mv#731 ORIG-4 (no hosted mirror; host only): the shadow advisor's glue over the
416 # pinned aien-train units (native/orig4/orig4.pin, one aien-train main commit), materialised
417 # under build/pins from the sibling clone; every verdict is made by the .om units.
418 orig4-shadow)
419 train_sha="$(awk '$1 == "unit" && $3 == "aien-train" {print $4; exit}' native/orig4/orig4.pin)"
420 pin aien-train-src aien-train "$train_sha"
421 set -o pipefail
422 OUT="$ROOT/$OUT_DIR/orig4" ORIG4_TRAIN_GIT="$PINS/aien-train-src" \
423 sh tests/orig4/run.sh | tee "$OUT_DIR.orig4.log"
424 grep -q '^ORIG4_SHADOW_RUN_PASS$' "$OUT_DIR.orig4.log"
425 obs shadow_test_checks "$(sed -n 's/.*ORIG4_SHADOW_TEST_PASS checks=\([0-9]*\).*/\1/p' "$OUT_DIR.orig4.log" | head -n 1)"
426 obs cost_wall_ms_mlp "$(sed -n 's/^COST_WALL records=780 ms=\([0-9]*\) image=mlp fixture$/\1/p' "$OUT_DIR.orig4.log" | head -n 1)"
427 ;;
428 # host-suites-2.yml
429 visor) aienos_pin; make $NOPHYS test-visor ;;
430 turing) make $NOPHYS test-turing; make $NOPHYS test-turing-exp001-a test-turing-exp001-coders; make $NOPHYS test-turing-verify-indep; make $NOPHYS test-turing-qcont test-turing-qrecord ;;
431 brownian) make $NOPHYS test-brownian-tps; make $NOPHYS test-brownian-active ;;
432 polyglot) make $NOPHYS test-polyglot-asm; make $NOPHYS test-polyglot-encoder ;;
433 algebra) make $NOPHYS test-algebra test-algebra-asan; make $NOPHYS test-realize; make $NOPHYS test-phase-twin; make $NOPHYS test-ma-digital-bottom ;;
434 path) make $NOPHYS test-path ;;
435 crumbline) make $NOPHYS test-crumbline test-library test-vcstore test-resolve test-vcstore-genesis test-resolve-genesis test-genesis test-genesis-real test-program-ir test-vc-bridge ;;
436 runtime)
437 physics_pin; aienos_pin
438 # host-suites-2.yml sets only PHYSICS_DIR and AIENOS_R7_DIR, and only on the steps that list
439 # them; the qualify self-test and the aienos.lock source proof run with neither (the latter
440 # checks the default cache, which an inherited AIENOS_R7_DIR override would bypass).
441 unset AIENOS_COMMIT OMEGA_CANDIDATE_COMMIT
442 make test-r15-instr
443 make test-r15-receipt
444 make test-r15-preflight test-r15-g15-diag
445 make test-r16-inventory
446 make test-r16-negative
447 make test-r16-surface
448 make test-r16-negative-mutants
449 env -u PHYSICS_DIR -u AIENOS_R7_DIR make test-r16-qualify-selftest
450 env -u PHYSICS_DIR -u AIENOS_R7_DIR make test-aienos-lock-source
451 make test-allen
452 ;;
453 argus)
454 physics_pin; aienos_pin; argus_pin
455 ARGUS_STREAMS="$(mktemp -d /tmp/argus-streams.XXXXXX)"; export ARGUS_STREAMS
456 make test-argus-runtime test-machine-identity-argus
457 ;;
458 bw-hazard) # omega-mv#554 scoreboard hazards, then the elementwise host test (DRA-344: RSQ listing,
459 # n=0 refusal, MUFU flush model); host only, no device
460 physics_pin; make test-bw-hazard; make test-gpu-elementwise ;;
461 numeric2) make $NOPHYS test-numeric-reduce-cpu test-divsqrt-host ;;
462 tensor) make $NOPHYS test-tensor; make $NOPHYS test-tensor-store; make $NOPHYS test-m20-receipt; make $NOPHYS test-tensor-mutations ;;
463 atomf32-probe-host) # host-suites-2.yml gpu-engine job, "f32 global atomic add probe in the warp simulator" step:
464 # physics-src at physics.lock; host, no device (the chip run is by hand)
465 physics_pin; make test-atomf32-probe-host ;;
466 gpu-decode-graph) physics_pin; make test-gpu-decode-graph ;;
467 gpu-prefill-host) # omega-mv#1032 (from #456): REQUIRED, first-party prefill host-only tests (3 probes); no device,
468 # no model-shape cases, no OWN-30B build (those run in gpu-prefill-modelshapes)
469 physics_pin; set -o pipefail; mkdir -p "$OUT_DIR"
470 env -i PATH="$PATH" HOME="$HOME" OUT_DIR="$OUT_DIR" PHYSICS_DIR="$PHYSICS_DIR" make -f Makefile test-gpu-prefill-host-fp | tee "$OUT_DIR/prefill-host.log"
471 grep -qx 'test-gpu-prefill-host-fp: PASS (3 first-party prefill tests, host model, no device)' "$OUT_DIR/prefill-host.log"
472 ;;
473 gpu-prefill-modelshapes) # omega-mv#1032: OPTIONAL lane (requires: operator): model-shape prefill cases + the OWN-30B -Werror build
474 physics_pin; set -o pipefail; mkdir -p "$OUT_DIR"
475 env -i PATH="$PATH" HOME="$HOME" OUT_DIR="$OUT_DIR" PHYSICS_DIR="$PHYSICS_DIR" make -f Makefile test-gpu-prefill-modelshapes check-own30b-decode-profile | tee "$OUT_DIR/prefill-modelshapes.log"
476 grep -qx 'test-gpu-prefill-modelshapes: PASS (5 model-shape prefill tests, host model + warp simulator, no device)' "$OUT_DIR/prefill-modelshapes.log"
477 grep -qx 'check-own30b-decode-profile: PASS (compiles with -Werror)' "$OUT_DIR/prefill-modelshapes.log"
478 ;;
479 # host-suites-3.yml
480 numeric-lifecycle) make $NOPHYS test-numeric-lifecycle ;;
481 numeric-transc-digest)
482 set -o pipefail; mkdir -p build
483 make $NOPHYS test-numeric-transc-digest | tee build/digest.log
484 n=$(grep -c 'matches frozen digest' build/digest.log); obs frozen_digests_matched "$n"
485 test "$n" -ge 1
486 ;;
487 gpu-attention) # host-suites-3.yml gpu-attention (omega#470): physics-src at physics.lock, lock check on;
488 # host-only, sim and sweep tiers, nothing touches a GPU (the Spark has nvdisasm, so the
489 # listing check runs here where the hosted runner printed "skipped")
490 physics_pin; set -o pipefail; mkdir -p build
491 make -j"$(nproc)" test-gpu-attention | tee build/attn.log
492 test "$(grep -cE '^PASS: [0-9]+ checks, 0 failed$' build/attn.log)" -eq 6
493 ! grep -qE '^FAIL' build/attn.log
494 ;;
495 sm121dis) # L386 bar C6 (docs/OMEGA.md): Omega's own sm_121 disassembler. Host only. Every kernel the
496 # library builds, decoded by build/sm121dis and compared word for word with nvdisasm (the
497 # offline oracle the Spark has), plus the faulty-decoder red check; then ZERO-NVDISASM: the
498 # listing and provenance checks under a decoy nvdisasm and strace, plus its planted-call red check.
499 physics_pin; set -o pipefail; mkdir -p build
500 make -j"$(nproc)" test-sm121dis | tee build/sm121dis.log
501 grep -qE '^kernels: [0-9]+, words: [0-9]+, failed kernels: 0$' build/sm121dis.log
502 grep -qE '^red check: the faulty decoder FAILS the comparison' build/sm121dis.log
503 make test-zero-nvdisasm | tee build/zero-nvdisasm.log
504 grep -qE '^ZERO-NVDISASM: PASS' build/zero-nvdisasm.log
505 grep -qE '^red check: the planted nvdisasm calls FAIL the gate' build/zero-nvdisasm.log
506 ;;
507 gpu-libm-free) # omega-mv#471: no libm symbol left undefined in libomega_gpu.a (physics-src at physics.lock)
508 physics_pin; set -o pipefail; mkdir -p build
509 make -j"$(nproc)" test-gpu-libm-free | tee build/libm-free.log
510 grep -q '^PASS: libomega_gpu.a is libm-free$' build/libm-free.log
511 ;;
512 numeric-transc-full) make $NOPHYS test-numeric-transc-full ;;
513 m6|m7|m8|m9|m10|m11|m12|m13|m14|m15|m17|m5|m19|m19r-qualify|gate14-combine)
514 physics_pin; set -o pipefail; mkdir -p build
515 make "test-$step" | tee "build/gate-$step.log"
516 gates_pass "build/gate-$step.log"
517 ;;
518 # rx-host.yml
519 rx-host-reference)
520 physics_pin; export PHYSICS_COMMIT="$(lock physics.lock)"
521 aienos_pin; set -o pipefail; mkdir -p build
522 # The hosted job runs these as one make line; the speed test test-action-graph is taken out (speed,
523 # above) so a busy machine is a refusal and the targets after it still run, in the same order.
524 # All test output also goes to build/rx-host-reference.log, so a step that hits its time limit
525 # leaves a record of the test that was running. speed runs in this shell (BUSY), so its output
526 # reaches the log through a process substitution, not a pipe.
527 make test-r3 test-r7 test-r16-operator-authority-misuse test-r8 test-r9 test-r12 test-rx-emergency | tee build/rx-host-reference.log
528 speed test-action-graph rx_action_graph_receipt.json OMEGA_ACTION_GRAPH_IR_PASS > >(tee -a build/rx-host-reference.log)
529 make test-state-projection test-capability-query test-capability-graph test-skillroute-compose test-semantic-comm test-cognitive-routing test-sem-incremental test-cortex test-jspace-prod test-composition test-composition-attach-asan test-composition-gate test-fabric test-fabric-living | tee -a build/rx-host-reference.log
530 make test-machine-identity | tee -a build/rx-host-reference.log
531 make test-effect-cap64 | tee build/effect-cap64.log
532 grep -q '^OMEGA_EFFECT_CAP64_PASS$' build/effect-cap64.log
533 receipt omega_state_projection_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_STATE_PROJECTION_PASS": "PASS"'
534 # omega-mv#404 item 2: PASS means the package energy counter (hwmon aien_spbm, found by the
535 # same name-prefix test rx_sem_incremental uses) measured the work; HOST_PASS_ENERGY_UNMEASURED
536 # means this host has no such counter. The verdict must match this host; PASS_UNBOUND and FAIL
537 # never pass. Which one ran is recorded as an observation.
538 if grep -qs '^aien_spbm' /sys/class/hwmon/*/name; then inc_verdict=PASS; else inc_verdict=HOST_PASS_ENERGY_UNMEASURED; fi
539 receipt omega_incremental_semantics_receipt.json "\"OMEGA_INCREMENTAL_SEMANTICS_PASS\": \"$inc_verdict\"" '"false_hits": 0,'
540 obs incremental_semantics_verdict "\"$inc_verdict\""
541 receipt rx_capability_query_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_CAPABILITY_QUERY_PASS": "PASS"'
542 receipt rx_semantic_comm_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_SEMANTIC_COMMUNICATION_PASS": "PASS"'
543 receipt rx_cognitive_routing_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_COGNITIVE_ROUTING_PASS": "PASS"'
544 speed test-workflow-fusion rx_workflow_fusion_receipt.json OMEGA_WORKFLOW_FUSION_PASS
545 make test-typed-results
546 receipt rx_typed_results_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_TYPED_RESULT_CONSTRAINTS_PASS": "PASS"'
547 make test-costmodel
548 receipt rx_aegis_resident_receipt.json '"failures": 0,' '"candidate_bound": true,' '"R8_CONSTITUTIONAL_AEGIS": "PASS"'
549 r="$(find build/qual-runs -name rx_heartbeat_receipt.json -type f -newer "$STEP_MARK" | head -n 1)"
550 native="$(find build/qual-runs -name rx_native_authority_receipt.json -type f -newer "$STEP_MARK" | head -n 1)"
551 generation="$(find build/qual-runs -name rx_generation_barrier_receipt.json -type f -newer "$STEP_MARK" | head -n 1)"
552 test -n "$r"; test -n "$native"; test -n "$generation"
553 if git diff --quiet && git diff --cached --quiet; then obs tree_cleanliness '"clean"'; else obs tree_cleanliness '"dirty"'; fi
554 tools/rx_host_receipts.sh heartbeat "$r"
555 tools/rx_host_receipts.sh native "$native" "$OMEGA_CANDIDATE_COMMIT"
556 tools/rx_host_receipts.sh generation "$generation" "$OMEGA_CANDIDATE_COMMIT"
557 if [ "$BUSY" = 1 ]; then obs not_run_reason "\"$BUSY_REASON\""; exit 77; fi
558 ;;
559 faculty-arm)
560 physics_pin
561 aienos_pin; argus_pin; set -o pipefail; mkdir -p build
562 make OUT_DIR=build/pid $NOPHYS test-program-id
563 make OUT_DIR=build/prz $NOPHYS test-program-realize
564 R10_ALLOW_NO_WIN=1 make test-r10
565 receipt rx_omega_faculty_receipt.json '"failures": 0,' '"candidate_bound": true,' '"tree_dirty": false,'
566 make test-regulate
567 make test-r11
568 receipt rx_aien_faculty_receipt.json '"failures": 0,' '"candidate_bound": true,' '"tree_dirty": false,'
569 make "$OUT_DIR/rx_r13_living_host" "$OUT_DIR/rx_r13_living_testbuild_host"
570 make "$OUT_DIR/rx_r14_recovery_host"
571 make test-r16-authpath-linkmap | tee build/r16-g3-linkmap-host.log
572 grep -qx 'R16-G3 static: R16_G3_LINKMAP=STATIC_PASS mode=host (checks 1-3 of 5 on this build; not the gate)' build/r16-g3-linkmap-host.log
573 grep -qx 'R16 gate: R16_G3_AUTHPATH=NOT_RUN (checks 4-5, exec trace and living run, not run in static-only mode)' build/r16-g3-linkmap-host.log
574 make test-r16-authpath-linkmap-silicon | tee build/r16-g3-linkmap-silicon.log
575 grep -qx 'R16-G3 static: R16_G3_LINKMAP=STATIC_PASS mode=silicon (checks 1-3 of 5 on this build; not the gate)' build/r16-g3-linkmap-silicon.log
576 grep -qx 'R16 gate: R16_G3_AUTHPATH=NOT_RUN (checks 4-5, exec trace and living run, not run in static-only mode)' build/r16-g3-linkmap-silicon.log
577 make test-prod-hygiene | tee build/prod-hygiene-host.log
578 grep -q '^R16 prod: PROD_HYGIENE=PASS mode=host ' build/prod-hygiene-host.log
579 R16_PROD_NO_RUN=1 make test-prod-hygiene-silicon | tee build/prod-hygiene-silicon.log
580 grep -q '^R16 prod: PROD_HYGIENE=PASS mode=silicon ' build/prod-hygiene-silicon.log
581 make test-prod-refuses-test-pieces | tee build/prod-refuses.log
582 grep -q '^R16 prod: PROD_REFUSES_TEST_PIECES=PASS ' build/prod-refuses.log
583 EMPIRICAL_ALLOW_NO_WIN=1 make test-empirical
584 receipt rx_empirical_optimizer_receipt.json '"failures": 0,' '"candidate_bound": true,' '"tree_dirty": false,' '"mismatches": 0,' '"OMEGA_EMPIRICAL_OPTIMIZER_PASS": "\(PASS\|CHAIN_PASS_NO_WIN\)"'
585 PLAN_REUSE_NO_ENERGY=1 make test-plan-reuse
586 receipt 'rx_plan_reuse_receipt.*.json' '"failures": 0,' '"G3_outcome_and_evidence": "PASS"' '"G4_false_applicability_zero": "PASS"' '"G5_identity": "PASS"'
587 make test-rx-deadline-cancel
588 make test-i11-wake-merge
589 make test-c4-requal
590 ;;
591 # rx-host.yml chip-only-declared and spark-only targets (SKIP on GitHub, never a pass there)
592 chip:*|spark:*)
593 t="${step#*:}"
594 # Chip and spark steps follow physics.lock like every other step. Makefile check-physics-lock
595 # (a prerequisite of omegatool, rx_composition_gate_gpu and libomega_gpu.a) refuses any other
596 # physics commit, and omegatool itself now needs the physics API of the lock (nvrm_channel_n,
597 # L136 via #614). The former hard-coded physics literal failed every such chip gate on the judge
598 # once #614 moved the lock to 048e5f5 (main 18c653b3, 2026-10-25).
599 physics_pin
600 aienos_pin; argus_pin
601 make "$t"
602 ;;
603 # turing-yield.yml
604 turing-yield) make test-turing-yield test-turing-energy test-turing-range-om ;;
605 # evidence-immutable.yml: reviewed evidence is additions-only. Hosted compares the PR base
606 # and head; locally the base is origin/main (or AIEN_BASE_REF).
607 evidence-immutable)
608 base="${AIEN_BASE_REF:-origin/main}"
609 obs base_ref "\"$(git rev-parse "$base")\""
610 changed="$(git diff --name-status --diff-filter=MDRT "$base...HEAD" -- evidence/)"
611 if [ -n "$changed" ]; then
612 echo "These existing evidence files would be changed:"; echo "$changed"
613 echo "Add a new, content-addressed file instead of rewriting reviewed evidence."
614 obs evidence_rewrites "$(printf '%s\n' "$changed" | grep -c .)"
615 exit 1
616 fi
617 obs evidence_rewrites 0
618 echo "evidence/: additions only"
619 ;;
620 zero-disk-secrets)
621 echo "Auditing repository for prohibited plaintext secret files..."
622 # Inspect every tracked path, including forced additions under generated dirs.
623 # NUL records preserve whitespace/newlines; producer failures are not "no hits".
624 if ! git ls-files -z > "$OUT_DIR/secret-tracked"; then
625 echo "::error::Cannot enumerate tracked paths." >&2; exit 1
626 fi
627 while IFS= read -r -d '' path; do
628 case "${path##*/}" in
629 .env*) echo "::error::Tracked plaintext .env path found."
630 obs env_files_found true; exit 1 ;;
631 esac
632 done < "$OUT_DIR/secret-tracked"
633 # Also catch untracked working-tree secrets. Only root build output and git
634 # metadata are excluded; tracked files in build were already checked above.
635 if ! find . \( -path './.git' -o -path './build' \) -prune -o \
636 -name '.env*' -print -quit > "$OUT_DIR/secret-untracked"; then
637 echo "::error::Cannot complete plaintext secret search." >&2; exit 1
638 fi
639 if [ -s "$OUT_DIR/secret-untracked" ]; then
640 echo "::error::Prohibited plaintext .env file found. Use an approved AIEN SecretProvider."
641 obs env_files_found true; exit 1
642 fi
643 obs env_files_found false
644 echo "Zero plaintext .env files verified."
645 ;;
646 runtime-api) # omega-mv#594: the Runtime API manifest against the C headers, plus its negative controls.
647 # Host only (gcc for -aux-info), no GPU, no physics checkout.
648 make $NOPHYS test-runtime-api ;;
649 arboris-gated-silicon)
650 sh seed/omega-from-seed.sh
651 OMC="$ROOT/seed/out/omc" sh tests/arboris/host.sh "$OUT_DIR"
652 for model in gated wide experimental; do
653 log="$OUT_DIR/$model-device.log"
654 "$OUT_DIR/caproot-issuer" "$OUT_DIR/$model-chip" --arboris-silicon > "$log" || { cat "$log"; exit 1; }
655 cat "$log"
656 case "$model" in
657 gated) halves=40; output=ad8a70b5e2935b7fca819ce4823afea8bef95c56135b6d86e7cf4ada6f16a089 ;;
658 experimental) halves=1320; output=c2437a10406d7aa8902c0a46eeca1b00413461689a8345cb0f62927d6b742fe5 ;;
659 wide) halves=1320; output=ca8052acb8c6306df043531ab6c116c5d8dd69a7e565974338088119f8355e34 ;;
660 esac
661 grep -Eq '^step_message=4152425354503032[0-9a-f]{352}$' "$log"
662 grep -qx "matching_fp16_elements=$halves" "$log"
663 grep -qx "kernel_sha256=$(sha256sum "$OUT_DIR/$model.sass" | cut -d' ' -f1)" "$log"
664 grep -qx "output_sha256=$output" "$log"
665 done
666 ;;
667 arboris-sparse-silicon)
668 sh seed/omega-from-seed.sh
669 OMC="$ROOT/seed/out/omc" sh tests/arboris/host.sh "$OUT_DIR"
670 for model in sparse small wave persistent hubs even; do
671 log="$OUT_DIR/arboris-$model.log"
672 "$OUT_DIR/caproot-issuer" "$OUT_DIR/$model-chip" --arboris-silicon > "$log" || {
673 cat "$log"
674 exit 1
675 }
676 cat "$log"
677 case "$model" in
678 even) words=24576; code=even.bin; output=48a04a4fc0bb0f8e14dca0855e21a1d239faec514a9e1d5c6696f273a798842d ;;
679 persistent) words=258; code=persistent.bin; output=125cb0ac528c34014d14a0b99ac75afcf8e21cbd6b3a4845070bd9d5ab638ba4 ;;
680 hubs) words=258; code=hubs.bin; output=d1a4e4639301e305a4f7768d14e642153ff5d4b2743bb011009ca9a5358a299b ;;
681 sparse) words=200000; code=relax.bin; output=8ded4456ffe03d54cad43b7b7b8d07ff1997919c103dd1b49b61c6782d6e3d19 ;;
682 small) words=4096; code=small.bin; output=33dfc6bc867a2bfbe09192038538c209c9b8bc89e16b6cedcaf0e7cf32b1a8f6 ;;
683 wave) words=400000; code=wave.bin; output=b2d9f9458d97db2f5415078fbc43ad0256229175bbc28127eeaad941a708dc7a ;;
684 esac
685 grep -Eq '^step_message=4152425354503032[0-9a-f]{352}$' "$log"
686 grep -qx "matching_fp32_words=$words" "$log"
687 grep -qx "kernel_sha256=$(sha256sum "$OUT_DIR/$code" | cut -d' ' -f1)" "$log"
688 grep -qx "output_sha256=$output" "$log"
689 done
690 ;;
691 arboris)
692 sh seed/omega-from-seed.sh > "$OUT_DIR/seed.log" 2>&1
693 OMC="$ROOT/seed/out/omc" sh tests/arboris/host.sh "$OUT_DIR"
694 ;;
695 om-units) # The C entry points whose algorithm is Omega (om/units.sh): omc born from the seed here,
696 # the generator pinned by om/omega-bridge.lock; regenerated binding, SHA-256 and BLAKE3
697 # byte parity against the C they replaced, and the BLAKE3 mutants. NOT_RUN (3) without tools.
698 # Then the program-mode om/blake3/blake3.om output contract (#726): digest, /dev/full, closed stdout.
699 pin omega-bridge omega-bridge "$(lock om/omega-bridge.lock)"
700 sh seed/omega-from-seed.sh > build/om-units-seed.log 2>&1 || { tail -3 build/om-units-seed.log; exit 1; }
701 export OMEGA_OMC="$ROOT/seed/out/omc" OMEGA_BRIDGE="$PINS/omega-bridge"
702 obs omc_sha256 "\"$(sha256sum < "$OMEGA_OMC" | cut -c1-64)\""
703 sh om/units.sh --check
704 sh om/sha256/parity/run.sh
705 sh om/blake3/parity/run.sh
706 "$OMEGA_OMC" < om/blake3/blake3.om > build/om-units-blake3 && chmod 700 build/om-units-blake3
707 sh om/blake3/test-output.sh build/om-units-blake3
708 ;;
709 tilelab) # omega#906: native .om tile planner and streaming (m,s,p) softmax. omc born from the seed
710 # here, then seed/tilelab/gate.sh (expected output, mutants failing for their own reason).
711 sh seed/omega-from-seed.sh > build/tilelab-seed.log 2>&1 || { tail -3 build/tilelab-seed.log; exit 1; }
712 obs omc_sha256 "\"$(sha256sum < seed/out/omc | cut -c1-64)\""
713 sh seed/tilelab/gate.sh
714 ;;
715 trace) # omega#608: local trace segment (seed/trace/segment.om), built by the committed seed/out/omc
716 # after its recorded SHA-256 is checked: 71 checks against expected.txt (torn-tail recovery
717 # keeps N-1 records, CRC/length/sequence damage, header refusals, O_EXCL, O_NOFOLLOW) and
718 # 4 source mutants (CRC check, torn tail, alignment, O_EXCL) that must each fail their check.
719 sha256sum -c seed/out/omc.sha256
720 obs omc_sha256 "\"$(sha256sum < seed/out/omc | cut -c1-64)\""
721 sh seed/trace/gate.sh
722 ;;
723 tracecli) # omega#610: offline read-only trace CLI (seed/trace/tracecli.om), built by the
724 # committed seed/out/omc after its recorded SHA-256 is checked. Golden stdout and
725 # exit codes, a mode-0000 refusal, and 4 source mutants (partial exit, compare
726 # equality, type filter, read-only open flags) that must each fail their own check.
727 sha256sum -c seed/out/omc.sha256
728 obs omc_sha256 "\"$(sha256sum < seed/out/omc | cut -c1-64)\""
729 sh seed/trace/cli-gate.sh
730 ;;
731 security758) # omega#758 (#774): relational comparison suite under seed/qualification/security673/relational,
732 # run by the OM-2 case gate rebuilt from seed/qualification/om2/gate.om with the committed
733 # seed/out/omc (sha checked) and the scanner seed/qualification/om2/leak/leakscan.om. Exits
734 # 0/0/0 for qualification/bindings/consumer, 1 with exactly the two intended FAIL rows for
735 # binding-negative; the L4 secret-dividend scanner PASS is a separate tripwire, not a total.
736 sha256sum -c seed/out/omc.sha256
737 OMC=seed/out/omc; H="$(cut -c1-64 seed/out/omc.sha256)"
738 obs omc_sha256 "\"$H\""
739 R=seed/qualification/security673/relational
740 sec="$OUT_DIR/security758"; rm -rf "$sec"; mkdir -p "$sec"
741 "$OMC" < seed/qualification/om2/gate.om > "$sec/gate.bin"; chmod 700 "$sec/gate.bin"
742 obs gate_sha256 "\"$(sha256sum < "$sec/gate.bin" | cut -c1-64)\""
743 sec_run() { local rc=0; "$sec/gate.bin" "$OMC" "$H" "$R/$1.cases" "$sec/$1" > "$sec/$1.log" 2>&1 || rc=$?
744 tail -1 "$sec/$1.log"; [ "$rc" = "$2" ] || { echo "SECURITY758 FAIL $1.cases exit=$rc expected=$2" >&2; exit 1; }; }
745 sec_run qualification 0; sec_run bindings 0; sec_run consumer 0; sec_run binding-negative 1
746 grep -qx 'OM2GATE FAIL cases=2 pass=0 fail=2 invalid=0 not_run=0' "$sec/binding-negative.log"
747 grep -q '^VERDICT wrong-source-bytes FAIL ' "$sec/binding-negative.log"
748 grep -q '^VERDICT wrong-checker-bytes FAIL ' "$sec/binding-negative.log"
749 echo "SECURITY758 PASS qualification consumer bindings, binding-negative 2 intended FAIL rows"
750 sec_run l4-tripwire 0
751 echo "SECURITY758 TRIPWIRE L4-division-gap: scanner still PASSES a secret dividend (known false negative, README L4; not a qualification)"
752 ;;
753 native) # omega#663/#664: native .om units built by the committed seed/out/omc after its recorded
754 # SHA-256 is checked. The metadata test must pass and each recorded ECOSYSTEM663 mutant must
755 # exit 1; with native/autodiff664 present, its tape suite (test + 3 compiled mutants) and the
756 # C M21 fixture replay (CPU table, value-exact, mutant-sign control must FAIL) run too.
757 sha256sum -c seed/out/omc.sha256
758 OMC="$ROOT/seed/out/omc"
759 obs omc_sha256 "\"$(sha256sum < "$OMC" | cut -c1-64)\""
760 nat="$OUT_DIR/native"; rm -rf "$nat"; mkdir -p "$nat"
761 native_build() { "$OMC" < "$1" > "$2" && [ "$(od -An -tx1 -N4 "$2" | tr -d ' ')" = 7f454c46 ] && chmod 700 "$2"; }
762 cat native/ecosystem663/metadata.om tests/ecosystem663/metadata-test.om > "$nat/metadata-test.om"
763 native_build "$nat/metadata-test.om" "$nat/metadata-test.elf"
764 "$nat/metadata-test.elf" > "$nat/metadata-test.stdout"
765 grep "^M20_METADATA_V1_PASS checks=" "$nat/metadata-test.stdout"
766 for m in evidence/ECOSYSTEM663/mutant-*.om; do
767 native_build "$m" "$nat/mutant.elf"
768 rc=0; "$nat/mutant.elf" > /dev/null 2>&1 || rc=$?
769 [ "$rc" = 1 ] || { echo "run.sh: $m was not rejected (exit $rc, need 1)" >&2; exit 1; }
770 echo "mutant $m: exit 1 as required"
771 done
772 if [ -d native/autodiff664 ]; then
773 OMC="$OMC" OUT="$ROOT/$nat/tape" sh tests/autodiff664/run-tape.sh
774 make $NOPHYS test-autodiff-fixture FIXTURE=tests/fixtures/autodiff664/adtrain.fix
775 fi
776 ;;
777 trinary) # T-002 trit/codebook signal tools (tools/trit, tools/codebook), host only, no device. Built by the
778 # committed seed/out/omc after its recorded SHA-256 is checked (the compiler is not retyped here).
779 # Builds both binaries, runs both fixture suites (a SKIP is not a pass), the codebook mutant list,
780 # the regression for the trit mutation driver itself, the trit mutation driver (every mutant applied,
781 # built and killed by test.sh; difftest kills the read-mode ones), the Lean differential of trit.bin
782 # against TritSignal.lean, and the existing Lean proofs (compilation and reported theorem axioms).
783 # Needs python3, perl, strace, lean, cmp and timeout: without them NOT_RUN (exit 3).
784 sha256sum -c seed/out/omc.sha256
785 OMC="$ROOT/seed/out/omc"; export OMC
786 obs omc_sha256 "\"$(sha256sum < "$OMC" | cut -c1-64)\""
787 for t in python3 perl lean strace cmp timeout; do
788 command -v "$t" >/dev/null 2>&1 || { echo "run.sh: trinary NOT_RUN: $t is not installed" >&2; exit 3; }
789 done
790 tri=$(mktemp -d "$OUT_DIR/trinary.XXXXXX")
791 export TMPDIR="$ROOT/$tri"
792 obs lean_version "\"$(lean --version)\""
793 obs python_version "\"$(python3 --version)\""
794 obs perl_version "\"$(perl -e 'printf "%vd", $^V')\""
795 obs strace_version "\"$(strace --version | head -n 1)\""
796 B="$tri/codebook" sh tools/codebook/build.sh > "$tri/build-codebook.log"
797 B="$tri/trit" sh tools/trit/build.sh > "$tri/build-trit.log"
798 obs trit_binary_sha256 "\"$(sha256sum < "$tri/trit/trit" | cut -c1-64)\""
799 obs codebook_binary_sha256 "\"$(sha256sum < "$tri/codebook/codebook" | cut -c1-64)\""
800 tri_suite() { # name, then the command: its own TOTAL line must show fail=0 skip=0
801 local name="$1" rc=0 tot; shift
802 "$@" > "$tri/$name.log" 2>&1 || rc=$?
803 tot="$(grep -E '^TOTAL pass=[0-9]+ fail=[0-9]+ skip=[0-9]+$' "$tri/$name.log" | tail -n 1 || true)"
804 echo "trinary $name: exit $rc, $tot (log $tri/$name.log, sha256 $(sha256sum < "$tri/$name.log" | cut -c1-64))"
805 [ "$rc" = 0 ] && [ -n "$tot" ] || { echo "run.sh: trinary $name FAIL (exit $rc)" >&2; tail -n 20 "$tri/$name.log" >&2; exit 1; }
806 case "$tot" in *"fail=0 skip=0") ;; *) echo "run.sh: trinary $name: $tot is not fail=0 skip=0" >&2; exit 1 ;; esac
807 }
808 tri_suite codebook-test env BIN="$ROOT/$tri/codebook/codebook" FIX="$ROOT/$tri/fix-codebook" sh tools/codebook/test.sh
809 tri_suite trit-test env BIN="$ROOT/$tri/trit/trit" CBIN="$ROOT/$tri/codebook/codebook" FIX="$ROOT/$tri/fix-trit" sh tools/trit/test.sh
810 BIN="$ROOT/$tri/trit/trit" python3 tools/trit/test-daily.py > "$tri/daily.log" 2>&1 || { cat "$tri/daily.log" >&2; exit 1; }
811 tail -n 1 "$tri/daily.log"
812 COMPOSED="$ROOT/$tri/trit/trit.full.om" python3 tools/trit/mutate-daily.py > "$tri/daily-mutations.log" 2>&1 || { cat "$tri/daily-mutations.log" >&2; exit 1; }
813 tail -n 1 "$tri/daily-mutations.log"
814 sh tools/codebook/test-mutate.sh > "$tri/codebook-driver.log" 2>&1 || { cat "$tri/codebook-driver.log" >&2; exit 1; }
815 tail -n 1 "$tri/codebook-driver.log"
816 M="$ROOT/$tri/codebook-mutants" sh tools/codebook/mutate.sh > "$tri/codebook-mutate.log" 2>&1 || { echo "run.sh: trinary codebook mutate FAIL" >&2; tail -n 20 "$tri/codebook-mutate.log" >&2; exit 1; }
817 tail -n 1 "$tri/codebook-mutate.log"
818 W="$ROOT/$tri/driver-regression" sh tools/trit/test-mutate.sh > "$tri/test-mutate.log" 2>&1 || { echo "run.sh: trinary mutation-driver regression FAIL" >&2; tail -n 20 "$tri/test-mutate.log" >&2; exit 1; }
819 tail -n 1 "$tri/test-mutate.log"
820 W="$ROOT/$tri/mutants" sh tools/trit/mutate.sh > "$tri/trit-mutate.log" 2>&1 || { echo "run.sh: trinary trit mutate FAIL" >&2; tail -n 25 "$tri/trit-mutate.log" >&2; exit 1; }
821 grep -E '^(MUTANTS|mutate.sh: PASS)' "$tri/trit-mutate.log"
822 mline="$(grep '^MUTANTS ' "$tri/trit-mutate.log")"; mn="${mline#MUTANTS }"; mn="${mn%% *}"; mk="${mline#*killed-by-test.sh=}"; mk="${mk%% *}"
823 [ "$mn" -ge 1 ] && [ "$mk" = "$mn" ] && printf '%s\n' "$mline" | grep -qE 'survived=0 invalid=0 harness-errors=0$' || { echo "run.sh: trinary mutants: killed-by-test.sh=$mk of $mn, or a survivor/invalid/harness error: $mline" >&2; exit 1; }
824 BIN="$ROOT/$tri/trit/trit" N=600 SEED=1 W="$ROOT/$tri/diff" sh tools/trit/proof/difftest.sh > "$tri/difftest.log" 2>&1 || { echo "run.sh: trinary difftest FAIL" >&2; tail -n 20 "$tri/difftest.log" >&2; exit 1; }
825 grep -E '^DIFF agree=600/600 ' "$tri/difftest.log"
826 # CodebookProof.lean prints no axioms itself: check a copy of it with one `#print axioms Codebook.<name>` appended per top-level theorem.
827 { cat tools/codebook/proof/CodebookProof.lean; sed -n "s/^theorem \([^ ]*\) .*/#print axioms Codebook.\1/p" tools/codebook/proof/CodebookProof.lean; } > "$tri/CodebookAxioms.lean"
828 lean "$tri/CodebookAxioms.lean" > "$tri/lean-codebook.log" 2>&1 || { echo "run.sh: trinary CodebookProof.lean FAIL" >&2; head -n 20 "$tri/lean-codebook.log" >&2; exit 1; }
829 ( cd tools/trit/proof && lean TritSignal.lean ) > "$tri/lean-trit.log" 2>&1 || { echo "run.sh: trinary TritSignal.lean FAIL" >&2; head -n 20 "$tri/lean-trit.log" >&2; exit 1; }
830 if grep -q 'sorry\|error' "$tri/lean-codebook.log" "$tri/lean-trit.log"; then echo "run.sh: trinary Lean output mentions sorry or error" >&2; exit 1; fi
831 cbthm="$(grep -c '^theorem ' tools/codebook/proof/CodebookProof.lean || true)"
832 for lf in codebook trit; do
833 nax="$(grep -c "depends on axioms\|does not depend on any axioms" "$tri/lean-$lf.log" || true)"
834 badax="$(grep "depends on axioms" "$tri/lean-$lf.log" | sed 's/.*\[\(.*\)\]/\1/' | tr ',' '\n' | tr -d ' ' | grep -v '^propext$\|^Classical.choice$\|^Quot.sound$' | sort -u | tr '\n' ' ' || true)"
835 [ "$nax" -ge 1 ] && [ -z "$badax" ] || { echo "run.sh: trinary $lf axioms: $nax lines, non-standard '$badax'" >&2; exit 1; }
836 echo "trinary lean $lf: $nax axiom lines, standard axioms only"
837 [ "$lf" != codebook ] || [ "$nax" = "$cbthm" ] || { echo "run.sh: trinary CodebookProof.lean: $nax axiom lines for $cbthm theorems" >&2; exit 1; }
838 done
839 find "$tri" -maxdepth 1 -type f -name "*.log" -print0 | sort -z | xargs -0 sha256sum > "$tri/LOGS.sha256"
840 cat "$tri/LOGS.sha256"
841 echo "TRINARY PASS"
842 ;;
843 *) echo "run.sh: unknown step '$step'" >&2; exit 2 ;;
844esac