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/seed/qualification/om2/candidates/sha/mutants/run-mutants.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 / seed / qualification / om2 / candidates / sha / mutants / run-mutants.sh` 65 lines ยท 3525 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # OM-2 qualification L836 (#748), phaseB/sha-`f5d14cb2`: source mutants of om/sha256/sha256-om2.om. 4 # For each NAME.from/NAME.to pair in this folder (and the unmutated CONTROL): the .from bytes must 5 # occur exactly once in the unit (else INVALID); a scratch copy gets them replaced by the .to bytes, 6 # keeping the basename sha256-om2.om; it is compiled by the S4 omc (sha256 checked), bound by the 7 # bridge generator (tools/native), and the ORACLE driver oracle/sha/sha_qual.c is linked against that 8 # binding. Modes run in order vec, rcpt, part, rand 748 200, bigzero, big; the first FAIL line (status 9 # 0, wrong digest) is the kill. A TRAP line alone is not a kill; a signal is INVALID. 10 # Usage (repository root): sh .../run-mutants.sh UNIT OMC OMC_SHA256 SCRATCH [NAME...] 11 set -u 12 UNIT=$1; OMC=$2; PIN=$3; S=$4; shift 4 13 Q=$(cd "$(dirname "$0")/../../.." && pwd) # seed/qualification/om2 14 MD=$Q/candidates/sha/mutants 15 DRV=$Q/oracle/sha/sha_qual.c 16 VEC=$Q/fixtures/sha256-vectors.txt 17 ROOT=$(cd "$Q/../../.." && pwd) 18 SEEDOMC=$ROOT/seed/out/omc 19 BRIDGE=${BRIDGE:-/tmp/zl/qbridge} 20 [ "$(/usr/bin/sha256sum < "$OMC" | cut -d' ' -f1)" = "$PIN" ] || { echo "INVALID omc sha256 mismatch"; exit 3; } 21 [ ! -e "$S" ] || { echo "scratch $S exists"; exit 91; } 22 mkdir -p "$S" 23 names=${*:-CONTROL $(cd "$MD" && ls *.from | sed 's/\.from$//')} 24 for n in $names; do 25 d=$S/$n; mkdir -p "$d" 26 if [ "$n" = CONTROL ]; then cp "$UNIT" "$d/sha256-om2.om" 27 else 28 /usr/bin/python3 - "$UNIT" "$MD/$n.from" "$MD/$n.to" "$d/sha256-om2.om" > "$d/anchor.txt" <<'EOF' 29 import sys 30 src = open(sys.argv[1], 'rb').read(); a = open(sys.argv[2], 'rb').read(); b = open(sys.argv[3], 'rb').read() 31 c = src.count(a) 32 print(f"anchor-count={c} line={src[:src.find(a)].count(b'\n') + 1 if c else 0}") 33 if c != 1: 34 sys.exit(1) 35 open(sys.argv[4], 'wb').write(src.replace(a, b)) 36 EOF 37 [ $? = 0 ] || { echo "MUTANT $n INVALID anchor $(cat "$d/anchor.txt")"; continue; } 38 fi 39 src=$(/usr/bin/sha256sum < "$d/sha256-om2.om" | cut -d' ' -f1) 40 if ! "$OMC" < "$d/sha256-om2.om" > "$d/code.bin" 2> "$d/omc.err"; then 41 echo "MUTANT $n NOT_COMPILED $(cat "$d/omc.err")"; continue 42 fi 43 art=$(/usr/bin/sha256sum < "$d/code.bin" | cut -d' ' -f1) 44 OMEGA_NATIVE_OMC=$SEEDOMC OMEGA_NATIVE_OMC2=$OMC sh "$BRIDGE/tools/native" "$d/bind" "$d/sha256-om2.om" > "$d/native.log" 2>&1 \ 45 || { echo "MUTANT $n INVALID tools/native $(cat "$d/native.log")"; continue; } 46 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -I"$d/bind" "$DRV" -L"$d/bind" -lomega_native -Wl,-rpath,"$d/bind" -o "$d/drv" \ 47 || { echo "MUTANT $n INVALID driver build"; continue; } 48 verdict="" 49 for mode in "vec $VEC $ROOT" rcpt part "rand 748 200" bigzero big; do 50 m=${mode%% *} 51 # shellcheck disable=SC2086 52 "$d/drv" $mode > "$d/$m.out" 2>&1; rc=$? 53 if [ $rc -gt 128 ] || [ $rc = 3 ] || [ $rc = 90 ]; then verdict="INVALID mode=$m exit=$rc (signal or oracle failure)"; break; fi 54 f=$(grep -m1 '^FAIL' "$d/$m.out") 55 if [ -n "$f" ]; then 56 t=$(grep -c '^TRAP' "$d/$m.out") 57 verdict="KILLED mode=$m traps-in-mode=$t $f"; break 58 fi 59 t=$(grep -m1 '^TRAP' "$d/$m.out") 60 [ -z "$t" ] || echo "MUTANT $n NOTE trap without wrong digest in mode $m: $t" 61 [ "$n" != CONTROL ] || grep '^TOTAL' "$d/$m.out" | sed "s/^/MUTANT $n /" 62 done 63 [ -n "$verdict" ] || verdict=$([ "$n" = CONTROL ] && echo "PASS all modes clean" || echo "SURVIVED") 64 echo "MUTANT $n src=$src artifact=$art $(cat "$d/anchor.txt" 2> /dev/null) $verdict" 65 done