Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/turing/tc_range_om.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / turing / tc_range_om.sh` 373 lines ยท 20736 bytes Raw Blame History 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 # tests/turing/tc_range_om.sh: gate glue for the Omega range coder src/turing/tc_range.om (L111). 18 # POSIX sh, sequencing only (disclosed host glue, as tests/turing/origsel-run.sh): it builds the 19 # unit with the repository's own seed/out/omc, runs it next to the C reference turing-coder and 20 # compares bytes and exit codes. Every length number and the bound verdict come from tc_range.om. 21 # usage: sh tests/turing/tc_range_om.sh 22 # Checks, each printed PASS/FAIL, any FAIL exits 1: 23 # 1 build; 2 selftest (synthetic round trips, length identity, upper and lower bound, one random 24 # flipped payload byte per case detected, exhaustive ub rule check); 25 # 3 for 2 committed traces x 7 models: Omega encode byte-identical to C, C verifies the Omega 26 # file, Omega verifies the C file, Omega decode byte-identical to the TSY1, ideal_ub equal, 27 # bound=PASS; 28 # 4 single-fault inputs: Omega and the C reference refuse with the same CODER_SPEC s.10 name 29 # (flipped payload byte, truncated, trailing byte, other TPS1, altered magic, corrupted TPS1, 30 # TSY1 of another trace, corrupted TSY1); a refusal after the output exists removes it; an 31 # output path naming an input is refused and the input is left intact; usage; 32 # 4b n = `1152514738907` (cap+1) refuses ARG. The file is a digest-valid 160-byte TPS1, not a 33 # terabyte body. A sibling with n = 1 and the same shape refuses FORMAT, so a size-check 34 # miss is not counted as the cap. `selftest overflow` raises ALARM 7 on the wrapping sum. 35 # 4c ofinish: a forced fsync failure (seccomp EIO on fsync/fdatasync; compile-time 36 # AUDIT_ARCH_X86_64 / AUDIT_ARCH_AARCH64 and __NR_fsync/__NR_fdatasync) refuses 37 # IO (102) and removes the partial output only if rc is 2 and the IO line is 38 # present; a SIGSYS or other rc with no file must not PASS. A mutant that 39 # clears the open flag before that check leaves the file. 40 # 5 mutants that must fail: range >> 15 on every real unit (exit 0 and bytes differ from C, or 41 # exit 3 from an ALARM; a refusal of every unit is a failed mutant), decoder renorm count 42 # doubled (ALARM 1 on verify, the decode still finishes), upper-bound constants, ub rounding, 43 # lower-bound constant, ofinish flag-clear order; 44 # 6 Lean: docs/turing/proofs/TcrBound.lean checks with the pinned toolchain, 10 theorems, no 45 # sorry, standard axioms only (lean found as $LEAN, on PATH or in ~/.elan/bin; missing = FAIL). 46 set -u 47 ROOT=$(cd "$(dirname "$0")/../.." && pwd) 48 TC=$1 49 OUT=$2 50 OMC=${OMC:-$ROOT/seed/out/omc} 51 mkdir -p "$OUT" 52 fails=0 53 pass() { echo "PASS $*"; } 54 fail() { echo "FAIL $*"; fails=$((fails + 1)); } 55 56 build() { # build 57 { printf 'om2\n'; cat "$ROOT/seed/ng/sha256.om" "$1"; } > "$2.unit.om" 58 "$OMC" < "$2.unit.om" > "$2" 2> "$2.err" || return 1 59 chmod +x "$2" 60 } 61 expect_rc() { # expect_rc 62 name=$1; want=$2; shift 2 63 "$@" > "$OUT/last.out" 2> "$OUT/last.err"; rc=$? 64 if [ "$rc" -eq "$want" ]; then pass "$name (exit $rc: $(head -c 120 "$OUT/last.err"))" 65 else fail "$name: exit $rc, want $want"; fi 66 } 67 68 echo "omc sha256 $(sha256sum "$OMC" | cut -d' ' -f1)" 69 B=$OUT/tcr-om 70 if build "$ROOT/src/turing/tc_range.om" "$B"; then pass "build"; else fail "build: $(cat "$B.err")"; exit 1; fi 71 72 if "$B" selftest > "$OUT/selftest.txt" 2>&1 && grep -q '^selftest=PASS$' "$OUT/selftest.txt"; then 73 pass "selftest $(head -n 1 "$OUT/selftest.txt")" 74 else fail "selftest: $(cat "$OUT/selftest.txt")"; fi 75 76 Z=`0000000000000000000000000000000000000000000000000000000000000000` 77 C=$ROOT/calibration/experiments/EXP-001/candidates 78 i=0 79 for TR in tests/turing/fixtures/ctr1_seed1_crumbs05-07.ctr tests/turing/fixtures/ctr1_seed1_crumbs10-12.ctr; do 80 for M in evidence/TURING_YIELD/ty2_candidate.tym uniform:9 $C/B0_uniform.tym $C/B1_order0.tym \ 81 $C/B2_order1.tym $C/B3_heuristic.tym $C/M_candidate.tym; do 82 i=$((i + 1)); D=$OUT/u$i; mkdir -p "$D" 83 case $M in uniform:*) MP=$M ;; /*) MP=$M ;; *) MP=$ROOT/$M ;; esac 84 if ! "$TC" pstream "$MP" $Z "$ROOT/$TR" "$D/s.tps" "$D/s.tsy" > "$D/pstream.txt" 2>&1; then 85 fail "unit $i pstream ($TR $M)"; continue; fi 86 "$TC" encode range "$D/s.tps" "$D/s.tsy" "$D/c.tcr" > /dev/null 2>&1 || fail "unit $i C encode" 87 if "$B" encode range "$D/s.tps" "$D/s.tsy" "$D/o.tcr" > "$D/enc.txt" 2> "$D/enc.err" \ 88 && grep -q '^bound=PASS$' "$D/enc.txt" && grep -q '^lower=PASS$' "$D/enc.txt"; then :; else fail "unit $i Omega encode: $(cat "$D/enc.err")"; continue; fi 89 cmp -s "$D/o.tcr" "$D/c.tcr" || fail "unit $i Omega bytes differ from C" 90 "$TC" verify range "$D/s.tps" "$D/s.tsy" "$D/o.tcr" > /dev/null 2>&1 || fail "unit $i C rejects the Omega file" 91 "$B" verify range "$D/s.tps" "$D/s.tsy" "$D/c.tcr" > "$D/ver.txt" 2>&1 || fail "unit $i Omega rejects the C file" 92 "$B" decode range "$D/s.tps" "$D/o.tcr" "$D/o.tsy" > /dev/null 2>&1 || fail "unit $i Omega decode" 93 cmp -s "$D/o.tsy" "$D/s.tsy" || fail "unit $i decoded TSY1 differs" 94 ci=$(sed -n 's/^ideal_ub=//p' "$D/pstream.txt"); oi=$(sed -n 's/^ideal_ub=//p' "$D/enc.txt") 95 [ "$ci" = "$oi" ] || fail "unit $i ideal_ub C $ci Omega $oi" 96 echo "unit $i n=$(sed -n 's/^count=//p' "$D/enc.txt") ideal_ub=$oi coded_bits=$(sed -n 's/^coded_bits=//p' "$D/enc.txt") slack_ub=$(sed -n 's/^slack_ub=//p' "$D/enc.txt") lower_ub=$(sed -n 's/^lower_ub=//p' "$D/enc.txt") $(basename "$TR") $(basename "$M")" 97 done 98 done 99 [ "$fails" -eq 0 ] && pass "14 units: byte-identical to C both ways, decode exact, ideal_ub equal, bound=PASS, lower=PASS" 100 101 # Refusals (unit 1 files). Each input has one fault; the Omega refusal name must equal the C 102 # reference's (turing-coder prints TC_E_) and both must exit 2. 103 D=$OUT/u1; N=$OUT/neg; mkdir -p "$N" 104 same_refusal() { # same_refusal