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/tests/r16_qualify/run.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 / 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 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_= 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 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