From 4b57b4f1bd0581733c13ce431d437e6f2426282d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 10 Sep 2026 09:20:34 +0000 Subject: [PATCH] Derive the four residual self-test verdict counts from their battery ledger check-init-service-contract.mjs, check-kernel-hook-pairs.mjs, check-quick-reference-counts.mjs and check-spec-parsed-alias.mjs each printed a transcribed literal count that nothing derived. All four already carry the SELF_TEST_BATTERIES + batterySeen ledger the floor above the verdict line evaluates, so each verdict now reads its number off that ledger instead of a hand-maintained literal, the same shape PR #16669 landed for check-wildcard-fallthrough.mjs. Three files count batteries that ran (batterySeen.size); check-spec-parsed-alias.mjs counts individual assertions (sum of batterySeen.values()), matching what its own verdict text calls them. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_012GKcPZbMoGq7WPzKLfRBTU --- scripts/check-init-service-contract.mjs | 10 +++++++++- scripts/check-kernel-hook-pairs.mjs | 10 +++++++++- scripts/check-quick-reference-counts.mjs | 10 +++++++++- scripts/check-spec-parsed-alias.mjs | 13 ++++++++++++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/scripts/check-init-service-contract.mjs b/scripts/check-init-service-contract.mjs index cfd16b4eca..fe7638a779 100644 --- a/scripts/check-init-service-contract.mjs +++ b/scripts/check-init-service-contract.mjs @@ -974,7 +974,15 @@ function selfTest() { process.exit(1); } - console.log('✓ self-test: 19 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. + // What "cases" counts here is BATTERIES that actually ran (the named + // scenarios), not `assert(` call sites: the floor above guarantees + // `batterySeen.size` equals `declaredBatteries.length` by this point, so + // reading it off the runtime ledger rather than the static roster is a + // distinction without a difference — and it is the ledger, not the roster, + // that a stopped-running battery would actually shrink (#16664). + console.log(`✓ self-test: ${batterySeen.size} cases`); return SELF_TEST_VERDICT; } diff --git a/scripts/check-kernel-hook-pairs.mjs b/scripts/check-kernel-hook-pairs.mjs index 9d913a0eb3..316adf4d16 100644 --- a/scripts/check-kernel-hook-pairs.mjs +++ b/scripts/check-kernel-hook-pairs.mjs @@ -557,7 +557,15 @@ function selfTest() { } assert(!floorBreached, floorMessages.join('\n ')); - console.log('✓ self-test: 10 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. What "cases" counts here is BATTERIES that actually ran (the + // named scenarios), not `check(` call sites: the floor above guarantees + // `batterySeen.size` equals `declaredBatteries.length` by this point, so + // reading it off the runtime ledger rather than the static roster is a + // distinction without a difference — and it is the ledger, not the roster, + // that a stopped-running battery would actually shrink (#16664). + console.log(`✓ self-test: ${batterySeen.size} cases`); return SELF_TEST_VERDICT; } diff --git a/scripts/check-quick-reference-counts.mjs b/scripts/check-quick-reference-counts.mjs index ce2b2de37f..19d42057d3 100644 --- a/scripts/check-quick-reference-counts.mjs +++ b/scripts/check-quick-reference-counts.mjs @@ -925,7 +925,15 @@ function selfTest() { for (const f of failures) console.error(f); process.exit(1); } - console.log('✓ check-quick-reference-counts self-test: 22 cases pass.'); + // 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. What "cases" counts here is BATTERIES that actually ran (the + // named scenarios), not `expect(` call sites: the floor above guarantees + // `batterySeen.size` equals `declaredBatteries.length` by this point, so + // reading it off the runtime ledger rather than the static roster is a + // distinction without a difference — and it is the ledger, not the roster, + // that a stopped-running battery would actually shrink (#16664). + console.log(`✓ check-quick-reference-counts self-test: ${batterySeen.size} cases pass.`); selfTestReachedVerdict = true; } diff --git a/scripts/check-spec-parsed-alias.mjs b/scripts/check-spec-parsed-alias.mjs index 353f8d4fe7..f0943acc4c 100644 --- a/scripts/check-spec-parsed-alias.mjs +++ b/scripts/check-spec-parsed-alias.mjs @@ -558,7 +558,18 @@ export type Iso0 = Assert, z.infer< typeof for (const f of failures) console.error(' - ' + f); process.exit(1); } - console.log('check-spec-parsed-alias --self-test: 18 assertions passed'); + // 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 (#16664). Unlike the other three + // files in this class, this roster holds a SINGLE battery, and what it + // counts is assertions that actually RAN this run (every `check(` call), not + // `check(` 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 assertionsRun = [...batterySeen.values()].reduce((total, count) => total + count, 0); + console.log(`check-spec-parsed-alias --self-test: ${assertionsRun} assertions passed`); return SELF_TEST_VERDICT; }