Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tools/r16_qualify.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tools / r16_qualify.sh` 651 lines · 38061 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 # r16_qualify.sh -- R16 Orchestrator Retirement qualification harness (schema revision 2). 18 # 19 # Runs the R16 gate targets on the current checkout and writes the 20 # AIEN_RX_R16_ORCHESTRATOR_RETIRED_V1 receipt (field names unchanged; the added field 21 # "schema_revision": 2 marks the changed semantics below). 22 # 23 # Truthfulness rules (revision 2): 24 # * A dirty tree is REFUSED (exit 2) before anything runs. 25 # * Every gate status is computed from a real check: a make target's exit status AND 26 # a required line in its log (or a value read from the inventory JSON). A failing 27 # check is FAIL. A gate with no implemented check is NOT_RUN, never PASS. 28 # * candidate_bound, tree_dirty and silicon_observed are computed from what was 29 # observed during this run, not written as literals. 30 # * Raw evidence and the receipt go to an UNTRACKED directory (default build/r16-raw/, 31 # or R16_OUT_DIR). Nothing under evidence/ is touched; a human or agent step copies 32 # and commits the receipt later. 33 # * No hardcoded machine paths. PHYSICS_DIR / AIENOS_LOCK_REPO are passed to make 34 # only if the caller set them. 35 # 36 # Exit status: 0 every gate PASS; 1 at least one FAIL; 2 refused (dirty tree / bad 37 # environment); 3 no FAIL but at least one gate NOT_RUN. 38 # 39 # Environment: 40 # R16_OUT_DIR output root (default /build/r16-raw); must not be tracked 41 # R16_RUN_ID override the run id (used by the self-test) 42 # R16_EXPECT_COMMIT if set, HEAD must equal it or the run is refused 43 # R16_R15_RECEIPT path to the R15 receipt on this candidate (checked for G7) 44 # R16_QUALIFY_DRY=1 dry mode, used by tests/r16_qualify/run.sh: runs no make target, no 45 # chip, no machine probe; reads fixture logs ( and .rc) 46 # already in the raw dir. Never writes a sha-named receipt. 47 set -euo pipefail 48 49 SCHEMA_REVISION=2 50 HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) 51 cd "$HERE" 52 DRY=${R16_QUALIFY_DRY:-0} 53 54 refuse() { echo "REFUSED: $*" >&2; exit 2; } 55 56 # ---- 0. refuse before running anything ------------------------------------ 57 git rev-parse --git-dir >/dev/null 2>&1 || refuse "not a git work tree: $HERE" 58 if [ -n "$(git status --porcelain)" ]; then 59 git status --porcelain | head -20 >&2 60 refuse "working tree is dirty (uncommitted or untracked files); commit or clean first" 61 fi 62 CANDIDATE_COMMIT=$(git rev-parse HEAD) 63 if [ -n "${R16_EXPECT_COMMIT:-}" ] && [ "$R16_EXPECT_COMMIT" != "$CANDIDATE_COMMIT" ]; then 64 refuse "HEAD $CANDIDATE_COMMIT is not the expected candidate $R16_EXPECT_COMMIT" 65 fi 66 export OMEGA_CANDIDATE_COMMIT="$CANDIDATE_COMMIT" 67 for v in AIENOS_CAP_LIB VISOR_AUTH_CAP_LIB EFFECT_CAP64_CAP_LIB; do 68 [ -z "${!v:-}" ] || refuse "$v is set: a prebuilt authority library has no source proof; build it from aienos.lock (AIENOS_LOCK_REPO / AIENOS_R7_DIR)" 69 done 70 if [ -n "${PHYSICS_DIR:-}" ]; then export PHYSICS_DIR; fi 71 if [ -n "${AIENOS_LOCK_REPO:-}" ]; then export AIENOS_LOCK_REPO; fi 72 73 RUN_COMMIT=$CANDIDATE_COMMIT 74 RUN_ID=${R16_RUN_ID:-$(date -u +%Y%m%dT%H%M%SZ)-${CANDIDATE_COMMIT:0:12}} 75 OUT_ROOT=${R16_OUT_DIR:-$HERE/build/r16-raw} 76 RAW_DIR="$OUT_ROOT/$RUN_ID" 77 case "$OUT_ROOT/" in 78 "$HERE"/evidence/*) refuse "output dir is under tracked evidence/; use an untracked path" ;; 79 esac 80 mkdir -p "$RAW_DIR" 81 if [ "$DRY" != 1 ]; then 82 case "$RAW_DIR" in 83 "$HERE"/*) git check-ignore -q "$RAW_DIR" || refuse "output dir $RAW_DIR is inside the repo but not git-ignored" ;; 84 esac 85 fi 86 87 echo "=== R16 Qualification (schema revision $SCHEMA_REVISION): $RUN_ID ===" 88 echo "Candidate commit: $CANDIDATE_COMMIT" 89 if [ "$DRY" = 1 ]; then echo "DRY MODE: no make target, no chip, no receipt named by hash"; fi 90 91 # ---- helpers ----------------------------------------------------------------- 92 RC=0 93 # run_target : sets RC to the exit status, or NOT_RUN in dry 94 # mode when no fixture log exists. Never aborts the script (set -e is off around make). 95 run_target() { 96 local log=$1; shift 97 if [ "$DRY" = 1 ]; then 98 if [ -f "$log" ]; then RC=$(cat "$log.rc" 2>/dev/null || echo 0); else RC=NOT_RUN; fi 99 return 0 100 fi 101 set +e 102 make "$@" > "$log" 2>&1 < /dev/null 103 RC=$? 104 set -e 105 echo "$RC" > "$log.rc" 106 } 107 # verdict : PASS only if the target exited 0 and the log 108 # holds the pattern; FAIL if it ran and either failed; NOT_RUN if it did not run. 109 verdict() { 110 local rc=$1 log=$2 pat=$3 111 if [ "$rc" = NOT_RUN ]; then echo NOT_RUN; return; fi 112 if [ "$rc" != 0 ]; then echo FAIL; return; fi 113 if [ -s "$log" ] && grep -Fq -- "$pat" "$log"; then echo PASS; else echo FAIL; fi 114 } 115 # combine : FAIL beats NOT_RUN (or MISSING_IMPLEMENTATION) beats PASS. 116 combine() { 117 local s r=PASS 118 for s in "$@"; do 119 if [ "$s" = FAIL ]; then echo FAIL; return; fi 120 if [ "$s" != PASS ]; then r=NOT_RUN; fi # NOT_RUN, MISSING_IMPLEMENTATION, anything else 121 done 122 echo "$r" 123 } 124 # jint : integer value of a key (last occurrence), empty if absent. 125 jint() { 126 [ -s "$1" ] || return 0 127 sed -n 's/^.*"'"$2"'": *\([0-9][0-9]*\).*$/\1/p' "$1" | tail -1 128 } 129 jstrv() { 130 [ -s "$1" ] || return 0 131 sed -n 's/^.*"'"$2"'": *"\([^"]*\)".*$/\1/p' "$1" | tail -1 132 } 133 repohead() { 134 [ -s "$1" ] || return 0 135 sed -n 's/^.*"name": "'"$2"'".*"head": "\([0-9a-f]*\)".*$/\1/p' "$1" | head -1 136 } 137 b2j() { if [ "$1" = PASS ]; then echo true; elif [ "$1" = FAIL ]; then echo false; else echo '"NOT_RUN"'; fi; } 138 139 # ---- 1. machine identity (observation only; no chip access) ----------------- 140 AIENOS_COMMIT=$(cat "$HERE/aienos.lock" 2>/dev/null || echo "unknown") 141 PHYSICS_COMMIT=$(cat "$HERE/physics.lock" 2>/dev/null || echo "unknown") 142 if [ "$DRY" != 1 ]; then 143 echo "[*] Capturing machine identity..." 144 midrs=$(for c in /sys/devices/system/cpu/cpu[0-9]*; do 145 printf '%s:%s ' "${c##*cpu}" "$(cat "$c/regs/identification/midr_el1" 2>/dev/null || true)"; done) || true 146 govs=$(for c in /sys/devices/system/cpu/cpu[0-9]*; do 147 printf '%s:%s:%s ' "${c##*cpu}" "$(cat "$c/cpufreq/scaling_governor" 2>/dev/null || true)" \ 148 "$(cat "$c/cpufreq/scaling_cur_freq" 2>/dev/null || true)"; done) || true 149 top=$(ps -eo pcpu,comm --sort=-pcpu 2>/dev/null | sed -n '2,11p' | awk '{printf "%s:%s ", $2, $1}') || true 150 gpu_info=$(nvidia-smi --query-gpu=name,pci.bus_id,driver_version,temperature.gpu --format=csv,noheader 2>/dev/null) || gpu_info="N/A" 151 mach_id=$(sha256sum /etc/machine-id 2>/dev/null | cut -d' ' -f1) || mach_id="N/A" 152 mem_total=$(awk '/MemTotal/{print $2}' /proc/meminfo 2>/dev/null) || mem_total=0 153 cat > "$RAW_DIR/machine.json" </dev/null || true)", 164 "top_cpu": "$top", 165 "aienos_commit": "$AIENOS_COMMIT", 166 "physics_commit": "$PHYSICS_COMMIT", 167 "compiler": "$(${CC:-cc} --version 2>/dev/null | head -1 || true)" 168 } 169 MEOF 170 fi 171 172 # ---- 2. G1 / G2: loop inventory ------------------------------------------- 173 echo "[*] R16-G1 / R16-G2: loop inventory..." 174 INV_LOG="$RAW_DIR/r16_inventory.log" 175 INV_JSON="$RAW_DIR/inventory.json" 176 INV_TEST_LOG="$RAW_DIR/test_r16_inventory.log" 177 if [ "$DRY" != 1 ]; then rm -f build/r16-inventory.json; fi 178 run_target "$INV_LOG" r16-inventory 179 INV_RC=$RC 180 if [ "$DRY" != 1 ] && [ -s build/r16-inventory.json ]; then cp build/r16-inventory.json "$INV_JSON"; fi 181 run_target "$INV_TEST_LOG" test-r16-inventory 182 INV_TEST_RC=$RC 183 G1=NOT_RUN; G2=NOT_RUN; UNCLASS=""; AREACH="" 184 if [ "$INV_RC" != NOT_RUN ] || [ -s "$INV_JSON" ]; then 185 if [ ! -s "$INV_JSON" ]; then 186 G1=FAIL; G2=FAIL 187 else 188 UNCLASS=$(jint "$INV_JSON" unclassified) 189 AREACH=$(jint "$INV_JSON" a_reachable) 190 g1=PASS 191 for k in unclassified question_rows bad_class stale_rows map_errors skipped_repos; do 192 [ "$(jint "$INV_JSON" "$k")" = 0 ] || g1=FAIL 193 done 194 for r in omega aien-sovereign-core aegis-runtime aienos physics; do 195 [ -n "$(repohead "$INV_JSON" "$r")" ] || g1=FAIL # every scanned commit recorded 196 done 197 G1=$g1 198 g2=PASS 199 [ "$INV_RC" = 0 ] || g2=FAIL 200 [ "$(jstrv "$INV_JSON" result)" = PASS ] || g2=FAIL 201 [ "$AREACH" = 0 ] || g2=FAIL 202 G2=$(combine "$g2" "$(verdict "$INV_TEST_RC" "$INV_TEST_LOG" "R16 inventory self-test: PASS")") 203 fi 204 fi 205 echo " G1=$G1 G2=$G2 (unclassified=${UNCLASS:-n/a} a_reachable=${AREACH:-n/a})" 206 207 # ---- 3. G3: authoritative path without legacy orchestrators ------------------ 208 echo "[*] R16-G3: authpath host and silicon..." 209 SILICON_BROKEN=0 210 V=NOT_RUN 211 run_target "$RAW_DIR/r16_authpath_host.log" test-r16-authpath 212 G3H=$(verdict "$RC" "$RAW_DIR/r16_authpath_host.log" "R16 gate: R16_G3_AUTHPATH=HOST_PASS_NON_SILICON") 213 # silicon_run : sets V. After one silicon failure the 214 # remaining silicon targets are NOT run (a failed seat run can leave the chip in a bad state). 215 silicon_run() { 216 local log=$2 pat=$3; shift 3 217 if [ "$SILICON_BROKEN" = 1 ]; then V=NOT_RUN; return 0; fi 218 run_target "$log" "$@" 219 V=$(verdict "$RC" "$log" "$pat") 220 if [ "$V" = FAIL ]; then SILICON_BROKEN=1; fi 221 return 0 222 } 223 silicon_run g3s "$RAW_DIR/r16_authpath_silicon.log" "R16 gate: R16_G3_AUTHPATH=PASS" test-r16-authpath-silicon 224 G3S=$V 225 G3=$(combine "$G3H" "$G3S") 226 echo " G3=$G3 (host $G3H, silicon $G3S)" 227 228 # ---- 4. G4: negative tests and load-bearing mutants ------------------------- 229 echo "[*] R16-G4: negative tests and mutants..." 230 run_target "$RAW_DIR/r16_negative.log" test-r16-negative 231 G4A=$(verdict "$RC" "$RAW_DIR/r16_negative.log" "R16 gate: R16_G4_LEGACY_REFUSED=PASS") 232 run_target "$RAW_DIR/r16_negative_mutants.log" test-r16-negative-mutants 233 G4B=$(verdict "$RC" "$RAW_DIR/r16_negative_mutants.log" "R16 gate: R16_G4_GUARDS_LOAD_BEARING=PASS") 234 G4=$(combine "$G4A" "$G4B") 235 echo " G4=$G4" 236 237 # ---- 5. G5: surface ---------------------------------------------------------- 238 echo "[*] R16-G5: surface check..." 239 run_target "$RAW_DIR/r16_surface.log" test-r16-surface 240 G5=$(verdict "$RC" "$RAW_DIR/r16_surface.log" "R16 gate: R16_G5_SURFACE=PASS") 241 echo " G5=$G5" 242 243 # ---- 6. G7: R1-R15 ladder on the candidate ---------------------------------- 244 echo "[*] R16-G7: ladder..." 245 # name|make target|log|pattern|silicon(0/1) 246 LADDER='R1_R6|test-r3|r1_r6_heartbeat.log|R4_CAUSAL_TRACE: PASS|0 247 R7|test-r7|r7_native.log|native authority matched the linux oracle|0 248 R8|test-r8|r8_aegis.log|failures 0|0 249 R9|test-r9|r9_barrier.log|generation barrier kept a single coherent generation|0 250 R10|test-r10|r10_omega.log|failures 0|0 251 R11|test-r11|r11_aien.log|failures 0|0 252 R12_host|test-r12|r12_host.log|failures 0|0 253 R12_silicon|test-r12-silicon|r12_silicon.log|silicon 1|1 254 R13_host|test-r13-host|r13_host.log|R13 gate: R13_LIVING_SYSTEM=HOST_PASS_NON_SILICON|0 255 R13_silicon|test-r13-silicon|r13_silicon.log|R13 gate: R13_LIVING_SYSTEM=PASS|1 256 R14_host|test-r14-host|r14_host.log|R14 gate: R14_LIVING_RECOVERY=HOST_PASS_NON_SILICON|0 257 R14_silicon|test-r14-silicon|r14_silicon.log|R14 gate: R14_LIVING_RECOVERY=PASS|1 258 R15_parity_host|test-r15-parity-host|r15_parity_host.log|SEQ_SEMANTIC_PARITY=PASS|0 259 R15_g7_host|test-r15-g7-host|r15_g7_host.log|R15 G7 worker split: 57 checks, 0 failures|0 260 R15_parity_silicon|test-r15-parity-silicon|r15_parity_silicon.log|SEQ_SEMANTIC_PARITY=PASS|1 261 R15_receipt|test-r15-receipt|r15_receipt.log|r15 receipt test: 0 failure(s)|0' 262 declare -A LV TG LOGF SEATOF # SEATOF: host or silicon, the seat each test ran on 263 SILICON_RAN=0; SILICON_PASS=0 264 if [ "$G3S" != NOT_RUN ]; then 265 SILICON_RAN=1 266 if [ "$G3S" = PASS ]; then SILICON_PASS=1; fi 267 fi 268 while IFS='|' read -r name target log pat sil; do 269 TG[$name]=$target; LOGF[$name]="$RAW_DIR/$log" 270 if [ "$sil" = 1 ]; then SEATOF[$name]=silicon; else SEATOF[$name]=host; fi 271 if [ "$sil" = 1 ]; then 272 silicon_run "$name" "$RAW_DIR/$log" "$pat" "$target" 273 LV[$name]=$V 274 if [ "$V" != NOT_RUN ]; then SILICON_RAN=$((SILICON_RAN + 1)); fi 275 if [ "$V" = PASS ]; then SILICON_PASS=$((SILICON_PASS + 1)); fi 276 else 277 run_target "$RAW_DIR/$log" "$target" 278 LV[$name]=$(verdict "$RC" "$RAW_DIR/$log" "$pat") 279 # A rung whose living part did not run (R11 refuses to start above load 2 and still 280 # exits 0 with "failures 0") is NOT_RUN, never PASS. 281 if [ "${LV[$name]}" = PASS ] && grep -Fq -- "[-] living run not exercised" "$RAW_DIR/$log"; then 282 LV[$name]=NOT_RUN 283 fi 284 fi 285 echo " $name: ${LV[$name]}" 286 done <<< "$LADDER" 287 288 # R15 physical acceptance (R15 spec G1-G16) is judged from the R15 receipt on this 289 # candidate, supplied by the caller. No receipt: NOT_RUN. 290 R15ACC=NOT_RUN 291 if [ -n "${R16_R15_RECEIPT:-}" ]; then 292 R15ACC=PASS 293 f=$R16_R15_RECEIPT 294 if [ ! -s "$f" ]; then 295 R15ACC=FAIL 296 else 297 [ "$(basename "$f" .json)" = "$(sha256sum "$f" | cut -d' ' -f1)" ] || R15ACC=FAIL 298 grep -Fq "\"outcome\": \"PASS\"" "$f" || R15ACC=FAIL 299 grep -Fq "\"candidate_commit\": \"$CANDIDATE_COMMIT\"" "$f" || R15ACC=FAIL 300 grep -Fq "\"candidate_bound\": true" "$f" || R15ACC=FAIL 301 grep -Fq "\"tree_dirty\": false" "$f" || R15ACC=FAIL 302 grep -Fq "\"silicon_observed\": true" "$f" || R15ACC=FAIL 303 fi 304 fi 305 G7=$(combine "${LV[R1_R6]}" "${LV[R7]}" "${LV[R8]}" "${LV[R9]}" "${LV[R10]}" "${LV[R11]}" "${LV[R12_host]}" \ 306 "${LV[R12_silicon]}" "${LV[R13_host]}" "${LV[R13_silicon]}" "${LV[R14_host]}" "${LV[R14_silicon]}" \ 307 "${LV[R15_parity_host]}" "${LV[R15_g7_host]}" "${LV[R15_parity_silicon]}" "${LV[R15_receipt]}" "$R15ACC") 308 echo " G7=$G7 (R15 acceptance receipt: $R15ACC)" 309 310 # ---- 7. G6: protected things kept ------------------------------------------- 311 # The twelve items of spec R16-G6: the six section-49 items plus R9 crash recovery, R10 312 # verifier, R12 seat-loss handling, R14 recovery paths, operator emergency controls and 313 # the benchmark reference paths (SEQ). Presence and operation are separate facts: 314 # * present = every named implementation symbol is DEFINED in its file (a function 315 # definition line; a comment, prototype or call does not count). Absent: MISSING_IMPLEMENTATION. 316 # An item with no implementation named at all is MISSING_IMPLEMENTATION (never a proxy PASS). 317 # * operated = every named exercising test ran in THIS invocation and passed (exit 318 # status AND required log line). A log that reports a skipped or unexercised run is 319 # NOT_RUN, never PASS. FAIL if any test ran and failed. 320 # Item status: MISSING_IMPLEMENTATION if not present; else FAIL > NOT_RUN > PASS over its 321 # tests. G6 combines the items like combine() (FAIL > NOT_RUN/MISSING > PASS); G6 names 322 # MISSING_IMPLEMENTATION when an item is missing and nothing failed. 323 # Each item carries its own "basis" text in the receipt: it says whether the file:symbol is 324 # what the spec itself names or a mapping chosen here (PROXY), and what the tests do not cover. 325 echo "[*] R16-G6: protected things kept..." 326 # g6_defined : f = C function definition line, t = fixed text, 327 # l = function definition in the aienos source at the FULL aienos.lock commit (the trusted 328 # capability root). Kind l reads immutable blobs through tools/aienos_lock_source.sh: the 329 # repository must hold the locked commit object, every object read is re-hashed, replace 330 # refs are off. Files in AIENOS_R7_DIR, a build cache or a directory name are never read 331 # for it; the repository around AIENOS_R7_DIR may serve objects, which prove themselves. 332 # Returns 0 defined, 1 absent (the locked commit was read: file or symbol not there), 333 # 2 cannot look (no repository holds the locked commit, or the lock is malformed). 334 G6_LOCK_COMMIT=$(head -n 1 "$HERE/aienos.lock" 2>/dev/null || true) 335 g6_lock() { AIENOS_LOCK=$G6_LOCK_COMMIT bash "$HERE/tools/aienos_lock_source.sh" "$@"; } 336 G6_LOCK_IDENTITY=$(g6_lock identity 2>/dev/null) || true 337 [ -n "$G6_LOCK_IDENTITY" ] || G6_LOCK_IDENTITY="{\"aienos_lock\": \"$G6_LOCK_COMMIT\", \"source\": \"none\", \"status\": \"malformed_lock\"}" 338 declare -A G6BLOB 339 g6_defined() { 340 local re="^[A-Za-z_][^;]*[ *]$2\\([^;]*\$" 341 if [ "$3" = l ]; then 342 local src rc 343 src=$(g6_lock show "$1" 2>/dev/null); rc=$? 344 [ "$rc" = 0 ] || return "$rc" 345 G6BLOB[$1]=$(g6_lock blob "$1" 2>/dev/null) 346 printf '%s\n' "$src" | grep -Eq -- "$re"; return $? 347 fi 348 [ -f "$HERE/$1" ] || return 1 349 if [ "$3" = t ]; then grep -Fq -- "$2" "$HERE/$1"; else grep -Eq -- "$re" "$HERE/$1"; fi 350 } 351 # M19 accelerator world (the known-good fallback, spec lines 182-183) and its maintenance 352 # entry: one silicon run. PASS needs exit 0, no [FAIL] gate line and "N / N M19 GATES PASSED" 353 # with N equal and nonzero. 354 silicon_run m19 "$RAW_DIR/m19_world.log" "M19 GATES PASSED" test-m19 355 LV[M19]=$V; TG[M19]=test-m19; LOGF[M19]="$RAW_DIR/m19_world.log"; SEATOF[M19]=silicon 356 if [ "${LV[M19]}" = PASS ]; then 357 if grep -Fq -- "[FAIL]" "$RAW_DIR/m19_world.log" || \ 358 ! grep -Eq -- "PERSISTENT WORLD QUALIFICATION: ([1-9][0-9]*) / \1 M19 GATES PASSED" "$RAW_DIR/m19_world.log"; then 359 LV[M19]=FAIL 360 fi 361 fi 362 # R16 G6 operator emergency stop runtime (spec/r16-operator-emergency-stop.md): host test 363 # plus the guard mutants. PASS needs exit 0 and both pass lines. 364 run_target "$RAW_DIR/rx_emergency.log" test-rx-emergency 365 LV[RX_EMERGENCY]=$(verdict "$RC" "$RAW_DIR/rx_emergency.log" "RX_EMERGENCY_MUTANTS: PASS") 366 if [ "${LV[RX_EMERGENCY]}" = PASS ] && ! grep -Fq -- "RX_EMERGENCY_STOP: PASS" "$RAW_DIR/rx_emergency.log"; then 367 LV[RX_EMERGENCY]=FAIL 368 fi 369 TG[RX_EMERGENCY]=test-rx-emergency; LOGF[RX_EMERGENCY]="$RAW_DIR/rx_emergency.log" 370 # R16 G6 operator control by execution (docs/r16-operator-control.md section 7): the production 371 # program driven from outside by the operator client. Host: the integration test plus its 372 # mutants, both must pass. Silicon: the same test on the resident seat. Labelled apart. 373 # Each seat's test writes its receipt to OP_OUT (beside the raw directory, untracked); the 374 # receipt is copied INTO the raw directory, so the raw digest covers it, and a PASS needs 375 # the receipt to name this seat, this candidate on a clean tree, no failure or skip, the 376 # seat's own gate value, and the SHA-256 of the production binary this run built 377 # (build/rx_r13_living_, file name included). A test that skipped a case (gate 378 # NOT_RUN, exit 0) is NOT_RUN, never FAIL and never PASS. 379 OP_OUT="$OUT_ROOT/$RUN_ID.operator" 380 export RX_OP_OUT="$OP_OUT" 381 OPV=NOT_RUN 382 # op_receipt : sets OPV to the verdict after the receipt check. 383 op_receipt() { 384 local seat=$1 want=$3 f="$RAW_DIR/operator_$1_receipt.json" bin="$HERE/build/rx_r13_living_$1" why="" 385 OPV=$2 386 if [ "$DRY" != 1 ]; then 387 rm -f "$f" 388 if [ -f "$OP_OUT/operator_${seat}_receipt.json" ]; then cp "$OP_OUT/operator_${seat}_receipt.json" "$f"; fi 389 fi 390 [ "$OPV" = PASS ] || return 0 391 if [ ! -s "$f" ]; then why="no operator receipt" 392 elif [ "$(jstrv "$f" seat)" != "$seat" ]; then why="receipt seat is not $seat" 393 elif [ "$(jstrv "$f" binary)" != "rx_r13_living_$seat" ]; then why="receipt binary $(jstrv "$f" binary) is not rx_r13_living_$seat" 394 elif [ ! -f "$bin" ] || [ "$(jstrv "$f" binary_sha256)" != "$(sha256sum "$bin" | cut -d' ' -f1)" ]; then why="receipt binary digest is not the production binary built in this run" 395 elif [ "$(jstrv "$f" candidate_commit)" != "$CANDIDATE_COMMIT" ]; then why="receipt candidate commit is not $CANDIDATE_COMMIT" 396 elif [ "$(sed -n 's/^.*"tree_dirty": *\([a-z]*\).*$/\1/p' "$f")" != false ]; then why="receipt tree not clean" 397 elif [ "$(jint "$f" failures)" != 0 ] || [ "$(jint "$f" skipped)" != 0 ]; then why="receipt counts failures or skips" 398 elif [ "$(sed -n 's/^.*"R16_G6_OPERATOR": "\([^"]*\)".*$/\1/p' "$f")" != "$want" ]; then why="receipt gate is not $want" 399 fi 400 if [ -n "$why" ]; then OPV=FAIL; echo " operator $seat receipt: FAIL ($why)" 401 else echo " operator $seat receipt: bound (binary $(jstrv "$f" binary_sha256 | cut -c1-12))"; fi 402 } 403 # op_notrun : a run that exited with an accepted status and 404 # printed a NOT_RUN gate line is NOT_RUN. 405 op_notrun() { 406 local v=$1 log=$2 rc=$3 ok; shift 3 407 for ok in "$@"; do 408 if [ "$rc" = "$ok" ] && [ -s "$log" ] && grep -Eq -- "(R16_G6_OPERATOR|RX_OPERATOR_MUTANTS)(=|: )NOT_RUN" "$log"; then echo NOT_RUN; return; fi 409 done 410 echo "$v" 411 } 412 rm -f "$OP_OUT/operator_host_receipt.json" "$OP_OUT/operator_silicon_receipt.json" 413 run_target "$RAW_DIR/r16_operator_host.log" test-r16-operator-host 414 LV[R16_OP_HOST]=$(op_notrun "$(verdict "$RC" "$RAW_DIR/r16_operator_host.log" "R16 operator gate: R16_G6_OPERATOR=HOST_PASS_NON_SILICON")" "$RAW_DIR/r16_operator_host.log" "$RC" 0) 415 op_receipt host "${LV[R16_OP_HOST]}" HOST_PASS_NON_SILICON; LV[R16_OP_HOST]=$OPV 416 TG[R16_OP_HOST]=test-r16-operator-host; LOGF[R16_OP_HOST]="$RAW_DIR/r16_operator_host.log" 417 run_target "$RAW_DIR/r16_operator_mutants.log" test-r16-operator-mutants 418 LV[R16_OP_MUTANTS]=$(op_notrun "$(verdict "$RC" "$RAW_DIR/r16_operator_mutants.log" "RX_OPERATOR_MUTANTS: PASS")" "$RAW_DIR/r16_operator_mutants.log" "$RC" 3) 419 TG[R16_OP_MUTANTS]=test-r16-operator-mutants; LOGF[R16_OP_MUTANTS]="$RAW_DIR/r16_operator_mutants.log" 420 silicon_run r16op "$RAW_DIR/r16_operator_silicon.log" "R16 operator gate: R16_G6_OPERATOR=PASS" test-r16-operator-silicon 421 if [ "$V" = FAIL ]; then 422 V=$(op_notrun "$V" "$RAW_DIR/r16_operator_silicon.log" "$RC" 0) 423 if [ "$V" = NOT_RUN ]; then SILICON_BROKEN=0; fi # it skipped a case; nothing failed on the chip 424 fi 425 op_receipt silicon "$V" PASS; LV[R16_OP_SILICON]=$OPV 426 if [ "$OPV" != NOT_RUN ]; then SILICON_RAN=$((SILICON_RAN + 1)); fi 427 if [ "$OPV" = PASS ]; then SILICON_PASS=$((SILICON_PASS + 1)); fi 428 TG[R16_OP_SILICON]=test-r16-operator-silicon; LOGF[R16_OP_SILICON]="$RAW_DIR/r16_operator_silicon.log"; SEATOF[R16_OP_SILICON]=silicon 429 unset RX_OP_OUT 430 # g6_test : status of one exercising test; a skipped or unexercised log is NOT_RUN. 431 g6_test() { 432 local s=${LV[$1]:-NOT_RUN} 433 if [ "$s" = PASS ] && [ -s "${LOGF[$1]:-/nonexistent}" ] && grep -Eq -- "SKIPPED|not exercised" "${LOGF[$1]}"; then s=NOT_RUN; fi 434 echo "$s" 435 } 436 # key|file:symbol:kind;...|tests (comma separated)|basis 437 G6_ITEMS='known_good_fallback_present|src/omega_accelerator_world.c:omega_world_drain:f;src/omega_accelerator_world.c:omega_world_init:f|M19|Spec lines 182-183 name M19 omega_world_* as the known-good fallback (class C): the spec own mapping, not a proxy. Exercised by test-m19 (silicon, N/N gates). Does not test falling back from the reaction world to the M19 world. 438 recovery_path_present|src/runtime/rx_generation.c:rx_gen_recover:f|R9,R14_host|PROXY: the spec names no single recovery symbol; rx_gen_recover is the generation-store crash recovery chosen here. R9 stops after each persistence step and R14 host recovers; boot or repair recovery outside omega is not covered. 439 deterministic_maintenance_controls_present|src/omega_world_gates.c:run_m19_gates:f;tools/omegatool.c:--run-m19-gates:t|M19|Spec line 182 classes omegatool --run-*-gates as B (deterministic maintenance). PARTIAL: only the M19 runner is exercised (by test-m19); the other --run-*-gates entries are not. 440 trusted_capability_root_present|src/runtime/rx_native_bind.c:rx_world_init_native:f;native/capability/aienos_capability.c:aienos_cap_validate:l;native/capability/aienos_capability.c:aienos_cap_mint:l|R7,R12_host|Spec C3: the native C library at aienos.lock is the sole authoritative root. Checks that source as immutable blobs of the FULL locked commit (tools/aienos_lock_source.sh; identity in g6_lock_source) plus the omega binding; NOT_RUN if no repository holds the locked commit, MISSING_IMPLEMENTATION if the locked commit was read and lacks a symbol. R7 compares native authority with the Linux oracle. 441 generation_mechanism_present|src/runtime/rx_generation.c:rx_gen_propose:f|R9,R13_host|Map row OM-022 and spec line 659 name rx_generation.c as the protected generation mechanism; rx_gen_propose is the entry chosen here (PROXY for the symbol). R9 barrier and R13 host promote. 442 evidence_present|src/omega_evidence.c:omega_evidence_write_digest:f|R15_receipt,R9|PROXY: the spec names no evidence symbol; omega_evidence_write_digest (content-addressed evidence writer) chosen here. R15 receipt test and R9 evidence blob exercise it indirectly. 443 r9_crash_recovery_passing|src/runtime/rx_generation.c:rx_gen_recover:f|R9|PROXY: R9 exercises rx_gen_recover (same routine as recovery_path_present, not independent). PASS means the R9 barrier test passed in this run. 444 r10_verifier_passing|src/omega_verify.c:omega_verify_v0_structural:f|R10|PROXY: omega_verify_v0_structural is the verifier R10 reaches through rx_omega.c; R10 pass in this run is the evidence. 445 r12_seat_loss_handling_passing|src/runtime/rx_world.c:rx_resident_seat_lost:f|R12_host,R12_silicon|rx_resident_seat_lost is the seat-loss handler (spec/r12-resident-seat.md, Seat loss). R12 host and silicon exercise it; rx_gpu_seat_kill is only the test hook and is not counted here. 446 r14_recovery_paths_passing|src/runtime/rx_living.c:fn_restore:f|R14_host,R14_silicon|PROXY: fn_restore (generation.restore reaction) is one R14 recovery path chosen here; R14 host and silicon exercise the recovery runs. 447 operator_emergency_controls_passing|src/runtime/rx_world.c:rx_world_emergency_stop:f;src/runtime/rx_world.c:rx_world_emergency_resume:f;src/runtime/rx_world.c:rx_world_operator_authorize:f;src/runtime/rx_generation.c:rx_gen_promote:f;src/runtime/rx_operator.c:rx_operator_open:f;tests/runtime/rx_r13_living.c:operator_open:f;tests/runtime/rx_r13_living.c:operator_audit:f|RX_EMERGENCY,R12_host,R16_OP_HOST,R16_OP_MUTANTS,R16_OP_SILICON|The runtime control (spec/r16-operator-emergency-stop.md: rx_world_emergency_stop / _resume; authority = enrolled caller credential plus an RX_WORLD_RES_CONTROL capability with the privileged RX_RIGHT_EPOCH right, never a reaction subject; a durable sealed OPERATOR_HALT mark that the generation store obeys and a restarted world restores) and its operator entry point in the production R13 program (docs/r16-operator-control.md: owner-only socket rx_operator_open, per-world credential and capability, generation store directory as the durable halt directory, restored stop before any work). Presence of these definitions proves nothing by itself: the item is operated only by execution. RX_EMERGENCY (host, in-process) and R12_host t_emergency_stop cover the runtime; R16_OP_HOST (test-r16-operator-host) starts the production host program and drives stop, status, resume, revoke and shutdown from outside through build/rx_operator, checking replies, the state directory and the crumb-log audit the program prints (no COMMIT or EXTERNAL under a stop); R16_OP_MUTANTS rebuilds the production program from mutated copies (wiring missing, wiring in a comment, unused call, handler disconnected, success reply without a transition, unauthorized resume accepted, and others) and requires the test to fail on each; R16_OP_SILICON is the same test on build/rx_r13_living_silicon (resident GB10 seat, no SIGKILL phase). Host and silicon are separate tests: the item is not PASS without the silicon run. Not covered: effects already outside the world when the stop lands (spec section 7.4), another process of the same uid deleting the mark while no program runs (spec section 7.3). 448 benchmark_reference_paths_seq_passing|src/runtime/rx_seq_reference.c:rx_seq_pulse:f|R15_parity_host,R15_parity_silicon|Spec line 183 names rx_seq_reference as class D reference oracle. R15 parity host and silicon compare the reaction path with it.' 449 declare -A G6S 450 G6LIST=""; G6ALL=""; G6MISSING=0 451 while IFS='|' read -r key pairs tests basis; do 452 present=true; implj="" 453 if [ -z "$pairs" ]; then present=false; fi 454 IFS=';' read -ra PA <<< "$pairs" 455 for p in "${PA[@]}"; do 456 [ -n "$p" ] || continue 457 pf=${p%%:*}; rest=${p#*:}; kind=${rest##*:}; sym=${rest%:*} 458 if g6_defined "$pf" "$sym" "$kind"; then dr=0; else dr=$?; fi 459 if [ "$dr" = 0 ]; then d=true 460 elif [ "$dr" = 2 ]; then d='"unreadable"'; if [ "$present" = true ]; then present=unknown; fi 461 else d=false; present=false; fi 462 src_kind=omega_tree; blobj="" 463 if [ "$kind" = l ]; then src_kind=aienos_lock_commit; blobj=", \"blob\": \"${G6BLOB[$pf]:-}\""; fi 464 implj="$implj{\"file\": \"$pf\", \"symbol\": \"$sym\", \"source\": \"$src_kind\", \"defined\": $d$blobj}, " 465 done 466 implj=${implj%, } 467 tj=""; ts=PASS; IFS=',' read -ra TA <<< "$tests" 468 for t in "${TA[@]}"; do 469 s=$(g6_test "$t"); ts=$(combine "$ts" "$s") 470 tj="$tj{\"name\": \"$t\", \"target\": \"${TG[$t]}\", \"seat\": \"${SEATOF[$t]:-host}\", \"status\": \"$s\"}, " 471 done 472 tj=${tj%, } 473 if [ "$present" = false ]; then st=MISSING_IMPLEMENTATION; G6MISSING=$((G6MISSING + 1)) 474 elif [ "$present" = unknown ]; then st=$(combine "$ts" NOT_RUN) 475 else st=$ts; fi 476 G6S[$key]=$st; G6ALL="$G6ALL $st" 477 G6LIST="$G6LIST {\"item\": \"$key\", \"status\": \"$st\", \"present\": \"$present\", \"implementation\": [$implj], \"tests\": [$tj], \"basis\": \"$basis\"}, 478 " 479 echo " $key: $st" 480 done <<< "$G6_ITEMS" 481 G6LIST=${G6LIST%$'\n'}; G6LIST=${G6LIST%,} 482 # shellcheck disable=SC2086 483 G6=$(combine $G6ALL) 484 if [ "$G6" = NOT_RUN ] && [ "$G6MISSING" -gt 0 ] && [[ " $G6ALL " != *" FAIL "* ]]; then G6=MISSING_IMPLEMENTATION; fi 485 echo " G6=$G6 (items missing: $G6MISSING)" 486 g6j() { local s=${G6S[$1]}; if [ "$s" = PASS ]; then echo true; elif [ "$s" = FAIL ]; then echo false; else echo "\"$s\""; fi; } 487 488 # ---- 8. observed binding ---------------------------------------------------------- 489 END_COMMIT=$(git rev-parse HEAD) 490 if [ -n "$(git status --porcelain)" ]; then TREE_DIRTY=true; else TREE_DIRTY=false; fi 491 if [ "$END_COMMIT" = "$CANDIDATE_COMMIT" ] && [ "$RUN_COMMIT" = "$CANDIDATE_COMMIT" ] && [ "$TREE_DIRTY" = false ]; then 492 CAND_BOUND=true 493 else 494 CAND_BOUND=false 495 fi 496 # silicon_observed: every silicon target (authpath, R12, R13, R14, R15 parity, R16 G6 497 # operator control on the resident seat) ran and passed. Host results never count here. 498 if [ "$SILICON_RAN" -ge 6 ] && [ "$SILICON_PASS" = "$SILICON_RAN" ]; then SIL_OBS=true; else SIL_OBS=false; fi 499 500 # ---- 9. receipt --------------------------------------------------------------------- 501 SC_COMMIT=$(repohead "$INV_JSON" aien-sovereign-core) 502 AR_COMMIT=$(repohead "$INV_JSON" aegis-runtime) 503 REMAINING_CENTRAL='"NOT_RUN"' 504 if [ -n "$AREACH" ]; then REMAINING_CENTRAL=$AREACH; fi 505 REMAINING_UNCLASS='"NOT_RUN"' 506 if [ -n "$UNCLASS" ]; then REMAINING_UNCLASS=$UNCLASS; fi 507 508 # G8 (spec/r16-orchestrator-retirement.md §G8) includes "the PR is merged with a merge 509 # commit" and silicon_observed = true. This script runs before any merge, so it can 510 # never observe the whole gate: G8 is always NOT_RUN here. It reports only whether the 511 # receipt preconditions hold (bound, clean tree, silicon observed, not dry); G8 is 512 # decided after the merge by whoever checks the merge commit. 513 if [ "$CAND_BOUND" = true ] && [ "$TREE_DIRTY" = false ] && [ "$SIL_OBS" = true ] && [ "$DRY" != 1 ]; then 514 G8_PRECONDITIONS=met 515 else 516 G8_PRECONDITIONS=not_met 517 fi 518 G8=NOT_RUN 519 echo "[*] R16-G8: NOT_RUN (merge-commit part is outside this script; receipt preconditions $G8_PRECONDITIONS)" 520 521 OVERALL=$(combine "$G1" "$G2" "$G3" "$G4" "$G5" "$G6" "$G7" "$G8") 522 523 lr() { printf ' "%s": {"status": "%s", "target": "%s"}' "$1" "${LV[$2]}" "${TG[$2]}"; } 524 RAW_DIGEST="NOT_RUN" 525 (cd "$RAW_DIR" && rm -f SHA256SUMS && ls | grep -v '^SHA256SUMS$' | LC_ALL=C sort | xargs sha256sum > SHA256SUMS) || true 526 if [ -s "$RAW_DIR/SHA256SUMS" ]; then RAW_DIGEST=$(sha256sum "$RAW_DIR/SHA256SUMS" | cut -d' ' -f1); fi 527 RAW_REL=${RAW_DIR#"$HERE"/} 528 529 OUT_RECEIPT_TMP="$RAW_DIR/receipt.raw.json" 530 cat > "$OUT_RECEIPT_TMP" < "$RAW_DIR/json_canon" && chmod +x "$RAW_DIR/json_canon" 631 "$RAW_DIR/json_canon" --pretty < "$OUT_RECEIPT_TMP" > "$RAW_DIR/receipt.pretty.json" 632 RECEIPT_SHA=$(sha256sum "$RAW_DIR/receipt.pretty.json" | cut -d' ' -f1) 633 mkdir -p "$OUT_ROOT/receipts" 634 FINAL_PATH="$OUT_ROOT/receipts/$RECEIPT_SHA.json" 635 "$RAW_DIR/json_canon" --write-exclusive "$FINAL_PATH" < "$RAW_DIR/receipt.pretty.json" 636 chmod 0444 "$FINAL_PATH" 637 if [ "$(sha256sum "$FINAL_PATH" | cut -d' ' -f1)" != "$RECEIPT_SHA" ]; then 638 echo "ERROR: receipt not named by its own SHA-256" >&2 639 exit 1 640 fi 641 rm -f "$OUT_RECEIPT_TMP" "$RAW_DIR/receipt.pretty.json" 642 fi 643 644 echo "Gates: G1=$G1 G2=$G2 G3=$G3 G4=$G4 G5=$G5 G6=$G6 G7=$G7 G8=$G8" 645 echo "Receipt (untracked): $FINAL_PATH" 646 echo "R16_QUALIFY_RESULT=$OVERALL" 647 case "$OVERALL" in 648 PASS) exit 0 ;; 649 FAIL) exit 1 ;; 650 *) exit 3 ;; 651 esac