omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / evidence / text-parent-qualification / gate.sh
| 1 | #!/usr/bin/env bash |
| 2 | # L555 parent qualification runner (bay 2, t_93b414c3 run 343). Run under a queen CPU pool flock. |
| 3 | # Work clone: probe + 17 emitter mutants + seeded suites + cabi gate + seeded_next + emitter delta. |
| 4 | # Clean clone of the same commit (no untracked files): bootstrap, build, tools/test.sh. |
| 5 | # Usage: gate.sh HEAD_SHA EVIDENCE_DIR (HEAD_SHA must be the work clone's HEAD with no tracked changes). |
| 6 | set -uo pipefail |
| 7 | W=/home/drakestapleton/.hermes/kanban/boards/aien-hive/workspaces/t_93b414c3 |
| 8 | REPO=$W/omega-bridge |
| 9 | HEAD=$1 |
| 10 | EV=$2 |
| 11 | SEEDED_SRC=/home/drakestapleton/workspace/omega-mcp/build/omc |
| 12 | MV=/home/drakestapleton/.radicle/storage/z6do9WDBhuSnvopDkgFdFr1yWA62 |
| 13 | export OMEGA_SOURCE=/home/drakestapleton/workspace/omega |
| 14 | export OMEGA_SEED=$REPO/build/bootstrap/omc |
| 15 | mkdir -p "$EV" |
| 16 | step() { local name=$1; shift; local t0=$(date +%s); "$@" > "$EV/$name.log" 2>&1; local rc=$?; echo "$name rc=$rc secs=$(( $(date +%s) - t0 ))" | tee -a "$EV/steps.txt"; return 0; } |
| 17 | |
| 18 | cd "$REPO" |
| 19 | { |
| 20 | echo "pool=$POOL cores=$CORES host=$(hostname) start=$(date -u +%FT%TZ)" |
| 21 | echo "head=$(git rev-parse HEAD) want=$HEAD" |
| 22 | echo "tracked_changes=$(git status --porcelain --untracked-files=no | wc -l)" |
| 23 | git rev-parse HEAD:src/toc.om |
| 24 | sha256sum src/toc.om |
| 25 | } > "$EV/meta.txt" |
| 26 | [ "$(git rev-parse HEAD)" = "$HEAD" ] && [ -z "$(git status --porcelain --untracked-files=no)" ] || { echo "wrong head or tracked changes" >> "$EV/meta.txt"; exit 2; } |
| 27 | : > "$EV/steps.txt" |
| 28 | |
| 29 | # Pins |
| 30 | mkdir -p "$W/pins" |
| 31 | cp "$SEEDED_SRC" "$W/pins/omc-seeded"; chmod +x "$W/pins/omc-seeded" |
| 32 | export OMEGA_SEEDED_OMC=$W/pins/omc-seeded |
| 33 | git -C "$MV" show 7e93ca8e:seed/omc/omc.om > "$W/pins/next-omc.om" |
| 34 | "$OMEGA_SEEDED_OMC" < "$W/pins/next-omc.om" > "$W/pins/omc-next"; chmod +x "$W/pins/omc-next" |
| 35 | export OMEGA_SEEDED_NEXT_OMC=$W/pins/omc-next |
| 36 | sha256sum "$W/pins/omc-seeded" "$W/pins/next-omc.om" "$W/pins/omc-next" > "$EV/pins.sha256" |
| 37 | |
| 38 | # Work clone: seed, emitter, probe |
| 39 | step bootstrap tools/bootstrap.sh |
| 40 | step build tools/build.sh |
| 41 | sha256sum build/bootstrap/omc src/toc.om build/bridge >> "$EV/pins.sha256" |
| 42 | rm -rf "$EV/probe"; step probe env PROBE_JOBS=$JOBS python3 evidence/text-parent-qualification/probe.py "$EV/probe" |
| 43 | |
| 44 | # Emitter mutants compiled by the pinned seed from mutated copies of src/toc.om |
| 45 | python3 - "$EV" <<'EOF' > "$EV/mutants-build.log" 2>&1 |
| 46 | import hashlib, pathlib, subprocess, sys |
| 47 | ev = pathlib.Path(sys.argv[1]); md = ev / 'mutants'; md.mkdir(exist_ok=True) |
| 48 | t = pathlib.Path('src/toc.om').read_text() |
| 49 | M = [('pool-bound-off-by-one', 'u = get textuse 0\nif ge u 32768\nfail 14', 'u = get textuse 0\nif gt u 32768\nfail 14'), |
| 50 | ('table-bound-9', 'if ge i 8\nfail 14\nend\nput g_off i get ts 0\nput g_nl i get tl 0\nput g_ty i 2', 'if ge i 9\nfail 14\nend\nput g_off i get ts 0\nput g_nl i get tl 0\nput g_ty i 2'), |
| 51 | ('text-writable', 'if eq get g_ro sub a 32 1\nfail 20', 'if eq get g_ro sub a 32 2\nfail 20'), |
| 52 | ('after-quote-check', 'if gt get src get cur 0 32\nfail 22', 'if gt get src get cur 0 255\nfail 22'), |
| 53 | ('tab-escape', 'b = uchar 9', 'b = uchar 32'), |
| 54 | ('raw-lf-accepted', 'b = get src get cur 0\nif eq b 10\nfail 22\nend\nif eq b 34', 'b = get src get cur 0\nif eq b 34'), |
| 55 | ('note-tokenized', 'if and eq isw 1702129518 1 eq get abmode 0 0\nskipline', 'if and eq isw 1702129518 1 eq get abmode 0 7\nskipline'), |
| 56 | ('c-storage-writable', 'text z129 "static const uint8_t "', 'text z129 "static uint8_t "'), |
| 57 | ('py-view-length-unchecked', '(edit==2 and type(p) is bytes)) and len(p)==n', '(edit==2 and type(p) is bytes)) and len(p)>=0'), |
| 58 | ('trailing-token-ignored', 'if and ne get tk 0 3 ne get tk 0 0\nfail 16\nend\nend\n\nfn namescan', 'if and ne get tk 0 3 eq get tk 0 99\nfail 16\nend\nend\n\nfn namescan'), |
| 59 | ('fn-global-dup-unchecked', 'if ne glob_of 99\nfail 10\nend\nend\nif eq rec 1', 'if eq glob_of 4242\nfail 10\nend\nend\nif eq rec 1'), |
| 60 | ('empty-index-sentinel', 'always sized.\nif and eq get nk i 1 or ge a 32 ne alen a 0', 'always sized.\nif and eq get nk i 1 ne alen a 0'), |
| 61 | ('put-index-unchecked', 'put as for get.\nif and eq get nk i 1 or ge a 32 ne alen a 0', 'put as for get.\nif and eq get nk i 1 eq a 999'), |
| 62 | ('seed-keywords-ignored', 'if eq m 1\nret 1\nend\nend\nend\ni = add i 1', 'if eq m 9\nret 1\nend\nend\nend\ni = add i 1'), |
| 63 | ('param-dup-unchecked', 'if or eq param_dup ix 1 ne glob_of 99', 'if or eq param_dup ix 9 ne glob_of 99'), |
| 64 | ('param-fn-sweep-skipped', 'namescan\nparam_fn_sweep\n', 'namescan\n'), |
| 65 | ('keyword-locals-allowed', 'refuse 16.\nif eq seedkw 1\nfail 16', 'refuse 16.\nif eq seedkw 9\nfail 16')] |
| 66 | for name, old, new in M: |
| 67 | assert t.count(old) == 1, name |
| 68 | s = t.replace(old, new); assert s != t |
| 69 | (md / f'{name}.om').write_text(s) |
| 70 | r = subprocess.run(['build/bootstrap/omc'], input=s.encode(), capture_output=True) |
| 71 | assert r.returncode == 0 and r.stdout[:4] == b'\x7fELF', (name, r.returncode, r.stderr[:200]) |
| 72 | e = md / f'{name}.emitter'; e.write_bytes(r.stdout); e.chmod(0o755) |
| 73 | print(name, 'src', hashlib.sha256(s.encode()).hexdigest(), 'emitter', hashlib.sha256(r.stdout).hexdigest()) |
| 74 | print('MUTANTS BUILT', len(M)) |
| 75 | EOF |
| 76 | echo "mutants-build rc=$?" | tee -a "$EV/steps.txt" |
| 77 | for e in "$EV"/mutants/*.emitter; do |
| 78 | n=$(basename "$e" .emitter) |
| 79 | step "mutant-$n" env PROBE_JOBS=$JOBS PROBE_MODE="$n" PROBE_EMITTER="$e" python3 evidence/text-parent-qualification/probe.py "$EV/probe" |
| 80 | done |
| 81 | |
| 82 | # Seeded suites, cabi gate, seeded_next (work clone, same toc/bridge) |
| 83 | for s in seeded seeded_float seeded_views seeded_runtime_views freest_views freest seeded_next; do |
| 84 | step "suite-$s" python3 tests/$s.py |
| 85 | done |
| 86 | step cabi-gate sh -c 'cat tests/cabi/proc.om tests/cabi/gate.om | "$OMEGA_SEEDED_OMC" > build/cabi-gate && chmod +x build/cabi-gate && build/cabi-gate' |
| 87 | |
| 88 | # Delta against the immutable L551 source: old emitter built by the seed from e9511dbd's toc.om |
| 89 | git show e9511dbde3530089ace29d6ad1b5176a2c4ed2b2:src/toc.om | build/bootstrap/omc > "$EV/l551-bridge" && chmod +x "$EV/l551-bridge" |
| 90 | sha256sum "$EV/l551-bridge" >> "$EV/pins.sha256" |
| 91 | step emitdiff python3 evidence/text-parent-qualification/emitdiff.py "$EV/l551-bridge" build/bridge "$EV/emitdiff.json" |
| 92 | |
| 93 | # Clean clone replay + full install suite |
| 94 | R=$W/replay |
| 95 | rm -rf "$R"; git init -q "$R" |
| 96 | git -C "$R" fetch -q "$REPO" "$HEAD:refs/heads/replay" |
| 97 | git -C "$R" checkout -q replay |
| 98 | echo "replay head=$(git -C "$R" rev-parse HEAD) untracked=$(git -C "$R" status --porcelain | wc -l)" >> "$EV/meta.txt" |
| 99 | ( cd "$R" && step replay-bootstrap tools/bootstrap.sh && step replay-test tools/test.sh ) |
| 100 | sha256sum "$R/build/bootstrap/omc" "$R/src/toc.om" "$R/build/bridge" > "$EV/replay.sha256" |
| 101 | echo "end=$(date -u +%FT%TZ)" >> "$EV/meta.txt" |
| 102 | echo GATE-DONE >> "$EV/steps.txt" |