Files
stack/agents/rocko/work/queue-78/mutants.sh
T
jason.woltjeandClaude Opus 5.5 2ece44919e rocko: row 78 round 1 packet, BUILD-LOG and SESSIONS (#1572)
Packet agents/rocko/work/queue-78/ (packet manifest 9e067f40, 32 files,
candidate manifest 3016dbf1), 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:10:16 -05:00

44 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Row 78 (#1572): rerun the mutants against a tree. Usage: mutants.sh <tree>.
# Each mutant makes one check in scripts/bus-service.sh skip the default pin
# (no --claude) while still applying to --claude, runs the cli host tests,
# 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.
set -euo pipefail
TREE="$(cd "${1:?usage: mutants.sh <tree>}" && pwd)"
cd "$TREE"
SCRIPT=scripts/bus-service.sh
TESTS=(packages/cli/tests/host.test.mjs)
run_tests() { node --test "${TESTS[@]}" >"$1" 2>&1; }
# name | sed expression
MUTANTS=(
'default-skips-exec-check|s/^ \[ -f "\$bin" \] && \[ -x "\$bin" \] || die / [ "$CLAUDE_SET" = 0 ] || { [ -f "$bin" ] \&\& [ -x "$bin" ]; } || die /'
'default-skips-char-check|s/^ case "\$bin" in \*\[!A-Za-z0-9\/._+-\]\*) die / case "$bin" in *[!A-Za-z0-9\/._+-]*) [ "$CLAUDE_SET" = 0 ] || die /'
)
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 "$SCRIPT" "$OUT/orig"
sed -i -e "$expr" "$SCRIPT"
if cmp -s "$OUT/orig" "$SCRIPT"; then
echo "$name: NOT APPLIED (sed matched nothing)"; status=1; continue
fi
diff -u "$OUT/orig" "$SCRIPT" >"$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" "$SCRIPT"
cmp -s "$OUT/orig" "$SCRIPT" || { echo "restore failed: $SCRIPT" >&2; exit 1; }
rm -f "$OUT/orig"
done
exit "$status"