Rocko's packet agents/rocko/work/queue-73/ (candidate manifest bf4e5ed6, packet manifest 41ffcd5c, 53 files), their BUILD-LOG entry and SESSIONS line. Sage's SESSIONS line for the review request (comment 27467) and row 79 (#1573) for the stale text the packet names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
57 lines
2.6 KiB
Bash
Executable File
57 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Row 73 (#1567): rerun the role-file revert and the mutants against a tree
|
|
# with the candidate. Usage: mutants.sh <tree>. Each mutant edits one line,
|
|
# runs the row's 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 its file, or the unmutated run fails.
|
|
# The tasks test is in the list but kills nothing here: the verb refuses a
|
|
# coder's task.reassign with or without the grant.
|
|
set -euo pipefail
|
|
TREE="$(cd "${1:?usage: mutants.sh <tree>}" && pwd)"
|
|
cd "$TREE"
|
|
ROLE=roles/coder.json
|
|
BROKER=packages/bus/src/broker.mjs
|
|
RESOLVE=packages/business/src/resolve.mjs
|
|
TOOLS=packages/harness/src/tools.mjs
|
|
TESTS=(
|
|
packages/bus/tests/broker.test.mjs
|
|
packages/business/tests/role.test.mjs
|
|
packages/business/tests/resolve.test.mjs
|
|
packages/harness/tests/tools.test.mjs
|
|
packages/tasks/tests/verbs.test.mjs
|
|
)
|
|
run_tests() { node --test "${TESTS[@]}" >"$1" 2>&1; }
|
|
|
|
# name | file | sed expression
|
|
MUTANTS=(
|
|
'role-keeps-reassign|'"$ROLE"'|s/"crossRole": \["task.scope.change"\]/"crossRole": ["task.reassign", "task.scope.change"]/'
|
|
'broker-unlisted-cross|'"$BROKER"'|/^ ? .cross-role.$/{n;s/^ : .gated.;$/ : '"'"'cross-role'"'"';/}'
|
|
'resolve-cross-unnarrowed|'"$RESOLVE"'|s/^ crossRole = crossRole.filter((a) => vars\["limits.authority"\].includes(a));$/ crossRole = [...crossRole];/'
|
|
'classify-unlisted-cross|'"$RESOLVE"'|/^ if (resolved.limits.authority.crossRole.includes(action)) return "cross";$/{n;s/return "gated";/return "cross";/}'
|
|
'tools-all-task-verbs|'"$TOOLS"'|s/^ if (held.has(action)) add(name, action, action, description, obj(properties, required));$/ add(name, action, action, description, obj(properties, required));/'
|
|
)
|
|
|
|
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 file expr <<<"$m"
|
|
cp -p "$file" "$OUT/orig"
|
|
sed -i -e "$expr" "$file"
|
|
if cmp -s "$OUT/orig" "$file"; then
|
|
echo "$name: NOT APPLIED (sed matched nothing)"; status=1; continue
|
|
fi
|
|
diff -u "$OUT/orig" "$file" >"$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" "$file"
|
|
cmp -s "$OUT/orig" "$file" || { echo "restore failed: $file" >&2; exit 1; }
|
|
rm -f "$OUT/orig"
|
|
done
|
|
exit "$status"
|