interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / gen / protocol / test_gen_protocol.sh

394 lines · 37254 bytes Raw Blame History
1#!/usr/bin/env bash
2# tools/gen/protocol/test_gen_protocol.sh <builddir> -- tests of the GEN protocol tools (aien-spark/omega#476).
3# CPU only; reads only public files of this repository; writes only under <builddir> 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.
19set -uo pipefail
20ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
21B="${1:?usage: test_gen_protocol.sh <builddir>}"
22mkdir -p "$B"; B="$(realpath -e "$B")"
23T="$(mktemp -d "${TMPDIR:-/tmp}/gen-proto-test.XXXXXXXX")"; trap 'rm -rf "$T"' EXIT
24CFLAGS="-std=gnu11 -Wall -Wextra -Werror -O2"
25G="$ROOT/tests/one_layer/generalization"
26P="$G/protocol.json"
27ok=0; bad=0
28pass() { ok=$((ok + 1)); echo "ok $1"; }
29fail() { bad=$((bad + 1)); echo "FAIL $1"; }
30expect_out() { # name expected command...
31 local n="$1" e="$2"; shift 2
32 local got; got="$("$@" 2>/dev/null)"
33 if [ "$got" = "$e" ]; then pass "$n"; else fail "$n (got '$got')"; fi
34}
35refuse() { # name command... : must exit non-zero
36 local n="$1"; shift
37 if "$@" >/dev/null 2>&1; then fail "mutant not caught: $n"; else pass "refused: $n"; fi
38}
39refuse_why() { # name expected-output-substring command... : must exit non-zero and say why
40 local n="$1" w="$2"; shift 2
41 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
42}
43
44${CC:-cc} $CFLAGS -I"$ROOT/src" -o "$B/famsig" "$ROOT/tools/gen/protocol/famsig.c" "$ROOT/src/omega_om_units.c" || exit 1
45${CC:-cc} $CFLAGS -I"$ROOT/src" -o "$B/gencheck" "$ROOT/tools/gen/protocol/gencheck.c" "$ROOT/src/omega_om_units.c" || exit 1
46${CC:-cc} $CFLAGS -o "$B/genstats" "$ROOT/tools/gen/protocol/genstats.c" -lm || exit 1
47${CC:-cc} $CFLAGS -o "$B/genjac" "$ROOT/tools/gen/protocol/genjac.c" || exit 1
48FS="$B/famsig"; GC="$B/gencheck"; GS="$B/genstats"; JC="$B/genjac"
49
50# ---- 1. statistics ----
51if "$GS" selftest | tail -1 | grep -q '^SELFTEST PASS'; then pass "genstats selftest"; else fail "genstats selftest"; fi
52if "$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
53z59=$(printf '%059d' 0); o59=$(printf '1%.0s' $(seq 59)); z60="0$z59"; o60="1$o59"; z61="0$z60"
54refuse_why "genstats verdict with n = 59" "n = 60 only" "$GS" verdict 1 "$o59" "$z59" "$z59" "$o59"
55refuse_why "genstats verdict with n = 61" "n = 60 only" "$GS" verdict 1 "${o60}1" "$z61" "$z61" "${o60}1"
56if "$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
57
58expect_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"
59expect_out "lenmatch 256 B boundary: matched" "tasks=2 matched=1 unmatched=1 status=AVAILABLE" sh -c "\"$GS\" lenmatch 300:556 300:557 | tail -1"
60expect_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"
61expect_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"
62expect_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"
63if 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
64refuse "lenmatch bad pair" "$GS" lenmatch 300-556
65# genjac: word 3-gram Jaccard
66printf '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"
67expect_out "genjac pair 1/3" "grams_a=2 grams_b=2 inter=1 union=3 jaccard=0.333333" "$JC" pair "$T/j1" "$T/j2"
68expect_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"
69expect_out "genjac pair identical" "grams_a=2 grams_b=2 inter=2 union=2 jaccard=1.000000" "$JC" pair "$T/j1" "$T/j1"
70expect_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"
71printf '%s\n' "$T/j3" > "$T/hl"; printf '%s\n' "$T/j4" "$T/j5" > "$T/cl"
72expect_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"
73if "$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
74expect_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"
75"$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"
76"$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"
77printf '%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"
78# ---- 2. famsig ----
79expect_out "canon flattens seq and sorts" "gs1:seq(array,loop(array,branch(arith)))" "$FS" canon 'seq(loop(branch(arith),array),array)'
80expect_out "canon loop(seq(a,b)) = loop(a,b)" "gs1:loop(arith,array)" "$FS" canon 'loop(seq(array,arith))'
81expect_out "nesting order matters" "gs1:branch(loop(arith))" "$FS" canon 'branch(loop(arith))'
82expect_out "token devgen01 family" "gs1-bd9c105e5ae45397" "$FS" token 'loop(call(nested))'
83expect_out "token devgen04 family" "gs1-e05d1c5dffd08b06" "$FS" token 'branch(loop(arith),nested)'
84expect_out "token devgen09 family" "gs1-f63e09ec03a454ee" "$FS" token 'loop(loop(branch(arith)))'
85expect_out "token devgen07 family" "gs1-30938c5c7504ef0e" "$FS" token 'seq(array,loop(array,branch(arith)))'
86if "$FS" rule "$G/dev/META" >/dev/null 2>&1; then pass "famsig rule dev/META: RULE PASS"; else fail "famsig rule dev/META"; fi
87
88refuse "shape unknown primitive" "$FS" canon 'loop(sort)'
89refuse "shape leaf with children" "$FS" canon 'arith(loop)'
90refuse "shape container without child" "$FS" canon 'loop()'
91refuse "shape seq with one child" "$FS" canon 'seq(arith)'
92refuse "shape with a space" "$FS" canon 'loop(arith, array)'
93refuse "shape deeper than 8" "$FS" canon 'loop(loop(loop(loop(loop(loop(loop(loop(loop(arith)))))))))'
94m() { printf '%s\n' "$@" > "$T/m.txt"; echo "$T/m.txt"; }
95refuse "meta count mismatch (R1)" "$FS" meta "$(m 'gen-meta 1' 'c1 corpus 2 0 1 0 0 0 loop(arith)')"
96refuse "meta heldout line in a public file" "$FS" meta "$(m 'gen-meta 1' 'h1 heldout 1 1 0 0 0 0 branch(arith)')"
97refuse "meta bad task id" "$FS" meta "$(m 'gen-meta 1' 'C1 corpus 1 0 1 0 0 0 loop(arith)')"
98refuse "meta leading zero count" "$FS" meta "$(m 'gen-meta 1' 'c1 corpus 01 0 1 0 0 0 loop(arith)')"
99refuse "meta double space" "$FS" meta "$(m 'gen-meta 1' 'c1 corpus 1 0 1 0 0 0 loop(arith)')"
100printf 'gen-meta 1\nc1 corpus 1 0 1 0 0 0 loop(arith)' > "$T/nonl"; refuse "meta no final newline" "$FS" meta "$T/nonl"
101printf '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"
102SALT=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
103refuse "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)')"
104refuse "split with a comment" "$FS" split "$(m 'gen-split 1' "salt $SALT" '# x' 'h1 heldout 1 1 0 0 0 0 branch(arith)')"
105refuse "split bad salt" "$FS" split "$(m 'gen-split 1' 'salt 0123' 'h1 heldout 1 1 0 0 0 0 branch(arith)')"
106refuse "split corpus line" "$FS" split "$(m 'gen-split 1' "salt $SALT" 'c1 corpus 1 0 1 0 0 0 loop(arith)')"
107printf '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"
108refuse "R2 duplicate id across files" "$FS" rule "$G/dev/META" "$(m 'gen-meta 1' 'devgen01 corpus 1 0 1 0 0 0 loop(arith)')"
109refuse "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))')"
110printf 'gen-split 1\nsalt %s\nh1 heldout 0 0 0 0 1 1 call(nested)\n' "$SALT" > "$T/r4"
111refuse "R4 held-out primitive absent from corpus" "$FS" rule "$T/corpus.ok" "$T/r4"
112printf 'gen-split 1\nsalt %s\nh1 heldout 0 0 0 2 0 0 seq(array,array)\n' "$SALT" > "$T/r5"
113refuse "R5 held-out family with one primitive" "$FS" rule "$T/corpus.ok" "$T/r5"
114printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 1 0 0 0 loop(branch(arith))\n' "$SALT" > "$T/r3h"
115refuse "R3 held-out shares a corpus signature" "$FS" rule "$T/corpus.ok" "$T/r3h"
116printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 1 1 0 0 seq(array,branch(loop(arith)))\n' "$SALT" > "$T/hok"
117if "$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
118if ! "$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
119expect_out "coarse: nested read as arith" "gc1:loop(branch(arith))" "$FS" coarse 'loop(branch(nested))'
120expect_out "coarse: duplicate siblings collapsed" "gc1:loop(branch(arith))" "$FS" coarse 'loop(branch(arith,arith))'
121expect_out "coarse: top-level seq wrapper with leaves dropped" "gc1:loop(branch(arith))" "$FS" coarse 'seq(arith,loop(branch(arith)))'
122expect_out "coarse: leaf inside a container kept" "gc1:loop(arith,branch(arith))" "$FS" coarse 'loop(branch(arith),arith)'
123expect_out "coarse: two containers keep the seq" "gc1:seq(call(array),loop(arith))" "$FS" coarse 'seq(call(array),loop(nested))'
124expect_out "coarse devgen family branch(loop(arith),nested)" "gc1:branch(arith,loop(arith))" "$FS" coarse 'branch(loop(arith),nested)'
125printf 'gen-split 1\nsalt %s\nh1 heldout 0 1 1 0 0 1 loop(branch(nested))\n' "$SALT" > "$T/r6"
126refuse_why "R6 held-out = corpus family with nested for arith" "FAIL R6" "$FS" rule "$T/corpus.ok" "$T/r6"
127printf 'gen-split 1\nsalt %s\nh1 heldout 2 1 1 0 0 0 seq(arith,loop(branch(arith)))\n' "$SALT" > "$T/r6b"
128refuse_why "R6 held-out = corpus family inside a seq wrapper" "FAIL R6" "$FS" rule "$T/corpus.ok" "$T/r6b"
129if ! "$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
130refuse_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))')"
131printf '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"
132printf 'gen-split 1\nsalt %s\nh1 heldout 2 1 1 0 0 0 loop(branch(arith),arith)\n' "$SALT" > "$T/r7"
133refuse_why "R7 held-out with no novel coarse edge" "FAIL R7" "$FS" rule "$T/corpus.ok2" "$T/r7"
134if "$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
135printf 'gen-split 1\nsalt %s\nh1 heldout 1 1 2 1 0 0 seq(loop(branch(arith)),loop(array))\n' "$SALT" > "$T/r8"
136refuse_why "R8 held-out top-level step = corpus family loop(branch(arith))" "FAIL R8" "$FS" rule "$T/corpus.ok" "$T/r8"
137if ! "$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
138printf 'gen-split 1\nsalt %s\nh1 heldout 0 1 2 2 0 0 seq(loop(branch(array)),loop(array))\n' "$SALT" > "$T/r8ok"
139if "$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
140refuse_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))')"
141if "$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
142# blind re-declaration
143printf '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"
144printf '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"
145expect_out "compare: same families, other salt and sibling order" "tasks=2 mismatches=0" "$FS" compare "$T/cmpA" "$T/cmpB"
146sed 's/^h2 .*/h2 heldout 0 0 1 1 1 0 call(loop(array))/' "$T/cmpB" > "$T/cmpC"
147if "$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
148sed 's/^h2 /h3 /' "$T/cmpB" > "$T/cmpD"; refuse "compare: different task ids" "$FS" compare "$T/cmpA" "$T/cmpD"
149head -3 "$T/cmpB" > "$T/cmpE"; refuse "compare: different task counts" "$FS" compare "$T/cmpA" "$T/cmpE"
150
151# ---- 3. gencheck ----
152# The GEN-3 corpus files that protocol.json pins (corpus META, record-set manifests) arrive with GEN-3's own
153# PR. Until that is merged, they are taken from git at GEN3_COMMIT into a private overlay tree, and the real
154# protocol.json is checked there; once they exist in this tree, this tree is checked directly.
155GEN3_COMMIT=e521e818e42421884d5fd9826426bba56ad10531
156GEN3_FILES="tests/one_layer/generalization/corpus/META tests/one_layer/generalization/records/C.MANIFEST tests/one_layer/generalization/records/D.MANIFEST"
157gen3_into() { # dest-root: copy the GEN-3 files from this tree, else from git at GEN3_COMMIT
158 local p ok=1
159 for p in $GEN3_FILES; do
160 mkdir -p "$1/$(dirname "$p")"
161 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
162 done
163 [ "$ok" = 1 ]
164}
165tree_copy() { # dest-root: a private copy of every file gencheck reads
166 mkdir -p "$1"
167 (cd "$ROOT" && tar -cf - docs/one_layer/GEN_PROTOCOL_V1.md docs/one_layer/OMEGESE.md tests/one_layer/acceptance/HARNESS_INTERFACE_V2.md \
168 tests/one_layer/acceptance/ola.sh tests/one_layer/generalization tools/exp445/PARAMS tools/exp445/arms tools/exp445/reader.sh \
169 tools/exp445/sampling-gate.sh tools/exp445/weights.A.sha256 tools/gen/protocol) | (cd "$1" && tar -xf -)
170}
171LR="$ROOT"
172if [ ! -f "$ROOT/tests/one_layer/generalization/corpus/META" ]; then
173 LR="$T/live"; tree_copy "$LR"
174 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
175fi
176# P0: protocol.json with the corpus and record sets unfrozen, the base of the synthetic-corpus tests below
177sed -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"
178if "$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
179if "$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
180
181gmut() { # name expected-stderr-substring sed-or-perl-expression [root]
182 local n="$1" want="$2" ex="$3" r="${4:-$LR}"
183 sed -zE "$ex" "$P" > "$T/mut.json"
184 if cmp -s "$T/mut.json" "$P"; then fail "mutant did not apply: $n"; return; fi
185 if "$GC" manifest "$T/mut.json" "$r" > /dev/null 2> "$T/mut.err"; then fail "mutant not caught: $n"; return; fi
186 if grep -qF -- "$want" "$T/mut.err"; then pass "refused: $n"; else fail "refused for another reason: $n ($(cat "$T/mut.err"))"; fi
187}
188gmut "unknown top-level key" "unknown key extra" 's/^\{\n/{\n "extra": 1,\n/'
189gmut "unknown nested key" "unknown key retrieval.top_n" 's/"k": 3,/"k": 3, "top_n": 3,/'
190gmut "duplicate key" "duplicate key \"revision\"" 's/"revision": 1,/"revision": 1, "revision": 1,/'
191gmut "missing key" "missing key issue" 's/ "issue": "aien-spark\/omega#476",\n//'
192gmut "missing split heldout" "missing key splits.heldout" 's/,\n "heldout": \{[^}]*\}//'
193gmut "missing split dev" "missing key splits.dev" 's/ "dev": \{[^]]*\][^]]*\]\n \},\n//'
194gmut "changed split: heldout count" "splits.heldout.count changed" 's/"count": 60/"count": 59/'
195gmut "changed split: min families" "splits.heldout.min_families changed" 's/"min_families": 6/"min_families": 5/'
196gmut "changed split: dev task renamed" "devgen11" 's/"devgen10"\]/"devgen11"]/'
197gmut "changed split: dev task dropped" "splits.dev.tasks: 9 tasks" 's/, "devgen10"\]/]/'
198gmut "duplicate dev task id" "duplicate or unsorted task id devgen09" 's/"devgen10"\]/"devgen09"]/'
199gmut "dev family list changed" "splits.dev.families" 's/"gs1:loop\(call\(nested\)\)", //'
200gmut "digest drift: pinned file" "digest drift: tools/exp445/PARAMS" 's/("path": "tools\/exp445\/PARAMS", "sha256": ")a/\1b/'
201gmut "digest drift: dev META" "digest drift: tests/one_layer/generalization/dev/META" 's/("meta_sha256": ")1/\12/'
202gmut "pin removed" "required file tools/exp445/PARAMS is not pinned" 's/ \{"path": "tools\/exp445\/PARAMS"[^\n]*\n//'
203gmut "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/'
204gmut "unsafe pin path" "unsafe path" 's/"path": "tools\/exp445\/PARAMS"/"path": "..\/omega\/tools\/exp445\/PARAMS"/'
205gmut "changed constant: delta" "decision.delta changed" 's/"delta": 0.10/"delta": 0.20/'
206gmut "changed constant: k" "retrieval.k changed" 's/"k": 3/"k": 5/'
207gmut "changed constant: max_tokens" "generation.max_tokens changed" 's/"max_tokens": 3072/"max_tokens": 4096/'
208gmut "changed constant: masking on" "config.masking changed" 's/"masking": false/"masking": true/'
209gmut "changed constant: floor_max" "decision.floor_max changed" 's/"floor_max": 3/"floor_max": 4/'
210gmut "changed constant: G0 seed s8" "gates.g0.seed_values[7] changed" 's/476908\]/476909]/'
211gmut "G0 seed list shortened" "missing frozen value gates.g0.seed_values[7]" 's/, 476908\]/]/'
212gmut "changed constant: length-match tolerance" "retrieval.length_match_frac changed" 's/"length_match_frac": 0.15/"length_match_frac": 0.25/'
213gmut "changed constant: near-duplicate threshold" "splits.heldout.near_dup_threshold changed" 's/"near_dup_threshold": 0.5/"near_dup_threshold": 0.6/'
214gmut "changed constant: one request in flight" "generation.in_flight changed" 's/"in_flight": 1/"in_flight": 4/'
215gmut "condition order changed" "conditions[0].name changed" 's/\{"name": "A", "prefix_examples": 1/{"name": "B", "prefix_examples": 1/'
216gmut "extra condition" "conditions: 5 elements" 's/(\{"name": "D"[^\n]*)\n/\1,\n {"name": "E", "prefix_examples": 14, "retrieval": "raw"}\n/'
217gmut "wrong type" "revision: type s" 's/"revision": 1/"revision": "1"/'
218gmut "null where not allowed" "splits.dev.meta_sha256: type z" 's/"meta_sha256": "[0-9a-f]{64}"/"meta_sha256": null/'
219gmut "record set frozen before corpus" "is set while the corpus META is not frozen" 's/("corpus": \{[^}]*"meta_sha256": )"[0-9a-f]{64}"/\1null/'
220gmut "trailing bytes" "trailing bytes" 's/\}\n$/}\n}\n/'
221gmut "non-ASCII byte" "ASCII only" 's/"question": "Does/"question": "D\xc3\xb6es/'
222gmut "bad escape" "escape" 's/"issue": "aien-spark\/omega#476"/"issue": "aien-spark\\u002fomega#476"/'
223gmut "empty array" "empty array" 's/"controls": \["A", "B", "C"\]/"controls": []/'
224
225# tree mutants: a private copy of every file gencheck reads
226R="$T/root"
227mkdir -p "$R"
228(cd "$ROOT" && tar -cf - docs/one_layer/GEN_PROTOCOL_V1.md docs/one_layer/OMEGESE.md tests/one_layer/acceptance/HARNESS_INTERFACE_V2.md \
229 tests/one_layer/acceptance/ola.sh tests/one_layer/generalization tools/exp445/PARAMS tools/exp445/arms tools/exp445/reader.sh \
230 tools/exp445/sampling-gate.sh tools/exp445/weights.A.sha256 tools/gen/protocol) | (cd "$R" && tar -xf -)
231gen3_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
232mkdir "$R/tests/one_layer/generalization/dev/tasks/cases/devgen11"
233if "$GC" manifest "$P" "$R" >/dev/null 2>"$T/e"; then fail "extra dev case directory not caught"
234elif grep -q 'dev cases: 11 directories' "$T/e"; then pass "refused: extra dev case directory"
235else fail "extra dev case directory: other reason ($(cat "$T/e"))"; fi
236rmdir "$R/tests/one_layer/generalization/dev/tasks/cases/devgen11"
237mkdir -p "$R/tests/one_layer/generalization/corpus"
238CM="$R/tests/one_layer/generalization/corpus/META"
239corpus_json() { # write $T/c.json with the corpus META digest set
240 local s; s="$(sha256sum "$CM" | cut -c1-64)"
241 sed "s/\"meta_sha256\": null/\"meta_sha256\": \"$s\"/" "$T/P0.json" > "$T/c.json"
242}
243printf 'gen-meta 1\nc9 corpus 0 0 1 0 1 1 loop(call(nested))\n' > "$CM"; corpus_json
244if "$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
245printf 'gen-meta 1\ndevgen01 corpus 1 0 1 0 0 0 loop(arith)\n' > "$CM"; corpus_json
246if "$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
247printf 'gen-meta 1\nc1 dev 1 0 1 0 0 0 loop(arith)\n' > "$CM"; corpus_json
248refuse "corpus META with a dev line" "$GC" manifest "$T/c.json" "$R"
249# synthetic valid corpus: every primitive, no dev signature
250{
251 echo 'gen-meta 1'
252 echo 'c01 corpus 1 1 1 0 0 0 loop(branch(arith))'
253 echo 'c02 corpus 0 0 0 1 0 0 array'
254 echo 'c03 corpus 0 0 0 0 1 1 call(nested)'
255 echo 'c04 corpus 1 0 1 1 0 0 seq(array,loop(arith))'
256} > "$CM"; corpus_json
257if "$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
258s="$(sha256sum "$CM" | cut -c1-64)"; d="$(printf '%s' "$s" | tr '0-9a-f' '1-9a-f0')"
259sed "s/$s/$d/" "$T/c.json" > "$T/c2.json"
260refuse "corpus META digest drift" "$GC" manifest "$T/c2.json" "$R"
261
262# reviewer split check on a SYNTHETIC held-out split (test-only)
263SP="$T/SPLIT"; PUB="$T/HELDOUT.pub"
264shapes='branch(call(nested)) loop(call(array)) seq(array,branch(loop(nested))) branch(array,loop(nested)) call(loop(branch(arith))) seq(call(array),branch(nested))'
265{
266 echo 'gen-split 1'; echo "salt $SALT"
267 i=0
268 for k in $(seq 1 10); do for sh in $shapes; do
269 i=$((i + 1)); id="$(printf 'q%02d' "$i")"
270 c="$(for p in arith branch loop array call nested; do printf '%s' "$sh" | grep -o "$p" | wc -l; done | tr '\n' ' ' | sed 's/ $//')"
271 echo "$id heldout $c $sh"
272 done; done
273} > "$SP.unsorted"
274{ head -2 "$SP.unsorted"; tail -n +3 "$SP.unsorted" | LC_ALL=C sort; } > "$SP"
275mkpub() { # tasks-sha split-file
276 local out; out="$("$FS" split "$2")" || return 1
277 printf 'gen-heldout-pub 1\ntasks_sha256 %s\nsplit_sha256 %s\nfamlist_sha256 %s\ntasks %s\nfamilies %s\n' "$1" \
278 "$(echo "$out" | sed -n 's/^split_sha256=//p')" "$(echo "$out" | sed -n 's/^famlist_sha256=//p')" \
279 "$(echo "$out" | sed -n 's/^tasks=//p')" "$(echo "$out" | sed -n 's/^families=//p')"
280 tail -n +3 "$2" | cut -d' ' -f1 | sed 's/^/task /'
281}
282TS=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
283mkpub "$TS" "$SP" > "$PUB"
284anchor() { # in-json out-json pub-file tasks-sha: anchor the held-out digests in a manifest copy
285 sed "s/\"pub_sha256\": null/\"pub_sha256\": \"$(sha256sum "$3" | cut -c1-64)\"/; s/\"tasks_sha256\": null/\"tasks_sha256\": \"$4\"/" "$1" > "$2"
286}
287spl() { # SPLIT HELDOUT.pub: gencheck split with the digests of that HELDOUT.pub anchored
288 anchor "$T/c.json" "$T/cs.json" "$2" "$TS"
289 "$GC" split "$T/cs.json" "$R" "$1" "$2"
290}
291if 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
292if ! 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
293refuse_why "split check with null held-out digests (fail closed)" "fail closed on null" "$GC" split "$T/c.json" "$R" "$SP" "$PUB"
294anchor "$T/c.json" "$T/cn.json" "$PUB" "$TS"; sed -i 's/"tasks_sha256": "a\{64\}"/"tasks_sha256": null/' "$T/cn.json"
295refuse_why "split check with only tasks_sha256 null (fail closed)" "fail closed on null" "$GC" split "$T/cn.json" "$R" "$SP" "$PUB"
296anchor "$P" "$T/pn.json" "$PUB" "$TS"; refuse "split check without a frozen corpus" "$GC" split "$T/pn.json" "$R" "$SP" "$PUB"
297sed 's/^famlist_sha256 ./famlist_sha256 0/' "$PUB" > "$T/p1"; cmp -s "$T/p1" "$PUB" && sed -i 's/^famlist_sha256 ./famlist_sha256 1/' "$T/p1"
298refuse_why "HELDOUT.pub famlist digest wrong" "famlist" spl "$SP" "$T/p1"
299sed '$d' "$PUB" > "$T/p2"; refuse "HELDOUT.pub missing a task line" spl "$SP" "$T/p2"
300sed 's/^families 6$/families 7/' "$PUB" > "$T/p3"; refuse "HELDOUT.pub families count wrong" spl "$SP" "$T/p3"
301sed 's/^task q60$/task q61/' "$PUB" > "$T/p4"; refuse "HELDOUT.pub task id differs" spl "$SP" "$T/p4"
302sed "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"
303head -61 "$SP" > "$T/s6"; mkpub "$TS" "$T/s6" > "$T/p6"; refuse "held-out split with 59 tasks" spl "$T/s6" "$T/p6"
304{ 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"
305mkpub "$TS" "$T/s7" > "$T/p7"; refuse_why "held-out split with 5 families" "famil" spl "$T/s7" "$T/p7"
306{ head -2 "$SP"; tail -n +3 "$SP" | sed 's/^q01 .*/q01 heldout 1 1 1 0 0 0 loop(branch(arith))/'; } > "$T/s8"
307mkpub "$TS" "$T/s8" > "$T/p8"; refuse_why "held-out family shared with corpus (R3)" "FAIL R3" spl "$T/s8" "$T/p8"
308{ head -2 "$SP"; tail -n +3 "$SP" | sed 's/^q01 .*/q01 heldout 0 1 1 0 0 1 loop(branch(nested))/'; } > "$T/s9"
309mkpub "$TS" "$T/s9" > "$T/p9"; refuse_why "held-out coarse family shared with corpus (R6)" "FAIL R6" spl "$T/s9" "$T/p9"
310{ head -2 "$SP"; tail -n +3 "$SP" | sed 's/^q01 .*/q01 heldout 2 1 1 0 0 0 loop(branch(arith),arith)/'; } > "$T/s10"
311mkpub "$TS" "$T/s10" > "$T/p10"; refuse_why "held-out family with no novel coarse edge (R7)" "FAIL R7" spl "$T/s10" "$T/p10"
312{ 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"
313mkpub "$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"
314anchor "$T/c.json" "$T/c3.json" "$PUB" "$(printf '%s' "$TS" | tr a b)"
315refuse_why "HELDOUT.pub tasks_sha256 differs from protocol" "tasks_sha256 mismatch" "$GC" split "$T/c3.json" "$R" "$SP" "$PUB"
316anchor "$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"
317refuse_why "HELDOUT.pub differs from the anchored pub_sha256" "digest drift: HELDOUT.pub" "$GC" split "$T/c4.json" "$R" "$SP" "$PUB"
318
319# run-ready and seal-open on a fully frozen SYNTHETIC manifest (test-only values)
320refuse_why "run-ready on the committed protocol.json (nulls pending)" "GENCHECK FAIL" "$GC" run-ready "$P" "$LR"
321{
322 echo 'gen-meta 1'
323 echo 'c01 corpus 1 1 1 0 0 0 loop(branch(arith))'
324 echo 'c02 corpus 0 0 0 1 0 0 array'
325 echo 'c03 corpus 0 0 0 0 1 1 call(nested)'
326 echo 'c04 corpus 1 0 1 1 0 0 seq(array,loop(arith))'
327 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
328} > "$CM"; corpus_json
329mkdir -p "$R/records"; printf 'raw manifest (test)\n' > "$R/records/MANIFEST.C"; printf 'abstraction manifest (test)\n' > "$R/records/MANIFEST.D"
330ifok=1
331ic=""
332for ic in $(sed -nE 's/.*"path": "([^"]*)", "commit": "([0-9a-f]{40})".*/\2:\1/p' "$P"); do
333 mkdir -p "$R/$(dirname "${ic#*:}")"; git -C "$ROOT" show "$ic" > "$R/${ic#*:}" 2>/dev/null || ifok=0
334done
335[ "$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)"
336ids="$(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/, $//')"
337hC="$(sha256sum "$R/records/MANIFEST.C" | cut -c1-64)"; hD="$(sha256sum "$R/records/MANIFEST.D" | cut -c1-64)"
338sed -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"
339anchor "$T/f0.json" "$T/F.json" "$PUB" "$TS"
340if "$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
341fmut() { # name expected sed-expression [cmd]: mutate F.json, expect run-ready refusal with that reason
342 sed -zE "$3" "$T/F.json" > "$T/fm.json"
343 if cmp -s "$T/fm.json" "$T/F.json"; then fail "mutant did not apply: $1"; return; fi
344 refuse_why "$1" "$2" "$GC" "${4:-run-ready}" "$T/fm.json" "$R"
345}
346fmut "run-ready with prefix_sha256 null" "not run-ready: record_sets.prefix_sha256 is null" 's/"prefix_sha256": "[0-9]{64}"/"prefix_sha256": null/'
347fmut "run-ready without the genret-cli-v3 interface" "retrieval contract genret-cli-v3 is not pinned" 's/,\n? \{"name": "genret-cli-v3"[^}]*\}//'
348fmut "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
349fmut "record-set manifest digest drift" "digest drift: record-set manifest records/MANIFEST.D" "s/\"abstraction_manifest_sha256\": \"$hD\"/\"abstraction_manifest_sha256\": \"$hC\"/" manifest
350fmut "record-set manifest path missing" "record-set manifest missing" 's|"raw_manifest": "records/MANIFEST.C"|"raw_manifest": "records/MANIFEST.X"|' manifest
351fmut "prefix id not a corpus task" "is not a corpus task" 's/"c14"\]/"c99"]/' manifest
352mv "$R/tools/gen/retrieval/CONTRACT.md" "$T/contract.keep"
353refuse_why "run-ready with an interface file missing from the tree" "is not in this tree" "$GC" run-ready "$T/F.json" "$R"
354if "$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
355mv "$T/contract.keep" "$R/tools/gen/retrieval/CONTRACT.md"
356mkopen() { # protocol-sha tasks-sha pub-sha > OPEN
357 printf 'gen-open 1\nomega_commit %s\nprotocol_sha256 %s\ntasks_sha256 %s\nheldout_pub_sha256 %s\n' "$(printf '%040d' 1)" "$1" "$2" "$3"
358}
359hF="$(sha256sum "$T/F.json" | cut -c1-64)"; hP="$(sha256sum "$PUB" | cut -c1-64)"
360mkopen "$hF" "$TS" "$hP" > "$T/OPEN"
361if "$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
362mkopen "$(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"
363mkopen "$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"
364mkopen "$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"
365head -4 "$T/OPEN" > "$T/O4"; refuse_why "OPEN with 4 lines" "exactly 5 lines" "$GC" open "$T/F.json" "$R" "$T/O4"
366sed '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"
367sed -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"
368refuse_why "OPEN over a manifest with a null digest" "is null" "$GC" open "$T/Fn.json" "$R" "$T/O6"
369
370# ---- 4. dev pack ----
371PK="$ROOT/tests/one_layer/generalization/dev/pack_dev.sh"
372if 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
373want="$(sed -n 's/.*"pack_sha256": "\([0-9a-f]\{64\}\)".*/\1/p' "$P")"
374if [ "$(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
375cp -r "$ROOT/tests/one_layer/generalization/dev" "$T/devneg"
376sed -i '1s/.*/1/' "$T/devneg/tasks/cases/devgen04/hidden/expected"
377if 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
378if [ "${GEN_TASKS_CHECK:-0}" = 1 ]; then
379 # ola.sh writes evidence under its own repo root and OLA_EVIDENCE_ROOT forces RUN INVALID (ola.sh line 27), so it
380 # runs in a private detached git worktree of HEAD under $T; that worktree (with its evidence and build output) is
381 # removed afterwards. Nothing in this checkout's evidence/ tree is written or deleted.
382 WT="$T/wt"
383 if git -C "$ROOT" worktree add -q --detach "$WT" HEAD 2>"$T/wt.err"; then
384 # OUT_DIR from an outer make call would reach ola.sh's own make through MAKEFLAGS; it is dropped so ola
385 # builds into the worktree's build/one_layer, where it looks for its tools.
386 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
387 git -C "$ROOT" worktree remove --force "$WT" || fail "private worktree not removed: $WT"
388 else
389 fail "git worktree add for the tasks-check"; cat "$T/wt.err"
390 fi
391fi
392
393echo "test-gen-protocol: $ok ok, $bad failed"
394[ "$bad" = 0 ]