Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/turing/origsel-run.sh # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / turing / origsel-run.sh` 363 lines ยท 24399 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 # tests/turing/origsel-run.sh: omega-mv#700 ORIGSEL host glue (POSIX sh, disclosed). 18 # Turing-profile-ORIGSEL-v1.2. It sequences only. Its jobs: 19 # - verify the compiler, every pinned unit and the profile sidecar; 20 # - build the seeded .om evaluator, its tests, the independent C recomputer and turing-coder; 21 # - run the pinned aien-train V2=1 trainer where an arm needs images; 22 # - compute SHA-256 digests and TPS1/TSY1 trailers with coreutils sha256sum (disclosed external tool); 23 # - compare bytes and exit codes. 24 # Every number and verdict comes from origsel.om. The recomputer must reproduce the report byte for byte. 25 # 26 # MODE=qualify (default): instrument qualification on outcome-independent inputs (profile 27 # verification_requirements): unit tests, SYNTHETIC fixture report and recomputation, H1 on 28 # every arm and on synthetic K=5 streams (n 50, 100, 300), leakage, the full non-access audit 29 # on the fixture, null fixture, refusal and mutant checks, and ORIGSEL_OWNER_RECORDS (the 30 # inspected v1 owner file, never D) as a dry run when set. 31 # MODE=measure RECORDS= ALLOW= IMAGES= 33 # V1=" ": the measurement of profile v1.2 (D = C3), run once. 34 # Host CPU only, nice -n 19 by the caller. No GPU, network, service or model process. 35 set -u 36 ROOT=$(cd "$(dirname "$0")/../.." && pwd) 37 MODE=${MODE:-qualify} 38 OUT=${OUT:-$ROOT/evidence/TURING-ORIGSEL/$MODE} 39 BUILD=${BUILD:-$(mktemp -d "${TMPDIR:-/tmp}/origsel.XXXXXX")} 40 OMC=${OMC:-$ROOT/seed/out/omc} 41 TRAIN=${ORIGSEL_TRAIN_GIT:-$ROOT/../aien-train} 42 BRIDGE=${ORIGSEL_BRIDGE_GIT:-$ROOT/../omega-bridge} 43 PIN=$ROOT/native/turing/origsel.pin 44 N=$ROOT/native/turing 45 PROFILE=$ROOT/calibration/profiles/Turing-profile-ORIGSEL-v1.2.toml 46 TRAINC=`351402e89b3a657cdfedc13f83e36543578329c7` 47 mkdir -p "$OUT" "$BUILD/units" "$BUILD/w" 48 SUM="$OUT/summary.txt" 49 : > "$SUM" 50 note() { echo "$*" | tee -a "$SUM"; } 51 fail() { note "ORIGSEL_RUN_FAIL $*"; exit 1; } 52 53 note "mode=$MODE" 54 note "source_commit=$(git -C "$ROOT" rev-parse HEAD)" 55 note "host=$(uname -srm)" 56 (cd "$ROOT/calibration/profiles" && sha256sum -c Turing-profile-ORIGSEL-v1.2.sha256) > /dev/null 2>&1 || fail "profile sidecar" 57 note "profile_sha256=$(sha256sum "$PROFILE" | cut -c1-64)" 58 59 # 1. Compiler and pinned units. 60 OMC_SHA=$(sha256sum "$OMC" | cut -c1-64) 61 [ "$OMC_SHA" = "$(awk '$1 == "omc" {print $2}' "$PIN")" ] || fail "compiler hash $OMC_SHA differs from the pin" 62 note "compiler_sha256=$OMC_SHA" 63 materialize() { 64 LIB="" 65 while read -r kind order repo commit path sha; do 66 [ "$kind" = unit ] || continue 67 case "$repo" in 68 omega) dir=$ROOT ;; aien-train) dir=$TRAIN ;; omega-bridge) dir=$BRIDGE ;; *) return 2 ;; 69 esac 70 f="$BUILD/units/$order-$(basename "$path")" 71 git -C "$dir" show "$commit:$path" > "$f" 2> /dev/null || return 3 72 [ "$(sha256sum "$f" | cut -c1-64)" = "$sha" ] || return 4 73 LIB="$LIB $f" 74 done < "$1" 75 [ -n "$LIB" ] || return 5 76 } 77 materialize "$PIN" || fail "pinned unit refused (rc $?)" 78 note "units_pinned=$(echo $LIB | wc -w)" 79 80 build() { 81 name=$1; shift 82 cat $LIB "$N/origsel_kappa.om" "$@" > "$BUILD/$name.om" 83 "$OMC" < "$BUILD/$name.om" > "$BUILD/$name.elf" 2> "$OUT/$name.compile.stderr" || return 1 84 chmod 700 "$BUILD/$name.elf" 85 } 86 build origsel "$N/origsel.om" "$N/origselmain.om" || fail "compile origsel" 87 build origsel-test "$N/origsel.om" "$ROOT/tests/turing/origsel-test.om" || fail "compile origsel-test" 88 E=$BUILD/origsel.elf 89 note "origsel_elf_sha256=$(sha256sum "$E" | cut -c1-64) origsel_om_sha256=$(sha256sum "$N/origsel.om" | cut -c1-64)" 90 make -s -C "$ROOT/tools/turing_origsel_indep" OMC="$OMC" origsel_indep > "$OUT/indep.build" 2>&1 || fail "build recomputer" 91 IND=$ROOT/tools/turing_origsel_indep/origsel_indep 92 note "indep_sha256=$(sha256sum "$IND" | cut -c1-64) indep_src_sha256=$(sha256sum "$ROOT/tools/turing_origsel_indep/origsel_indep.om" | cut -c1-64)" 93 TCC=$(awk '$1 == "tool" && $2 == "turing-coder" {print $3}' "$PIN") 94 mkdir -p "$BUILD/tc" && git -C "$ROOT" archive "$TCC" src | tar -x -C "$BUILD/tc" || fail "export turing-coder $TCC" 95 (cd "$BUILD/tc" && ${CC:-cc} -std=c11 -Wall -Wextra -Werror -pedantic -O2 -D_POSIX_C_SOURCE=200809L -Isrc -o turing-coder \ 96 src/turing/tc_tool.c src/turing/tc_pstream.c src/turing/tc_range.c src/turing/tc_rans.c src/turing/ty_math.c src/sha256.c \ 97 src/turing/tc_produce.c src/turing/ty_model.c src/turing/ty_ctr1.c -lm) > "$OUT/tc.build" 2>&1 || fail "build turing-coder" 98 TC=$BUILD/tc/turing-coder 99 note "turing_coder_commit=$TCC sha256=$(sha256sum "$TC" | cut -c1-64)" 100 101 # 2. Canonical P2 byte counts (REPORT-CONTRACT): functions and files without note and blank lines. 102 SELU=$BUILD/units/9-select.om; OMXU=$BUILD/units/7-omexp.om; KAP=$N/origsel_kappa.om 103 canon() { grep -v -e '^$' -e '^note' "$@" | wc -c | tr -d ' '; } 104 fnbytes() { f=$1; shift; for fn in "$@"; do awk -v n="fn $fn " 'index($0, n) == 1 {on = 1; print; next} on && (/^fn / || /^global /) {on = 0} on {print}' "$f"; done | grep -v -e '^$' -e '^note' | wc -c | tr -d ' '; } 105 P2SEL=$(canon "$SELU"); P2RULE=$(fnbytes "$OMXU" oxrule); P2STAT=$(fnbytes "$OMXU" oxstatic) 106 P2NEAR=$(fnbytes "$OMXU" oxnearok oxl1 oxnear); P2KAP=$(canon "$KAP") 107 note "p2_bytes select=$P2SEL oxrule=$P2RULE oxstatic=$P2STAT near=$P2NEAR kappa=$P2KAP" 108 PROFD=$(sha256sum "$PROFILE" | cut -c1-64) 109 110 # le64 / hexbin / stream helpers. POSIX sh has no locals: helper variables carry a _ prefix. 111 le64() { _n=$1; _i=0; while [ "$_i" -lt 8 ]; do _b=$((_n % 256)); _n=$((_n / 256)); printf "\\$(printf '%03o' "$_b")"; _i=$((_i + 1)); done; } 112 hexbin() { _h=$1; while [ -n "$_h" ]; do _b=${_h%"${_h#??}"}; _h=${_h#??}; printf "\\$(printf '%03o' "0x$_b")"; done; } 113 # stream MODE ARM V1 FLAGS REC ALLOW IMGDIR MODELHEX DATAHEX [CODERBLOCK] 114 stream() { 115 printf '%s' "$1" 116 for v in "$2" "$(wc -c < "$3")" "$P2SEL" "$P2RULE" "$P2STAT" "$P2NEAR" "$P2KAP" "$4"; do le64 "$v"; done 117 { cat "$6"; head -c 4096 /dev/zero; } | head -c 4096 118 hexbin "$PROFD"; hexbin "$8"; hexbin "$9" 119 cat "$7/v2_train_mlp.img" "$7/v2_ctrl_shuffled.img" "$7/v2_ctrl_untrained.img" "$3" 120 [ -n "${10:-}" ] && cat "${10}" 121 cat "$5" 122 } 123 Z64=`0000000000000000000000000000000000000000000000000000000000000000` 124 ARMS="U O0 FR S R M1 M2 A CSH CUN" 125 # report TAG REC ALLOW IMGDIR V1: .om report, recomputer report, byte comparison. 126 report() { 127 stream R 0 "$5" 0 "$2" "$3" "$4" $Z64 $Z64 | "$E" > "$OUT/$1.om.report" 2> "$OUT/$1.om.stderr" 128 echo $? > "$OUT/$1.om.rc" 129 "$IND" "$2" "$3" "$5" "$4/v2_train_mlp.img" "$4/v2_ctrl_shuffled.img" "$4/v2_ctrl_untrained.img" "$SELU" "$OMXU" "$KAP" \ 130 > "$OUT/$1.indep.report" 2> "$OUT/$1.indep.stderr" 131 echo $? > "$OUT/$1.indep.rc" 132 [ "$(cat "$OUT/$1.om.rc")" = 0 ] || return 1 133 cmp -s "$OUT/$1.om.report" "$OUT/$1.indep.report" || return 2 134 } 135 # streams TAG REC ALLOW IMGDIR V1: per-arm model code, TPS1, TSY1 and both coders; writes the 136 # coder block TAG.coders (10 arms x rans, range x rt, ideal_ub, coded_bits). 137 trailer() { { printf '%s\0' "$1"; cat "$2"; } | sha256sum | cut -c1-64; } 138 streams() { 139 W=$BUILD/w/$1; mkdir -p "$W"; : > "$OUT/$1.coders.txt"; : > "$W/coders.bin" 140 DATAD=$(sha256sum "$2" | cut -c1-64) 141 stream Y 0 "$5" 0 "$2" "$3" "$4" $Z64 "$DATAD" | "$E" > "$W/tsy.body" || return 1 142 { cat "$W/tsy.body"; hexbin "$(trailer turing.tc.symbols.v1 "$W/tsy.body")"; } > "$W/d.tsy" 143 ac=1 144 for a in $ARMS; do 145 stream M "$ac" "$5" 0 "$2" "$3" "$4" $Z64 $Z64 | "$E" > "$W/$a.code" || return 2 146 MD=$({ printf 'turing.origsel.arm.v1\0'; cat "$W/$a.code"; } | sha256sum | cut -c1-64) 147 stream P "$ac" "$5" 0 "$2" "$3" "$4" "$MD" "$DATAD" | "$E" > "$W/$a.body" || return 3 148 { cat "$W/$a.body"; hexbin "$(trailer turing.tc.pstream.v1 "$W/$a.body")"; } > "$W/$a.tps" 149 for c in rans range; do 150 rt=0 151 "$TC" encode "$c" "$W/$a.tps" "$W/d.tsy" "$W/$a.$c" > /dev/null 2>> "$OUT/$1.coders.stderr" \ 152 && "$TC" verify "$c" "$W/$a.tps" "$W/d.tsy" "$W/$a.$c" > "$W/$a.$c.verify" 2>> "$OUT/$1.coders.stderr" && rt=1 153 iu=$(sed -n 's/^ideal_ub=//p' "$W/$a.$c.verify" 2> /dev/null); iu=${iu:-0} 154 cb=$(sed -n 's/^coded_bits=//p' "$W/$a.$c.verify" 2> /dev/null); cb=${cb:-0} 155 echo "$a $c rt=$rt ideal_ub=$iu coded_bits=$cb model_digest=$MD" >> "$OUT/$1.coders.txt" 156 { le64 "$rt"; le64 "$iu"; le64 "$cb"; } >> "$W/coders.bin" 157 done 158 ac=$((ac + 1)) 159 done 160 stream H 0 "$5" 1 "$2" "$3" "$4" $Z64 $Z64 "$W/coders.bin" | "$E" > "$OUT/$1.h.report" || return 4 161 (cd "$W" && sha256sum -- *.tps d.tsy *.code) > "$OUT/$1.streams.sha256" 162 } 163 # retrain TAG REC ALLOW: the pinned aien-train V2=1 run (trainer and controls) on REC. 164 retrain() { 165 # The trainer's glue reads pinned objects with git show, so it needs a clone at the pin. 166 # The trainer pins its own compilers (OMC, OMC2), so a caller's OMC for this runner must not reach it; 167 # ORIGSEL_TRAIN_OMC names the trainer's compiler when it is not at the trainer's default path. 168 [ -d "$BUILD/train" ] || { git clone -q --no-hardlinks "$TRAIN" "$BUILD/train" && git -C "$BUILD/train" checkout -q "$TRAINC"; } || return 1 169 [ "$(git -C "$BUILD/train" rev-parse HEAD)" = "$TRAINC" ] || return 1 170 env -u OMC -u OMC2 ${ORIGSEL_TRAIN_OMC:+OMC="$ORIGSEL_TRAIN_OMC"} \ 171 V2=1 RECORDS="$2" ALLOW="$3" OUT="$OUT/train-$1" BUILD="$BUILD/train-$1" sh "$BUILD/train/tests/si19/run-select.sh" \ 172 > "$OUT/train-$1.log" 2>&1 || return 2 173 grep -q SI19_SELECT_V2_RUN_PASS "$OUT/train-$1.log" || return 3 174 } 175 rows() { awk '$1 == "arm" {for (i = 1; i <= NF; i++) if ($i ~ /^rows=/) print $2, $i}' "$1"; } 176 recbody() { n=$(sed -n 's/^d n=\([0-9]*\).*/\1/p' "$OUT/$1.om.report"); tail -c +129 "$BUILD/w/$1/$2.tps" | head -c $((34 * n)); } 177 # audit TAG REC ALLOW IMGDIR V1: the program-enforced non-access audit (profile blinding_mechanism 2). 178 # Returns 0 PASS; 1..9 the audit could not run or C' does not reproduce admission (BLOCKED); 179 # 11..19 a predictive artifact changed with the held-out outcomes (INVALID). 180 audit() { 181 t=$1 182 stream A 0 "$5" 0 "$2" "$3" "$4" $Z64 $Z64 | "$E" > "$BUILD/$t.cprime" || return 1 183 CF=$("$IND" --fnv "$BUILD/$t.cprime") 184 { printf 'F'; cat "$BUILD/$t.cprime"; } | "$E" > "$BUILD/$t.cprime.fnv" || return 1 185 printf '%s SYNTHETIC orig-turing-audit\n' "$CF" > "$BUILD/$t.cprime.allow" 186 retrain "$t-cprime" "$BUILD/$t.cprime" "$BUILD/$t.cprime.allow" || return 2 187 CI=$BUILD/train-$t-cprime 188 report "$t-cprime" "$BUILD/$t.cprime" "$BUILD/$t.cprime.allow" "$CI" "$5" || return 4 189 [ "$(sed -n 2,3p "$OUT/$t.om.report")" = "$(sed -n 2,3p "$OUT/$t-cprime.om.report")" ] || return 8 190 for img in v2_train_mlp v2_ctrl_shuffled v2_ctrl_untrained; do 191 { printf 'K'; cat "$4/$img.img" "$CI/$img.img" "$BUILD/$t.cprime.fnv"; } | "$E" > "$OUT/$t.audit-$img.txt" 192 grep -q '^K same$' "$OUT/$t.audit-$img.txt" || { grep -q '^K diff' "$OUT/$t.audit-$img.txt" && return 13; return 3; } 193 done 194 rows "$OUT/$t.om.report" > "$OUT/$t.rows"; rows "$OUT/$t-cprime.om.report" > "$OUT/$t-cprime.rows" 195 cmp -s "$OUT/$t.rows" "$OUT/$t-cprime.rows" || return 15 196 streams "$t-cprime" "$BUILD/$t.cprime" "$BUILD/$t.cprime.allow" "$CI" "$5" || return 6 197 for a in $ARMS; do 198 [ "$(recbody "$t" "$a" | sha256sum)" = "$(recbody "$t-cprime" "$a" | sha256sum)" ] || return 17 199 done 200 } 201 # idealbad TAG: a round-tripped stream whose turing-coder ideal_ub differs from the .om sum. 202 idealbad() { grep -q '^h1 .* rt=1 ideal=mismatch' "$OUT/$1.h.report"; } 203 204 if [ "$MODE" = qualify ]; then 205 "$BUILD/origsel-test.elf" > "$OUT/unit-test.stdout"; [ $? = 0 ] || fail "unit tests $(cat "$OUT/unit-test.stdout")" 206 note "unit_tests $(cat "$OUT/unit-test.stdout")" 207 "$IND" --selftest > "$OUT/indep-selftest.stdout" 2>&1 || fail "recomputer selftest" 208 : > "$BUILD/empty" 209 # Fixture: the pinned trainer generates the SYNTHETIC fixture (seed 4242, 400 records) and trains. 210 retrain fix "" "" || fail "trainer on fixture" 211 FIXB=$BUILD/train-fix; FREC=$FIXB/fixture.rb; FALLOW=$FIXB/allow.txt 212 report fix "$FREC" "$FALLOW" "$FIXB" "$BUILD/empty" || fail "fixture report (rc $?)" 213 note "fixture_report om=indep identical sha256=$(sha256sum "$OUT/fix.om.report" | cut -c1-64)" 214 streams fix "$FREC" "$FALLOW" "$FIXB" "$BUILD/empty" || fail "fixture streams (rc $?)" 215 idealbad fix && fail "ideal_ub mismatch between .om and turing-coder" 216 [ "$(grep -c '^h1 .* rt=1 ideal=match' "$OUT/fix.h.report")" = 20 ] || fail "fixture round trips" 217 note "fixture_h1 roundtrip=20/20 ideal_match=20/20 band_ok=$(grep -c '^h1 .*band=ok' "$OUT/fix.h.report")/20" 218 # The F mode (64-bit FNV as bytes) on a value at or above 2^63; od reads it back. 219 FB=$({ printf 'F'; cat "$FREC"; } | "$E" | od -An -tu8 | tr -d ' ') 220 [ "$FB" = "$("$IND" --fnv "$FREC")" ] || fail "F mode $FB differs from the recomputer's FNV" 221 note "fnv_bytes PASS ($FB)" 222 # Burned exclusion and D_fresh / D_v1fam: V1 = the fixture's first 100 records. 223 head -c 25600 "$FREC" > "$BUILD/v1part" 224 report fixv1 "$FREC" "$FALLOW" "$FIXB" "$BUILD/v1part" || fail "burned-path report (rc $?)" 225 note "burned_path om=indep identical $(sed -n 3p "$OUT/fixv1.om.report")" 226 # Synthetic K=5 coder streams (no record involved): n 50, 100, 300. 227 for n in 50 100 300; do 228 stream Q "$n" "$BUILD/empty" 0 "$FREC" "$FALLOW" "$FIXB" $Z64 $Z64 | "$E" > "$BUILD/q$n.body" || fail "synthetic Q $n" 229 stream W "$n" "$BUILD/empty" 0 "$FREC" "$FALLOW" "$FIXB" $Z64 $Z64 | "$E" > "$BUILD/w$n.body" || fail "synthetic W $n" 230 { cat "$BUILD/q$n.body"; hexbin "$(trailer turing.tc.pstream.v1 "$BUILD/q$n.body")"; } > "$BUILD/q$n.tps" 231 { cat "$BUILD/w$n.body"; hexbin "$(trailer turing.tc.symbols.v1 "$BUILD/w$n.body")"; } > "$BUILD/w$n.tsy" 232 for c in rans range; do 233 rt=0 234 "$TC" encode "$c" "$BUILD/q$n.tps" "$BUILD/w$n.tsy" "$BUILD/q$n.$c" > /dev/null 2>&1 \ 235 && "$TC" verify "$c" "$BUILD/q$n.tps" "$BUILD/w$n.tsy" "$BUILD/q$n.$c" > "$BUILD/q$n.$c.v" 2>&1 && rt=1 236 iu=$(sed -n 's/^ideal_ub=//p' "$BUILD/q$n.$c.v"); cb=$(sed -n 's/^coded_bits=//p' "$BUILD/q$n.$c.v") 237 res=$({ printf 'B'; for v in "$n" "${iu:-0}" "${cb:-0}" "$rt" 0 0 0 0; do le64 "$v"; done; } | "$E") 238 note "band_synthetic n=$n coder=$c rt=$rt ideal_ub=${iu:-0} coded_bits=${cb:-0}$res" 239 [ "$c" = rans ] && { echo "$res" | grep -q 'band=ok' || fail "rans band at n=$n"; } 240 done 241 done 242 # Leakage: C' records under the same images must leave every TPS1 record byte and row unchanged. 243 stream A 0 "$BUILD/empty" 0 "$FREC" "$FALLOW" "$FIXB" $Z64 $Z64 | "$E" > "$BUILD/leak.rec" || fail "leak derivative" 244 CFL=$("$IND" --fnv "$BUILD/leak.rec"); printf '%s SYNTHETIC leak\n' "$CFL" > "$BUILD/leak.allow" 245 report leak "$BUILD/leak.rec" "$BUILD/leak.allow" "$FIXB" "$BUILD/empty" || fail "leak report (rc $?)" 246 streams leak "$BUILD/leak.rec" "$BUILD/leak.allow" "$FIXB" "$BUILD/empty" || fail "leak streams" 247 rows "$OUT/fix.om.report" > "$OUT/fix.rows"; rows "$OUT/leak.om.report" > "$OUT/leak.rows" 248 cmp -s "$OUT/fix.rows" "$OUT/leak.rows" || fail "leakage: rows changed" 249 for a in $ARMS; do [ "$(recbody fix "$a" | sha256sum)" = "$(recbody leak "$a" | sha256sum)" ] || fail "leakage: TPS1 records of $a changed"; done 250 cmp -s "$BUILD/w/fix/d.tsy" "$BUILD/w/leak/d.tsy" && fail "leakage test inert: labels did not change" 251 note "leakage PASS (labels changed, 10/10 TPS1 record bodies and every row identical)" 252 # Full non-access audit on the fixture (retraining on C'). 253 audit fix "$FREC" "$FALLOW" "$FIXB" "$BUILD/empty" || fail "audit on fixture (rc $?)" 254 note "audit_fixture PASS ($(cat "$OUT"/fix.audit-*.txt | tr '\n' ' '))" 255 # Null fixture: state-independent labels everywhere; A must not beat O0. 256 stream N 0 "$BUILD/empty" 0 "$FREC" "$FALLOW" "$FIXB" $Z64 $Z64 | "$E" > "$BUILD/null.rec" || fail "null derivative" 257 CFN=$("$IND" --fnv "$BUILD/null.rec"); printf '%s SYNTHETIC null\n' "$CFN" > "$BUILD/null.allow" 258 retrain null "$BUILD/null.rec" "$BUILD/null.allow" || fail "trainer on null fixture" 259 report null "$BUILD/null.rec" "$BUILD/null.allow" "$BUILD/train-null" "$BUILD/empty" || fail "null report (rc $?)" 260 UB=$(awk '$1 == "t" && $2 == "A" && $3 == "O0" {sub("ub=", "", $6); print $6}' "$OUT/null.om.report") 261 [ "$UB" -le 0 ] || fail "null fixture: ub(A;O0) = $UB > 0" 262 note "null_fixture PASS ub(A;O0)=$UB" 263 # Refusals and mutants. 264 sed 's/^\(unit 9 .* \)[0-9a-f]\{64\}$/\1'"$Z64"'/' "$PIN" > "$BUILD/bad.pin" 265 ( materialize "$BUILD/bad.pin" ) && fail "unpinned unit accepted" 266 note "refuse_unpinned_unit PASS" 267 awk '$1 == "arm" && $2 == "M1" {sub(/p1=[0-9]+/, "p1=1")} {print}' "$OUT/fix.om.report" > "$BUILD/forged-l.report" 268 cmp -s "$BUILD/forged-l.report" "$OUT/fix.indep.report" && fail "wrong L(M|G) receipt accepted" 269 awk '$1 == "t" && $2 == "A" && $3 == "FR" {sub(/lb=-?[0-9]+/, "lb=1")} {print}' "$OUT/fix.om.report" > "$BUILD/forged-t.report" 270 cmp -s "$BUILD/forged-t.report" "$OUT/fix.indep.report" && fail "tampered receipt accepted" 271 note "refuse_wrong_model_cost PASS refuse_tampered_receipt PASS" 272 NREC=$(($(wc -c < "$FREC") / 256)) 273 { cat "$FREC"; tail -c 256 "$FREC" | head -c 112; le64 `1099511627776`; tail -c 136 "$FREC"; } > "$BUILD/dup.rec" 274 CFD=$("$IND" --fnv "$BUILD/dup.rec"); printf '%s SYNTHETIC dup\n' "$CFD" > "$BUILD/dup.allow" 275 report dup "$BUILD/dup.rec" "$BUILD/dup.allow" "$FIXB" "$BUILD/empty" || fail "duplicate report (rc $?)" 276 [ "$(sed -n 2p "$OUT/dup.om.report" | sed 's/^admit records=[0-9]* //')" = "$(sed -n 2p "$OUT/fix.om.report" | sed 's/^admit records=[0-9]* //')" ] \ 277 || fail "duplicate record admitted" 278 note "refuse_duplicate PASS (records $NREC -> $((NREC + 1)), admitted unchanged)" 279 { head -c 96 "$FREC"; le64 15; tail -c +105 "$FREC"; } > "$BUILD/unp.rec" 280 CFU=$("$IND" --fnv "$BUILD/unp.rec"); printf '%s SYNTHETIC unpaired\n' "$CFU" > "$BUILD/unp.allow" 281 report unp "$BUILD/unp.rec" "$BUILD/unp.allow" "$FIXB" "$BUILD/empty" || fail "unpaired report (rc $?)" 282 A0=$(sed -n 's/.* admitted=\([0-9]*\).*/\1/p' "$OUT/fix.om.report"); A1=$(sed -n 's/.* admitted=\([0-9]*\).*/\1/p' "$OUT/unp.om.report") 283 [ "$A1" -lt "$A0" ] || fail "unpaired record admitted" 284 note "refuse_unpaired PASS (admitted $A0 -> $A1)" 285 # Evaluator mutants: each must fail the in-process tests or make the .om report differ from 286 # the recomputer; a mutant that does not compile is a harness error, not a kill. 287 mutant() { 288 sed "$2" "$N/origsel.om" > "$BUILD/mut$1.om" 289 cmp -s "$BUILD/mut$1.om" "$N/origsel.om" && fail "mutant $1 pattern matched nothing" 290 cat $LIB "$N/origsel_kappa.om" "$BUILD/mut$1.om" "$ROOT/tests/turing/origsel-test.om" > "$BUILD/mutt$1.om" 291 "$OMC" < "$BUILD/mutt$1.om" > "$BUILD/mutt$1.elf" 2> /dev/null || fail "mutant $1 test unit does not compile" 292 chmod 700 "$BUILD/mutt$1.elf" 293 "$BUILD/mutt$1.elf" > /dev/null 2>&1 || { note "mutant $1 killed by unit tests"; return 0; } 294 cat $LIB "$N/origsel_kappa.om" "$BUILD/mut$1.om" "$N/origselmain.om" > "$BUILD/mutu$1.om" 295 "$OMC" < "$BUILD/mutu$1.om" > "$BUILD/mut$1.elf" 2> /dev/null || fail "mutant $1 does not compile" 296 chmod 700 "$BUILD/mut$1.elf" 297 stream R 0 "$BUILD/empty" 0 "$3" "$4" "$FIXB" $Z64 $Z64 | "$BUILD/mut$1.elf" > "$BUILD/mut$1.report" 2> /dev/null 298 cmp -s "$BUILD/mut$1.report" "$OUT/$5.indep.report" && return 1 299 note "mutant $1 killed by recomputation" 300 return 0 301 } 302 mutant 1 's/^if lt get k a get k b$/if le get k a get k b/' "$FREC" "$FALLOW" fix || fail "mutant 1 (tie rule) survived" 303 mutant 2 's/^put TQS i sub sub va vb d$/put TQS i sub va vb/' "$FREC" "$FALLOW" fix || fail "mutant 2 (model cost) survived" 304 mutant 3 's/^put TQT 91 get TQS 166$/put TQT 91 get TQS 499/' "$FREC" "$FALLOW" fix || fail "mutant 3 (bound rank) survived" 305 mutant 4 's/^if ne get TQB c 0$/if eq get TQB c 0/' "$FREC" "$FALLOW" fix || fail "mutant 4 (blocks) survived" 306 mutant 5 '/^fn tqmlp /,/^fn tqctx /s/^ret tqord5 k$/ret tqqord r/' "$FREC" "$FALLOW" fix || fail "mutant 5 (leaky MLP order) survived" 307 mutant 6 's/^tqgam add n 1$/tqgam add n 2/' "$FREC" "$FALLOW" fix || fail "mutant 6 (row code length) survived" 308 note "evaluator_mutants 6/6 killed" 309 if [ -n "${ORIGSEL_OWNER_RECORDS:-}" ]; then 310 retrain own "$ORIGSEL_OWNER_RECORDS" "$BUILD/train/docs/si19/orig1-datasets.txt" || fail "trainer on owner file" 311 report own "$ORIGSEL_OWNER_RECORDS" "$BUILD/train/docs/si19/orig1-datasets.txt" "$BUILD/train-own" "$BUILD/empty" || fail "owner dry run (rc $?)" 312 note "owner_dry_run om=indep identical (inspected v1 file, development only, never D) $(grep '^experiment' "$OUT/own.om.report")" 313 rm -rf "$OUT/train-own" 314 fi 315 (cd "$OUT" && sha256sum -- *.report *.txt *.rc 2> /dev/null) > "$OUT/raw.sha256" 316 note "ORIGSEL_QUALIFY_PASS" 317 exit 0 318 fi 319 320 if [ "$MODE" = measure ]; then 321 blocked() { note "ORIGSEL_VERDICT BLOCKED ($*)"; exit 3; } 322 invalid() { note "ORIGSEL_VERDICT INVALID ($*)"; exit 2; } 323 [ -f "${RECORDS:-}" ] && [ -f "${ALLOW:-}" ] || blocked "RECORDS and ALLOW required" 324 # E's qualification receipts must be PASS for exactly this evaluator and recomputer. 325 QS=$ROOT/evidence/TURING-ORIGSEL/qualify/summary.txt 326 [ "$(tail -n 1 "$QS" 2> /dev/null)" = ORIGSEL_QUALIFY_PASS ] || blocked "qualification receipt not PASS" 327 grep -q "origsel_om_sha256=$(sha256sum "$N/origsel.om" | cut -c1-64)" "$QS" || blocked "evaluator differs from the qualified one" 328 grep -q "indep_src_sha256=$(sha256sum "$ROOT/tools/turing_origsel_indep/origsel_indep.om" | cut -c1-64)" "$QS" || blocked "recomputer differs from the qualified one" 329 grep -q "origsel_elf_sha256=$(sha256sum "$E" | cut -c1-64)" "$QS" || blocked "evaluator binary differs from the qualified one" 330 # V1 = exactly the two pinned v1 files, in order (profile burned_exclusion). 331 set -- ${V1:-} 332 [ "$#" = 2 ] || blocked "V1 must name the v1 owner file and the v1 sealed file" 333 [ "$("$IND" --fnv "$1")" = `16622604375676129865` ] || blocked "V1 owner file fnv" 334 [ "$("$IND" --fnv "$2")" = `12602815733741495377` ] || blocked "V1 sealed file fnv" 335 cat "$1" "$2" > "$BUILD/v1.bin" || blocked "V1 read" 336 if [ -z "${IMAGES:-}" ]; then 337 retrain d "$RECORDS" "$ALLOW" || blocked "pinned V2=1 trainer on RECORDS" 338 IMAGES=$BUILD/train-d 339 note "images: pinned V2=1 run by this glue (aien-train $TRAINC)" 340 fi 341 note "records_sha256=$(sha256sum "$RECORDS" | cut -c1-64) records_fnv=$("$IND" --fnv "$RECORDS")" 342 for img in v2_train_mlp v2_ctrl_shuffled v2_ctrl_untrained; do note "image $img sha256=$(sha256sum "$IMAGES/$img.img" | cut -c1-64)"; done 343 note "v1_sha256=$(sha256sum "$BUILD/v1.bin" | cut -c1-64)" 344 report d "$RECORDS" "$ALLOW" "$IMAGES" "$BUILD/v1.bin" 345 rc=$? 346 [ "$rc" = 2 ] && invalid "the independent recomputation disagrees with the evaluator" 347 [ "$rc" = 0 ] || blocked "evaluator refusal or instrument failure, rc $(cat "$OUT/d.om.rc"): $(head -c 200 "$OUT/d.om.report")" 348 note "report om=indep identical sha256=$(sha256sum "$OUT/d.om.report" | cut -c1-64)" 349 streams d "$RECORDS" "$ALLOW" "$IMAGES" "$BUILD/v1.bin" || blocked "stream writer failure (rc $?)" 350 idealbad d && invalid "turing-coder ideal_ub differs from the evaluator on a round-tripped stream" 351 note "h1 $(grep -c '^h1 .*rt=1 ideal=match.*band=ok' "$OUT/d.h.report")/20 arm x coder round trip + ideal + band" 352 audit d "$RECORDS" "$ALLOW" "$IMAGES" "$BUILD/v1.bin" 353 rc=$? 354 [ "$rc" -ge 11 ] && invalid "non-access audit failed (rc $rc)" 355 [ "$rc" = 0 ] || blocked "non-access audit could not run or C' admission differs (rc $rc)" 356 note "non_access_audit PASS" 357 rm -rf "$OUT/train-d-cprime" 358 (cd "$OUT" && sha256sum -- *.report *.txt *.rc 2> /dev/null) > "$OUT/raw.sha256" 359 note "$(grep '^experiment' "$OUT/d.om.report")" 360 note "ORIGSEL_VERDICT $(sed -n 's/^experiment //p' "$OUT/d.om.report")" 361 exit 0 362 fi 363 fail "unknown MODE $MODE"