interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-replay / mutations / run_mutants.sh

117 lines · 4213 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# Prove the KV ownership checks catch realistic faults.
18#
19# usage: run_mutants.sh native apply each kv.mutants line, run the proptest,
20# expect a FAILED test (KILLED)
21# run_mutants.sh miri apply each miri.mutants line, expect native
22# tests to still pass and `cargo miri test` to fail
23# run_mutants.sh trn1 switch off each TRN1 check (trn1.mutants), expect
24# the shared corpus test to fail; needs TRN1_VECTORS
25# or the sibling ../aien-protocols checkout
26#
27# Works on a scratch copy; the real tree is never modified. Exit 0 only if
28# every mutant is KILLED. A mutant that does not compile counts as BROKEN
29# (a bad mutant, not a kill) and fails the run.
30set -eu
31
32mode=${1:-native}
33here=$(cd "$(dirname "$0")" && pwd)
34root=$(cd "$here/../../.." && pwd)
35case "$mode" in
36native) table="$here/kv.mutants" ;;
37miri) table="$here/miri.mutants" ;;
38trn1) table="$here/trn1.mutants" ;;
39*) echo "usage: $0 native|miri|trn1" >&2; exit 2 ;;
40esac
41
42work=$(mktemp -d)
43trap 'rm -rf "$work"' EXIT INT TERM
44mkdir -p "$work/crates"
45for c in aien-kv-cache aien-platform aien-platform-linux aien-replay; do
46 mkdir -p "$work/crates/$c"
47 (cd "$root/crates/$c" && tar cf - --exclude=./target .) | (cd "$work/crates/$c" && tar xf -)
48done
49# Minimal workspace root: same [workspace.package] values, only the three
50# crates the test needs, so the copy builds without the aien-protocols sibling.
51awk '/^members = \[/ { print "members = [\"crates/aien-kv-cache\", \"crates/aien-platform\", \"crates/aien-platform-linux\"]"; skip = 1; next }
52 skip && /^\]/ { skip = 0; next }
53 !skip { print }' "$root/Cargo.toml" >"$work/Cargo.toml"
54
55src="$work/crates/aien-kv-cache/src/lib.rs"
56test=kv_ownership_props
57if [ "$mode" = trn1 ]; then
58 src="$work/crates/aien-replay/src/lib.rs"
59 test=trn1_conformance
60 vectors=$(cd "${TRN1_VECTORS:-$root/../aien-protocols/specs/execution-transcript/vectors}" && pwd)
61 export TRN1_VECTORS="$vectors" TRN1_REQUIRE=1
62fi
63cp "$src" "$work/lib.rs.orig"
64manifest="$work/crates/aien-replay/Cargo.toml"
65export CARGO_TARGET_DIR="${MUTANT_TARGET_DIR:-$work/target}"
66cargo=${CARGO:-cargo}
67
68run_native() { $cargo test --offline --manifest-path "$manifest" --test "$test" >"$1" 2>&1; }
69run_miri() { $cargo +nightly miri test --manifest-path "$manifest" --test "$test" >"$1" 2>&1; }
70
71fail=0
72killed=0
73total=0
74tab=$(printf '\t')
75while IFS="$tab" read -r id expr what; do
76 case "$id" in '' | '#'*) continue ;; esac
77 total=$((total + 1))
78 cp "$work/lib.rs.orig" "$src"
79 sed -i "$expr" "$src"
80 if cmp -s "$src" "$work/lib.rs.orig"; then
81 echo "BROKEN $id: sed expression matched nothing"
82 fail=1
83 continue
84 fi
85 log="$work/$id.log"
86 if [ "$mode" != miri ]; then
87 if run_native "$log"; then
88 echo "SURVIVED $id ($what)"
89 fail=1
90 elif grep -q "test result: FAILED" "$log"; then
91 echo "KILLED $id ($what)"
92 killed=$((killed + 1))
93 else
94 echo "BROKEN $id: did not compile"
95 tail -n 20 "$log"
96 fail=1
97 fi
98 else
99 if ! run_native "$log.native"; then
100 echo "NOTE $id: native tests also fail, so this is not a Miri-only catch"
101 fi
102 if run_miri "$log"; then
103 echo "SURVIVED $id under Miri ($what)"
104 fail=1
105 elif grep -q "Undefined Behavior" "$log"; then
106 echo "KILLED $id under Miri ($what)"
107 killed=$((killed + 1))
108 else
109 echo "BROKEN $id: Miri run failed without reporting UB"
110 tail -n 20 "$log"
111 fail=1
112 fi
113 fi
114done <"$table"
115
116echo "mode=$mode killed=$killed total=$total"
117exit "$fail"