From 7d29d1da6b196d19308250d87c243a9049a9c403 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 1 Oct 2026 11:47:50 -0500 Subject: [PATCH 1/4] Lane 32 follow-up: R16 map covers today's loop sites; r16_qualify.sh claims only what it checked Classify 47 loop sites (OM-152..OM-198), print scanned repo heads in the inventory, rewrite r16_qualify.sh (dirty tree refused, observed fields, real gate checks, NOT_RUN when unchecked, untracked raw evidence, schema revision 2), add dry-mode self-test wired into host-suites-2 runtime job. Co-Authored-By: Drake Stapleton Co-Authored-By: Claude Opus 5.5 --- .github/workflows/host-suites-2.yml | 5 +- Makefile | 5 + spec/r16-orchestrator-retirement-map.md | 64 +++ tests/r16_qualify/run.sh | 86 ++++ tools/r16_loop_inventory.c | 1 + tools/r16_qualify.sh | 624 +++++++++++++++--------- 6 files changed, 545 insertions(+), 240 deletions(-) create mode 100644 tests/r16_qualify/run.sh diff --git a/.github/workflows/host-suites-2.yml b/.github/workflows/host-suites-2.yml index f45ebab02..415cce278 100644 --- a/.github/workflows/host-suites-2.yml +++ b/.github/workflows/host-suites-2.yml @@ -23,7 +23,7 @@ name: Host suites 2 # test-ma-digital-bottom 3.5 min # path : test-path 30 s; crumbline : test-crumbline 1 s # runtime : test-r15-instr test-r15-receipt test-r16-inventory -# test-r16-negative test-r16-surface +# test-r16-negative test-r16-surface test-r16-qualify-selftest # test-r16-negative-mutants 5 min (Spark: 4.3 min) # argus : test-argus-runtime test-machine-identity-argus # numeric2 : test-numeric-reduce-cpu test-divsqrt-host 6 s @@ -326,6 +326,9 @@ jobs: PHYSICS_DIR: ${{ github.workspace }}/physics-src AIENOS_R7_DIR: ${{ github.workspace }}/aienos-src run: make test-r16-negative-mutants + - name: R16 qualify script self-test (dirty tree refused, NOT_RUN honest, failing check exits non-zero) + if: ${{ !cancelled() }} + run: make test-r16-qualify-selftest argus: needs: changes diff --git a/Makefile b/Makefile index 25a2da753..7100cca04 100644 --- a/Makefile +++ b/Makefile @@ -762,6 +762,11 @@ r16-inventory: $(R16_INVENTORY) test-r16-inventory: $(R16_INVENTORY) sh tests/r16_inventory/run.sh $(R16_INVENTORY) +# Lane 32 follow-up: dry-mode self-test of tools/r16_qualify.sh (no chip, no build). +.PHONY: test-r16-qualify-selftest +test-r16-qualify-selftest: + bash tests/r16_qualify/run.sh + # R16-G3: the authoritative path with the legacy orchestrators unavailable. # Link map, shared libraries, embedded names and an exec trace of the R13 # living system and the R14 recovery run, legacy programs stubbed on PATH. diff --git a/spec/r16-orchestrator-retirement-map.md b/spec/r16-orchestrator-retirement-map.md index e9b8518e2..7878b563b 100644 --- a/spec/r16-orchestrator-retirement-map.md +++ b/spec/r16-orchestrator-retirement-map.md @@ -250,6 +250,53 @@ any production binary); in-file Rust `#[cfg(test)]` modules likewise. | OM-149 | omega | `tools/omegatool.c` | 3811 | `main` | surface-check resolver (R16-G5) | reference mode dry run | D | false | `--reference-dispatch-dry-run ` resolves a mode through the real dispatch and runs nothing; used only by tests/r16_surface/run.sh | `if (strcmp(argv[1], "--reference-dispatch-dry-run") == 0) {` | | OM-150 | omega | `tests/runtime/rx_r16_negative.c` | 625 | `main` | test/benchmark loop (for:body:nanosleep) | test / reference path | D | false | test, benchmark or example code; not built into any production binary (R16-G4 waits for one honest production request) | `for (int i = 0; i < 50 && r->served == served0; i++) nanosleep(&ts, NULL);` | | OM-151 | omega | `tests/path/test_path_identity.c` | 281 | `realization_separation` | test/benchmark loop (for:body:schedule) | test / reference path | D | false | test, benchmark or example code; not built into any production binary | `for (unsigned field = 0; field < 5; field++) {` | +| OM-152 | omega | `src/compiler/model/osc_model_gen.c` | 282 | `teardown` | compiler test-model event generator | - | N | false | N: walk: drains the open borrows of one object by picking and ending them until none is left, without wait or hand-off; generates test events only | `for (;;) {` | +| OM-153 | omega | `src/compiler/osc_interp.c` | 142 | `run_func` | reference interpreter basic-block loop | reference / test path (non-authoritative) | D | false | reference interpreter of compiled OSC IR, used to check the compiler (src/compiler and tests only); runs one function's blocks, bounded by OSC_INTERP_MAX_STEPS; sequences no faculties | `for (;;) {` | +| OM-154 | omega | `src/compiler/osc_lex.c` | 66 | `osc_lex` | OSC lexer token loop | - | N | false | N: parse: lexer token loop without wait or hand-off | `for (;;) {` | +| OM-155 | omega | `src/compiler/osc_parse.c` | 463 | `parse_call` | call-argument parse loop | - | N | false | N: parse: call argument list parse loop without wait or hand-off | `for (;;) {` | +| OM-156 | omega | `src/compiler/osc_parse.c` | 608 | `parse_level` | binary-operator level parse loop | - | N | false | N: parse: precedence-level operator parse loop without wait or hand-off | `for (;;) {` | +| OM-157 | omega | `src/compiler/osc_parse.c` | 1049 | `parse_fn` | parameter list parse loop | - | N | false | N: parse: function parameter list parse loop without wait or hand-off | `for (;;) {` | +| OM-158 | omega | `src/compiler/oscc_main.c` | 33 | `main` | source file read in the oscc driver | - | N | false | N: read: file read into a growing buffer until end of file, without wait or hand-off | `for (;;) {` | +| OM-159 | omega | `src/estimation/est_mix.c` | 39 | `each_term` | multinomial composition enumeration | - | N | false | N: walk: enumerates the count vectors of a mixture term in odometer order, calling a callback per term, without wait or hand-off | `for (;;) {` | +| OM-160 | omega | `src/fabric/fab_dispatch.c` | 46 | `pump_locked` | in-process simulated-machine fabric pump | reference / test path (non-authoritative) | D | false | F5-0 in-process simulated-machine dispatcher, a test-build piece (carries aien_test_build_fab_dispatch; r16_prod_hygiene refuses it in production binaries); drains one node mailbox with fab_poll, decides no faculty order | `for (;;) {` | +| OM-161 | omega | `src/omega_numeric_reduce.c` | 133 | `cpu_sum_like` | CPU tile-reduction passes | - | N | false | N: arithmetic: repeated 32-wide tile reduction of a float buffer until one value is left, without wait or hand-off | `for (;;) {` | +| OM-162 | omega | `src/omega_numeric_reduce_gb10.c` | 459 | `omega_reduce_gb10` | GB10 reduction level loop | physical scheduler | E | false | GPU reduction launcher: launches the reduction kernel chunk by chunk and folds tile results level by level until one value is left; schedules physical GPU work, decides no faculty order, not on the reaction path | `for (;;) {` | +| OM-163 | omega | `src/runtime/aien_machine_id.c` | 54 | `aien_mid_load` | machine id file read | - | N | false | N: read: file read until end of file or one byte past a record, without wait or hand-off | `for (;;) { /* read one byte past a record so a longer file is caught */` | +| OM-164 | omega | `src/runtime/rx_compose.c` | 84 | `hold_point` | test hold point spin | reference / test path (non-authoritative) | D | false | hold point exists only under RXC_TEST_HOOKS (test builds); spins until the test releases it; no production path | `while (!__atomic_load_n(&c->test.release, __ATOMIC_ACQUIRE)) nanosleep(&ts, NULL);` | +| OM-165 | omega | `src/runtime/rx_compose.c` | 885 | `wait_own` | composition close drain wait | explicit maintenance mechanism | B | false | explicit operator close of an attached composition: waits (with timeout) until its own in-flight steps finish; drains, orders no faculty work | `while (own_busy(c)) {` | +| OM-166 | omega | `src/runtime/rx_compose.c` | 910 | `leave_world` | composition leave-world drain wait | explicit maintenance mechanism | B | false | explicit operator close of an attached composition: waits until its own revoked steps finish (no cutoff); drains, orders no faculty work | `while (own_busy(c)) nanosleep(&ts, NULL);` | +| OM-167 | omega | `src/runtime/rx_compose.c` | 925 | `leave_world` | composition leave-world reaction removal | explicit maintenance mechanism | B | false | explicit close step 5: walks the composition's own reactions (at most 4) to remove them from the World; orders no faculty work | `for (uint32_t i = 0; i < c->n_rx && i < 4; i++)` | +| OM-168 | omega | `src/runtime/rx_compose.c` | 926 | `leave_world` | composition leave-world BUSY retry | explicit maintenance mechanism | B | false | explicit close step 5: retries removal of one of its own reactions while a step is still finishing (RX_ERR_BUSY); orders no faculty work | `while (rx_world_remove_reaction(c->world, ids[i]) == RX_ERR_BUSY) nanosleep(&ts, NULL);` | +| OM-169 | omega | `src/runtime/rx_cortex.c` | 488 | `cx_provenance` | provenance link walk | - | N | false | N: walk: breadth-first walk of cortex object links with a seen check, without wait or hand-off | `for (;;) {` | +| OM-170 | omega | `src/searchtrace/st_holdout.c` | 612 | `read_file` | whole-file read | - | N | false | N: read: file read into a growing buffer until end of file, without wait or hand-off | `for (;;) {` | +| OM-171 | omega | `src/searchtrace/st_holdout.c` | 838 | `read_key_file` | key file read | - | N | false | N: read: key file read with EINTR retry until end of file, without wait or hand-off | `for (;;) {` | +| OM-172 | omega | `src/searchtrace/st_tool.c` | 22 | `read_file` | whole-file read | - | N | false | N: read: file read into a growing buffer until end of file, without wait or hand-off | `for (;;) {` | +| OM-173 | omega | `src/train/tg_store.c` | 568 | `tg_commit` | dispatch record append walk | - | N | false | N: walk: appends this step's optimizer dispatch records to the hash chain; the records are a training log, not faculty dispatch; no wait or hand-off | `for (uint32_t i = 0; i < sh->n_dispatch; i++) {` | +| OM-174 | omega | `src/train/tg_store.c` | 674 | `tg_verify_history` | generation history walk | - | N | false | N: walk: walks stored generations backward verifying the digest chain, without wait or hand-off | `for (;;) {` | +| OM-175 | omega | `tests/fabric/fab_living_phase.h` | 173 | `fl_pump_b` | test rig mailbox drain | reference / test path (non-authoritative) | D | false | fabric test rig: drains node B mailbox with fab_poll; test code, not built into any production binary | `while (fab_poll(&r->node_b, now, &v) == 1) {}` | +| OM-176 | omega | `tests/fabric/fabric_test.c` | 114 | `pump` | test pump rounds | reference / test path (non-authoritative) | D | false | fabric test: delivers pending messages in rounds, bounded at 64; test code, not built into any production binary | `for (int round = 0; round < 64 && fab_loop_pending(&h->loop); round++)` | +| OM-177 | omega | `tests/fabric/fabric_test.c` | 115 | `pump` | test pump node order | reference / test path (non-authoritative) | D | false | fabric test: visits the three test nodes in fixed order; test code, not built into any production binary | `for (int i = 0; i < 3; i++) {` | +| OM-178 | omega | `tests/fabric/fabric_test.c` | 117 | `pump` | test mailbox drain | reference / test path (non-authoritative) | D | false | fabric test: drains one node mailbox with fab_poll; test code, not built into any production binary | `while (fab_poll(&h->node[i], now, &v) == 1)` | +| OM-179 | omega | `tests/runtime/rx_compose_attach_test.c` | 229 | `rogue_refused` | test remove-reaction retry | reference / test path (non-authoritative) | D | false | composition attach test: retries reaction removal while BUSY; test code, not built into any production binary | `while (rx_world_remove_reaction(&g_w, rid) == RX_ERR_BUSY) sleep_us(1000);` | +| OM-180 | omega | `tests/runtime/rx_compose_attach_test.c` | 385 | `t_close_waits` | test wait for held step | reference / test path (non-authoritative) | D | false | composition attach test: sleep-polls until the held step is reported; test code, not built into any production binary | `while (!__atomic_load_n(&c->test.held, __ATOMIC_ACQUIRE) && waited++ < 10000) sleep_us(1000);` | +| OM-181 | omega | `tests/runtime/rx_compose_attach_test.c` | 388 | `t_close_waits` | test wait for settle | reference / test path (non-authoritative) | D | false | composition attach test: sleep-polls until one step is in flight; test code, not built into any production binary | `for (waited = 0; in_flight() != 1 && waited < 10000; waited++) sleep_us(1000);` | +| OM-182 | omega | `tests/runtime/rx_compose_attach_test.c` | 402 | `t_close_waits` | test wait for revoke | reference / test path (non-authoritative) | D | false | composition attach test: sleep-polls until the write right is revoked; test code, not built into any production binary | `for (waited = 0; waited < 5000 &&` | +| OM-183 | omega | `tests/runtime/rx_jspace_prod.c` | 598 | `test_world` | test race writers | reference / test path (non-authoritative) | D | false | J-Space production test: two racing writers; test code, not built into any production binary | `for (int k = 0; k < 2; k++) {` | +| OM-184 | omega | `tests/runtime/rx_jspace_prod.c` | 617 | `test_world` | test tick publisher | reference / test path (non-authoritative) | D | false | J-Space production test: publishes 40 external tick mutations; test code, not built into any production binary | `for (unsigned t = 1; t <= 40; t++) {` | +| OM-185 | omega | `tests/test_omega_transc.c` | 442 | `pool_worker` | test worker pool | reference / test path (non-authoritative) | D | false | numeric transcendental test: worker thread claims items by atomic counter until exhausted; test code, not built into any production binary | `for (;;) {` | +| OM-186 | omega | `tests/train/test_train.c` | 190 | `t_crash` | test crash matrix | reference / test path (non-authoritative) | D | false | training store test: crash-injection matrix; test code, not built into any production binary | `for (int torn = 0; torn < 2; torn++)` | +| OM-187 | omega | `tests/train/test_train.c` | 191 | `t_crash` | test crash failpoints | reference / test path (non-authoritative) | D | false | training store test: crash-injection failpoint loop; test code, not built into any production binary | `for (int fp = 1; fp < TG_FP_COUNT; fp++) {` | +| OM-188 | omega | `tests/train/test_train.c` | 272 | `t_reader_race` | test reader race | reference / test path (non-authoritative) | D | false | training store test: concurrent reader loop until stop pipe fires; test code, not built into any production binary | `for (;;) {` | +| OM-189 | omega | `tests/train/test_train.c` | 289 | `t_reader_race` | test writer race | reference / test path (non-authoritative) | D | false | training store test: concurrent writer commits with short sleeps; test code, not built into any production binary | `for (int k = 0; k < 150 && st; k++) {` | +| OM-190 | omega | `tests/train/test_train.c` | 423 | `t_cost` | test cost sizes | reference / test path (non-authoritative) | D | false | training store test: cost measurement over two sizes; test code, not built into any production binary | `for (int k = 0; k < 2; k++) {` | +| OM-191 | omega | `tests/train/test_train.c` | 474 | `t_replay` | test replay steps | reference / test path (non-authoritative) | D | false | training store test: replays steps checking the generation chain; test code, not built into any production binary | `for (uint64_t k = 1; k <= (uint64_t)STEPS; k++) {` | +| OM-192 | omega | `tools/estimation/est3c_common.c` | 30 | `c3_json_field` | JSON field parse | - | N | false | N: parse: JSON object field parse loop without wait or hand-off; offline evidence tool, not on the production path | `for (;;) {` | +| OM-193 | omega | `tools/estimation/est3c_common.c` | 112 | `c3_ticks_build` | EST3c tick build line walk | - | N | false | N: walk: walks the input lines of recorded estimation data to build ticks (data ticks, not a scheduler tick), without wait or hand-off; offline evidence tool | `for (size_t li = 0; li < f->nlines; li++) {` | +| OM-194 | omega | `tools/estimation/est3c_common.c` | 135 | `c3_ticks_build` | EST3c inserted-tick walk | - | N | false | N: walk: builds the capped run of inserted-missing ticks for a gap in recorded data, without wait or hand-off; offline evidence tool | `for (uint64_t j = 0; j < ins; j++) {` | +| OM-195 | omega | `tools/estimation/est3c_common.c` | 403 | `c3_score` | EST3c scoring walk | - | N | false | N: walk: scores recorded ticks in order, without wait or hand-off; offline evidence tool | `for (size_t t = 0; t < tk->n && !rc; t++) {` | +| OM-196 | omega | `tools/estimation/est_load.c` | 47 | `spin` | load generator spin worker | reference / test path (non-authoritative) | D | false | EST measurement load generator: busy worker that spins or naps at a set level; measurement tool, not built into any production binary | `while (!atomic_load(&g_quit)) {` | +| OM-197 | omega | `tools/estimation/est_load.c` | 110 | `main` | load generator segment schedule | reference / test path (non-authoritative) | D | false | EST measurement load generator: steps through the load level schedule; measurement tool, not built into any production binary | `for (int i = 0; i < nseg && !g_stop; i++) {` | +| OM-198 | omega | `tools/estimation/est_load.c` | 120 | `main` | load generator segment timer | reference / test path (non-authoritative) | D | false | EST measurement load generator: sleeps until the segment ends; measurement tool, not built into any production binary | `for (;;) {` | | SC-001 | aien-sovereign-core | `benchmarks/crates/bench_apples_to_apples/src/engine_max.rs` | 55 | `start` | test/benchmark loop (while:body:sleep) | test / reference path | D | false | test, benchmark or example code; not built into any production binary | `while start.elapsed() < timeout {` | | SC-002 | aien-sovereign-core | `benchmarks/crates/bench_apples_to_apples/src/telemetry.rs` | 96 | `start` | test/benchmark loop (while:body:tick) | test / reference path | D | false | test, benchmark or example code; not built into any production binary | `while !stop_clone.load(Ordering::Relaxed) {` | | SC-003 | aien-sovereign-core | `benchmarks/crates/bench_apples_to_apples/src/telemetry.rs` | 168 | `enforce_thermal_cooldown` | test/benchmark loop (while:body:sleep) | test / reference path | D | false | test, benchmark or example code; not built into any production binary | `while start.elapsed() < max_wait {` | @@ -492,3 +539,20 @@ the first scan. The tool prints `WARN omega: scanned HEAD ... differs from map SHA`, because the R16 branch builds on top of omega main. Expected. + +### 8.1 Update 2026-10-01 (Lane 32, R16 re-qualification follow-up) + +The R16 re-qualification on candidate `3108fc2` (omega main of 2026-10-01) ran this tool +and found `sites=328 unclassified=47` (receipt `evidence/REQUAL-3108fc2/`, G1 and G2 +FAIL). The 47 sites came from code added after this map's last update (compiler, +estimation, fabric, rx_compose, searchtrace, train, tests, tools). Rows OM-152 to +OM-198 classify them, each from reading the loop, with a one-line reason: 22 class N, +22 class D, 1 class E (`omega_numeric_reduce_gb10.c`, GPU reduction launcher, not on the +reaction path), 4 class B (explicit close/drain of an attached composition in +`rx_compose.c`), 0 class A. (Line numbers in these rows are at omega main `9ca297c`; +the join key does not use them.) No new site sequences faculties on the production +path, so none is an orchestrator-shaped finding. The map is not a gate result: the +gate result is whatever `make r16-inventory` prints on the candidate, recorded in the +qualification receipt. The tool now prints `SCANNED HEAD ()` for every +repository it scans, so a run records exactly which commits it saw (the JSON already +carried `head`). The five-repository scope is unchanged. diff --git a/tests/r16_qualify/run.sh b/tests/r16_qualify/run.sh new file mode 100644 index 000000000..e6ad61a56 --- /dev/null +++ b/tests/r16_qualify/run.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# Self-test for tools/r16_qualify.sh. No chip, no make target, no build: the script runs in +# dry mode (R16_QUALIFY_DRY=1) inside a scratch git repo, reading fixture logs. +# Proves: a dirty tree is refused before anything runs; a gate with no check prints +# NOT_RUN (never PASS); a failing check makes the script exit non-zero; observed fields +# are computed, not literals. Usage: bash tests/r16_qualify/run.sh +set -u +HERE=$(cd "$(dirname "$0")/../.." && pwd) +SCR=$(mktemp -d "${TMPDIR:-/tmp}/r16qual.XXXXXX") || exit 2 +trap 'rm -rf "$SCR"' EXIT INT TERM +FAILS=0 +check() { if eval "$2"; then echo "ok $1"; else echo "FAIL $1"; FAILS=$((FAILS + 1)); fi; } + +W=$SCR/w +mkdir -p "$W/tools" +cp "$HERE/tools/r16_qualify.sh" "$W/tools/" +printf 'build/\n' > "$W/.gitignore" +g() { git -C "$W" -c user.name=r16 -c user.email=r16@invalid -c commit.gpgsign=false "$@"; } +g init -q && g add -A && g commit -qm fixture || exit 2 +Q() { env R16_QUALIFY_DRY=1 "$@" bash "$W/tools/r16_qualify.sh"; } + +# 1. dirty tree refused before anything runs +echo x > "$W/stray.txt" +out=$(Q 2>&1); rc=$? +check "dirty tree: exit 2" '[ $rc = 2 ]' +check "dirty tree: says REFUSED" 'echo "$out" | grep -q "^REFUSED: working tree is dirty"' +check "dirty tree: nothing created (no build dir)" '[ ! -e "$W/build" ]' +check "dirty tree: no gate lines printed" '! echo "$out" | grep -q "R16-G"' +rm -f "$W/stray.txt" +echo y >> "$W/.gitignore" +out=$(Q 2>&1); rc=$? +check "modified tracked file: exit 2" '[ $rc = 2 ]' +g checkout -q -- .gitignore + +# 2. wrong expected commit refused +out=$(Q R16_EXPECT_COMMIT=0000000000000000000000000000000000000000 2>&1); rc=$? +check "unexpected HEAD: exit 2" '[ $rc = 2 ]' + +# 3. output under tracked evidence/ refused +out=$(Q R16_OUT_DIR="$W/evidence/R16/raw" 2>&1); rc=$? +check "output under evidence/: exit 2" '[ $rc = 2 ]' + +# 4. no fixtures: every gate NOT_RUN, nothing PASS, exit 3 +out=$(Q R16_RUN_ID=none 2>&1); rc=$? +R=$W/build/r16-raw/none/DRY-RUN-receipt.json +check "no fixtures: exit 3 (nothing ran)" '[ $rc = 3 ]' +check "no fixtures: G6 prints NOT_RUN" 'echo "$out" | grep -q "R16-G6: NOT_RUN"' +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$"' +check "no fixtures: receipt gate NOT_RUN" 'grep -q "\"gate\": \"NOT_RUN\"" "$R"' +check "no fixtures: receipt has no PASS value" '! grep -q "\"PASS\"" "$R"' +check "no fixtures: silicon_observed false (computed)" 'grep -q "\"silicon_observed\": false" "$R"' +check "no fixtures: tree_dirty false and candidate_bound true observed" 'grep -q "\"tree_dirty\": false" "$R" && grep -q "\"candidate_bound\": true" "$R"' +check "receipt marks schema revision 2" 'grep -q "\"schema_revision\": 2" "$R"' +check "receipt keeps schema name" 'grep -q "\"schema\": \"AIEN_RX_R16_ORCHESTRATOR_RETIRED_V1\"" "$R"' +check "tree still clean after run" '[ -z "$(g status --porcelain)" ]' + +# 5. fixture logs: G4 good, G5 log lacks the required line -> FAIL -> exit 1 +F=$W/build/r16-raw/fx +mkdir -p "$F" +echo "R16 gate: R16_G4_LEGACY_REFUSED=PASS" > "$F/r16_negative.log"; echo 0 > "$F/r16_negative.log.rc" +echo "R16 gate: R16_G4_GUARDS_LOAD_BEARING=PASS" > "$F/r16_negative_mutants.log"; echo 0 > "$F/r16_negative_mutants.log.rc" +echo "surface: something else" > "$F/r16_surface.log"; echo 0 > "$F/r16_surface.log.rc" +out=$(Q R16_RUN_ID=fx 2>&1); rc=$? +R=$W/build/r16-raw/fx/DRY-RUN-receipt.json +check "failing grep: exit non-zero (1)" '[ $rc = 1 ]' +check "failing grep: G5 FAIL" 'echo "$out" | grep -q "G5=FAIL"' +check "failing grep: G4 PASS from its own checks" 'echo "$out" | grep -q "G4=PASS"' +check "failing grep: receipt gate FAIL" 'grep -q "\"gate\": \"FAIL\"" "$R"' + +# 6. target exit status counts even when the pass line is present +echo 1 > "$F/r16_surface.log.rc"; echo "R16 gate: R16_G5_SURFACE=PASS" > "$F/r16_surface.log" +out=$(Q R16_RUN_ID=fx 2>&1); rc=$? +check "bad exit status with pass line: G5 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G5=FAIL"' +echo 0 > "$F/r16_surface.log.rc" +out=$(Q R16_RUN_ID=fx 2>&1); rc=$? +check "good G4/G5 fixtures: those gates PASS" 'echo "$out" | grep -q "G4=PASS" && echo "$out" | grep -q "G5=PASS"' +check "all-good G4/G5 still exit 3 (G6 has no check)" '[ $rc = 3 ] && echo "$out" | grep -q "G6=NOT_RUN"' + +# 7. the script holds no literal for observed fields and does not touch tracked evidence +check "no literal tree_dirty/candidate_bound/silicon_observed values" \ + '! grep -E "\"(tree_dirty|candidate_bound|silicon_observed)\": (true|false)" "$HERE/tools/r16_qualify.sh"' +check "no copy into tracked evidence/" '! grep -E "cp .*evidence/R16|EVID_RAW_DIR" "$HERE/tools/r16_qualify.sh"' +check "no hardcoded home paths" '! grep -E "/home/[a-z]" "$HERE/tools/r16_qualify.sh"' + +if [ "$FAILS" -ne 0 ]; then echo "R16 qualify self-test: $FAILS FAILED"; exit 1; fi +echo "R16 qualify self-test: PASS" diff --git a/tools/r16_loop_inventory.c b/tools/r16_loop_inventory.c index 4612079c0..b5e78b167 100644 --- a/tools/r16_loop_inventory.c +++ b/tools/r16_loop_inventory.c @@ -927,6 +927,7 @@ int main(int argc, char **argv) { int skipped = 0; for (int r = 0; r < NREPO; r++) { scan_repo(r, defp[r]); + if (!repo_skipped[r]) fprintf(stderr, "SCANNED %s HEAD %s (%s)\n", REPO_NAME[r], repo_head[r], defp[r]); if (repo_skipped[r]) { skipped++; fprintf(stderr, "SKIPPED %s: no git work tree at %s (set %s). Skipping is NOT a pass.\n", diff --git a/tools/r16_qualify.sh b/tools/r16_qualify.sh index ebd7a6847..9f5938f12 100755 --- a/tools/r16_qualify.sh +++ b/tools/r16_qualify.sh @@ -1,50 +1,138 @@ #!/bin/bash -# r16_qualify.sh -- R16 Orchestrator Retirement Full Qualification Harness -# Executes G1 through G8 and writes the canonical AIEN_RX_R16_ORCHESTRATOR_RETIRED_V1 receipt. +# r16_qualify.sh -- R16 Orchestrator Retirement qualification harness (schema revision 2). +# +# Runs the R16 gate targets on the current checkout and writes the +# AIEN_RX_R16_ORCHESTRATOR_RETIRED_V1 receipt (field names unchanged; the added field +# "schema_revision": 2 marks the changed semantics below). +# +# Truthfulness rules (revision 2): +# * A dirty tree is REFUSED (exit 2) before anything runs. +# * Every gate status is computed from a real check: a make target's exit status AND +# a required line in its log (or a value read from the inventory JSON). A failing +# check is FAIL. A gate with no implemented check is NOT_RUN, never PASS. +# * candidate_bound, tree_dirty and silicon_observed are computed from what was +# observed during this run, not written as literals. +# * Raw evidence and the receipt go to an UNTRACKED directory (default build/r16-raw/, +# or R16_OUT_DIR). Nothing under evidence/ is touched; a human or agent step copies +# and commits the receipt later. +# * No hardcoded machine paths. PHYSICS_DIR / AIENOS_LOCK_REPO are passed to make +# only if the caller set them. +# +# Exit status: 0 every gate PASS; 1 at least one FAIL; 2 refused (dirty tree / bad +# environment); 3 no FAIL but at least one gate NOT_RUN. +# +# Environment: +# R16_OUT_DIR output root (default /build/r16-raw); must not be tracked +# R16_RUN_ID override the run id (used by the self-test) +# R16_EXPECT_COMMIT if set, HEAD must equal it or the run is refused +# R16_R15_RECEIPT path to the R15 receipt on this candidate (checked for G7) +# R16_QUALIFY_DRY=1 dry mode, used by tests/r16_qualify/run.sh: runs no make target, no +# chip, no machine probe; reads fixture logs ( and .rc) +# already in the raw dir. Never writes a sha-named receipt. set -euo pipefail +SCHEMA_REVISION=2 HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) cd "$HERE" +DRY=${R16_QUALIFY_DRY:-0} -PHYSICS_DIR=${PHYSICS_DIR:-/home/drakestapleton/workspace/hive-worktrees/physics-gate14-e95e3ed} -AIENOS_LOCK_REPO=${AIENOS_LOCK_REPO:-/home/drakestapleton/workspace/aienos-repo} -export PHYSICS_DIR AIENOS_LOCK_REPO +refuse() { echo "REFUSED: $*" >&2; exit 2; } +# ---- 0. refuse before running anything ------------------------------------ +git rev-parse --git-dir >/dev/null 2>&1 || refuse "not a git work tree: $HERE" +if [ -n "$(git status --porcelain)" ]; then + git status --porcelain | head -20 >&2 + refuse "working tree is dirty (uncommitted or untracked files); commit or clean first" +fi CANDIDATE_COMMIT=$(git rev-parse HEAD) +if [ -n "${R16_EXPECT_COMMIT:-}" ] && [ "$R16_EXPECT_COMMIT" != "$CANDIDATE_COMMIT" ]; then + refuse "HEAD $CANDIDATE_COMMIT is not the expected candidate $R16_EXPECT_COMMIT" +fi export OMEGA_CANDIDATE_COMMIT="$CANDIDATE_COMMIT" - -RUN_COMMIT="$CANDIDATE_COMMIT" -RUN_ID=$(date -u +%Y%m%dT%H%M%SZ)-${CANDIDATE_COMMIT:0:12} -RAW_DIR="$HERE/build/r16-raw/$RUN_ID" +if [ -n "${PHYSICS_DIR:-}" ]; then export PHYSICS_DIR; fi +if [ -n "${AIENOS_LOCK_REPO:-}" ]; then export AIENOS_LOCK_REPO; fi + +RUN_COMMIT=$CANDIDATE_COMMIT +RUN_ID=${R16_RUN_ID:-$(date -u +%Y%m%dT%H%M%SZ)-${CANDIDATE_COMMIT:0:12}} +OUT_ROOT=${R16_OUT_DIR:-$HERE/build/r16-raw} +RAW_DIR="$OUT_ROOT/$RUN_ID" +case "$OUT_ROOT/" in + "$HERE"/evidence/*) refuse "output dir is under tracked evidence/; use an untracked path" ;; +esac mkdir -p "$RAW_DIR" +if [ "$DRY" != 1 ]; then + case "$RAW_DIR" in + "$HERE"/*) git check-ignore -q "$RAW_DIR" || refuse "output dir $RAW_DIR is inside the repo but not git-ignored" ;; + esac +fi -echo "=== R16 Full Qualification: $RUN_ID ===" +echo "=== R16 Qualification (schema revision $SCHEMA_REVISION): $RUN_ID ===" echo "Candidate commit: $CANDIDATE_COMMIT" +if [ "$DRY" = 1 ]; then echo "DRY MODE: no make target, no chip, no receipt named by hash"; fi + +# ---- helpers ----------------------------------------------------------------- +RC=0 +# run_target : sets RC to the exit status, or NOT_RUN in dry +# mode when no fixture log exists. Never aborts the script (set -e is off around make). +run_target() { + local log=$1; shift + if [ "$DRY" = 1 ]; then + if [ -f "$log" ]; then RC=$(cat "$log.rc" 2>/dev/null || echo 0); else RC=NOT_RUN; fi + return 0 + fi + set +e + make "$@" > "$log" 2>&1 < /dev/null + RC=$? + set -e + echo "$RC" > "$log.rc" +} +# verdict : PASS only if the target exited 0 and the log +# holds the pattern; FAIL if it ran and either failed; NOT_RUN if it did not run. +verdict() { + local rc=$1 log=$2 pat=$3 + if [ "$rc" = NOT_RUN ]; then echo NOT_RUN; return; fi + if [ "$rc" != 0 ]; then echo FAIL; return; fi + if [ -s "$log" ] && grep -Fq -- "$pat" "$log"; then echo PASS; else echo FAIL; fi +} +# combine : FAIL beats NOT_RUN beats PASS. +combine() { + local s r=PASS + for s in "$@"; do + if [ "$s" = FAIL ]; then echo FAIL; return; fi + if [ "$s" = NOT_RUN ]; then r=NOT_RUN; fi + done + echo "$r" +} +# jint : integer value of a key (last occurrence), empty if absent. +jint() { + [ -s "$1" ] || return 0 + sed -n 's/^.*"'"$2"'": *\([0-9][0-9]*\).*$/\1/p' "$1" | tail -1 +} +jstrv() { + [ -s "$1" ] || return 0 + sed -n 's/^.*"'"$2"'": *"\([^"]*\)".*$/\1/p' "$1" | tail -1 +} +repohead() { + [ -s "$1" ] || return 0 + sed -n 's/^.*"name": "'"$2"'".*"head": "\([0-9a-f]*\)".*$/\1/p' "$1" | head -1 +} +b2j() { if [ "$1" = PASS ]; then echo true; elif [ "$1" = FAIL ]; then echo false; else echo '"NOT_RUN"'; fi; } -# Check clean tree before qualification -DIRTY=false -if [ -n "$(git status --porcelain)" ]; then - DIRTY=true - echo "WARNING: Tree has uncommitted changes" -fi - -# 1. Hardware Identity (machine.json) -echo "[*] Capturing hardware identity..." +# ---- 1. machine identity (observation only; no chip access) ----------------- AIENOS_COMMIT=$(cat "$HERE/aienos.lock" 2>/dev/null || echo "unknown") PHYSICS_COMMIT=$(cat "$HERE/physics.lock" 2>/dev/null || echo "unknown") - -midrs=$(for c in /sys/devices/system/cpu/cpu[0-9]*; do - printf '%s:%s ' "${c##*cpu}" "$(cat "$c/regs/identification/midr_el1" 2>/dev/null)"; done) -govs=$(for c in /sys/devices/system/cpu/cpu[0-9]*; do - printf '%s:%s:%s ' "${c##*cpu}" "$(cat "$c/cpufreq/scaling_governor" 2>/dev/null)" \ - "$(cat "$c/cpufreq/scaling_cur_freq" 2>/dev/null)"; done) -temps=$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null | tr '\n' ' ') -top=$(ps -eo pcpu,comm --sort=-pcpu | sed -n '2,11p' | awk '{printf "%s:%s ", $2, $1}') -gpu_info=$(nvidia-smi --query-gpu=name,pci.bus_id,driver_version,temperature.gpu --format=csv,noheader 2>/dev/null || echo "N/A") -mach_id=$(sha256sum /etc/machine-id 2>/dev/null | cut -d' ' -f1 || echo "N/A") -mem_total=$(awk '/MemTotal/{print $2}' /proc/meminfo 2>/dev/null || echo "0") - -cat << MEOF > "$RAW_DIR/machine.json" +if [ "$DRY" != 1 ]; then + echo "[*] Capturing machine identity..." + midrs=$(for c in /sys/devices/system/cpu/cpu[0-9]*; do + printf '%s:%s ' "${c##*cpu}" "$(cat "$c/regs/identification/midr_el1" 2>/dev/null || true)"; done) || true + govs=$(for c in /sys/devices/system/cpu/cpu[0-9]*; do + printf '%s:%s:%s ' "${c##*cpu}" "$(cat "$c/cpufreq/scaling_governor" 2>/dev/null || true)" \ + "$(cat "$c/cpufreq/scaling_cur_freq" 2>/dev/null || true)"; done) || true + top=$(ps -eo pcpu,comm --sort=-pcpu 2>/dev/null | sed -n '2,11p' | awk '{printf "%s:%s ", $2, $1}') || true + gpu_info=$(nvidia-smi --query-gpu=name,pci.bus_id,driver_version,temperature.gpu --format=csv,noheader 2>/dev/null) || gpu_info="N/A" + mach_id=$(sha256sum /etc/machine-id 2>/dev/null | cut -d' ' -f1) || mach_id="N/A" + mem_total=$(awk '/MemTotal/{print $2}' /proc/meminfo 2>/dev/null) || mem_total=0 + cat > "$RAW_DIR/machine.json" < "$RAW_DIR/machine.json" "governor_freq": "$govs", "mem_kb": "$mem_total", "gpu": "$gpu_info", - "loadavg": "$(cat /proc/loadavg 2>/dev/null)", + "loadavg": "$(cat /proc/loadavg 2>/dev/null || true)", "top_cpu": "$top", "aienos_commit": "$AIENOS_COMMIT", "physics_commit": "$PHYSICS_COMMIT", - "compiler": "$(gcc --version | head -1)" + "compiler": "$(${CC:-cc} --version 2>/dev/null | head -1 || true)" } MEOF - -# 2. Gate 1 & 2: Loop Inventory -echo "[*] Running R16-G1 / R16-G2: Loop Inventory..." -make r16-inventory > "$RAW_DIR/r16_inventory.log" 2>&1 -cp build/r16-inventory.json "$RAW_DIR/inventory.json" -make test-r16-inventory >> "$RAW_DIR/r16_inventory.log" 2>&1 -G1_STATUS="PASS" -G2_STATUS="PASS" -UNCLASS=$(jq -r '.unclassified // 1' "$RAW_DIR/inventory.json") -if [ "$UNCLASS" != "0" ]; then - echo "ERROR: R16-G2 unclassified loops: $UNCLASS" - exit 1 fi -echo " -> R16-G1: PASS, R16-G2: PASS (0 unclassified)" - -# 3. Gate 3: Authoritative path without legacy orchestrators (host + silicon) -echo "[*] Running R16-G3: Authpath host & silicon..." -make test-r16-authpath > "$RAW_DIR/r16_authpath_host.log" 2>&1 -make test-r16-authpath-silicon > "$RAW_DIR/r16_authpath_silicon.log" 2>&1 -grep -q "R16 gate: R16_G3_AUTHPATH=PASS" "$RAW_DIR/r16_authpath_silicon.log" || { echo "ERROR: G3 failed"; exit 1; } -G3_STATUS="PASS" -echo " -> R16-G3: PASS" - -# 4. Gate 4: Negative tests and load-bearing mutants -echo "[*] Running R16-G4: Negative tests & 36 mutants..." -make test-r16-negative > "$RAW_DIR/r16_negative.log" 2>&1 -grep -q "R16 gate: R16_G4_LEGACY_REFUSED=PASS" "$RAW_DIR/r16_negative.log" || { echo "ERROR: G4 negative failed"; exit 1; } - -make test-r16-negative-mutants > "$RAW_DIR/r16_negative_mutants.log" 2>&1 -grep -q "R16 gate: R16_G4_GUARDS_LOAD_BEARING=PASS" "$RAW_DIR/r16_negative_mutants.log" || { echo "ERROR: G4 mutants failed"; exit 1; } -G4_STATUS="PASS" -echo " -> R16-G4: PASS (36/36 mutants killed)" - -# 5. Gate 5: Surface -echo "[*] Running R16-G5: Surface check..." -make test-r16-surface > "$RAW_DIR/r16_surface.log" 2>&1 -grep -q "R16 gate: R16_G5_SURFACE=PASS" "$RAW_DIR/r16_surface.log" || { echo "ERROR: G5 surface failed"; exit 1; } -G5_STATUS="PASS" -echo " -> R16-G5: PASS" - -# 6. Gate 7: Complete R1-R15 Ladder on the candidate -echo "[*] Running R16-G7: Complete R1-R15 ladder on candidate..." - -echo " Running R1-R6 (test-r3)..." -make test-r3 > "$RAW_DIR/r1_r6_heartbeat.log" 2>&1 - -echo " Running R7 (test-r7)..." -make test-r7 > "$RAW_DIR/r7_native.log" 2>&1 - -echo " Running R8 (test-r8)..." -make test-r8 > "$RAW_DIR/r8_aegis.log" 2>&1 - -echo " Running R9 (test-r9)..." -make test-r9 > "$RAW_DIR/r9_barrier.log" 2>&1 - -echo " Running R10 (test-r10)..." -make test-r10 > "$RAW_DIR/r10_omega.log" 2>&1 -echo " Running R11 (test-r11)..." -make test-r11 > "$RAW_DIR/r11_aien.log" 2>&1 - -echo " Running R12 host (test-r12)..." -make test-r12 > "$RAW_DIR/r12_host.log" 2>&1 - -echo " Running R12 silicon (test-r12-silicon)..." -make test-r12-silicon > "$RAW_DIR/r12_silicon.log" 2>&1 - -echo " Running R13 host (test-r13-host)..." -make test-r13-host > "$RAW_DIR/r13_host.log" 2>&1 - -echo " Running R13 silicon (test-r13-silicon)..." -make test-r13-silicon > "$RAW_DIR/r13_silicon.log" 2>&1 - -echo " Running R14 host (test-r14-host)..." -make test-r14-host > "$RAW_DIR/r14_host.log" 2>&1 - -echo " Running R14 silicon (test-r14-silicon)..." -make test-r14-silicon > "$RAW_DIR/r14_silicon.log" 2>&1 - -echo " Running R15 parity host (test-r15-parity-host)..." -make test-r15-parity-host > "$RAW_DIR/r15_parity_host.log" 2>&1 - -echo " Running R15 G7 host (test-r15-g7-host)..." -make test-r15-g7-host > "$RAW_DIR/r15_g7_host.log" 2>&1 - -echo " Running R15 parity silicon (test-r15-parity-silicon)..." -make test-r15-parity-silicon > "$RAW_DIR/r15_parity_silicon.log" 2>&1 - -echo " Running R15 receipt verification (test-r15-receipt)..." -make test-r15-receipt > "$RAW_DIR/r15_receipt.log" 2>&1 - -# Verify ladder results -grep -q "R4_CAUSAL_TRACE: PASS" "$RAW_DIR/r1_r6_heartbeat.log" || { echo "ERROR: R1-R6 failed"; exit 1; } -grep -q "native authority matched the linux oracle" "$RAW_DIR/r7_native.log" || { echo "ERROR: R7 failed"; exit 1; } -grep -q "failures 0" "$RAW_DIR/r8_aegis.log" || { echo "ERROR: R8 failed"; exit 1; } -grep -q "generation barrier kept a single coherent generation" "$RAW_DIR/r9_barrier.log" || { echo "ERROR: R9 failed"; exit 1; } -grep -q "failures 0" "$RAW_DIR/r10_omega.log" || { echo "ERROR: R10 failed"; exit 1; } -grep -q "failures 0" "$RAW_DIR/r11_aien.log" || { echo "ERROR: R11 failed"; exit 1; } -grep -q "failures 0" "$RAW_DIR/r12_host.log" || { echo "ERROR: R12 host failed"; exit 1; } -grep -q "silicon 1" "$RAW_DIR/r12_silicon.log" || { echo "ERROR: R12 silicon failed"; exit 1; } -grep -q "R13 gate: R13_LIVING_SYSTEM=HOST_PASS_NON_SILICON" "$RAW_DIR/r13_host.log" || { echo "ERROR: R13 host failed"; exit 1; } -grep -q "R13 gate: R13_LIVING_SYSTEM=PASS" "$RAW_DIR/r13_silicon.log" || { echo "ERROR: R13 silicon failed"; exit 1; } -grep -q "R14 gate: R14_LIVING_RECOVERY=HOST_PASS_NON_SILICON" "$RAW_DIR/r14_host.log" || { echo "ERROR: R14 host failed"; exit 1; } -grep -q "R14 gate: R14_LIVING_RECOVERY=PASS" "$RAW_DIR/r14_silicon.log" || { echo "ERROR: R14 silicon failed"; exit 1; } -grep -q "SEQ_SEMANTIC_PARITY=PASS" "$RAW_DIR/r15_parity_host.log" || { echo "ERROR: R15 parity host failed"; exit 1; } -grep -q "R15 G7 worker split: 57 checks, 0 failures" "$RAW_DIR/r15_g7_host.log" || { echo "ERROR: R15 G7 host failed"; exit 1; } -grep -q "SEQ_SEMANTIC_PARITY=PASS" "$RAW_DIR/r15_parity_silicon.log" || { echo "ERROR: R15 parity silicon failed"; exit 1; } -grep -q "r15 receipt test: 0 failure(s)" "$RAW_DIR/r15_receipt.log" || { echo "ERROR: R15 receipt verification failed"; exit 1; } - -G7_STATUS="PASS" -echo " -> R16-G7: PASS (entire R1-R15 ladder passed)" - -# 7. Gate 6: Protected Things Kept -G6_STATUS="PASS" -echo " -> R16-G6: PASS (protected surfaces verified)" - -# 8. Copy raw evidence to evidence/R16/raw/$RUN_ID and update evidence/R16/inventory.json -EVID_RAW_DIR="$HERE/evidence/R16/raw/$RUN_ID" -mkdir -p "$EVID_RAW_DIR" -cp -a "$RAW_DIR"/* "$EVID_RAW_DIR"/ -cp "$RAW_DIR/inventory.json" "$HERE/evidence/R16/inventory.json" - -(cd "$EVID_RAW_DIR" && rm -f SHA256SUMS && sha256sum * > SHA256SUMS) -RAW_DIGEST=$(sha256sum "$EVID_RAW_DIR/SHA256SUMS" | cut -d' ' -f1) -# 9. Gate 8: Generate Final Receipt -echo "[*] Generating final R16 receipt..." -G8_STATUS="PASS" -OUT_RECEIPT_TMP="/tmp/r16_receipt.$RUN_ID.json" - -# Compile json_canon -gcc -std=gnu11 -O2 -Isrc -o /tmp/json_canon tools/json_canon.c src/sha256.c -lm - -cat << RECOBJ > "$OUT_RECEIPT_TMP" +# ---- 2. G1 / G2: loop inventory ------------------------------------------- +echo "[*] R16-G1 / R16-G2: loop inventory..." +INV_LOG="$RAW_DIR/r16_inventory.log" +INV_JSON="$RAW_DIR/inventory.json" +INV_TEST_LOG="$RAW_DIR/test_r16_inventory.log" +if [ "$DRY" != 1 ]; then rm -f build/r16-inventory.json; fi +run_target "$INV_LOG" r16-inventory +INV_RC=$RC +if [ "$DRY" != 1 ] && [ -s build/r16-inventory.json ]; then cp build/r16-inventory.json "$INV_JSON"; fi +run_target "$INV_TEST_LOG" test-r16-inventory +INV_TEST_RC=$RC +G1=NOT_RUN; G2=NOT_RUN; UNCLASS=""; AREACH="" +if [ "$INV_RC" != NOT_RUN ] || [ -s "$INV_JSON" ]; then + if [ ! -s "$INV_JSON" ]; then + G1=FAIL; G2=FAIL + else + UNCLASS=$(jint "$INV_JSON" unclassified) + AREACH=$(jint "$INV_JSON" a_reachable) + g1=PASS + for k in unclassified question_rows bad_class stale_rows map_errors skipped_repos; do + [ "$(jint "$INV_JSON" "$k")" = 0 ] || g1=FAIL + done + for r in omega aien-sovereign-core aegis-runtime aienos physics; do + [ -n "$(repohead "$INV_JSON" "$r")" ] || g1=FAIL # every scanned commit recorded + done + G1=$g1 + g2=PASS + [ "$INV_RC" = 0 ] || g2=FAIL + [ "$(jstrv "$INV_JSON" result)" = PASS ] || g2=FAIL + [ "$AREACH" = 0 ] || g2=FAIL + G2=$(combine "$g2" "$(verdict "$INV_TEST_RC" "$INV_TEST_LOG" "R16 inventory self-test: PASS")") + fi +fi +echo " G1=$G1 G2=$G2 (unclassified=${UNCLASS:-n/a} a_reachable=${AREACH:-n/a})" + +# ---- 3. G3: authoritative path without legacy orchestrators ------------------ +echo "[*] R16-G3: authpath host and silicon..." +SILICON_BROKEN=0 +V=NOT_RUN +run_target "$RAW_DIR/r16_authpath_host.log" test-r16-authpath +G3H=$(verdict "$RC" "$RAW_DIR/r16_authpath_host.log" "R16 gate: R16_G3_AUTHPATH=HOST_PASS_NON_SILICON") +# silicon_run : sets V. After one silicon failure the +# remaining silicon targets are NOT run (a failed seat run can leave the chip in a bad state). +silicon_run() { + local log=$2 pat=$3; shift 3 + if [ "$SILICON_BROKEN" = 1 ]; then V=NOT_RUN; return 0; fi + run_target "$log" "$@" + V=$(verdict "$RC" "$log" "$pat") + if [ "$V" = FAIL ]; then SILICON_BROKEN=1; fi + return 0 +} +silicon_run g3s "$RAW_DIR/r16_authpath_silicon.log" "R16 gate: R16_G3_AUTHPATH=PASS" test-r16-authpath-silicon +G3S=$V +G3=$(combine "$G3H" "$G3S") +echo " G3=$G3 (host $G3H, silicon $G3S)" + +# ---- 4. G4: negative tests and load-bearing mutants ------------------------- +echo "[*] R16-G4: negative tests and mutants..." +run_target "$RAW_DIR/r16_negative.log" test-r16-negative +G4A=$(verdict "$RC" "$RAW_DIR/r16_negative.log" "R16 gate: R16_G4_LEGACY_REFUSED=PASS") +run_target "$RAW_DIR/r16_negative_mutants.log" test-r16-negative-mutants +G4B=$(verdict "$RC" "$RAW_DIR/r16_negative_mutants.log" "R16 gate: R16_G4_GUARDS_LOAD_BEARING=PASS") +G4=$(combine "$G4A" "$G4B") +echo " G4=$G4" + +# ---- 5. G5: surface ---------------------------------------------------------- +echo "[*] R16-G5: surface check..." +run_target "$RAW_DIR/r16_surface.log" test-r16-surface +G5=$(verdict "$RC" "$RAW_DIR/r16_surface.log" "R16 gate: R16_G5_SURFACE=PASS") +echo " G5=$G5" + +# ---- 6. G7: R1-R15 ladder on the candidate ---------------------------------- +echo "[*] R16-G7: ladder..." +# name|make target|log|pattern|silicon(0/1) +LADDER='R1_R6|test-r3|r1_r6_heartbeat.log|R4_CAUSAL_TRACE: PASS|0 +R7|test-r7|r7_native.log|native authority matched the linux oracle|0 +R8|test-r8|r8_aegis.log|failures 0|0 +R9|test-r9|r9_barrier.log|generation barrier kept a single coherent generation|0 +R10|test-r10|r10_omega.log|failures 0|0 +R11|test-r11|r11_aien.log|failures 0|0 +R12_host|test-r12|r12_host.log|failures 0|0 +R12_silicon|test-r12-silicon|r12_silicon.log|silicon 1|1 +R13_host|test-r13-host|r13_host.log|R13 gate: R13_LIVING_SYSTEM=HOST_PASS_NON_SILICON|0 +R13_silicon|test-r13-silicon|r13_silicon.log|R13 gate: R13_LIVING_SYSTEM=PASS|1 +R14_host|test-r14-host|r14_host.log|R14 gate: R14_LIVING_RECOVERY=HOST_PASS_NON_SILICON|0 +R14_silicon|test-r14-silicon|r14_silicon.log|R14 gate: R14_LIVING_RECOVERY=PASS|1 +R15_parity_host|test-r15-parity-host|r15_parity_host.log|SEQ_SEMANTIC_PARITY=PASS|0 +R15_g7_host|test-r15-g7-host|r15_g7_host.log|R15 G7 worker split: 57 checks, 0 failures|0 +R15_parity_silicon|test-r15-parity-silicon|r15_parity_silicon.log|SEQ_SEMANTIC_PARITY=PASS|1 +R15_receipt|test-r15-receipt|r15_receipt.log|r15 receipt test: 0 failure(s)|0' +declare -A LV TG +SILICON_RAN=0; SILICON_PASS=0 +if [ "$G3S" != NOT_RUN ]; then + SILICON_RAN=1 + if [ "$G3S" = PASS ]; then SILICON_PASS=1; fi +fi +while IFS='|' read -r name target log pat sil; do + TG[$name]=$target + if [ "$sil" = 1 ]; then + silicon_run "$name" "$RAW_DIR/$log" "$pat" "$target" + LV[$name]=$V + if [ "$V" != NOT_RUN ]; then SILICON_RAN=$((SILICON_RAN + 1)); fi + if [ "$V" = PASS ]; then SILICON_PASS=$((SILICON_PASS + 1)); fi + else + run_target "$RAW_DIR/$log" "$target" + LV[$name]=$(verdict "$RC" "$RAW_DIR/$log" "$pat") + fi + echo " $name: ${LV[$name]}" +done <<< "$LADDER" + +# R15 physical acceptance (R15 spec G1-G16) is judged from the R15 receipt on this +# candidate, supplied by the caller. No receipt: NOT_RUN. +R15ACC=NOT_RUN +if [ -n "${R16_R15_RECEIPT:-}" ]; then + R15ACC=PASS + f=$R16_R15_RECEIPT + if [ ! -s "$f" ]; then + R15ACC=FAIL + else + [ "$(basename "$f" .json)" = "$(sha256sum "$f" | cut -d' ' -f1)" ] || R15ACC=FAIL + grep -Fq "\"outcome\": \"PASS\"" "$f" || R15ACC=FAIL + grep -Fq "\"candidate_commit\": \"$CANDIDATE_COMMIT\"" "$f" || R15ACC=FAIL + grep -Fq "\"candidate_bound\": true" "$f" || R15ACC=FAIL + grep -Fq "\"tree_dirty\": false" "$f" || R15ACC=FAIL + grep -Fq "\"silicon_observed\": true" "$f" || R15ACC=FAIL + fi +fi +G7=$(combine "${LV[R1_R6]}" "${LV[R7]}" "${LV[R8]}" "${LV[R9]}" "${LV[R10]}" "${LV[R11]}" "${LV[R12_host]}" \ + "${LV[R12_silicon]}" "${LV[R13_host]}" "${LV[R13_silicon]}" "${LV[R14_host]}" "${LV[R14_silicon]}" \ + "${LV[R15_parity_host]}" "${LV[R15_g7_host]}" "${LV[R15_parity_silicon]}" "${LV[R15_receipt]}" "$R15ACC") +echo " G7=$G7 (R15 acceptance receipt: $R15ACC)" + +# ---- 7. G6: protected things kept ------------------------------------------- +# The spec asks for the six section-49 items to be shown present with file/symbol and +# the exercising test. No such check is implemented in this script, so those six items +# and G6 are NOT_RUN. Items covered by ladder runs are derived from those runs. +G6=NOT_RUN +echo "[*] R16-G6: NOT_RUN (presence checks for the six section-49 items are not implemented)" + +# ---- 8. observed binding ---------------------------------------------------------- +END_COMMIT=$(git rev-parse HEAD) +if [ -n "$(git status --porcelain)" ]; then TREE_DIRTY=true; else TREE_DIRTY=false; fi +if [ "$END_COMMIT" = "$CANDIDATE_COMMIT" ] && [ "$RUN_COMMIT" = "$CANDIDATE_COMMIT" ] && [ "$TREE_DIRTY" = false ]; then + CAND_BOUND=true +else + CAND_BOUND=false +fi +# silicon_observed: every silicon target (authpath, R12, R13, R14, R15 parity) ran and passed. +if [ "$SILICON_RAN" -ge 5 ] && [ "$SILICON_PASS" = "$SILICON_RAN" ]; then SIL_OBS=true; else SIL_OBS=false; fi + +# ---- 9. receipt --------------------------------------------------------------------- +SC_COMMIT=$(repohead "$INV_JSON" aien-sovereign-core) +AR_COMMIT=$(repohead "$INV_JSON" aegis-runtime) +REMAINING_CENTRAL='"NOT_RUN"' +if [ -n "$AREACH" ]; then REMAINING_CENTRAL=$AREACH; fi +REMAINING_UNCLASS='"NOT_RUN"' +if [ -n "$UNCLASS" ]; then REMAINING_UNCLASS=$UNCLASS; fi + +# G8 scope: the receipt itself (bound to the candidate, clean tree, named by its own +# SHA-256). The merge with a merge commit is a separate human step recorded in the PR; +# this script does not claim it. Dry mode never claims G8. +if [ "$CAND_BOUND" = true ] && [ "$TREE_DIRTY" = false ] && [ "$DRY" != 1 ]; then G8=PASS; else G8=NOT_RUN; fi + +OVERALL=$(combine "$G1" "$G2" "$G3" "$G4" "$G5" "$G6" "$G7" "$G8") + +lr() { printf ' "%s": {"status": "%s", "target": "%s"}' "$1" "${LV[$2]}" "${TG[$2]}"; } +RAW_DIGEST="NOT_RUN" +(cd "$RAW_DIR" && rm -f SHA256SUMS && ls | grep -v '^SHA256SUMS$' | LC_ALL=C sort | xargs sha256sum > SHA256SUMS) || true +if [ -s "$RAW_DIR/SHA256SUMS" ]; then RAW_DIGEST=$(sha256sum "$RAW_DIR/SHA256SUMS" | cut -d' ' -f1); fi +RAW_REL=${RAW_DIR#"$HERE"/} + +OUT_RECEIPT_TMP="$RAW_DIR/receipt.raw.json" +cat > "$OUT_RECEIPT_TMP" < "$PRETTY_RECEIPT" -rm -f "$OUT_RECEIPT_TMP" - -RECEIPT_SHA=$(sha256sum "$PRETTY_RECEIPT" | cut -d' ' -f1) -FINAL_PATH="$HERE/evidence/R16/$RECEIPT_SHA.json" - -/tmp/json_canon --write-exclusive "$FINAL_PATH" < "$PRETTY_RECEIPT" -rm -f "$PRETTY_RECEIPT" -chmod 0444 "$FINAL_PATH" - -echo "=== R16 QUALIFICATION PASS ===" -echo "Final Receipt: $FINAL_PATH" -echo "Receipt Digest: $RECEIPT_SHA" +if [ "$DRY" = 1 ]; then + mv "$OUT_RECEIPT_TMP" "$RAW_DIR/DRY-RUN-receipt.json" + FINAL_PATH="$RAW_DIR/DRY-RUN-receipt.json" +else + # Canonical writer built into the untracked output dir. The receipt goes beside the + # raw dir, untracked; a later human/agent step copies it under evidence/R16/ and commits. + ${CC:-cc} -std=gnu11 -O2 -Isrc -o "$RAW_DIR/json_canon" tools/json_canon.c src/sha256.c -lm + "$RAW_DIR/json_canon" --pretty < "$OUT_RECEIPT_TMP" > "$RAW_DIR/receipt.pretty.json" + RECEIPT_SHA=$(sha256sum "$RAW_DIR/receipt.pretty.json" | cut -d' ' -f1) + mkdir -p "$OUT_ROOT/receipts" + FINAL_PATH="$OUT_ROOT/receipts/$RECEIPT_SHA.json" + "$RAW_DIR/json_canon" --write-exclusive "$FINAL_PATH" < "$RAW_DIR/receipt.pretty.json" + chmod 0444 "$FINAL_PATH" + if [ "$(sha256sum "$FINAL_PATH" | cut -d' ' -f1)" != "$RECEIPT_SHA" ]; then + echo "ERROR: receipt not named by its own SHA-256" >&2 + exit 1 + fi + rm -f "$OUT_RECEIPT_TMP" "$RAW_DIR/receipt.pretty.json" +fi -echo "AIEN_RX_R16_ORCHESTRATOR_RETIRED_V1 = PASS" +echo "Gates: G1=$G1 G2=$G2 G3=$G3 G4=$G4 G5=$G5 G6=$G6 G7=$G7 G8=$G8" +echo "Receipt (untracked): $FINAL_PATH" +echo "R16_QUALIFY_RESULT=$OVERALL" +case "$OVERALL" in + PASS) exit 0 ;; + FAIL) exit 1 ;; + *) exit 3 ;; +esac From a409678853388b02537f4268f7eb0045f2084935 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 1 Oct 2026 11:58:42 -0500 Subject: [PATCH 2/4] r16_qualify: G8 is always NOT_RUN in the script (merge-commit part unobservable pre-merge) The spec's G8 includes the merge with a merge commit and silicon_observed=true. The script ran before any merge and set G8=PASS from bound+clean alone. It now reports only whether the receipt preconditions hold (incl. silicon observed). Co-Authored-By: Drake Stapleton Co-Authored-By: Claude Opus 5.5 --- tools/r16_qualify.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/r16_qualify.sh b/tools/r16_qualify.sh index 9f5938f12..96c7f3a3a 100755 --- a/tools/r16_qualify.sh +++ b/tools/r16_qualify.sh @@ -309,10 +309,18 @@ if [ -n "$AREACH" ]; then REMAINING_CENTRAL=$AREACH; fi REMAINING_UNCLASS='"NOT_RUN"' if [ -n "$UNCLASS" ]; then REMAINING_UNCLASS=$UNCLASS; fi -# G8 scope: the receipt itself (bound to the candidate, clean tree, named by its own -# SHA-256). The merge with a merge commit is a separate human step recorded in the PR; -# this script does not claim it. Dry mode never claims G8. -if [ "$CAND_BOUND" = true ] && [ "$TREE_DIRTY" = false ] && [ "$DRY" != 1 ]; then G8=PASS; else G8=NOT_RUN; fi +# G8 (spec/r16-orchestrator-retirement.md §G8) includes "the PR is merged with a merge +# commit" and silicon_observed = true. This script runs before any merge, so it can +# never observe the whole gate: G8 is always NOT_RUN here. It reports only whether the +# receipt preconditions hold (bound, clean tree, silicon observed, not dry); G8 is +# decided after the merge by whoever checks the merge commit. +if [ "$CAND_BOUND" = true ] && [ "$TREE_DIRTY" = false ] && [ "$SIL_OBS" = true ] && [ "$DRY" != 1 ]; then + G8_PRECONDITIONS=met +else + G8_PRECONDITIONS=not_met +fi +G8=NOT_RUN +echo "[*] R16-G8: NOT_RUN (merge-commit part is outside this script; receipt preconditions $G8_PRECONDITIONS)" OVERALL=$(combine "$G1" "$G2" "$G3" "$G4" "$G5" "$G6" "$G7" "$G8") From b765cd6894a66282b7e2a6096d9701d874b2e611 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 1 Oct 2026 12:34:22 -0500 Subject: [PATCH 3/4] r16: fix map 8.1 class tally; self-test counterexamples for G1/G2 inventory JSON and G7 R15 receipt - spec 8.1: rows OM-152..OM-198 are 19 N, 23 D, 1 E, 4 B (47); the note said 22 N, 22 D. - tests/r16_qualify: good inventory fixture passes G1/G2, then each of unclassified, question_rows, bad_class, stale_rows, map_errors, skipped_repos = 1, each missing repo head, a_reachable = 1, result FAIL, inventory exit 1, self-test log without its pass line, self-test exit 1, and no JSON must each FAIL. Good R15 receipt passes, then wrong name, missing, empty, other commit, outcome FAIL, candidate_bound false, tree_dirty true and silicon_observed false must each FAIL G7. NOT_RUN: nothing built or run by the builder; queued for the forge. Co-Authored-By: Claude Opus 5.5 --- spec/r16-orchestrator-retirement-map.md | 4 +- tests/r16_qualify/run.sh | 119 +++++++++++++++++++++++- 2 files changed, 119 insertions(+), 4 deletions(-) mode change 100644 => 100755 tests/r16_qualify/run.sh diff --git a/spec/r16-orchestrator-retirement-map.md b/spec/r16-orchestrator-retirement-map.md index 7878b563b..b84d8fb98 100644 --- a/spec/r16-orchestrator-retirement-map.md +++ b/spec/r16-orchestrator-retirement-map.md @@ -546,8 +546,8 @@ The R16 re-qualification on candidate `3108fc2` (omega main of 2026-10-01) ran t and found `sites=328 unclassified=47` (receipt `evidence/REQUAL-3108fc2/`, G1 and G2 FAIL). The 47 sites came from code added after this map's last update (compiler, estimation, fabric, rx_compose, searchtrace, train, tests, tools). Rows OM-152 to -OM-198 classify them, each from reading the loop, with a one-line reason: 22 class N, -22 class D, 1 class E (`omega_numeric_reduce_gb10.c`, GPU reduction launcher, not on the +OM-198 classify them, each from reading the loop, with a one-line reason: 19 class N, +23 class D, 1 class E (`omega_numeric_reduce_gb10.c`, GPU reduction launcher, not on the reaction path), 4 class B (explicit close/drain of an attached composition in `rx_compose.c`), 0 class A. (Line numbers in these rows are at omega main `9ca297c`; the join key does not use them.) No new site sequences faculties on the production diff --git a/tests/r16_qualify/run.sh b/tests/r16_qualify/run.sh old mode 100644 new mode 100755 index e6ad61a56..effd142eb --- a/tests/r16_qualify/run.sh +++ b/tests/r16_qualify/run.sh @@ -3,7 +3,10 @@ # dry mode (R16_QUALIFY_DRY=1) inside a scratch git repo, reading fixture logs. # Proves: a dirty tree is refused before anything runs; a gate with no check prints # NOT_RUN (never PASS); a failing check makes the script exit non-zero; observed fields -# are computed, not literals. Usage: bash tests/r16_qualify/run.sh +# are computed, not literals; G1/G2 follow every count, repo head and result in the +# inventory JSON; the G7 R15 receipt check fails on each broken field. Each check has a +# passing fixture first and then a counterexample that must fail. +# Usage: bash tests/r16_qualify/run.sh set -u HERE=$(cd "$(dirname "$0")/../.." && pwd) SCR=$(mktemp -d "${TMPDIR:-/tmp}/r16qual.XXXXXX") || exit 2 @@ -76,7 +79,119 @@ out=$(Q R16_RUN_ID=fx 2>&1); rc=$? check "good G4/G5 fixtures: those gates PASS" 'echo "$out" | grep -q "G4=PASS" && echo "$out" | grep -q "G5=PASS"' check "all-good G4/G5 still exit 3 (G6 has no check)" '[ $rc = 3 ] && echo "$out" | grep -q "G6=NOT_RUN"' -# 7. the script holds no literal for observed fields and does not touch tracked evidence + +# 7. G1/G2 from the inventory JSON. A good fixture passes first (so each failure below is +# caused by the one value changed), then every G1/G2 check is broken on its own. +I=$W/build/r16-raw/inv +mkdir -p "$I" +# inv_fixture [key=value ...]: writes inventory.json in the tool's layout with all counts 0, +# result PASS and five recorded heads; a key=value pair overrides one field +# (head_= overrides one repo head; an empty value records no head). +inv_fixture() { + local unclassified=0 question_rows=0 bad_class=0 a_reachable=0 stale_rows=0 map_errors=0 + local skipped_repos=0 result=PASS kv k v r + local head_omega=1111111111111111111111111111111111111111 + local head_aien_sovereign_core=2222222222222222222222222222222222222222 + local head_aegis_runtime=3333333333333333333333333333333333333333 + local head_aienos=4444444444444444444444444444444444444444 + local head_physics=5555555555555555555555555555555555555555 + for kv in "$@"; do k=${kv%%=*}; v=${kv#*=}; k=${k//-/_}; printf -v "$k" '%s' "$v"; done + { + printf '{\n "schema": "AIEN_R16_LOOP_INVENTORY_V1",\n "map": "spec/r16-orchestrator-retirement-map.md",\n "repos": [\n' + for r in omega aien-sovereign-core aegis-runtime aienos physics; do + k=head_${r//-/_} + printf ' {"name": "%s", "path": "/x/%s", "head": "%s", "map_sha": "", "status": "SCANNED", "sites_by_class": {"A": 0}}%s\n' \ + "$r" "$r" "${!k}" "$([ "$r" = physics ] || echo ,)" + done + printf ' ],\n "sites": [\n ],\n "manual_rows": 5,\n "sites_total": 328,\n' + printf ' "unclassified": %s,\n "question_rows": %s,\n "bad_class": %s,\n "a_reachable": %s,\n' \ + "$unclassified" "$question_rows" "$bad_class" "$a_reachable" + printf ' "stale_rows": %s,\n "map_errors": %s,\n "skipped_repos": %s,\n "class_n_sites": 0,\n "result": "%s"\n}\n' \ + "$stale_rows" "$map_errors" "$skipped_repos" "$result" + } > "$I/inventory.json" +} +inv_logs() { # inv_logs + echo "R16 loop inventory: sites=328 -> fixture" > "$I/r16_inventory.log"; echo "$1" > "$I/r16_inventory.log.rc" + echo "$3" > "$I/test_r16_inventory.log"; echo "$2" > "$I/test_r16_inventory.log.rc" +} +inv_logs 0 0 "R16 inventory self-test: PASS" +inv_fixture +out=$(Q R16_RUN_ID=inv 2>&1); rc=$? +R=$I/DRY-RUN-receipt.json +check "good inventory: G1 PASS and G2 PASS" 'echo "$out" | grep -q "G1=PASS G2=PASS"' +check "good inventory: no FAIL, exit 3 (other gates NOT_RUN)" '[ $rc = 3 ]' +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"' +check "good inventory: repo heads read from the JSON" 'grep -q "\"aien_sovereign_core_commit\": \"2222222222222222222222222222222222222222\"" "$R" && grep -q "\"aegis_runtime_commit\": \"3333333333333333333333333333333333333333\"" "$R"' +for k in unclassified question_rows bad_class stale_rows map_errors skipped_repos; do + inv_fixture "$k=1" + out=$(Q R16_RUN_ID=inv 2>&1); rc=$? + check "bad inventory $k=1: G1 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=FAIL"' +done +inv_fixture unclassified=7 +out=$(Q R16_RUN_ID=inv 2>&1) +check "bad inventory unclassified=7: count carried into receipt" 'grep -q "\"remaining_unclassified_semantic_loop_count\": 7" "$R"' +for r in omega aien-sovereign-core aegis-runtime aienos physics; do + inv_fixture "head_$r=" + out=$(Q R16_RUN_ID=inv 2>&1); rc=$? + check "inventory with no head for $r: G1 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=FAIL"' +done +inv_fixture a_reachable=1 +out=$(Q R16_RUN_ID=inv 2>&1); rc=$? +check "bad inventory a_reachable=1: G2 FAIL (G1 PASS), exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=PASS G2=FAIL"' +check "bad inventory a_reachable=1: count carried into receipt" 'grep -q "\"remaining_central_loop_count\": 1" "$R"' +inv_fixture result=FAIL +out=$(Q R16_RUN_ID=inv 2>&1); rc=$? +check "inventory result FAIL: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' +inv_fixture; inv_logs 1 0 "R16 inventory self-test: PASS" +out=$(Q R16_RUN_ID=inv 2>&1); rc=$? +check "inventory target exit 1: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' +inv_logs 0 0 "R16 inventory self-test: 1 FAILED" +out=$(Q R16_RUN_ID=inv 2>&1); rc=$? +check "inventory self-test log lacks pass line: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' +inv_logs 0 1 "R16 inventory self-test: PASS" +out=$(Q R16_RUN_ID=inv 2>&1); rc=$? +check "inventory self-test exit 1 with pass line: G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G2=FAIL"' +inv_logs 0 0 "R16 inventory self-test: PASS"; rm -f "$I/inventory.json" +out=$(Q R16_RUN_ID=inv 2>&1); rc=$? +check "inventory ran but wrote no JSON: G1 FAIL and G2 FAIL, exit 1" '[ $rc = 1 ] && echo "$out" | grep -q "G1=FAIL G2=FAIL"' + +# 8. G7 R15 acceptance receipt (R16_R15_RECEIPT). A good receipt (named by its own +# SHA-256, bound to this HEAD) passes first; then each check is broken on its own. +CAND=$(g rev-parse HEAD) +RD=$SCR/r15 +mkdir -p "$RD" +# r15_receipt [field=value ...]: writes a receipt named by its own SHA-256, prints its path. +r15_receipt() { + local outcome=PASS candidate_commit=$CAND candidate_bound=true tree_dirty=false silicon_observed=true kv + for kv in "$@"; do printf -v "${kv%%=*}" '%s' "${kv#*=}"; done + 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' \ + "$outcome" "$candidate_commit" "$candidate_bound" "$tree_dirty" "$silicon_observed" > "$RD/tmp.json" + local s; s=$(sha256sum "$RD/tmp.json" | cut -d' ' -f1) + mv "$RD/tmp.json" "$RD/$s.json" + echo "$RD/$s.json" +} +GOOD=$(r15_receipt) +out=$(Q R16_RUN_ID=r15 R16_R15_RECEIPT="$GOOD" 2>&1); rc=$? +R=$W/build/r16-raw/r15/DRY-RUN-receipt.json +check "good R15 receipt: acceptance PASS" 'echo "$out" | grep -q "R15 acceptance receipt: PASS"' +check "good R15 receipt: field true, exit 3 (ladder NOT_RUN)" '[ $rc = 3 ] && grep -q "\"r15_acceptance_still_passing\": true" "$R"' +r15_bad() { # r15_bad