Skip to content

Commit 54db16d

Browse files
claude[bot]claude
andauthored
tooling(scripts): assertion floors for the class-2 self-tests, one hoisted battery each (#13799 batch 5) (#15217)
* tooling(scripts): floor the check-dts-emitted self-test with a single hoisted battery (#13799) The self-test decided success by `failures.length === 0` alone, so "every case held" and "the cases never ran" printed the same line. It carries no named section banner, and a comment is not promoted to a section head, so it declares ONE battery opened at the top of the body -- the hoisted shape PRs #14896 and #15003 landed for exactly this case. Floor 8, measured rather than transcribed: the roster was probed with a deliberately unreachable pin and the floor's own report named the registered count. Behaviour is unchanged -- `--self-test` stdout and stderr are byte-identical against origin/main, exit 0 both sides. Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk Co-authored-by: Claude <noreply@anthropic.com> * tooling(scripts): floor the logger-receiver-detach and objectql-double-limit self-tests (#13799) Both decided success by `failures.length === 0` alone. Neither carries the two named section banners the sectioning criterion needs, and a comment is not promoted to a section head, so each declares ONE battery opened at the top of its self-test body -- the hoisted shape PRs #14896 and #15003 landed. Floors 47 and 47, measured by probing the roster with an unreachable pin and reading the count the floor's own report names. `--self-test` stdout and stderr are byte-identical against origin/main for both, exit 0 on both sides. Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk Co-authored-by: Claude <noreply@anthropic.com> * tooling(scripts): floor the spec-parsed-alias and stack-collection-maps self-tests (#13799) check-spec-parsed-alias decided success by `failures.length === 0` alone. check-stack-collection-maps already COUNTED its assertions and printed the number -- but nothing compared it, so a case block that stopped running shrank the printed count and the gate stayed green: evidence, not proof. Neither carries the two named section banners the sectioning criterion needs, and a comment is not promoted to a section head, so each declares ONE battery opened at the top of its self-test body. Both floors measured at 18. The two hand-written verdict counts agree with the registered count on this tree (`18 assertions passed`, `18 assertions over synthetic sources`), so neither had drifted. `--self-test` stdout and stderr are byte-identical against origin/main for both, exit 0 on both sides. Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk Co-authored-by: Claude <noreply@anthropic.com> * tooling(scripts): floor the tenant-chokepoint and label-desc-cap self-tests (#13799) Both decided success by their sink alone (`failures.length === 0`, `failed === 0`), so "every case held" and "the cases never ran" printed the same line. tenant-chokepoint's blocks are headed by unmarked prose and label-desc-cap carries one banner, below the two the sectioning criterion needs; a comment is not promoted to a section head and a lone banner is not split, so each declares ONE battery opened at the top of its self-test body. label-desc-cap's sink is a counter rather than a list, so its floor prints the breach and folds it into `failed` -- the same refusal in that file's own idiom. Floors 17 and 44, measured by probing the roster with an unreachable pin. `--self-test` stdout and stderr are byte-identical against origin/main for both, exit 0 on both sides. Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk Co-authored-by: Claude <noreply@anthropic.com> * tooling(scripts): floor the whole-set-label-write and wildcard-fallthrough self-tests (#13799) Neither carries the two named section banners the sectioning criterion needs, so each declares ONE battery opened at the top of its self-test body. Floors 41 and 18, measured by probing the roster with an unreachable pin. whole-set-label-write registers from `expect()` only. Its two trailing ledger loops walk WHOLE_SET_ACTIONS and ALLOWLIST and push straight to `failures`; they are left unregistered ON PURPOSE, because ALLOWLIST is meant to shrink and a floor that moved with it would red every legitimate removal -- the one habit these floors exist to prevent. The comment above the roster says so in place. wildcard-fallthrough refuses in place rather than collecting, so its floor refuses in place too. ⚠️ Its verdict prints a TRANSCRIBED `17 cases` while the body has 18 assert call sites and registers 18 -- the literal had already drifted one low. It is left untouched so this change stays a pure no-op on output, and filed separately; the floor is what makes the drift harmless. `--self-test` stdout and stderr are byte-identical against origin/main for both, exit 0 on both sides. Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk Co-authored-by: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1c6f7b4 commit 54db16d

9 files changed

Lines changed: 866 additions & 4 deletions

‎scripts/check-dts-emitted.mjs‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,57 @@ function run(dir) {
233233
// handshake is a flag rather than a returned sentinel.
234234
let selfTestReachedVerdict = false;
235235

236+
// ── The self-test's own battery roster and floor (#13489) ──────────────────
237+
//
238+
// `failures.length === 0` used to be this self-test's ONLY success condition, so
239+
// "every case held" and "the cases never ran" printed the same line. Closed the
240+
// way PR #13487 validated on check-doc-authoring: what is pinned is the
241+
// registered NAMES, not a number. The floor requires the OPENED set to equal the
242+
// DECLARED set with each battery at or above its own count.
243+
//
244+
// This file declares ONE battery, opened at the top of the self-test body. It
245+
// carries fewer than the two named section banners the sectioning criterion
246+
// needs, and ⛔ a comment is NOT promoted to a section head — that is a
247+
// judgement per comment this transplant does not make. The hoisted single
248+
// battery is the shape PR #14896 and PR #15003 landed for exactly this case.
249+
//
250+
// ⛔ A pinned TOTAL is not the repair: a battery dropping from 9 cases to 3
251+
// keeps a total "right" the moment a sibling grows.
252+
//
253+
// The count is a FLOOR, not an equality — adding cases is ordinary work and must
254+
// not red. A battery BELOW its floor means cases stopped running; the remedy is
255+
// to find what stopped registering.
256+
const SELF_TEST_BATTERIES = Object.freeze({
257+
'check-dts-emitted self-test': 8,
258+
});
259+
260+
// DELETING an entry silences that battery's floor exactly as effectively as
261+
// zeroing it, so the roster's own size is pinned too.
262+
const SELF_TEST_BATTERY_FLOOR = 1;
263+
264+
// The key an assertion is filed under when no battery is open. It is not a
265+
// declared battery, so it reds by the same set difference rather than silently
266+
// inflating whichever battery happened to run last.
267+
const UNATTRIBUTED_BATTERY = '(no battery open)';
268+
236269
function selfTest() {
270+
// The battery ledger this self-test's floor is evaluated against (#13489).
271+
// `battery()` opens a battery; every assertion below is attributed to the one
272+
// most recently opened, so a section that stops running stops registering and
273+
// names ITSELF at the floor rather than going quiet.
274+
const batterySeen = new Map();
275+
let openBattery = null;
276+
const battery = (name) => {
277+
openBattery = name;
278+
};
279+
const registerCase = () => {
280+
const b = openBattery ?? UNATTRIBUTED_BATTERY;
281+
batterySeen.set(b, (batterySeen.get(b) ?? 0) + 1);
282+
};
283+
battery('check-dts-emitted self-test');
237284
const failures = [];
238285
const eq = (label, actual, expected) => {
286+
registerCase();
239287
const a = JSON.stringify(actual);
240288
const e = JSON.stringify(expected);
241289
if (a !== e) failures.push(`${label}\n expected ${e}\n actual ${a}`);
@@ -295,6 +343,50 @@ function selfTest() {
295343
['empty:dist/index.d.ts'],
296344
);
297345

346+
// ── The floor: every declared battery RAN, and ran its cases (#13489) ────
347+
//
348+
// Evaluated after every battery has had its chance and BEFORE the verdict, so
349+
// the success line below can only be printed by a run in which the set of
350+
// batteries that registered assertions EQUALS the set declared. A set
351+
// difference names WHICH battery stopped; a count says only that something did.
352+
const floorFailure = (message) => { failures.push(message); };
353+
const declaredBatteries = Object.keys(SELF_TEST_BATTERIES);
354+
let floorBreached = false;
355+
if (declaredBatteries.length < SELF_TEST_BATTERY_FLOOR) {
356+
floorBreached = true;
357+
floorFailure(
358+
`SELF_TEST_BATTERIES declares ${declaredBatteries.length} batteries, below the pinned `
359+
+ `${SELF_TEST_BATTERY_FLOOR} — a battery deleted from the roster takes its own floor with it.`,
360+
);
361+
}
362+
for (const [name, count] of batterySeen) {
363+
if (declaredBatteries.includes(name)) continue;
364+
floorBreached = true;
365+
floorFailure(
366+
`self-test battery "${name}" registered ${count} case(s) but is not declared in `
367+
+ 'SELF_TEST_BATTERIES — an assertion attributed to no declared battery is one nothing floors.',
368+
);
369+
}
370+
for (const name of declaredBatteries) {
371+
const count = batterySeen.get(name) ?? 0;
372+
if (count >= SELF_TEST_BATTERIES[name]) continue;
373+
floorBreached = true;
374+
floorFailure(
375+
count === 0
376+
? `self-test battery "${name}" DID NOT RUN — 0 cases registered, ${SELF_TEST_BATTERIES[name]} pinned. `
377+
+ 'The verdict below would have claimed those cases hold.'
378+
: `self-test battery "${name}" registered ${count} case(s), below its pinned floor of `
379+
+ `${SELF_TEST_BATTERIES[name]} — cases that used to run no longer do.`,
380+
);
381+
}
382+
if (floorBreached) {
383+
floorFailure(
384+
'A battery at or below its floor means cases STOPPED RUNNING — the battery is the bug, not the '
385+
+ 'number. Find what stopped registering (an early return, a deleted block, a guard that now '
386+
+ 'skips) and restore it.',
387+
);
388+
}
389+
298390
if (failures.length > 0) {
299391
console.error(`\nx check-dts-emitted self-test: ${failures.length} failure(s)\n`);
300392
for (const f of failures) console.error(` - ${f}\n`);

‎scripts/check-logger-receiver-detach.mjs‎

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,56 @@ function measure() {
583583
// as one that passed (#13798).
584584
const SELF_TEST_VERDICT = 'check-logger-receiver-detach self-test reached its verdict';
585585

586+
// ── The self-test's own battery roster and floor (#13489) ──────────────────
587+
//
588+
// `failures.length === 0` used to be this self-test's ONLY success condition, so
589+
// "every case held" and "the cases never ran" printed the same line. Closed the
590+
// way PR #13487 validated on check-doc-authoring: what is pinned is the
591+
// registered NAMES, not a number. The floor requires the OPENED set to equal the
592+
// DECLARED set with each battery at or above its own count.
593+
//
594+
// This file declares ONE battery, opened at the top of the self-test body. It
595+
// carries fewer than the two named section banners the sectioning criterion
596+
// needs, and ⛔ a comment is NOT promoted to a section head — that is a
597+
// judgement per comment this transplant does not make. The hoisted single
598+
// battery is the shape PR #14896 and PR #15003 landed for exactly this case.
599+
//
600+
// ⛔ A pinned TOTAL is not the repair: a battery dropping from 9 cases to 3
601+
// keeps a total "right" the moment a sibling grows.
602+
//
603+
// The count is a FLOOR, not an equality — adding cases is ordinary work and must
604+
// not red. A battery BELOW its floor means cases stopped running; the remedy is
605+
// to find what stopped registering.
606+
const SELF_TEST_BATTERIES = Object.freeze({
607+
'check-logger-receiver-detach self-test': 47,
608+
});
609+
610+
// DELETING an entry silences that battery's floor exactly as effectively as
611+
// zeroing it, so the roster's own size is pinned too.
612+
const SELF_TEST_BATTERY_FLOOR = 1;
613+
614+
// The key an assertion is filed under when no battery is open. It is not a
615+
// declared battery, so it reds by the same set difference rather than silently
616+
// inflating whichever battery happened to run last.
617+
const UNATTRIBUTED_BATTERY = '(no battery open)';
618+
586619
function selfTest() {
620+
// The battery ledger this self-test's floor is evaluated against (#13489).
621+
// `battery()` opens a battery; every assertion below is attributed to the
622+
// one most recently opened, so a section that stops running stops
623+
// registering and names ITSELF at the floor rather than going quiet.
624+
const batterySeen = new Map();
625+
let openBattery = null;
626+
const battery = (name) => {
627+
openBattery = name;
628+
};
629+
const registerCase = () => {
630+
const b = openBattery ?? UNATTRIBUTED_BATTERY;
631+
batterySeen.set(b, (batterySeen.get(b) ?? 0) + 1);
632+
};
633+
battery('check-logger-receiver-detach self-test');
587634
const failures = [];
588-
const expect = (what, ok) => { if (!ok) failures.push(what); };
635+
const expect = (what, ok) => { registerCase(); if (!ok) failures.push(what); };
589636

590637
// The control corpus -- both halves.
591638
const problems = controlProblems();
@@ -691,6 +738,51 @@ function selfTest() {
691738
expect('and no hint names a root this gate does not walk',
692739
ROOT_DIR_WATCH_HINTS.every((h) => SCAN_ROOTS.some((r) => h.startsWith(`${r}/`))));
693740

741+
// ── The floor: every declared battery RAN, and ran its cases (#13489) ────
742+
//
743+
// Evaluated after every battery has had its chance and BEFORE the verdict,
744+
// so the success line below can only be printed by a run in which the set of
745+
// batteries that registered assertions EQUALS the set declared. A set
746+
// difference names WHICH battery stopped; a count says only that something
747+
// did.
748+
const floorFailure = (message) => { failures.push(message); };
749+
const declaredBatteries = Object.keys(SELF_TEST_BATTERIES);
750+
let floorBreached = false;
751+
if (declaredBatteries.length < SELF_TEST_BATTERY_FLOOR) {
752+
floorBreached = true;
753+
floorFailure(
754+
`SELF_TEST_BATTERIES declares ${declaredBatteries.length} batteries, below the pinned `
755+
+ `${SELF_TEST_BATTERY_FLOOR} — a battery deleted from the roster takes its own floor with it.`,
756+
);
757+
}
758+
for (const [name, count] of batterySeen) {
759+
if (declaredBatteries.includes(name)) continue;
760+
floorBreached = true;
761+
floorFailure(
762+
`self-test battery "${name}" registered ${count} case(s) but is not declared in `
763+
+ 'SELF_TEST_BATTERIES — an assertion attributed to no declared battery is one nothing floors.',
764+
);
765+
}
766+
for (const name of declaredBatteries) {
767+
const count = batterySeen.get(name) ?? 0;
768+
if (count >= SELF_TEST_BATTERIES[name]) continue;
769+
floorBreached = true;
770+
floorFailure(
771+
count === 0
772+
? `self-test battery "${name}" DID NOT RUN — 0 cases registered, ${SELF_TEST_BATTERIES[name]} pinned. `
773+
+ 'The verdict below would have claimed those cases hold.'
774+
: `self-test battery "${name}" registered ${count} case(s), below its pinned floor of `
775+
+ `${SELF_TEST_BATTERIES[name]} — cases that used to run no longer do.`,
776+
);
777+
}
778+
if (floorBreached) {
779+
floorFailure(
780+
'A battery at or below its floor means cases STOPPED RUNNING — the battery is the bug, not '
781+
+ 'the number. Find what stopped registering (an early return, a deleted block, a guard that '
782+
+ 'now skips) and restore it.',
783+
);
784+
}
785+
694786
if (failures.length > 0) {
695787
console.error(`x check-logger-receiver-detach --self-test (${failures.length} failure(s)):\n`);
696788
for (const f of failures) console.error(` - ${f}`);

‎scripts/check-objectql-double-limit.mjs‎

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,9 +1095,56 @@ async function judgeFixture(src) {
10951095
// as one that passed (#13798).
10961096
const SELF_TEST_VERDICT = 'check-objectql-double-limit self-test reached its verdict';
10971097

1098+
// ── The self-test's own battery roster and floor (#13489) ──────────────────
1099+
//
1100+
// `failures.length === 0` used to be this self-test's ONLY success condition, so
1101+
// "every case held" and "the cases never ran" printed the same line. Closed the
1102+
// way PR #13487 validated on check-doc-authoring: what is pinned is the
1103+
// registered NAMES, not a number. The floor requires the OPENED set to equal the
1104+
// DECLARED set with each battery at or above its own count.
1105+
//
1106+
// This file declares ONE battery, opened at the top of the self-test body. It
1107+
// carries fewer than the two named section banners the sectioning criterion
1108+
// needs, and ⛔ a comment is NOT promoted to a section head — that is a
1109+
// judgement per comment this transplant does not make. The hoisted single
1110+
// battery is the shape PR #14896 and PR #15003 landed for exactly this case.
1111+
//
1112+
// ⛔ A pinned TOTAL is not the repair: a battery dropping from 9 cases to 3
1113+
// keeps a total "right" the moment a sibling grows.
1114+
//
1115+
// The count is a FLOOR, not an equality — adding cases is ordinary work and must
1116+
// not red. A battery BELOW its floor means cases stopped running; the remedy is
1117+
// to find what stopped registering.
1118+
const SELF_TEST_BATTERIES = Object.freeze({
1119+
'check-objectql-double-limit self-test': 47,
1120+
});
1121+
1122+
// DELETING an entry silences that battery's floor exactly as effectively as
1123+
// zeroing it, so the roster's own size is pinned too.
1124+
const SELF_TEST_BATTERY_FLOOR = 1;
1125+
1126+
// The key an assertion is filed under when no battery is open. It is not a
1127+
// declared battery, so it reds by the same set difference rather than silently
1128+
// inflating whichever battery happened to run last.
1129+
const UNATTRIBUTED_BATTERY = '(no battery open)';
1130+
10981131
async function selfTest() {
1132+
// The battery ledger this self-test's floor is evaluated against (#13489).
1133+
// `battery()` opens a battery; every assertion below is attributed to the one
1134+
// most recently opened, so a section that stops running stops registering and
1135+
// names ITSELF at the floor rather than going quiet.
1136+
const batterySeen = new Map();
1137+
let openBattery = null;
1138+
const battery = (name) => {
1139+
openBattery = name;
1140+
};
1141+
const registerCase = () => {
1142+
const b = openBattery ?? UNATTRIBUTED_BATTERY;
1143+
batterySeen.set(b, (batterySeen.get(b) ?? 0) + 1);
1144+
};
1145+
battery('check-objectql-double-limit self-test');
10991146
const failures = [];
1100-
const expect = (label, cond) => { if (!cond) failures.push(label); };
1147+
const expect = (label, cond) => { registerCase(); if (!cond) failures.push(label); };
11011148
const one = async (src) => {
11021149
const { found, results } = await judgeFixture(src);
11031150
return { found, r: results[0], n: found.length };
@@ -1242,6 +1289,50 @@ async function selfTest() {
12421289
+ 'is under the same root and is NOT in the walk',
12431290
Boolean(nonTestSibling) && !admitted.has(nonTestSibling));
12441291

1292+
// ── The floor: every declared battery RAN, and ran its cases (#13489) ────
1293+
//
1294+
// Evaluated after every battery has had its chance and BEFORE the verdict, so
1295+
// the success line below can only be printed by a run in which the set of
1296+
// batteries that registered assertions EQUALS the set declared. A set
1297+
// difference names WHICH battery stopped; a count says only that something did.
1298+
const floorFailure = (message) => { failures.push(message); };
1299+
const declaredBatteries = Object.keys(SELF_TEST_BATTERIES);
1300+
let floorBreached = false;
1301+
if (declaredBatteries.length < SELF_TEST_BATTERY_FLOOR) {
1302+
floorBreached = true;
1303+
floorFailure(
1304+
`SELF_TEST_BATTERIES declares ${declaredBatteries.length} batteries, below the pinned `
1305+
+ `${SELF_TEST_BATTERY_FLOOR} — a battery deleted from the roster takes its own floor with it.`,
1306+
);
1307+
}
1308+
for (const [name, count] of batterySeen) {
1309+
if (declaredBatteries.includes(name)) continue;
1310+
floorBreached = true;
1311+
floorFailure(
1312+
`self-test battery "${name}" registered ${count} case(s) but is not declared in `
1313+
+ 'SELF_TEST_BATTERIES — an assertion attributed to no declared battery is one nothing floors.',
1314+
);
1315+
}
1316+
for (const name of declaredBatteries) {
1317+
const count = batterySeen.get(name) ?? 0;
1318+
if (count >= SELF_TEST_BATTERIES[name]) continue;
1319+
floorBreached = true;
1320+
floorFailure(
1321+
count === 0
1322+
? `self-test battery "${name}" DID NOT RUN — 0 cases registered, ${SELF_TEST_BATTERIES[name]} pinned. `
1323+
+ 'The verdict below would have claimed those cases hold.'
1324+
: `self-test battery "${name}" registered ${count} case(s), below its pinned floor of `
1325+
+ `${SELF_TEST_BATTERIES[name]} — cases that used to run no longer do.`,
1326+
);
1327+
}
1328+
if (floorBreached) {
1329+
floorFailure(
1330+
'A battery at or below its floor means cases STOPPED RUNNING — the battery is the bug, not the '
1331+
+ 'number. Find what stopped registering (an early return, a deleted block, a guard that now '
1332+
+ 'skips) and restore it.',
1333+
);
1334+
}
1335+
12451336
if (failures.length > 0) {
12461337
console.error(`x check-objectql-double-limit --self-test (${failures.length} failure(s)):\n`);
12471338
for (const f of failures) console.error(` - ${f}`);

0 commit comments

Comments
 (0)