From 3185352ffca90a66ef0f14889ec23aa86b519937 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 7 Sep 2026 17:17:28 +0000 Subject: [PATCH] fix(tooling): derive check-wildcard-fallthrough's self-test case count from its own ledger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The self-test verdict printed a transcribed `17 cases` while the body ran 18 assertions and the battery roster pinned 18 — a number nothing derived and nothing compared. The literal was left wrong deliberately when the floor landed, so that change could prove byte-identical output; correcting it is this change. The line now sums `batterySeen`, the same ledger the floor immediately above evaluates, so the printed number and the floor can no longer disagree and a block that stops running shrinks the count instead of leaving a stale literal standing. What it counts is assertions that RAN, not `assert(` call sites in the source — today both are 18, and the comment says which one is meant. The in-place comment that explained why the literal was knowingly wrong, and the roster's present-tense description of the verdict as transcribed, are both rewritten: left standing next to a derived line they would tell the next reader the opposite of what the file does. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8 --- scripts/check-wildcard-fallthrough.mjs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/check-wildcard-fallthrough.mjs b/scripts/check-wildcard-fallthrough.mjs index 7dad490313..bf00750b2d 100644 --- a/scripts/check-wildcard-fallthrough.mjs +++ b/scripts/check-wildcard-fallthrough.mjs @@ -460,9 +460,11 @@ const SELF_TEST_VERDICT = 'check-wildcard-fallthrough self-test reached its verd // // "no assertion threw" used to be this self-test's ONLY success condition, so // "every case held" and "the cases never ran" printed the same line — and this -// file's verdict spells a TRANSCRIBED count (`17 cases`), which is evidence, not -// proof: nothing compared it, so a deleted block shrank the real count while the -// literal stayed put. Closed the way PR #13487 validated on check-doc-authoring: +// file's verdict once spelled a TRANSCRIBED count (a literal `17` against a real +// 18), which is evidence, not proof: nothing compared it, so a deleted block +// shrank the real count while the literal stayed put. The verdict now derives +// its number from the ledger this roster floors (#15231). Closed the way PR +// #13487 validated on check-doc-authoring: // what is pinned is the registered NAMES, not a number, and the floor requires // the OPENED set to equal the DECLARED set with each battery at or above its own // count. @@ -625,13 +627,16 @@ function selfTest() { process.exit(1); } - // ⚠️ MEASURED at 18, not 17: this transcribed literal had already drifted one - // below the real count before this floor existed, which is precisely why a - // printed number is evidence and not proof. It is left as-is here so this - // change stays a pure no-op on output; the correction is filed separately, and - // the floor above is what makes the drift harmless — the count can no longer - // shrink in silence. - console.log('✓ self-test: 17 cases'); + // The verdict DERIVES its number from `batterySeen` — the very ledger the floor + // above just evaluated — so the printed count and the floor can never disagree, + // and a block that stops running shrinks the number instead of leaving a + // transcribed literal standing (#15231). What it counts is assertions that + // actually RAN this run, not `assert(` call sites in the source: those are two + // different facts, and only the first one is measured here. Summing the whole + // ledger is exact because reaching this line means every battery that + // registered is a declared one — the set difference above reds otherwise. + const casesRun = [...batterySeen.values()].reduce((total, count) => total + count, 0); + console.log(`✓ self-test: ${casesRun} cases`); return SELF_TEST_VERDICT; }