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/research/atemporal/at1/integration/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 / research / atemporal / at1 / integration / run.sh` 551 lines ยท 47904 bytes Raw Blame History 1 #!/bin/sh 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 # AT-1 Agent 5: clean-checkout integration runner (AT1_CHARTER.md sections 3, 6; gates G1 to G6). 18 # 19 # sh run.sh [--out DIR | --evidence] [--keep-work] 20 # 21 # Builds the AT-1 oracle, engine and evaluator from a fresh local clone of this checkout's HEAD (the 22 # working tree is never touched), runs every public evaluator case through 23 # oracle -> engine (which splices every reference_* line of the oracle record, charter reading (c)) 24 # -> the evaluator's own runner (its splice, verifier, gate lines) 25 # twice for repeatability, and runs the integration controls (contract digests, splice agreement, 26 # evaluation order, real-engine mutants, isolation, make hygiene). Writes receipts. 27 # --evidence writes the new folder evidence/AT1/- (append-only; must not exist) 28 # --out DIR writes to DIR (wiped first); default build/at1/check (what `make at1-check` uses) 29 # Optional environment: 30 # AT1_ARCH_DIR a local aien-architecture git clone: enables the contract digest control C0 31 # AT1_QUALIFY_COMMIT an omega commit whose AT-1 component sources must equal HEAD's (control C0) 32 # CC C compiler for the integration controls (default cc); components use their own builds 33 # Single-threaded, CPU only, no network, no Python, no GPU. Never reads a hidden case. 34 # Exit 0 only if no control and no gate is FAIL. POSIX sh; Linux (GNU tools) and macOS (BSD tools). 35 set -u 36 LC_ALL=C; export LC_ALL 37 TZ=UTC; export TZ 38 # the runner may be started by `make at1-check`: inner makes must not inherit its state 39 unset MAKELEVEL MAKEFLAGS MFLAGS MAKEOVERRIDES GNUMAKEFLAGS CDPATH 40 HERE=$(cd "$(dirname "$0")" && pwd -P) 41 ROOT=$(cd "$HERE/../../../.." && pwd -P) 42 MODE=check; OUT=""; KEEP=0; OUTSET=0 43 usage() { echo "usage: sh run.sh [--out DIR | --evidence] [--keep-work]" >&2; exit 64; } 44 while [ $# -gt 0 ]; do 45 case "$1" in 46 --evidence) MODE=evidence;; 47 --out) shift; [ $# -gt 0 ] && [ -n "$1" ] || usage; OUT=$1; OUTSET=1;; 48 --keep-work) KEEP=1;; 49 *) usage;; 50 esac 51 shift 52 done 53 [ "$MODE" = evidence ] && [ $OUTSET = 1 ] && { echo "--out and --evidence exclude each other" >&2; exit 64; } 54 case "$ROOT" in *[[:space:]]*) echo "the checkout path contains white space; the evaluator's command templates cannot carry it" >&2; exit 64;; esac 55 HEAD=$(git -C "$ROOT" rev-parse HEAD) || { echo "not a git checkout" >&2; exit 64; } 56 SHORT=$(git -C "$ROOT" rev-parse --short=7 HEAD) 57 STAMP=$(date -u +%Y%m%dT%H%M%SZ) 58 # state of the checkout the runner was started from (the components are built from a fresh clone of HEAD) 59 OUTER_CLEAN=YES; [ -n "$(git -C "$ROOT" status --porcelain)" ] && OUTER_CLEAN=NO 60 if [ "$MODE" = evidence ]; then 61 [ "$OUTER_CLEAN" = YES ] || { echo "--evidence needs a clean checkout (git status --porcelain is not empty)" >&2; exit 64; } 62 [ -n "${AT1_ARCH_DIR:-}" ] || { echo "--evidence needs AT1_ARCH_DIR (a local aien-architecture clone) for the contract digest control C0" >&2; exit 64; } 63 OUT="$ROOT/evidence/AT1/$STAMP-$SHORT" 64 [ -e "$OUT" ] && { echo "evidence folder exists: $OUT" >&2; exit 64; } 65 mkdir -p "$OUT" || exit 1 66 else 67 [ -n "$OUT" ] || OUT="$ROOT/build/at1/check" 68 case "$OUT" in /*) ;; *) OUT="$PWD/$OUT";; esac 69 mkdir -p "$OUT" && OUT=$(cd "$OUT" && pwd -P) || exit 1 70 case "$ROOT/" in "$OUT/"*) echo "--out must not be the checkout or one of its parents: $OUT" >&2; exit 64;; esac 71 case "$OUT/" in "$ROOT/evidence/"*) echo "--out must not point into evidence/; use --evidence" >&2; exit 64;; esac 72 # wipe only an empty folder or one an earlier run of this runner wrote 73 if [ -n "$(ls -A "$OUT")" ]; then 74 [ -f "$OUT/receipts/controls.tsv" ] && [ -f "$OUT/run.log" ] || { echo "--out $OUT is not empty and was not written by this runner; refusing to wipe it" >&2; exit 64; } 75 rm -rf "$OUT" && mkdir -p "$OUT" || exit 1 76 fi 77 fi 78 mkdir -p "$OUT/receipts" "$OUT/cases" "$OUT/results" "$OUT/components" "$OUT/mutants" || exit 1 79 WORK=$(mktemp -d "${TMPDIR:-/tmp}/a5run.XXXXXX") || exit 1 80 WORK=$(cd "$WORK" && pwd -P) || exit 1 81 case "$WORK" in *[[:space:]]*) echo "TMPDIR contains white space: $WORK" >&2; rm -rf "$WORK"; exit 64;; esac 82 [ $KEEP = 1 ] || trap 'rm -rf "$WORK"' EXIT 83 trap 'exit 130' INT TERM 84 LOG="$OUT/run.log"; : > "$LOG" 85 R="$OUT/receipts" 86 say() { printf '%s\n' "$*" | tee -a "$LOG"; } 87 logrun() { printf '$ %s\n' "$*" >> "$LOG"; } 88 if command -v sha256sum > /dev/null 2>&1; then SHATOOL="sha256sum"; else SHATOOL="shasum -a 256"; fi 89 sha() { $SHATOOL "$1" | cut -c1-64; } 90 shastdin() { $SHATOOL | cut -c1-64; } 91 GATES="$R/gates.tsv"; CTRL="$R/controls.tsv"; : > "$GATES"; : > "$CTRL" 92 gate() { printf '%s\t%s\t%s\t%s\n' "$1" "$2" "$3" "$4" >> "$GATES"; say "GATE $1 $2 $4"; } 93 ctrl() { printf '%s\t%s\t%s\t%s\n' "$1" "$2" "$3" "$4" >> "$CTRL"; say "CONTROL $1 $2 $4"; } 94 cst() { awk -F'\t' -v k="$1" '$1==k {print $2}' "$CTRL" | tail -1; } 95 field() { sed -n "s/^$2 //p" "$1" | head -1; } 96 valblock() { sed -n '/^begin values$/,/^end values$/p' "$1"; } 97 # a result without the three lines the contract allows to differ between honest runs 98 stable() { grep -v -E '^(run_started_utc|run_finished_utc|evidence_digest) ' "$1"; } 99 CCBIN=${CC:-cc} 100 ASAN_LIMIT=${AT1_ASAN_LIMIT:-900} # seconds for the model sanitizer leg; rc 124 on timeout (G7 run 1 hung here) 101 kill_tree() { for c in $(pgrep -P "$1" 2>/dev/null); do kill_tree "$c"; done; kill "$1" 2>/dev/null; } 102 # limited SECONDS LOG CMD...: run CMD with output to LOG and kill its whole process tree after SECONDS (rc 124). 103 # Portable: no coreutils timeout on macOS, so a sleeping watchdog subshell plus pgrep -P for the descendants. 104 limited() { 105 lsec=$1; llog=$2; shift 2 106 "$@" > "$llog" 2>&1 & lpid=$! 107 ( sleep "$lsec"; kill_tree "$lpid"; echo "$lpid" > "$llog.timeout" ) & lwd=$! 108 wait "$lpid"; lrc=$? 109 if [ -f "$llog.timeout" ]; then rm -f "$llog.timeout"; lrc=124; else kill_tree "$lwd"; wait "$lwd" 2>/dev/null; fi 110 return $lrc 111 } 112 TAB=$(printf '\t') 113 114 say "AT-1 Agent 5 run $STAMP mode=$MODE omega=$HEAD starting_checkout_clean=$OUTER_CLEAN" 115 116 # ---------- 0. contract pin (C0) ---------- 117 LOCK="$HERE/contract.lock" 118 lock() { sed -n "s/^$1 //p" "$LOCK" | head -1; } 119 CONTRACT_COMMIT=$(lock contract_commit); SPEC_COMMIT=$(lock spec_commit) 120 cp "$LOCK" "$R/contract.lock" 121 if [ -n "${AT1_ARCH_DIR:-}" ] && ! git -C "$AT1_ARCH_DIR" rev-parse HEAD > /dev/null 2>&1; then 122 ctrl C0-CONTRACT-DIGESTS FAIL "git -C \$AT1_ARCH_DIR rev-parse HEAD" "AT1_ARCH_DIR=$AT1_ARCH_DIR is set but is not a git clone" 123 elif [ -n "${AT1_ARCH_DIR:-}" ]; then 124 A=$AT1_ARCH_DIR; P=docs/plans/atemporal; c0bad="" 125 adig() { git -C "$A" show "$1:$P/$2" 2>/dev/null | shastdin; } 126 for row in "AT1_CASE_V1 case_v1_sha256 $CONTRACT_COMMIT" "AT1_RESULT_V1 result_v1_sha256 $CONTRACT_COMMIT" "AT0_RESULT_V2 result_v2_sha256 $CONTRACT_COMMIT" "AT1_SPEC spec_sha256 $SPEC_COMMIT"; do 127 set -- $row 128 want=$(lock "$2"); got=$(adig "$3" "$1.md"); head_got=$(sha "$A/$P/$1.md" 2>/dev/null) 129 [ "$got" = "$want" ] || c0bad="$c0bad $1@${3%"${3#???????}"}($got)" 130 [ "$head_got" = "$want" ] || c0bad="$c0bad $1@working-tree($head_got)" 131 printf '%s %s at %s: %s; working tree: %s; lock: %s\n' "$1" "$2" "$3" "$got" "$head_got" "$want" >> "$R/contract-digests.txt" 132 done 133 # the frozen rows of the freeze record carry the same digests 134 for k in "AT1_CASE_V1 case_v1_sha256" "AT1_RESULT_V1 result_v1_sha256" "AT0_RESULT_V2 result_v2_sha256"; do 135 set -- $k 136 git -C "$A" show "$(lock freeze_record_commit):$P/AT0_FREEZE.md" 2>/dev/null | grep -q "^| $1 | .*| \`$(lock "$2")\` |" || c0bad="$c0bad freeze-row-$1" 137 done 138 ch=$(adig "$(lock charter_readings_commit)" AT1_CHARTER.md) 139 [ "$ch" = "$(lock charter_sha256_at_readings_commit)" ] || c0bad="$c0bad charter-at-readings-commit($ch)" 140 printf 'aien-architecture HEAD %s\n' "$(git -C "$A" rev-parse HEAD)" >> "$R/contract-digests.txt" 141 [ -z "$c0bad" ] && ctrl C0-CONTRACT-DIGESTS PASS "sha256 of AT1_CASE_V1, AT1_RESULT_V1, AT0_RESULT_V2 at contract_commit and AT1_SPEC at spec_commit (git show) and in the working tree of \$AT1_ARCH_DIR; AT0_FREEZE.md rows at freeze_record_commit; AT1_CHARTER at the readings commit" "all match contract.lock and the AT0_FREEZE.md rows (arch HEAD $(git -C "$A" rev-parse --short=7 HEAD))" \ 142 || ctrl C0-CONTRACT-DIGESTS FAIL "contract digests" "mismatch:$c0bad" 143 else ctrl C0-CONTRACT-DIGESTS NOT_RUN "AT1_ARCH_DIR unset" "no local aien-architecture clone given; digests only recorded in contract.lock"; fi 144 145 # ---------- 1. clean checkout and toolchain ---------- 146 S="$WORK/src"; AT1="$S/research/atemporal/at1"; INT="$AT1/integration" 147 logrun "git clone --no-hardlinks $ROOT $S; git checkout --detach $HEAD" 148 git -c core.hooksPath=/dev/null clone -q --no-hardlinks "$ROOT" "$S" >> "$LOG" 2>&1 && git -C "$S" -c core.hooksPath=/dev/null checkout -q --detach "$HEAD" >> "$LOG" 2>&1 || { say "FATAL clone failed"; exit 1; } 149 [ "$(git -C "$S" rev-parse HEAD)" = "$HEAD" ] || { say "FATAL clone HEAD mismatch"; exit 1; } 150 [ -d "$INT" ] || { say "FATAL HEAD has no research/atemporal/at1/integration (commit the runner first)"; exit 1; } 151 # source_tree_clean describes what is built: the fresh clone of HEAD (the starting checkout is in summary.txt) 152 CLEAN=YES; [ -n "$(git -C "$S" status --porcelain)" ] && CLEAN=NO 153 COMPS="research/atemporal/at1/model research/atemporal/at1/oracle research/atemporal/at1/evaluator src/omega_om_units.c src/omega_api_decl.h src/omega_native.h src/sha256.h" 154 if [ -n "${AT1_QUALIFY_COMMIT:-}" ]; then 155 QC=$(git -C "$S" rev-parse "$AT1_QUALIFY_COMMIT^{commit}" 2>/dev/null) 156 if [ -n "$QC" ] && git -C "$S" diff --quiet "$QC" "$HEAD" -- $COMPS; then 157 ctrl C0-COMPONENTS-AT-QUALIFIED-COMMIT PASS "git diff --quiet $QC HEAD -- $COMPS" "component sources at HEAD are byte-identical to $QC; HEAD differs from it only in: $(git -C "$S" diff --name-only "$QC" "$HEAD" | sed 's|/[^/]*$||' | sort -u | tr '\n' ' ')" 158 else ctrl C0-COMPONENTS-AT-QUALIFIED-COMMIT FAIL "git diff --quiet $AT1_QUALIFY_COMMIT HEAD -- $COMPS" "component sources differ (or commit unknown)"; fi 159 else ctrl C0-COMPONENTS-AT-QUALIFIED-COMMIT NOT_RUN "AT1_QUALIFY_COMMIT unset" "components are those of HEAD"; fi 160 HOSTN=$(cat /etc/hostname 2>/dev/null || uname -n) 161 OSDESC=$(uname -srm); command -v sw_vers > /dev/null 2>&1 && OSDESC="$(sw_vers -productName) $(sw_vers -productVersion) $(uname -m)" 162 CC_V=$($CCBIN --version 2>&1 | head -1) 163 RUSTC_V=$(rustc --version 2>&1) 164 { 165 echo "date_utc $STAMP"; echo "uname $(uname -srm)"; echo "host $HOSTN"; echo "os $OSDESC" 166 echo "cc ($CCBIN) $CC_V"; echo "make $(make --version 2>&1 | head -1)" 167 # nm path and version, and the shell actually running this script (Agent 7 finding: G7 substituted both) 168 echo "nm ($(command -v nm 2>/dev/null || echo not-found)) $(nm --version 2>&1 | head -1)"; echo "sh $(ls -l /bin/sh 2>&1)" 169 echo "sh running this script: $(ps -o comm= -p $$ 2>/dev/null || echo unknown)"; echo "asan limit seconds $ASAN_LIMIT" 170 echo "sha tool $SHATOOL"; echo "git $(git --version)" 171 echo "--- rustc -vV"; rustc -vV 2>&1 172 } > "$R/toolchain.txt" 173 MCFLAGS=$(sed -n 's/^CFLAGS = //p' "$AT1/model/Makefile" | head -1) 174 OFLAGS=$(sed -n 's/^FLAGS="\(.*\)"$/\1/p' "$AT1/oracle/build.sh" | head -1) 175 { echo "model (model/Makefile CFLAGS, LDLIBS -lm): $MCFLAGS"; echo "oracle (oracle/build.sh): rustc $OFLAGS --crate-name at1_oracle src/main.rs" 176 echo "evaluator (evaluator/Makefile): rustc --edition 2021 -O src/main.rs"; echo "integration objects for G2 (this runner): $CCBIN $MCFLAGS -c"; } > "$R/flags.txt" 177 178 # ---------- 2. builds and component tests (oracle first: its build records the clean state of its directory) ---------- 179 bstep() { # label dir cmd... 180 lab=$1; d=$2; shift 2; logrun "(cd $d && $*)" 181 (cd "$d" && "$@") > "$R/$lab.log" 2>&1; rc=$? 182 [ $rc -eq 0 ] && say "BUILD $lab ok" || say "BUILD $lab FAILED rc=$rc"; return $rc 183 } 184 BUILD_OK=1 185 bstep oracle-build "$AT1/oracle" sh build.sh || BUILD_OK=0 186 bstep model-build "$AT1/model" make CC="$CCBIN" || BUILD_OK=0 187 bstep evaluator-build "$AT1/evaluator" make all || BUILD_OK=0 188 MODEL="$AT1/model/build/at1-model"; ORACLE="$AT1/oracle/target/at1-oracle"; EVAL="$AT1/evaluator/build/at1-eval" 189 if [ $BUILD_OK != 1 ] || [ ! -x "$MODEL" ] || [ ! -x "$ORACLE" ] || [ ! -x "$EVAL" ]; then 190 say "FATAL build failure; see $R/*-build.log" 191 for g in AT1-G1 AT1-G2 AT1-G3 AT1-G4 AT1-G5 AT1-G6; do gate $g NOT_RUN "build" "a component did not build"; done 192 exit 1 193 fi 194 [ -z "$(git -C "$S" status --porcelain)" ] && ctrl C1-BUILD-LEAVES-TREE-CLEAN PASS "git status --porcelain in the clone after the three builds" "empty (build outputs are git-ignored)" \ 195 || ctrl C1-BUILD-LEAVES-TREE-CLEAN FAIL "git status --porcelain in the clone after the builds" "$(git -C "$S" status --porcelain | head -3 | tr '\n' ' ')" 196 OSTATE=$("$ORACLE" emit "$AT1/evaluator/cases/positive/P2-kat-rotated-level-n4.case" 2>/dev/null | sed -n 's/^source_tree_clean //p') 197 ( cd "$AT1/model" && make test CC="$CCBIN" ) > "$R/model-tests.log" 2>&1; mrc=$? 198 limited "$ASAN_LIMIT" "$R/model-tests-asan.log" sh -c "cd \"$AT1/model\" && make asan CC=\"$CCBIN\""; mrca=$? 199 [ $mrca -eq 124 ] && echo "asan: TIMEOUT after $ASAN_LIMIT s (watchdog; Agent 7 finding: an ASan probe can spin forever on some hosts)" >> "$R/model-tests-asan.log" 200 ( cd "$AT1/oracle" && sh build.sh test ) > "$R/oracle-tests.log" 2>&1; orc=$? 201 ( cd "$AT1/oracle" && sh isolation.sh ) > "$R/oracle-isolation-own.log" 2>&1; oisorc=$? 202 ( cd "$AT1/evaluator" && make test CC="$CCBIN" ) > "$R/evaluator-tests.log" 2>&1; erc=$? 203 ctrl C1-MODEL-TESTS "$( [ $mrc -eq 0 ] && [ $mrca -eq 0 ] && echo PASS || echo FAIL )" "(cd model && make test; make asan)" "plain rc=$mrc ($(grep -E 'passed|failed' "$R/model-tests.log" | tail -1)); asan rc=$mrca ($(grep -E 'passed|failed|skipped' "$R/model-tests-asan.log" | tail -1))" 204 ctrl C1-ORACLE-TESTS "$( [ $orc -eq 0 ] && echo PASS || echo FAIL )" "(cd oracle && sh build.sh test)" "rc=$orc ($(grep -m1 'test result' "$R/oracle-tests.log"))" 205 ctrl C1-ORACLE-OWN-ISOLATION "$( [ $oisorc -eq 0 ] && echo PASS || echo FAIL )" "(cd oracle && sh isolation.sh)" "Agent 2's own gate rc=$oisorc ($(tail -1 "$R/oracle-isolation-own.log"))" 206 ctrl C1-EVALUATOR-TESTS "$( [ $erc -eq 0 ] && echo PASS || echo FAIL )" "(cd evaluator && make test)" "rc=$erc; $(grep -E '^(SELFTEST|corpus-check|MUTANT_RECEIPT|AT1_ISOLATION_CONTROLS)' "$R/evaluator-tests.log" | tr '\n' ';')" 207 cp "$AT1/evaluator/build/ISOLATION_RECEIPT.txt" "$R/evaluator-isolation-controls.txt" 2>/dev/null 208 209 # ---------- 3. receipts: sources and binaries ---------- 210 ( cd "$S" && git ls-files research/atemporal/at1 src/omega_om_units.c src/omega_api_decl.h src/omega_native.h src/sha256.h mk/at1.mk | LC_ALL=C sort | while read -r f; do printf '%s %s\n' "$(sha "$f")" "$f"; done ) > "$R/sources.sha256" 211 { for b in "$MODEL" "$ORACLE" "$EVAL" "$AT1/model/build/test_model" "$AT1/oracle/target/at1-oracle-test"; do 212 [ -f "$b" ] && printf '%s %s\n' "$(sha "$b")" "${b#"$WORK"/}"; done; } > "$R/binaries.sha256" 213 ENGINE_SHA=$(sha "$MODEL"); ORACLE_SHA=$(sha "$ORACLE") 214 215 # ---------- 4. provenance template (the engine reads no clock; the shim adds the two run times) ---------- 216 ptext() { printf '%s' "$1" | tr -cd ' -~' | tr -s ' ' | sed 's/^ //; s/ $//' | cut -c1-200 | sed 's/ $//'; } 217 BCC=$(ptext "$CC_V (engine); $RUSTC_V (oracle)") 218 BFL=$(ptext "engine: $MCFLAGS -lm; oracle: rustc $OFLAGS") 219 HOSTT=$(ptext "$HOSTN $OSDESC") 220 PROV="$WORK/prov.static" 221 { echo "source_repo aien-dev/omega"; echo "source_commit $HEAD"; echo "source_tree_clean $CLEAN"; echo "contract_commit $CONTRACT_COMMIT" 222 echo "engine_sha256 $ENGINE_SHA"; echo "oracle_repo aien-dev/omega"; echo "oracle_commit $HEAD"; echo "oracle_sha256 $ORACLE_SHA" 223 echo "build_cc $BCC"; echo "build_flags $BFL"; echo "host $HOSTT"; } > "$PROV" 224 cp "$PROV" "$R/provenance.static" 225 export AT1_MODEL_BIN="$MODEL" AT1_ORACLE_BIN="$ORACLE" AT1_PROV_STATIC="$PROV" 226 ENGT="sh $INT/engine_shim.sh {case} {out}"; ORAT="sh $INT/oracle_shim.sh {case} {out}" 227 228 # ---------- 5. case set (public corpus only; the hidden sets are never touched) ---------- 229 EC="$AT1/evaluator/cases" 230 cp -R "$EC/." "$OUT/cases/" 231 ( cd "$OUT/cases" && find . -type f | sed 's|^\./||' | LC_ALL=C sort | while read -r c; do printf '%s %s\n' "$(sha "$c")" "$c"; done ) > "$R/cases.sha256" 232 NPOS=$(grep -c '^positive/' "$EC/MANIFEST.tsv"); NNEG=$(grep -c '^negative/' "$EC/MANIFEST.tsv"); NREF=$(grep -c '^refuse/' "$EC/MANIFEST.tsv") 233 NCASE=$((NPOS+NNEG+NREF)) 234 say "cases: $NCASE (positive $NPOS, negative $NNEG, refuse $NREF); hidden sets not touched" 235 236 # ---------- 6. pass 1: the evaluator's own runner with the two shims ---------- 237 P1="$OUT/results/pass1"; P2="$OUT/results/pass2" 238 logrun "(cd evaluator && sh run.sh '$ENGT' '$ORAT' cases $P1)" 239 ( cd "$AT1/evaluator" && AT1_COMP_DIR="$OUT/components" sh run.sh "$ENGT" "$ORAT" cases "$P1" ) > "$R/evaluator-run-pass1.log" 2>&1; ev1=$? 240 say "pass 1: evaluator run.sh rc=$ev1" 241 242 # ---------- 7. pass 2 (repeatability): later, other time zone ---------- 243 sleep 2 244 logrun "(TZ=Asia/Tokyo sh evaluator/run.sh '$ENGT' '$ORAT' cases $P2)" 245 ( TZ=Asia/Tokyo sh "$AT1/evaluator/run.sh" "$ENGT" "$ORAT" cases "$P2" ) > "$R/evaluator-run-pass2.log" 2>&1; ev2=$? 246 say "pass 2: evaluator run.sh rc=$ev2" 247 RP_N=0; RP_BYTE=0; RP_STABLE=0; RP_BAD="" 248 for f in "$P1"/engine/*.result "$P1"/oracle/*.result "$P1"/spliced/*.result; do 249 [ -f "$f" ] || continue 250 rel=${f#"$P1"/}; g="$P2/$rel"; RP_N=$((RP_N+1)) 251 [ -f "$g" ] || { RP_BAD="$RP_BAD $rel(missing)"; continue; } 252 if cmp -s "$f" "$g"; then RP_BYTE=$((RP_BYTE+1)); RP_STABLE=$((RP_STABLE+1)) 253 elif [ "$(stable "$f")" = "$(stable "$g")" ]; then RP_STABLE=$((RP_STABLE+1)) 254 else RP_BAD="$RP_BAD $rel"; fi 255 done 256 for t in TABLE.tsv VERDICT_IDS.tsv; do cmp -s "$P1/$t" "$P2/$t" || RP_BAD="$RP_BAD $t"; done 257 if [ $RP_N -gt 0 ] && [ $RP_STABLE = $RP_N ] && [ -z "$RP_BAD" ] && [ $ev1 = $ev2 ]; then 258 ctrl C2-REPEATABILITY PASS "evaluator run.sh twice (2 s apart; TZ=UTC, then TZ=Asia/Tokyo); cmp of every engine, oracle and spliced result, TABLE.tsv, VERDICT_IDS.tsv" "$RP_N result files: $RP_STABLE/$RP_N identical outside run_started_utc, run_finished_utc, evidence_digest ($RP_BYTE/$RP_N byte-identical); TABLE.tsv and VERDICT_IDS.tsv byte-identical; both runs rc=$ev1" 259 else ctrl C2-REPEATABILITY FAIL "evaluator run.sh twice; compare" "stable $RP_STABLE/$RP_N, rc $ev1/$ev2; differ:$RP_BAD"; fi 260 261 # ---------- 8. integration controls over pass 1 ---------- 262 # C3: the engine's own splice and the evaluator's independent splice give the same file 263 SP_N=0; SP_OK=0; SP_BAD="" 264 for f in "$P1"/spliced/*.result; do 265 [ -f "$f" ] || continue 266 b=$(basename "$f"); SP_N=$((SP_N+1)) 267 cmp -s "$f" "$P1/engine/$b" && SP_OK=$((SP_OK+1)) || SP_BAD="$SP_BAD $b" 268 done 269 [ $SP_N -gt 0 ] && [ $SP_OK = $SP_N ] && ctrl C3-SPLICE-AGREEMENT PASS "cmp results/pass1/spliced/.result results/pass1/engine/.result (engine splice + judge vs evaluator splice + re-judge + reseal)" "$SP_OK/$SP_N byte-identical (same verdict block, verdict_id, provenance and evidence_digest)" \ 270 || ctrl C3-SPLICE-AGREEMENT FAIL "engine result vs evaluator splice" "identical $SP_OK/$SP_N; differ:$SP_BAD" 271 # C4: reading (c): the engine result's reference_* lines are exactly the oracle record's, in values-block 272 # order, and every other values line is the engine's own (at1-model values) 273 RC_N=0; RC_OK=0; RC_BAD="" 274 for f in "$P1"/engine/*.result; do 275 [ -f "$f" ] || continue 276 stem=$(basename "$f" .result); [ "$stem" = T9-second-run ] && continue 277 cls=${stem%%_*}; name=${stem#*_}; cf="$EC/$cls/$name.case"; o="$OUT/components/$stem.oracle" 278 RC_N=$((RC_N+1)) 279 [ -f "$o" ] || { RC_BAD="$RC_BAD $stem(no-record)"; continue; } 280 valblock "$f" | grep '^reference_' > "$WORK/rc.e"; valblock "$o" | grep '^reference_' > "$WORK/rc.o" 281 valblock "$f" | sed '1d;$d' | grep -v '^reference_' > "$WORK/rc.own"; "$MODEL" values "$cf" > "$WORK/rc.val" 2>/dev/null 282 if [ -s "$WORK/rc.o" ] && cmp -s "$WORK/rc.e" "$WORK/rc.o" && cmp -s "$WORK/rc.own" "$WORK/rc.val" \ 283 && [ "$(cut -d' ' -f1 "$WORK/rc.e" | uniq | tr '\n' ' ')" = "reference_label reference_clock_probability reference_ideal reference_interacting " ]; then RC_OK=$((RC_OK+1)); else RC_BAD="$RC_BAD $stem"; fi 284 done 285 [ $RC_N -gt 0 ] && [ $RC_OK = $RC_N ] && ctrl C4-SPLICE-READING-C PASS "per engine result: reference_* lines vs the oracle record the engine consumed (components/), other values lines vs at1-model values " "$RC_OK/$RC_N: all four reference_* families copied verbatim in values-block order (label, clock_probability, ideal, interacting), nothing else spliced" \ 286 || ctrl C4-SPLICE-READING-C FAIL "reading (c) splice check" "ok $RC_OK/$RC_N; bad:$RC_BAD" 287 # C5: every engine result names the pinned contract commit and the pinned provenance 288 CC_N=0; CC_OK=0 289 for f in "$P1"/engine/*.result; do [ -f "$f" ] || continue; CC_N=$((CC_N+1)); [ "$(field "$f" contract_commit)" = "$CONTRACT_COMMIT" ] && [ "$(field "$f" source_commit)" = "$HEAD" ] && [ "$(field "$f" engine_sha256)" = "$ENGINE_SHA" ] && [ "$(field "$f" oracle_sha256)" = "$ORACLE_SHA" ] && CC_OK=$((CC_OK+1)); done 290 for f in "$OUT"/components/*.oracle; do [ -f "$f" ] || continue; CC_N=$((CC_N+1)); [ "$(field "$f" contract_commit)" = "$CONTRACT_COMMIT" ] && [ "$(field "$f" engine_sha256)" = "$ORACLE_SHA" ] && [ "$(field "$f" source_commit)" = "$HEAD" ] && CC_OK=$((CC_OK+1)); done 291 [ $CC_N -gt 0 ] && [ $CC_OK = $CC_N ] && ctrl C5-PROVENANCE-PIN PASS "contract_commit, source_commit, engine_sha256, oracle_sha256 of every engine result and oracle record" "$CC_OK/$CC_N name contract_commit $CONTRACT_COMMIT, omega $SHORT and the built binaries; oracle build recorded source_tree_clean $(printf '%s' "$OSTATE" | tr '\n' ' ')" \ 292 || ctrl C5-PROVENANCE-PIN FAIL "provenance pin" "$CC_OK/$CC_N" 293 # C6: label evaluation order does not change a byte 294 EO_N=0; EO_OK=0; EO_BAD="" 295 printf 'run_started_utc 2026-01-01T00:00:00Z\nrun_finished_utc 2026-01-01T00:00:00Z\n' | cat "$PROV" - > "$WORK/prov.fixed" 296 for o in "$OUT"/components/*.oracle; do 297 [ -f "$o" ] || continue 298 stem=$(basename "$o" .oracle); cls=${stem%%_*}; name=${stem#*_}; cf="$EC/$cls/$name.case"; EO_N=$((EO_N+1)) 299 "$MODEL" result "$cf" "$o" "$WORK/prov.fixed" > "$WORK/eo.f" 2>/dev/null; "$MODEL" result "$cf" "$o" "$WORK/prov.fixed" --reversed > "$WORK/eo.r" 2>/dev/null 300 [ -s "$WORK/eo.f" ] && cmp -s "$WORK/eo.f" "$WORK/eo.r" && EO_OK=$((EO_OK+1)) || EO_BAD="$EO_BAD $stem" 301 done 302 [ $EO_N -gt 0 ] && [ $EO_OK = $EO_N ] && ctrl C6-EVALUATION-ORDER PASS "at1-model result with and without --reversed, cmp" "$EO_OK/$EO_N byte-identical" \ 303 || ctrl C6-EVALUATION-ORDER FAIL "at1-model --reversed" "identical $EO_OK/$EO_N; differ:$EO_BAD" 304 # C7: direct verification of each engine-written result (not the evaluator's re-splice) 305 DV_N=0; DV_OK=0; DV_BAD="" 306 mkdir -p "$OUT/results/verify" 307 for f in "$P1"/engine/*.result; do 308 [ -f "$f" ] || continue 309 stem=$(basename "$f" .result); [ "$stem" = T9-second-run ] && continue 310 cls=${stem%%_*}; name=${stem#*_}; cf="$EC/$cls/$name.case"; DV_N=$((DV_N+1)) 311 "$EVAL" verify --case "$cf" "$f" > "$OUT/results/verify/$stem.txt" 2>&1; vrc=$? 312 tv=$(awk -F'\t' -v p="$cls/$name.case" '$1==p {print $9}' "$P1/TABLE.tsv") 313 [ $vrc -eq 0 ] && [ "$tv" = PASS ] && DV_OK=$((DV_OK+1)) || DV_BAD="$DV_BAD $stem(rc=$vrc,table=$tv)" 314 done 315 [ $DV_N -gt 0 ] && [ $DV_OK = $DV_N ] && ctrl C7-DIRECT-VERIFY PASS "at1-eval verify --case results/pass1/engine/.result" "$DV_OK/$DV_N AT1_VERIFY PASS, each matching the evaluator's TABLE.tsv case verdict" \ 316 || ctrl C7-DIRECT-VERIFY FAIL "at1-eval verify on engine results" "pass $DV_OK/$DV_N; others:$DV_BAD" 317 318 # ---------- 9. real-engine physics mutants: M1 drop V, M3 V on the wrong level (freeze record), plus the 319 # remaining AT1_SPEC 9.2 physics mutants M2 flip V, M4 phase sign, M5 Y sign, M6 axis swap, M8 ideal marginal 320 # (post-freeze follow-up from the G8 review, AT1_RESULTS.md section 5 item 3; predicted cells are Agent 4's) ---------- 321 MLIB="at1_bn.c at1_case.c at1_exact.c at1_numeric.c at1_result.c at1_io.c" 322 mutant_model() { # name sed-script file -> $WORK/mut//at1-model 323 mn=$1; ms=$2; mf=$3; md="$WORK/mut/$mn"; mkdir -p "$md" 324 cp "$AT1"/model/*.c "$AT1"/model/*.h "$md/" 325 sed "$ms" "$AT1/model/$mf" > "$md/$mf" 326 if cmp -s "$AT1/model/$mf" "$md/$mf"; then echo "mutation $mn did not change $mf" >> "$LOG"; return 1; fi 327 ( cd "$md" && $CCBIN $MCFLAGS -I"$S/src" -o at1-model $MLIB "$S/src/omega_om_units.c" at1_main.c -lm ) > "$md/build.log" 2>&1 328 } 329 MR="$AT1/evaluator/results/MUTANT_RECEIPT.tsv" 330 for mn in drop_v wrong_level flip_v phase_sign y_sign axis_swap ideal_marginal; do 331 case $mn in 332 drop_v) MS='s/mat s = kron(&Pj, &Vj); mat_addto(&H, &s);/mat s = kron(\&Pj, \&Vj);/'; AM=M1-drop-v; MF=at1_exact.c;; 333 wrong_level) MS='s/gq_set_rat(&t, &c->v\[j\]\[a\], NULL);/gq_set_rat(\&t, \&c->v[(j + N - 1) % N][a], NULL);/'; AM=M3-wrong-level; MF=at1_exact.c;; 334 flip_v) MS='s/gq_set_rat(&t, &c->v\[j\]\[a\], NULL);/gq_set_rat(\&t, \&c->v[j][a], NULL); gq_neg(\&t, \&t);/'; AM=M2-flip-v; MF=at1_exact.c;; 335 phase_sign) MS='s/out->re = cos(ang); out->im = -sin(ang);/out->re = cos(ang); out->im = sin(ang);/'; AM=M4-phase-sign; MF=at1_numeric.c;; 336 y_sign) MS='s/{ 0, -0.5 } }, { { 0, 0.5 }/@@TMP@@/; s/{ 0, 0.5 } }, { { 0, -0.5 }/{ 0, -0.5 } }, { { 0, 0.5 }/; s/@@TMP@@/{ 0, 0.5 } }, { { 0, -0.5 }/'; AM=M5-y-sign; MF=at1_numeric.c;; 337 axis_swap) MS='/\/\* X+ \*\//s/{ {.*} },/{ { { 0.5, 0 }, { 0, -0.5 } }, { { 0, 0.5 }, { 0.5, 0 } } },/; /\/\* X- \*\//s/{ {.*} },/{ { { 0.5, 0 }, { 0, 0.5 } }, { { 0, -0.5 }, { 0.5, 0 } } },/; /\/\* Y+ \*\//s/{ {.*} },/{ { { 0.5, 0 }, { 0.5, 0 } }, { { 0.5, 0 }, { 0.5, 0 } } },/; /\/\* Y- \*\//s/{ {.*} },/{ { { 0.5, 0 }, { -0.5, 0 } }, { { -0.5, 0 }, { 0.5, 0 } } },/'; AM=M6-axis-swap; MF=at1_numeric.c;; 338 ideal_marginal) MS='s/double p = w \* n2 \/ norm2;/double p = w \/ (double)N;/'; AM=M8-ideal-marginal; MF=at1_numeric.c;; 339 esac 340 mkdir -p "$OUT/mutants/$mn" 341 if mutant_model $mn "$MS" "$MF"; then 342 MBCC=$(ptext "(MUTANT $mn control, not a qualification result) $CC_V (engine); $RUSTC_V (oracle)"); MBCC=$(printf '%s' "$MBCC" | sed 's/[\/&]/\\&/g') 343 sed "s/^engine_sha256 .*/engine_sha256 $(sha "$WORK/mut/$mn/at1-model")/; s/^build_cc .*/build_cc $MBCC/" "$PROV" > "$WORK/prov.mut.$mn" 344 awk -F'\t' -v m="$AM" '$1==m {print $2 "\t" (($6 ~ /^BLIND/) ? "BLIND" : "KILLED")}' "$MR" | while IFS="$(printf '\t')" read -r c pred; do 345 stem=$(printf '%s' "$c" | sed 's|/|_|; s|\.case$||'); res="$OUT/mutants/$mn/$stem.result" 346 AT1_MODEL_BIN="$WORK/mut/$mn/at1-model" AT1_PROV_STATIC="$WORK/prov.mut.$mn" \ 347 sh "$INT/engine_shim.sh" "$EC/$c" "$res" 2> "$WORK/mut.err"; rc=$? 348 if [ $rc -ne 0 ]; then got=KILLED; how="no result rc=$rc $(head -1 "$WORK/mut.err" | cut -c1-60)"; rm -f "$res" 349 else 350 "$EVAL" verify --case "$EC/$c" "$res" > "$WORK/mut.v" 2>&1; vrc=$? 351 if [ $vrc -eq 0 ] && [ "$(field "$res" expectation_met)" = YES ]; then got=BLIND; else got=KILLED; fi 352 how="verify rc=$vrc outcome $(field "$res" outcome) codes $(field "$res" failure_codes) expectation_met $(field "$res" expectation_met)" 353 fi 354 printf '%s\t%s\t%s\t%s\n' "$c" "$pred" "$got" "$how" 355 done > "$R/mutant-$mn.tsv" 356 else echo "mutant $mn did not build: $(tail -2 "$WORK/mut/$mn/build.log" 2>/dev/null)" >> "$LOG"; : > "$R/mutant-$mn.tsv"; fi 357 MN=$(wc -l < "$R/mutant-$mn.tsv" | tr -d ' '); MK=$(awk -F'\t' '$3=="KILLED"' "$R/mutant-$mn.tsv" | wc -l | tr -d ' ') 358 MDIFF=$(awk -F'\t' '$2!=$3 {printf " %s(predicted %s, got %s)", $1, $2, $3}' "$R/mutant-$mn.tsv") 359 MBL=$(awk -F'\t' '$3=="BLIND" {printf " %s", $1}' "$R/mutant-$mn.tsv") 360 KATK=$(awk -F'\t' '$1 ~ /P2-kat/ {print $3}' "$R/mutant-$mn.tsv") 361 [ "$MN" -gt 0 ] && [ -z "$MDIFF" ] && [ "$KATK" = KILLED ] && ctrl "C8-ENGINE-MUTANT-$(echo $mn | tr a-z_ A-Z-)" PASS "copy of model/$MF with $AM applied ($MS), built with the model flags, every case of Agent 4's $AM receipt rows through the shim and at1-eval verify" "$MK/$MN killed; blind:${MBL:- none}; every cell equals Agent 4's predicted KILLED/BLIND" \ 362 || ctrl "C8-ENGINE-MUTANT-$(echo $mn | tr a-z_ A-Z-)" FAIL "real-engine $AM mutant" "$MK/$MN killed; KAT $KATK; cells differing from the receipt:${MDIFF:- none}" 363 done 364 365 # ---------- 10. isolation (G2): Agent 4's gate on the candidates' compute objects, plus mutants ---------- 366 ISO="$WORK/iso"; mkdir -p "$ISO/clean" "$ISO/mut" 367 ISOOK=1 368 for f in "$AT1"/model/at1_*.c "$S/src/omega_om_units.c"; do 369 b=$(basename "$f" .c) 370 $CCBIN $MCFLAGS -I"$AT1/model" -I"$S/src" -c "$f" -o "$ISO/clean/$b.o" >> "$LOG" 2>&1 || ISOOK=0 371 done 372 GATE="$AT1/evaluator/gates/isolation.sh" 373 # allowed() obj "sym sym": run the gate on one object; PASS iff every FAIL line is "references " with sym in the list 374 allowed() { 375 sh "$GATE" "$EVAL" "$1" > "$WORK/al.out" 2>&1; alrc=$? 376 # One FAIL line per iteration, read from a file (not a pipe) so the loop runs in this shell, and no 377 # case statement inside $( ): bash 3.2 (macOS /bin/sh) cannot parse that (Agent 7 finding, G7 run 2). 378 grep '^FAIL' "$WORK/al.out" > "$WORK/al.fail"; bad="" 379 while read -r l; do 380 s=$(printf '%s' "$l" | sed -n 's/^FAIL: .* references \([A-Za-z0-9_]*\)$/\1/p') 381 keep=1 382 if [ -n "$s" ]; then case " $2 " in *" $s "*) keep=0;; esac; fi 383 [ $keep -eq 1 ] && bad="$bad$l 384 " 385 done < "$WORK/al.fail" 386 cat "$WORK/al.out" 387 # the gate must have run to its summary line; a nonzero exit is acceptable only with exempt FAIL lines and nothing else 388 grep -q '^AT1_ISOLATION: ' "$WORK/al.out" || return 1 389 [ $alrc -eq 0 ] || grep -q '^FAIL: .* references ' "$WORK/al.out" || return 1 390 [ -z "$bad" ] 391 } 392 STRICT="$ISO/clean/at1_bn.o $ISO/clean/at1_case.o $ISO/clean/at1_exact.o $ISO/clean/at1_numeric.o $ISO/clean/at1_result.o $ISO/clean/omega_om_units.o" 393 sh "$GATE" "$EVAL" $STRICT > "$R/isolation-engine-strict.log" 2>&1; i1=$? 394 i2=0 # at1_bn is strict since omega D2 follow-up: its fatal exit moved to at1_io.c (at1_fatal) 395 allowed "$ISO/clean/at1_io.o" "fopen fread" > "$R/isolation-engine-io.log" 2>&1; i3=$? 396 sh "$GATE" "$EVAL" "$ISO/clean/at1_main.o" > "$R/isolation-engine-main-record-only.log" 2>&1 397 [ $ISOOK = 1 ] && [ $i1 -eq 0 ] && [ $i2 -eq 0 ] && [ $i3 -eq 0 ] && ctrl C9-ISOLATION-ENGINE PASS "evaluator/gates/isolation.sh (nm symbol scan + at1-eval scan-clock instruction scan) on every engine object compiled with the model flags: at1_bn, at1_case, at1_exact, at1_numeric, at1_result, sha256 strictly (at1_bn strict since the D2 follow-up moved its fatal exit into at1_io.c); at1_io (the file reader) with only fopen, fread exempt; at1_main (CLI) recorded, not judged" "strict set clean ($(tail -1 "$R/isolation-engine-strict.log")); at1_io: only fopen, fread (plus the at1_fatal diagnostic line via fprintf, not a banned symbol); no instruction hit anywhere" \ 398 || ctrl C9-ISOLATION-ENGINE FAIL "gates/isolation.sh on engine objects" "build=$ISOOK strict rc=$i1 bn rc=$i2 io rc=$i3: $(grep '^FAIL' "$R"/isolation-engine-strict.log "$R/isolation-engine-bn.log" "$R/isolation-engine-io.log" | head -3 | tr '\n' ' ')" 399 # the three gate controls of Agent 4, embedded in a real engine compute object 400 MUTOK=1; MUTMSG="" 401 for m in hidden_clock_mutant counter_mutant raw_syscall_mutant; do 402 cat "$AT1/model/at1_numeric.c" "$AT1/evaluator/gates/$m.c" > "$ISO/mut/at1_numeric_$m.c" 403 if $CCBIN -O2 -I"$AT1/model" -I"$S/src" -c "$ISO/mut/at1_numeric_$m.c" -o "$ISO/mut/at1_numeric_$m.o" >> "$LOG" 2>&1; then 404 nm "$ISO/mut/at1_numeric_$m.o" 2>/dev/null | grep -q " T _\{0,1\}at1_[a-z_]*phase$" || { MUTOK=0; MUTMSG="$MUTMSG $m:mutant-function-absent"; continue; } 405 sh "$GATE" "$EVAL" "$ISO/mut/at1_numeric_$m.o" > "$R/isolation-engine-$m.log" 2>&1; g=$? 406 case $m in hidden_clock_mutant) want='references clock_gettime';; *) want='^FAIL: instruction';; esac 407 if [ $g -ne 0 ] && grep -q "$want" "$R/isolation-engine-$m.log"; then MUTMSG="$MUTMSG $m:caught"; else MUTOK=0; MUTMSG="$MUTMSG $m:NOT-caught(rc=$g)"; fi 408 else MUTOK=0; MUTMSG="$MUTMSG $m:not-built"; fi 409 done 410 [ $MUTOK = 1 ] && ctrl C10-ISOLATION-ENGINE-MUTANTS PASS "at1_numeric.c with each of evaluator/gates/{hidden_clock,counter,raw_syscall}_mutant.c appended, compiled -O2, then gates/isolation.sh" "all three flagged:$MUTMSG (clock_gettime by the symbol scan; the inline counter read and inline system call by the instruction scan)" \ 411 || ctrl C10-ISOLATION-ENGINE-MUTANTS FAIL "engine-object mutants" "$MUTMSG" 412 # Rust oracle: the compute rlib members strictly, then three Rust mutants 413 RI="$WORK/riso"; mkdir -p "$RI/clean" 414 ( cd "$AT1/oracle" && sh build.sh lib ) >> "$LOG" 2>&1 415 ( cd "$RI/clean" && ar x "$AT1/oracle/target/libat1.rlib" ) 2>> "$LOG" 416 sh "$GATE" "$EVAL" "$RI"/clean/*.o > "$R/isolation-oracle.log" 2>&1; r0=$? 417 [ $r0 -eq 0 ] && ctrl C11-ISOLATION-ORACLE PASS "oracle/build.sh lib; ar x libat1.rlib; gates/isolation.sh on each object member" "$(tail -1 "$R/isolation-oracle.log") (compute crate src/at1 only; main.rs is the I/O layer, excluded by design)" \ 418 || ctrl C11-ISOLATION-ORACLE FAIL "gates/isolation.sh on oracle rlib members" "$(grep '^FAIL' "$R/isolation-oracle.log" | head -2 | tr '\n' ' ')" 419 cat > "$RI/std_time.rs" <<'EOF' 420 #[inline(never)] pub fn hidden_clock() -> u64 { std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0) } 421 EOF 422 cat > "$RI/counter.rs" <<'EOF' 423 #[cfg(target_arch = "aarch64")] 424 #[inline(never)] pub fn hidden_counter() -> u64 { let t: u64; unsafe { core::arch::asm!("mrs {}, cntvct_el0", out(reg) t); } t } 425 #[cfg(target_arch = "x86_64")] 426 #[inline(never)] pub fn hidden_counter() -> u64 { let lo: u32; let hi: u32; unsafe { core::arch::asm!("rdtsc", out("eax") lo, out("edx") hi); } ((hi as u64) << 32) | lo as u64 } 427 EOF 428 cat > "$RI/raw_syscall.rs" <<'EOF' 429 #[cfg(all(target_arch = "aarch64", target_os = "linux"))] 430 #[inline(never)] pub fn hidden_syscall() -> i64 { let mut ts = [0i64; 2]; let r: i64; unsafe { core::arch::asm!("svc #0", inout("x0") 0i64 => r, in("x1") ts.as_mut_ptr(), in("x8") 113i64); } r + ts[1] } 431 #[cfg(all(target_arch = "aarch64", target_os = "macos"))] 432 #[inline(never)] pub fn hidden_syscall() -> i64 { let mut ts = [0i64; 2]; let r: i64; unsafe { core::arch::asm!("svc #0x80", inout("x0") ts.as_mut_ptr() as i64 => r, in("x1") 0i64, in("x16") 116i64); } r + ts[1] } 433 #[cfg(all(target_arch = "x86_64", target_os = "linux"))] 434 #[inline(never)] pub fn hidden_syscall() -> i64 { let mut ts = [0i64; 2]; let r: i64; unsafe { core::arch::asm!("syscall", inout("rax") 228i64 => r, in("rdi") 0i64, in("rsi") ts.as_mut_ptr(), out("rcx") _, out("r11") _); } r + ts[1] } 435 EOF 436 RFL=$(printf '%s' "$OFLAGS" | sed 's/ -D warnings//') 437 RMOK=1; RMMSG="" 438 for m in std_time counter raw_syscall; do 439 mkdir -p "$RI/$m/iso"; cp -R "$AT1/oracle/src/at1" "$RI/$m/at1"; printf '\n' >> "$RI/$m/at1/mod.rs"; cat "$RI/$m.rs" >> "$RI/$m/at1/mod.rs" 440 if ( cd "$RI/$m" && rustc $RFL --crate-type lib --crate-name at1_mutant at1/mod.rs -o lib.rlib && cd iso && ar x ../lib.rlib ) >> "$LOG" 2>&1; then 441 nm "$RI/$m"/iso/*.o 2>/dev/null | grep -q " T .*hidden_" || { RMOK=0; RMMSG="$RMMSG $m:mutant-function-absent"; continue; } 442 sh "$GATE" "$EVAL" "$RI/$m"/iso/*.o > "$R/isolation-oracle-mutant-$m.log" 2>&1; g=$? 443 case $m in std_time) want='Rust std time';; *) want='^FAIL: instruction';; esac 444 if [ $g -ne 0 ] && grep -q "$want" "$R/isolation-oracle-mutant-$m.log"; then RMMSG="$RMMSG $m:caught"; else RMOK=0; RMMSG="$RMMSG $m:NOT-caught(rc=$g)"; fi 445 else RMOK=0; RMMSG="$RMMSG $m:not-built"; fi 446 done 447 [ $RMOK = 1 ] && ctrl C12-ISOLATION-ORACLE-MUTANTS PASS "copy of oracle src/at1 with a std::time read, an inline asm counter read, an inline asm clock system call appended; rlib members through gates/isolation.sh" "all three flagged:$RMMSG" \ 448 || ctrl C12-ISOLATION-ORACLE-MUTANTS FAIL "Rust oracle mutants" "$RMMSG" 449 GC=$(grep -c '^AT1_ISOLATION_CONTROLS: PASS$' "$R/evaluator-isolation-controls.txt" 2>/dev/null) 450 [ "$GC" = 1 ] && ctrl C13-GATE-CONTROLS PASS "evaluator make test: gates/isolation.sh --controls (clean, hidden clock, counter, raw syscall)" "$(grep -c AS_INTENDED "$R/evaluator-isolation-controls.txt") rows AS_INTENDED; symbol scan alone blind to the two inline mutants, as designed" \ 451 || ctrl C13-GATE-CONTROLS FAIL "gates/isolation.sh --controls" "see receipts/evaluator-isolation-controls.txt" 452 453 # ---------- 11. make hygiene (G2) ---------- 454 if [ -f "$S/mk/at1.mk" ]; then 455 HY="$WORK/hyg"; mkdir -p "$HY" 456 MKV="PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0" 457 S2="$WORK/src-without" 458 hy() { # tag dir 459 D=$2 460 for g in all test; do 461 ( cd "$D" && make -n -k $g $MKV ) > "$HY/$1.$g" 2>&1; echo "exit $?" >> "$HY/$1.$g" 462 ( cd "$D" && make -n -k $g ) > "$HY/$1.$g.default" 2>&1; echo "exit $?" >> "$HY/$1.$g.default" 463 done 464 # database: comments dropped, both clone paths written , commit stamps masked; the fragment's own 465 # names (AT1_* variables, at1-check/at1-clean rules and recipes, its own file entry "mk/at1.mk:", 466 # its MAKEFILE_LIST and .PHONY entries) removed 467 ( cd "$D" && make -pn -k all $MKV ) 2>/dev/null | grep -v '^#' | sed "s|$S2||g; s|$S||g" | sed -E 's/[0-9a-f]{12,40}/SHA/g; s/ at1-check at1-clean//; s| mk/at1\.mk||g' \ 468 | grep -v -E '^(AT1_[A-Z0-9_]* [:?+]?= |at1-(check|clean):|mk/at1\.mk:|MAKEFILE_LIST|MA2_RUN_ID|R16_STAMP)' | grep -v -E "^${TAB}.*(AT1_|integration/run\\.sh)" | LC_ALL=C sort -u > "$HY/$1.db" 469 } 470 # "without": a second clone with mk/at1.mk removed and committed, so both trees are clean 471 hok=1; hmsg="" 472 git -C "$S" -c core.hooksPath=/dev/null clone -q --no-hardlinks "$S" "$S2" >> "$LOG" 2>&1 && git -C "$S2" rm -q mk/at1.mk >> "$LOG" 2>&1 \ 473 && git -C "$S2" -c core.hooksPath=/dev/null -c commit.gpgsign=false -c user.email=a5@example.invalid -c user.name=a5 commit -q -m "without at1.mk (control)" >> "$LOG" 2>&1 \ 474 && [ ! -e "$S2/mk/at1.mk" ] || { hok=0; hmsg=" control-clone-not-made"; } 475 # warm both trees once (a first make in a fresh clone may generate files), then compare 476 ( cd "$S" && make -n -k all $MKV ) > /dev/null 2>&1; ( cd "$S2" && make -n -k all $MKV ) > /dev/null 2>&1 477 hy with "$S"; hy without "$S2" 478 for g in all test; do for v in "" ".default"; do cmp -s "$HY/with.$g$v" "$HY/without.$g$v" || { hok=0; hmsg="$hmsg $g$v"; }; done; done 479 # the comparison must not be vacuous: the existing build must actually have been planned 480 grep -q 'omegatool' "$HY/with.all" || { hok=0; hmsg="$hmsg all-plan-empty"; } 481 for g in all test; do cp "$HY/with.$g" "$R/make-n-$g.with.txt"; cp "$HY/without.$g" "$R/make-n-$g.without.txt"; done 482 diff "$HY/without.db" "$HY/with.db" > "$R/make-database.diff"; drc=$? 483 extra=$(grep -c '^[<>]' "$R/make-database.diff") 484 dbok=1; { [ $drc -le 1 ] && grep -q '^SRCS ' "$HY/with.db" && grep -q '^all:' "$HY/with.db" && grep -q '^test:' "$HY/with.db"; } || dbok=0 485 [ $hok = 1 ] && ctrl C14-MAKE-N-HYGIENE PASS "make -n -k all|test with $MKV and with defaults, fragment present vs removed-and-committed clone (cmp of stdout+stderr+exit)" "byte-identical in all four comparisons (all: $(wc -l < "$HY/with.all" | tr -d ' ') lines, $(tail -1 "$HY/with.all"); test: $(wc -l < "$HY/with.test" | tr -d ' ') lines, $(tail -1 "$HY/with.test")); the plan names omegatool" \ 486 || ctrl C14-MAKE-N-HYGIENE FAIL "make -n -k all|test with and without mk/at1.mk" "problems:$hmsg" 487 [ "$extra" = 0 ] && [ $dbok = 1 ] && ctrl C15-MAKE-DATABASE PASS "make -pn -k all, sorted, fragment present vs removed; clone paths written ; only the fragment's own AT1_* variables, at1-check/at1-clean rules, its MAKEFILE_LIST and .PHONY entries removed" "empty diff over $(wc -l < "$HY/with.db" | tr -d ' ') database lines (SRCS, all, test present): no variable, rule, target or prerequisite of the existing build changes" \ 488 || ctrl C15-MAKE-DATABASE FAIL "make -pn database diff" "$extra changed lines, diff rc=$drc, database sane=$dbok; see make-database.diff" 489 ( cd "$S" && make -n at1-check $MKV ) > "$R/make-n-at1-check.txt" 2>&1; pc=$? 490 ( cd "$S" && make -n at1-clean $MKV ) > "$R/make-n-at1-clean.txt" 2>&1; pc2=$? 491 ( cd "$S" && make -n --warn-undefined-variables at1-check at1-clean $MKV ) > "$R/make-warn-undefined.txt" 2>&1 492 wu=$(grep -i 'undefined variable' "$R/make-warn-undefined.txt" | grep -c 'AT1_') 493 [ $pc -eq 0 ] && [ $pc2 -eq 0 ] && [ "$wu" = 0 ] && grep -q 'integration/run.sh' "$R/make-n-at1-check.txt" && ctrl C16-MAKE-PARSES PASS "make -n at1-check; make -n at1-clean; make -n --warn-undefined-variables (all with $MKV)" "both plan: $(grep -m1 run.sh "$R/make-n-at1-check.txt" | cut -c1-90); no undefined AT1_ variable" \ 494 || ctrl C16-MAKE-PARSES FAIL "make -n at1-check at1-clean" "rc=$pc/$pc2 undefined-AT1-warnings=$wu" 495 else 496 for k in C14-MAKE-N-HYGIENE C15-MAKE-DATABASE C16-MAKE-PARSES; do ctrl $k FAIL "test -f mk/at1.mk" "mk/at1.mk is not committed at HEAD (a deliverable of this runner)"; done 497 fi 498 499 # ---------- 12. gates ---------- 500 cp "$P1/TABLE.tsv" "$R/TABLE.pass1.tsv" 2>/dev/null; cp "$P1/VERDICT_IDS.tsv" "$R/VERDICT_IDS.pass1.tsv" 2>/dev/null 501 eg() { grep "^# $1 " "$P1/TABLE.tsv" 2>/dev/null | head -1 | sed 's/.*: \([A-Z_]*\)$/\1/'; } # read a gate verdict off the evaluator's table 502 cnt() { grep "^# $1: " "$P1/TABLE.tsv" 2>/dev/null | head -1 | sed 's/^# [a-z]*: //'; } 503 G1E=$(eg AT1-G1); G3E=$(eg AT1-G3); G4E=$(eg AT1-G4); G5E=$(eg AT1-G5) 504 T9L=$(grep '^# T9 ' "$P1/TABLE.tsv" 2>/dev/null | sed 's/^# T9 [^:]*: //' | cut -d' ' -f1) 505 G1BAD=$(awk -F'\t' '!/^#/ && $3!="AT1_CASE_OK" && $9!="PASS" {printf " %s(engine: %s; oracle: %s)", $1, $5, $6}' "$P1/TABLE.tsv" 2>/dev/null) 506 gate AT1-G0 REFERENCE "AT0_FREEZE.md AT-1 rows, AT1_CHARTER.md section 11; control C0" "freeze recorded by Agent 0 (aien-architecture contract $(printf %.7s "$CONTRACT_COMMIT"), spec $(printf %.7s "$SPEC_COMMIT"), from contract.lock); this run: C0-CONTRACT-DIGESTS $(cst C0-CONTRACT-DIGESTS)" 507 gate AT1-G1 "${G1E:-NOT_RUN}" "evaluator TABLE.tsv line AT1-G1 (evaluator codec, engine and oracle refusals exact on every refuse row; KAT digests copied)" "refusal rows: $(cnt refusal); failing rows:${G1BAD:- none}" 508 isoG=PASS 509 for k in C9-ISOLATION-ENGINE C10-ISOLATION-ENGINE-MUTANTS C11-ISOLATION-ORACLE C12-ISOLATION-ORACLE-MUTANTS C13-GATE-CONTROLS C14-MAKE-N-HYGIENE C15-MAKE-DATABASE C16-MAKE-PARSES C1-ORACLE-OWN-ISOLATION; do 510 st=$(cst $k); case "$st" in PASS) ;; FAIL) isoG=FAIL;; *) [ $isoG = FAIL ] || isoG=NOT_RUN;; esac 511 done 512 gate AT1-G2 "$isoG" "controls C9-C16 and C1-ORACLE-OWN-ISOLATION (Agent 4's gates/isolation.sh on engine and oracle compute objects, engine-object and Rust mutants for clock symbol, counter read and raw system call; gate controls; make hygiene)" "symbol + instruction scans of compute objects only; the evaluator is UNISOLATED (same host, same account); what the scans cannot see is listed in QUALIFICATION.md" 513 gate AT1-G3 "${G3E:-NOT_RUN}" "evaluator TABLE.tsv line AT1-G3 (every oracle record against the evaluator's exact shadow)" "oracle records judged on $((NPOS+NNEG)) valid cases" 514 gate AT1-G4 "${G4E:-NOT_RUN}" "evaluator TABLE.tsv line AT1-G4 (every POSITIVE case verifies PASS)" "positive: $(cnt positive)" 515 gate AT1-G5 "${G5E:-NOT_RUN}" "evaluator TABLE.tsv line AT1-G5 (every NEGATIVE case FAILs with exactly its codes) and evaluator run.sh mutant receipt cmp" "negative: $(cnt negative); $(grep -m1 '^MUTANT_RECEIPT' "$R/evaluator-run-pass1.log")" 516 # G6 is read off the evaluator's own lines: its self-checks (corpus-check, selftest, mutant receipt), 517 # every candidate result verified (G4 and G5 lines) and T9. The G1 refusal rows are G1's business: when 518 # only G1 fails, run.sh exits 1 for that reason alone and G6 says so instead of counting it twice. 519 EL="$R/evaluator-run-pass1.log" 520 E_CORP=$(grep -c '^corpus-check: [0-9]* files, 0 differ$' "$EL"); E_SELF=$(grep -c '^SELFTEST: PASS ' "$EL"); E_MUT=$(grep -c '^MUTANT_RECEIPT: PASS ' "$EL") 521 if [ $ev1 -ne 0 ] && [ ! -s "$P1/TABLE.tsv" ]; then G6=FAIL # the evaluator stopped in its own self-checks before qualifying 522 elif [ -z "$T9L" ] || [ -z "$G4E" ]; then G6=NOT_RUN 523 elif [ "$E_CORP" = 1 ] && [ "$E_SELF" = 1 ] && [ "$E_MUT" = 1 ] && [ "$G4E" = PASS ] && [ "$G5E" = PASS ] && [ "$G3E" = PASS ] && [ "$T9L" = PASS ]; then G6=PASS 524 else G6=FAIL; fi 525 G6WHY="run.sh rc=$ev1"; [ $ev1 -ne 0 ] && [ "$G6" = PASS ] && [ "$G1E" = FAIL ] && G6WHY="run.sh rc=$ev1 caused only by the AT1-G1 row(s) above" 526 gate AT1-G6 "$G6" "evaluator lines on this host: corpus-check 0 differ, SELFTEST PASS, MUTANT_RECEIPT PASS (cmp with the committed receipt), AT1-G3, AT1-G4, AT1-G5 PASS, T9 PASS" "$G6WHY; $(grep -m1 '^SELFTEST' "$EL"); $(grep -m1 '^corpus-check' "$EL"); T9 $T9L; the evaluator ran on the same host and account as the candidates (UNISOLATED)" 527 gate AT1-G7 NOT_RUN "-" "Agent 7 (replication on the MacBook) owns G7" 528 gate AT1-G8 NOT_RUN "-" "Agent 6 (scientific review) owns G8" 529 530 # receipts name the temporary work directory as , so two runs' receipts compare without noise 531 # (both the resolved path and its /private-less or /private-prefixed twin, for macOS /var/folders) 532 case "$WORK" in /private/*) WORK_ALT=${WORK#/private};; *) WORK_ALT=/private$WORK;; esac 533 for f in "$R"/*.log "$R"/*.txt "$R"/*.tsv "$LOG"; do 534 [ -f "$f" ] || continue 535 sed -e "s|$WORK||g" -e "s|$WORK_ALT||g" "$f" > "$WORK/scrub.tmp" && cat "$WORK/scrub.tmp" > "$f" 536 done 537 # ---------- 13. result digests and summary ---------- 538 ( cd "$OUT" && find results mutants components -type f | LC_ALL=C sort | while read -r f; do printf '%s %s\n' "$(sha "$f")" "$f"; done ) > "$R/outputs.sha256" 539 NRES=$(ls "$P1"/engine/*.result 2>/dev/null | grep -vc T9-second-run) 540 { 541 echo "omega_commit $HEAD"; echo "source_tree_clean $CLEAN"; echo "starting_checkout_clean $OUTER_CLEAN"; echo "contract_commit $CONTRACT_COMMIT"; echo "stamp $STAMP"; echo "host $HOSTT" 542 echo "cases $NCASE: positive $NPOS, negative $NNEG, refuse $NREF; engine results written $NRES" 543 echo "evaluator table: positive $(cnt positive); negative $(cnt negative); refusal $(cnt refusal)" 544 MSUM=""; for mn in drop_v wrong_level flip_v phase_sign y_sign axis_swap ideal_marginal; do MSUM="$MSUM $mn $(awk -F'\t' '$3=="KILLED"' "$R/mutant-$mn.tsv" | wc -l | tr -d ' ')/$(wc -l < "$R/mutant-$mn.tsv" | tr -d ' ') killed;"; done 545 echo "mutants:$MSUM evaluator receipt $(grep -m1 '^MUTANT_RECEIPT' "$R/evaluator-run-pass1.log")" 546 } > "$R/summary.txt" 547 cat "$R/summary.txt" | tee -a "$LOG" 548 NFAIL=$(awk -F'\t' '$2=="FAIL"' "$GATES" | wc -l | tr -d ' '); NCF=$(awk -F'\t' '$2=="FAIL"' "$CTRL" | wc -l | tr -d ' ') 549 say "gates: $(awk -F'\t' '{printf "%s=%s ", $1, $2}' "$GATES")" 550 say "controls failing: $NCF; gates failing: $NFAIL" 551 [ "$NFAIL" -eq 0 ] && [ "$NCF" -eq 0 ]