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/om/evidence/parity/run.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 / om / evidence / parity / run.sh` 106 lines ยท 6083 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Parity of om/evidence/evidence.om against the C it ports (src/omega_vector.c, src/omega_evidence.c), 4 # by recorded oracle output: corpus.py regenerates the corpus, the .om harness runs every stream in its 5 # own empty directory, and each stream's output, plus the directory tree the path and digest streams 6 # leave behind (pathtree, digtree), must hash to parity/expected.txt. Those hashes are the C oracle's 7 # output, recorded when the port was made; the oracle driver itself is not in the tree. Then sixteen 8 # small mutants of evidence.om must each change their stream's hash (the corpus discriminates). With 9 # OMEGA_BRIDGE set, the 13 exported functions are also cut into function-mode units (unit.py), bound by 10 # the pinned omega-bridge generator and compiled as C (bindability). 11 # OMEGA_OMC seed-born omc, sha256 pinned below (exit 3 NOT_RUN without it) 12 # OMEGA_BRIDGE optional: an aien-dev/omega-bridge checkout whose src/native.om matches the pin 13 # The tree listings hash each entry's path, type and mode, each file's size and content, and no 14 # directory size (filesystem-dependent: ext4 4096, tmpfs 40..3800), so any TMPDIR works; the stream 15 # directory is created 775 whatever the caller's umask. 16 set -eu 17 OMC_PIN=`26540e6de62402d5784b30b24d7c6faae488137c1f8a4b3e784fd0b5d5528991` 18 NATIVE_PIN=`2c2c53f61d4ab302f1a2092c3c32189335dd53f6cf2b388f47a475f99f2c3940` 19 P=$(cd "$(dirname "$0")" && pwd) 20 OM=$P/../evidence.om 21 [ -n "${OMEGA_OMC:-}" ] || { echo "EVIDENCE-PARITY NOT_RUN: set OMEGA_OMC"; exit 3; } 22 [ "$(sha256sum < "$OMEGA_OMC" | cut -c1-64)" = "$OMC_PIN" ] || { echo "EVIDENCE-PARITY NOT_RUN: omc is not the pinned compiler"; exit 3; } 23 command -v python3 > /dev/null || { echo "EVIDENCE-PARITY NOT_RUN: python3 missing"; exit 3; } 24 T=$(mktemp -d); trap 'rm -rf "$T"' EXIT 25 python3 "$P/corpus.py" "$T/corp" > "$T/counts" 26 27 # run BIN STREAM OUT: one stream in a fresh directory; pathtree/digtree list what path/digest left. 28 # A directory's size (find %s) is the filesystem's, not the program's: 4096 on ext4, 40..3800 on tmpfs, 29 # and mktemp follows TMPDIR. So directories list '-' for size; their path, type and mode still count. 30 run() { 31 case $2 in pathtree) rs=path ;; digtree) rs=digest ;; *) rs=$2 ;; esac 32 rm -rf "$T/w"; mkdir -m 775 "$T/w" 33 rc=0; (cd "$T/w" && umask 022 && "$1" $rs < "$T/corp/$rs.txt" > "$T/s.out" 2> /dev/null) || rc=$? 34 case $2 in 35 pathtree|digtree) (cd "$T/w" && { find . \( -type d -printf '%p %y %m -\n' \) -o -printf '%p %y %m %s\n'; find . -type f -exec sha256sum {} +; } | LC_ALL=C sort) > "$3" ;; 36 *) cp "$T/s.out" "$3" ;; 37 esac 38 return $rc 39 } 40 41 "$OMEGA_OMC" < "$OM" > "$T/ev"; chmod +x "$T/ev" 42 grep -v '^#' "$P/expected.txt" | while read -r s n want; do 43 rc=0; run "$T/ev" "$s" "$T/$s.out" || rc=$? 44 got=$(sha256sum < "$T/$s.out" | cut -c1-64) 45 lines=$(wc -l < "$T/$s.out") 46 if [ "$rc" = 0 ] && [ "$got" = "$want" ] && [ "$lines" = "$n" ]; then 47 echo "PASS $s: $n lines, output identical to the C oracle" 48 else 49 echo "FAIL $s: exit $rc, $lines lines, sha256 $got (want $n, $want)"; echo x >> "$T/failed" 50 fi 51 done 52 [ ! -e "$T/failed" ] || { echo "EVIDENCE-PARITY FAIL"; exit 1; } 53 sed 's/^/corpus records: /' "$T/counts" 54 55 # Mutants: name | stream | exact text in evidence.om (\n for a newline) | replacement 56 cat > "$T/mutants" <<'EOF' 57 overflow_byte|vspec|put p 22 1|put p 22 0 58 name_64|vspec|put onm 63 0|put onm 63 get nm 63 59 mismatch_idx|vadd|put idx 0 i|put idx 0 add i 1 60 gen_b|vgen|y = add 2000 mul i 2|y = add 2000 i 61 trim_cr|line|if and ne c 10 and ne c 13 ne c 32|if and ne c 10 ne c 32 62 len_rule|line|if or eq l 0 ge l n|if or eq l 0 gt l n 63 commit_len|line|if ne slen256 view t 40|if ne slen256 view t 41 64 floor_div|runid|q = sub q 1|q = sub q 0 65 leap_month|runid|if le m 2|if lt m 2 66 hex_upper|hw|ret uchar add v 87|ret uchar add v 55 67 path_limit|path|if ge tot 1024\nret -1|if gt tot 1024\nret -1 68 mkdir_mode|pathtree|r = makedir p 0 i 493|r = makedir p 0 i 448 69 rel_dot|digest|put rel sl 46|put rel sl 95 70 exists_rc|digest|if eq fd -17\nret 1|if eq fd -17\nret 0 71 sha_pad|digest|if ge r 56|if ge r 55 72 file_mode|digtree|fd = fopen out 0 l 524481 292|fd = fopen out 0 l 524481 420 73 EOF 74 while IFS='|' read -r name s old new; do 75 python3 - "$OM" "$T/m.om" "$old" "$new" <<'PY' 76 import sys 77 src, dst, old, new = sys.argv[1], sys.argv[2], sys.argv[3].replace("\\n", "\n"), sys.argv[4].replace("\\n", "\n") 78 s = open(src).read() 79 assert s.count(old + "\n") == 1, "mutant text not found exactly once: " + old 80 open(dst, "w").write(s.replace(old + "\n", new + "\n")) 81 PY 82 "$OMEGA_OMC" < "$T/m.om" > "$T/m"; chmod +x "$T/m" 83 rc=0; run "$T/m" "$s" "$T/m.out" || rc=$? 84 got=$(sha256sum < "$T/m.out" | cut -c1-64) 85 want=$(grep "^$s " "$P/expected.txt" | cut -d' ' -f3) 86 if [ "$got" = "$want" ]; then echo "mutant $name NOT killed on $s"; echo x >> "$T/failed"; continue; fi 87 d=$(diff "$T/m.out" "$T/$s.out" | grep -c '^>' || true) 88 echo "mutant $name killed on $s ($d lines differ, exit $rc)" 89 done < "$T/mutants" 90 [ ! -e "$T/failed" ] || { echo "EVIDENCE-PARITY FAIL"; exit 1; } 91 92 if [ -z "${OMEGA_BRIDGE:-}" ]; then 93 echo "EVIDENCE-PARITY PASS (bindability NOT_RUN: set OMEGA_BRIDGE)"; exit 0 94 fi 95 [ "$(sha256sum < "$OMEGA_BRIDGE/src/native.om" | cut -c1-64)" = "$NATIVE_PIN" ] || { echo "EVIDENCE-PARITY PASS (bindability NOT_RUN: native.om is not the pinned generator)"; exit 0; } 96 "$OMEGA_OMC" < "$OMEGA_BRIDGE/src/native.om" > "$T/native"; chmod +x "$T/native" 97 : > "$T/units" 98 for u in vecspec vecadd vecver vecgen lnacc cmtacc runid evpath digrel hwhex shainit shaupd shafin; do 99 python3 "$P/unit.py" "$OM" "$u" > "$T/u.om" 100 "$OMEGA_OMC" < "$T/u.om" > "$T/u.bin" 101 { cat "$T/u.om"; printf '\0'; printf '%08d' "$(wc -c < "$T/u.bin")"; cat "$T/u.bin"; } >> "$T/units" 102 done 103 "$T/native" < "$T/units" > "$T/units.c" 104 cc -std=gnu11 -O2 -Wall -Wextra -Werror -c "$T/units.c" -o "$T/units.o" 105 echo "bindability: 13 function-mode units accepted by native.om and compiled ($(grep -c ') uint32_t omega_[a-z0-9]*(uint64_t \*result' "$T/units.c") exported functions)" 106 echo "EVIDENCE-PARITY PASS"