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/aien-protocols-mv/blob/main/specs/aienet/jobpath/mutants.sh # aien-protocols-mv Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-protocols-mv / specs / aienet / jobpath / mutants.sh` 85 lines ยท 4207 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # Guard mutants for the Aienet-0 job path profile. Each `AN0-GUARD ` 3 # statement in crates/aien-microjob/src/aienet0.rs is removed (or, for 4 # executor-pin, made to trust the receipt's own signer) in a scratch copy of 5 # the crate, and the unit tests must then FAIL. A mutant that still passes 6 # means the guard is not tested. Two Omega mutants of the recompute must make 7 # parity.sh fail. Usage: mutants.sh OMC (or set OMEGA_OMC and OMEGA_MV). 8 # Exit 0 only when the baseline passes and every Rust and Omega mutant is killed. 9 set -e -u -o pipefail 10 here=$(cd "$(dirname "$0")" && pwd) 11 root=$(cd "$here/../../.." && pwd) 12 omc=${1:-${OMEGA_OMC:-}} 13 if [ -z "$omc" ] || [ ! -x "$omc" ] || [ -z "${OMEGA_MV:-}" ]; then 14 echo "OM-MUTANTS NOT_RUN: set executable OMEGA_OMC (or OMC argument) and OMEGA_MV" 15 exit 2 16 fi 17 scratch=$(mktemp -d /tmp/an0-mutants.XXXXXX) 18 trap 'rm -rf "$scratch"' EXIT 19 export CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-$root/target/mutants} 20 src=crates/aien-microjob/src/aienet0.rs 21 cp -a "$root/Cargo.toml" "$root/Cargo.lock" "$root/crates" "$scratch/" 22 pristine=$(cat "$root/$src") 23 killed=0; survived=0 24 25 # Establish the exact parity path before counting any failed mutant as killed. 26 if ! OMEGA_OMC=$omc "$here/build.sh" "$scratch/recompute"; then 27 echo "OM-MUTANTS NOT_RUN: baseline build failed"; exit 2 28 fi 29 if ! "$here/parity.sh" "$scratch/recompute"; then 30 echo "OM-MUTANTS INVALID: baseline parity failed"; exit 2 31 fi 32 33 run_tests() { 34 (cd "$scratch" && cargo test -q -p aien-microjob --lib aienet0 >/dev/null 2>&1) 35 } 36 37 printf '%s\n' "$pristine" > "$scratch/$src" 38 if ! run_tests; then echo "BASELINE FAIL: unmutated tests do not pass"; exit 2; fi 39 echo "BASELINE PASS" 40 41 names=$(grep -o 'AN0-GUARD [a-z-]*' "$root/$src" | awk '{print $2}') 42 for name in $names; do 43 if [ "$name" = executor-pin ]; then 44 printf '%s\n' "$pristine" | sed "s|let trusted = vec!\[pinned_executor\]; // AN0-GUARD executor-pin|let trusted = vec![decode_receipt(receipt)?.signer_key];|" > "$scratch/$src" 45 else 46 # Drop the whole tagged statement: one line, or (as rustfmt wraps it) the 47 # lines from an opening `guard(` through the tagged `)?;`. 48 printf '%s\n' "$pristine" | awk -v tag="AN0-GUARD $name" ' 49 buf != "" { buf = buf "\n" $0; if ($0 ~ /^[[:space:]]*\)\?;/) { if (index($0, tag) == 0) print buf; buf = "" } ; next } 50 /^[[:space:]]*guard\($/ { buf = $0; next } 51 index($0, "// " tag) && $0 ~ (tag "$") { next } 52 { print }' > "$scratch/$src" 53 fi 54 if cmp -s "$root/$src" "$scratch/$src"; then echo "MUTANT $name NOT APPLIED"; exit 2; fi 55 if ! (cd "$scratch" && cargo test -q -p aien-microjob --lib --no-run >/dev/null 2>&1); then 56 echo "MUTANT $name BUILD-FAILED (not counted)"; exit 2 57 fi 58 if run_tests; then echo "MUTANT $name SURVIVED"; survived=$((survived + 1)); else echo "MUTANT $name KILLED"; killed=$((killed + 1)); fi 59 done 60 61 # Omega recompute mutants: a changed splitmix constant and a dropped 62 # accumulate. Built with the same pinned build.sh; parity.sh must fail. 63 om=$here/matmul_u32_recompute.om 64 for spec in 'splitmix-constant|s/0xbf58476d1ce4e5b9/0xbf58476d1ce4e5b8/' 'drop-accumulate|s/^acc = add acc mul x get b q$/acc = mul x get b q/'; do 65 name=${spec%%|*}; expr=${spec#*|} 66 mkdir -p "$scratch/om-$name" 67 cp "$here/build.sh" "$here/pins.txt" "$scratch/om-$name/" 68 sed "$expr" "$om" > "$scratch/om-$name/matmul_u32_recompute.om" 69 if cmp -s "$om" "$scratch/om-$name/matmul_u32_recompute.om"; then echo "OM-MUTANT $name NOT APPLIED"; exit 2; fi 70 if ! OMEGA_OMC=$omc OMEGA_MV=${OMEGA_MV:?set OMEGA_MV} "$scratch/om-$name/build.sh" "$scratch/om-$name/bin" >/dev/null 2>&1; then 71 echo "OM-MUTANT $name BUILD-FAILED (not counted)"; exit 2 72 fi 73 if "$here/parity.sh" "$scratch/om-$name/bin" >"$scratch/om-$name/parity.log" 2>&1; then 74 echo "OM-MUTANT $name SURVIVED"; survived=$((survived + 1)) 75 else 76 rc=$? 77 if [ "$rc" != 1 ]; then 78 cat "$scratch/om-$name/parity.log" 79 echo "OM-MUTANT $name INVALID parity rc=$rc (not counted)"; exit 2 80 fi 81 echo "OM-MUTANT $name KILLED"; killed=$((killed + 1)) 82 fi 83 done 84 echo "killed=$killed survived=$survived" 85 [ "$survived" = 0 ]