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 / seed / omc / gate18.sh
| 1 | #!/bin/sh |
| 2 | # gate18.sh -- keyword generator parity. genkw.awk is a text generator (not on the seed path), but it |
| 3 | # must reproduce the committed keyword chain: every literal pack/id pair, plus the two computed entries |
| 4 | # readlnk (133) and sockopt (134). This catches list drift and awk precision regressions (packs above |
| 5 | # 2^53 are printed with decimal string arithmetic, not doubles). The one target-scoped entry, efi (178) |
| 6 | # under `target x86efi` only, is not generated; it must appear exactly once in its fixed form. |
| 7 | # Foreign gate kept for generator parity; pair count is derived, never hand-maintained. .om successor seed/omc/gate18.om, |
| 8 | # tracked in aien-dev/omega-mv#1073. |
| 9 | # Replacing `[ "$n" = N ]` with `[ "$n" -gt 0 ]` is a weakened gate. |
| 10 | # The expectation comes from a committed table the gate does not regenerate in that run. |
| 11 | # A control that deletes the new keyword from the generator and from `omc.om`, and leaves |
| 12 | # that table unchanged, must exit nonzero when only `sh seed/omc/gate18.sh` is run. |
| 13 | set -eu |
| 14 | R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 15 | cd "$R" |
| 16 | mkdir -p build/seed/r18 |
| 17 | T=$(mktemp -d build/seed/r18/kw.XXXXXX) |
| 18 | trap 'rm -rf "$T"' EXIT HUP INT TERM |
| 19 | bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; } |
| 20 | |
| 21 | awk -f seed/omc/genkw.awk > "$T/gen" |
| 22 | |
| 23 | # The committed chain, scoped to fn kw: stop at its final `ret 0` fallback. |
| 24 | awk ' |
| 25 | /^fn kw /{inkw=1; next} |
| 26 | inkw && /^if eq w /{p=$4; next} |
| 27 | inkw && /^if and eq w /{p=$5 " target=" $NF; next} |
| 28 | inkw && /^ret /{ |
| 29 | if ($2 == 0) { inkw=0; exit } |
| 30 | if ($2 != 133 && $2 != 134) print $2, p |
| 31 | } |
| 32 | ' seed/omc/omc.om | sort -n > "$T/all.pairs" |
| 33 | [ "$(grep -c '^178 ' "$T/all.pairs")" = 1 ] || bad "committed chain must hold efi (178) exactly once" |
| 34 | grep -qx '178 6907493 target=2' "$T/all.pairs" || bad "efi (178) must be scoped to x86efi (xtarget 2)" |
| 35 | grep -v '^178 ' "$T/all.pairs" > "$T/chain.pairs" |
| 36 | |
| 37 | awk ' |
| 38 | /^if eq w /{p=$4} |
| 39 | /^ret /{ if ($2 != 133 && $2 != 134) print $2, p } |
| 40 | ' "$T/gen" | sort -n > "$T/gen.pairs" |
| 41 | |
| 42 | cmp -s "$T/chain.pairs" "$T/gen.pairs" || { |
| 43 | diff -u "$T/chain.pairs" "$T/gen.pairs" | sed -n '1,20p' >&2 |
| 44 | bad "generated keyword packs differ from the committed chain" |
| 45 | } |
| 46 | # The canonicalizer consumes a separate committed keyword inventory. Do not |
| 47 | # regenerate that inventory in this gate: losing an entry from both files above |
| 48 | # must still fail. Compare the complete ID multiset, including spelling aliases. |
| 49 | awk ' |
| 50 | /^text tkw1 "/ { |
| 51 | sub(/^text tkw1 "/, ""); sub(/"$/, "") |
| 52 | n=split($0, a, /\\n/) |
| 53 | for (i=1; i<=n; i++) { |
| 54 | split(a[i], p, " ") |
| 55 | if (a[i] != "" && p[2] != 133 && p[2] != 134) print p[2] |
| 56 | } |
| 57 | } |
| 58 | ' seed/semhash/semhash.om | sort -n > "$T/semantic.ids" |
| 59 | [ -s "$T/semantic.ids" ] || bad "semantic keyword inventory is absent" |
| 60 | cut -d ' ' -f 1 "$T/gen.pairs" > "$T/generated.ids" |
| 61 | cmp -s "$T/generated.ids" "$T/semantic.ids" || |
| 62 | bad "generated keyword inventory differs from committed semantic inventory" |
| 63 | n=$(wc -l < "$T/gen.pairs") |
| 64 | expected=$(wc -l < "$T/semantic.ids") |
| 65 | [ "$n" = "$expected" ] || bad "literal pair count $n differs from semantic inventory $expected" |
| 66 | |
| 67 | grep -q '^ret 133$' seed/omc/omc.om || bad "committed chain lacks readlnk (133)" |
| 68 | grep -q '^ret 134$' seed/omc/omc.om || bad "committed chain lacks sockopt (134)" |
| 69 | grep -q 'readlnk:133' seed/omc/genkw.awk || bad "generator lacks readlnk:133" |
| 70 | grep -q 'sockopt:134' seed/omc/genkw.awk || bad "generator lacks sockopt:134" |
| 71 | grep -q '^ret 224$' seed/omc/omc.om || bad "committed chain lacks peername (224)" |
| 72 | grep -q 'peername:224' seed/omc/genkw.awk || bad "generator lacks peername:224" |
| 73 | grep -q '^ret 227$' seed/omc/omc.om || bad "committed chain lacks fma (227)" |
| 74 | grep -q 'fma:227' seed/omc/genkw.awk || bad "generator lacks fma:227" |
| 75 | |
| 76 | printf 'PASS gate18 %s literal packs, both computed entries and the x86efi-scoped efi entry match the committed chain\n' "$n" |
| 77 | exit 0 |