aien
aien-dev/aien
Brought by drakestapleton
aien / tests / goal_microjobs / gate.sh
| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | # Allen #13 offline gate: build the seeded .om microjob kernel, drive a 12-node objective |
| 4 | # through the persistent journal in separate processes (restart, partial completion, |
| 5 | # model failure, correction, refusal, cancellation, budgets), refuse plan and event |
| 6 | # mutants, then show that source mutations of the kernel are caught by the probes. |
| 7 | # Workers and verifiers below are synthetic fixtures: no model is called, nothing leaves |
| 8 | # the run directory. Usage: OMEGA_WORKTREE=... bash tests/goal_microjobs/gate.sh |
| 9 | set -euo pipefail |
| 10 | |
| 11 | repo=$(cd "$(dirname "$0")/../.." && pwd) |
| 12 | : "${OMEGA_WORKTREE:?Set OMEGA_WORKTREE to the isolated seeded-Omega compiler worktree}" |
| 13 | run_root=${GM_RUN_ROOT:-"$repo/evidence/goal-microjobs"} |
| 14 | mkdir -p "$run_root" |
| 15 | run=$(mktemp -d "$run_root/offline-$(date -u +%Y%m%dT%H%M%SZ)-XXXXXX") |
| 16 | work=$(mktemp -d "${TMPDIR:-/tmp}/allen-gm-XXXXXX") |
| 17 | trap 'rm -rf "$work"' EXIT |
| 18 | mkdir -p "$work/probes" |
| 19 | log="$run/transcript.log" |
| 20 | : > "$log" |
| 21 | |
| 22 | drv="$repo/scripts/goal_microjobs/microjobs.sh" |
| 23 | export GM_KERNEL="$work/kernel" |
| 24 | bash "$repo/scripts/goal_microjobs/build.sh" "$repo/src/goal_microjobs/kernel.om" "$GM_KERNEL" >> "$log" |
| 25 | |
| 26 | checks=0 |
| 27 | die() { echo "FAIL: $*" | tee -a "$log" >&2; exit 1; } |
| 28 | ok() { checks=$((checks + 1)); printf 'ok %d %s\n' "$checks" "$*" >> "$log"; } |
| 29 | dw() { bash "$drv" digest "$1"; } |
| 30 | |
| 31 | # identities: owner 7, Allen runtime 9, verifiers 5 (recompute) and 6 (checker), |
| 32 | # workers 20 (native compute), 21 (reflex route), 22 (student route) |
| 33 | OWNER=7 RT=9 V5=5 V6=6 W20=20 W21=21 W22=22 |
| 34 | |
| 35 | # plan fields after "2 id": kind op route profile effect in out reqin reqout vkind |
| 36 | # verifier rclass maxatt tenant time_ms required d0 d1 d2 d3 ndeps deps... |
| 37 | node() { local id=$1 rest=$2 tag=$3 deps=$4; printf '2 %s %s %s %s\n' "$id" "$rest" "$(dw "operand:$tag")" "$deps"; } |
| 38 | # header: abi objective(4) owner runtime ceiling n terminal maxatt maxmodel maxtok budin budout budtime |
| 39 | HDR_ABI=1 HDR_CEIL=2 HDR_MAXATT=24 HDR_MAXMODEL=8 HDR_MAXTOK=2000 HDR_BUDIN=1000 |
| 40 | plan() { |
| 41 | printf '1 %s %s %s %s %s 12 11 %s %s %s %s 256 20000\n' "$HDR_ABI" "$(dw 'objective:allen13-fixture-weekly-budget-note')" \ |
| 42 | "$OWNER" "$RT" "$HDR_CEIL" "$HDR_MAXATT" "$HDR_MAXMODEL" "$HDR_MAXTOK" "$HDR_BUDIN" |
| 43 | node 1 "1 1 0 0 1 0 0 0 0 1 5 2 2 7 100 1" n1 "0" |
| 44 | node 2 "1 3 0 0 1 0 0 0 0 1 5 2 2 7 100 1" n2 "0" |
| 45 | node 3 "1 1 0 0 1 0 0 0 0 1 5 2 2 7 100 1" n3-v1 "0" |
| 46 | node 4 "2 1 1 1 0 60 12 40 8 2 6 2 3 7 2000 1" n4 "0" |
| 47 | node 5 "2 2 2 2 0 120 30 100 20 2 6 2 3 7 4000 1" n5 "1 4" |
| 48 | node 6 "2 3 3 4 0 500 120 300 64 3 6 2 2 7 8000 0" n6 "1 4" |
| 49 | node 7 "1 1 0 0 1 0 0 0 0 1 5 2 2 7 100 1" n7 "3 1 2 3" |
| 50 | node 8 "1 4 0 0 1 0 0 0 0 1 5 2 2 7 100 1" n8 "2 5 7" |
| 51 | node 9 "2 4 1 2 0 120 30 90 24 2 6 2 3 7 4000 1" n9 "2 7 8" |
| 52 | node 10 "1 6 0 0 1 0 0 0 0 1 5 2 2 7 100 1" n10 "2 7 9" |
| 53 | node 11 "1 3 0 0 1 0 0 0 0 1 5 2 2 7 100 1" n11 "3 8 9 10" |
| 54 | node 12 "1 3 0 0 2 0 0 0 0 1 5 3 1 7 100 1" n12 "1 11" |
| 55 | } |
| 56 | |
| 57 | S="" |
| 58 | z4="0 0 0 0" |
| 59 | # ev TYPE NODE ATTEMPT GEN ISSUER VERDICT "D0 D1 D2 D3" TOK TIME |
| 60 | accept() { local out; out=$(bash "$drv" propose "$S" "$1" "$2" "$3" "$4" "$5" "$6" $7 "$8" "$9") || die "expected ACCEPT for $*: $out"; ok "accept $*"; } |
| 61 | reject() { |
| 62 | local name=$1 code=$2; shift 2 |
| 63 | local seq=$(( $(wc -l < "$S/journal") + 1 )) |
| 64 | { cat "$S/plan" "$S/journal"; printf '3 %s %s %s %s %s %s %s %s %s %s\n' "$seq" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"; } > "$work/probes/$name.in" |
| 65 | printf '%s\n' "$code" > "$work/probes/$name.code" |
| 66 | local out rc |
| 67 | set +e |
| 68 | out=$(bash "$drv" propose "$S" "$1" "$2" "$3" "$4" "$5" "$6" $7 "$8" "$9") |
| 69 | rc=$? |
| 70 | set -e |
| 71 | test "$rc" -eq "$code" || die "$name: expected reject $code, got $rc ($out)" |
| 72 | ok "reject $name $code" |
| 73 | } |
| 74 | status() { bash "$drv" status "$S"; } |
| 75 | nodef() { status | awk -v id="$1" -v f="$2" '$1 == 101 && $2 == id { print $f }'; } |
| 76 | objf() { status | awk -v f="$1" '$1 == 100 { print $f }'; } |
| 77 | expect_node() { local got; got=$(nodef "$1" 3)/$(nodef "$1" 4)/$(nodef "$1" 5); test "$got" = "$2" || die "node $1 state/gen/attempts $got, want $2"; ok "node $1 = $2"; } |
| 78 | expect_obj() { local got; got=$(objf 2); test "$got" = "$1" || die "objective status $got, want $1"; ok "objective status $1"; } |
| 79 | |
| 80 | # compute worker and an independent recompute verifier (different arithmetic path) |
| 81 | work_value() { echo $(( $1 )); } |
| 82 | verify_value() { expr "$1" "$2" "$3"; } |
| 83 | run_compute() { # node gen attempt expr-for-worker tag |
| 84 | local n=$1 g=$2 a=$3 val=$4 tag=$5 |
| 85 | accept 1 "$n" "$a" "$g" $W20 0 "$z4" 0 0 |
| 86 | local d; d=$(dw "n$n:$tag:$val") |
| 87 | accept 2 "$n" "$a" "$g" $W20 0 "$d" 0 3 |
| 88 | accept 3 "$n" "$a" "$g" $V5 1 "$d" 0 0 |
| 89 | } |
| 90 | |
| 91 | echo '== plan admission and plan mutants' >> "$log" |
| 92 | plan > "$work/plan" |
| 93 | S="$work/state-a" |
| 94 | bash "$drv" init "$S" "$work/plan" >> "$log" |
| 95 | ok "init acceptance plan" |
| 96 | expect_obj 1 |
| 97 | |
| 98 | plan_mutant() { # name code awk-program |
| 99 | local name=$1 code=$2 prog=$3 rc |
| 100 | plan | awk "$prog" > "$work/probes/plan-$name.in" |
| 101 | printf '%s\n' "$code" > "$work/probes/plan-$name.code" |
| 102 | set +e |
| 103 | bash "$drv" init "$work/m-$name" "$work/probes/plan-$name.in" > /dev/null |
| 104 | rc=$? |
| 105 | set -e |
| 106 | test "$rc" -eq "$code" || die "plan mutant $name: expected $code, got $rc" |
| 107 | test ! -e "$work/m-$name/plan" || die "plan mutant $name left a plan" |
| 108 | ok "plan mutant $name $code" |
| 109 | } |
| 110 | plan_mutant old-abi 10 'NR == 1 { $2 = 0 } { print }' |
| 111 | plan_mutant cycle 20 '$1 == 2 && $2 == 1 { $NF = "1 7" } { print }' |
| 112 | plan_mutant missing-dep 19 '$1 == 2 && $2 == 12 { $NF = 13 } { print }' |
| 113 | plan_mutant self-dep 19 '$1 == 2 && $2 == 12 { $NF = 12 } { print }' |
| 114 | plan_mutant overlong-unsplittable 15 '$1 == 2 && $2 == 4 { $10 = 70 } { print }' |
| 115 | plan_mutant cap-above-profile 14 '$1 == 2 && $2 == 4 { $8 = 65 } { print }' |
| 116 | plan_mutant compute-with-tokens 14 '$1 == 2 && $2 == 7 { $8 = 1 } { print }' |
| 117 | plan_mutant changed-privacy-owner 17 '$1 == 2 && $2 == 6 { $16 = 8 } { print }' |
| 118 | plan_mutant unauthorized-effect 18 'NR == 1 { $9 = 1 } { print }' |
| 119 | plan_mutant missing-operand 22 '$1 == 2 && $2 == 9 { $19 = 0; $20 = 0; $21 = 0; $22 = 0 } { print }' |
| 120 | plan_mutant missing-verifier 16 '$1 == 2 && $2 == 8 { $13 = 0 } { print }' |
| 121 | plan_mutant never-retry-twice 23 '$1 == 2 && $2 == 12 { $14 = 1; $15 = 2 } { print }' |
| 122 | plan_mutant effect-idempotent-retry 23 '$1 == 2 && $2 == 12 { $14 = 2 } { print }' |
| 123 | plan_mutant over-budget 26 'NR == 1 { $15 = 700 } { print }' |
| 124 | plan_mutant terminal-optional 21 'NR == 1 { $11 = 6 } { print }' |
| 125 | plan_mutant truncated 2 'NR < 13 { print }' |
| 126 | plan_mutant malformed-word 3 '$1 == 2 && $2 == 3 { $3 = "x" } { print }' |
| 127 | |
| 128 | echo '== independent microjobs before the join (several running at once)' >> "$log" |
| 129 | accept 1 1 1 1 $W20 0 "$z4" 0 0 |
| 130 | accept 1 2 1 1 $W20 0 "$z4" 0 0 |
| 131 | reject dispatch-by-verifier 39 1 3 1 1 $V5 0 "$z4" 0 0 |
| 132 | reject dispatch-by-owner 39 1 3 1 1 $OWNER 0 "$z4" 0 0 |
| 133 | accept 1 3 1 1 $W20 0 "$z4" 0 0 |
| 134 | accept 1 4 1 1 $W21 0 "$z4" 0 0 |
| 135 | expect_node 4 2/1/1 |
| 136 | reject dispatch-before-dependencies 43 1 7 1 1 $W20 0 "$z4" 0 0 |
| 137 | v1=$(work_value '120+80+45'); test "$v1" = "$(verify_value 120 + 125)" || die "oracle n1" |
| 138 | d1=$(dw "n1:sum:$v1") |
| 139 | accept 2 1 1 1 $W20 0 "$d1" 0 3 |
| 140 | reject compute-result-with-tokens 48 2 2 1 1 $W20 0 "$d1" 1 3 |
| 141 | reject self-reported-success 40 3 1 1 1 $W20 1 "$d1" 0 0 |
| 142 | reject wrong-verifier 39 3 1 1 1 $V6 1 "$d1" 0 0 |
| 143 | reject verifier-digest-mismatch 41 3 1 1 1 $V5 1 "$(dw "n1:sum:999")" 0 0 |
| 144 | accept 3 1 1 1 $V5 1 "$d1" 0 0 |
| 145 | v2=$(work_value '300+15'); d2=$(dw "n2:reduce:$v2") |
| 146 | accept 2 2 1 1 $W20 0 "$d2" 0 2 |
| 147 | accept 3 2 1 1 $V5 1 "$d2" 0 0 |
| 148 | v3=$(work_value '12*7'); test "$v3" = "$(verify_value 12 '*' 7)" || die "oracle n3" |
| 149 | d3=$(dw "n3:arith:$v3") |
| 150 | accept 2 3 1 1 $W20 0 "$d3" 0 2 |
| 151 | accept 3 3 1 1 $V5 1 "$d3" 0 0 |
| 152 | d4=$(dw "n4:route:budget-note") |
| 153 | reject result-over-token-contract 42 2 4 1 1 $W21 0 "$d4" 73 900 |
| 154 | reject result-by-other-worker 39 2 4 1 1 $W22 0 "$d4" 50 900 |
| 155 | accept 2 4 1 1 $W21 0 "$d4" 50 900 |
| 156 | accept 3 4 1 1 $V6 1 "$d4" 0 0 |
| 157 | echo '== refusal: optional teacher route has no current qualification' >> "$log" |
| 158 | accept 7 6 0 1 $RT 0 "$z4" 0 0 |
| 159 | expect_node 6 7/1/0 |
| 160 | |
| 161 | echo '== model failure then bounded retry' >> "$log" |
| 162 | accept 1 5 1 1 $W22 0 "$z4" 0 0 |
| 163 | accept 4 5 1 1 $W22 0 "$z4" 40 4000 |
| 164 | expect_node 5 1/1/1 |
| 165 | reject retry-reuses-attempt 35 1 5 1 1 $W22 0 "$z4" 0 0 |
| 166 | accept 1 5 2 1 $W22 0 "$z4" 0 0 |
| 167 | d5=$(dw "n5:extract:limit=700") |
| 168 | accept 2 5 2 1 $W22 0 "$d5" 110 2500 |
| 169 | accept 3 5 2 1 $V6 1 "$d5" 0 0 |
| 170 | expect_node 5 4/1/2 |
| 171 | |
| 172 | echo '== join' >> "$log" |
| 173 | v7=$(work_value "$v1+$v2+$v3"); test "$v7" = "$(verify_value "$v1" + "$(verify_value "$v2" + "$v3")")" || die "oracle n7" |
| 174 | run_compute 7 1 1 "$v7" join |
| 175 | run_compute 8 1 1 "$(work_value "$v7 <= 700")" compare |
| 176 | accept 1 9 1 1 $W21 0 "$z4" 0 0 |
| 177 | |
| 178 | echo '== partial completion: process stops with a live lease; restart replays exact state' >> "$log" |
| 179 | status > "$run/partial-1.status" |
| 180 | # Interrupt a real writer with SIGKILL after the kernel admitted its event but before the |
| 181 | # atomic rename: nothing may be committed, the lock must be released, replay must match. |
| 182 | cat > "$work/slow-kernel" <<EOF |
| 183 | #!/usr/bin/env bash |
| 184 | "$work/kernel" |
| 185 | rc=\$? |
| 186 | sleep 30 |
| 187 | exit \$rc |
| 188 | EOF |
| 189 | chmod 700 "$work/slow-kernel" |
| 190 | jsha=$(sha256sum < "$S/journal") |
| 191 | GM_KERNEL="$work/slow-kernel" setsid bash "$drv" propose "$S" 4 9 1 1 $RT 0 $z4 0 0 > /dev/null 2>&1 & |
| 192 | wpid=$! |
| 193 | for _ in $(seq 200); do pgrep -s "$wpid" -x sleep > /dev/null && break; sleep 0.05; done |
| 194 | pgrep -s "$wpid" -x sleep > /dev/null || die "interrupted writer never reached its commit window" |
| 195 | kill -KILL -- -"$wpid" |
| 196 | wait "$wpid" 2> /dev/null || true |
| 197 | test -f "$S/journal.cand" || die "interrupted writer left no candidate" |
| 198 | test "$(sha256sum < "$S/journal")" = "$jsha" || die "SIGKILL before rename changed the journal" |
| 199 | ok "SIGKILL inside the commit window left the journal unchanged" |
| 200 | status > "$run/partial-2.status" |
| 201 | cmp -s "$run/partial-1.status" "$run/partial-2.status" || die "replay after restart differs" |
| 202 | ok "restart replay byte-identical ($(sha256sum < "$run/partial-1.status" | cut -c1-16))" |
| 203 | expect_node 9 2/1/1 |
| 204 | expect_obj 1 |
| 205 | accept 4 9 1 1 $RT 0 "$z4" 0 0 |
| 206 | d9late=$(dw "n9:summarize:late") |
| 207 | reject duplicate-result-after-restart 33 2 9 1 1 $W21 0 "$d9late" 20 100 |
| 208 | accept 1 9 2 1 $W21 0 "$z4" 0 0 |
| 209 | d9bad=$(dw "n9:summarize:total 640") |
| 210 | accept 2 9 2 1 $W21 0 "$d9bad" 120 1800 |
| 211 | accept 3 9 2 1 $V6 0 "$d9bad" 0 0 |
| 212 | expect_node 9 1/1/2 |
| 213 | accept 1 9 3 1 $W21 0 "$z4" 0 0 |
| 214 | d9=$(dw "n9:summarize:total $v7 within 700") |
| 215 | accept 2 9 3 1 $W21 0 "$d9" 118 1700 |
| 216 | reject result-twice 33 2 9 3 1 $W21 0 "$d9" 118 1700 |
| 217 | accept 3 9 3 1 $V6 1 "$d9" 0 0 |
| 218 | expect_node 9 4/1/3 |
| 219 | |
| 220 | echo '== human correction invalidates exactly the affected nodes' >> "$log" |
| 221 | reject correction-by-non-owner 39 6 3 0 1 $RT 0 "$(dw operand:n3-v2)" 0 0 |
| 222 | reject correction-same-operand 46 6 3 0 1 $OWNER 0 "$(dw operand:n3-v1)" 0 0 |
| 223 | reject correction-stale-generation 34 6 3 0 2 $OWNER 0 "$(dw operand:n3-v2)" 0 0 |
| 224 | accept 6 3 0 1 $OWNER 0 "$(dw operand:n3-v2)" 0 0 |
| 225 | for n in 1 2 4 5; do test "$(nodef $n 3)/$(nodef $n 4)" = "4/1" || die "unaffected node $n changed"; done |
| 226 | ok "unaffected nodes 1 2 4 5 stay DONE at generation 1" |
| 227 | expect_node 6 7/1/0 |
| 228 | for n in 3 7 8 9 10 11 12; do test "$(nodef $n 3)/$(nodef $n 4)/$(nodef $n 5)" = "1/2/0" || die "affected node $n not reset"; done |
| 229 | ok "affected nodes 3 7 8 9 10 11 12 reset to generation 2" |
| 230 | reject stale-generation-dispatch 34 1 3 1 1 $W20 0 "$z4" 0 0 |
| 231 | |
| 232 | v3=$(work_value '12*9'); test "$v3" = "$(verify_value 12 '*' 9)" || die "oracle n3 v2" |
| 233 | run_compute 3 2 1 "$v3" arith |
| 234 | v7=$(work_value "$v1+$v2+$v3"); test "$v7" = "$(verify_value "$v1" + "$(verify_value "$v2" + "$v3")")" || die "oracle n7 v2" |
| 235 | run_compute 7 2 1 "$v7" join |
| 236 | run_compute 8 2 1 "$(work_value "$v7 <= 700")" compare |
| 237 | accept 1 9 1 2 $W21 0 "$z4" 0 0 |
| 238 | d9=$(dw "n9:summarize:total $v7 within 700") |
| 239 | accept 2 9 1 2 $W21 0 "$d9" 116 1600 |
| 240 | accept 3 9 1 2 $V6 1 "$d9" 0 0 |
| 241 | run_compute 10 2 1 1 verify |
| 242 | run_compute 11 2 1 "$v7" "note-ok" |
| 243 | reject effect-before-done 44 8 12 0 2 $RT 0 "$(dw effect:n12:g2)" 0 0 |
| 244 | run_compute 12 2 1 "$v7" publish |
| 245 | reject effect-on-non-effect-node 44 8 11 0 2 $RT 0 "$(dw effect:n11:g2)" 0 0 |
| 246 | reject effect-by-worker 39 8 12 0 2 $W20 0 "$(dw effect:n12:g2)" 0 0 |
| 247 | expect_obj 1 |
| 248 | accept 8 12 0 2 $RT 0 "$(dw effect:n12:g2)" 0 0 |
| 249 | reject duplicate-effect 45 8 12 0 2 $RT 0 "$(dw effect:n12:g2)" 0 0 |
| 250 | expect_obj 2 |
| 251 | # status words: 100 status nodes done attempts model_calls tokens_reserved last_seq time_ms |
| 252 | # cancelled tokens_used. Expected totals recomputed independently (docs/GOAL_MICROJOBS.md). |
| 253 | totals=$(awk '$1 == 100' <(status)) |
| 254 | test "$totals" = "100 2 12 11 18 7 972 55 12531 0 554" || die "objective totals $totals" |
| 255 | ok "objective totals: 18 attempts, 7 model calls, 972 tokens reserved, 554 used, 12531 ms" |
| 256 | status > "$run/acceptance.status" |
| 257 | receipt=$(awk '$1 == 103' "$run/acceptance.status") |
| 258 | want="103 $(dw 'objective:allen13-fixture-weekly-budget-note') $(dw "n11:note-ok:$v7") 2 $(wc -l < "$S/journal")" |
| 259 | test "$receipt" = "$want" || die "objective receipt $receipt, want $want" |
| 260 | ok "terminal receipt binds objective digest and verified terminal result n11:note-ok:$v7" |
| 261 | cp "$S/journal" "$run/acceptance.journal" |
| 262 | cp "$S/plan" "$run/acceptance.plan" |
| 263 | |
| 264 | echo '== event wire refusals (driven directly, the driver never writes these)' >> "$log" |
| 265 | wire() { # name code line |
| 266 | local name=$1 code=$2 line=$3 rc |
| 267 | { cat "$S/plan" "$S/journal"; printf '%s\n' "$line"; } > "$work/probes/$name.in" |
| 268 | printf '%s\n' "$code" > "$work/probes/$name.code" |
| 269 | set +e; "$GM_KERNEL" < "$work/probes/$name.in" > /dev/null; rc=$?; set -e |
| 270 | test "$rc" -eq "$code" || die "$name: expected $code, got $rc" |
| 271 | ok "wire $name $code" |
| 272 | } |
| 273 | next=$(( $(wc -l < "$S/journal") + 1 )) |
| 274 | wire seq-gap 30 "3 $((next + 1)) 1 1 1 1 $W20 0 $z4 0 0" |
| 275 | wire unknown-event-type 32 "3 $next 9 1 1 1 $W20 0 $z4 0 0" |
| 276 | wire unknown-node 31 "3 $next 1 13 1 1 $W20 0 $z4 0 0" |
| 277 | wire truncated-event 2 "3 $next 1 1" |
| 278 | |
| 279 | echo '== budgets stop model-call storms' >> "$log" |
| 280 | HDR_MAXMODEL=2 plan > "$work/plan-b" |
| 281 | S="$work/state-b" |
| 282 | bash "$drv" init "$S" "$work/plan-b" >> "$log" |
| 283 | accept 1 4 1 1 $W21 0 "$z4" 0 0 |
| 284 | accept 4 4 1 1 $W21 0 "$z4" 70 2000 |
| 285 | accept 1 4 2 1 $W21 0 "$z4" 0 0 |
| 286 | accept 4 4 2 1 $W21 0 "$z4" 70 2000 |
| 287 | reject model-call-budget 37 1 4 3 1 $W21 0 "$z4" 0 0 |
| 288 | test "$(nodef 4 7)" = 0 || die "unfundable node reported ready" |
| 289 | ok "unfundable model node is not offered as ready" |
| 290 | HDR_MAXTOK=100 plan > "$work/plan-c" |
| 291 | S="$work/state-c" |
| 292 | bash "$drv" init "$S" "$work/plan-c" >> "$log" |
| 293 | accept 1 4 1 1 $W21 0 "$z4" 0 0 |
| 294 | accept 2 4 1 1 $W21 0 "$d4" 50 900 |
| 295 | accept 3 4 1 1 $V6 1 "$d4" 0 0 |
| 296 | reject token-budget 38 1 5 1 1 $W22 0 "$z4" 0 0 |
| 297 | S="$work/state-d" |
| 298 | bash "$drv" init "$S" "$work/plan" >> "$log" |
| 299 | for a in 1 2 3; do accept 1 4 "$a" 1 $W21 0 "$z4" 0 0; accept 4 4 "$a" 1 $W21 0 "$z4" 10 2000; done |
| 300 | expect_node 4 5/1/3 |
| 301 | reject attempts-exhausted 33 1 4 4 1 $W21 0 "$z4" 0 0 |
| 302 | expect_obj 3 |
| 303 | test "$(nodef 5 6)/$(nodef 9 6)/$(nodef 12 6)" = "1/1/1" || die "dependents of failed node not blocked" |
| 304 | ok "dependents of the exhausted model node are blocked" |
| 305 | |
| 306 | echo '== cancellation' >> "$log" |
| 307 | S="$work/state-e" |
| 308 | bash "$drv" init "$S" "$work/plan" >> "$log" |
| 309 | accept 1 1 1 1 $W20 0 "$z4" 0 0 |
| 310 | accept 1 4 1 1 $W21 0 "$z4" 0 0 |
| 311 | reject cancel-by-non-owner 39 5 7 0 0 $W20 0 "$z4" 0 0 |
| 312 | accept 5 4 0 0 $OWNER 0 "$z4" 0 0 |
| 313 | for n in 4 5 6 8 9 10 11 12; do test "$(nodef $n 3)" = 6 || die "node $n not cancelled"; done |
| 314 | ok "cancel of node 4 cancels exactly 4 and its dependents 5 6 8 9 10 11 12" |
| 315 | reject late-result-after-cancel 33 2 4 1 1 $W21 0 "$d4" 50 900 |
| 316 | accept 2 1 1 1 $W20 0 "$d1" 0 3 |
| 317 | accept 3 1 1 1 $V5 1 "$d1" 0 0 |
| 318 | expect_node 1 4/1/1 |
| 319 | expect_obj 5 |
| 320 | accept 5 0 0 0 $OWNER 0 "$z4" 0 0 |
| 321 | expect_obj 4 |
| 322 | reject dispatch-after-objective-cancel 47 1 2 1 1 $W20 0 "$z4" 0 0 |
| 323 | reject cancel-twice 47 5 0 0 0 $OWNER 0 "$z4" 0 0 |
| 324 | |
| 325 | echo '== source mutation controls' >> "$log" |
| 326 | : > "$run/mutations.tsv" |
| 327 | mutate() { # name from to probe |
| 328 | local name=$1 from=$2 to=$3 probe=$4 count rc want |
| 329 | count=$(grep -F -x -c "$from" "$repo/src/goal_microjobs/kernel.om") |
| 330 | test "$count" -eq 1 || die "mutation $name anchor occurs $count times" |
| 331 | awk -v f="$from" -v t="$to" '$0 == f { print t; next } { print }' "$repo/src/goal_microjobs/kernel.om" > "$work/mutant.om" |
| 332 | bash "$repo/scripts/goal_microjobs/build.sh" "$work/mutant.om" "$work/mutant" > /dev/null || die "mutant $name did not compile" |
| 333 | want=$(cat "$work/probes/$probe.code") |
| 334 | set +e; "$work/mutant" < "$work/probes/$probe.in" > /dev/null; rc=$?; set -e |
| 335 | test "$rc" -ne "$want" || die "mutant $name survived probe $probe" |
| 336 | printf '%s\t%s\t%s\t%s\tCAUGHT\n' "$name" "$probe" "$want" "$rc" >> "$run/mutations.tsv" |
| 337 | ok "mutant $name caught by $probe ($want -> $rc)" |
| 338 | } |
| 339 | mutate verifier-identity 'if ne ev 4 nd i 10' 'if eq ev 4 0' wrong-verifier |
| 340 | mutate self-verification 'if eq ev 4 sg i 4' 'if eq ev 4 0' self-reported-success |
| 341 | mutate dependency-gate 'fail 43' 'put Tot 7 0' dispatch-before-dependencies |
| 342 | mutate generation-bump 'ss j 1 add sg j 1 1' 'ss j 1 sg j 1' stale-generation-dispatch |
| 343 | mutate duplicate-effect 'if eq sg i 9 sg i 1' 'if eq sg i 9 99' duplicate-effect |
| 344 | mutate model-budget 'fail 37' 'put Tot 7 0' model-call-budget |
| 345 | mutate objective-cancel 'put Tot 5 1' 'put Tot 7 1' cancel-twice |
| 346 | mutate cycle-check 'fail 20' 'put Tot 7 0' plan-cycle |
| 347 | mutate privacy-owner 'fail 17' 'put Tot 7 0' plan-changed-privacy-owner |
| 348 | |
| 349 | echo '== receipt' >> "$log" |
| 350 | sha() { sha256sum "$1" | cut -d' ' -f1; } |
| 351 | cat > "$run/receipt.json" <<EOF |
| 352 | { |
| 353 | "schema": "aien.allen.goal-microjobs.offline-gate/1", |
| 354 | "verdict": "PASS", |
| 355 | "scope": "seeded .om admission and journal replay kernel; synthetic fixture workers and verifiers; local journal, not Cortex", |
| 356 | "signed": false, |
| 357 | "allen_source_commit": "$(git -C "$repo" rev-parse HEAD)", |
| 358 | "allen_tree_dirty": $(if test -n "$(git -C "$repo" status --porcelain -- src scripts tests)"; then echo true; else echo false; fi), |
| 359 | "omega_source_commit": "$(git -C "$OMEGA_WORKTREE" rev-parse HEAD)", |
| 360 | "compiler_sha256": "$(sha "$OMEGA_WORKTREE/build/L574/toolchain/build/bootstrap/omc")", |
| 361 | "kernel_source_sha256": "$(sha "$repo/src/goal_microjobs/kernel.om")", |
| 362 | "kernel_executable_sha256": "$(sha "$GM_KERNEL")", |
| 363 | "driver_sha256": "$(sha "$drv")", |
| 364 | "gate_sha256": "$(sha "$repo/tests/goal_microjobs/gate.sh")", |
| 365 | "acceptance_journal_sha256": "$(sha "$run/acceptance.journal")", |
| 366 | "acceptance_status_sha256": "$(sha "$run/acceptance.status")", |
| 367 | "mutation_log_sha256": "$(sha "$run/mutations.tsv")", |
| 368 | "host": "$(uname -smr)", |
| 369 | "checks_passed": $checks, |
| 370 | "mutants_caught": $(wc -l < "$run/mutations.tsv"), |
| 371 | "model_inference": "NOT_RUN", |
| 372 | "omega_or_core_dispatch": "NOT_RUN", |
| 373 | "cortex_write_and_restart": "NOT_RUN", |
| 374 | "canonical_mjb1_binary_abi": "NOT_RUN", |
| 375 | "routing_comparison": "NOT_RUN", |
| 376 | "gpu_or_physical_qualification": "NOT_RUN", |
| 377 | "deployment": "OFF" |
| 378 | } |
| 379 | EOF |
| 380 | printf 'PASS %s checks=%d\n' "$run/receipt.json" "$checks" | tee -a "$log" |