Files
stack/agents/rocko/work/queue-79/mutants.sh
T
jason.woltjeandClaude Opus 5.5 1735f27d37 rocko: row 79 round 1 packet, BUILD-LOG and SESSIONS (#1573)
Packet agents/rocko/work/queue-79/ (packet manifest b6b11e7b, 42 files,
candidate manifest 16b12387), Rocko's BUILD-LOG and SESSIONS appends.
Committed by Sage for Rocko, who has no credential.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-11 19:19:14 -05:00

46 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Row 79 (#1573): rerun the untyped-list mutants against a tree. Usage:
# mutants.sh <tree>. Each mutant edits untypedActions in
# packages/harness/src/tools.mjs, runs the harness tools test, and restores
# the file from a saved copy, so the tree need not be committed. Prints
# "killed" or "SURVIVED" per mutant; exit 1 if any survives, a sed doesn't
# change the file, or the unmutated run fails. untyped-within-only stands in
# for Dewey's mutant of that name (row 73 comment 27506).
set -euo pipefail
TREE="$(cd "${1:?usage: mutants.sh <tree>}" && pwd)"
cd "$TREE"
SRC=packages/harness/src/tools.mjs
TESTS=(packages/harness/tests/tools.test.mjs)
run_tests() { node --test "${TESTS[@]}" >"$1" 2>&1; }
# name | sed expression
MUTANTS=(
'untyped-within-only|s/^ return \[\.\.\.resolved\.limits\.authority\.withinRole, \.\.\.resolved\.limits\.authority\.crossRole\]\.filter/ return [...resolved.limits.authority.withinRole].filter/'
'untyped-cross-first|s/^ return \[\.\.\.resolved\.limits\.authority\.withinRole, \.\.\.resolved\.limits\.authority\.crossRole\]\.filter/ return [...resolved.limits.authority.crossRole, ...resolved.limits.authority.withinRole].filter/'
'untyped-keeps-typed|s/\.filter((a) => !typed\.has(a));$/.filter((a) => a === "message.send" || !typed.has(a));/'
)
OUT="${OUT:-$TREE/.mutants}"
mkdir -p "$OUT"
run_tests "$OUT/baseline.log" || { echo "baseline run failed: $OUT/baseline.log" >&2; exit 1; }
echo "baseline: pass"
status=0
for m in "${MUTANTS[@]}"; do
IFS='|' read -r name expr <<<"$m"
cp -p "$SRC" "$OUT/orig"
sed -i -e "$expr" "$SRC"
if cmp -s "$OUT/orig" "$SRC"; then
echo "$name: NOT APPLIED (sed matched nothing)"; status=1; continue
fi
diff -u "$OUT/orig" "$SRC" >"$OUT/$name.diff" || true
if run_tests "$OUT/$name.log"; then
echo "$name: SURVIVED"; status=1
else
echo "$name: killed ($(grep -E '^✖' "$OUT/$name.log" | grep -v 'failing tests' | sed 's/ ([0-9.]*ms)$//' | sort -u | tr '\n' ';'))"
fi
cp -p "$OUT/orig" "$SRC"
cmp -s "$OUT/orig" "$SRC" || { echo "restore failed: $SRC" >&2; exit 1; }
rm -f "$OUT/orig"
done
exit "$status"