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/tools/gen/protocol/test_gen_protocol.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 / tools / gen / protocol / test_gen_protocol.sh` 440 lines ยท 40442 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # tools/gen/protocol/test_gen_protocol.sh -- tests of the GEN protocol tools (aien-spark/omega#476). 3 # CPU only; reads only public files of this repository; writes only under and a mktemp dir. 4 # 1. genstats: selftest (Newcombe 1998 Table III, McNemar, Wilson), byte-identical regeneration of 5 # tests/one_layer/generalization/stats_vectors.tsv, length-match classes; genjac known answers 6 # 2. famsig: known answers (canonical forms, the reserved dev family tokens), RULE PASS on the dev META, 7 # coarse forms, mutants (bad shapes and files, R2..R8 violations) that must each be refused, and 8 # famsig compare (blind re-declaration) 9 # 3. gencheck: PASS on the real protocol.json, then mutants of the manifest (unknown, duplicate, missing 10 # keys, missing or changed splits, duplicate task ids, digest drift, changed constants, bad types) and 11 # of the tree (shared signature across splits, extra case directory) that must each be refused; then 12 # the reviewer's split check on a SYNTHETIC held-out split (generated here, test-only, not a task) and 13 # its mutants (including fail-closed on null digests); run-ready and open on a fully frozen SYNTHETIC 14 # manifest (interface files taken from git at their pinned commits) and their mutants 15 # 4. dev pack: pack_dev.sh twice (byte-identical, sha256 = splits.dev.pack_sha256) and a negative control 16 # (one wrong hidden/expected line must refuse) 17 # GEN_TASKS_CHECK=1 also runs ola.sh tasks-check on the dev pack inside a private git worktree of HEAD (under the 18 # test temp dir, removed afterwards), so the shared evidence/ONE-LAYER-2 tree is never written or deleted. 19 # GENP_OMC= also builds the pure OM-2 ports (_om) and runs each invocation through both builds: any 20 # difference from the C build of record in stdout, stderr or exit status fails the suite (OM parity). 21 set -uo pipefail 22 ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" 23 B="${1:?usage: test_gen_protocol.sh }" 24 mkdir -p "$B"; B="$(realpath -e "$B")" 25 T="$(mktemp -d "${TMPDIR:-/tmp}/gen-proto-test.XXXXXXXX")"; trap 'rm -rf "$T"' EXIT 26 CFLAGS="-std=gnu11 -Wall -Wextra -Werror -O2" 27 G="$ROOT/tests/one_layer/generalization" 28 P="$G/protocol.json" 29 ok=0; bad=0 30 pass() { ok=$((ok + 1)); echo "ok $1"; } 31 fail() { bad=$((bad + 1)); echo "FAIL $1"; } 32 expect_out() { # name expected command... 33 local n="$1" e="$2"; shift 2 34 local got; got="$("$@" 2>/dev/null)" 35 if [ "$got" = "$e" ]; then pass "$n"; else fail "$n (got '$got')"; fi 36 } 37 refuse() { # name command... : must exit non-zero 38 local n="$1"; shift 39 if "$@" >/dev/null 2>&1; then fail "mutant not caught: $n"; else pass "refused: $n"; fi 40 } 41 refuse_why() { # name expected-output-substring command... : must exit non-zero and say why 42 local n="$1" w="$2"; shift 2 43 if "$@" > "$T/rw.out" 2>&1; then fail "mutant not caught: $n"; elif grep -qF -- "$w" "$T/rw.out"; then pass "refused: $n"; else fail "refused for another reason: $n ($(tail -2 "$T/rw.out" | tr "\n" " "))"; fi 44 } 45 46 ${CC:-cc} $CFLAGS -I"$ROOT/src" -o "$B/famsig" "$ROOT/tools/gen/protocol/famsig.c" "$ROOT/src/omega_om_units.c" || exit 1 47 ${CC:-cc} $CFLAGS -I"$ROOT/src" -o "$B/gencheck" "$ROOT/tools/gen/protocol/gencheck.c" "$ROOT/src/omega_om_units.c" || exit 1 48 ${CC:-cc} $CFLAGS -o "$B/genstats" "$ROOT/tools/gen/protocol/genstats.c" -lm || exit 1 49 ${CC:-cc} $CFLAGS -o "$B/genjac" "$ROOT/tools/gen/protocol/genjac.c" || exit 1 50 FS="$B/famsig"; GC="$B/gencheck"; GS="$B/genstats"; JC="$B/genjac" 51 # OM parity (when GENP_OMC names the seeded omc): the pure OM-2 ports are built as _om and run beside the 52 # C build of record on every invocation below; any difference in stdout, stderr or exit status fails the suite. 53 # The C stays the build of record while protocol.json pins the C sources. 54 if [ -n "${GENP_OMC:-}" ]; then 55 om_build() { # output unit.om...: one OM-2 unit (a single om2 header) compiled by GENP_OMC 56 local o="$1"; shift 57 (printf 'om2\n'; sed '/^om2$/d' "$@") | "$GENP_OMC" > "$o.tmp" && chmod +x "$o.tmp" && mv "$o.tmp" "$o" 58 } 59 GP="$ROOT/tools/gen/protocol" 60 om_build "$B/famsig_om" "$ROOT/seed/ng/sha256.om" "$GP/famsig_lib.om" "$GP/famsig.om" || exit 1 61 om_build "$B/gencheck_om" "$ROOT/seed/ng/sha256.om" "$GP/famsig_lib.om" "$GP/gencheck.om" || exit 1 62 om_build "$B/genstats_om" "$GP/genstats.om" || exit 1 63 om_build "$B/genjac_om" "$GP/genjac.om" || exit 1 64 mkdir -p "$T/par"; : > "$T/par.count"; : > "$T/par.diff" 65 for t in famsig gencheck genstats genjac; do 66 cat > "$T/par/$t" < "\$w/c.out" 2> "\$w/c.err"; crc=\$? 70 "$B/${t}_om" "\$@" > "\$w/o.out" 2> "\$w/o.err"; orc=\$? 71 echo . >> "$T/par.count" 72 if [ \$crc != \$orc ] || ! cmp -s "\$w/c.out" "\$w/o.out" || ! cmp -s "\$w/c.err" "\$w/o.err"; then 73 echo "$t \$* (c exit \$crc, om exit \$orc)" >> "$T/par.diff" 74 fi 75 cat "\$w/c.out"; cat "\$w/c.err" >&2; rm -rf "\$w"; exit \$crc 76 EOF 77 chmod +x "$T/par/$t" 78 done 79 FS="$T/par/famsig"; GC="$T/par/gencheck"; GS="$T/par/genstats"; JC="$T/par/genjac" 80 fi 81 82 # ---- 1. statistics ---- 83 if "$GS" selftest | tail -1 | grep -q '^SELFTEST PASS'; then pass "genstats selftest"; else fail "genstats selftest"; fi 84 if "$GS" vectors | cmp -s - "$G/stats_vectors.tsv"; then pass "stats_vectors.tsv regenerates byte-identical"; else fail "stats_vectors.tsv regenerates byte-identical"; fi 85 z59=$(printf '%059d' 0); o59=$(printf '1%.0s' $(seq 59)); z60="0$z59"; o60="1$o59"; z61="0$z60" 86 refuse_why "genstats verdict with n = 59" "n = 60 only" "$GS" verdict 1 "$o59" "$z59" "$z59" "$o59" 87 refuse_why "genstats verdict with n = 61" "n = 60 only" "$GS" verdict 1 "${o60}1" "$z61" "$z61" "${o60}1" 88 if "$GS" verdict 1 "$o60" "$z60" "$z60" "$o60" >/dev/null 2>&1; then pass "genstats verdict with n = 60 runs"; else fail "genstats verdict with n = 60"; fi 89 # p just under 0.05: 13 D-only vs 5 control-only tasks, exact one-sided p = 12616/262144 = 0.0481 (pass at 0.05) 90 d13="`1111111111111`$z59"; d13="${d13:0:60}"; x5="`0000000000000111110`$z59"; x5="${x5:0:60}" 91 pr=$'0\t13\t5\t42\t12616\t262144\t0.`0481262207`\tyes\tyes' 92 expect_out "genstats verdict p = 0.0481 just under 0.05: PASS" "$(printf '5\t5\t5\t13\t%s\t%s\t%s\t-0.`0060060942`\t0.`2686372479`\t0.`0173465500`\t0.`2466232525`\t0\tPASS\tall_controls_lift_and_p' "$pr" "$pr" "$pr")" "$GS" verdict 1 "$x5" "$x5" "$x5" "$d13" 93 94 expect_out "lenmatch reviewer fixture 295 vs 945: unmatched" "task 1 target_bytes=295 suffix_bytes=945 length_gap=650 tolerance_bytes=256.00 class=unmatched" sh -c "\"$GS\" lenmatch 295:945 | head -1" 95 expect_out "lenmatch 256 B boundary: matched" "tasks=2 matched=1 unmatched=1 status=AVAILABLE" sh -c "\"$GS\" lenmatch 300:556 300:557 | tail -1" 96 expect_out "lenmatch 15% boundary, C shorter: matched" "tasks=2 matched=1 unmatched=1 status=AVAILABLE" sh -c "\"$GS\" lenmatch 2000:1700 2000:1699 | tail -1" 97 expect_out "lenmatch 4 of 10 matched: UNAVAILABLE" "tasks=10 matched=4 unmatched=6 status=UNAVAILABLE" sh -c "\"$GS\" lenmatch 300:300 300:301 300:302 300:303 300:945 300:946 300:947 300:948 300:949 300:950 | tail -1" 98 expect_out "lenmatch 5 of 10 matched: AVAILABLE" "tasks=10 matched=5 unmatched=5 status=AVAILABLE" sh -c "\"$GS\" lenmatch 300:300 300:301 300:302 300:303 300:304 300:946 300:947 300:948 300:949 300:950 | tail -1" 99 if grep -q $'^lenset\ts03\t10\t4\t6\tUNAVAILABLE$' "$G/stats_vectors.tsv" && grep -q $'^lenmatch\tl03\t300\t556\t256\t256.00\tmatched$' "$G/stats_vectors.tsv"; then pass "stats_vectors.tsv carries lenmatch and lenset records"; else fail "stats_vectors.tsv lenmatch/lenset records"; fi 100 refuse "lenmatch bad pair" "$GS" lenmatch 300-556 101 # genjac: word 3-gram Jaccard 102 printf 'a b c d\n' > "$T/j1"; printf 'a b c e\n' > "$T/j2"; printf 'A, b; c d e\n' > "$T/j3"; printf 'a b c d f\n' > "$T/j4"; printf 'x y\n' > "$T/j5" 103 expect_out "genjac pair 1/3" "grams_a=2 grams_b=2 inter=1 union=3 jaccard=0.333333" "$JC" pair "$T/j1" "$T/j2" 104 printf 'a b c d e\n' > "$T/j6" 105 expect_out "genjac pair 2/3 rounds half up to 0.666667" "grams_a=2 grams_b=3 inter=2 union=3 jaccard=0.666667" "$JC" pair "$T/j1" "$T/j6" 106 expect_out "genjac pair 0.5 exact, case and punctuation folded" "grams_a=3 grams_b=3 inter=2 union=4 jaccard=0.500000" "$JC" pair "$T/j3" "$T/j4" 107 expect_out "genjac pair identical" "grams_a=2 grams_b=2 inter=2 union=2 jaccard=1.000000" "$JC" pair "$T/j1" "$T/j1" 108 expect_out "genjac pair under 3 words" "grams_a=0 grams_b=2 inter=0 union=2 jaccard=0.000000" "$JC" pair "$T/j5" "$T/j1" 109 printf '%s\n' "$T/j3" > "$T/hl"; printf '%s\n' "$T/j4" "$T/j5" > "$T/cl" 110 expect_out "genjac scan: 0.5 is not above 0.5" "heldout=1 corpus=2 threshold=0.5 max_jaccard=0.500000 above=0" "$JC" scan "$T/hl" "$T/cl" 111 if "$JC" scan --threshold 0.49 "$T/hl" "$T/cl" > "$T/jc.out"; then fail "genjac scan above threshold must exit 1"; elif grep -qx 'heldout=1 corpus=2 threshold=0.49 max_jaccard=0.500000 above=1' "$T/jc.out" && ! grep -q "$T/j3" "$T/jc.out"; then pass "genjac scan above=1 exits 1 and names no file without --show"; else fail "genjac scan above=1 output ($(cat "$T/jc.out"))"; fi 112 expect_out "genjac scan --show names the pair" "above $T/j3 $T/j4 0.500000" sh -c "\"$JC\" scan --threshold 0.49 --show \"$T/hl\" \"$T/cl\" | head -1" 113 "$JC" scan --threshold 1.5 "$T/hl" "$T/cl" >/dev/null 2>&1; [ $? = 2 ] && pass "genjac refuses threshold > 1 (exit 2)" || fail "genjac threshold > 1" 114 "$JC" scan --threshold 0.`1234567` "$T/hl" "$T/cl" >/dev/null 2>&1; [ $? = 2 ] && pass "genjac refuses 7 fraction digits (exit 2)" || fail "genjac 7 fraction digits" 115 printf '%s\n\n' "$T/j3" > "$T/hlb"; "$JC" scan "$T/hlb" "$T/cl" >/dev/null 2>&1; [ $? = 2 ] && pass "genjac refuses a blank list line (exit 2)" || fail "genjac blank list line" 116 # ---- 2. famsig ---- 117 expect_out "canon flattens seq and sorts" "gs1:seq(array,loop(array,branch(arith)))" "$FS" canon 'seq(loop(branch(arith),array),array)' 118 expect_out "canon loop(seq(a,b)) = loop(a,b)" "gs1:loop(arith,array)" "$FS" canon 'loop(seq(array,arith))' 119 expect_out "nesting order matters" "gs1:branch(loop(arith))" "$FS" canon 'branch(loop(arith))' 120 expect_out "token devgen01 family" "gs1-`bd9c105e5ae45397`" "$FS" token 'loop(call(nested))' 121 expect_out "token devgen04 family" "gs1-`e05d1c5dffd08b06`" "$FS" token 'branch(loop(arith),nested)' 122 expect_out "token devgen09 family" "gs1-`f63e09ec03a454ee`" "$FS" token 'loop(loop(branch(arith)))' 123 expect_out "token devgen07 family" "gs1-`30938c5c7504ef0e`" "$FS" token 'seq(array,loop(array,branch(arith)))' 124 if "$FS" rule "$G/dev/META" >/dev/null 2>&1; then pass "famsig rule dev/META: RULE PASS"; else fail "famsig rule dev/META"; fi 125 126 refuse "shape unknown primitive" "$FS" canon 'loop(sort)' 127 refuse "shape leaf with children" "$FS" canon 'arith(loop)' 128 refuse "shape container without child" "$FS" canon 'loop()' 129 refuse "shape seq with one child" "$FS" canon 'seq(arith)' 130 refuse "shape with a space" "$FS" canon 'loop(arith, array)' 131 refuse "shape deeper than 8" "$FS" canon 'loop(loop(loop(loop(loop(loop(loop(loop(loop(arith)))))))))' 132 refuse_why "shape depth boundary: 8 nested loops" "nesting deeper than 8" "$FS" canon 'loop(loop(loop(loop(loop(loop(loop(loop(arith))))))))' 133 expect_out "shape depth boundary: 7 nested loops accepted" "gs1:loop(loop(loop(loop(loop(loop(loop(arith)))))))" "$FS" canon 'loop(loop(loop(loop(loop(loop(loop(arith)))))))' 134 m() { printf '%s\n' "$@" > "$T/m.txt"; echo "$T/m.txt"; } 135 refuse "meta count mismatch (R1)" "$FS" meta "$(m 'gen-meta 1' 'c1 corpus 2 0 1 0 0 0 loop(arith)')" 136 refuse "meta heldout line in a public file" "$FS" meta "$(m 'gen-meta 1' 'h1 heldout 1 1 0 0 0 0 branch(arith)')" 137 refuse "meta bad task id" "$FS" meta "$(m 'gen-meta 1' 'C1 corpus 1 0 1 0 0 0 loop(arith)')" 138 refuse "meta leading zero count" "$FS" meta "$(m 'gen-meta 1' 'c1 corpus 01 0 1 0 0 0 loop(arith)')" 139 refuse "meta double space" "$FS" meta "$(m 'gen-meta 1' 'c1 corpus 1 0 1 0 0 0 loop(arith)')" 140 printf 'gen-meta 1\nc1 corpus 1 0 1 0 0 0 loop(arith)' > "$T/nonl"; refuse "meta no final newline" "$FS" meta "$T/nonl" 141 printf 'gen-meta 1\nc1 corpus 1 0 1 0 0 0 loop(arith)\n# caf\xc3\xa9\n' > "$T/nonascii"; refuse "meta non-ASCII byte" "$FS" meta "$T/nonascii" 142 SALT=`0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef` 143 refuse "split ids not ascending" "$FS" split "$(m 'gen-split 1' "salt $SALT" 'h2 heldout 1 1 0 0 0 0 branch(arith)' 'h1 heldout 1 1 0 0 0 0 branch(arith)')" 144 refuse "split with a comment" "$FS" split "$(m 'gen-split 1' "salt $SALT" '# x' 'h1 heldout 1 1 0 0 0 0 branch(arith)')" 145 refuse "split bad salt" "$FS" split "$(m 'gen-split 1' 'salt 0123' 'h1 heldout 1 1 0 0 0 0 branch(arith)')" 146 refuse "split corpus line" "$FS" split "$(m 'gen-split 1' "salt $SALT" 'c1 corpus 1 0 1 0 0 0 loop(arith)')" 147 printf 'gen-meta 1\nc1 corpus 1 1 1 0 0 0 loop(branch(arith))\nc2 corpus 0 0 0 1 0 0 array\n' > "$T/corpus.ok" 148 refuse "R2 duplicate id across files" "$FS" rule "$G/dev/META" "$(m 'gen-meta 1' 'devgen01 corpus 1 0 1 0 0 0 loop(arith)')" 149 refuse "R3 corpus uses a dev signature" "$FS" rule "$G/dev/META" "$(m 'gen-meta 1' 'c9 corpus 0 0 1 0 1 1 loop(call(nested))')" 150 printf 'gen-split 1\nsalt %s\nh1 heldout 0 0 0 0 1 1 call(nested)\n' "$SALT" > "$T/r4" 151 refuse "R4 held-out primitive absent from corpus" "$FS" rule "$T/corpus.ok" "$T/r4" 152 printf 'gen-split 1\nsalt %s\nh1 heldout 0 0 0 2 0 0 seq(array,array)\n' "$SALT" > "$T/r5" 153 refuse "R5 held-out family with one primitive" "$FS" rule "$T/corpus.ok" "$T/r5" 154 printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 1 0 0 0 loop(branch(arith))\n' "$SALT" > "$T/r3h" 155 refuse "R3 held-out shares a corpus signature" "$FS" rule "$T/corpus.ok" "$T/r3h" 156 printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 1 1 0 0 seq(array,branch(loop(arith)))\n' "$SALT" > "$T/hok" 157 if "$FS" rule "$T/corpus.ok" "$T/hok" >/dev/null 2>&1; then pass "rule positive control (valid corpus + split)"; else fail "rule positive control"; fi 158 if ! "$FS" rule "$T/corpus.ok" "$T/hok" 2>/dev/null | grep -q 'seq(array,branch'; then pass "rule hides held-out signatures without --show-heldout"; else fail "rule leaks held-out signatures"; fi 159 expect_out "coarse: nested read as arith" "gc1:loop(branch(arith))" "$FS" coarse 'loop(branch(nested))' 160 expect_out "coarse: duplicate siblings collapsed" "gc1:loop(branch(arith))" "$FS" coarse 'loop(branch(arith,arith))' 161 expect_out "coarse: top-level seq wrapper with leaves dropped" "gc1:loop(branch(arith))" "$FS" coarse 'seq(arith,loop(branch(arith)))' 162 expect_out "coarse: leaf inside a container kept" "gc1:loop(arith,branch(arith))" "$FS" coarse 'loop(branch(arith),arith)' 163 expect_out "coarse: two containers keep the seq" "gc1:seq(call(array),loop(arith))" "$FS" coarse 'seq(call(array),loop(nested))' 164 expect_out "coarse devgen family branch(loop(arith),nested)" "gc1:branch(arith,loop(arith))" "$FS" coarse 'branch(loop(arith),nested)' 165 printf 'gen-split 1\nsalt %s\nh1 heldout 0 1 1 0 0 1 loop(branch(nested))\n' "$SALT" > "$T/r6" 166 refuse_why "R6 held-out = corpus family with nested for arith" "FAIL R6" "$FS" rule "$T/corpus.ok" "$T/r6" 167 printf 'gen-split 1\nsalt %s\nh1 heldout 2 1 1 0 0 0 seq(arith,loop(branch(arith)))\n' "$SALT" > "$T/r6b" 168 refuse_why "R6 held-out = corpus family inside a seq wrapper" "FAIL R6" "$FS" rule "$T/corpus.ok" "$T/r6b" 169 if ! "$FS" rule "$T/corpus.ok" "$T/r6" 2>/dev/null | grep -q 'gc1:loop'; then pass "R6 failure hides the held-out coarse signature"; else fail "R6 failure leaks the held-out coarse signature"; fi 170 refuse_why "R6 corpus = dev family with arith for nested" "FAIL R6" "$FS" rule "$G/dev/META" "$(m 'gen-meta 1' 'c9 corpus 1 0 1 0 1 0 loop(call(arith))')" 171 printf 'gen-meta 1\nc1 corpus 1 1 1 0 0 0 loop(branch(arith))\nc2 corpus 0 0 0 1 0 0 array\nc3 corpus 1 0 1 1 0 0 seq(array,loop(arith))\n' > "$T/corpus.ok2" 172 printf 'gen-split 1\nsalt %s\nh1 heldout 2 1 1 0 0 0 loop(branch(arith),arith)\n' "$SALT" > "$T/r7" 173 refuse_why "R7 held-out with no novel coarse edge" "FAIL R7" "$FS" rule "$T/corpus.ok2" "$T/r7" 174 if "$FS" rule "$T/corpus.ok" "$T/r7" >/dev/null 2>&1; then pass "R6/R7 known limit: loop(branch(arith),arith) passes when loop>arith is new"; else fail "R7 limit control"; fi 175 printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 2 1 0 0 seq(loop(branch(arith)),loop(array))\n' "$SALT" > "$T/r8" 176 refuse_why "R8 held-out top-level step = corpus family loop(branch(arith))" "FAIL R8" "$FS" rule "$T/corpus.ok" "$T/r8" 177 if ! "$FS" rule "$T/corpus.ok" "$T/r8" 2>/dev/null | grep -q 'seq(loop'; then pass "R8 failure hides the held-out shape"; else fail "R8 failure leaks the held-out shape"; fi 178 printf 'gen-split 1\nsalt %s\nh1 heldout 0 1 2 2 0 0 seq(loop(branch(array)),loop(array))\n' "$SALT" > "$T/r8ok" 179 if "$FS" rule "$T/corpus.ok" "$T/r8ok" >/dev/null 2>&1; then pass "R8 control: top-level steps that are no corpus family pass"; else fail "R8 positive control"; fi 180 refuse_why "R8 dev top-level step = corpus family loop(branch(arith))" "FAIL R8" "$FS" rule "$T/corpus.ok" "$(m 'gen-meta 1' 'd1 dev 1 1 1 1 1 0 seq(loop(branch(arith)),call(array))')" 181 if "$FS" rule "$T/corpus.ok" "$G/dev/META" >/dev/null 2>&1; then pass "R8 control: dev/META against a corpus with loop(branch(arith))"; else fail "R8 dev control"; fi 182 # blind re-declaration 183 printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 1 1 0 0 seq(array,branch(loop(arith)))\nh2 heldout 0 0 1 1 1 0 loop(call(array))\n' "$SALT" > "$T/cmpA" 184 printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 1 1 0 0 seq(branch(loop(arith)),array)\nh2 heldout 0 0 1 1 1 0 loop(call(array))\n' "$(printf '%s' "$SALT" | tr '0-9a-f' '1-9a-f0')" > "$T/cmpB" 185 expect_out "compare: same families, other salt and sibling order" "tasks=2 mismatches=0" "$FS" compare "$T/cmpA" "$T/cmpB" 186 sed 's/^h2 .*/h2 heldout 0 0 1 1 1 0 call(loop(array))/' "$T/cmpB" > "$T/cmpC" 187 if "$FS" compare "$T/cmpA" "$T/cmpC" > "$T/cmp.out" 2>&1; then fail "compare mismatch must exit 1"; elif [ "$(cat "$T/cmp.out")" = "tasks=2 mismatches=1" ]; then pass "compare: one mismatch, exit 1, no signature printed"; else fail "compare mismatch output ($(cat "$T/cmp.out"))"; fi 188 sed 's/^h2 /h3 /' "$T/cmpB" > "$T/cmpD"; refuse "compare: different task ids" "$FS" compare "$T/cmpA" "$T/cmpD" 189 head -3 "$T/cmpB" > "$T/cmpE"; refuse "compare: different task counts" "$FS" compare "$T/cmpA" "$T/cmpE" 190 191 # ---- 3. gencheck ---- 192 # The GEN-3 corpus files that protocol.json pins (corpus META, record-set manifests) arrive with GEN-3's own 193 # PR. Until that is merged, they are taken from git at GEN3_COMMIT into a private overlay tree, and the real 194 # protocol.json is checked there; once they exist in this tree, this tree is checked directly. 195 GEN3_COMMIT=`e521e818e42421884d5fd9826426bba56ad10531` 196 GEN3_FILES="tests/one_layer/generalization/corpus/META tests/one_layer/generalization/records/C.MANIFEST tests/one_layer/generalization/records/D.MANIFEST" 197 gen3_into() { # dest-root: copy the GEN-3 files from this tree, else from git at GEN3_COMMIT 198 local p ok=1 199 for p in $GEN3_FILES; do 200 mkdir -p "$1/$(dirname "$p")" 201 if [ -f "$ROOT/$p" ]; then cp "$ROOT/$p" "$1/$p"; else git -C "$ROOT" show "$GEN3_COMMIT:$p" > "$1/$p" 2>/dev/null || ok=0; fi 202 done 203 [ "$ok" = 1 ] 204 } 205 tree_copy() { # dest-root: a private copy of every file gencheck reads 206 mkdir -p "$1" 207 (cd "$ROOT" && tar -cf - docs/one_layer/GEN_PROTOCOL_V1.md docs/one_layer/OMEGESE.md tests/one_layer/acceptance/HARNESS_INTERFACE_V2.md \ 208 tests/one_layer/acceptance/ola.sh tests/one_layer/generalization tools/exp445/PARAMS tools/exp445/arms tools/exp445/reader.sh \ 209 tools/exp445/sampling-gate.sh tools/exp445/weights.A.sha256 tools/gen/protocol) | (cd "$1" && tar -xf -) 210 } 211 LR="$ROOT" 212 if [ ! -f "$ROOT/tests/one_layer/generalization/corpus/META" ]; then 213 LR="$T/live"; tree_copy "$LR" 214 if gen3_into "$LR"; then pass "GEN-3 corpus files taken from git at ${GEN3_COMMIT:0:8} (not yet merged here)"; else fail "GEN-3 files not available from git (fetch origin gen/abstract)"; fi 215 fi 216 # P0: protocol.json with the corpus and record sets unfrozen, the base of the synthetic-corpus tests below 217 sed -E 's/("corpus": \{[^}]*"meta_sha256": )"[0-9a-f]{64}"/\1null/; s/"record_sets": \{[^}]*\}/"record_sets": {"prefix_ids": null, "prefix_sha256": null, "raw_manifest_sha256": null, "abstraction_manifest_sha256": null, "raw_manifest": null, "abstraction_manifest": null}/' "$P" > "$T/P0.json" 218 if "$GC" manifest "$P" "$LR" > "$T/gc.out" 2>&1 && tail -1 "$T/gc.out" | grep -qx 'GENCHECK PASS'; then pass "gencheck manifest protocol.json"; else fail "gencheck manifest protocol.json"; cat "$T/gc.out"; fi 219 if "$FS" rule "$LR/tests/one_layer/generalization/dev/META" "$LR/tests/one_layer/generalization/corpus/META" > "$T/dc.out" 2>&1 && grep -qx 'RULE PASS' "$T/dc.out"; then pass "famsig rule dev/META + GEN-3 corpus/META (R1..R8)"; else fail "famsig rule dev/META + GEN-3 corpus/META"; grep FAIL "$T/dc.out"; fi 220 221 gmut() { # name expected-stderr-substring sed-or-perl-expression [root] 222 local n="$1" want="$2" ex="$3" r="${4:-$LR}" 223 sed -zE "$ex" "$P" > "$T/mut.json" 224 if cmp -s "$T/mut.json" "$P"; then fail "mutant did not apply: $n"; return; fi 225 if "$GC" manifest "$T/mut.json" "$r" > /dev/null 2> "$T/mut.err"; then fail "mutant not caught: $n"; return; fi 226 if grep -qF -- "$want" "$T/mut.err"; then pass "refused: $n"; else fail "refused for another reason: $n ($(cat "$T/mut.err"))"; fi 227 } 228 gmut "unknown top-level key" "unknown key extra" 's/^\{\n/{\n "extra": 1,\n/' 229 gmut "unknown nested key" "unknown key retrieval.top_n" 's/"k": 3,/"k": 3, "top_n": 3,/' 230 gmut "duplicate key" "duplicate key \"revision\"" 's/"revision": 1,/"revision": 1, "revision": 1,/' 231 gmut "missing key" "missing key issue" 's/ "issue": "aien-spark\/omega#476",\n//' 232 gmut "missing split heldout" "missing key splits.heldout" 's/,\n "heldout": \{[^}]*\}//' 233 gmut "missing split dev" "missing key splits.dev" 's/ "dev": \{[^]]*\][^]]*\]\n \},\n//' 234 gmut "changed split: heldout count" "splits.heldout.count changed" 's/"count": 60/"count": 59/' 235 gmut "changed split: min families" "splits.heldout.min_families changed" 's/"min_families": 6/"min_families": 5/' 236 gmut "changed split: dev task renamed" "devgen11" 's/"devgen10"\]/"devgen11"]/' 237 gmut "changed split: dev task dropped" "splits.dev.tasks: 9 tasks" 's/, "devgen10"\]/]/' 238 gmut "duplicate dev task id" "duplicate or unsorted task id devgen09" 's/"devgen10"\]/"devgen09"]/' 239 gmut "dev family list changed" "splits.dev.families" 's/"gs1:loop\(call\(nested\)\)", //' 240 gmut "digest drift: pinned file" "digest drift: tools/exp445/PARAMS" 's/("path": "tools\/exp445\/PARAMS", "sha256": ")a/\1b/' 241 gmut "digest drift: dev META" "digest drift: tests/one_layer/generalization/dev/META" 's/("meta_sha256": ")1/\12/' 242 gmut "pin removed" "required file tools/exp445/PARAMS is not pinned" 's/ \{"path": "tools\/exp445\/PARAMS"[^\n]*\n//' 243 gmut "pins out of order" "not strictly ascending" 's/( \{"path": "docs\/one_layer\/GEN_PROTOCOL_V1.md"[^\n]*\n)( \{"path": "docs\/one_layer\/OMEGESE.md"[^\n]*\n)/\2\1/' 244 gmut "unsafe pin path" "unsafe path" 's/"path": "tools\/exp445\/PARAMS"/"path": "..\/omega\/tools\/exp445\/PARAMS"/' 245 gmut "changed constant: delta" "decision.delta changed" 's/"delta": 0.10/"delta": 0.20/' 246 gmut "changed constant: k" "retrieval.k changed" 's/"k": 3/"k": 5/' 247 gmut "changed constant: max_tokens" "generation.max_tokens changed" 's/"max_tokens": 3072/"max_tokens": 4096/' 248 gmut "changed constant: masking on" "config.masking changed" 's/"masking": false/"masking": true/' 249 gmut "changed constant: floor_max" "decision.floor_max changed" 's/"floor_max": 3/"floor_max": 4/' 250 gmut "changed constant: G0 seed s8" "gates.g0.seed_values[7] changed" 's/476908\]/476909]/' 251 gmut "G0 seed list shortened" "missing frozen value gates.g0.seed_values[7]" 's/, 476908\]/]/' 252 gmut "changed constant: length-match tolerance" "retrieval.length_match_frac changed" 's/"length_match_frac": 0.15/"length_match_frac": 0.25/' 253 gmut "changed constant: near-duplicate threshold" "splits.heldout.near_dup_threshold changed" 's/"near_dup_threshold": 0.5/"near_dup_threshold": 0.6/' 254 gmut "changed constant: one request in flight" "generation.in_flight changed" 's/"in_flight": 1/"in_flight": 4/' 255 gmut "condition order changed" "conditions[0].name changed" 's/\{"name": "A", "prefix_examples": 1/{"name": "B", "prefix_examples": 1/' 256 gmut "extra condition" "conditions: 5 elements" 's/(\{"name": "D"[^\n]*)\n/\1,\n {"name": "E", "prefix_examples": 14, "retrieval": "raw"}\n/' 257 gmut "wrong type" "revision: type s" 's/"revision": 1/"revision": "1"/' 258 gmut "null where not allowed" "splits.dev.meta_sha256: type z" 's/"meta_sha256": "[0-9a-f]{64}"/"meta_sha256": null/' 259 gmut "record set frozen before corpus" "is set while the corpus META is not frozen" 's/("corpus": \{[^}]*"meta_sha256": )"[0-9a-f]{64}"/\1null/' 260 gmut "trailing bytes" "trailing bytes" 's/\}\n$/}\n}\n/' 261 gmut "non-ASCII byte" "ASCII only" 's/"question": "Does/"question": "D\xc3\xb6es/' 262 gmut "bad escape" "escape" 's/"issue": "aien-spark\/omega#476"/"issue": "aien-spark\\u002fomega#476"/' 263 gmut "empty array" "empty array" 's/"controls": \["A", "B", "C"\]/"controls": []/' 264 265 # tree mutants: a private copy of every file gencheck reads 266 R="$T/root" 267 mkdir -p "$R" 268 (cd "$ROOT" && tar -cf - docs/one_layer/GEN_PROTOCOL_V1.md docs/one_layer/OMEGESE.md tests/one_layer/acceptance/HARNESS_INTERFACE_V2.md \ 269 tests/one_layer/acceptance/ola.sh tests/one_layer/generalization tools/exp445/PARAMS tools/exp445/arms tools/exp445/reader.sh \ 270 tools/exp445/sampling-gate.sh tools/exp445/weights.A.sha256 tools/gen/protocol) | (cd "$R" && tar -xf -) 271 gen3_into "$R"; if "$GC" manifest "$P" "$R" >/dev/null 2>&1; then pass "gencheck on the private tree copy"; else fail "gencheck on the private tree copy"; fi 272 mkdir "$R/tests/one_layer/generalization/dev/tasks/cases/devgen11" 273 if "$GC" manifest "$P" "$R" >/dev/null 2>"$T/e"; then fail "extra dev case directory not caught" 274 elif grep -q 'dev cases: 11 directories' "$T/e"; then pass "refused: extra dev case directory" 275 else fail "extra dev case directory: other reason ($(cat "$T/e"))"; fi 276 rmdir "$R/tests/one_layer/generalization/dev/tasks/cases/devgen11" 277 mkdir -p "$R/tests/one_layer/generalization/corpus" 278 CM="$R/tests/one_layer/generalization/corpus/META" 279 corpus_json() { # write $T/c.json with the corpus META digest set 280 local s; s="$(sha256sum "$CM" | cut -c1-64)" 281 sed "s/\"meta_sha256\": null/\"meta_sha256\": \"$s\"/" "$T/P0.json" > "$T/c.json" 282 } 283 printf 'gen-meta 1\nc9 corpus 0 0 1 0 1 1 loop(call(nested))\n' > "$CM"; corpus_json 284 if "$GC" manifest "$T/c.json" "$R" >/dev/null 2>"$T/e"; then fail "mutant not caught: corpus shares a dev signature"; else grep -qF 'R1..R8' "$T/e" && pass "refused: corpus family shared with dev (R3)" || fail "corpus/dev R3: other reason"; fi 285 printf 'gen-meta 1\ndevgen01 corpus 1 0 1 0 0 0 loop(arith)\n' > "$CM"; corpus_json 286 if "$GC" manifest "$T/c.json" "$R" >/dev/null 2>"$T/e"; then fail "mutant not caught: corpus reuses a dev task id"; else grep -qF 'R1..R8' "$T/e" && pass "refused: duplicate task id across splits (R2)" || fail "R2: other reason"; fi 287 printf 'gen-meta 1\nc1 dev 1 0 1 0 0 0 loop(arith)\n' > "$CM"; corpus_json 288 refuse "corpus META with a dev line" "$GC" manifest "$T/c.json" "$R" 289 # synthetic valid corpus: every primitive, no dev signature 290 { 291 echo 'gen-meta 1' 292 echo 'c01 corpus 1 1 1 0 0 0 loop(branch(arith))' 293 echo 'c02 corpus 0 0 0 1 0 0 array' 294 echo 'c03 corpus 0 0 0 0 1 1 call(nested)' 295 echo 'c04 corpus 1 0 1 1 0 0 seq(array,loop(arith))' 296 } > "$CM"; corpus_json 297 if "$GC" manifest "$T/c.json" "$R" >/dev/null 2>&1; then pass "gencheck with a frozen synthetic corpus"; else fail "gencheck with a frozen synthetic corpus"; fi 298 s="$(sha256sum "$CM" | cut -c1-64)"; d="$(printf '%s' "$s" | tr '0-9a-f' '1-9a-f0')" 299 sed "s/$s/$d/" "$T/c.json" > "$T/c2.json" 300 refuse "corpus META digest drift" "$GC" manifest "$T/c2.json" "$R" 301 302 # reviewer split check on a SYNTHETIC held-out split (test-only) 303 SP="$T/SPLIT"; PUB="$T/HELDOUT.pub" 304 shapes='branch(call(nested)) loop(call(array)) seq(array,branch(loop(nested))) branch(array,loop(nested)) call(loop(branch(arith))) seq(call(array),branch(nested))' 305 { 306 echo 'gen-split 1'; echo "salt $SALT" 307 i=0 308 for k in $(seq 1 10); do for sh in $shapes; do 309 i=$((i + 1)); id="$(printf 'q%02d' "$i")" 310 c="$(for p in arith branch loop array call nested; do printf '%s' "$sh" | grep -o "$p" | wc -l; done | tr '\n' ' ' | sed 's/ $//')" 311 echo "$id heldout $c $sh" 312 done; done 313 } > "$SP.unsorted" 314 { head -2 "$SP.unsorted"; tail -n +3 "$SP.unsorted" | LC_ALL=C sort; } > "$SP" 315 mkpub() { # tasks-sha split-file 316 local out; out="$("$FS" split "$2")" || return 1 317 printf 'gen-heldout-pub 1\ntasks_sha256 %s\nsplit_sha256 %s\nfamlist_sha256 %s\ntasks %s\nfamilies %s\n' "$1" \ 318 "$(echo "$out" | sed -n 's/^split_sha256=//p')" "$(echo "$out" | sed -n 's/^famlist_sha256=//p')" \ 319 "$(echo "$out" | sed -n 's/^tasks=//p')" "$(echo "$out" | sed -n 's/^families=//p')" 320 tail -n +3 "$2" | cut -d' ' -f1 | sed 's/^/task /' 321 } 322 TS=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 323 mkpub "$TS" "$SP" > "$PUB" 324 anchor() { # in-json out-json pub-file tasks-sha: anchor the held-out digests in a manifest copy 325 sed "s/\"pub_sha256\": null/\"pub_sha256\": \"$(sha256sum "$3" | cut -c1-64)\"/; s/\"tasks_sha256\": null/\"tasks_sha256\": \"$4\"/" "$1" > "$2" 326 } 327 spl() { # SPLIT HELDOUT.pub: gencheck split with the digests of that HELDOUT.pub anchored 328 anchor "$T/c.json" "$T/cs.json" "$2" "$TS" 329 "$GC" split "$T/cs.json" "$R" "$1" "$2" 330 } 331 if spl "$SP" "$PUB" > "$T/sp.out" 2>&1 && tail -1 "$T/sp.out" | grep -qx 'GENCHECK PASS'; then pass "gencheck split (synthetic 60 tasks, 6 families, R1..R8)"; else fail "gencheck split positive"; cat "$T/sp.out"; fi 332 if ! grep -q 'branch(call' "$T/sp.out"; then pass "gencheck split prints no held-out signature"; else fail "gencheck split leaks a held-out signature"; fi 333 refuse_why "split check with null held-out digests (fail closed)" "fail closed on null" "$GC" split "$T/c.json" "$R" "$SP" "$PUB" 334 anchor "$T/c.json" "$T/cn.json" "$PUB" "$TS"; sed -i 's/"tasks_sha256": "a\{64\}"/"tasks_sha256": null/' "$T/cn.json" 335 refuse_why "split check with only tasks_sha256 null (fail closed)" "fail closed on null" "$GC" split "$T/cn.json" "$R" "$SP" "$PUB" 336 anchor "$P" "$T/pn.json" "$PUB" "$TS"; refuse "split check without a frozen corpus" "$GC" split "$T/pn.json" "$R" "$SP" "$PUB" 337 sed 's/^famlist_sha256 ./famlist_sha256 0/' "$PUB" > "$T/p1"; cmp -s "$T/p1" "$PUB" && sed -i 's/^famlist_sha256 ./famlist_sha256 1/' "$T/p1" 338 refuse_why "HELDOUT.pub famlist digest wrong" "famlist" spl "$SP" "$T/p1" 339 sed '$d' "$PUB" > "$T/p2"; refuse "HELDOUT.pub missing a task line" spl "$SP" "$T/p2" 340 sed 's/^families 6$/families 7/' "$PUB" > "$T/p3"; refuse "HELDOUT.pub families count wrong" spl "$SP" "$T/p3" 341 sed 's/^task q60$/task q61/' "$PUB" > "$T/p4"; refuse "HELDOUT.pub task id differs" spl "$SP" "$T/p4" 342 sed "s/^salt .*/salt $(printf '%s' "$SALT" | tr '0-9a-f' '1-9a-f0')/" "$SP" > "$T/s5"; refuse "SPLIT salt changed after publication" spl "$T/s5" "$PUB" 343 head -61 "$SP" > "$T/s6"; mkpub "$TS" "$T/s6" > "$T/p6"; refuse "held-out split with 59 tasks" spl "$T/s6" "$T/p6" 344 { head -2 "$SP"; tail -n +3 "$SP" | sed 's/ 0 1 0 1 1 1 seq(call(array),branch(nested))$/ 0 1 0 0 1 1 branch(call(nested))/'; } > "$T/s7" 345 mkpub "$TS" "$T/s7" > "$T/p7"; refuse_why "held-out split with 5 families" "famil" spl "$T/s7" "$T/p7" 346 { head -2 "$SP"; tail -n +3 "$SP" | sed 's/^q01 .*/q01 heldout 1 1 1 0 0 0 loop(branch(arith))/'; } > "$T/s8" 347 mkpub "$TS" "$T/s8" > "$T/p8"; refuse_why "held-out family shared with corpus (R3)" "FAIL R3" spl "$T/s8" "$T/p8" 348 { head -2 "$SP"; tail -n +3 "$SP" | sed 's/^q01 .*/q01 heldout 0 1 1 0 0 1 loop(branch(nested))/'; } > "$T/s9" 349 mkpub "$TS" "$T/s9" > "$T/p9"; refuse_why "held-out coarse family shared with corpus (R6)" "FAIL R6" spl "$T/s9" "$T/p9" 350 { head -2 "$SP"; tail -n +3 "$SP" | sed 's/^q01 .*/q01 heldout 2 1 1 0 0 0 loop(branch(arith),arith)/'; } > "$T/s10" 351 mkpub "$TS" "$T/s10" > "$T/p10"; refuse_why "held-out family with no novel coarse edge (R7)" "FAIL R7" spl "$T/s10" "$T/p10" 352 { head -2 "$SP"; tail -n +3 "$SP" | sed 's/^q01 .*/q01 heldout 1 1 2 1 0 0 seq(loop(branch(arith)),loop(array))/'; } > "$T/s11" 353 mkpub "$TS" "$T/s11" > "$T/p11"; refuse_why "held-out top-level step equal to a corpus family (R8)" "FAIL R8" spl "$T/s11" "$T/p11" 354 anchor "$T/c.json" "$T/c3.json" "$PUB" "$(printf '%s' "$TS" | tr a b)" 355 refuse_why "HELDOUT.pub tasks_sha256 differs from protocol" "tasks_sha256 mismatch" "$GC" split "$T/c3.json" "$R" "$SP" "$PUB" 356 anchor "$T/c.json" "$T/c4.json" "$PUB" "$TS"; sed -i 's/"pub_sha256": "\([0-9a-f]\)/"pub_sha256": "f\1/; s/"pub_sha256": "\([0-9a-f]\{64\}\)[0-9a-f]"/"pub_sha256": "\1"/' "$T/c4.json" 357 refuse_why "HELDOUT.pub differs from the anchored pub_sha256" "digest drift: HELDOUT.pub" "$GC" split "$T/c4.json" "$R" "$SP" "$PUB" 358 359 # run-ready and seal-open on a fully frozen SYNTHETIC manifest (test-only values) 360 refuse_why "run-ready on the committed protocol.json (nulls pending)" "GENCHECK FAIL" "$GC" run-ready "$P" "$LR" 361 { 362 echo 'gen-meta 1' 363 echo 'c01 corpus 1 1 1 0 0 0 loop(branch(arith))' 364 echo 'c02 corpus 0 0 0 1 0 0 array' 365 echo 'c03 corpus 0 0 0 0 1 1 call(nested)' 366 echo 'c04 corpus 1 0 1 1 0 0 seq(array,loop(arith))' 367 for i in 05 06 07 08 09 10 11 12 13 14; do echo "c$i corpus 1 1 1 0 0 0 loop(branch(arith))"; done 368 } > "$CM"; corpus_json 369 mkdir -p "$R/records"; printf 'raw manifest (test)\n' > "$R/records/MANIFEST.C"; printf 'abstraction manifest (test)\n' > "$R/records/MANIFEST.D" 370 ifok=1 371 ic="" 372 for ic in $(sed -nE 's/.*"path": "([^"]*)", "commit": "([0-9a-f]{40})".*/\2:\1/p' "$P"); do 373 mkdir -p "$R/$(dirname "${ic#*:}")"; git -C "$ROOT" show "$ic" > "$R/${ic#*:}" 2>/dev/null || ifok=0 374 done 375 [ "$ifok" = 1 ] && [ -n "$ic" ] && pass "interface files available from git at their pinned commits (read from protocol.json)" || fail "interface files not available from git (fetch origin)" 376 ids="$(for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14; do printf '"c%s", ' "$i"; done | sed 's/, $//')" 377 hC="$(sha256sum "$R/records/MANIFEST.C" | cut -c1-64)"; hD="$(sha256sum "$R/records/MANIFEST.D" | cut -c1-64)" 378 sed -E "s|\"record_sets\": \{[^}]*\}|\"record_sets\": {\"prefix_ids\": [$ids], \"prefix_sha256\": \"$(printf '%064d' 7)\", \"raw_manifest_sha256\": \"$hC\", \"abstraction_manifest_sha256\": \"$hD\", \"raw_manifest\": \"records/MANIFEST.C\", \"abstraction_manifest\": \"records/MANIFEST.D\"}|" "$T/c.json" > "$T/f0.json" 379 anchor "$T/f0.json" "$T/F.json" "$PUB" "$TS" 380 if "$GC" run-ready "$T/F.json" "$R" > "$T/rr.out" 2>&1 && tail -1 "$T/rr.out" | grep -qx 'GENCHECK PASS'; then pass "run-ready on a fully frozen synthetic manifest"; else fail "run-ready positive"; tail -3 "$T/rr.out"; fi 381 fmut() { # name expected sed-expression [cmd]: mutate F.json, expect run-ready refusal with that reason 382 sed -zE "$3" "$T/F.json" > "$T/fm.json" 383 if cmp -s "$T/fm.json" "$T/F.json"; then fail "mutant did not apply: $1"; return; fi 384 refuse_why "$1" "$2" "$GC" "${4:-run-ready}" "$T/fm.json" "$R" 385 } 386 fmut "run-ready with prefix_sha256 null" "not run-ready: record_sets.prefix_sha256 is null" 's/"prefix_sha256": "[0-9]{64}"/"prefix_sha256": null/' 387 fmut "run-ready without the genret-cli-v3 interface" "retrieval contract genret-cli-v3 is not pinned" 's/,\n? \{"name": "genret-cli-v3"[^}]*\}//' 388 fmut "record-set path set, digest null" "must both be null or both be set" 's/"raw_manifest_sha256": "[0-9a-f]{64}"/"raw_manifest_sha256": null/' manifest 389 fmut "record-set manifest digest drift" "digest drift: record-set manifest records/MANIFEST.D" "s/\"abstraction_manifest_sha256\": \"$hD\"/\"abstraction_manifest_sha256\": \"$hC\"/" manifest 390 fmut "record-set manifest path missing" "record-set manifest missing" 's|"raw_manifest": "records/MANIFEST.C"|"raw_manifest": "records/MANIFEST.X"|' manifest 391 fmut "prefix id not a corpus task" "is not a corpus task" 's/"c14"\]/"c99"]/' manifest 392 mv "$R/tools/gen/retrieval/CONTRACT.md" "$T/contract.keep" 393 refuse_why "run-ready with an interface file missing from the tree" "is not in this tree" "$GC" run-ready "$T/F.json" "$R" 394 if "$GC" manifest "$T/F.json" "$R" 2>/dev/null | grep -q 'pending merge'; then pass "manifest mode still allows a pending interface (run-ready does not)"; else fail "manifest mode pending interface"; fi 395 mv "$T/contract.keep" "$R/tools/gen/retrieval/CONTRACT.md" 396 mkopen() { # protocol-sha tasks-sha pub-sha > OPEN 397 printf 'gen-open 1\nomega_commit %s\nprotocol_sha256 %s\ntasks_sha256 %s\nheldout_pub_sha256 %s\n' "$(printf '%040d' 1)" "$1" "$2" "$3" 398 } 399 hF="$(sha256sum "$T/F.json" | cut -c1-64)"; hP="$(sha256sum "$PUB" | cut -c1-64)" 400 mkopen "$hF" "$TS" "$hP" > "$T/OPEN" 401 if "$GC" open "$T/F.json" "$R" "$T/OPEN" > "$T/op.out" 2>&1 && tail -1 "$T/op.out" | grep -qx 'GENCHECK PASS'; then pass "gencheck open: OPEN receipt matches the frozen manifest"; else fail "gencheck open positive"; tail -3 "$T/op.out"; fi 402 mkopen "$(printf '%s' "$hF" | tr '0-9a-f' '1-9a-f0')" "$TS" "$hP" > "$T/O1"; refuse_why "OPEN with another protocol.json sha256" "protocol_sha256" "$GC" open "$T/F.json" "$R" "$T/O1" 403 mkopen "$hF" "$(printf '%s' "$TS" | tr a b)" "$hP" > "$T/O2"; refuse_why "OPEN with another tasks_sha256" "OPEN: tasks_sha256 differs" "$GC" open "$T/F.json" "$R" "$T/O2" 404 mkopen "$hF" "$TS" "$(printf '%s' "$hP" | tr '0-9a-f' '1-9a-f0')" > "$T/O3"; refuse_why "OPEN with another heldout_pub_sha256" "OPEN: heldout_pub_sha256 differs" "$GC" open "$T/F.json" "$R" "$T/O3" 405 head -4 "$T/OPEN" > "$T/O4"; refuse_why "OPEN with 4 lines" "exactly 5 lines" "$GC" open "$T/F.json" "$R" "$T/O4" 406 sed 's/^gen-open 1$/gen-open 2/' "$T/OPEN" > "$T/O5"; refuse_why "OPEN with another header" "exactly 5 lines" "$GC" open "$T/F.json" "$R" "$T/O5" 407 sed -E 's/"prefix_sha256": "[0-9]{64}"/"prefix_sha256": null/' "$T/F.json" > "$T/Fn.json"; mkopen "$(sha256sum "$T/Fn.json" | cut -c1-64)" "$TS" "$hP" > "$T/O6" 408 refuse_why "OPEN over a manifest with a null digest" "is null" "$GC" open "$T/Fn.json" "$R" "$T/O6" 409 410 # ---- 4. dev pack ---- 411 PK="$ROOT/tests/one_layer/generalization/dev/pack_dev.sh" 412 if bash "$PK" "$T/pack1" >/dev/null && bash "$PK" "$T/pack2" >/dev/null && cmp -s "$T/pack1/tasks.tar" "$T/pack2/tasks.tar"; then pass "dev pack reproducible"; else fail "dev pack reproducible"; fi 413 want="$(sed -n 's/.*"pack_sha256": "\([0-9a-f]\{64\}\)".*/\1/p' "$P")" 414 if [ "$(cut -c1-64 "$T/pack1/TASKS.sha256")" = "$want" ]; then pass "dev pack sha256 = splits.dev.pack_sha256"; else fail "dev pack sha256 differs from protocol.json"; fi 415 cp -r "$ROOT/tests/one_layer/generalization/dev" "$T/devneg" 416 sed -i '1s/.*/1/' "$T/devneg/tasks/cases/devgen04/hidden/expected" 417 if bash "$T/devneg/pack_dev.sh" "$T/packneg" >/dev/null 2>&1; then fail "wrong hidden/expected not refused"; else pass "refused: dev pack with one wrong expected line (oracle check)"; fi 418 if [ "${GEN_TASKS_CHECK:-0}" = 1 ]; then 419 # ola.sh writes evidence under its own repo root and OLA_EVIDENCE_ROOT forces RUN INVALID (ola.sh line 27), so it 420 # runs in a private detached git worktree of HEAD under $T; that worktree (with its evidence and build output) is 421 # removed afterwards. Nothing in this checkout's evidence/ tree is written or deleted. 422 WT="$T/wt" 423 if git -C "$ROOT" worktree add -q --detach "$WT" HEAD 2>"$T/wt.err"; then 424 # OUT_DIR from an outer make call would reach ola.sh's own make through MAKEFLAGS; it is dropped so ola 425 # builds into the worktree's build/one_layer, where it looks for its tools. 426 if env -u MAKEFLAGS -u MFLAGS -u MAKELEVEL -u OUT_DIR bash "$WT/tests/one_layer/acceptance/ola.sh" tasks-check "$T/pack1/tasks.tar" "$T/pack1/TASKS.sha256" 2>"$T/tc.err" | grep -q 'RUN VALID'; then pass "ola.sh tasks-check dev pack in a private worktree of HEAD: RUN VALID"; else fail "ola.sh tasks-check dev pack (private worktree)"; tail -5 "$T/tc.err"; fi 427 git -C "$ROOT" worktree remove --force "$WT" || fail "private worktree not removed: $WT" 428 else 429 fail "git worktree add for the tasks-check"; cat "$T/wt.err" 430 fi 431 fi 432 433 if [ -n "${GENP_OMC:-}" ]; then 434 np=$(wc -l < "$T/par.count"); nd=$(wc -l < "$T/par.diff") 435 if [ "$nd" -gt 0 ]; then fail "OM parity: $nd of $np invocations differ from the C build"; head -20 "$T/par.diff" 436 elif [ "$np" -gt 0 ]; then pass "OM parity: $np invocations byte-identical to the C build (stdout, stderr, exit status)" 437 else fail "OM parity: no invocation ran through the OM build"; fi 438 fi 439 echo "test-gen-protocol: $ok ok, $bad failed" 440 [ "$bad" = 0 ]