Skip to content

Commit 59db8a0

Browse files
baozhoutaoclaude
andauthored
Derive the four residual self-test verdict counts from their battery ledger (#17367)
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. Claude-Session: https://claude.ai/code/session_012GKcPZbMoGq7WPzKLfRBTU Co-authored-by: Claude <noreply@anthropic.com>
1 parent d29fdcf commit 59db8a0

4 files changed

Lines changed: 39 additions & 4 deletions

File tree

scripts/check-init-service-contract.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,15 @@ function selfTest() {
974974
process.exit(1);
975975
}
976976

977-
console.log('✓ self-test: 19 cases');
977+
// The verdict DERIVES its number from `batterySeen` — the very ledger the floor
978+
// above just evaluated — so the printed count and the floor can never disagree.
979+
// What "cases" counts here is BATTERIES that actually ran (the named
980+
// scenarios), not `assert(` call sites: the floor above guarantees
981+
// `batterySeen.size` equals `declaredBatteries.length` by this point, so
982+
// reading it off the runtime ledger rather than the static roster is a
983+
// distinction without a difference — and it is the ledger, not the roster,
984+
// that a stopped-running battery would actually shrink (#16664).
985+
console.log(`✓ self-test: ${batterySeen.size} cases`);
978986

979987
return SELF_TEST_VERDICT;
980988
}

scripts/check-kernel-hook-pairs.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,15 @@ function selfTest() {
557557
}
558558
assert(!floorBreached, floorMessages.join('\n '));
559559

560-
console.log('✓ self-test: 10 cases');
560+
// The verdict DERIVES its number from `batterySeen` — the very ledger the
561+
// floor above just evaluated — so the printed count and the floor can never
562+
// disagree. What "cases" counts here is BATTERIES that actually ran (the
563+
// named scenarios), not `check(` call sites: the floor above guarantees
564+
// `batterySeen.size` equals `declaredBatteries.length` by this point, so
565+
// reading it off the runtime ledger rather than the static roster is a
566+
// distinction without a difference — and it is the ledger, not the roster,
567+
// that a stopped-running battery would actually shrink (#16664).
568+
console.log(`✓ self-test: ${batterySeen.size} cases`);
561569

562570
return SELF_TEST_VERDICT;
563571
}

scripts/check-quick-reference-counts.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,15 @@ function selfTest() {
925925
for (const f of failures) console.error(f);
926926
process.exit(1);
927927
}
928-
console.log('✓ check-quick-reference-counts self-test: 22 cases pass.');
928+
// The verdict DERIVES its number from `batterySeen` — the very ledger the
929+
// floor above just evaluated — so the printed count and the floor can never
930+
// disagree. What "cases" counts here is BATTERIES that actually ran (the
931+
// named scenarios), not `expect(` call sites: the floor above guarantees
932+
// `batterySeen.size` equals `declaredBatteries.length` by this point, so
933+
// reading it off the runtime ledger rather than the static roster is a
934+
// distinction without a difference — and it is the ledger, not the roster,
935+
// that a stopped-running battery would actually shrink (#16664).
936+
console.log(`✓ check-quick-reference-counts self-test: ${batterySeen.size} cases pass.`);
929937
selfTestReachedVerdict = true;
930938
}
931939

scripts/check-spec-parsed-alias.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,18 @@ export type Iso0 = Assert<Eq< z.input< typeof M0.ColourSchema >, z.infer< typeof
558558
for (const f of failures) console.error(' - ' + f);
559559
process.exit(1);
560560
}
561-
console.log('check-spec-parsed-alias --self-test: 18 assertions passed');
561+
// The verdict DERIVES its number from `batterySeen` — the very ledger the
562+
// floor above just evaluated — so the printed count and the floor can never
563+
// disagree, and a block that stops running shrinks the number instead of
564+
// leaving a transcribed literal standing (#16664). Unlike the other three
565+
// files in this class, this roster holds a SINGLE battery, and what it
566+
// counts is assertions that actually RAN this run (every `check(` call), not
567+
// `check(` call sites in the source — those are two different facts, and
568+
// only the first one is measured here. Summing the whole ledger is exact
569+
// because reaching this line means every battery that registered is a
570+
// declared one — the set difference above reds otherwise.
571+
const assertionsRun = [...batterySeen.values()].reduce((total, count) => total + count, 0);
572+
console.log(`check-spec-parsed-alias --self-test: ${assertionsRun} assertions passed`);
562573

563574
return SELF_TEST_VERDICT;
564575
}

0 commit comments

Comments
 (0)