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 / tests / r16_surface / run.sh
| 1 | #!/bin/sh |
| 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 | # R16-G5 API/build surface (spec/r16-orchestrator-retirement.md ยง5 R16-G5). |
| 18 | # |
| 19 | # Usage: tests/r16_surface/run.sh <omegatool-binary> |
| 20 | # |
| 21 | # Checks, host only (no mode that touches the graphics processor is run): |
| 22 | # 1. no old legacy mode name survives in code, scripts, the Makefile or the |
| 23 | # README: omegatool's legacy modes are `--legacy-oracle-*` (class A, |
| 24 | # retired) and `--reference-demonstrate-*` (class D, reference oracle). |
| 25 | # Allowed: the inventory tool's detector pattern and one history comment. |
| 26 | # 2. the SEQ reference loop is named and called only in rx_seq_reference.*: |
| 27 | # no production source under src/ calls rx_seq_* or names |
| 28 | # run_until_complete. |
| 29 | # 3. no legacy mode is omegatool's default: with no argument it prints usage |
| 30 | # and exits nonzero, running nothing. |
| 31 | # 4. every retired --demonstrate-<name> (all 16 reference modes, read from |
| 32 | # omegatool's reference_modes table, plus living-matvec) is rejected. |
| 33 | # 5. every new name (--reference-demonstrate-<name>, --legacy-oracle-living- |
| 34 | # matvec) is accepted by the dispatcher (--reference-dispatch-dry-run |
| 35 | # resolves without running), and --reference-demonstrate-arithmetic |
| 36 | # (CPU only) really runs. Usage lists exactly the table's modes (3). |
| 37 | # 6. the production entry point is documented |
| 38 | # (docs/r16-production-entry-point.md names the R13/R14 targets). |
| 39 | set -u |
| 40 | tool=${1:-build/omegatool} |
| 41 | fails=0 |
| 42 | ok() { echo "ok $*"; } |
| 43 | bad() { echo "FAIL $*"; fails=$((fails + 1)); } |
| 44 | |
| 45 | # 1 --------------------------------------------------------------------------- |
| 46 | hits=$(git grep -n -e '--demonstrate-' -- tools src tests Makefile README.md \ |
| 47 | ':!tools/r16_loop_inventory.c' ':!tests/r16_surface/run.sh' \ |
| 48 | ':!tests/r16_inventory/fixture' \ |
| 49 | | grep -v '^tools/omegatool.c:[0-9]*: \* --legacy-oracle-living-matvec; the old --demonstrate-living-matvec mode is$') |
| 50 | if [ -z "$hits" ]; then ok "old mode names: none in code, scripts, Makefile or README" |
| 51 | else bad "old mode names still present:"; echo "$hits" | head -20; fi |
| 52 | |
| 53 | # 2 --------------------------------------------------------------------------- |
| 54 | calls=$(git grep -nE 'rx_seq_[a-z_]+\(|run_until_complete' -- 'src/*.c' 'src/*.h' \ |
| 55 | ':!src/runtime/rx_seq_reference.c' ':!src/runtime/rx_seq_reference.h' \ |
| 56 | | grep -vE '^[^:]+:[0-9]+:[[:space:]]*(\*|/\*|//)') |
| 57 | if [ -z "$calls" ]; then ok "SEQ reference loop: named and called only in rx_seq_reference.*" |
| 58 | else bad "SEQ reference loop called from production sources:"; echo "$calls" | head -20; fi |
| 59 | |
| 60 | # 3 --------------------------------------------------------------------------- |
| 61 | [ -x "$tool" ] || { bad "binary missing: $tool"; echo "R16 gate: R16_G5_SURFACE=FAIL"; exit 1; } |
| 62 | out=$("$tool" 2>&1); rc=$? |
| 63 | lines=$(printf '%s\n' "$out" | wc -l) |
| 64 | if [ $rc -ne 0 ] && printf '%s\n' "$out" | head -1 | grep -q '^Usage:' && [ "$lines" -le 4 ] && |
| 65 | ! printf '%s\n' "$out" | grep -qE 'PASS|FAIL|Result'; then |
| 66 | ok "omegatool default: usage only, exit $rc, nothing run" |
| 67 | else bad "omegatool with no argument ran something (exit $rc, $lines lines)"; fi |
| 68 | |
| 69 | # The reference modes, read from the one table the dispatcher uses. |
| 70 | modes=$(awk '/^static const ReferenceMode reference_modes\[\] = \{/ {on = 1; next} |
| 71 | on && /^\};/ {exit} |
| 72 | on { if (match($0, /\{"[a-z0-9-]+"/)) print substr($0, RSTART + 2, RLENGTH - 3) }' \ |
| 73 | tools/omegatool.c) |
| 74 | nmodes=$(printf '%s\n' "$modes" | grep -c .) |
| 75 | if [ "$nmodes" -eq 16 ]; then ok "reference mode table: $nmodes modes" |
| 76 | else bad "reference mode table has $nmodes modes, expected 16"; fi |
| 77 | |
| 78 | # 3b. usage lists exactly the table's modes. |
| 79 | listed=$(printf '%s\n' "$out" | tr ' ' '\n' | sed -n 's/^--reference-demonstrate-//p' | sort) |
| 80 | if [ "$listed" = "$(printf '%s\n' "$modes" | sort)" ]; then |
| 81 | ok "usage lists all $nmodes reference modes and no others" |
| 82 | else bad "usage and the reference mode table differ:"; printf 'usage: %s\ntable: %s\n' \ |
| 83 | "$(echo $listed)" "$(echo $modes)"; fi |
| 84 | |
| 85 | # 4 --------------------------------------------------------------------------- |
| 86 | # Every retired --demonstrate-<name> is rejected. The resolver (dry run, same |
| 87 | # dispatch, nothing run) is asked for all of them; the real binary is run on |
| 88 | # the ones that cannot touch the chip (never the accelerator or Blackwell names: |
| 89 | # if a regression accepted one, it would start a chip run). |
| 90 | nrej=0 |
| 91 | for m in $modes living-matvec; do |
| 92 | old=--demonstrate-$m |
| 93 | o=$("$tool" --reference-dispatch-dry-run "$old" 2>&1); rc=$? |
| 94 | if [ $rc -ne 0 ] && printf '%s\n' "$o" | grep -q "Unknown argument: $old"; then |
| 95 | nrej=$((nrej + 1)) |
| 96 | else bad "old mode $old accepted by the dispatcher (exit $rc)"; fi |
| 97 | case $m in accelerator*|blackwell*) continue ;; esac |
| 98 | o=$("$tool" "$old" 2>&1); rc=$? |
| 99 | if [ $rc -eq 0 ] || ! printf '%s\n' "$o" | grep -q "Unknown argument: $old"; then |
| 100 | bad "old mode $old accepted by the binary (exit $rc)" |
| 101 | fi |
| 102 | done |
| 103 | [ "$nrej" -eq $((nmodes + 1)) ] && ok "all $nrej retired --demonstrate-* names rejected" |
| 104 | |
| 105 | # 5 --------------------------------------------------------------------------- |
| 106 | # Every new name is accepted by the real dispatcher (dry run: resolved, not |
| 107 | # run), and one CPU-only mode really runs. |
| 108 | nacc=0 |
| 109 | for n in $(printf -- '--reference-demonstrate-%s\n' $modes) --legacy-oracle-living-matvec; do |
| 110 | o=$("$tool" --reference-dispatch-dry-run "$n" 2>&1); rc=$? |
| 111 | if [ $rc -eq 0 ] && printf '%s\n' "$o" | grep -q "^dispatch: $n accepted"; then |
| 112 | nacc=$((nacc + 1)) |
| 113 | else bad "new mode $n not accepted by the dispatcher (exit $rc)"; fi |
| 114 | done |
| 115 | [ "$nacc" -eq $((nmodes + 1)) ] && ok "all $nacc new names accepted by the dispatcher" |
| 116 | o=$("$tool" --reference-demonstrate-arithmetic 2>&1); rc=$? |
| 117 | if [ $rc -eq 0 ] && ! printf '%s\n' "$o" | grep -q 'Unknown argument' && |
| 118 | printf '%s\n' "$o" | grep -q 'PASS'; then |
| 119 | ok "--reference-demonstrate-arithmetic runs (exit 0)" |
| 120 | else bad "--reference-demonstrate-arithmetic did not run (exit $rc)"; fi |
| 121 | |
| 122 | # 6 --------------------------------------------------------------------------- |
| 123 | doc=docs/r16-production-entry-point.md |
| 124 | if [ -f "$doc" ] && grep -q 'test-r13-silicon' "$doc" && grep -q 'test-r14-silicon' "$doc" && |
| 125 | grep -q -- '--reference-demonstrate-' "$doc" && grep -q -- '--legacy-oracle-living-matvec' "$doc"; then |
| 126 | ok "production entry point documented in $doc" |
| 127 | else bad "$doc missing or incomplete"; fi |
| 128 | |
| 129 | if [ $fails -eq 0 ]; then echo "R16 gate: R16_G5_SURFACE=PASS"; exit 0; fi |
| 130 | echo "R16 gate: R16_G5_SURFACE=FAIL ($fails)"; exit 1 |