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
omega-mv / tools / estimation / test_est6dev.sh
| 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 for est6dev and est6opchar (pre-freeze development tools). Reads only the committed v5 D1 |
| 18 | # development folder; every held-out path must be refused before any file is opened. |
| 19 | # usage: test_est6dev.sh <est6dev> <est6opchar> |
| 20 | set -eu |
| 21 | E=${1:?est6dev binary} |
| 22 | O=${2:?est6opchar binary} |
| 23 | D1=evidence/EST5/raw/20261001T153156Z-est5-fit-silicon |
| 24 | fail=0 |
| 25 | n=0 |
| 26 | chk() { n=$((n+1)); if [ "$1" = ok ]; then :; else echo "FAIL $2"; fail=1; fi; } |
| 27 | |
| 28 | # 1. held-out refusals (path tags and the v5 D2 date tag), exit status 2, nothing opened |
| 29 | for p in evidence/EST5/raw/20261005T112838Z-est5-heldout-silicon evidence/X/raw/zz-est6-heldout-silicon evidence/EST3C/raw/zz-est3c-heldout-q; do |
| 30 | rc=0 |
| 31 | "$E" g1pit --raw "$p/machine-state.ndjson" --marks "$p/machine-state-marks.txt" --dyn 1 --q 10000 --lam 0.1 --nu 1.25 --c 0.7 >/dev/null 2>&1 || rc=$? |
| 32 | [ "$rc" = 2 ] && chk ok x || chk bad "g1pit did not refuse held-out path $p (rc $rc)" |
| 33 | rc=0 |
| 34 | "$E" g1s --raw "$p/machine-state.ndjson" --marks "$p/machine-state-marks.txt" --dyn 1 --q 10000 --lam 0.1 --nu 1.25 >/dev/null 2>&1 || rc=$? |
| 35 | [ "$rc" = 2 ] && chk ok x || chk bad "g1s did not refuse held-out path $p (rc $rc)" |
| 36 | done |
| 37 | |
| 38 | # 1b. the D2 SHA backstops equal the committed d2.sha256 (hash list only; no D2 file is opened) |
| 39 | D2S=docs/estimation/receipts/est-v5/d2.sha256 |
| 40 | for pair in "D2_RAW_SHA machine-state.ndjson" "D2_MARKS_SHA machine-state-marks.txt"; do |
| 41 | set -- $pair |
| 42 | want=$(awk -v n="$2" '$2 == n { print $1 }' "$D2S") |
| 43 | got=$(sed -n "s/^#define $1 \"\([0-9a-f]*\)\"$/\1/p" tools/estimation/est6dev.c) |
| 44 | [ -n "$want" ] && [ "$want" = "$got" ] && chk ok x || chk bad "$1 in est6dev.c ($got) != d2.sha256 $2 ($want)" |
| 45 | done |
| 46 | |
| 47 | # 2. schedule generator reproduces the v5 protocol text (seed 0xE5C5D1: idle 406, L6 929, L12 655, L18 710) |
| 48 | "$E" sched 0xE5C5D1 2700 | grep -q '^segments 39 idle 406 L6 929 L12 655 L18 710$' && chk ok x || chk bad "schedule totals for 0xE5C5D1" |
| 49 | "$E" sched 0xE5C5D1 2700 | grep -q '^schedule 0 0 74$' && chk ok x || chk bad "schedule first segment 0xE5C5D1" |
| 50 | # ... and the recorded schedule.txt of the v5 D1 folder (seed 0xE5C5D2) line for line |
| 51 | "$E" sched 0xE5C5D2 2700 | grep '^schedule' | cut -d' ' -f2- > "${TMPDIR:-/tmp}/e6dev.sched.$$" |
| 52 | grep '^schedule' $D1/schedule.txt | cut -d' ' -f2- | cmp -s - "${TMPDIR:-/tmp}/e6dev.sched.$$" && chk ok x || chk bad "schedule 0xE5C5D2 vs D1 schedule.txt" |
| 53 | rm -f "${TMPDIR:-/tmp}/e6dev.sched.$$" |
| 54 | # balance rule: 0xE5C5D1 fails (L6 929 > 900), pick moves +1 until it passes |
| 55 | "$E" sched 0xE5C5D1 2700 | grep -q '^balance FAIL$' && chk ok x || chk bad "balance FAIL expected" |
| 56 | "$E" pick 0xE6C6D1 2700 | grep -q '^picked 0xe6c6d3 after 2 failures$' && chk ok x || chk bad "pick 0xE6C6D1" |
| 57 | |
| 58 | |
| 59 | # 2b. schedule rule SR-1 (domain separated by run label) against the old chained rule |
| 60 | PLAN="2700 F=0xE6C6D1 H1=0xD6E6C7 H2=0xD6E6C8" |
| 61 | T6=${TMPDIR:-/tmp}/e6dev.plan.$$ |
| 62 | # RED: the old rule (seed + 1 chain) sends H1 and H2 to the same seed and schedule; the plan tool refuses it |
| 63 | rc=0; "$E" plan6 --rule old $PLAN > $T6.old || rc=$? |
| 64 | [ "$rc" = 1 ] && grep -q '^COLLISION H1 H2 effective 0xd6e6cb$' $T6.old && chk ok x || chk bad "old rule must reproduce the H1/H2 collision at 0xd6e6cb (rc $rc)" |
| 65 | grep '^label H1 ' $T6.old | grep -q 'segments 41 idle 522 L6 572 L12 857 L18 749' && chk ok x || chk bad "old rule H1 schedule totals" |
| 66 | # GREEN: SR-1 gives distinct effective seeds and distinct schedules |
| 67 | rc=0; "$E" plan6 $PLAN > $T6.a || rc=$? |
| 68 | [ "$rc" = 0 ] && grep -q '^distinct PASS$' $T6.a && chk ok x || chk bad "SR-1 plan not distinct (rc $rc)" |
| 69 | h1=$(grep '^schedule H1 ' $T6.a | cut -d' ' -f3-); h2=$(grep '^schedule H2 ' $T6.a | cut -d' ' -f3-) |
| 70 | [ -n "$h1" ] && [ -n "$h2" ] && [ "$h1" != "$h2" ] && chk ok x || chk bad "SR-1 H1 and H2 schedules equal" |
| 71 | e1=$(grep '^label H1 ' $T6.a | cut -d' ' -f6); e2=$(grep '^label H2 ' $T6.a | cut -d' ' -f6) |
| 72 | [ "$e1" != "$e2" ] && chk ok x || chk bad "SR-1 H1 and H2 effective seeds equal" |
| 73 | # determinism: same input, same output, and a label's schedule does not depend on the other labels in the plan |
| 74 | "$E" plan6 $PLAN > $T6.b; cmp -s $T6.a $T6.b && chk ok x || chk bad "SR-1 plan not deterministic" |
| 75 | "$E" plan6 2700 H2=0xD6E6C8 | grep '^schedule H2 ' > $T6.c |
| 76 | grep '^schedule H2 ' $T6.a | cmp -s - $T6.c && chk ok x || chk bad "SR-1 H2 schedule depends on the other labels in the plan" |
| 77 | "$E" plan6 2700 A=0xD6E6C7 B=0xD6E6C7 | grep -q '^distinct PASS$' && chk ok x || chk bad "domain separation: same declared seed, two labels" |
| 78 | # balance and structure properties hold for every label (totals sum to 2700, each level 400..900, segments 20..120 but a clipped last) |
| 79 | for L in F H1 H2; do |
| 80 | grep "^label $L " $T6.a | grep -q 'balance PASS' && chk ok x || chk bad "balance $L" |
| 81 | grep "^schedule $L " $T6.a | awk '{ d[NR]=$5; lv[$4]+=$5; s+=$5 } END { ok=(s==2700); for (i=1;i<=NR;i++) { if (d[i]>120 || d[i]<1) ok=0; if (d[i]<20 && i<NR) ok=0 } for (k in lv) if (lv[k]<400 || lv[k]>900) ok=0; exit ok?0:1 }' && chk ok x || chk bad "structure $L (sum 2700, levels 400..900, segments 20..120, last may be clipped)" |
| 82 | done |
| 83 | rm -f $T6.old $T6.a $T6.b $T6.c |
| 84 | |
| 85 | # 3. G1 on v5 D1 with the v5 parameters reproduces params.txt (n 2652, bin0 0.075981, cov95 0.952950, mean z 0.046045) |
| 86 | out=$("$E" g1pit --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --dyn 1 --q 10000 --lam 0.1 --nu 1.25 --c 0.7 --boot 200) |
| 87 | echo "$out" | grep -q '^n_scored 2652 unscorable 0$' && chk ok x || chk bad "n_scored" |
| 88 | echo "$out" | grep -q '^stat pit_bin0 0.075981 ' && chk ok x || chk bad "pit_bin0 vs params.txt" |
| 89 | echo "$out" | grep -q '^stat coverage95 0.952950 ' && chk ok x || chk bad "coverage95 vs params.txt" |
| 90 | echo "$out" | grep -q '^mean_z_midpit 0.046045$' && chk ok x || chk bad "mean z vs params.txt" |
| 91 | # deterministic bootstrap |
| 92 | out2=$("$E" g1pit --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --dyn 1 --q 10000 --lam 0.1 --nu 1.25 --c 0.7 --boot 200) |
| 93 | [ "$out" = "$out2" ] && chk ok x || chk bad "bootstrap not deterministic" |
| 94 | |
| 95 | # 4. G1S at kappa 1.0 reproduces the G1 in-sample log score (-1.962811) |
| 96 | "$E" g1s --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --dyn 1 --q 10000 --lam 0.1 --nu 1.25 | grep -q '^insample kappa 1.0 best_c 0.70 mean_logscore -1.962811 ' && chk ok x || chk bad "g1s kappa 1.0 log score" |
| 97 | |
| 98 | # 5. simulation tool self test |
| 99 | "$O" selftest | grep -q 'selftest: PASS' && chk ok x || chk bad "est6opchar selftest" |
| 100 | a=$("$O" run --case a --reps 50 --boot 300) ; b=$("$O" run --case a --reps 50 --boot 300) |
| 101 | [ "$a" = "$b" ] && chk ok x || chk bad "est6opchar not deterministic" |
| 102 | |
| 103 | |
| 104 | # 4b. full G1S: two-piece predictive self check, held-out refusals, determinism, label, control is kappa 1.0 |
| 105 | "$E" twopiece-selfcheck | grep -q '^twopiece-selfcheck: PASS$' && chk ok x || chk bad "two-piece self check" |
| 106 | for p in evidence/EST5/raw/20261005T112838Z-est5-heldout-silicon evidence/X/raw/zz-est6-heldout-silicon; do |
| 107 | rc=0 |
| 108 | "$E" g1sfull --raw "$p/machine-state.ndjson" --marks "$p/machine-state-marks.txt" >/dev/null 2>&1 || rc=$? |
| 109 | [ "$rc" = 2 ] && chk ok x || chk bad "g1sfull did not refuse held-out path $p (rc $rc)" |
| 110 | done |
| 111 | G1=${TMPDIR:-/tmp}/e6dev.g1sfull.$$ |
| 112 | "$E" g1sfull --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --grid-stride 6 --boot 200 > $G1.a |
| 113 | "$E" g1sfull --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --grid-stride 6 --boot 200 > $G1.b |
| 114 | cmp -s $G1.a $G1.b && chk ok x || chk bad "g1sfull not deterministic" |
| 115 | grep -q '^label DEVELOPMENT RESULT' $G1.a && chk ok x || chk bad "g1sfull development label" |
| 116 | grep -q '^grid .* steps 2652 folds 5$' $G1.a && chk ok x || chk bad "g1sfull step count 2652 (same steps as g1pit)" |
| 117 | grep -q '^final control .* kappa 1.0 ' $G1.a && chk ok x || chk bad "g1sfull control kappa" |
| 118 | rm -f $G1.a $G1.b |
| 119 | |
| 120 | # 5b. opchar case d (regime-dependent PIT) deterministic |
| 121 | a=$("$O" run --case d --reps 50 --boot 300) ; b=$("$O" run --case d --reps 50 --boot 300) |
| 122 | [ "$a" = "$b" ] && chk ok x || chk bad "est6opchar case d not deterministic" |
| 123 | |
| 124 | if [ "$fail" = 0 ]; then echo "test-est6dev: PASS ($n checks)"; else exit 1; fi |