aien
aien-dev/aien
Brought by drakestapleton
aien / tests / goal_microjobs / canon / run.sh
| 1 | #!/usr/bin/env bash |
| 2 | # Synthetic host verification oracle, not production orchestration. |
| 3 | set -euo pipefail |
| 4 | here=$(cd "$(dirname "$0")" && pwd) |
| 5 | repo=$(cd "$here/../../.." && pwd) |
| 6 | : "${CANON_RUN_ROOT:?Set CANON_RUN_ROOT to an external scratch/evidence directory}" |
| 7 | mkdir -p "$CANON_RUN_ROOT" |
| 8 | work=$(mktemp -d) |
| 9 | trap 'rm -rf "$work"' EXIT |
| 10 | for f in "$here"/*.hex; do xxd -r -p "$f" > "$work/$(basename "$f" .hex)"; done |
| 11 | bash "$repo/scripts/goal_microjobs/canon-build.sh" "$work/canon" |
| 12 | "$work/canon" emit < "$here/emit.in" > "$work/emission" |
| 13 | { cat "$work/document" "$work/payload"; sha256sum < "$work/document" | cut -c1-64 | xxd -r -p; } > "$work/expected" |
| 14 | cmp "$work/emission" "$work/expected" |
| 15 | "$work/canon" ingest < "$work/ingest.in" > "$work/events" |
| 16 | cmp "$work/events" "$here/events" |
| 17 | printf 'PASS emit bytes + Omega dag hash; PASS exact RESULT/VERIFY\n' |
| 18 | checks=0 |
| 19 | while read -r name code mode; do |
| 20 | rc=0 |
| 21 | "$work/canon" "$mode" < "$work/$name.in" > "$work/out" 2> "$work/err" || rc=$? |
| 22 | test "$rc" -eq "$code" |
| 23 | test ! -s "$work/out" |
| 24 | printf 'PASS refusal %s rc=%s %s\n' "$name" "$rc" "$(cat "$work/err")" |
| 25 | checks=$((checks+1)) |
| 26 | done < "$here/cases" |
| 27 | mkdir -p "$work/mut/scripts/goal_microjobs" "$work/mut/src/goal_microjobs" |
| 28 | cp "$repo/scripts/goal_microjobs/canon-build.sh" "$work/mut/scripts/goal_microjobs/" |
| 29 | : > "$CANON_RUN_ROOT/mutants.tsv" |
| 30 | while read -r name code mode; do |
| 31 | # These share guards with isolated receipt/outbind and reserved controls. |
| 32 | case "$name" in staleoutput|reserved1|reserved2) continue;; esac |
| 33 | case "$name" in |
| 34 | objective) |
| 35 | # Remove the whole expected-objective pin: equality and identity derivation. |
| 36 | sed -e '/^note CANON-GUARD objective$/{n;s/.*/if false/;}' \ |
| 37 | -e 's/put av add 2 i get a add 15 i/put av add 2 i num doc add 8 mul i 8 8/' \ |
| 38 | "$repo/src/goal_microjobs/canon.om" > "$work/mut/src/goal_microjobs/canon.om";; |
| 39 | idempotence) |
| 40 | # The reviewed surviving mutant: check job_id but silently omit idempotence_key. |
| 41 | sed 's/same part doc 192 32 part r 40 32/same part doc 192 16 part r 40 16/' \ |
| 42 | "$repo/src/goal_microjobs/canon.om" > "$work/mut/src/goal_microjobs/canon.om";; |
| 43 | *) |
| 44 | sed "/^note CANON-GUARD $name\$/{n;s/.*/if false/;}" "$repo/src/goal_microjobs/canon.om" > "$work/mut/src/goal_microjobs/canon.om";; |
| 45 | esac |
| 46 | bash "$work/mut/scripts/goal_microjobs/canon-build.sh" "$work/mutant" > "$work/build.log" 2>&1 |
| 47 | rc=0 |
| 48 | "$work/mutant" "$mode" < "$work/$name.in" > "$work/out" 2> "$work/err" || rc=$? |
| 49 | test "$rc" -eq 0 || { printf 'SURVIVED %s rc=%s\n' "$name" "$rc"; exit 1; } |
| 50 | test -s "$work/out" |
| 51 | printf '%s\tKILLED\tguardless_exit=0\tguarded_exit=%s\n' "$name" "$code" | tee -a "$CANON_RUN_ROOT/mutants.tsv" |
| 52 | done < "$here/cases" |
| 53 | bash "$repo/scripts/goal_microjobs/build.sh" "$repo/src/goal_microjobs/kernel.om" "$work/kernel" |
| 54 | "$work/kernel" < "$here/replay.in" > "$CANON_RUN_ROOT/kernel.status" |
| 55 | grep -qx '101 1 4 1 1 0 0 0' "$CANON_RUN_ROOT/kernel.status" |
| 56 | printf 'PASS pinned kernel replay DONE; refusals=%s\n' "$checks" |
| 57 | # Build pin mismatch control: no output and exit 3, never silently compile with another tool. |
| 58 | rc=0 |
| 59 | OMEGA_OMC=/bin/true bash "$repo/scripts/goal_microjobs/canon-build.sh" "$work/not-built" > "$work/blocked" 2>&1 || rc=$? |
| 60 | test "$rc" -eq 3 && test ! -e "$work/not-built" |
| 61 | printf 'PASS compiler pin refusal rc=3\n' |