Skip to content

Commit 51bc005

Browse files
committed
tooling(pm): run the sweep's own self-test before it writes, and refuse unknown flags
`check-self-test-wired` is the gate that settles where the self-test belongs: CI runs this script, so CI must run its cases. The patrol step now runs them first and skips the sweep entirely if they fail -- this step writes to other people's cards, and a broken predicate that still runs is the one failure the next run cannot undo. The CLI gains `--dry-run` as a real flag so the workflow can name the mode it is in, and refuses any argument it does not know: a caller who believes it passed a mode flag and did not must not get a run that looks ordinary. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019RfFHiRCSs3JXLK4cwcfox
1 parent 7078fc0 commit 51bc005

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/half-state-patrol.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,28 @@ jobs:
289289
# and it is load-bearing: a PR must never write to the board.
290290
SWEEP_MODE: ${{ github.event_name == 'pull_request' && '--dry-run' || '--write' }}
291291
run: |
292+
# The judge's own cases first, and the sweep only if they hold: this
293+
# step WRITES to other people's cards, and a broken predicate that
294+
# still runs is the one failure mode that cannot be undone by the next
295+
# run. `check:pm-closed-card-sweep` is the same command under a dev
296+
# -facing name; this is the invocation CI holds.
297+
set +e
298+
node scripts/pm/sweep-closed-cards.mjs --self-test > "$RUNNER_TEMP/closed-cards-selftest.log" 2>&1
299+
selftest=$?
300+
set -e
301+
cat "$RUNNER_TEMP/closed-cards-selftest.log"
302+
if [ "$selftest" != "0" ]; then
303+
echo "exit_code=$selftest" >> "$GITHUB_OUTPUT"
304+
{
305+
echo "### Closed-card sweep — SKIPPED: its own self-test failed (exit $selftest)"
306+
echo
307+
echo '```'
308+
cat "$RUNNER_TEMP/closed-cards-selftest.log"
309+
echo '```'
310+
} >> "$GITHUB_STEP_SUMMARY"
311+
echo "::error::closed-card sweep self-test failed (exit $selftest) — the sweep did NOT run and wrote nothing. Nothing here is a reading about the board."
312+
exit 0
313+
fi
292314
set +e
293315
node scripts/pm/sweep-closed-cards.mjs "$SWEEP_MODE" --provenance="$PROVENANCE" \
294316
> "$RUNNER_TEMP/closed-cards.md" 2> "$RUNNER_TEMP/closed-cards.err"

0 commit comments

Comments
 (0)