interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / numeric_check_sweep.sh

57 lines · 2971 bytes Raw Blame History
1#!/bin/bash
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# numeric_check_sweep.sh -- proves each pre-submission check in
18# src/omega_numeric.c is load-bearing. Every refusal line there ends in a
19# /* CHECK:<name> */ marker. For each marker this script deletes that one
20# line in a scratch copy, rebuilds the CPU-only Gate 5 test binary and runs
21# it. The sweep passes only if every copy still builds and every run FAILS
22# (a check whose removal no test notices is reported as SURVIVED). Unused-
23# variable warnings are allowed in the scratch copies only: deleting a check
24# can leave the value it tested unused.
25# Host only: opens no device, writes only under a temporary directory.
26# Run: make test-numeric-sweep (or run this file).
27set -u
28HERE=$(cd -P "$(dirname "$0")/.." && pwd)
29SRC=$HERE/src/omega_numeric.c
30TMP=$(mktemp -d)
31trap 'rm -rf "$TMP"' EXIT
32OTHER="tests/test_omega_numeric.c src/omega_numeric_provenance.c src/omega_numeric_divsqrt_gb10.c src/omega_blackwell_encoder.c
33 src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c src/omega_blackwell_qmd.c src/omega_om_units.c"
34names=$(grep -o '/\* CHECK:[a-z0-9_]* \*/' "$SRC" | sed 's|/\* CHECK:\([a-z0-9_]*\) \*/|\1|')
35total=0 killed=0 survived=0 broken=0
36for name in $names; do
37 total=$((total + 1))
38 mut=$TMP/omega_numeric.c
39 grep -v "/\* CHECK:$name \*/" "$SRC" > "$mut"
40 if [ "$(wc -l < "$SRC")" -ne $(( $(wc -l < "$mut") + 1 )) ]; then
41 echo " [BROKEN] $name: marker is not on exactly one line"; broken=$((broken + 1)); continue
42 fi
43 # shellcheck disable=SC2086
44 if ! (cd "$HERE" && gcc -std=gnu11 -O2 -Wall -Wextra -Werror -ffp-contract=off -Isrc \
45 -Wno-unused-variable -Wno-unused-but-set-variable \
46 -DOMEGA_NUMERIC_CPU_ONLY -o "$TMP/t" "$mut" $OTHER) > "$TMP/build.log" 2>&1; then
47 echo " [BROKEN] $name: scratch copy does not build"; broken=$((broken + 1)); continue
48 fi
49 if "$TMP/t" > "$TMP/run.log" 2>&1; then
50 echo " [SURVIVED] $name: removing this check fails no test"; survived=$((survived + 1))
51 else
52 echo " [KILLED] $name: $(grep -m3 '^\[FAIL\]' "$TMP/run.log" | sed 's/^\[FAIL\] //' | tr '\n' ' ')"
53 killed=$((killed + 1))
54 fi
55done
56echo "check sweep: $total checks, $killed caught by a failing test, $survived survived, $broken broken"
57[ "$total" -gt 0 ] && [ "$killed" -eq "$total" ]