Skip to content

Commit 03310bc

Browse files
committed
fix(scripts): set check:single-claim-paths' self-test handshake after the verdict prints, not before the async block that produces it
`selfTestReachedVerdict = true` sat on the line directly above `return (async () => {` — the block that runs every assertion, evaluates the battery floor and prints the verdict. The flag was therefore true before a single case had run, so an early return or a throw anywhere inside that block left it true and the dispatch's `if (!selfTestReachedVerdict)` branch was unreachable. The one sentence the flag exists to make possible — "selfTest() returned without reaching its verdict" — could never be said by this gate. AGENTS.md, verbatim: "Set the flag as the self-test's last statement, after its success line prints" and "SAY the self-test never reached its verdict. An exit code is not a handshake." The assignment now is that last statement. The failing arm is left without one deliberately: it calls process.exit(1) on the next instruction, so no reader survives to consult the flag — the handshake is for the SILENT ways out, which is what the new position catches. Negative control (deliberate early return injected inside the block, on the committed file, restored by blob hash): red, "selfTest() returned without reaching its verdict", exit 1. Before this commit the identical injection printed the same partial output and exited 0. Claude-Session: https://claude.ai/code/session_01BTeBejoPUvRHN8WdAJC6oF Co-authored-by: Claude <noreply@anthropic.com>
1 parent d4b1f28 commit 03310bc

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎scripts/check-single-claim-paths.mjs‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,14 @@ function rearmThroughProxy(args) {
698698
// and still exits 0 — a self-test that never finished, reported as one that
699699
// passed (#13798). The self-test's own exit code stays load-bearing, so the
700700
// handshake is a flag rather than a returned sentinel.
701+
//
702+
// ⛔ "After its verdict is printed" is positional and it is the whole contract.
703+
// This self-test runs its assertions inside an async block that `selfTest()`
704+
// RETURNS, and the assignment used to sit on the line above that `return`
705+
// (#18940): synchronously true before a single assertion had run, so every
706+
// early return and every throw inside the block still left it true and the
707+
// dispatch could never reach its own diagnostic. The flag belongs to the code
708+
// that PRINTED the verdict, never to the code that is about to start.
701709
let selfTestReachedVerdict = false;
702710

703711
function selfTest() {
@@ -870,7 +878,6 @@ function selfTest() {
870878
};
871879

872880
const ctxOf = (number) => ({ number: String(number), repo: 'o/r', token: 't' });
873-
selfTestReachedVerdict = true;
874881
return (async () => {
875882
calls.length = 0;
876883
const quiet = await collect(ctxOf(200), fakeApi({ 200: ['fixture/tree/alpha.ts', 'fixture/tree/beta.ts'] }));
@@ -997,9 +1004,19 @@ function selfTest() {
9971004
}
9981005
if (failedCount) {
9991006
console.error(`✗ check-single-claim-paths self-test: ${failedCount} of ${cases.length} case(s) failed.`);
1007+
// No handshake is owed on this arm: the process is gone on the next
1008+
// instruction, so nothing downstream can read the flag. The handshake
1009+
// exists for the SILENT ways out — a `return` or a throw that prints
1010+
// nothing — and those are exactly the ones the line below now catches.
10001011
process.exit(1);
10011012
}
10021013
console.log(`✓ check-single-claim-paths self-test: ${cases.length} cases pass.`);
1014+
// LAST statement of the block, after the success line printed (#18940).
1015+
// Set before the block, it certified a run that had not happened yet: an
1016+
// early return or a throw anywhere inside left it true, and the dispatch
1017+
// below could never say the self-test had not reached its verdict — the
1018+
// one sentence the flag exists to make possible.
1019+
selfTestReachedVerdict = true;
10031020
})();
10041021
}
10051022

0 commit comments

Comments
 (0)