aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / tools / aien-test / mutations / run_mutants.sh
| 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 | # Prove the aien-test unit tests catch realistic faults. |
| 18 | # |
| 19 | # usage: tools/aien-test/mutations/run_mutants.sh |
| 20 | # |
| 21 | # Applies each line of aien-test.mutants (id TAB file TAB sed expression TAB |
| 22 | # what it models) to a scratch copy of the crate, runs `cargo test`, and |
| 23 | # expects a FAILED test (KILLED). Exit 0 only if every mutant is KILLED. A |
| 24 | # mutant whose sed changes nothing, or that does not compile, is BROKEN and |
| 25 | # fails the run. The real tree is never modified. |
| 26 | set -eu |
| 27 | |
| 28 | here=$(cd "$(dirname "$0")" && pwd) |
| 29 | crate=$(cd "$here/.." && pwd) |
| 30 | root=$(cd "$here/../../.." && pwd) |
| 31 | table="$here/aien-test.mutants" |
| 32 | |
| 33 | work=$(mktemp -d) |
| 34 | trap 'rm -rf "$work"' EXIT INT TERM |
| 35 | mkdir -p "$work/tools/aien-test" |
| 36 | (cd "$crate" && tar cf - --exclude=./target --exclude=./mutations .) | (cd "$work/tools/aien-test" && tar xf -) |
| 37 | cp "$root/Cargo.lock" "$work/Cargo.lock" |
| 38 | # Minimal workspace root: same [workspace.package] values, only this crate. |
| 39 | awk '/^members = \[/ { print "members = [\"tools/aien-test\"]"; skip = 1; next } |
| 40 | skip && /^\]/ { skip = 0; next } |
| 41 | !skip { print }' "$root/Cargo.toml" >"$work/Cargo.toml" |
| 42 | |
| 43 | export CARGO_TARGET_DIR="${MUTANT_TARGET_DIR:-$work/target}" |
| 44 | cargo=${CARGO:-cargo} |
| 45 | manifest="$work/tools/aien-test/Cargo.toml" |
| 46 | |
| 47 | # Sanity: the unmutated copy must pass, or every "kill" would be meaningless. |
| 48 | if ! $cargo test --offline --manifest-path "$manifest" >"$work/baseline.log" 2>&1; then |
| 49 | echo "BASELINE FAILED: the unmutated crate does not pass its own tests" |
| 50 | tail -n 30 "$work/baseline.log" |
| 51 | exit 1 |
| 52 | fi |
| 53 | |
| 54 | fail=0 |
| 55 | killed=0 |
| 56 | total=0 |
| 57 | tab=$(printf '\t') |
| 58 | while IFS="$tab" read -r id file expr what; do |
| 59 | case "$id" in '' | '#'*) continue ;; esac |
| 60 | total=$((total + 1)) |
| 61 | src="$work/tools/aien-test/src/$file" |
| 62 | cp "$crate/src/$file" "$src" |
| 63 | sed -i "$expr" "$src" |
| 64 | if cmp -s "$src" "$crate/src/$file"; then |
| 65 | echo "BROKEN $id: sed expression matched nothing" |
| 66 | fail=1 |
| 67 | continue |
| 68 | fi |
| 69 | log="$work/$id.log" |
| 70 | if $cargo test --offline --manifest-path "$manifest" >"$log" 2>&1; then |
| 71 | echo "SURVIVED $id ($what)" |
| 72 | fail=1 |
| 73 | elif grep -q "test result: FAILED" "$log"; then |
| 74 | echo "KILLED $id ($what)" |
| 75 | killed=$((killed + 1)) |
| 76 | else |
| 77 | echo "BROKEN $id: did not compile" |
| 78 | tail -n 20 "$log" |
| 79 | fail=1 |
| 80 | fi |
| 81 | cp "$crate/src/$file" "$src" |
| 82 | done <"$table" |
| 83 | |
| 84 | echo "killed=$killed total=$total" |
| 85 | exit "$fail" |