Files
jason.woltje 6bad02612a lead: commit dewey's untracked evidence (721 files: queue-124-review queue-143 queue-149 queue-165-review queue-170 queue-175 queue-177 queue-184 queue-191)
Unclaimed files left in the canonical checkout. Inventory: canonical-cleanup-inventory.md (commit-as-evidence groups). detect-secrets scan clean on 2026-11-02: hits are sha256 pins, git object ids, test sentinels already in tracked tests and unit-file lines.
2026-11-02 15:05:14 -06:00

73 lines
4.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Dewey's row 124 round 2 review runs, in Sage's slot. Usage: run.sh <r124b worktree>.
# 1. The round 1 list of 20 test files, one node --test at a time.
# 2. ../probes.mjs: p1 must now refuse invalid-timestamp; p2 is unchanged (transcript source unchanged).
# 3. Two mutants, one per round 2 check: m65 drops usage_records from timedTables (store.test.mjs),
# m66 is round 1's d1 (transcript.test.mjs). Each file is backed up (abort on failure), restored by
# a trap on any exit, and must hash to its candidate manifest line before the script goes on.
set -uo pipefail
WT=$(cd "$1" && pwd) || exit 2
OUT=$(cd "$(dirname "$0")" && pwd) || exit 2
mkdir -p "$OUT/single" "$OUT/mutants" "$OUT/backup" "$HOME/dewey-scratch/tmp/lt" || exit 2
export TMPDIR=$HOME/dewey-scratch/tmp
M="$OUT/candidate-manifest.sha256"
status=0
counts() { grep -E '^ℹ (tests|pass|fail|skipped) ' "$1" | awk '{printf "%s=%s ", $2, $3}'; }
check() { (cd "$WT" && sha256sum -c --quiet "$M"); }
echo "start $(date -u +%FT%TZ) head $(git -C "$WT" rev-parse --short HEAD)"
check || { echo "manifest check failed"; exit 2; }
for f in \
packages/bus/tests/usage.test.mjs packages/bus/tests/usage-broker.test.mjs packages/bus/tests/usage-runtime.test.mjs \
packages/bus/tests/usage-migration.test.mjs packages/bus/tests/schema.test.mjs packages/bus/tests/store.test.mjs \
packages/bus/tests/chief-of-staff.test.mjs packages/bus/tests/comment-migration.test.mjs packages/bus/tests/name-migration.test.mjs \
packages/bus/tests/spec-migration.test.mjs packages/bus/tests/thread-migration.test.mjs packages/bus/tests/broker.test.mjs \
packages/plugins/tests/transcript.test.mjs packages/harness/tests/runner.test.mjs packages/cli/tests/usage.test.mjs \
packages/webui/tests/usage.test.mjs packages/webui/tests/usage-browser.test.mjs packages/webui/tests/views.test.mjs \
packages/webui/tests/reads.test.mjs packages/cli/tests/launcher.test.mjs; do
[ -f "$WT/$f" ] || { echo "MISSING $f"; status=1; continue; }
log="$OUT/single/$(echo "$f" | tr / _).log"
if [ "$f" = packages/cli/tests/launcher.test.mjs ]; then
(cd "$WT" && TMPDIR=$HOME/dewey-scratch/tmp/lt setsid -w timeout -k 10 600 node --test --test-reporter=spec "$f") > "$log" 2>&1; rc=$?
else
(cd "$WT" && setsid -w timeout -k 10 600 node --test "$f") > "$log" 2>&1; rc=$?
fi
echo "$f rc=$rc $(counts "$log")"; [ $rc -eq 0 ] || status=1
done
(cd "$WT" && setsid -w timeout -k 10 120 node "$OUT/../probes.mjs") > "$OUT/probes.log" 2>&1; echo "probes rc=$?"; cat "$OUT/probes.log"
# mutant ID FILE TEST OLD NEW
mutant() {
id=$1 T=$2 test=$3 old=$4 new=$5 want="" rc=0
want=$(awk -v f="$T" '$2 == f || $2 == "./" f {print $1}' "$M")
[ -n "$want" ] || { echo "$id: $T not in manifest"; exit 2; }
[ "$(sha256sum < "$WT/$T" | cut -d' ' -f1)" = "$want" ] || { echo "$id: $T differs from manifest before the edit"; exit 2; }
cp "$WT/$T" "$OUT/backup/$id" || { echo "$id: backup failed"; exit 1; }
cmp -s "$WT/$T" "$OUT/backup/$id" || { echo "$id: backup differs"; exit 1; }
restore() {
cp "$OUT/backup/$id" "$WT/$T" || { echo "$id: restore copy failed"; exit 1; }
[ "$(sha256sum < "$WT/$T" | cut -d' ' -f1)" = "$want" ] || { echo "$id: restored hash differs from manifest"; exit 1; }
echo "$id restored, $T sha256 $want matches manifest"
}
trap 'trap - EXIT; restore' EXIT
python3 - "$WT/$T" "$old" "$new" <<'PY' || { echo "$id: edit refused"; exit 1; }
import sys, pathlib
p = pathlib.Path(sys.argv[1]); t = p.read_text(); old, new = sys.argv[2], sys.argv[3]
if t.count(old) != 1: sys.exit(f"{t.count(old)} matches")
p.write_text(t.replace(old, new))
PY
(cd "$WT" && setsid -w timeout -k 10 300 node --test "$test") > "$OUT/mutants/$id.log" 2>&1; rc=$?
trap - EXIT; restore
if [ $rc -ne 0 ]; then echo "$id caught: $(grep -m1 -E '^✖ ' "$OUT/mutants/$id.log" | cut -c1-140)"
else echo "$id SURVIVED"; status=1; fi
}
mutant m65 packages/bus/src/store.mjs packages/bus/tests/store.test.mjs " 'usage_records',
" ""
mutant m66 packages/plugins/usage-source/transcript/index.mjs packages/plugins/tests/transcript.test.mjs \
'const child = openSync(at(fd, entry.name), DIR);' \
'const child = openSync(at(fd, entry.name), constants.O_RDONLY | constants.O_DIRECTORY);'
check || { echo "manifest check failed after"; status=1; }
echo "single totals: $(cat "$OUT"/single/*.log | grep -E '^ℹ (tests|pass|fail|skipped) ' | awk '{s[$2]+=$3} END{printf "tests=%d pass=%d fail=%d skipped=%d", s["tests"], s["pass"], s["fail"], s["skipped"]}')"
echo "dirty paths: $(cd "$WT" && git status --short | grep -v node_modules | wc -l)"
echo "end $(date -u +%FT%TZ) status=$status"
exit $status