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 / exp445 / test_exp445.sh
| 1 | #!/usr/bin/env bash |
| 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 | # tools/exp445/test_exp445.sh <build/omega_emit dir> <oscc> <omegese> -- tests of the exp445 r3 tooling |
| 18 | # (omega#445, docs/one_layer/EXP445_PROTOCOL.md section 13) without a model: |
| 19 | # 1 x445 helpers (extract, hex, check, wilson, mcnemar) |
| 20 | # 2 the worked examples (13.2): format, expected results computed independently, both forms through the |
| 21 | # arm's reader and x445 check, both forms through the sealed harness (ola.sh experiment) on their own |
| 22 | # inputs, the same task text in both arms' prompts, the word card, the one-token gate, held-out hygiene |
| 23 | # 3 G0 (g0.sh) and a dry run of run.sh against fake445 (a local stand-in endpoint) on the public dev tasks |
| 24 | # 4 score.sh: provenance, results, McNemar, cost, interim score and the Stage 1 stop rule |
| 25 | # Every check has a negative control or a mutant that must fail it. |
| 26 | # OMEGESE_TOKCOUNT + OMEGESE_TOKENIZER: run the one-token gate on the examples' Omegese words (default: the Spark paths when both exist; skipped otherwise). |
| 27 | # EXP445_HELDOUT_TAR + EXP445_HELDOUT_SUMS (optional; default: the sealed pack on the Spark): the held-out |
| 28 | # entry-name collision check; skipped when the pack is absent (CI). It prints only a count. |
| 29 | set -euo pipefail |
| 30 | B="${1:?usage: test_exp445.sh <build/omega_emit dir> <oscc> <omegese>}"; OSCC="${2:?oscc}"; G="${3:?omegese}" |
| 31 | HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 32 | ROOT="$(cd "$HERE/../.." && pwd)" |
| 33 | X="$B/x445" EMIT="$B/omega_emit" FAKE="$B/fake445" EXX="$B/examples_expected" |
| 34 | T="$(mktemp -d "${TMPDIR:-/tmp}/exp445-test.XXXXXXXX")" |
| 35 | FPIDS="" |
| 36 | trap 'for p in $FPIDS; do kill "$p" 2>/dev/null; done; rm -rf "$T"' EXIT |
| 37 | fails=0 |
| 38 | ok() { echo "ok $*"; } |
| 39 | bad() { echo "FAIL $*"; fails=$((fails + 1)); } |
| 40 | not() { ! "$@"; } |
| 41 | DEV="$ROOT/tests/one_layer/exp445/dev/tasks/cases" |
| 42 | OMD="$ROOT/tests/one_layer/omegese/dev" |
| 43 | REQ="$DEV/dev01/requirement" |
| 44 | EXD="$HERE/arms/examples" |
| 45 | . "$HERE/reader.sh" |
| 46 | fence() { printf 'Here is the program.\n```\n'; cat "$1"; printf '```\n'; } |
| 47 | # pack <src dir holding tasks/> <out dir>: a sealed task tarball the way pack_dev.sh makes one |
| 48 | pack() { mkdir -p "$2"; (cd "$1" && tar --format=ustar --sort=name --owner=0 --group=0 --numeric-owner --mtime=@0 -cf "$2/tasks.tar" tasks); (cd "$2" && sha256sum tasks.tar > TASKS.sha256); } |
| 49 | OLA() { OLA_ALLOW_DIRTY=1 OLA_EVIDENCE_ROOT="$T/evid" "$ROOT/tests/one_layer/acceptance/ola.sh" "$@"; } |
| 50 | |
| 51 | # ---- 1. x445 helpers -------------------------------------------------------------------------------- |
| 52 | printf 'Sure.\n```osc\nfn a() {}\n```\ntrailing\n```\nsecond\n```\n' > "$T/f1"; printf 'no fence here\n' > "$T/f2"; printf 'x\n```\ncut off' > "$T/f3" |
| 53 | [ "$("$X" extract "$T/f1" "$T/o1")" = fenced ] && [ "$(cat "$T/o1")" = "fn a() {}" ] && |
| 54 | [ "$("$X" extract "$T/f2" "$T/o2")" = unfenced ] && cmp -s "$T/f2" "$T/o2" && |
| 55 | [ "$("$X" extract "$T/f3" "$T/o3")" = open ] && [ "$(cat "$T/o3")" = "cut off" ] && |
| 56 | ok "extract: first fenced block, whole text without a fence, an unclosed block to the end" || bad "extract" |
| 57 | "$OSCC" "$DEV/dev01/hidden/reference.osc" "$T/d1" > /dev/null |
| 58 | "$X" tohex "$T/d1.ir" > "$T/d1.hex" |
| 59 | "$X" hex "$T/d1.hex" "$T/d1b.oscir" > /dev/null && cmp -s "$T/d1.ir" "$T/d1b.oscir" && ok "tohex -> hex round trip byte-identical" || bad "hex round trip" |
| 60 | chk() { "$X" check "$1" "$2" "$3" | head -1; } |
| 61 | printf 'fn clamp_add(a: u8, b: u8) -> u8 { return a + ; }\n' > "$T/syn.osc" |
| 62 | printf 'fn clamp_add(a: u8) -> u8 { return a; }\n' > "$T/sig.osc" |
| 63 | printf 'fn other(a: u8, b: u8) -> u8 { return a; }\n' > "$T/name.osc" |
| 64 | head -c 30 "$T/d1.ir" > "$T/trunc.oscir" |
| 65 | [ "$(chk osc "$DEV/dev01/hidden/reference.osc" "$REQ")" = OK ] && [ "$(chk oscir "$T/d1.ir" "$REQ")" = OK ] && |
| 66 | [ "$(chk osc "$T/syn.osc" "$REQ")" = "REFUSED compiler: SYNTAX at line 1: expected an expression, found ';'" ] && |
| 67 | [ "$(chk osc "$T/sig.osc" "$REQ")" = "REFUSED signature: clamp_add takes (u8) -> u8; the task needs (u8, u8) -> u8" ] && |
| 68 | [ "$(chk osc "$T/name.osc" "$REQ")" = "REFUSED signature: no function named clamp_add" ] && |
| 69 | [ "$(chk oscir "$T/trunc.oscir" "$REQ")" = "REFUSED decoder: TRUNCATED (the input ends inside a field)" ] && |
| 70 | ok "check: reference OK in both readers; compiler, signature, name and decoder refusals with reasons" || bad "check" |
| 71 | [ "$("$X" wilson 7 10)" = "0.7000 0.3968 0.8922" ] && [ "$("$X" wilson 0 60)" = "0.0000 0.0000 0.0602" ] && [ "$("$X" wilson 60 60)" = "1.0000 0.9398 1.0000" ] && |
| 72 | not "$X" wilson 3 2 2> /dev/null && ok "wilson: 7/10 -> [0.3968, 0.8922], 0/60 and 60/60 bounds; k > n refused" || bad "wilson" |
| 73 | # exact two-sided McNemar: p = min(1, 2 P(X <= min(b, c))), X ~ Bin(b + c, 1/2); 1 vs 9: 2 * 11/1024 |
| 74 | [ "$("$X" mcnemar 1 9)" = 0.021484 ] && [ "$("$X" mcnemar 9 1)" = 0.021484 ] && [ "$("$X" mcnemar 3 12)" = 0.035156 ] && |
| 75 | [ "$("$X" mcnemar 0 0)" = 1.000000 ] && [ "$("$X" mcnemar 5 5)" = 1.000000 ] && [ "$("$X" mcnemar 0 1)" = 1.000000 ] && |
| 76 | [ "$("$X" mcnemar 0 10)" = 0.001953 ] && not "$X" mcnemar -1 2 2> /dev/null && not "$X" mcnemar 1 2> /dev/null && |
| 77 | ok "mcnemar: 1/9 -> 0.021484 (symmetric), 3/12 -> 0.035156, 0/10 -> 0.001953, ties and 0/0 -> 1; bad arguments refused" || bad "mcnemar" |
| 78 | |
| 79 | # ---- 2. worked examples (13.2) ----------------------------------------------------------------------- |
| 80 | mapfile -t MANY < <(grep . "$EXD/many.list"); mapfile -t ONE < <(grep . "$EXD/one.list") |
| 81 | EXS=("${MANY[@]}" "${ONE[@]}") |
| 82 | [ "${#MANY[@]}" = 14 ] && [ "${#ONE[@]}" = 1 ] && [ "$(printf '%s\n' "${EXS[@]}" | LC_ALL=C sort -u | wc -l)" = 15 ] && |
| 83 | [ "$(printf '%s\n' "${EXS[@]}" | LC_ALL=C sort)" = "$(cd "$EXD" && find . -mindepth 1 -maxdepth 1 -type d -printf '%P\n' | LC_ALL=C sort)" ] && |
| 84 | ok "examples: 14 in the many-shot list, 1 (the r2 example) in the one-shot list, every example dir listed exactly once" || bad "example lists" |
| 85 | # format, inputs, expected computed from the prompt by examples_expected.c (not from the programs) |
| 86 | devents="$(cat "$DEV"/*/requirement | awk '$1 == "entry" { print $2 }' | LC_ALL=C sort)" |
| 87 | exform() { # exform <example dir>: 0 when the example is well formed and its expected file is the independent one |
| 88 | local d="$1" e; e="$(basename "$1")" |
| 89 | [ "$(sed -n 1p "$d/requirement")" = "# exp445 worked example (protocol r3 section 13.2), not a held-out task" ] && |
| 90 | [ "$(sed -n 2p "$d/requirement")" = "kind task" ] && [ "$(sed -n 3p "$d/requirement")" = "entry $e" ] && |
| 91 | grep -qE '^params( (bool|[ui](8|16|32|64)))+$' "$d/requirement" && grep -qE '^ret (bool|[ui](8|16|32|64))$' "$d/requirement" && |
| 92 | [ "$(grep -c . "$d/inputs")" -ge 3 ] && [ "$(grep -c . "$d/inputs")" = "$(grep -c . "$d/expected")" ] && |
| 93 | [ -s "$d/prompt" ] && [ -s "$d/program.osc" ] && [ -s "$d/program.omegese" ] && |
| 94 | "$EXX" "$e" < "$d/inputs" | cmp -s - "$d/expected" && not grep -qx "$e" <<< "$devents" |
| 95 | } |
| 96 | nb=0 nin=0; for e in "${EXS[@]}"; do if exform "$EXD/$e"; then nin=$((nin + $(grep -c . "$EXD/$e/inputs"))); else nb=$((nb + 1)); echo " example $e malformed"; fi; done |
| 97 | [ "$nb" = 0 ] && ok "every example: requirement format, entry = its name (not a dev entry), >= 3 inputs ($nin in all), expected = examples_expected" || bad "$nb examples malformed" |
| 98 | cp -R "$EXD/hash_step" "$T/exbad"; sed -i '1s/.*/TRAP 9/' "$T/exbad/expected" |
| 99 | mkdir -p "$T/exbad2"; cp -R "$EXD/hash_step" "$T/exbad2/dev_entry"; sed -i 's/^entry hash_step$/entry clamp_add/' "$T/exbad2/dev_entry/requirement" |
| 100 | not exform "$T/exbad" && not exform "$T/exbad2/dev_entry" && ok " (negative controls: a changed expected line, an entry named like a dev task)" || bad "example format controls" |
| 101 | # both forms through the arm's own reader: omegese -> omega_emit -> x445 check; text -> x445 check (oscc) |
| 102 | mkdir -p "$T/rd" "$T/exc/omegese" "$T/exc/text" |
| 103 | nr=0; for e in "${EXS[@]}"; do for arm in omegese text; do |
| 104 | ext=osc; [ "$arm" = omegese ] && ext=omegese |
| 105 | fence "$EXD/$e/program.$ext" > "$T/rd/$e.$arm.content" |
| 106 | reader "$X" "$EMIT" "$arm" "$T/rd/$e.$arm.content" "$T/rd/$e.$arm" "$EXD/$e/requirement" |
| 107 | if [ "$(cat "$T/rd/$e.$arm.check")" = OK ]; then nr=$((nr + 1)); mkdir -p "$T/exc/$arm/$e"; for f in "$T/rd/$e.$arm".candidate.*; do cp "$f" "$T/exc/$arm/$e/candidate.${f##*.}"; done |
| 108 | else echo " $e $arm: $(cat "$T/rd/$e.$arm.check")"; fi |
| 109 | done; done |
| 110 | [ "$nr" = 30 ] && ok "reader + x445 check: all 15 examples OK in both forms (30 of 30)" || bad "reader: $nr of 30 example forms OK" |
| 111 | printf '```\nfn hash_step h uint to uint\nret h\nend\n```\n' > "$T/rd/sig.content" |
| 112 | reader "$X" "$EMIT" omegese "$T/rd/sig.content" "$T/rd/sig" "$EXD/hash_step/requirement" |
| 113 | grep -q '^REFUSED signature' "$T/rd/sig.check" && ok " (negative control: an Omegese hash_step with one parameter is refused: $(cat "$T/rd/sig.check"))" || bad "reader control: $(cat "$T/rd/sig.check")" |
| 114 | # both forms through the sealed harness on the examples' own inputs, the way score.sh scores candidates; |
| 115 | # a mutant set (one Omegese and one OSC program with one changed constant) must be rejected |
| 116 | for e in "${EXS[@]}"; do |
| 117 | c="$T/expk/src/tasks/cases/$e"; mkdir -p "$c/hidden" |
| 118 | cp "$EXD/$e/requirement" "$EXD/$e/prompt" "$c/"; cp "$EXD/$e/inputs" "$EXD/$e/expected" "$c/hidden/"; cp "$EXD/$e/program.osc" "$c/hidden/reference.osc" |
| 119 | done |
| 120 | pack "$T/expk/src" "$T/expk" |
| 121 | mkdir -p "$T/exc/mutant/hash_step" "$T/exc/mutant/count_digits" |
| 122 | grep -q '31' "$EXD/hash_step/program.omegese" && sed 's/31/37/' "$EXD/hash_step/program.omegese" > "$T/rd/mut.omegese" |
| 123 | fence "$T/rd/mut.omegese" > "$T/rd/mut.content"; reader "$X" "$EMIT" omegese "$T/rd/mut.content" "$T/rd/mut" "$EXD/hash_step/requirement" |
| 124 | cp "$T/rd/mut.candidate.oscir" "$T/exc/mutant/hash_step/candidate.oscir" |
| 125 | grep -q '10' "$EXD/count_digits/program.osc" && sed '0,/10/s//16/' "$EXD/count_digits/program.osc" > "$T/exc/mutant/count_digits/candidate.osc" |
| 126 | not cmp -s "$T/exc/mutant/count_digits/candidate.osc" "$EXD/count_digits/program.osc" || bad "mutant: sed changed nothing in count_digits" |
| 127 | if OLA experiment "$T/expk/tasks.tar" "$T/expk/TASKS.sha256" "$T/exc" > /dev/null 2> "$T/exh.err"; then |
| 128 | ev="$(sed -n 's/^ola.sh: evidence in //p' "$T/exh.err" | tail -1)"; case "$ev" in /*) ;; *) ev="$ROOT/$ev" ;; esac |
| 129 | grep -q '^set=omegese accepted=15/15 ' "$ev/score.txt" && grep -q '^set=text accepted=15/15 ' "$ev/score.txt" && grep -q '^references_accepted=15/15' "$ev/score.txt" && |
| 130 | ok "harness: both forms of all 15 examples ACCEPT on their $nin inputs, so both forms give the expected (the same) outputs" || { bad "harness on the examples"; grep '^set=\|^references' "$ev/score.txt"; } |
| 131 | [ "$(awk '$1 == "hash_step" || $1 == "count_digits" { print $2 }' "$ev/sets/mutant/verdicts.txt" | sort -u)" = REJECT ] && |
| 132 | ! awk '$1 == "hash_step" || $1 == "count_digits"' "$ev/sets/mutant/verdicts.txt" | grep -q no_candidate && |
| 133 | ok " (negative control: one changed constant in an Omegese and in an OSC example is REJECTED by the harness)" || bad "harness mutant set: $(cat "$ev/sets/mutant/verdicts.txt" | head -3)" |
| 134 | else bad "ola.sh experiment on the examples failed: $(tail -3 "$T/exh.err")"; fi |
| 135 | # both arms' prompts carry the same tasks; only the program blocks differ |
| 136 | tasktext() { awk '/^Worked example/ { w = 1 } w' | awk '/^```$/ { f = !f; print; next } !f'; } |
| 137 | for mode in many one; do for arm in omegese text; do system_prompt "$HERE/arms" "$arm" "$mode" > "$T/p.$arm.$mode"; done; done |
| 138 | cmp -s <(tasktext < "$T/p.omegese.many") <(tasktext < "$T/p.text.many") && cmp -s <(tasktext < "$T/p.omegese.one") <(tasktext < "$T/p.text.one") && |
| 139 | [ "$(grep -cE '^Example [0-9]+\.$' "$T/p.omegese.many")" = 14 ] && [ "$(grep -cE '^Example [0-9]+\.$' "$T/p.text.one")" = 1 ] && |
| 140 | grep -qx 'entry clamp_sub' "$T/p.text.one" && not grep -qx 'entry clamp_sub' "$T/p.text.many" && |
| 141 | [ "$(grep -c '^```$' "$T/p.omegese.many")" = 28 ] && grep -qF "$(cat "$EXD/dot3/program.omegese")" "$T/p.omegese.many" && grep -qF "$(cat "$EXD/dot3/program.osc")" "$T/p.text.many" && |
| 142 | ok "prompts: both arms carry the same task text (14 many-shot, 1 one-shot = clamp_sub), each with its own program form" || bad "prompt task text differs between arms" |
| 143 | not cmp -s <(tasktext < "$T/p.omegese.many") <(tasktext < "$T/p.text.many" | sed '0,/signed/s//unsigned/') && |
| 144 | not system_prompt "$HERE/arms" bytes many 2> /dev/null > /dev/null && not system_prompt "$HERE/arms" omegese few 2> /dev/null > /dev/null && |
| 145 | ok " (negative controls: one changed word is seen; the bytes arm and an unknown mode have no prompt)" || bad "prompt controls" |
| 146 | # word card: one line per fixed word of the language, no more, no less |
| 147 | card() { awk '/^Word card/ { w = 1; next } w && /^ [a-z]/ { print $1 }' "$1" | LC_ALL=C sort; } |
| 148 | [ "$(card "$HERE/arms/omegese.md")" = "$("$G" words | LC_ALL=C sort)" ] && [ "$(card "$HERE/arms/omegese.md" | uniq -d | wc -l)" = 0 ] && |
| 149 | ok "word card: exactly the $("$G" words | wc -l) fixed words of omegese, each once" || bad "word card differs from omegese words" |
| 150 | grep -v '^ bound ' "$HERE/arms/omegese.md" > "$T/card.md" |
| 151 | [ "$(card "$T/card.md")" != "$("$G" words | LC_ALL=C sort)" ] && ok " (negative control: a card missing 'bound' is caught)" || bad "word card control" |
| 152 | # one-token gate on every word of the Omegese examples (numbers, = and the task's own entry name excluded) |
| 153 | # the Spark default paths when the variables are unset and both exist (the gate then runs in a plain make call) |
| 154 | if [ -z "${OMEGESE_TOKCOUNT:-}" ] && [ -z "${OMEGESE_TOKENIZER:-}" ] && [ -x "$HOME/workspace/glyph-tok/target/release/tokcount" ] && |
| 155 | [ -f "$HOME/models/qwen3-30b-a3b-instruct-2507-fp8/tokenizer.json" ]; then |
| 156 | OMEGESE_TOKCOUNT="$HOME/workspace/glyph-tok/target/release/tokcount" OMEGESE_TOKENIZER="$HOME/models/qwen3-30b-a3b-instruct-2507-fp8/tokenizer.json"; fi |
| 157 | if [ -n "${OMEGESE_TOKCOUNT:-}" ] && [ -n "${OMEGESE_TOKENIZER:-}" ]; then |
| 158 | for e in "${EXS[@]}"; do tr -s ' \t' '\n\n' < "$EXD/$e/program.omegese" | grep -v -E '^-?[0-9]+$|^=$|^$' | grep -vx "$e" || true; done | LC_ALL=C sort -u > "$T/words" |
| 159 | multi="$("$OMEGESE_TOKCOUNT" "$OMEGESE_TOKENIZER" words $(cat "$T/words") | awk '$1 != 1 { print $3 }')" |
| 160 | [ -z "$multi" ] && ok "one-token gate: all $(wc -l < "$T/words") distinct words of the Omegese examples are one token each" || bad "multi-token example words: $multi" |
| 161 | [ "$("$OMEGESE_TOKCOUNT" "$OMEGESE_TOKENIZER" words a1 mulmod | awk '$1 != 1' | wc -l)" = 2 ] && |
| 162 | ok " (negative control: a1 and mulmod are two tokens each and would fail the gate)" || bad "token gate control" |
| 163 | else echo "one-token gate on the examples: SKIPPED (set OMEGESE_TOKCOUNT and OMEGESE_TOKENIZER)"; fi |
| 164 | # held-out hygiene: no example entry name equals a held-out task entry name. Reads only the entry lines of |
| 165 | # the public view's requirement files and prints only the count. |
| 166 | printf '%s\n' "${EXS[@]}" | LC_ALL=C sort -u > "$T/exnames" |
| 167 | collisions() { cat "$1"/tasks/cases/*/requirement | awk '$1 == "entry" { print $2 }' | LC_ALL=C sort -u | LC_ALL=C comm -12 - "$2" | wc -l; } |
| 168 | "$ROOT/tests/one_layer/exp445/pack_dev.sh" "$T/pack" > /dev/null |
| 169 | "$ROOT/tests/one_layer/acceptance/ola.sh" tasks-public "$T/pack/tasks.tar" "$T/pack/TASKS.sha256" "$T/pub" > /dev/null 2>&1 |
| 170 | { cat "$T/exnames"; echo clamp_add; } | LC_ALL=C sort > "$T/exnames.bad" |
| 171 | [ "$(collisions "$T/pub" "$T/exnames")" = 0 ] && [ "$(collisions "$T/pub" "$T/exnames.bad")" = 1 ] && |
| 172 | ok "no example entry name is a dev entry name (negative control: an extra clamp_add counts 1)" || bad "dev collision check" |
| 173 | HT="${EXP445_HELDOUT_TAR:-$HOME/workspace/one-layer-sealed-445/tasks.tar}" HS="${EXP445_HELDOUT_SUMS:-$HOME/workspace/omega-vision/stage2/TASKS.sha256}" |
| 174 | if [ -f "$HT" ] && [ -f "$HS" ]; then |
| 175 | if "$ROOT/tests/one_layer/acceptance/ola.sh" tasks-public "$HT" "$HS" "$T/hpub-sealed" > /dev/null 2>&1; then |
| 176 | n="$(collisions "$T/hpub-sealed" "$T/exnames")"; rm -rf "$T/hpub-sealed" |
| 177 | [ "$n" = 0 ] && ok "held-out hygiene: example entry names colliding with held-out entry names: 0" || bad "held-out hygiene: example entry names colliding with held-out entry names: $n" |
| 178 | else bad "held-out hygiene: tasks-public refused the sealed pack"; rm -rf "$T/hpub-sealed"; fi |
| 179 | else echo "held-out hygiene: SKIPPED (no sealed pack here)"; fi |
| 180 | # the r2 one-shot example is still the same unit in every r2 form (bytes.md, the SCHEMA example) |
| 181 | awk '/^Example/ { e = 1 } e && /^```$/ { n++; next } e && n == 1 { print }' "$HERE/arms/bytes.md" > "$T/ex.hex" |
| 182 | awk '/^```$/ { n++; next } n == 3 { print }' "$ROOT/tools/omega_emit/SCHEMA.md" > "$T/ex.json" |
| 183 | "$OSCC" "$EXD/clamp_sub/program.osc" "$T/ext" > /dev/null; "$X" hex "$T/ex.hex" "$T/exb.oscir" > /dev/null; "$EMIT" emit "$T/ex.json" "$T/exs.oscir" > /dev/null |
| 184 | cmp -s "$T/ext.ir" "$T/exb.oscir" && cmp -s "$T/ext.ir" "$T/exs.oscir" && |
| 185 | ok "clamp_sub (the r2 one-shot example): the OSC, r2 bytes and SCHEMA forms are the same IR bytes" || bad "clamp_sub forms differ" |
| 186 | |
| 187 | # ---- 3. G0 and the dry run against the fake endpoint ------------------------------------------------- |
| 188 | mkdir -p "$T/pk"; cp "$ROOT/tests/one_layer/exp445/pack_dev.sh" "$ROOT/tests/one_layer/exp445/gen_expected.c" "$T/pk/"; cp -r "$ROOT/tests/one_layer/exp445/dev" "$T/pk/" |
| 189 | sed -i '0,/^255$/s//254/' "$T/pk/dev/tasks/cases/dev01/hidden/expected" |
| 190 | if bash "$T/pk/pack_dev.sh" "$T/pkout" > /dev/null 2> "$T/pk.err"; then bad "pack_dev accepted a wrong expected line" |
| 191 | else grep -q "dev01 hidden/expected differs" "$T/pk.err" && [ ! -e "$T/pkout/tasks.tar" ] && ok "pack_dev refuses a wrong expected line and packs nothing (negative control)" || bad "pack refusal reason"; fi |
| 192 | # a held-out-like pack: dev01..dev04 renamed h01..h04 (ids that are not dev*) |
| 193 | for i in 1 2 3 4; do mkdir -p "$T/hp/src/tasks/cases"; cp -R "$DEV/dev0$i" "$T/hp/src/tasks/cases/h0$i"; done |
| 194 | pack "$T/hp/src" "$T/hp"; "$ROOT/tests/one_layer/acceptance/ola.sh" tasks-public "$T/hp/tasks.tar" "$T/hp/TASKS.sha256" "$T/hpub" > /dev/null 2>&1 |
| 195 | # fake answers. text: dev01 OK, dev02 compiler refusal then repaired, dev03 HTTP 500 (all tries). |
| 196 | # omegese: dev01 OK (a different wording per G0 seed), dev02 refused then repaired, dev03 over budget, dev04 OK. |
| 197 | A="$T/answers"; mkdir -p "$A/text" "$A/omegese" |
| 198 | fence "$DEV/dev01/hidden/reference.osc" > "$A/text/clamp_add" |
| 199 | printf '```\nfn absdiff(a: i32, b: i32) -> i64 { return a - ; }\n```\n' > "$A/text/absdiff" |
| 200 | fence "$DEV/dev02/hidden/reference.osc" > "$A/text/absdiff.repair" |
| 201 | printf '@@500\n' > "$A/text/popcount" |
| 202 | fence "$OMD/dev01.omegese" > "$A/omegese/clamp_add" |
| 203 | printf '```\nfn absdiff a int b int to long\nret sub a b\nend\n```\n' > "$A/omegese/absdiff" |
| 204 | fence "$OMD/dev02.omegese" > "$A/omegese/absdiff.repair" |
| 205 | { printf '```\n'; head -c 20000 /dev/zero | tr '\0' ' '; printf 'fn popcount\n```\n'; } > "$A/omegese/popcount" |
| 206 | fence "$OMD/dev04.omegese" > "$A/omegese/gcd" |
| 207 | g0seeds() { for k in 1 2 3 4 5 6 7 8; do seed_of 445000 "$k" 1; done; } |
| 208 | for s in $(g0seeds); do { echo "Answer for seed $s."; fence "$OMD/dev01.omegese"; } > "$A/omegese/clamp_add.seed$s"; done |
| 209 | # text, attempt 2 of the first task (seed 447001): the same program with another variable name (a distinct candidate) |
| 210 | sed 's/\bs\b/t/g' "$DEV/dev01/hidden/reference.osc" > "$T/clamp_add.alt.osc"; fence "$T/clamp_add.alt.osc" > "$A/text/clamp_add.seed447001" |
| 211 | printf '{"object":"list","data":[{"id":"qwen3-30b-a3b-instruct-2507","object":"model"},{"id":"qwen3-8b","object":"model"}]}\n' > "$A/models.json" |
| 212 | A2="$T/answers2"; mkdir -p "$A2/omegese"; cp "$A/models.json" "$A2/"; fence "$OMD/dev01.omegese" > "$A2/omegese/clamp_add" |
| 213 | startfake() { "$FAKE" "$1" "$2" & FPIDS="$FPIDS $!"; for i in $(seq 1 50); do [ -s "$1" ] && break; sleep 0.1; done; printf -v "$3" "http://127.0.0.1:%s/v1" "$(cat "$1")"; } |
| 214 | startfake "$T/port" "$A" URL; startfake "$T/port2" "$A2" URL2 |
| 215 | # test PARAMS: the frozen PARAMS with config A pointed at the fake endpoint and given a stand-in server, |
| 216 | # config B made available on the fake endpoint, 1 attempt, and a small stand-in model directory |
| 217 | mkdir -p "$T/models/m"; printf 'w1\n' > "$T/models/m/a.bin"; printf 'w2\n' > "$T/models/m/b.bin" |
| 218 | (cd "$T/models" && sha256sum m/a.bin m/b.bin) > "$T/wl.sha256" |
| 219 | TP="$T/PARAMS" |
| 220 | sed -e "s|^config\.A\.base_url=.*|config.A.base_url=$URL|" -e 's/^attempts=.*/attempts=1/' -e 's|^config\.A\.server=.*|config.A.server=fake445 test server A|' \ |
| 221 | -e '/^config\.B\.unavailable=/d' -e "s|^models_root=.*|models_root=$T/models|" -e "s|^config\.\([AB]\)\.weights=.*|config.\1.weights=$T/wl.sha256|" "$HERE/PARAMS" > "$TP" |
| 222 | printf 'config.B.base_url=%s\nconfig.B.extra={"chat_template_kwargs":{"enable_thinking":false}}\nconfig.B.server=fake445 test server B\n' "$URL" >> "$TP" |
| 223 | sed "s|^config\.A\.base_url=.*|config.A.base_url=$URL2|" "$TP" > "$T/PARAMS2" |
| 224 | sed -e 's/^attempts=.*/attempts=2/' -e 's/^heldout_tasks=.*/heldout_tasks=4/' -e 's/^futility_max=.*/futility_max=3/' "$TP" > "$T/PARAMSH" |
| 225 | sed 's/^futility_max=.*/futility_max=2/' "$T/PARAMSH" > "$T/PARAMSC" |
| 226 | export EXP445_PARAMS="$TP" EXP445_TEST_BACKOFF_S=0 |
| 227 | export EXP445_G0_LEDGER="$T/g0-ledger" # the tests never write the real ledger |
| 228 | lcat() { find "$1" -maxdepth 1 -type f -name "*.tsv" -print0 2> /dev/null | LC_ALL=C sort -z | xargs -0 -r cat; } # a ledger directory, oldest entry first |
| 229 | cw() { "$HERE/check_weights.sh" "$1" "$2" > /dev/null; } |
| 230 | g0() { "$HERE/g0.sh" --config "$1" --out "$2" > /dev/null 2>&1; } |
| 231 | prep() { cw "$1" "$2" && g0 "$1" "$2"; } |
| 232 | rehash() { local d; for d in "$1"/gen/*/*/; do gen_sums "${d%/}"; done; run_sums "$1"; } |
| 233 | g0hash() { (cd "$1/g0" && g0_files . | tr '\n' '\0' | xargs -0 sha256sum) > "$1/g0/SHA256SUMS"; } |
| 234 | refuse() { # refuse <name> <reason grep> <command...>: the command exits non-zero with that reason |
| 235 | local n="$1" why="$2"; shift 2 |
| 236 | if "$@" > "$T/rf.out" 2> "$T/rf.err"; then bad "$n: not refused"; return; fi |
| 237 | grep -q -- "$why" "$T/rf.err" && ok "refused: $n" || bad "$n: $(tail -2 "$T/rf.err")" |
| 238 | } |
| 239 | # the real PARAMS: config B unavailable with its reason, config A's server frozen (13.3) |
| 240 | refuse "real PARAMS: run.sh config B (OWN-8B not requalified)" "config B is unavailable: config B runs on our own dense 8B engine (OWN-8B), which has not requalified" \ |
| 241 | env -u EXP445_PARAMS "$HERE/run.sh" --config B --tasks "$T/pub" --out "$T/realb" |
| 242 | refuse "real PARAMS: g0.sh config B" "config B is unavailable: config B runs on our own dense 8B engine" env -u EXP445_PARAMS "$HERE/g0.sh" --config B --out "$T/realb" |
| 243 | refuse "real PARAMS: score.sh --configs B" "config B is unavailable" env -u EXP445_PARAMS "$HERE/score.sh" --configs B "$T/pack/tasks.tar" "$T/pack/TASKS.sha256" "$T/pub" |
| 244 | sed 's|^config\.A\.server=.*|config.A.server=PLACEHOLDER: not frozen|' "$HERE/PARAMS" > "$T/PARAMSPH" |
| 245 | refuse "PARAMS with config A's server a placeholder: a held-out run" "config A server is still a placeholder in PARAMS: held-out generation waits" \ |
| 246 | env EXP445_PARAMS="$T/PARAMSPH" "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$T/realh" |
| 247 | [ ! -e "$T/realb" ] && [ ! -e "$T/realh" ] && ok " nothing written by the refused runs" || bad "refused runs wrote files" |
| 248 | grep -qx 'arms=omegese,text' "$HERE/PARAMS" && grep -qx 'prompt_modes=many,one' "$HERE/PARAMS" && grep -qx 'heldout_prompt_mode=many' "$HERE/PARAMS" && |
| 249 | grep -qx 'futility_max=30' "$HERE/PARAMS" && grep -qx 'heldout_tasks=60' "$HERE/PARAMS" && |
| 250 | ok "PARAMS r3: arms omegese,text; prompt modes many,one (held-out: many); futility 30 of 60" || bad "PARAMS r3 values" |
| 251 | # config A's server: a binary path and its sha256, the same pair as the protocol table 13.3; the binary, when present here, has it |
| 252 | SV="$(awk -F= '$1 == "config.A.server" { print substr($0, 17); exit }' "$HERE/PARAMS")" |
| 253 | SVP="$(sed -n 's|^\(/[^ ]*/aien-serve-http\) sha256=[0-9a-f]\{64\} .*|\1|p' <<< "$SV")" SVH="$(sed -n 's|^/[^ ]* sha256=\([0-9a-f]\{64\}\) .*|\1|p' <<< "$SV")" |
| 254 | if [ -n "$SVP" ] && [ -n "$SVH" ] && grep -F '| server |' "$ROOT/docs/one_layer/EXP445_PROTOCOL.md" | grep -qF "\`$SVP\`, sha256 \`$SVH\`"; then |
| 255 | ok "config A server frozen: $SVP, sha256 ${SVH:0:16}..., the same as protocol 13.3" |
| 256 | if [ -f "$SVP" ]; then [ "$(sha256sum < "$SVP" | cut -d' ' -f1)" = "$SVH" ] && ok " and the binary here has that sha256" || bad "config A binary $SVP does not have the frozen sha256" |
| 257 | else echo "skip: $SVP not present here; the frozen pair is checked against the protocol only"; fi |
| 258 | else bad "config A server is not a frozen path + sha256 matching protocol 13.3: $SV"; fi |
| 259 | # frozen weight lists and the operator check |
| 260 | pblock() { awk '/^Weight files, sha256/ { w = 1 } w && /^```$/ { n++; next } w && n == 1 { print }' "$1"; } |
| 261 | [ "$(pblock "$ROOT/docs/one_layer/EXP445_PROTOCOL.md")" = "$(cat "$HERE/weights.A.sha256" "$HERE/weights.B.sha256")" ] && |
| 262 | [ "$(pblock "$ROOT/docs/one_layer/EXP445_PROTOCOL.md" | sed '3s/^./0/')" != "$(cat "$HERE/weights.A.sha256" "$HERE/weights.B.sha256")" ] && |
| 263 | ok "weights.A/B.sha256 equal the protocol's frozen hash block (one changed digit is caught)" || bad "weight lists vs protocol" |
| 264 | cw B "$T/wck" && [ "$(cat "$T/wck/weights.check")" = "$(printf 'm/a.bin: OK\nm/b.bin: OK')" ] && jq -e '.data[1].id == "qwen3-8b"' "$T/wck/server.json" > /dev/null && |
| 265 | ok "check_weights.sh: every listed file OK and the server's model list recorded" || bad "check_weights.sh" |
| 266 | printf 'w3\n' > "$T/models/m/b.bin" |
| 267 | if cw B "$T/wck2" 2> /dev/null; then bad "check_weights.sh accepted a changed weight file" |
| 268 | else grep -qx 'm/b.bin: FAILED' "$T/wck2/weights.check" && ok " (negative control: a changed weight file FAILS the check)" || bad "check_weights failure record"; fi |
| 269 | refuse "driver with a FAILED weight check" 'weights.check + server.json missing or not all OK' "$HERE/run.sh" --config B --tasks "$T/pub" --out "$T/wck2" |
| 270 | printf 'w2\n' > "$T/models/m/b.bin" |
| 271 | refuse "driver with no weight check" 'run tools/exp445/check_weights.sh A' "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/nowck" |
| 272 | refuse "driver on a tasks dir with hidden files" "hidden files" "$HERE/run.sh" --config A --tasks "$ROOT/tests/one_layer/exp445/dev" --out "$T/runbad" |
| 273 | # a 60-task dir with many hidden files (more find output than a pipe holds: a guard that pipes find into grep -q |
| 274 | # fails open under pipefail when find is killed by SIGPIPE) |
| 275 | for i in $(seq -w 1 60); do mkdir -p "$T/hid/tasks/cases/t$i/hidden"; for j in $(seq -w 1 40); do : > "$T/hid/tasks/cases/t$i/hidden/a_long_hidden_file_name_for_the_pipe_test_$j"; done; done |
| 276 | refuse "driver on a 60-task dir with 2400 hidden files" "hidden files" "$HERE/run.sh" --config A --tasks "$T/hid" --out "$T/runhid" |
| 277 | refuse "driver on a config not named in PARAMS" "config C is not named in" "$HERE/run.sh" --config C --tasks "$T/pub" --out "$T/runc" |
| 278 | refuse "the bytes arm (dropped by r3)" "arm bytes is dropped by protocol r3" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/runc" --arms omegese,bytes |
| 279 | refuse "an unknown prompt mode" "prompt mode 'few' is not one of PARAMS prompt_modes" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/runc" --prompt-mode few |
| 280 | refuse "a held-out run in the one-shot mode" "a held-out run uses the many prompt mode" env EXP445_PARAMS="$T/PARAMSH" "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$T/runc" --prompt-mode one |
| 281 | # G0 (13.4): the stage S sampling gate (vendored, frozen by sha256) plus dev01 at 8 seeds and a repeat of the first. |
| 282 | GS="$(sha256sum < "$HERE/sampling-gate.sh" | cut -d' ' -f1)" |
| 283 | grep -qx "g0_gate_sha256=$GS" "$HERE/PARAMS" && ok "the vendored sampling gate's sha256 equals PARAMS g0_gate_sha256" || bad "vendored sampling gate sha256 vs PARAMS" |
| 284 | SC="$HOME/workspace/aien-sovereign-core" |
| 285 | if git -C "$SC" cat-file -e f881710a:scripts/sampling-gate.sh 2> /dev/null; then |
| 286 | [ "$(git -C "$SC" show f881710a:scripts/sampling-gate.sh | sha256sum | cut -d' ' -f1)" = "$GS" ] && |
| 287 | ok " and is byte for byte aien-sovereign-core f881710a scripts/sampling-gate.sh" || bad "vendored sampling gate differs from sovereign-core f881710a" |
| 288 | else echo "skip: aien-sovereign-core f881710a not present here; the vendored gate is checked against PARAMS only"; fi |
| 289 | # PASS on the fake endpoint: 8 distinct answers, the repeat identical, every reply sampled with its own seed |
| 290 | G0P="$T/g0pass"; cw A "$G0P" |
| 291 | if "$HERE/g0.sh" --config A --out "$G0P" > "$T/g0p.out" 2>&1; then |
| 292 | v="$G0P/g0/verdict.txt" |
| 293 | [ "$(tail -1 "$v")" = "G0 PASS" ] && grep -qx 'derived=gate=PASS distinct=8/8 repeat_identical=yes sampled_own_seed=9/9' "$v" && |
| 294 | [ "$(tail -1 "$G0P/g0/gate/gate.txt")" = "VERDICT PASS" ] && grep -q '^gate d PASS distinct=8/8' "$G0P/g0/gate/gate.txt" && |
| 295 | [ "$(jq -s '[.[].seed] | join(" ")' "$G0P"/g0/r[1-9].req.json)" = "\"$(g0seeds | tr '\n' ' ')446001\"" ] && |
| 296 | jq -s -e 'all(.[]; .temperature == 0.7 and .top_p == 0.8 and .max_tokens == 3072)' "$G0P"/g0/r*.req.json > /dev/null && |
| 297 | jq -e '.messages[1].content | test("\nentry clamp_add\n")' "$G0P/g0/r1.req.json" > /dev/null && cmp -s "$G0P/g0/prompt.system.txt" "$T/p.omegese.many" && |
| 298 | cmp -s "$G0P/g0/sampling-gate.sh" "$HERE/sampling-gate.sh" && grep -qx "gate_sha256=$GS" "$v" && |
| 299 | (cd "$G0P/g0" && sha256sum -c --quiet --strict SHA256SUMS) && grep -q ' gate/d-r8.json$' "$G0P/g0/SHA256SUMS" && |
| 300 | ok "G0 PASS: the sampling gate passes (its gate d on dev01's 8 attempt seeds), the repeat of seed 1 identical, 9/9 sampled with their own seeds; T 0.7, top_p 0.8; all hashed" || |
| 301 | { bad "G0 PASS record"; cat "$v"; } |
| 302 | else bad "g0.sh did not PASS: $(tail -2 "$T/g0p.out")"; fi |
| 303 | refuse "g0.sh over an existing G0 record" "exists: a G0 record is never overwritten" "$HERE/g0.sh" --config A --out "$G0P" |
| 304 | # the same answer for every seed: PASS only when the reported p_repeat makes it plausible (p_repeat^7 >= 0.01) |
| 305 | g0case() { # g0case <name> <sampling.json or -> <expect PASS|FAIL> <derived> [gate.txt line grep] |
| 306 | local d="$T/g0c$((++G0N))"; if [ "$2" = - ]; then rm -f "$A2/sampling.json"; else printf '%s\n' "$2" > "$A2/sampling.json"; fi |
| 307 | EXP445_PARAMS="$T/PARAMS2" cw A "$d"; local e=0; EXP445_G0_LEDGER="$d.ledger" EXP445_PARAMS="$T/PARAMS2" "$HERE/g0.sh" --config A --out "$d" > /dev/null 2>&1 || e=$? |
| 308 | [ "$e" = "$([ "$3" = PASS ] && echo 0 || echo 1)" ] && [ "$(tail -1 "$d/g0/verdict.txt")" = "G0 $3" ] && grep -qx "derived=$4" "$d/g0/verdict.txt" && |
| 309 | { [ -z "${5:-}" ] || grep -q -- "$5" "$d/g0/gate/gate.txt"; } && ok "G0 $3 (exit $e): $1" || { bad "G0 case: $1"; grep derived "$d/g0/verdict.txt"; tail -3 "$d/g0/gate/gate.txt"; } |
| 310 | G0LAST="$d" |
| 311 | } |
| 312 | G0N=0 |
| 313 | g0case "identical answers, p_repeat 0.5 (0.5^7 < 0.01): the seed looks ignored" - FAIL 'gate=FAIL distinct=1/8 repeat_identical=yes sampled_own_seed=9/9' 'gate d FAIL identical replies with p_repeat^7=0.0078125 < 0.01' |
| 314 | g0case "identical answers, p_repeat 0.51 (0.51^7 = 0.00897 < 0.01), boundary" '{"p_repeat": 0.51}' FAIL 'gate=FAIL distinct=1/8 repeat_identical=yes sampled_own_seed=9/9' 'gate d FAIL identical' |
| 315 | g0case "identical answers, p_repeat 0.52 (0.52^7 = 0.0103 >= 0.01): a confident model; distinct 1/8 recorded, not gated" '{"p_repeat": 0.52}' PASS 'gate=PASS distinct=1/8 repeat_identical=yes sampled_own_seed=9/9' 'gate d PASS identical replies explained by confidence' |
| 316 | # the G0 ledger: a FAIL bars the configuration's identity (server and settings) in every run dir (13.4) |
| 317 | ID2="$(g0_ident "$T/PARAMS2" A)" |
| 318 | [ "$(lcat "$T/g0c1.ledger" | cut -f2-5)" = "$(printf 'A\tfake445 test server A\t%s\tFAIL' "$ID2")" ] && [ "$(lcat "$T/g0c1.ledger" | cut -f6)" = "$T/g0c1/g0" ] && |
| 319 | [ "$(lcat "$T/g0c1.ledger" | cut -f7)" = "$(sha256sum < "$T/g0c1/g0/SHA256SUMS" | cut -d' ' -f1)" ] && [ "$(lcat "$T/g0c1.ledger" | cut -f8)" = "$(sha256sum < "$T/PARAMS2" | cut -d' ' -f1)" ] && |
| 320 | ok "G0 ledger: the FAIL appended (config, server, identity, verdict, record dir, SHA256SUMS sha, PARAMS sha)" || bad "G0 ledger line: $(lcat "$T/g0c1.ledger")" |
| 321 | [ "$(lcat "$T/g0c3.ledger" | cut -f2,4,5)" = "$(printf 'A\t%s\tPASS' "$ID2")" ] && [ "$(lcat "$T/g0c3.ledger" | cut -f7)" = "$(sha256sum < "$T/g0c3/g0/SHA256SUMS" | cut -d' ' -f1)" ] && |
| 322 | ok "G0 ledger: a PASS appended too, with its record's SHA256SUMS sha" || bad "G0 ledger PASS line: $(lcat "$T/g0c3.ledger")" |
| 323 | [ "$(find "$T/g0c1.ledger" -type f | wc -l)" = 1 ] && [ "$(find "$T/g0c3.ledger" -type f | wc -l)" = 1 ] && h1="$(lcat "$T/g0c1.ledger" | sha256sum)" && |
| 324 | not env EXP445_G0_LEDGER="$T/g0c1.ledger" bash -c ". '$HERE/reader.sh'; g0_append \"\$1\"" _ "$(lcat "$T/g0c1.ledger" | sed 's/FAIL/PASS/')" 2> "$T/ga.err" && |
| 325 | grep -q "exists already" "$T/ga.err" && [ "$(lcat "$T/g0c1.ledger" | sha256sum)" = "$h1" ] && [ "$(find "$T/g0c1.ledger" -type f | wc -l)" = 1 ] && |
| 326 | ok "G0 ledger: one new file per verdict (evidence stays append-only); an entry with the same name is never overwritten (a FAIL cannot become a PASS)" || bad "G0 ledger files" |
| 327 | g0refuse() { # g0refuse <name> <ledger> <PARAMS>: g0.sh refused with exit 3 and the ledger reason, nothing written |
| 328 | local e=0; rm -rf "$T/g0again"; env EXP445_G0_LEDGER="$2" EXP445_PARAMS="$3" "$HERE/g0.sh" --config A --out "$T/g0again" > /dev/null 2> "$T/g0again.err" || e=$? |
| 329 | [ "$e" = 3 ] && grep -q "a G0 FAIL for config A on this server and settings is in" "$T/g0again.err" && [ ! -e "$T/g0again" ] && |
| 330 | ok "refused (exit 3, nothing written): $1" || bad "$1: exit $e $(tail -1 "$T/g0again.err")" |
| 331 | } |
| 332 | g0refuse "g0.sh in a new run dir after a G0 FAIL for the same config, server and settings" "$T/g0c1.ledger" "$T/PARAMS2" |
| 333 | # an edit elsewhere in PARAMS (a comment, the stop rule) does not lift the bar (the identity is not the PARAMS sha) |
| 334 | { cat "$T/PARAMS2"; echo "# a comment added later"; } | sed 's/^futility_max=.*/futility_max=29/' > "$T/PARAMS2e" |
| 335 | if [ "$(g0_ident "$T/PARAMS2e" A)" = "$ID2" ]; then g0refuse "g0.sh after a FAIL, PARAMS edited outside the configuration's identity" "$T/g0c1.ledger" "$T/PARAMS2e"; else bad "an edit outside the identity changed g0_ident"; fi |
| 336 | refuse "run.sh on a run dir with a G0 PASS while the ledger holds a FAIL for that config" "a G0 FAIL for config A on this server and settings is in" \ |
| 337 | env EXP445_G0_LEDGER="$T/g0c1.ledger" EXP445_PARAMS="$T/PARAMS2e" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/g0c3" |
| 338 | # negative controls: a FAIL for another server, another setting or another config bars nothing |
| 339 | sed 's|^config\.A\.server=.*|config.A.server=fake445 test server A2|' "$T/PARAMS2" > "$T/PARAMS2s" |
| 340 | sed 's|^temperature=.*|temperature=0.6|' "$T/PARAMS2" > "$T/PARAMS2t" |
| 341 | [ "$(EXP445_G0_LEDGER="$T/g0c1.ledger" g0_failed A "$ID2" | cut -f5)" = FAIL ] && |
| 342 | [ -z "$(EXP445_G0_LEDGER="$T/g0c1.ledger" g0_failed A "$(g0_ident "$T/PARAMS2s" A)")" ] && |
| 343 | [ -z "$(EXP445_G0_LEDGER="$T/g0c1.ledger" g0_failed A "$(g0_ident "$T/PARAMS2t" A)")" ] && |
| 344 | [ -z "$(EXP445_G0_LEDGER="$T/g0c1.ledger" g0_failed B "$ID2")" ] && |
| 345 | ok " negative controls: that FAIL does not bar another server, another temperature or config B" || bad "g0_failed matches too much" |
| 346 | EXP445_G0_LEDGER="$T/ledger-elsewhere" g0_ledger | grep -qx "$T/ledger-elsewhere" && [ "$(env -u EXP445_PARAMS EXP445_G0_LEDGER="$T/x" bash -c "ROOT=$ROOT; . $HERE/reader.sh; g0_ledger")" = "$ROOT/evidence/ONE-LAYER-2/g0-ledger" ] && |
| 347 | ok " EXP445_G0_LEDGER is honoured only with EXP445_PARAMS (tests); otherwise the real ledger" || bad "g0_ledger override" |
| 348 | # run.sh needs the record's PASS line on the ledger: a G0 PASS record that the ledger does not know is refused |
| 349 | mkdir -p "$T/empty.ledger" |
| 350 | refuse "run.sh on a G0 PASS record with no PASS line on the ledger" "has no PASS line in" \ |
| 351 | env EXP445_G0_LEDGER="$T/empty.ledger" EXP445_PARAMS="$T/PARAMS2" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/g0c3" |
| 352 | mkdir -p "$T/other.ledger"; lcat "$T/g0c3.ledger" | awk -F"\t" -v OFS="\t" -v z="$(printf "%064d" 0)" '$5 == "PASS" { $7 = z } 1' > "$T/other.ledger/x.tsv" |
| 353 | refuse "run.sh when the ledger's PASS line names another record" "has no PASS line in" \ |
| 354 | env EXP445_G0_LEDGER="$T/other.ledger" EXP445_PARAMS="$T/PARAMS2" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/g0c3" |
| 355 | printf 'config.A.server=fake445\twith a tab\n' > "$T/tab.params"; grep -v '^config\.A\.server=' "$T/PARAMS2" >> "$T/tab.params" |
| 356 | refuse "g0.sh with a tab in the server name (a ledger column)" "must not contain a tab" env EXP445_PARAMS="$T/tab.params" "$HERE/g0.sh" --config A --out "$T/g0tab" |
| 357 | g0case "a server that ignores the seed (reports seed 0, the stage S mutant)" '{"ignore_seed": true, "p_repeat": 0.9}' FAIL 'gate=FAIL distinct=1/8 repeat_identical=yes sampled_own_seed=0/9' 'gate d FAIL a reply was not sampled with its own seed' |
| 358 | g0case "a server that forces greedy decoding (reports mode greedy, the stage S mutant)" '{"force_greedy": true, "p_repeat": 0.9}' FAIL 'gate=FAIL distinct=1/8 repeat_identical=yes sampled_own_seed=0/9' 'gate b 0/4 FAIL' |
| 359 | g0case "the gate's own replays differ (gates a and c fail) while dev01's identical answers are confident (gate d passes)" '{"vary_untasked": true, "p_repeat": 0.9}' FAIL 'gate=FAIL distinct=1/8 repeat_identical=yes sampled_own_seed=9/9' '^gate a 0/4 FAIL' |
| 360 | grep -q '^b p1 distinct=3/3 PASS ' "$G0LAST/g0/gate/gate.txt" && grep -qx 'gate c 0/4 FAIL' "$G0LAST/g0/gate/gate.txt" && grep -q '^gate d PASS identical replies explained by confidence' "$G0LAST/g0/gate/gate.txt" && |
| 361 | ok " (there gate b passes on distinct replies, gate c fails, gate d passes: G0 needs the whole gate)" || bad "gate a/c failure record" |
| 362 | # a forged record: the p_repeat 0.5 FAIL with gate.txt's verdict, verdict.txt's derived and G0 lines edited to PASS and every hash redone |
| 363 | G0X="$T/g0c1"; sed -i '$s/.*/VERDICT PASS/' "$G0X/g0/gate/gate.txt"; (cd "$G0X/g0/gate" && find . -type f ! -name SHA256SUMS | sort | sed 's|^\./||' | xargs sha256sum > SHA256SUMS) |
| 364 | sed -i -e 's/^derived=gate=FAIL/derived=gate=PASS/' -e 's/^gate_exit=.*/gate_exit=0/' -e '$s/.*/G0 PASS/' "$G0X/g0/verdict.txt"; g0hash "$G0X" |
| 365 | refuse "run.sh with a forged G0 (gate verdict, gate exit, derived and G0 lines edited, all hashes redone)" "G0 verdict (gate=PASS distinct=1/8 repeat_identical=yes sampled_own_seed=9/9) differs from its raw files (gate=FAIL" \ |
| 366 | env EXP445_PARAMS="$T/PARAMS2" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$G0X" |
| 367 | # a transport failure writes no record (exit 2): an endpoint that refuses connections |
| 368 | sed "s|^config\.A\.base_url=.*|config.A.base_url=http://127.0.0.1:9/v1|" "$TP" > "$T/PARAMSD" |
| 369 | refuse "g0.sh against an endpoint that does not answer" "the sampling gate could not complete (exit 2" env EXP445_PARAMS="$T/PARAMSD" "$HERE/g0.sh" --config A --out "$T/g0dead" |
| 370 | [ ! -e "$T/g0dead/g0" ] && ok " no G0 record written for a transport failure (the run dir can still be gated)" || bad "transport failure wrote a G0 record" |
| 371 | for s in $(g0seeds); do { echo "Answer for seed $s."; fence "$OMD/dev01.omegese"; } > "$A2/omegese/clamp_add.seed$s"; done |
| 372 | { echo "Another answer."; fence "$OMD/dev01.omegese"; } > "$A2/omegese/clamp_add.seed446001.again"; rm -f "$A2"/seen.* |
| 373 | g0case "8 distinct answers, the sampling gate passes, but the repeat of seed 1 differs" - FAIL 'gate=PASS distinct=8/8 repeat_identical=no sampled_own_seed=9/9' '^VERDICT PASS$' |
| 374 | G0R="$G0LAST" |
| 375 | # run.sh refuses without a G0 PASS for this config, server and PARAMS |
| 376 | cw A "$T/nog0" |
| 377 | refuse "run.sh with no G0 record" "no G0 PASS for config A and this server in .*no G0 record" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/nog0" |
| 378 | refuse "run.sh with a G0 FAIL (repeat differs)" "no G0 PASS for config A .*G0 FAILED (gate=PASS distinct=8/8 repeat_identical=no" env EXP445_PARAMS="$T/PARAMS2" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$G0R" |
| 379 | sed -i '$s/.*/G0 PASS/' "$G0R/g0/verdict.txt"; g0hash "$G0R" |
| 380 | refuse "run.sh with a G0 FAIL whose verdict line was edited to PASS (re-hashed)" "G0 FAILED (gate=PASS distinct=8/8 repeat_identical=no" env EXP445_PARAMS="$T/PARAMS2" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$G0R" |
| 381 | cw B "$T/g0b"; cp -R "$G0P/g0" "$T/g0b/g0" |
| 382 | refuse "run.sh with config A's G0 in a config B run" "G0 was made for another config (A)" "$HERE/run.sh" --config B --tasks "$T/pub" --out "$T/g0b" |
| 383 | cw A "$T/g0s"; cp -R "$G0P/g0" "$T/g0s/g0"; sed -i 's/^server=.*/server=another server/' "$T/g0s/g0/verdict.txt"; g0hash "$T/g0s" |
| 384 | refuse "run.sh with a G0 made on another server (re-hashed)" "G0 was made for another server (another server)" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/g0s" |
| 385 | cw A "$T/g0t"; cp -R "$G0P/g0" "$T/g0t/g0"; sed -i 's/Answer/answer/' "$T/g0t/g0/gate/d-r3.json" |
| 386 | refuse "run.sh with a G0 response edited (not re-hashed)" "G0 SHA256SUMS does not verify" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/g0t" |
| 387 | cw A "$T/g0q"; cp -R "$G0P/g0" "$T/g0q/g0"; jqi() { jq -c "$1" "$2" > "$2.tmp"; mv "$2.tmp" "$2"; }; jqi '.temperature = 0' "$T/g0q/g0/r2.req.json"; g0hash "$T/g0q" |
| 388 | refuse "run.sh with a G0 request at another temperature (re-hashed)" "G0 request 2 is not the frozen G0 request" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/g0q" |
| 389 | cw A "$T/g0g"; cp -R "$G0P/g0" "$T/g0g/g0"; sed -i 's/>= 0.01/>= 0.001/' "$T/g0g/g0/sampling-gate.sh"; g0hash "$T/g0g" |
| 390 | refuse "run.sh with a G0 made by an edited sampling gate (re-hashed)" "G0 was made by another sampling gate script" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/g0g" |
| 391 | mut_make0() { rm -rf "$T/mg"; mkdir -p "$T/mg"; cp "$HERE/g0.sh" "$HERE/PARAMS" "$HERE/reader.sh" "$HERE/sampling-gate.sh" "$T/mg/"; cp -R "$HERE/arms" "$T/mg/arms" |
| 392 | sed -i "s|^ROOT=.*|ROOT=\"$ROOT\"|" "$T/mg/g0.sh"; } |
| 393 | mut_make0; sed -i "s/at_least \"\$chance\" 0.01/at_least \"\$chance\" 0.001/" "$T/mg/sampling-gate.sh"; ! cmp -s "$T/mg/sampling-gate.sh" "$HERE/sampling-gate.sh" || bad "gate mutant: sed changed nothing" |
| 394 | refuse "g0.sh with an edited sampling gate script" "is not the frozen sampling gate" "$T/mg/g0.sh" --config A --out "$T/g0mg" |
| 395 | [ ! -e "$T/g0mg/g0" ] && ok " nothing recorded by the refused G0" || bad "refused G0 wrote a record" |
| 396 | prep A "$T/locked" |
| 397 | refuse "driver on a run dir another driver holds (flock)" "another run.sh holds" flock "$T/locked/.lock" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/locked" --only dev01 |
| 398 | [ ! -e "$T/locked/log.tsv" ] && ok " the refused driver wrote no log.tsv" || bad "locked run dir got a log.tsv" |
| 399 | # a dev run of 3 tasks |
| 400 | R="$T/gens/run-a"; prep A "$R" |
| 401 | "$HERE/run.sh" --config A --tasks "$T/pub" --out "$R" --only dev01,dev02,dev03 > /dev/null 2> "$T/run.err" || { bad "run.sh failed"; tail -5 "$T/run.err"; } |
| 402 | lg() { awk -F'\t' -v s="$1" -v t="$2" -v c="$3" '$1 == s && $2 == t { print $c }' "$R/log.tsv"; } |
| 403 | [ "$(($(wc -l < "$R/log.tsv") - 1))" -eq 6 ] && grep -qx 'protocol=OVERRIDDEN: only' "$R/meta.txt" && grep -qx "base_url=$URL" "$R/meta.txt" && grep -qx 'request_extra={}' "$R/meta.txt" && |
| 404 | grep -qx 'revision=r3' "$R/meta.txt" && grep -qx 'prompt_mode=many' "$R/meta.txt" && grep -qx 'order=attempt,task,arm' "$R/meta.txt" && grep -qx 'server=fake445 test server A' "$R/meta.txt" && |
| 405 | ok "6 generations (3 tasks x 2 arms) logged; meta.txt: revision r3, prompt mode many, order, server, the override recorded" || bad "log/meta" |
| 406 | [ "$(tail -n +2 "$R/log.tsv" | cut -f1,2 | tr '\t' ' ' | paste -sd,)" = "a-omegese-1 dev01,a-text-1 dev01,a-omegese-1 dev02,a-text-1 dev02,a-omegese-1 dev03,a-text-1 dev03" ] && |
| 407 | ok "order: task, then arm within attempt 1" || bad "generation order: $(tail -n +2 "$R/log.tsv" | cut -f1,2 | paste -sd,)" |
| 408 | [ "$(lg a-text-1 dev01 3)" = 1 ] && [ "$(lg a-text-1 dev01 10)" = OK ] && [ "$(lg a-text-1 dev02 3)" = 2 ] && |
| 409 | [ "$(lg a-text-1 dev02 10)" = "REFUSED compiler: SYNTAX at line 1: expected an expression, found ';'" ] && [ "$(lg a-text-1 dev02 11)" = OK ] && |
| 410 | [ "$(lg a-text-1 dev03 10)" = "REQUEST FAILED" ] && [ "$(lg a-text-1 dev03 12)" = - ] && [ "$(grep -c "^try=[012] http=500 curl_exit=0 time_s=[0-9.]* body=r1.err.[012].json msg=" "$R/gen/a-text-1/dev03/r1.transport")" = 3 ] && |
| 411 | ok "text arm: accepted, repaired after a compiler refusal, HTTP 500 retried twice then no candidate" || bad "text arm log" |
| 412 | [ "$(lg a-omegese-1 dev01 10)" = OK ] && [ -f "$R/cands/a-omegese-1/dev01/candidate.oscir" ] && [ "$(lg a-omegese-1 dev02 3)" = 2 ] && |
| 413 | [[ "$(lg a-omegese-1 dev02 10)" == REFUSED* ]] && [ "$(lg a-omegese-1 dev02 11)" = OK ] && |
| 414 | [ "$(lg a-omegese-1 dev03 7)" = length ] && [ ! -e "$R/cands/a-omegese-1/dev03" ] && |
| 415 | ok "omegese arm: accepted, repaired after '$(lg a-omegese-1 dev02 10)', an over-budget answer cut at max_tokens (no candidate)" || bad "omegese arm log" |
| 416 | cmp -s "$R/prompts/omegese.system.txt" "$T/p.omegese.many" && cmp -s "$R/prompts/text.system.txt" "$T/p.text.many" && |
| 417 | ok "run prompts: the many-shot prompts of both arms" || bad "run prompts" |
| 418 | same_budget() { jq -s -e --argjson m "$1" 'all(.[]; .max_tokens == $m and .temperature == 0.7 and .top_p == 0.8)' "$R"/gen/*/*/r*.req.json > /dev/null; } |
| 419 | seeds_equal() { for t in dev01 dev02; do [ "$(jq -s '[.[].seed] | unique | length' "$R"/gen/a-*-1/$t/r1.req.json)" = 1 ] || return 1; done; } |
| 420 | same_budget 3072 && seeds_equal && not same_budget 2048 && ok "every request: max_tokens 3072 (PARAMS), temperature 0.7, top_p 0.8; one seed per task and attempt across the arms" || bad "budget/sampling" |
| 421 | fixmsg() { jq -r '.messages[3].content' "$R/gen/$1/$2/r2.req.json" | tail -1; } |
| 422 | [ "$(fixmsg a-text-1 dev02)" = "Reply with the corrected complete program in one fenced code block." ] && [ "$(fixmsg a-omegese-1 dev02)" = "$(fixmsg a-text-1 dev02)" ] && |
| 423 | ok "repair round: same message format in both arms" || bad "repair message" |
| 424 | (cd "$R" && sha256sum -c --quiet SHA256SUMS) && grep -q ' g0/verdict.txt$' "$R/SHA256SUMS" && ok "every raw request/response and the G0 record hashed in SHA256SUMS (verifies)" || bad "SHA256SUMS" |
| 425 | refuse "resume with other settings" "resuming with different settings" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$R" --only dev01,dev02,dev03 --top-p 0.9 |
| 426 | n0="$(grep -c . "$A/requests.log")" |
| 427 | "$HERE/run.sh" --config A --tasks "$T/pub" --out "$R" --only dev01,dev02,dev03 > /dev/null 2>&1 |
| 428 | [ "$(grep -c . "$A/requests.log")" = "$n0" ] && ok "resume with the same settings sends no request again" || bad "resume repeated requests" |
| 429 | # the full dev matrix in both configurations, and config B in the one-shot mode |
| 430 | FA="$T/gens/full-a" FB="$T/gens/full-b" FBO="$T/gens/one-b" |
| 431 | prep A "$FA"; prep B "$FB"; prep B "$FBO" |
| 432 | "$HERE/run.sh" --config A --tasks "$T/pub" --out "$FA" > /dev/null 2>&1 && "$HERE/run.sh" --config B --tasks "$T/pub" --out "$FB" > /dev/null 2>&1 && |
| 433 | "$HERE/run.sh" --config B --tasks "$T/pub" --out "$FBO" --prompt-mode one > /dev/null 2>&1 || bad "full matrix runs failed" |
| 434 | has_kw() { jq -s -e 'all(.[]; .chat_template_kwargs == {"enable_thinking": false})' "$1"/gen/*/*/r*.req.json > /dev/null; } |
| 435 | no_kw() { jq -s -e 'all(.[]; has("chat_template_kwargs") | not)' "$1"/gen/*/*/r*.req.json > /dev/null; } |
| 436 | has_kw "$FB" && no_kw "$FA" && not has_kw "$FA" && grep -qx 'model=qwen3-8b' "$FB/meta.txt" && grep -qx 'protocol=PARAMS' "$FB/meta.txt" && |
| 437 | ok "config extras: B's in every B request, none in A's" || bad "config extras in requests" |
| 438 | grep -qx 'prompt_mode=one' "$FBO/meta.txt" && grep -qx 'protocol=PARAMS' "$FBO/meta.txt" && cmp -s "$FBO/prompts/omegese.system.txt" "$T/p.omegese.one" && |
| 439 | ok "--prompt-mode one: the one-shot prompts, recorded as prompt_mode=one (not an override)" || bad "one-shot run" |
| 440 | # driver mutants |
| 441 | mut_make() { rm -rf "$T/mut"; mkdir -p "$T/mut"; cp "$HERE/run.sh" "$HERE/PARAMS" "$HERE/reader.sh" "$HERE/g0.sh" "$HERE/sampling-gate.sh" "$T/mut/"; cp -R "$HERE/arms" "$T/mut/arms" |
| 442 | sed -i "s|^ROOT=.*|ROOT=\"$ROOT\"|" "$T/mut/run.sh" "$T/mut/g0.sh"; cp "$T/mut/$1" "$T/mut/$1.orig"; sed -i "$2" "$T/mut/$1" |
| 443 | if cmp -s "$T/mut/$1.orig" "$T/mut/$1"; then bad "mutant: sed changed nothing in $1 ($2)"; return 1; fi; } |
| 444 | mut_run() { mut_make "$2" "$3" || return 1; rm -rf "$T/mr"; rm -f "$T/mut.ledger"; cw "${4:-A}" "$T/mr" # one fresh ledger per mutant, for both scripts |
| 445 | EXP445_G0_LEDGER="$T/mut.ledger" "$T/mut/g0.sh" --config "${4:-A}" --out "$T/mr" > /dev/null 2>&1 || true |
| 446 | EXP445_G0_LEDGER="$T/mut.ledger" "$T/mut/run.sh" --config "${4:-A}" --tasks "$T/pub" --out "$T/mr" --only dev01,dev02,dev03 > /dev/null 2>&1 || true; } |
| 447 | R0="$R"; R="$T/mr" |
| 448 | M="no repair round"; mut_run norepair run.sh 's/if \[ "\$k1" != OK \] \&\& ask/if false \&\& ask/' && { [ "$(lg a-text-1 dev02 11)" = OK ] && bad "mutant survived: $M" || ok " mutant caught: $M"; } |
| 449 | M="budget not sent"; mut_run nobudget reader.sh 's/max_tokens: \$mt, //' && { same_budget 3072 && bad "mutant survived: $M" || ok " mutant caught: $M"; } |
| 450 | M="G0 check skipped"; mut_make run.sh 's/^ die "no G0 PASS/ true "no G0 PASS/' && { rm -rf "$T/mr"; cw A "$T/mr" |
| 451 | "$T/mut/run.sh" --config A --tasks "$T/pub" --out "$T/mr" --only dev01 > /dev/null 2>&1 && [ -f "$T/mr/log.tsv" ] && ok " mutant caught: $M (that run.sh generates without G0; the real one refused above)" || bad "mutant survived: $M"; } |
| 452 | R="$R0" |
| 453 | # transport failure: curl's elapsed time is kept (not 0), every try recorded with HTTP status and curl exit |
| 454 | tpos() { awk '{ for (i = 1; i <= NF; i++) if ($i ~ /^time_s=/) { split($i, q, "="); if (!(q[2] > 0)) bad = 1 } } END { exit bad }' "$1"; } |
| 455 | prep A "$T/dead" |
| 456 | "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/dead" --only dev01 --arms text --base-url http://127.0.0.1:1/v1 > /dev/null 2>&1 || true |
| 457 | DT="$T/dead/gen/a-text-1/dev01/r1.transport" |
| 458 | [ "$(grep -c '^try=[012] http=000 curl_exit=7 time_s=[0-9.]* body=none msg=curl: (7)' "$DT" 2>/dev/null)" = 3 ] && tpos "$DT" && |
| 459 | [ "$(awk -F'\t' 'NR == 2 { print $10 }' "$T/dead/log.tsv")" = "REQUEST FAILED" ] && [ "$(awk -F'\t' 'NR == 2 { print ($9 > 0) }' "$T/dead/log.tsv")" = 1 ] && |
| 460 | { printf 'try=0 http=000 curl_exit=7 time_s=0 body=none msg=\n' > "$T/zero.tr"; not tpos "$T/zero.tr"; } && |
| 461 | ok "refused connection: 3 tries recorded (HTTP 000, curl exit 7, curl's own time > 0), row REQUEST FAILED with wall > 0 (a time of 0 is caught)" || bad "transport failure record" |
| 462 | # interrupted runs: killed after a round-1 response (before round 2) and after the log append (before |
| 463 | # done); resuming sends no request for a received round and leaves no duplicate row |
| 464 | tries() { cat "$1"/gen/*/*/r*.transport | wc -l; } |
| 465 | nreq() { grep -c . "$A/requests.log"; } |
| 466 | kill_seq() { # kill_seq <run.sh> <out>: prints the number of requests the three invocations sent |
| 467 | local n0; rm -rf "$2"; cw A "$2"; cp -R "$FA/g0" "$2/g0"; n0="$(nreq)" |
| 468 | EXP445_TEST_KILL=after-r1:a-text-1:dev02 "$1" --config A --tasks "$T/pub" --out "$2" > /dev/null 2>&1 && return 1 |
| 469 | [ -f "$2/gen/a-text-1/dev02/r1.transport" ] && [ ! -e "$2/gen/a-text-1/dev02/r2.req.json" ] && [ ! -e "$2/gen/a-text-1/dev02/done" ] || return 1 |
| 470 | EXP445_TEST_KILL=after-log:a-omegese-1:dev04 "$1" --config A --tasks "$T/pub" --out "$2" > /dev/null 2>&1 && return 1 |
| 471 | [ "$(awk -F'\t' '$1 == "a-omegese-1" && $2 == "dev04"' "$2/log.tsv" | wc -l)" = 1 ] && [ ! -e "$2/gen/a-omegese-1/dev04/done" ] || return 1 |
| 472 | "$1" --config A --tasks "$T/pub" --out "$2" > /dev/null 2>&1 || true |
| 473 | echo $(($(nreq) - n0)) |
| 474 | } |
| 475 | K="$T/gens/killed-a" |
| 476 | nk="$(kill_seq "$HERE/run.sh" "$K")" || nk=x |
| 477 | nocol9() { tail -n +2 "$1/log.tsv" | cut -f1-8,10-12 | LC_ALL=C sort; } |
| 478 | [ "$nk" = "$(tries "$K")" ] && [ "$nk" = "$(tries "$FA")" ] && [ "$(tail -n +2 "$K/log.tsv" | cut -f1,2 | sort | uniq -d | wc -l)" = 0 ] && |
| 479 | [ "$(nocol9 "$K")" = "$(nocol9 "$FA")" ] && (cd "$K" && sha256sum -c --quiet SHA256SUMS) && |
| 480 | ok "killed twice and resumed: $nk requests in all, the same as one uninterrupted run; 20 rows, no duplicate, same rows" || bad "kill/resume (requests $nk, tries $(tries "$K") vs $(tries "$FA"))" |
| 481 | M="resume requests a committed round again" |
| 482 | mut_make reader.sh 's/if \[ ! -f "\$p.transport" \]; then/if true; then/' && |
| 483 | { n="$(kill_seq "$T/mut/run.sh" "$T/mk")" || n=x; [ "$n" = "$(tries "$FA")" ] && bad "mutant survived: $M" || ok " mutant caught: $M ($n requests)"; } |
| 484 | M="resume appends the row again" |
| 485 | mut_make run.sh 's/if \[ -z "\$have" \]; then/if true; then/' && |
| 486 | { kill_seq "$T/mut/run.sh" "$T/mk" > /dev/null || true; [ "$(tail -n +2 "$T/mk/log.tsv" | wc -l)" = 20 ] && bad "mutant survived: $M" || ok " mutant caught: $M"; } |
| 487 | |
| 488 | # ---- 4. score.sh: provenance first, then the sealed harness, then the results ------------------------ |
| 489 | # the gate of 13.6 at its boundaries (omegese attempt-1, text attempt-1, tasks -> expected) |
| 490 | gres=""; for gc in "8 9 10 PASS" "8 10 10 FAIL" "7 7 10 FAIL" "48 54 60 PASS" "48 55 60 FAIL" "47 47 60 FAIL" "50 40 60 PASS" "60 60 60 PASS" "0 0 0 FAIL"; do |
| 491 | set -- $gc; if gate_config "$1" "$2" "$3"; then r=PASS; else r=FAIL; fi; [ "$r" = "$4" ] || gres="$gres $1/$3 vs $2/$3 gave $r;"; done |
| 492 | [ -z "$gres" ] && ok "gate 13.6 boundaries: 8 vs 9 of 10 PASS, 8 vs 10 FAIL, 7 FAIL; 48 vs 54 of 60 PASS (exactly 10 points), 48 vs 55 FAIL, 47 FAIL" || bad "gate 13.6:$gres" |
| 493 | SC() { EXP445_TEST=1 OLA_ALLOW_DIRTY=1 OLA_EVIDENCE_ROOT="$T/evid" "$HERE/score.sh" "$@"; } |
| 494 | PK=("$T/pack/tasks.tar" "$T/pack/TASKS.sha256"); HPK=("$T/hp/tasks.tar" "$T/hp/TASKS.sha256") |
| 495 | if SC "${PK[@]}" "$FA" "$FB" > "$T/score.out" 2> "$T/score.err"; then |
| 496 | S="$(sed -n 's/^score.sh: results in //p' "$T/score.err")" |
| 497 | row() { awk -F'\t' -v c="$1" -v a="$2" -v k="$3" 'NR == 1 { for (i = 1; i <= NF; i++) h[$i] = i; next } $1 == c && $2 == a { print $h[k] }' "$S/results.tsv"; } |
| 498 | [ "$(row a omegese success_attempt1)" = 3/10 ] && [ "$(row a text success_attempt1)" = 2/10 ] && [ "$(row b omegese success_attempt1)" = 3/10 ] && |
| 499 | [ "$(row a omegese success_attempt1_round1)" = 2/10 ] && [ "$(row a text success_attempt1_round1)" = 1/10 ] && |
| 500 | [ "$(row a text p1_lo)" = "$("$X" wilson 2 10 | cut -d' ' -f2)" ] && [ "$(row a omegese repaired_accepted)" = 1 ] && |
| 501 | [ "$(row a text completion_tokens_total)" = "$(awk -F'\t' '$1 == "a-text-1" { s += $5 + ($6 == "-" ? 0 : $6) } END { printf "%.1f", s }' "$FA/log.tsv")" ] && |
| 502 | head -1 "$S/results.txt" | grep -q '^TEST MODE, NOT EVIDENCE.*exp445 r3 results.*prompt mode many' && |
| 503 | grep -q '^cost config a: omegese / text mean completion tokens per generation x[0-9.]* ' "$S/results.txt" && |
| 504 | grep -qx 'paired attempt 1 config a: both 2, only omegese 1, only text 0, neither 7; exact two-sided McNemar p = 1.000000' "$S/results.txt" && |
| 505 | grep -q 'round 1 only 2/10' "$S/results.txt" && |
| 506 | grep -qx 'gate config a: omegese 3/10, text 2/10: FAIL (needs omegese >= 80% and at most 10 points below text)' "$S/results.txt" && |
| 507 | grep -q '^GATE FAIL ' "$S/results.txt" && grep -q '^provenance OK: 2 runs, 40 generations, configs A,B, prompt mode many$' "$S/validity.txt" && |
| 508 | ok "score.sh: success 3/10 omegese vs 2/10 text (round 1 alone 2/10 vs 1/10), Wilson, cost ratio, paired McNemar, gate 13.6 per config; TEST MODE" || |
| 509 | { bad "score.sh results"; cat "$S/results.txt"; } |
| 510 | awk -F'\t' '$1 == "a-omegese-1" && $2 == "dev03" { print $3, $4 }' "$S/verdicts.tsv" | grep -qx 'REJECT no_candidate' && |
| 511 | awk -F'\t' '$1 == "a-omegese-1" && $2 == "dev04" { print $3 }' "$S/verdicts.tsv" | grep -qx 'ACCEPT' && |
| 512 | ok "score.sh verdicts: the over-budget answer no_candidate, the Omegese gcd ACCEPT" || bad "score verdicts" |
| 513 | else bad "score.sh failed"; tail -5 "$T/score.err"; fi |
| 514 | if SC --configs A "${PK[@]}" "$FA" > "$T/s1.out" 2> /dev/null; then |
| 515 | grep -q '^GATE NOT EVALUATED: configs scored a, the protocol needs a,b' "$T/s1.out" && ok "score.sh --configs A: config A alone is scored, the gate is not evaluated" || bad "subset gate line" |
| 516 | else bad "score.sh --configs A failed"; fi |
| 517 | if SC --configs B "${PK[@]}" "$FBO" > "$T/s2.out" 2> "$T/s2.err"; then |
| 518 | grep -q 'prompt mode one$' "$(sed -n 's/^score.sh: output in //p' "$T/s2.err")/validity.txt" && ok "score.sh: a one-shot run scores against the one-shot prompts" || bad "one-shot score validity line" |
| 519 | else bad "score.sh refused the one-shot run: $(grep INVALID "$T/s2.err" | head -2)"; fi |
| 520 | # negative controls: each provenance failure gives RUN INVALID, exit 1 and no results table |
| 521 | invalid() { # invalid <name> <reason grep> <score.sh args...> |
| 522 | local n="$1" why="$2"; shift 2 |
| 523 | if SC "$@" > "$T/inv.out" 2> "$T/inv.err"; then bad "$n: scored"; return; fi |
| 524 | local s; s="$(sed -n 's/^score.sh: output in //p' "$T/inv.err")" |
| 525 | grep -q '^RUN INVALID' "$T/inv.err" && grep -q -- "$why" "$s/validity.txt" && [ ! -e "$s/results.txt" ] && [ ! -s "$T/inv.out" ] && |
| 526 | ok "RUN INVALID, no table: $n" || { bad "$n: $(head -3 "$T/inv.err")"; } |
| 527 | } |
| 528 | # smut <sed> <check name> <score.sh args...>: score.sh with that check removed must SCORE the case the real |
| 529 | # score.sh refuses (the check is what stops it) |
| 530 | smut() { |
| 531 | local s="$1" n="$2"; shift 2 |
| 532 | mkdir -p "$T/smut"; sed "$s" "$HERE/score.sh" > "$T/smut/score.sh"; chmod +x "$T/smut/score.sh" |
| 533 | sed -i "s|^ROOT=.*|ROOT=\"$ROOT\"|; s|^HERE=.*|HERE=\"$HERE\"|" "$T/smut/score.sh" |
| 534 | if cmp -s "$HERE/score.sh" "$T/smut/score.sh"; then bad "score mutant ($n): sed changed nothing" |
| 535 | elif EXP445_TEST=1 OLA_ALLOW_DIRTY=1 OLA_EVIDENCE_ROOT="$T/evid" "$T/smut/score.sh" "$@" > /dev/null 2>&1; then ok " mutant caught: score.sh without $n scores it" |
| 536 | else bad " score mutant ($n): still refused, that check is not the only guard tested"; fi |
| 537 | } |
| 538 | cpr() { rm -rf "$T/neg"; mkdir -p "$T/neg"; cp -R "$FA" "$T/neg/a"; cp -R "$FB" "$T/neg/b"; } |
| 539 | NA=(--configs A "${PK[@]}" "$T/neg/a"); NB=(--configs B "${PK[@]}" "$T/neg/b") |
| 540 | cpr; printf ' ' >> "$T/neg/a/cands/a-text-1/dev01/candidate.osc" |
| 541 | invalid "tampered candidate" "a-text-1 dev01 candidate in cands/ does not match" "${NA[@]}" |
| 542 | cpr; sed -i 's/"stop"/"stop" /' "$T/neg/b/gen/b-text-1/dev01/r1.resp.json" |
| 543 | invalid "tampered response" "SHA256SUMS does not verify" "${NB[@]}" |
| 544 | cpr; rm -rf "$T/neg/b/gen/b-omegese-1/dev07" "$T/neg/b/cands/b-omegese-1/dev07"; awk -F'\t' '!($1 == "b-omegese-1" && $2 == "dev07")' "$FB/log.tsv" > "$T/neg/b/log.tsv"; rehash "$T/neg/b" |
| 545 | invalid "missing generation (re-hashed)" "1 of 20 generations missing (first: b-omegese-1 dev07)" "${NB[@]}" |
| 546 | cpr; awk -F'\t' -v OFS='\t' '$1 == "b-omegese-1" { $5 = 1 } { print }' "$FB/log.tsv" > "$T/neg/b/log.tsv" |
| 547 | invalid "edited token column (not re-hashed)" "b: SHA256SUMS does not verify" "${NB[@]}" |
| 548 | rehash "$T/neg/b" |
| 549 | invalid "edited token column (re-hashed: only the cross-check sees it)" "log.tsv differs from the rows re-derived from the raw files (first: b-omegese-1" "${NB[@]}" |
| 550 | smut 's/^ if ! cmp -s "\$W\/derived_s" "\$W\/log_s"; then$/ if false; then/' "the log.tsv cross-check" "${NB[@]}" |
| 551 | cpr; jqi '.usage.prompt_tokens = "a[$(touch '"$T"'/pwned)]"' "$T/neg/b/gen/b-text-1/dev01/r1.resp.json" |
| 552 | awk -F'\t' -v OFS='\t' '$1 == "b-text-1" && $2 == "dev01" { $4 = "BAD" } { print }' "$FB/log.tsv" > "$T/neg/b/log.tsv"; rehash "$T/neg/b" |
| 553 | invalid "non-integer token count in a response (re-hashed)" "b-text-1 dev01 token counts in the response are not non-negative integers (BAD" "${NB[@]}" |
| 554 | [ ! -e "$T/pwned" ] && ok " the token payload was never evaluated" || bad "token payload evaluated by the shell" |
| 555 | cpr; awk -F'\t' -v OFS='\t' '$1 == "a-omegese-1" && $2 == "dev01" { $12 = "0000" } { print }' "$FA/log.tsv" > "$T/neg/a/log.tsv"; rehash "$T/neg/a" |
| 556 | invalid "log candidate hash edited (re-hashed)" "log.tsv differs from the rows re-derived from the raw files (first: a-omegese-1 dev01)" "${NA[@]}" |
| 557 | rm -rf "$T/hov"; prep A "$T/hov"; "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/hov" --temperature 0.6 > /dev/null 2>&1 |
| 558 | sed -i 's/^protocol=.*/protocol=PARAMS/; s/^temperature=.*/temperature=0.7/' "$T/hov/meta.txt"; rehash "$T/hov" |
| 559 | invalid "override hidden by editing meta.txt (re-hashed)" "a-omegese-1 dev01 r1 request differs from the frozen request in: temperature" --configs A "${PK[@]}" "$T/hov" |
| 560 | cpr; jqi '.seed += 1' "$T/neg/a/gen/a-text-1/dev01/r1.req.json"; rehash "$T/neg/a" |
| 561 | invalid "wrong seed (re-hashed)" "a-text-1 dev01 r1 request differs from the frozen request in: seed" "${NA[@]}" |
| 562 | cpr; jqi 'del(.chat_template_kwargs)' "$T/neg/b/gen/b-text-1/dev01/r1.req.json"; rehash "$T/neg/b" |
| 563 | invalid "B request without its extra field (re-hashed)" "b-text-1 dev01 r1 request differs from the frozen request in: chat_template_kwargs" "${NB[@]}" |
| 564 | cpr; cp "$FA"/gen/a-text-1/dev02/r2.{req.json,transport,resp.json} "$T/neg/a/gen/a-text-1/dev01/"; rehash "$T/neg/a" |
| 565 | invalid "round 2 without a round-1 refusal (re-hashed)" "a-text-1 dev01 has a round 2 without a round-1 refusal" "${NA[@]}" |
| 566 | cpr; rm "$T/neg/a/gen/a-omegese-1/dev02"/r2.*; rehash "$T/neg/a" |
| 567 | invalid "refused round 1 without its repair round (re-hashed)" "a-omegese-1 dev02 round 1 was refused (REFUSED" "${NA[@]}" |
| 568 | cpr; sed -i '$d' "$T/neg/a/gen/a-text-1/dev03/r1.transport"; rehash "$T/neg/a" |
| 569 | invalid "failed round with a try missing (re-hashed)" "a-text-1 dev03 failed round r1 has 2 tries, the protocol makes 3" "${NA[@]}" |
| 570 | cpr; sed -i '1s/: OK$/: FAILED/' "$T/neg/a/weights.check"; rehash "$T/neg/a" |
| 571 | invalid "a FAILED weight line (re-hashed)" "a: weights.check / server.json missing or not all OK for config A" "${NA[@]}" |
| 572 | sed 's/^temperature=.*/temperature=0.6/' "$TP" > "$T/PARAMS3" |
| 573 | EXP445_PARAMS="$T/PARAMS3" invalid "changed PARAMS" "PARAMS changed since generation" "${PK[@]}" "$FA" "$FB" |
| 574 | invalid "override flag used" "settings overridden on the command line (OVERRIDDEN: only)" --configs A "${PK[@]}" "$R" |
| 575 | invalid "same run twice" "generations appear more than once" "${PK[@]}" "$FA" "$FA" "$FB" |
| 576 | invalid "config outside --configs" "config 'B' is not one of the configs scored (A)" --configs A "${PK[@]}" "$FA" "$FB" |
| 577 | cpr; printf ' ' >> "$T/neg/a/cands/a-text-1/dev01/candidate.osc" |
| 578 | smut 's/\[ "\$n" -le 1 \] && \[ "\$got" = "\$want" \] ||/true ||/' "the cands/ check" "${NA[@]}" |
| 579 | # r3-specific provenance: revision, order, prompt mode, G0 |
| 580 | cpr; sed -i '/^revision=r3$/d' "$T/neg/a/meta.txt"; rehash "$T/neg/a" |
| 581 | invalid "an r2 run (meta.txt without revision=r3, re-hashed)" "not an r3 run (meta.txt has no revision=r3): r1/r2 runs are not scored" "${NA[@]}" |
| 582 | cpr; sed -i 's/^order=.*/order=arm,attempt,task/' "$T/neg/a/meta.txt"; rehash "$T/neg/a" |
| 583 | invalid "another generation order (re-hashed)" "generation order is not attempt,task,arm" "${NA[@]}" |
| 584 | invalid "a many-shot and a one-shot run scored together" "prompt mode one differs from the other runs' (many)" "${PK[@]}" "$FA" "$FBO" |
| 585 | rm -rf "$T/neg"; mkdir -p "$T/neg"; cp -R "$FBO" "$T/neg/b"; sed -i 's/^prompt_mode=one$/prompt_mode=many/' "$T/neg/b/meta.txt"; rehash "$T/neg/b" |
| 586 | invalid "a one-shot run relabelled many (re-hashed)" "arm omegese prompt differs from the current arm documents and many examples" "${NB[@]}" |
| 587 | cpr; rm -rf "$T/neg/a/g0"; rehash "$T/neg/a" |
| 588 | invalid "no G0 record (re-hashed)" "no G0 PASS for config A and its server: no G0 record" "${NA[@]}" |
| 589 | smut 's/|| inval "\$r: no G0 PASS/|| true "/; s/|| inval "\$r: the G0 record is not the one/|| true "/' "the G0 checks (PASS and run binding)" "${NA[@]}" |
| 590 | cpr; sed -i 's/Answer/answer/' "$T/neg/a/g0/gate/d-r4.json"; rehash "$T/neg/a" |
| 591 | invalid "a G0 response edited (run re-hashed, G0 not)" "G0 SHA256SUMS does not verify" "${NA[@]}" |
| 592 | cpr; rm -rf "$T/neg/a/g0"; cp -R "$G0R/g0" "$T/neg/a/g0"; rehash "$T/neg/a" |
| 593 | invalid "a G0 made with another PARAMS" "G0 was made for another base_url" "${NA[@]}" |
| 594 | cpr; rm -rf "$T/neg/a/g0"; cp -R "$G0P/g0" "$T/neg/a/g0"; rehash "$T/neg/a" |
| 595 | invalid "another G0 PASS swapped in after generation (re-hashed)" "the G0 record is not the one this run was generated under" "${NA[@]}" |
| 596 | smut 's/|| inval "\$r: the G0 record is not the one/|| true "/' "the run's G0 record check" "${NA[@]}" |
| 597 | # the G0 ledger at scoring: a FAIL for the config's identity, or no PASS line for the run's G0 record |
| 598 | cpr; mkdir -p "$T/fail.ledger"; { lcat "$T/g0-ledger"; printf '20261015T000000Z\tA\tfake445 test server A\t%s\tFAIL\telsewhere/g0\t%064d\t-\n' "$(g0_ident "$TP" A)" 0; } > "$T/fail.ledger/all.tsv" |
| 599 | EXP445_G0_LEDGER="$T/fail.ledger" invalid "a G0 FAIL on the ledger for config A's server and settings" "a G0 FAIL for config A on this server and settings is in" "${NA[@]}" |
| 600 | EXP445_G0_LEDGER="$T/fail.ledger" smut 's/\[ -z "\$fl" \] || inval "\$r: a G0 FAIL/true "/' "the ledger FAIL check" "${NA[@]}" |
| 601 | EXP445_G0_LEDGER="$T/empty.ledger" invalid "the run's G0 PASS record has no PASS line on the ledger" "has no PASS line in" "${NA[@]}" |
| 602 | rm -rf "$T/rsw"; cp -R "$FA" "$T/rsw"; rm -rf "$T/rsw/g0"; cp -R "$G0P/g0" "$T/rsw/g0" |
| 603 | refuse "run.sh resuming a run whose G0 record was swapped" "resuming with different settings" "$HERE/run.sh" --config A --tasks "$T/pub" --out "$T/rsw" |
| 604 | cpr; cp "$T/neg/a/gen/a-omegese-1/dev02/r1.req.json" "$T/neg/a/gen/a-omegese-1/dev02/r10.req.json"; rehash "$T/neg/a" |
| 605 | invalid "a round 10 request in a generation (re-hashed)" "has a round other than 1 and 2" "${NA[@]}" |
| 606 | if SC "${PK[@]}" "$K" "$FB" > /dev/null 2> "$T/ks.err"; then |
| 607 | grep -q '^provenance OK: 2 runs, 40 generations' "$(sed -n 's/^score.sh: output in //p' "$T/ks.err")/validity.txt" && |
| 608 | ok "score.sh: the killed-and-resumed run is valid (provenance OK, no duplicate)" || bad "killed run validity line" |
| 609 | else bad "score.sh refused the killed-and-resumed run: $(grep INVALID "$T/ks.err" | head -2)"; fi |
| 610 | |
| 611 | # ---- 5. Stage 1 stop rule on a held-out-like pack (h01..h04, heldout_tasks=4, attempts 2) ------------- |
| 612 | # omegese attempt 1 on h01..h04 = 3/4: futility_max 3 -> STOP, futility_max 2 -> CONTINUE |
| 613 | export EXP445_PARAMS="$T/PARAMSH" |
| 614 | H1="$T/gens/h-stop"; prep A "$H1" |
| 615 | "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$H1" > /dev/null 2> "$T/h1.err" || bad "held-out run attempt 1 failed: $(tail -2 "$T/h1.err")" |
| 616 | [ "$(tail -n +2 "$H1/log.tsv" | cut -f1 | sort -u | paste -sd,)" = "a-omegese-1,a-text-1" ] && grep -q 'score attempt 1 with tools/exp445/score.sh --interim' "$T/h1.err" && |
| 617 | (cd "$H1" && sha256sum -c --quiet SHA256SUMS) && ok "held-out run: the driver stops after attempt 1 and asks for the interim score (8 generations, hashed)" || bad "held-out pause after attempt 1" |
| 618 | if SC --interim --configs A "${HPK[@]}" "$H1" > "$T/hi.out" 2> "$T/hi.err"; then |
| 619 | SI="$(sed -n 's/^score.sh: results in //p' "$T/hi.err")"; FUT="$SI/futility.txt" |
| 620 | grep -q "^run=$H1 config=A omegese_attempt1=3/4 futility_max=3 a1_rows_sha256=[0-9a-f]\{64\} decision=STOP$" "$FUT" && |
| 621 | head -1 "$SI/results.txt" | grep -q 'INTERIM: attempt 1 only' && grep -q '^GATE NOT EVALUATED: interim' "$SI/results.txt" && |
| 622 | ok "score.sh --interim: attempt 1 scored, futility.txt: omegese 3/4 <= 3 -> decision=STOP, gate not evaluated" || { bad "interim score"; cat "$FUT" "$SI/results.txt"; } |
| 623 | else bad "score.sh --interim failed: $(grep INVALID "$T/hi.err" | head -2)"; FUT=/nonexistent; fi |
| 624 | sed 's/a1_rows_sha256=[0-9a-f]*/a1_rows_sha256=0000/' "$FUT" > "$T/fut.bad" |
| 625 | refuse "run.sh --futility made from other attempt-1 rows" "was made from other attempt-1 rows than this run" "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$H1" --futility "$T/fut.bad" |
| 626 | rm -rf "$T/h-cont-mut"; cp -R "$H1" "$T/h-cont-mut"; sed "s|^run=$H1 |run=$T/h-cont-mut |; s/decision=STOP/decision=CONTINUE/" "$FUT" > "$T/fut.cont" |
| 627 | "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$H1" --futility "$FUT" > /dev/null 2> "$T/h1b.err" || bad "run.sh --futility STOP failed" |
| 628 | [ "$(tail -n +2 "$H1/log.tsv" | wc -l)" = 8 ] && grep -q 'stop rule fired, attempts 2 and later are not run' "$T/h1b.err" && |
| 629 | ok "run.sh --futility (decision STOP): attempts 2 and later not run" || bad "STOP decision not followed by run.sh" |
| 630 | if SC --configs A "${HPK[@]}" "$H1" > "$T/hf.out" 2> "$T/hf.err"; then |
| 631 | grep -qx 'stop rule config a (omegese attempt 1 <= 3): STOP, attempts 2 and later not run' "$T/hf.out" && |
| 632 | ok "final score of the stopped run: valid, the stop rule recorded in results.txt" || { bad "stopped run results"; cat "$T/hf.out"; } |
| 633 | else bad "score.sh refused the stopped held-out run: $(grep INVALID "$T/hf.err" | head -2)"; fi |
| 634 | # a driver that ignores the decision (fed CONTINUE although the rule fired) runs attempt 2: score.sh refuses |
| 635 | "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$T/h-cont-mut" --futility "$T/fut.cont" > /dev/null 2>&1 || true |
| 636 | [ "$(tail -n +2 "$T/h-cont-mut/log.tsv" | wc -l)" = 16 ] || bad "CONTINUE mutant did not run attempt 2" |
| 637 | invalid "attempts run although the stop rule fired" "the stop rule fired (omegese attempt 1 3/4 <= 3) but attempts 2..2 were run" --configs A "${HPK[@]}" "$T/h-cont-mut" |
| 638 | # CONTINUE: futility_max 2 |
| 639 | export EXP445_PARAMS="$T/PARAMSC" |
| 640 | H2="$T/gens/h-cont"; prep A "$H2" |
| 641 | "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$H2" > /dev/null 2>&1 || bad "held-out run (CONTINUE) attempt 1 failed" |
| 642 | invalid "attempt 2 missing although the stop rule did not fire" "attempts 2..2 are missing but the stop rule did not fire (omegese attempt 1 3/4 > 2)" --configs A "${HPK[@]}" "$H2" |
| 643 | if SC --interim --configs A "${HPK[@]}" "$H2" > /dev/null 2> "$T/hi2.err"; then |
| 644 | FUT2="$(sed -n 's/^score.sh: results in //p' "$T/hi2.err")/futility.txt" |
| 645 | # the resume after attempt 1 happens at a later commit (the G0 ledger and the interim scores are committed |
| 646 | # between): the tools must be what decides, not the commit id. Negative control first: a run whose |
| 647 | # commit has other tools (the repository's first commit) is refused. |
| 648 | cp "$H2/meta.txt" "$T/h2meta"; MC="$(sed -n 's/^commit=//p' "$H2/meta.txt")" |
| 649 | sed -i "s/^commit=.*/commit=$(git -C "$ROOT" rev-list --max-parents=0 HEAD | tail -n 1)${MC#"${MC%-dirty}"}/" "$H2/meta.txt" |
| 650 | refuse "resume when the tools changed since the run's commit" "tool files differ" "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$H2" --futility "$FUT2" |
| 651 | cp "$T/h2meta" "$H2/meta.txt" |
| 652 | if [ "$MC" = "${MC%-dirty}" ]; then |
| 653 | # a later commit with the very same tree, like the ledger commit (an object only; no ref moves) |
| 654 | LC="$(git -C "$ROOT" -c user.name=exp445-test -c user.email=exp445-test@invalid commit-tree "HEAD^{tree}" -p HEAD -m "exp445 test: a later commit, same tools")" |
| 655 | sed -i "s/^commit=.*/commit=$LC/" "$H2/meta.txt" |
| 656 | else echo "skip resume across commits (tree dirty; meta_resume unit tests cover it, CI runs it clean)"; fi |
| 657 | grep -q "decision=CONTINUE$" "$FUT2" && "$HERE/run.sh" --config A --tasks "$T/hpub" --out "$H2" --futility "$FUT2" > /dev/null 2> "$T/h2b.err" && |
| 658 | [ "$(tail -n +2 "$H2/log.tsv" | wc -l)" = 16 ] && |
| 659 | [ "$(tail -n +2 "$H2/log.tsv" | cut -f1,2 | tr '\t' ' ' | paste -sd,)" = "$(for at in 1 2; do for t in h01 h02 h03 h04; do for a in omegese text; do printf 'a-%s-%s %s,' "$a" "$at" "$t"; done; done; done | sed 's/,$//')" ] && |
| 660 | ok "decision CONTINUE: attempt 2 run; 16 generations in the order attempt, then task, then arm" || bad "CONTINUE run: $(tail -n +2 "$H2/log.tsv" | cut -f1,2 | paste -sd, | head -c 300) / $(tail -n 3 "$T/h2b.err" 2> /dev/null | tr "\n" " ")" |
| 661 | if SC --configs A "${HPK[@]}" "$H2" > "$T/hc.out" 2> "$T/hc.err"; then |
| 662 | grep -qx 'stop rule config a (omegese attempt 1 <= 2): CONTINUE' "$T/hc.out" && ok "final score of the continued run: valid, stop rule CONTINUE" || { bad "continued run results"; cat "$T/hc.out"; } |
| 663 | grep -qx 'distinct candidates config a arm omegese: 1.00 per task over 2.00 attempts; every attempt identical on 4 of 4 tasks with 2+ attempts' "$T/hc.out" && |
| 664 | grep -qx 'distinct candidates config a arm text: 1.25 per task over 2.00 attempts; every attempt identical on 3 of 4 tasks with 2+ attempts' "$T/hc.out" && |
| 665 | ok " distinct candidates per task reported (13.5): text 1.25 (h01 attempt 2 is another program), omegese 1.00 (the same program every attempt)" || { bad "distinct candidates line"; grep distinct "$T/hc.out"; } |
| 666 | else bad "score.sh refused the continued held-out run: $(grep INVALID "$T/hc.err" | head -2)"; fi |
| 667 | else bad "score.sh --interim (CONTINUE) failed"; fi |
| 668 | unset EXP445_PARAMS |
| 669 | # meta_resume on a scratch repository: the resume rule by itself, whatever state this checkout is in |
| 670 | MR="$T/mr"; mkdir -p "$MR/tools" "$MR/evidence"; git -C "$MR" init -q |
| 671 | gc_() { git -C "$MR" add -A && git -C "$MR" -c user.name=t -c user.email=t@t commit -q -m "$1" && git -C "$MR" rev-parse HEAD; } |
| 672 | echo a > "$MR/tools/x"; C1="$(gc_ one)"; echo l > "$MR/evidence/ledger"; C2="$(gc_ ledger)"; echo b > "$MR/tools/x"; C3="$(gc_ tools)" |
| 673 | mm() { printf 'config=A\nmodel=m\ncommit=%s\ntasks=4\n' "$1" > "$T/mr.$2"; } |
| 674 | mrok() { mm "$2" a; mm "$3" b; [ -n "${4:-}" ] && sed -i 's/^tasks=4$/tasks=5/' "$T/mr.b"; meta_resume "$MR" "$T/mr.a" "$T/mr.b" > "$T/mr.why"; } |
| 675 | mrok x "$C1" "$C1" && ok "meta_resume: identical meta.txt resumes" || bad "meta_resume identical" |
| 676 | mrok x "$C1" "$C2" && ok "meta_resume: a later commit that touches only evidence resumes (the G0 ledger commit)" || bad "meta_resume ledger commit: $(cat "$T/mr.why")" |
| 677 | mrok x "$C1" "$C3" && bad "meta_resume accepted changed tools" || { grep -q "tool files differ" "$T/mr.why" && ok "meta_resume: changed tool files refused (negative control)" || bad "meta_resume tools reason: $(cat "$T/mr.why")"; } |
| 678 | mrok x "$C1" "$C2-dirty" && bad "meta_resume accepted a dirty tree across commits" || { grep -q "dirty" "$T/mr.why" && ok "meta_resume: a dirty tree across commits refused" || bad "meta_resume dirty reason"; } |
| 679 | mrok x "$C1" "$C2" y && bad "meta_resume accepted another setting" || { grep -q "settings differ" "$T/mr.why" && ok "meta_resume: another setting refused even with the same tools" || bad "meta_resume settings reason"; } |
| 680 | mrok x "$C1" "0000000000000000000000000000000000000000" && bad "meta_resume accepted an unknown commit" || ok "meta_resume: an unknown commit refused" |
| 681 | if mrok x HEAD "$C2"; then bad "meta_resume accepted a revision name (commit=HEAD)" |
| 682 | elif grep -q "not a full commit id" "$T/mr.why"; then ok "meta_resume: a revision name (commit=HEAD) refused" |
| 683 | else bad "meta_resume revision name reason: $(cat "$T/mr.why")"; fi |
| 684 | echo |
| 685 | if [ "$fails" -eq 0 ]; then echo "test-exp445: PASS"; else echo "test-exp445: FAIL ($fails)"; exit 1; fi |