Skip to content

Commit 05422bd

Browse files
committed
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>
1 parent 69df534 commit 05422bd

2 files changed

Lines changed: 185 additions & 2 deletions

File tree

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)