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 / r16_qualify / run.sh

547 lines · 39838 bytes Raw Blame History
1#!/bin/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# Self-test for tools/r16_qualify.sh. No chip, no make target, no build: the script runs in
18# dry mode (R16_QUALIFY_DRY=1) inside a scratch git repo, reading fixture logs.
19# Proves: a dirty tree is refused before anything runs; a gate with no check prints
20# NOT_RUN (never PASS); a failing check makes the script exit non-zero; observed fields
21# are computed, not literals; G1/G2 follow every count, repo head and result in the
22# inventory JSON; the G7 R15 receipt check fails on each broken field. Each check has a
23# passing fixture first and then a counterexample that must fail.
24# Usage: bash tests/r16_qualify/run.sh
25set -u
26HERE=$(cd "$(dirname "$0")/../.." && pwd)
27SCR=$(mktemp -d "${TMPDIR:-/tmp}/r16qual.XXXXXX") || exit 2
28trap 'rm -rf "$SCR"' EXIT INT TERM
29FAILS=0
30check() { if eval "$2"; then echo "ok $1"; else echo "FAIL $1"; FAILS=$((FAILS + 1)); fi; }
31
32W=$SCR/w
33mkdir -p "$W/tools"
34cp "$HERE/tools/r16_qualify.sh" "$HERE/tools/aienos_lock_source.sh" "$W/tools/"
35G6FILES="src/omega_accelerator_world.c src/runtime/rx_generation.c src/omega_world_gates.c tools/omegatool.c src/runtime/rx_native_bind.c src/omega_evidence.c src/omega_verify.c src/runtime/rx_resident_gpu.c src/runtime/rx_seq_reference.c src/runtime/rx_world.c src/runtime/rx_living.c src/runtime/rx_operator.c tests/runtime/rx_r13_living.c"
36for p in $G6FILES; do mkdir -p "$W/$(dirname "$p")"; cp "$HERE/$p" "$W/$p"; done
37printf 'build/\n' > "$W/.gitignore"
38g() { git -C "$W" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false "$@"; }
39g init -q && g add -A && g commit -qm fixture || exit 2
40Q() { env R16_QUALIFY_DRY=1 "$@" bash "$W/tools/r16_qualify.sh"; }
41
42# 1. dirty tree refused before anything runs
43echo x > "$W/stray.txt"
44out=$(Q 2>&1); rc=$?
45check "dirty tree: exit 2" '[ $rc = 2 ]'
46check "dirty tree: says REFUSED" 'echo "$out" | grep -q "^REFUSED: working tree is dirty"'
47check "dirty tree: nothing created (no build dir)" '[ ! -e "$W/build" ]'
48check "dirty tree: no gate lines printed" '! echo "$out" | grep -q "R16-G"'
49rm -f "$W/stray.txt"
50echo y >> "$W/.gitignore"
51out=$(Q 2>&1); rc=$?
52check "modified tracked file: exit 2" '[ $rc = 2 ]'
53g checkout -q -- .gitignore
54
55# 2. wrong expected commit refused
56out=$(Q R16_EXPECT_COMMIT=0000000000000000000000000000000000000000 2>&1); rc=$?
57check "unexpected HEAD: exit 2" '[ $rc = 2 ]'
58
59# 3. output under tracked evidence/ refused
60out=$(Q R16_OUT_DIR="$W/evidence/R16/raw" 2>&1); rc=$?
61check "output under evidence/: exit 2" '[ $rc = 2 ]'
62
63# 4. no fixtures: every gate NOT_RUN, nothing PASS, exit 3
64out=$(Q R16_RUN_ID=none 2>&1); rc=$?
65R=$W/build/r16-raw/none/DRY-RUN-receipt.json
66check "no fixtures: exit 3 (nothing ran)" '[ $rc = 3 ]'
67check "no fixtures: G6 NOT_RUN (every item implemented, no test ran)" 'echo "$out" | grep -q " G6=NOT_RUN" && ! echo "$out" | grep -q "G6=MISSING_IMPLEMENTATION"'
68check "no fixtures: summary all NOT_RUN" 'echo "$out" | grep -q "^Gates: G1=NOT_RUN G2=NOT_RUN G3=NOT_RUN G4=NOT_RUN G5=NOT_RUN G6=NOT_RUN G7=NOT_RUN G8=NOT_RUN$"'
69check "no fixtures: receipt gate NOT_RUN" 'grep -q "\"gate\": \"NOT_RUN\"" "$R"'
70check "no fixtures: receipt has no PASS value" '! grep -q "\"PASS\"" "$R"'
71check "no fixtures: silicon_observed false (computed)" 'grep -q "\"silicon_observed\": false" "$R"'
72check "no fixtures: tree_dirty false and candidate_bound true observed" 'grep -q "\"tree_dirty\": false" "$R" && grep -q "\"candidate_bound\": true" "$R"'
73check "receipt marks schema revision 2" 'grep -q "\"schema_revision\": 2" "$R"'
74check "receipt keeps schema name" 'grep -q "\"schema\": \"AIEN_RX_R16_ORCHESTRATOR_RETIRED_V1\"" "$R"'
75check "tree still clean after run" '[ -z "$(g status --porcelain)" ]'
76
77# 5. fixture logs: G4 good, G5 log lacks the required line -> FAIL -> exit 1
78F=$W/build/r16-raw/fx
79mkdir -p "$F"
80echo "R16 gate: R16_G4_LEGACY_REFUSED=PASS" > "$F/r16_negative.log"; echo 0 > "$F/r16_negative.log.rc"
81echo "R16 gate: R16_G4_GUARDS_LOAD_BEARING=PASS" > "$F/r16_negative_mutants.log"; echo 0 > "$F/r16_negative_mutants.log.rc"
82echo "surface: something else" > "$F/r16_surface.log"; echo 0 > "$F/r16_surface.log.rc"
83out=$(Q R16_RUN_ID=fx 2>&1); rc=$?
84R=$W/build/r16-raw/fx/DRY-RUN-receipt.json
85check "failing grep: exit non-zero (1)" '[ $rc = 1 ]'
86check "failing grep: G5 FAIL" 'echo "$out" | grep -q "G5=FAIL"'
87check "failing grep: G4 PASS from its own checks" 'echo "$out" | grep -q "G4=PASS"'
88check "failing grep: receipt gate FAIL" 'grep -q "\"gate\": \"FAIL\"" "$R"'
89
90# 6. target exit status counts even when the pass line is present
91echo 1 > "$F/r16_surface.log.rc"; echo "R16 gate: R16_G5_SURFACE=PASS" > "$F/r16_surface.log"
92out=$(Q R16_RUN_ID=fx 2>&1); rc=$?
93check "bad exit status with pass line: G5 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G5=FAIL"'
94echo 0 > "$F/r16_surface.log.rc"
95out=$(Q R16_RUN_ID=fx 2>&1); rc=$?
96check "good G4/G5 fixtures: those gates PASS" 'echo "$out" | grep -q "G4=PASS" && echo "$out" | grep -q "G5=PASS"'
97check "all-good G4/G5 still exit 3 (G6 tests did not run)" '[ $rc = 3 ] && echo "$out" | grep -q "G6=NOT_RUN"'
98
99# 6b. R11 that skipped its living run (load > 2) exits 0 with "failures 0": NOT_RUN, never PASS
100printf 'checks 400 failures 0\n' > "$F/r11_aien.log"; echo 0 > "$F/r11_aien.log.rc"
101out=$(Q R16_RUN_ID=fx 2>&1)
102check "R11 rules-only log with living run: PASS" 'echo "$out" | grep -q "^ R11: PASS$"'
103printf '[-] SKIPPED-LOADED: living run not started: load average 15.85 is above 2\n[-] living run not exercised: SKIPPED-LOADED: load average 15.85 is above 2\nchecks 400 failures 0\n' > "$F/r11_aien.log"
104out=$(Q R16_RUN_ID=fx 2>&1)
105check "R11 living run skipped under load: NOT_RUN" 'echo "$out" | grep -q "^ R11: NOT_RUN$"'
106rm -f "$F/r11_aien.log" "$F/r11_aien.log.rc"
107
108
109# 7. G1/G2 from the inventory JSON. A good fixture passes first (so each failure below is
110# caused by the one value changed), then every G1/G2 check is broken on its own.
111I=$W/build/r16-raw/inv
112mkdir -p "$I"
113# inv_fixture [key=value ...]: writes inventory.json in the tool's layout with all counts 0,
114# result PASS and five recorded heads; a key=value pair overrides one field
115# (head_<repo>=<sha> overrides one repo head; an empty value records no head).
116inv_fixture() {
117 local unclassified=0 question_rows=0 bad_class=0 a_reachable=0 stale_rows=0 map_errors=0
118 local skipped_repos=0 result=PASS kv k v r
119 local head_omega=1111111111111111111111111111111111111111
120 local head_aien_sovereign_core=2222222222222222222222222222222222222222
121 local head_aegis_runtime=3333333333333333333333333333333333333333
122 local head_aienos=4444444444444444444444444444444444444444
123 local head_physics=5555555555555555555555555555555555555555
124 for kv in "$@"; do k=${kv%%=*}; v=${kv#*=}; k=${k//-/_}; printf -v "$k" '%s' "$v"; done
125 {
126 printf '{\n "schema": "AIEN_R16_LOOP_INVENTORY_V1",\n "map": "spec/r16-orchestrator-retirement-map.md",\n "repos": [\n'
127 for r in omega aien-sovereign-core aegis-runtime aienos physics; do
128 k=head_${r//-/_}
129 printf ' {"name": "%s", "path": "/x/%s", "head": "%s", "map_sha": "", "status": "SCANNED", "sites_by_class": {"A": 0}}%s\n' \
130 "$r" "$r" "${!k}" "$([ "$r" = physics ] || echo ,)"
131 done
132 printf ' ],\n "sites": [\n ],\n "manual_rows": 5,\n "sites_total": 328,\n'
133 printf ' "unclassified": %s,\n "question_rows": %s,\n "bad_class": %s,\n "a_reachable": %s,\n' \
134 "$unclassified" "$question_rows" "$bad_class" "$a_reachable"
135 printf ' "stale_rows": %s,\n "map_errors": %s,\n "skipped_repos": %s,\n "class_n_sites": 0,\n "result": "%s"\n}\n' \
136 "$stale_rows" "$map_errors" "$skipped_repos" "$result"
137 } > "$I/inventory.json"
138}
139inv_logs() { # inv_logs <inventory rc> <self-test rc> <self-test last line>
140 echo "R16 loop inventory: sites=328 -> fixture" > "$I/r16_inventory.log"; echo "$1" > "$I/r16_inventory.log.rc"
141 echo "$3" > "$I/test_r16_inventory.log"; echo "$2" > "$I/test_r16_inventory.log.rc"
142}
143inv_logs 0 0 "R16 inventory self-test: PASS"
144inv_fixture
145out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
146R=$I/DRY-RUN-receipt.json
147check "good inventory: G1 PASS and G2 PASS" 'echo "$out" | grep -q "G1=PASS G2=PASS"'
148check "good inventory: no FAIL, exit 3 (other gates NOT_RUN)" '[ $rc = 3 ]'
149check "good inventory: counts read from the JSON (0 and 0)" 'grep -q "\"remaining_unclassified_semantic_loop_count\": 0" "$R" && grep -q "\"remaining_central_loop_count\": 0" "$R"'
150check "good inventory: repo heads read from the JSON" 'grep -q "\"aien_sovereign_core_commit\": \"2222222222222222222222222222222222222222\"" "$R" && grep -q "\"aegis_runtime_commit\": \"3333333333333333333333333333333333333333\"" "$R"'
151for k in unclassified question_rows bad_class stale_rows map_errors skipped_repos; do
152 inv_fixture "$k=1"
153 out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
154 check "bad inventory $k=1: G1 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=FAIL"'
155done
156inv_fixture unclassified=7
157out=$(Q R16_RUN_ID=inv 2>&1)
158check "bad inventory unclassified=7: count carried into receipt" 'grep -q "\"remaining_unclassified_semantic_loop_count\": 7" "$R"'
159for r in omega aien-sovereign-core aegis-runtime aienos physics; do
160 inv_fixture "head_$r="
161 out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
162 check "inventory with no head for $r: G1 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=FAIL"'
163done
164inv_fixture a_reachable=1
165out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
166check "bad inventory a_reachable=1: G2 FAIL (G1 PASS), exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=PASS G2=FAIL"'
167check "bad inventory a_reachable=1: count carried into receipt" 'grep -q "\"remaining_central_loop_count\": 1" "$R"'
168inv_fixture result=FAIL
169out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
170check "inventory result FAIL: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"'
171inv_fixture; inv_logs 1 0 "R16 inventory self-test: PASS"
172out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
173check "inventory target exit 1: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"'
174inv_logs 0 0 "R16 inventory self-test: 1 FAILED"
175out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
176check "inventory self-test log lacks pass line: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"'
177inv_logs 0 1 "R16 inventory self-test: PASS"
178out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
179check "inventory self-test exit 1 with pass line: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"'
180inv_logs 0 0 "R16 inventory self-test: PASS"; rm -f "$I/inventory.json"
181out=$(Q R16_RUN_ID=inv 2>&1); rc=$?
182check "inventory ran but wrote no JSON: G1 FAIL and G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=FAIL G2=FAIL"'
183
184# 8. G7 R15 acceptance receipt (R16_R15_RECEIPT). A good receipt (named by its own
185# SHA-256, bound to this HEAD) passes first; then each check is broken on its own.
186CAND=$(g rev-parse HEAD)
187RD=$SCR/r15
188mkdir -p "$RD"
189# r15_receipt [field=value ...]: writes a receipt named by its own SHA-256, prints its path.
190r15_receipt() {
191 local outcome=PASS candidate_commit=$CAND candidate_bound=true tree_dirty=false silicon_observed=true kv
192 for kv in "$@"; do printf -v "${kv%%=*}" '%s' "${kv#*=}"; done
193 printf '{\n "schema": "AIEN_RX_R15_FIXTURE",\n "outcome": "%s",\n "candidate_commit": "%s",\n "candidate_bound": %s,\n "tree_dirty": %s,\n "silicon_observed": %s\n}\n' \
194 "$outcome" "$candidate_commit" "$candidate_bound" "$tree_dirty" "$silicon_observed" > "$RD/tmp.json"
195 local s; s=$(sha256sum "$RD/tmp.json" | cut -d' ' -f1)
196 mv "$RD/tmp.json" "$RD/$s.json"
197 echo "$RD/$s.json"
198}
199GOOD=$(r15_receipt)
200out=$(Q R16_RUN_ID=r15 R16_R15_RECEIPT="$GOOD" 2>&1); rc=$?
201R=$W/build/r16-raw/r15/DRY-RUN-receipt.json
202check "good R15 receipt: acceptance PASS" 'echo "$out" | grep -q "R15 acceptance receipt: PASS"'
203check "good R15 receipt: field true, exit 3 (ladder NOT_RUN)" '[ $rc = 3 ] && grep -q "\"r15_acceptance_still_passing\": true" "$R"'
204r15_bad() { # r15_bad <label> <receipt path>
205 out=$(Q R16_RUN_ID=r15 R16_R15_RECEIPT="$2" 2>&1); rc=$?
206 check "R15 receipt $1: acceptance FAIL, G7 FAIL, exit 1" \
207 '[ $rc = 1 ] && echo "$out" | grep -q "R15 acceptance receipt: FAIL" && echo "$out" | grep -q "G7=FAIL" && grep -q "\"r15_acceptance_still_passing\": false" "$R"'
208}
209cp "$GOOD" "$RD/not-its-sha.json"
210r15_bad "not named by its SHA-256" "$RD/not-its-sha.json"
211r15_bad "missing file" "$RD/absent.json"
212: > "$RD/empty.json"
213r15_bad "empty file" "$RD/empty.json"
214r15_bad "for another commit" "$(r15_receipt candidate_commit=0000000000000000000000000000000000000000)"
215r15_bad "outcome FAIL" "$(r15_receipt outcome=FAIL)"
216r15_bad "candidate_bound false" "$(r15_receipt candidate_bound=false)"
217r15_bad "tree_dirty true" "$(r15_receipt tree_dirty=true)"
218r15_bad "silicon_observed false" "$(r15_receipt silicon_observed=false)"
219
220# 8b. G6 protected things kept. Presence (symbol defined) and operation (test ran and
221# passed in this run) are separate. All good first, then one control at a time.
222G=$W/build/r16-raw/g6
223mkdir -p "$G"
224# A stand-in for the pinned capability-root tree (the pinned-commit lookup of the lock file): a tiny repo holding the file
225# the script looks for, and a lock file in the fixture repo naming its commit.
226LK=$SCR/lockrepo
227mkdir -p "$LK/native/capability"
228printf 'int aienos_cap_validate(const void *view)\n{ return 0; }\nint aienos_cap_mint(void *admin)\n{ return 0; }\n' > "$LK/native/capability/aienos_capability.c"
229git -C "$LK" init -q && git -C "$LK" add -A && git -C "$LK" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false commit -qm lock
230git -C "$LK" rev-parse HEAD > "$W/aienos.lock"
231g add -A; g commit -qm "lock file"
232export AIENOS_LOCK_REPO=$LK
233# Operator receipts (G2): each seat's test writes one; the script copies it into the raw
234# directory and checks it against the production binary of the run. Fixture binaries in
235# build/ (git-ignored); templates filled with the current HEAD and binary digest by G6Q.
236mkdir -p "$W/build"
237printf 'host production binary fixture\n' > "$W/build/rx_r13_living_host"
238printf 'silicon production binary fixture\n' > "$W/build/rx_r13_living_silicon"
239# op_tmpl <seat> [sed expression...]: the receipt template of one seat, then edits.
240op_tmpl() {
241 local seat=$1 gate=HOST_PASS_NON_SILICON e; shift
242 [ "$seat" = silicon ] && gate=PASS
243 printf '{\n "schema": "AIEN_R16_G6_OPERATOR_CONTROL_V1",\n "seat": "%s",\n "candidate_commit": "@HEAD@",\n "tree_dirty": false,\n "binary": "rx_r13_living_%s",\n "binary_sha256": "@SHA@",\n "checks": 90,\n "failures": 0,\n "skipped": 0,\n "skip_reasons": [],\n "gate": {"R16_G6_OPERATOR": "%s"}\n}\n' \
244 "$seat" "$seat" "$gate" > "$G/op_$seat.tmpl"
245 for e in "$@"; do sed -i "$e" "$G/op_$seat.tmpl"; done
246}
247op_render() {
248 local s
249 for s in host silicon; do
250 rm -f "$G/operator_${s}_receipt.json"
251 [ -f "$G/op_$s.tmpl" ] || continue
252 sed -e "s/@HEAD@/$(g rev-parse HEAD)/" -e "s/@SHA@/$(sha256sum < "$W/build/rx_r13_living_$s" | cut -d' ' -f1)/" \
253 "$G/op_$s.tmpl" > "$G/operator_${s}_receipt.json"
254 done
255}
256# g6log <file> <pattern> [rc]: fixture log + exit status for one exercising test
257g6log() { printf '%s\n' "$2" > "$G/$1"; echo "${3:-0}" > "$G/$1.rc"; }
258g6_good_logs() {
259 g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 18 / 18 M19 GATES PASSED"
260 g6log r9_barrier.log "generation barrier kept a single coherent generation through every injected stop"
261 g6log r10_omega.log "checks 40 failures 0"
262 g6log r7_native.log "native authority matched the linux oracle"
263 g6log r12_host.log "checks 40 failures 0"
264 g6log r12_silicon.log "checks 40 failures 0 silicon 1"
265 g6log rx_emergency.log "RX_EMERGENCY_STOP: PASS (0 failures; host CPU, real caproot authority)
266RX_EMERGENCY_MUTANTS: PASS"
267 g6log r13_host.log "R13 gate: R13_LIVING_SYSTEM=HOST_PASS_NON_SILICON"
268 g6log r14_host.log "R14 gate: R14_LIVING_RECOVERY=HOST_PASS_NON_SILICON"
269 g6log r14_silicon.log "R14 gate: R14_LIVING_RECOVERY=PASS"
270 g6log r15_parity_host.log "SEQ_SEMANTIC_PARITY=PASS"
271 g6log r15_parity_silicon.log "SEQ_SEMANTIC_PARITY=PASS"
272 g6log r15_receipt.log "r15 receipt test: 0 failure(s)"
273 g6log r16_operator_host.log "R16 operator: 120 checks, 0 failures, 0 skipped (host, phases: startup control restart kill)
274R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON"
275 g6log r16_operator_mutants.log "RX_OPERATOR_MUTANTS: 14 mutants, 0 failures, 0 skipped
276RX_OPERATOR_MUTANTS: PASS"
277 g6log r16_operator_silicon.log "R16 operator: 100 checks, 0 failures, 0 skipped (silicon, phases: startup control restart kill)
278R16 operator gate: R16_G6_OPERATOR=PASS"
279 op_tmpl host; op_tmpl silicon
280}
281G6Q() { op_render; Q R16_RUN_ID=g6 2>&1; }
282R=$G/DRY-RUN-receipt.json
283g6_item() { sed -n 's/^.*"item": "'"$1"'", "status": "\([A-Z_]*\)".*$/\1/p' "$R"; }
284g6_good_logs
285out=$(G6Q); rc=$?
286check "G6 all good: every item implemented and operated, G6 PASS" 'echo "$out" | grep -q " G6=PASS"'
287check "G6 all good: twelve items PASS, operator emergency controls among them" '[ "$(grep -c "\"item\": \"[a-z0-9_]*\", \"status\": \"PASS\"" "$R")" = 12 ] && [ "$(g6_item operator_emergency_controls_passing)" = PASS ]'
288check "G6 all good: protected_surfaces_kept six presence flags true" '[ "$(grep -c "_present\": true" "$R")" = 6 ]'
289check "G6 all good: no FAIL anywhere and G6 alone does not make the run pass (exit 3)" '[ $rc = 3 ] && ! echo "$out" | grep -q "G6=FAIL"'
290check "G6 all good: receipt names file and symbol per item" 'grep -q "\"file\": \"src/runtime/rx_generation.c\", \"symbol\": \"rx_gen_recover\", \"source\": \"omega_tree\", \"defined\": true" "$R"'
291check "G6 operated checks cite the test and its status" 'grep -q "{\"name\": \"R9\", \"target\": \"test-r9\", \"seat\": \"host\", \"status\": \"PASS\"}" "$R"'
292
293# presence without operation: symbols all defined, tests never ran -> NOT_RUN, never PASS
294rm -f "$G"/*.log "$G"/*.rc
295out=$(G6Q)
296check "G6 presence alone (no test ran): item NOT_RUN, G6 not PASS" '[ "$(g6_item recovery_path_present)" = NOT_RUN ] && ! echo "$out" | grep -q "G6=PASS"'
297g6_good_logs
298
299# symbol removed / commented out / reduced to a prototype -> MISSING_IMPLEMENTATION
300RG=$W/src/runtime/rx_generation.c
301g6_mut() { # g6_mut <label> <sed expression>: mutate the fixture source, commit, run, report, revert
302 sed -i "$2" "$RG"; g add -A; g commit -qm "mutation: $1"
303 out=$(G6Q); rc=$?
304}
305g6_unmut() { g reset -q --hard HEAD~1; }
306g6_mut "symbol removed" 's/rx_gen_recover/rx_gen_rec0ver/'
307check "G6 symbol removed: recovery_path MISSING_IMPLEMENTATION" '[ "$(g6_item recovery_path_present)" = MISSING_IMPLEMENTATION ]'
308check "G6 symbol removed: r9 item (same routine) also MISSING_IMPLEMENTATION, r14 (fn_restore) unaffected" '[ "$(g6_item r9_crash_recovery_passing)" = MISSING_IMPLEMENTATION ] && [ "$(g6_item r14_recovery_paths_passing)" = PASS ]'
309check "G6 symbol removed: G6 is not PASS even though every test passed" 'echo "$out" | grep -q "G6=MISSING_IMPLEMENTATION" && [ $rc = 3 ]'
310check "G6 symbol removed: receipt flag is not true" 'grep -q "\"recovery_path_present\": \"MISSING_IMPLEMENTATION\"" "$R"'
311g6_unmut
312g6_mut "definition commented out (disabled)" 's|^int rx_gen_recover(|// int rx_gen_recover(|'
313check "G6 definition commented out: MISSING_IMPLEMENTATION" '[ "$(g6_item recovery_path_present)" = MISSING_IMPLEMENTATION ]'
314g6_unmut
315g6_mut "definition reduced to a prototype" 's|^int rx_gen_recover(const char \*dir, RxRecoveryRecord \*out) {|int rx_gen_recover(const char *dir, RxRecoveryRecord *out);|'
316check "G6 prototype only: MISSING_IMPLEMENTATION" '[ "$(g6_item recovery_path_present)" = MISSING_IMPLEMENTATION ]'
317g6_unmut
318out=$(G6Q)
319check "G6 mutations reverted: recovery_path back to PASS" '[ "$(g6_item recovery_path_present)" = PASS ]'
320
321# failing tests -> FAIL
322g6log r9_barrier.log "generation barrier kept a single coherent generation through every injected stop" 1
323out=$(G6Q); rc=$?
324check "G6 test exits 1 with its pass line present: item FAIL, G6 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G6=FAIL" && [ "$(g6_item recovery_path_present)" = FAIL ] && [ "$(g6_item generation_mechanism_present)" = FAIL ]'
325g6log r9_barrier.log "2 generation-barrier failures"
326out=$(G6Q); rc=$?
327check "G6 fake log reporting failures (no pass line): FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G6=FAIL"'
328g6log r9_barrier.log "generation barrier kept a single coherent generation through every injected stop"
329g6log r12_silicon.log "checks 40 failures 3 silicon 1" 1
330out=$(G6Q)
331check "G6 a failing silicon seat-loss run: G6 FAIL" 'echo "$out" | grep -q "G6=FAIL" && [ "$(g6_item r12_seat_loss_handling_passing)" = FAIL ]'
332g6log r12_silicon.log "checks 40 failures 0 silicon 1"
333g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 17 / 18 M19 GATES PASSED
334 [FAIL] OMEGA_ACCEL_RESIDENT_FAULT_RECOVERY_PASS : x" 0
335out=$(G6Q)
336check "G6 M19 log with a [FAIL] gate line (exit 0): known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]'
337g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 18 / 18 M19 GATES PASSED"
338
339# operator emergency controls: operated only by execution of the production program,
340# host and silicon apart; the old string-presence check can no longer pass it.
341g6log r16_operator_silicon.log "R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON"
342out=$(G6Q)
343check "G6 operator: a host result in the silicon slot is not a silicon pass: item FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]'
344rm -f "$G/r16_operator_silicon.log" "$G/r16_operator_silicon.log.rc"
345out=$(G6Q)
346check "G6 operator: host test and mutants passed, no silicon receipt: item NOT_RUN, G6 not PASS" '[ "$(g6_item operator_emergency_controls_passing)" = NOT_RUN ] && ! echo "$out" | grep -q "G6=PASS"'
347g6log r16_operator_silicon.log "[SKIPPED] unauthorized: peer of another uid (sudo -n unavailable)
348R16 operator gate: R16_G6_OPERATOR=PASS"
349out=$(G6Q)
350check "G6 operator: silicon log with a SKIPPED case and the pass line: NOT_RUN, never PASS" '[ "$(g6_item operator_emergency_controls_passing)" = NOT_RUN ]'
351g6log r16_operator_silicon.log "[-] stop: authorized stop accepted, durable
352R16 operator gate: R16_G6_OPERATOR=FAIL" 1
353out=$(G6Q)
354check "G6 operator: failed silicon run: item FAIL, G6 FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ] && echo "$out" | grep -q "G6=FAIL"'
355g6log r16_operator_silicon.log "R16 operator gate: R16_G6_OPERATOR=PASS"
356g6log r16_operator_host.log "R16 operator gate: R16_G6_OPERATOR=FAIL" 1
357out=$(G6Q)
358check "G6 operator: failed host run with a passing silicon log: item FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]'
359g6log r16_operator_host.log "R16 operator gate: R16_G6_OPERATOR=PASS"
360out=$(G6Q)
361check "G6 operator: a host log carrying the silicon pass line is not the host verdict: FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]'
362g6log r16_operator_host.log "R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON"
363g6log r16_operator_mutants.log "ok O1 wiring missing: killed
364FAIL O5 success reply without a state transition: SURVIVED (exit 0)
365RX_OPERATOR_MUTANTS: FAIL" 1
366out=$(G6Q)
367check "G6 operator: a surviving mutant: item FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]'
368g6log r16_operator_mutants.log "RX_OPERATOR_MUTANTS: PASS"
369RL=$W/tests/runtime/rx_r13_living.c
370sed -i 's|^static int operator_open(Rig \*r) {|/* static int operator_open(Rig *r) { */ static int operator_0pen(Rig *r) {|' "$RL"; g add -A; g commit -qm "mutation: entry point only in a comment"
371out=$(G6Q)
372check "G6 operator: production wiring present only in a comment (string still in the file), every log passing: MISSING_IMPLEMENTATION" '[ "$(g6_item operator_emergency_controls_passing)" = MISSING_IMPLEMENTATION ] && grep -q "operator_open(Rig" "$RL" && ! echo "$out" | grep -q "G6=PASS"'
373g6_unmut
374out=$(G6Q)
375check "G6 operator: reverted, all logs passing: PASS" '[ "$(g6_item operator_emergency_controls_passing)" = PASS ]'
376# G2: the operator receipt. Good receipts first, then one broken field at a time.
377op_item() { g6_item operator_emergency_controls_passing; }
378op_test() { jq -r ".g6_items[] | select(.item==\"operator_emergency_controls_passing\") | .tests[] | select(.name==\"$1\") | .$2" "$R"; }
379check "G6 operator receipts: both copied into the raw directory and covered by its digest" \
380 'grep -q " operator_host_receipt.json$" "$G/SHA256SUMS" && grep -q " operator_silicon_receipt.json$" "$G/SHA256SUMS" && [ "$(op_item)" = PASS ]'
381check "G6 operator: tests labelled by seat (host test host, silicon test silicon)" \
382 '[ "$(op_test R16_OP_HOST seat)" = host ] && [ "$(op_test R16_OP_MUTANTS seat)" = host ] && [ "$(op_test R16_OP_SILICON seat)" = silicon ] && [ "$(jq -r .operator_control.silicon.seat "$R")" = silicon ]'
383op_bad() { # op_bad <label> <seat> <sed expression>: that receipt broken: item FAIL
384 OPSEAT=$2; op_tmpl "$2" "$3"; out=$(G6Q)
385 check "G6 operator receipt $1: item FAIL" '[ "$(op_item)" = FAIL ] && echo "$out" | grep -q "operator $OPSEAT receipt: FAIL"'
386 op_tmpl "$2"
387}
388op_bad "binary digest is not the binary built in the run (host)" host 's/@SHA@/0000000000000000000000000000000000000000000000000000000000000000/'
389op_bad "binary digest is not the binary built in the run (silicon)" silicon 's/@SHA@/1111111111111111111111111111111111111111111111111111111111111111/'
390op_bad "written by a mutant run (binary prog)" host 's/"binary": "rx_r13_living_host"/"binary": "prog"/'
391op_bad "another candidate commit" silicon 's/@HEAD@/0123456789abcdef0123456789abcdef01234567/'
392op_bad "dirty tree" host 's/"tree_dirty": false/"tree_dirty": true/'
393op_bad "a skipped case" silicon 's/"skipped": 0/"skipped": 1/'
394op_bad "a failure" host 's/"failures": 0/"failures": 2/'
395op_bad "the host gate in the silicon receipt" silicon 's/"R16_G6_OPERATOR": "PASS"/"R16_G6_OPERATOR": "HOST_PASS_NON_SILICON"/'
396op_bad "the silicon seat in the host slot" host 's/"seat": "host"/"seat": "silicon"/'
397rm -f "$G/op_host.tmpl"; out=$(G6Q)
398check "G6 operator: host log passing but no host receipt: item FAIL" '[ "$(op_item)" = FAIL ]'
399op_tmpl host
400printf 'changed after the test\n' >> "$W/build/rx_r13_living_silicon"
401sed -i "s/@SHA@/$(sha256sum < "$W/build/rx_r13_living_silicon" | cut -d' ' -f1)/" "$G/op_silicon.tmpl"
402printf 'rebuilt\n' >> "$W/build/rx_r13_living_silicon"; out=$(G6Q)
403check "G6 operator: silicon binary rebuilt after its test: item FAIL" '[ "$(op_item)" = FAIL ]'
404op_tmpl silicon; out=$(G6Q)
405check "G6 operator: receipts restored: PASS" '[ "$(op_item)" = PASS ]'
406# G7: a run that only skipped a case (gate NOT_RUN, exit 0) is NOT_RUN, never FAIL.
407g6log r16_operator_host.log "[SKIPPED] unauthorized: a peer of another uid needs sudo -n (no passwordless sudo here)
408R16 operator: 85 checks, 0 failures, 1 skipped (host, phases: startup control restart kill)
409R16 operator gate: R16_G6_OPERATOR=NOT_RUN (1 SKIPPED)"
410op_tmpl host 's/"skipped": 0/"skipped": 1/' 's/"HOST_PASS_NON_SILICON"/"NOT_RUN (1 SKIPPED)"/'; out=$(G6Q)
411check "G6 operator: host run without sudo (NOT_RUN gate, exit 0): test NOT_RUN, not FAIL" '[ "$(op_test R16_OP_HOST status)" = NOT_RUN ] && [ "$(op_item)" = NOT_RUN ]'
412g6log r16_operator_host.log "[SKIPPED] unauthorized: a peer of another uid needs sudo -n (no passwordless sudo here)
413R16 operator gate: R16_G6_OPERATOR=NOT_RUN (1 SKIPPED)" 1
414out=$(G6Q)
415check "G6 operator: the same NOT_RUN line with exit 1: FAIL" '[ "$(op_test R16_OP_HOST status)" = FAIL ]'
416g6log r16_operator_host.log "R16 operator: 120 checks, 0 failures, 0 skipped (host, phases: startup control restart kill)
417R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON"
418op_tmpl host
419g6log r16_operator_mutants.log "SKIPPED O7 peer uid check removed: the test could not run the case that kills it
420RX_OPERATOR_MUTANTS: NOT_RUN (SKIPPED cases)" 3
421out=$(G6Q)
422check "G6 operator: mutants NOT_RUN (exit 3): test NOT_RUN, not FAIL" '[ "$(op_test R16_OP_MUTANTS status)" = NOT_RUN ]'
423g6log r16_operator_mutants.log "RX_OPERATOR_MUTANTS: PASS"
424# G3: silicon_observed needs every silicon run, the operator silicon test included.
425g6log r16_authpath_host.log "R16 gate: R16_G3_AUTHPATH=HOST_PASS_NON_SILICON"
426g6log r16_authpath_silicon.log "R16 gate: R16_G3_AUTHPATH=PASS"
427g6log r13_silicon.log "R13 gate: R13_LIVING_SYSTEM=PASS"
428out=$(G6Q)
429check "G3 silicon_observed: every silicon run passed, the operator silicon run included: true" 'grep -q "\"silicon_observed\": true" "$R"'
430rm -f "$G/r16_operator_silicon.log" "$G/r16_operator_silicon.log.rc"; out=$(G6Q)
431check "G3 silicon_observed: the five other silicon runs passed, operator silicon not run: false" 'grep -q "\"silicon_observed\": false" "$R"'
432g6log r16_operator_silicon.log "R16 operator gate: R16_G6_OPERATOR=PASS"
433op_tmpl silicon 's/@SHA@/2222222222222222222222222222222222222222222222222222222222222222/'; out=$(G6Q)
434check "G3 silicon_observed: operator silicon log passing but its receipt unbound: false" 'grep -q "\"silicon_observed\": false" "$R"'
435op_tmpl silicon
436rm -f "$G"/r16_authpath_*.log* "$G/r13_silicon.log" "$G/r13_silicon.log.rc"
437
438# skipped tests are never PASS
439g6log r9_barrier.log "[-] living run not exercised: SKIPPED-LOADED
440generation barrier kept a single coherent generation through every injected stop"
441out=$(G6Q); rc=$?
442check "G6 skipped test with pass line and exit 0: item NOT_RUN, never PASS" '[ "$(g6_item recovery_path_present)" = NOT_RUN ] && ! echo "$out" | grep -q "G6=PASS" && [ $rc = 3 ]'
443g6log r9_barrier.log "generation barrier kept a single coherent generation through every injected stop"
444
445# a test that never ran (log absent) -> NOT_RUN for exactly the items that need it
446rm -f "$G/r10_omega.log" "$G/r10_omega.log.rc"
447out=$(G6Q)
448check "G6 one test absent: only its item NOT_RUN" '[ "$(g6_item r10_verifier_passing)" = NOT_RUN ] && [ "$(g6_item r9_crash_recovery_passing)" = PASS ]'
449# M19 must show N / N with N nonzero: 17 / 18 (exit 0, no [FAIL] line) and 0 / 0 are not PASS
450g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 17 / 18 M19 GATES PASSED"
451out=$(G6Q)
452check "G6 M19 log 17 / 18 with exit 0: known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]'
453g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 0 / 0 M19 GATES PASSED"
454out=$(G6Q)
455check "G6 M19 log 0 / 0: known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]'
456g6log m19_world.log "M19 GATES PASSED"
457out=$(G6Q)
458check "G6 M19 log with only the substring: known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]'
459g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 18 / 18 M19 GATES PASSED"
460
461# second and third items' presence checks: another omega file, and the pinned capability-root source
462AW=$W/src/omega_accelerator_world.c
463sed -i 's/omega_world_drain(/omega_world_dra1n(/' "$AW"; g add -A; g commit -qm "mutation: omega_world_drain removed"
464out=$(G6Q)
465check "G6 omega_world_drain removed (other file): known_good_fallback MISSING_IMPLEMENTATION" '[ "$(g6_item known_good_fallback_present)" = MISSING_IMPLEMENTATION ] && ! echo "$out" | grep -q "G6=PASS"'
466g reset -q --hard HEAD~1
467sed -i 's/aienos_cap_mint(/aienos_cap_m1nt(/' "$LK/native/capability/aienos_capability.c"
468git -C "$LK" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false commit -qam mut
469git -C "$LK" rev-parse HEAD > "$W/aienos.lock"; g add -A; g commit -qm "lock mutated"
470out=$(G6Q)
471check "G6 capability-root symbol removed from the pinned tree: trusted_capability_root MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]'
472g reset -q --hard HEAD~1
473out=$(Q R16_RUN_ID=g6 AIENOS_LOCK_REPO=/nonexistent 2>&1)
474check "G6 pinned tree unreadable: trusted_capability_root NOT_RUN (not MISSING, not PASS)" '[ "$(g6_item trusted_capability_root_present)" = NOT_RUN ]'
475out=$(G6Q)
476check "G6 pinned tree readable again: trusted_capability_root PASS" '[ "$(g6_item trusted_capability_root_present)" = PASS ]'
477
478# 8c. capability-root source identity (the locked commit, never a directory). Lock A lacks
479# aienos_cap_mint; every place that has it must not turn the item PASS.
480GOODLOCK=$(cat "$W/aienos.lock")
481lkg() { git -C "$LK" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false "$@"; }
482lkg checkout -q -b lacks-mint "$GOODLOCK"
483sed -i 's/aienos_cap_mint(/aienos_cap_other(/' "$LK/native/capability/aienos_capability.c"; lkg commit -qam "lock A: no mint"
484ALOCK=$(git -C "$LK" rev-parse HEAD); lkg checkout -q -
485printf '%s\n' "$ALOCK" > "$W/aienos.lock"; g add -A; g commit -qm "lock A"
486UNREL=$SCR/unrelated; mkdir -p "$UNREL/native/capability"
487printf 'int aienos_cap_validate(const void *v)\n{ return 0; }\nint aienos_cap_mint(void *a)\n{ return 0; }\n' > "$UNREL/native/capability/aienos_capability.c"
488out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$UNREL" 2>&1)
489check "G6 lock A + unrelated dir with plausible functions: MISSING_IMPLEMENTATION (dir not read)" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]'
490out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$UNREL" AIENOS_LOCK_REPO=/nonexistent 2>&1)
491check "G6 lock A unavailable + unrelated dir supplied: NOT_RUN (not PASS)" '[ "$(g6_item trusted_capability_root_present)" = NOT_RUN ]'
492check "G6 unavailable: receipt g6_lock_source status unavailable" '[ "$(jq -r .g6_lock_source.status "$R")" = unavailable ]'
493CLONE=$SCR/clean-other; git clone -q "$LK" "$CLONE"; git -C "$CLONE" checkout -q "$GOODLOCK"
494out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$CLONE" 2>&1)
495check "G6 lock A + clean checkout of a different commit that has mint: MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]'
496out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$CLONE" AIENOS_LOCK_REPO=/nonexistent 2>&1)
497check "G6 lock A, no lock repo, other-commit checkout whose repo holds A: MISSING_IMPLEMENTATION (A read, not the files)" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]'
498for c in "$ALOCK" "${ALOCK:0:7}"; do
499 mkdir -p "$W/build/aienos-authority/$c/native/capability"
500 cp "$UNREL/native/capability/aienos_capability.c" "$W/build/aienos-authority/$c/native/capability/"
501done
502out=$(Q R16_RUN_ID=g6 2>&1)
503check "G6 lock A + modified cache dirs (full and short name) with mint: MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]'
504rm -rf "$W/build/aienos-authority"
505lkg replace "$ALOCK" "$GOODLOCK"
506out=$(Q R16_RUN_ID=g6 2>&1)
507check "G6 lock A with a git replace ref onto a commit that has mint: MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]'
508lkg replace -d "$ALOCK" >/dev/null
509printf '%s\n' "${GOODLOCK:0:7}" > "$W/aienos.lock"; g add -A; g commit -qm "short lock"
510out=$(Q R16_RUN_ID=g6 2>&1)
511check "G6 abbreviated aienos.lock: NOT_RUN, g6_lock_source malformed_lock" '[ "$(g6_item trusted_capability_root_present)" = NOT_RUN ] && [ "$(jq -r .g6_lock_source.status "$R")" = malformed_lock ]'
512printf '%s\n' "$GOODLOCK" > "$W/aienos.lock"; g add -A; g commit -qm "good lock again"
513out=$(G6Q)
514check "G6 valid locked source: PASS" '[ "$(g6_item trusted_capability_root_present)" = PASS ]'
515check "G6 valid: receipt records the full lock, its tree and the blob read" '[ "$(jq -r .g6_lock_source.aienos_lock "$R")" = "$GOODLOCK" ] && [ "$(jq -r .g6_lock_source.commit_tree "$R")" = "$(git -C "$LK" rev-parse "$GOODLOCK^{tree}")" ] && [ "$(jq -r "[.g6_items[] | select(.item==\"trusted_capability_root_present\") | .implementation[] | select(.source==\"aienos_lock_commit\") | .blob] | unique | .[0]" "$R")" = "$(git -C "$LK" rev-parse "$GOODLOCK:native/capability/aienos_capability.c")" ]'
516out=$(Q R16_RUN_ID=g6 AIENOS_CAP_LIB=/tmp/prebuilt.a 2>&1); rc=$?
517check "prebuilt AIENOS_CAP_LIB override refused (exit 2)" '[ $rc = 2 ] && echo "$out" | grep -q "no source proof"'
518
519# receipt is valid JSON; each item says plainly what its mapping is (no shared boilerplate)
520check "G6 receipt is valid JSON (jq)" 'jq -e . "$R" >/dev/null'
521check "G6 receipt: twelve items, twelve different basis texts" '[ "$(jq "[.g6_items[].basis] | unique | length" "$R")" = 12 ] && [ "$(jq ".g6_items | length" "$R")" = 12 ]'
522check "G6 receipt: proxy mappings say PROXY, emergency item says it is operated only by execution" '[ "$(jq "[.g6_items[] | select(.basis | startswith(\"PROXY\"))] | length" "$R")" -ge 5 ] && jq -e ".g6_items[] | select(.item==\"operator_emergency_controls_passing\") | .basis | contains(\"operated only by execution\")" "$R" >/dev/null'
523check "G6 receipt: seat kill hook is not an item symbol" '! jq -e ".g6_items[].implementation[] | select(.symbol==\"rx_gpu_seat_kill\")" "$R" >/dev/null'
524check "G6 emergency item: runtime and production wiring defined, RX_EMERGENCY cited" 'jq -e ".g6_items[] | select(.item==\"operator_emergency_controls_passing\") | (.implementation[] | select(.symbol==\"rx_world_emergency_stop\") | .defined == true) and (.implementation[] | select(.symbol==\"operator_open\") | .defined == true) and (.tests[] | select(.name==\"R16_OP_SILICON\") | .target == \"test-r16-operator-silicon\") and (.tests[] | select(.name==\"RX_EMERGENCY\") | .status == \"PASS\" and .target == \"test-rx-emergency\")" "$R" >/dev/null'
525g6log rx_emergency.log "RX_EMERGENCY_STOP: PASS (0 failures; host CPU, real caproot authority)"
526out=$(G6Q)
527check "G6 emergency test without the mutant pass line: test FAIL in the receipt, item FAIL, G6 never PASS" '! echo "$out" | grep -q "G6=PASS" && [ "$(g6_item operator_emergency_controls_passing)" = FAIL ] && jq -e ".g6_items[] | select(.item==\"operator_emergency_controls_passing\") | .tests[] | select(.name==\"RX_EMERGENCY\") | .status == \"FAIL\"" "$R" >/dev/null'
528g6log rx_emergency.log "RX_EMERGENCY_MUTANTS: PASS"
529out=$(G6Q)
530check "G6 emergency test without the stop pass line: test FAIL in the receipt" 'jq -e ".g6_items[] | select(.item==\"operator_emergency_controls_passing\") | .tests[] | select(.name==\"RX_EMERGENCY\") | .status == \"FAIL\"" "$R" >/dev/null'
531g6log rx_emergency.log "RX_EMERGENCY_STOP: PASS (0 failures; host CPU, real caproot authority)
532RX_EMERGENCY_MUTANTS: PASS" 1
533out=$(G6Q)
534check "G6 emergency test exit 1 with both pass lines: test FAIL in the receipt" 'jq -e ".g6_items[] | select(.item==\"operator_emergency_controls_passing\") | .tests[] | select(.name==\"RX_EMERGENCY\") | .status == \"FAIL\"" "$R" >/dev/null'
535g6log rx_emergency.log "RX_EMERGENCY_STOP: PASS (0 failures; host CPU, real caproot authority)
536RX_EMERGENCY_MUTANTS: PASS"
537out=$(G6Q)
538rm -rf "$G"
539
540# 9. the script holds no literal for observed fields and does not touch tracked evidence
541check "no literal tree_dirty/candidate_bound/silicon_observed values" \
542 '! grep -E "\"(tree_dirty|candidate_bound|silicon_observed)\": (true|false)" "$HERE/tools/r16_qualify.sh"'
543check "no copy into tracked evidence/" '! grep -E "cp .*evidence/R16|EVID_RAW_DIR" "$HERE/tools/r16_qualify.sh"'
544check "no hardcoded home paths" '! grep -E "/home/[a-z]" "$HERE/tools/r16_qualify.sh"'
545
546if [ "$FAILS" -ne 0 ]; then echo "R16 qualify self-test: $FAILS FAILED"; exit 1; fi
547echo "R16 qualify self-test: PASS"