Skip to content

Commit a104ad2

Browse files
claude[bot]claude
andauthored
test(scripts): control the self-test probe against the helper handshake spelling (#15491)
`measure-self-test-floor --probe` had zero coverage of one of the three landed handshake spellings. The helper form (`requireReachedVerdict(name, reached)`) has exactly one carrier under `scripts/` — `check-platform-checklist.mjs` — whose `ENTRY_BY_HAND` row is a deliberate `null`, so every probe run recorded `NOT MEASURED` for it and no sweep in this tree had ever read that shape in either direction: not held, not defeated. A green `--probe` was therefore evidence for the sentinel and flag spellings only. Add a helper-shaped fixture to the inline controls, which run on every invocation and never behind a flag, exactly as the sentinel-shaped `SOUND_GATE` does. The fixture mirrors the real spelling: a module-level `...ReachedVerdict` flag set as the self-test's last act, and a `requireReachedVerdict(name, reached)` helper the dispatch calls afterwards, refusing out loud after a leading blank line — which also exercises `firstNonBlankLine` reading past that blank. Both directions, from ONE pair differing by ONE line — the dispatch asking the helper. With the line, the probe must read HELD (and must have SPOKEN, with the helper's own refusal as the first non-blank line); with it deleted, the same file must read DEFEATED printing zero bytes. A fixture-derivation control refuses if the anchor stops matching, so the two directions can never silently become the same file. No change to the three-valued verdict (`DEFEATED` / `HELD` / `ACCIDENT`, `mutatedSpoke`), to the baseline precondition, to `ENTRY_BY_HAND`, or to any census row: the fixtures are spawned from a temp dir and the verdict is still taught no refusal wording. Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk Co-authored-by: Claude <noreply@anthropic.com>
1 parent 17f8604 commit a104ad2

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

‎scripts/measure-self-test-floor.mjs‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,64 @@ const UNRUNNABLE_GATE = [
390390
'',
391391
].join('\n');
392392

393+
/**
394+
* The HELPER handshake spelling, reduced: the third of the three landed
395+
* handshake shapes, and the one the probe had never read in either direction.
396+
* Its only carrier under `scripts/` is `check-platform-checklist.mjs`, whose
397+
* `ENTRY_BY_HAND` row is a deliberate `null` (its dispatch calls four self-test
398+
* functions and combines their statuses), so every probe run recorded NOT
399+
* MEASURED for it and the sweep said nothing at all about this shape -- not
400+
* held, not defeated (#15371). The other two spellings each have dozens of live
401+
* carriers AND, for the sentinel, the `SOUND_GATE` control above.
402+
*
403+
* The shape mirrored here is the real one: a module-level `...ReachedVerdict`
404+
* flag set as the self-test's last act, and a `requireReachedVerdict(name,
405+
* reached)` helper the DISPATCH calls afterwards, which refuses out loud and
406+
* exits 1. The refusal wording is printed after a leading blank line, as the
407+
* real helper prints it, so the control also exercises `firstNonBlankLine`
408+
* reading past that blank -- `mutatedSpoke` on a run whose first line is empty.
409+
*
410+
* ⛔ The verdict is still not taught this (or any) wording: the fixture's own
411+
* message is asserted below only so that the HELD it earns is the HELPER's
412+
* refusal and not some other printer's. Recognising WHICH handshake a file
413+
* carries remains #14968's column, not this verdict's job.
414+
*/
415+
const HELPER_HANDSHAKE_GATE = [
416+
'#!/usr/bin/env node',
417+
'let selfTestReachedVerdict = false;',
418+
'function requireReachedVerdict(name, reached) {',
419+
' if (reached) return;',
420+
" console.error(String.fromCharCode(10) + 'fixture self-test: ' + name + '() returned without reaching its verdict,');",
421+
" console.error('so its assertions did not all run and no failure of theirs could be reported.');",
422+
' process.exit(1);',
423+
'}',
424+
'function selfTest() {',
425+
' const failures = [];',
426+
" if (1 !== 1) failures.push('x');",
427+
" if (failures.length) { console.error(failures.join(String.fromCharCode(10))); process.exit(1); }",
428+
" console.log('fixture self-test: 1 case passes');",
429+
' selfTestReachedVerdict = true;',
430+
'}',
431+
"if (process.argv.includes('--self-test')) {",
432+
' selfTest();',
433+
" requireReachedVerdict('selfTest', selfTestReachedVerdict);",
434+
'}',
435+
'',
436+
].join('\n');
437+
438+
/**
439+
* The one dispatch line that IS the helper handshake. Deleting it leaves a file
440+
* identical in every other byte -- same helper defined, same flag, same
441+
* self-test -- whose early return therefore exits 0 in silence. The pair is the
442+
* both-directions control: with the line, the probe must read HELD; without it,
443+
* DEFEATED. Anything else means the verdict is keying on something other than
444+
* the handshake actually being asked for.
445+
*/
446+
const HELPER_HANDSHAKE_CALL = " requireReachedVerdict('selfTest', selfTestReachedVerdict);\n";
447+
448+
/** The same fixture with the handshake call, and only that, removed. */
449+
const HELPER_HANDSHAKE_GATE_HOLED = HELPER_HANDSHAKE_GATE.replace(HELPER_HANDSHAKE_CALL, '');
450+
393451
/**
394452
* The ternary exit, reduced: a roster floor whose ONLY failure production is
395453
* `process.exit(<cond> ? 0 : 1)`. It carries none of the NAMED spellings -- no
@@ -472,14 +530,20 @@ export function runControls() {
472530
const sound = join(dir, 'sound-gate.mjs');
473531
const accident = join(dir, 'accident-gate.mjs');
474532
const unrunnable = join(dir, 'unrunnable-gate.mjs');
533+
const helper = join(dir, 'helper-handshake-gate.mjs');
534+
const helperHoled = join(dir, 'helper-handshake-gate-holed.mjs');
475535
writeFileSync(holed, HOLED_GATE);
476536
writeFileSync(sound, SOUND_GATE);
477537
writeFileSync(accident, ACCIDENT_GATE);
478538
writeFileSync(unrunnable, UNRUNNABLE_GATE);
539+
writeFileSync(helper, HELPER_HANDSHAKE_GATE);
540+
writeFileSync(helperHoled, HELPER_HANDSHAKE_GATE_HOLED);
479541
const h = probeEarlyReturn(holed, 'selfTest');
480542
const s = probeEarlyReturn(sound, 'selfTest');
481543
const a = probeEarlyReturn(accident, 'runSelfTest');
482544
const u = probeEarlyReturn(unrunnable, 'selfTest');
545+
const hh = probeEarlyReturn(helper, 'selfTest');
546+
const hhHoled = probeEarlyReturn(helperHoled, 'selfTest');
483547
say(h.verdict === 'DEFEATED',
484548
`POSITIVE CONTROL FAILED: the probe read a known-holed gate as ${h.verdict} (${h.why ?? ''})`);
485549
say(h.mutatedBytes === 0,
@@ -505,6 +569,26 @@ export function runControls() {
505569
// being red, would satisfy the verdict above while testing nothing.
506570
say(u.baselineExit !== 0 && u.baselineBytes > 0 && u.baselineHead !== '',
507571
`POSITIVE CONTROL FAILED: the unrunnable fixture no longer produces the measured shape (baseline exit ${u.baselineExit}, ${u.baselineBytes} byte(s)); the NOT MEASURED verdict above would then be passing for the wrong reason`);
572+
// The HELPER handshake spelling, both directions, differing by ONE line: the
573+
// dispatch asking `requireReachedVerdict`. Until this fixture the probe had
574+
// read that shape in NEITHER direction -- its single carrier in the tree is
575+
// an ENTRY_BY_HAND `null`, so a green sweep was evidence for the sentinel and
576+
// flag spellings only (#15371).
577+
say(HELPER_HANDSHAKE_GATE_HOLED !== HELPER_HANDSHAKE_GATE,
578+
'CONTROL FIXTURE INVALID: the helper-handshake dispatch line was not found in the fixture, so the two directions below are the SAME file and one of the verdicts is passing for the wrong reason');
579+
say(hh.verdict === 'HELD',
580+
`NEGATIVE CONTROL FAILED: the probe read a helper-handshake gate (\`requireReachedVerdict\`) as ${hh.verdict} (${hh.why ?? ''})`);
581+
say(hh.mutatedSpoke === true && hh.mutatedBytes > 0,
582+
'NEGATIVE CONTROL FAILED: the helper-handshake gate printed nothing when defeated; HELD is supposed to mean it REFUSED out loud');
583+
// ... and the refusal has to be the HELPER's, read past the blank line it
584+
// prints first. A HELD earned by some other printer would test nothing about
585+
// this spelling.
586+
say((hh.mutatedHead ?? '').includes('returned without reaching its verdict'),
587+
`CONTROL FIXTURE INVALID: the helper-handshake gate's refusal is no longer the helper's (first non-blank line: ${JSON.stringify((hh.mutatedHead ?? '').slice(0, 80))})`);
588+
say(hhHoled.verdict === 'DEFEATED',
589+
`POSITIVE CONTROL FAILED: the SAME fixture with only the \`requireReachedVerdict\` call deleted was read as ${hhHoled.verdict} (${hhHoled.why ?? ''}); the handshake call is the whole difference`);
590+
say(hhHoled.mutatedBytes === 0,
591+
'POSITIVE CONTROL FAILED: the helper-handshake gate with its handshake deleted printed something; without the call there is nothing left to notice the early return, so the run says NOTHING and exits 0');
508592
} finally {
509593
rmSync(dir, { recursive: true, force: true });
510594
}

0 commit comments

Comments
 (0)