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
omega-mv / tests / r16_qualify / run.sh
| 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 |
| 25 | set -u |
| 26 | HERE=$(cd "$(dirname "$0")/../.." && pwd) |
| 27 | SCR=$(mktemp -d "${TMPDIR:-/tmp}/r16qual.XXXXXX") || exit 2 |
| 28 | trap 'rm -rf "$SCR"' EXIT INT TERM |
| 29 | FAILS=0 |
| 30 | check() { if eval "$2"; then echo "ok $1"; else echo "FAIL $1"; FAILS=$((FAILS + 1)); fi; } |
| 31 | |
| 32 | W=$SCR/w |
| 33 | mkdir -p "$W/tools" |
| 34 | cp "$HERE/tools/r16_qualify.sh" "$HERE/tools/aienos_lock_source.sh" "$W/tools/" |
| 35 | G6FILES="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" |
| 36 | for p in $G6FILES; do mkdir -p "$W/$(dirname "$p")"; cp "$HERE/$p" "$W/$p"; done |
| 37 | printf 'build/\n' > "$W/.gitignore" |
| 38 | g() { git -C "$W" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false "$@"; } |
| 39 | g init -q && g add -A && g commit -qm fixture || exit 2 |
| 40 | Q() { env R16_QUALIFY_DRY=1 "$@" bash "$W/tools/r16_qualify.sh"; } |
| 41 | |
| 42 | # 1. dirty tree refused before anything runs |
| 43 | echo x > "$W/stray.txt" |
| 44 | out=$(Q 2>&1); rc=$? |
| 45 | check "dirty tree: exit 2" '[ $rc = 2 ]' |
| 46 | check "dirty tree: says REFUSED" 'echo "$out" | grep -q "^REFUSED: working tree is dirty"' |
| 47 | check "dirty tree: nothing created (no build dir)" '[ ! -e "$W/build" ]' |
| 48 | check "dirty tree: no gate lines printed" '! echo "$out" | grep -q "R16-G"' |
| 49 | rm -f "$W/stray.txt" |
| 50 | echo y >> "$W/.gitignore" |
| 51 | out=$(Q 2>&1); rc=$? |
| 52 | check "modified tracked file: exit 2" '[ $rc = 2 ]' |
| 53 | g checkout -q -- .gitignore |
| 54 | |
| 55 | # 2. wrong expected commit refused |
| 56 | out=$(Q R16_EXPECT_COMMIT=0000000000000000000000000000000000000000 2>&1); rc=$? |
| 57 | check "unexpected HEAD: exit 2" '[ $rc = 2 ]' |
| 58 | |
| 59 | # 3. output under tracked evidence/ refused |
| 60 | out=$(Q R16_OUT_DIR="$W/evidence/R16/raw" 2>&1); rc=$? |
| 61 | check "output under evidence/: exit 2" '[ $rc = 2 ]' |
| 62 | |
| 63 | # 4. no fixtures: every gate NOT_RUN, nothing PASS, exit 3 |
| 64 | out=$(Q R16_RUN_ID=none 2>&1); rc=$? |
| 65 | R=$W/build/r16-raw/none/DRY-RUN-receipt.json |
| 66 | check "no fixtures: exit 3 (nothing ran)" '[ $rc = 3 ]' |
| 67 | check "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"' |
| 68 | check "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$"' |
| 69 | check "no fixtures: receipt gate NOT_RUN" 'grep -q "\"gate\": \"NOT_RUN\"" "$R"' |
| 70 | check "no fixtures: receipt has no PASS value" '! grep -q "\"PASS\"" "$R"' |
| 71 | check "no fixtures: silicon_observed false (computed)" 'grep -q "\"silicon_observed\": false" "$R"' |
| 72 | check "no fixtures: tree_dirty false and candidate_bound true observed" 'grep -q "\"tree_dirty\": false" "$R" && grep -q "\"candidate_bound\": true" "$R"' |
| 73 | check "receipt marks schema revision 2" 'grep -q "\"schema_revision\": 2" "$R"' |
| 74 | check "receipt keeps schema name" 'grep -q "\"schema\": \"AIEN_RX_R16_ORCHESTRATOR_RETIRED_V1\"" "$R"' |
| 75 | check "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 |
| 78 | F=$W/build/r16-raw/fx |
| 79 | mkdir -p "$F" |
| 80 | echo "R16 gate: R16_G4_LEGACY_REFUSED=PASS" > "$F/r16_negative.log"; echo 0 > "$F/r16_negative.log.rc" |
| 81 | echo "R16 gate: R16_G4_GUARDS_LOAD_BEARING=PASS" > "$F/r16_negative_mutants.log"; echo 0 > "$F/r16_negative_mutants.log.rc" |
| 82 | echo "surface: something else" > "$F/r16_surface.log"; echo 0 > "$F/r16_surface.log.rc" |
| 83 | out=$(Q R16_RUN_ID=fx 2>&1); rc=$? |
| 84 | R=$W/build/r16-raw/fx/DRY-RUN-receipt.json |
| 85 | check "failing grep: exit non-zero (1)" '[ $rc = 1 ]' |
| 86 | check "failing grep: G5 FAIL" 'echo "$out" | grep -q "G5=FAIL"' |
| 87 | check "failing grep: G4 PASS from its own checks" 'echo "$out" | grep -q "G4=PASS"' |
| 88 | check "failing grep: receipt gate FAIL" 'grep -q "\"gate\": \"FAIL\"" "$R"' |
| 89 | |
| 90 | # 6. target exit status counts even when the pass line is present |
| 91 | echo 1 > "$F/r16_surface.log.rc"; echo "R16 gate: R16_G5_SURFACE=PASS" > "$F/r16_surface.log" |
| 92 | out=$(Q R16_RUN_ID=fx 2>&1); rc=$? |
| 93 | check "bad exit status with pass line: G5 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G5=FAIL"' |
| 94 | echo 0 > "$F/r16_surface.log.rc" |
| 95 | out=$(Q R16_RUN_ID=fx 2>&1); rc=$? |
| 96 | check "good G4/G5 fixtures: those gates PASS" 'echo "$out" | grep -q "G4=PASS" && echo "$out" | grep -q "G5=PASS"' |
| 97 | check "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 |
| 100 | printf 'checks 400 failures 0\n' > "$F/r11_aien.log"; echo 0 > "$F/r11_aien.log.rc" |
| 101 | out=$(Q R16_RUN_ID=fx 2>&1) |
| 102 | check "R11 rules-only log with living run: PASS" 'echo "$out" | grep -q "^ R11: PASS$"' |
| 103 | printf '[-] 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" |
| 104 | out=$(Q R16_RUN_ID=fx 2>&1) |
| 105 | check "R11 living run skipped under load: NOT_RUN" 'echo "$out" | grep -q "^ R11: NOT_RUN$"' |
| 106 | rm -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. |
| 111 | I=$W/build/r16-raw/inv |
| 112 | mkdir -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). |
| 116 | inv_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 | } |
| 139 | inv_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 | } |
| 143 | inv_logs 0 0 "R16 inventory self-test: PASS" |
| 144 | inv_fixture |
| 145 | out=$(Q R16_RUN_ID=inv 2>&1); rc=$? |
| 146 | R=$I/DRY-RUN-receipt.json |
| 147 | check "good inventory: G1 PASS and G2 PASS" 'echo "$out" | grep -q "G1=PASS G2=PASS"' |
| 148 | check "good inventory: no FAIL, exit 3 (other gates NOT_RUN)" '[ $rc = 3 ]' |
| 149 | check "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"' |
| 150 | check "good inventory: repo heads read from the JSON" 'grep -q "\"aien_sovereign_core_commit\": \"2222222222222222222222222222222222222222\"" "$R" && grep -q "\"aegis_runtime_commit\": \"3333333333333333333333333333333333333333\"" "$R"' |
| 151 | for 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"' |
| 155 | done |
| 156 | inv_fixture unclassified=7 |
| 157 | out=$(Q R16_RUN_ID=inv 2>&1) |
| 158 | check "bad inventory unclassified=7: count carried into receipt" 'grep -q "\"remaining_unclassified_semantic_loop_count\": 7" "$R"' |
| 159 | for 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"' |
| 163 | done |
| 164 | inv_fixture a_reachable=1 |
| 165 | out=$(Q R16_RUN_ID=inv 2>&1); rc=$? |
| 166 | check "bad inventory a_reachable=1: G2 FAIL (G1 PASS), exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=PASS G2=FAIL"' |
| 167 | check "bad inventory a_reachable=1: count carried into receipt" 'grep -q "\"remaining_central_loop_count\": 1" "$R"' |
| 168 | inv_fixture result=FAIL |
| 169 | out=$(Q R16_RUN_ID=inv 2>&1); rc=$? |
| 170 | check "inventory result FAIL: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' |
| 171 | inv_fixture; inv_logs 1 0 "R16 inventory self-test: PASS" |
| 172 | out=$(Q R16_RUN_ID=inv 2>&1); rc=$? |
| 173 | check "inventory target exit 1: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' |
| 174 | inv_logs 0 0 "R16 inventory self-test: 1 FAILED" |
| 175 | out=$(Q R16_RUN_ID=inv 2>&1); rc=$? |
| 176 | check "inventory self-test log lacks pass line: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' |
| 177 | inv_logs 0 1 "R16 inventory self-test: PASS" |
| 178 | out=$(Q R16_RUN_ID=inv 2>&1); rc=$? |
| 179 | check "inventory self-test exit 1 with pass line: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' |
| 180 | inv_logs 0 0 "R16 inventory self-test: PASS"; rm -f "$I/inventory.json" |
| 181 | out=$(Q R16_RUN_ID=inv 2>&1); rc=$? |
| 182 | check "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. |
| 186 | CAND=$(g rev-parse HEAD) |
| 187 | RD=$SCR/r15 |
| 188 | mkdir -p "$RD" |
| 189 | # r15_receipt [field=value ...]: writes a receipt named by its own SHA-256, prints its path. |
| 190 | r15_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 | } |
| 199 | GOOD=$(r15_receipt) |
| 200 | out=$(Q R16_RUN_ID=r15 R16_R15_RECEIPT="$GOOD" 2>&1); rc=$? |
| 201 | R=$W/build/r16-raw/r15/DRY-RUN-receipt.json |
| 202 | check "good R15 receipt: acceptance PASS" 'echo "$out" | grep -q "R15 acceptance receipt: PASS"' |
| 203 | check "good R15 receipt: field true, exit 3 (ladder NOT_RUN)" '[ $rc = 3 ] && grep -q "\"r15_acceptance_still_passing\": true" "$R"' |
| 204 | r15_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 | } |
| 209 | cp "$GOOD" "$RD/not-its-sha.json" |
| 210 | r15_bad "not named by its SHA-256" "$RD/not-its-sha.json" |
| 211 | r15_bad "missing file" "$RD/absent.json" |
| 212 | : > "$RD/empty.json" |
| 213 | r15_bad "empty file" "$RD/empty.json" |
| 214 | r15_bad "for another commit" "$(r15_receipt candidate_commit=0000000000000000000000000000000000000000)" |
| 215 | r15_bad "outcome FAIL" "$(r15_receipt outcome=FAIL)" |
| 216 | r15_bad "candidate_bound false" "$(r15_receipt candidate_bound=false)" |
| 217 | r15_bad "tree_dirty true" "$(r15_receipt tree_dirty=true)" |
| 218 | r15_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. |
| 222 | G=$W/build/r16-raw/g6 |
| 223 | mkdir -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. |
| 226 | LK=$SCR/lockrepo |
| 227 | mkdir -p "$LK/native/capability" |
| 228 | printf '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" |
| 229 | git -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 |
| 230 | git -C "$LK" rev-parse HEAD > "$W/aienos.lock" |
| 231 | g add -A; g commit -qm "lock file" |
| 232 | export 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. |
| 236 | mkdir -p "$W/build" |
| 237 | printf 'host production binary fixture\n' > "$W/build/rx_r13_living_host" |
| 238 | printf '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. |
| 240 | op_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 | } |
| 247 | op_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 |
| 257 | g6log() { printf '%s\n' "$2" > "$G/$1"; echo "${3:-0}" > "$G/$1.rc"; } |
| 258 | g6_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) |
| 266 | RX_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) |
| 274 | R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON" |
| 275 | g6log r16_operator_mutants.log "RX_OPERATOR_MUTANTS: 14 mutants, 0 failures, 0 skipped |
| 276 | RX_OPERATOR_MUTANTS: PASS" |
| 277 | g6log r16_operator_silicon.log "R16 operator: 100 checks, 0 failures, 0 skipped (silicon, phases: startup control restart kill) |
| 278 | R16 operator gate: R16_G6_OPERATOR=PASS" |
| 279 | op_tmpl host; op_tmpl silicon |
| 280 | } |
| 281 | G6Q() { op_render; Q R16_RUN_ID=g6 2>&1; } |
| 282 | R=$G/DRY-RUN-receipt.json |
| 283 | g6_item() { sed -n 's/^.*"item": "'"$1"'", "status": "\([A-Z_]*\)".*$/\1/p' "$R"; } |
| 284 | g6_good_logs |
| 285 | out=$(G6Q); rc=$? |
| 286 | check "G6 all good: every item implemented and operated, G6 PASS" 'echo "$out" | grep -q " G6=PASS"' |
| 287 | check "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 ]' |
| 288 | check "G6 all good: protected_surfaces_kept six presence flags true" '[ "$(grep -c "_present\": true" "$R")" = 6 ]' |
| 289 | check "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"' |
| 290 | check "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"' |
| 291 | check "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 |
| 294 | rm -f "$G"/*.log "$G"/*.rc |
| 295 | out=$(G6Q) |
| 296 | check "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"' |
| 297 | g6_good_logs |
| 298 | |
| 299 | # symbol removed / commented out / reduced to a prototype -> MISSING_IMPLEMENTATION |
| 300 | RG=$W/src/runtime/rx_generation.c |
| 301 | g6_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 | } |
| 305 | g6_unmut() { g reset -q --hard HEAD~1; } |
| 306 | g6_mut "symbol removed" 's/rx_gen_recover/rx_gen_rec0ver/' |
| 307 | check "G6 symbol removed: recovery_path MISSING_IMPLEMENTATION" '[ "$(g6_item recovery_path_present)" = MISSING_IMPLEMENTATION ]' |
| 308 | check "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 ]' |
| 309 | check "G6 symbol removed: G6 is not PASS even though every test passed" 'echo "$out" | grep -q "G6=MISSING_IMPLEMENTATION" && [ $rc = 3 ]' |
| 310 | check "G6 symbol removed: receipt flag is not true" 'grep -q "\"recovery_path_present\": \"MISSING_IMPLEMENTATION\"" "$R"' |
| 311 | g6_unmut |
| 312 | g6_mut "definition commented out (disabled)" 's|^int rx_gen_recover(|// int rx_gen_recover(|' |
| 313 | check "G6 definition commented out: MISSING_IMPLEMENTATION" '[ "$(g6_item recovery_path_present)" = MISSING_IMPLEMENTATION ]' |
| 314 | g6_unmut |
| 315 | g6_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);|' |
| 316 | check "G6 prototype only: MISSING_IMPLEMENTATION" '[ "$(g6_item recovery_path_present)" = MISSING_IMPLEMENTATION ]' |
| 317 | g6_unmut |
| 318 | out=$(G6Q) |
| 319 | check "G6 mutations reverted: recovery_path back to PASS" '[ "$(g6_item recovery_path_present)" = PASS ]' |
| 320 | |
| 321 | # failing tests -> FAIL |
| 322 | g6log r9_barrier.log "generation barrier kept a single coherent generation through every injected stop" 1 |
| 323 | out=$(G6Q); rc=$? |
| 324 | check "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 ]' |
| 325 | g6log r9_barrier.log "2 generation-barrier failures" |
| 326 | out=$(G6Q); rc=$? |
| 327 | check "G6 fake log reporting failures (no pass line): FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G6=FAIL"' |
| 328 | g6log r9_barrier.log "generation barrier kept a single coherent generation through every injected stop" |
| 329 | g6log r12_silicon.log "checks 40 failures 3 silicon 1" 1 |
| 330 | out=$(G6Q) |
| 331 | check "G6 a failing silicon seat-loss run: G6 FAIL" 'echo "$out" | grep -q "G6=FAIL" && [ "$(g6_item r12_seat_loss_handling_passing)" = FAIL ]' |
| 332 | g6log r12_silicon.log "checks 40 failures 0 silicon 1" |
| 333 | g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 17 / 18 M19 GATES PASSED |
| 334 | [FAIL] OMEGA_ACCEL_RESIDENT_FAULT_RECOVERY_PASS : x" 0 |
| 335 | out=$(G6Q) |
| 336 | check "G6 M19 log with a [FAIL] gate line (exit 0): known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]' |
| 337 | g6log 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. |
| 341 | g6log r16_operator_silicon.log "R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON" |
| 342 | out=$(G6Q) |
| 343 | check "G6 operator: a host result in the silicon slot is not a silicon pass: item FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]' |
| 344 | rm -f "$G/r16_operator_silicon.log" "$G/r16_operator_silicon.log.rc" |
| 345 | out=$(G6Q) |
| 346 | check "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"' |
| 347 | g6log r16_operator_silicon.log "[SKIPPED] unauthorized: peer of another uid (sudo -n unavailable) |
| 348 | R16 operator gate: R16_G6_OPERATOR=PASS" |
| 349 | out=$(G6Q) |
| 350 | check "G6 operator: silicon log with a SKIPPED case and the pass line: NOT_RUN, never PASS" '[ "$(g6_item operator_emergency_controls_passing)" = NOT_RUN ]' |
| 351 | g6log r16_operator_silicon.log "[-] stop: authorized stop accepted, durable |
| 352 | R16 operator gate: R16_G6_OPERATOR=FAIL" 1 |
| 353 | out=$(G6Q) |
| 354 | check "G6 operator: failed silicon run: item FAIL, G6 FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ] && echo "$out" | grep -q "G6=FAIL"' |
| 355 | g6log r16_operator_silicon.log "R16 operator gate: R16_G6_OPERATOR=PASS" |
| 356 | g6log r16_operator_host.log "R16 operator gate: R16_G6_OPERATOR=FAIL" 1 |
| 357 | out=$(G6Q) |
| 358 | check "G6 operator: failed host run with a passing silicon log: item FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]' |
| 359 | g6log r16_operator_host.log "R16 operator gate: R16_G6_OPERATOR=PASS" |
| 360 | out=$(G6Q) |
| 361 | check "G6 operator: a host log carrying the silicon pass line is not the host verdict: FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]' |
| 362 | g6log r16_operator_host.log "R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON" |
| 363 | g6log r16_operator_mutants.log "ok O1 wiring missing: killed |
| 364 | FAIL O5 success reply without a state transition: SURVIVED (exit 0) |
| 365 | RX_OPERATOR_MUTANTS: FAIL" 1 |
| 366 | out=$(G6Q) |
| 367 | check "G6 operator: a surviving mutant: item FAIL" '[ "$(g6_item operator_emergency_controls_passing)" = FAIL ]' |
| 368 | g6log r16_operator_mutants.log "RX_OPERATOR_MUTANTS: PASS" |
| 369 | RL=$W/tests/runtime/rx_r13_living.c |
| 370 | sed -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" |
| 371 | out=$(G6Q) |
| 372 | check "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"' |
| 373 | g6_unmut |
| 374 | out=$(G6Q) |
| 375 | check "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. |
| 377 | op_item() { g6_item operator_emergency_controls_passing; } |
| 378 | op_test() { jq -r ".g6_items[] | select(.item==\"operator_emergency_controls_passing\") | .tests[] | select(.name==\"$1\") | .$2" "$R"; } |
| 379 | check "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 ]' |
| 381 | check "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 ]' |
| 383 | op_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 | } |
| 388 | op_bad "binary digest is not the binary built in the run (host)" host 's/@SHA@/0000000000000000000000000000000000000000000000000000000000000000/' |
| 389 | op_bad "binary digest is not the binary built in the run (silicon)" silicon 's/@SHA@/1111111111111111111111111111111111111111111111111111111111111111/' |
| 390 | op_bad "written by a mutant run (binary prog)" host 's/"binary": "rx_r13_living_host"/"binary": "prog"/' |
| 391 | op_bad "another candidate commit" silicon 's/@HEAD@/0123456789abcdef0123456789abcdef01234567/' |
| 392 | op_bad "dirty tree" host 's/"tree_dirty": false/"tree_dirty": true/' |
| 393 | op_bad "a skipped case" silicon 's/"skipped": 0/"skipped": 1/' |
| 394 | op_bad "a failure" host 's/"failures": 0/"failures": 2/' |
| 395 | op_bad "the host gate in the silicon receipt" silicon 's/"R16_G6_OPERATOR": "PASS"/"R16_G6_OPERATOR": "HOST_PASS_NON_SILICON"/' |
| 396 | op_bad "the silicon seat in the host slot" host 's/"seat": "host"/"seat": "silicon"/' |
| 397 | rm -f "$G/op_host.tmpl"; out=$(G6Q) |
| 398 | check "G6 operator: host log passing but no host receipt: item FAIL" '[ "$(op_item)" = FAIL ]' |
| 399 | op_tmpl host |
| 400 | printf 'changed after the test\n' >> "$W/build/rx_r13_living_silicon" |
| 401 | sed -i "s/@SHA@/$(sha256sum < "$W/build/rx_r13_living_silicon" | cut -d' ' -f1)/" "$G/op_silicon.tmpl" |
| 402 | printf 'rebuilt\n' >> "$W/build/rx_r13_living_silicon"; out=$(G6Q) |
| 403 | check "G6 operator: silicon binary rebuilt after its test: item FAIL" '[ "$(op_item)" = FAIL ]' |
| 404 | op_tmpl silicon; out=$(G6Q) |
| 405 | check "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. |
| 407 | g6log r16_operator_host.log "[SKIPPED] unauthorized: a peer of another uid needs sudo -n (no passwordless sudo here) |
| 408 | R16 operator: 85 checks, 0 failures, 1 skipped (host, phases: startup control restart kill) |
| 409 | R16 operator gate: R16_G6_OPERATOR=NOT_RUN (1 SKIPPED)" |
| 410 | op_tmpl host 's/"skipped": 0/"skipped": 1/' 's/"HOST_PASS_NON_SILICON"/"NOT_RUN (1 SKIPPED)"/'; out=$(G6Q) |
| 411 | check "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 ]' |
| 412 | g6log r16_operator_host.log "[SKIPPED] unauthorized: a peer of another uid needs sudo -n (no passwordless sudo here) |
| 413 | R16 operator gate: R16_G6_OPERATOR=NOT_RUN (1 SKIPPED)" 1 |
| 414 | out=$(G6Q) |
| 415 | check "G6 operator: the same NOT_RUN line with exit 1: FAIL" '[ "$(op_test R16_OP_HOST status)" = FAIL ]' |
| 416 | g6log r16_operator_host.log "R16 operator: 120 checks, 0 failures, 0 skipped (host, phases: startup control restart kill) |
| 417 | R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON" |
| 418 | op_tmpl host |
| 419 | g6log r16_operator_mutants.log "SKIPPED O7 peer uid check removed: the test could not run the case that kills it |
| 420 | RX_OPERATOR_MUTANTS: NOT_RUN (SKIPPED cases)" 3 |
| 421 | out=$(G6Q) |
| 422 | check "G6 operator: mutants NOT_RUN (exit 3): test NOT_RUN, not FAIL" '[ "$(op_test R16_OP_MUTANTS status)" = NOT_RUN ]' |
| 423 | g6log r16_operator_mutants.log "RX_OPERATOR_MUTANTS: PASS" |
| 424 | # G3: silicon_observed needs every silicon run, the operator silicon test included. |
| 425 | g6log r16_authpath_host.log "R16 gate: R16_G3_AUTHPATH=HOST_PASS_NON_SILICON" |
| 426 | g6log r16_authpath_silicon.log "R16 gate: R16_G3_AUTHPATH=PASS" |
| 427 | g6log r13_silicon.log "R13 gate: R13_LIVING_SYSTEM=PASS" |
| 428 | out=$(G6Q) |
| 429 | check "G3 silicon_observed: every silicon run passed, the operator silicon run included: true" 'grep -q "\"silicon_observed\": true" "$R"' |
| 430 | rm -f "$G/r16_operator_silicon.log" "$G/r16_operator_silicon.log.rc"; out=$(G6Q) |
| 431 | check "G3 silicon_observed: the five other silicon runs passed, operator silicon not run: false" 'grep -q "\"silicon_observed\": false" "$R"' |
| 432 | g6log r16_operator_silicon.log "R16 operator gate: R16_G6_OPERATOR=PASS" |
| 433 | op_tmpl silicon 's/@SHA@/2222222222222222222222222222222222222222222222222222222222222222/'; out=$(G6Q) |
| 434 | check "G3 silicon_observed: operator silicon log passing but its receipt unbound: false" 'grep -q "\"silicon_observed\": false" "$R"' |
| 435 | op_tmpl silicon |
| 436 | rm -f "$G"/r16_authpath_*.log* "$G/r13_silicon.log" "$G/r13_silicon.log.rc" |
| 437 | |
| 438 | # skipped tests are never PASS |
| 439 | g6log r9_barrier.log "[-] living run not exercised: SKIPPED-LOADED |
| 440 | generation barrier kept a single coherent generation through every injected stop" |
| 441 | out=$(G6Q); rc=$? |
| 442 | check "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 ]' |
| 443 | g6log 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 |
| 446 | rm -f "$G/r10_omega.log" "$G/r10_omega.log.rc" |
| 447 | out=$(G6Q) |
| 448 | check "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 |
| 450 | g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 17 / 18 M19 GATES PASSED" |
| 451 | out=$(G6Q) |
| 452 | check "G6 M19 log 17 / 18 with exit 0: known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]' |
| 453 | g6log m19_world.log "STAGE 1 / PERSISTENT WORLD QUALIFICATION: 0 / 0 M19 GATES PASSED" |
| 454 | out=$(G6Q) |
| 455 | check "G6 M19 log 0 / 0: known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]' |
| 456 | g6log m19_world.log "M19 GATES PASSED" |
| 457 | out=$(G6Q) |
| 458 | check "G6 M19 log with only the substring: known_good_fallback FAIL" '[ "$(g6_item known_good_fallback_present)" = FAIL ]' |
| 459 | g6log 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 |
| 462 | AW=$W/src/omega_accelerator_world.c |
| 463 | sed -i 's/omega_world_drain(/omega_world_dra1n(/' "$AW"; g add -A; g commit -qm "mutation: omega_world_drain removed" |
| 464 | out=$(G6Q) |
| 465 | check "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"' |
| 466 | g reset -q --hard HEAD~1 |
| 467 | sed -i 's/aienos_cap_mint(/aienos_cap_m1nt(/' "$LK/native/capability/aienos_capability.c" |
| 468 | git -C "$LK" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false commit -qam mut |
| 469 | git -C "$LK" rev-parse HEAD > "$W/aienos.lock"; g add -A; g commit -qm "lock mutated" |
| 470 | out=$(G6Q) |
| 471 | check "G6 capability-root symbol removed from the pinned tree: trusted_capability_root MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]' |
| 472 | g reset -q --hard HEAD~1 |
| 473 | out=$(Q R16_RUN_ID=g6 AIENOS_LOCK_REPO=/nonexistent 2>&1) |
| 474 | check "G6 pinned tree unreadable: trusted_capability_root NOT_RUN (not MISSING, not PASS)" '[ "$(g6_item trusted_capability_root_present)" = NOT_RUN ]' |
| 475 | out=$(G6Q) |
| 476 | check "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. |
| 480 | GOODLOCK=$(cat "$W/aienos.lock") |
| 481 | lkg() { git -C "$LK" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false "$@"; } |
| 482 | lkg checkout -q -b lacks-mint "$GOODLOCK" |
| 483 | sed -i 's/aienos_cap_mint(/aienos_cap_other(/' "$LK/native/capability/aienos_capability.c"; lkg commit -qam "lock A: no mint" |
| 484 | ALOCK=$(git -C "$LK" rev-parse HEAD); lkg checkout -q - |
| 485 | printf '%s\n' "$ALOCK" > "$W/aienos.lock"; g add -A; g commit -qm "lock A" |
| 486 | UNREL=$SCR/unrelated; mkdir -p "$UNREL/native/capability" |
| 487 | printf '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" |
| 488 | out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$UNREL" 2>&1) |
| 489 | check "G6 lock A + unrelated dir with plausible functions: MISSING_IMPLEMENTATION (dir not read)" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]' |
| 490 | out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$UNREL" AIENOS_LOCK_REPO=/nonexistent 2>&1) |
| 491 | check "G6 lock A unavailable + unrelated dir supplied: NOT_RUN (not PASS)" '[ "$(g6_item trusted_capability_root_present)" = NOT_RUN ]' |
| 492 | check "G6 unavailable: receipt g6_lock_source status unavailable" '[ "$(jq -r .g6_lock_source.status "$R")" = unavailable ]' |
| 493 | CLONE=$SCR/clean-other; git clone -q "$LK" "$CLONE"; git -C "$CLONE" checkout -q "$GOODLOCK" |
| 494 | out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$CLONE" 2>&1) |
| 495 | check "G6 lock A + clean checkout of a different commit that has mint: MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]' |
| 496 | out=$(Q R16_RUN_ID=g6 AIENOS_R7_DIR="$CLONE" AIENOS_LOCK_REPO=/nonexistent 2>&1) |
| 497 | check "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 ]' |
| 498 | for 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/" |
| 501 | done |
| 502 | out=$(Q R16_RUN_ID=g6 2>&1) |
| 503 | check "G6 lock A + modified cache dirs (full and short name) with mint: MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]' |
| 504 | rm -rf "$W/build/aienos-authority" |
| 505 | lkg replace "$ALOCK" "$GOODLOCK" |
| 506 | out=$(Q R16_RUN_ID=g6 2>&1) |
| 507 | check "G6 lock A with a git replace ref onto a commit that has mint: MISSING_IMPLEMENTATION" '[ "$(g6_item trusted_capability_root_present)" = MISSING_IMPLEMENTATION ]' |
| 508 | lkg replace -d "$ALOCK" >/dev/null |
| 509 | printf '%s\n' "${GOODLOCK:0:7}" > "$W/aienos.lock"; g add -A; g commit -qm "short lock" |
| 510 | out=$(Q R16_RUN_ID=g6 2>&1) |
| 511 | check "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 ]' |
| 512 | printf '%s\n' "$GOODLOCK" > "$W/aienos.lock"; g add -A; g commit -qm "good lock again" |
| 513 | out=$(G6Q) |
| 514 | check "G6 valid locked source: PASS" '[ "$(g6_item trusted_capability_root_present)" = PASS ]' |
| 515 | check "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")" ]' |
| 516 | out=$(Q R16_RUN_ID=g6 AIENOS_CAP_LIB=/tmp/prebuilt.a 2>&1); rc=$? |
| 517 | check "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) |
| 520 | check "G6 receipt is valid JSON (jq)" 'jq -e . "$R" >/dev/null' |
| 521 | check "G6 receipt: twelve items, twelve different basis texts" '[ "$(jq "[.g6_items[].basis] | unique | length" "$R")" = 12 ] && [ "$(jq ".g6_items | length" "$R")" = 12 ]' |
| 522 | check "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' |
| 523 | check "G6 receipt: seat kill hook is not an item symbol" '! jq -e ".g6_items[].implementation[] | select(.symbol==\"rx_gpu_seat_kill\")" "$R" >/dev/null' |
| 524 | check "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' |
| 525 | g6log rx_emergency.log "RX_EMERGENCY_STOP: PASS (0 failures; host CPU, real caproot authority)" |
| 526 | out=$(G6Q) |
| 527 | check "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' |
| 528 | g6log rx_emergency.log "RX_EMERGENCY_MUTANTS: PASS" |
| 529 | out=$(G6Q) |
| 530 | check "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' |
| 531 | g6log rx_emergency.log "RX_EMERGENCY_STOP: PASS (0 failures; host CPU, real caproot authority) |
| 532 | RX_EMERGENCY_MUTANTS: PASS" 1 |
| 533 | out=$(G6Q) |
| 534 | check "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' |
| 535 | g6log rx_emergency.log "RX_EMERGENCY_STOP: PASS (0 failures; host CPU, real caproot authority) |
| 536 | RX_EMERGENCY_MUTANTS: PASS" |
| 537 | out=$(G6Q) |
| 538 | rm -rf "$G" |
| 539 | |
| 540 | # 9. the script holds no literal for observed fields and does not touch tracked evidence |
| 541 | check "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"' |
| 543 | check "no copy into tracked evidence/" '! grep -E "cp .*evidence/R16|EVID_RAW_DIR" "$HERE/tools/r16_qualify.sh"' |
| 544 | check "no hardcoded home paths" '! grep -E "/home/[a-z]" "$HERE/tools/r16_qualify.sh"' |
| 545 | |
| 546 | if [ "$FAILS" -ne 0 ]; then echo "R16 qualify self-test: $FAILS FAILED"; exit 1; fi |
| 547 | echo "R16 qualify self-test: PASS" |