You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(devx): the handshake column, its controls, and a LIVE completeness check (#14968)
`--json` and the human census gain a per-file `handshake` field beside `floor`,
plus a per-shape summary line. One fixture per landed shape drives the
recogniser in both directions, including the ACCIDENT boundary (a return value
compared against a LITERAL is not a handshake), a decoy whose spellings sit in
a comment and a fixture template, and a name-independence control that renames
all three landed spellings out of the fixtures and requires the same verdicts.
`handshakeCensusFailures` measures the census's completeness against a second
opinion that shares no code with the recogniser, over the live tree rather than
over fixtures -- so it lives outside `runControls()`, whose invariant is that a
control failure is always the instrument and never the tree.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
* The COLUMN-ZERO BRACE gate, reduced: an inline arrow argument whose `});`
1122
+
* closes at column 0 INSIDE the self-test, ahead of the line that sets the
1123
+
* handshake flag. This is the shape `scripts/check-error-code-casing.mjs`
1124
+
* carries -- and `check-optional-error-sink-contract.mjs` and
1125
+
* `check-org-identifier.mjs` with it. Read with a "body ends at the first `}` at
1126
+
* column 0" rule, the flag assignment falls outside its own function's body, the
1127
+
* carrier never crosses anything, and all three ordinary handshakes read `none`.
1128
+
* `definitionSpan` counts braces over masked text instead; this fixture is why.
1129
+
*/
1130
+
constEARLY_BRACE_GATE=[
1131
+
'#!/usr/bin/env node',
1132
+
'let selfTestReachedVerdict = false;',
1133
+
'const check = (fn) => fn();',
1134
+
'function selfTest() {',
1135
+
' check(() => {',
1136
+
" console.log('fixture self-test: 1 case passes');",
1137
+
'});',
1138
+
' selfTestReachedVerdict = true;',
1139
+
'}',
1140
+
"if (process.argv.includes('--self-test')) {",
1141
+
' selfTest();',
1142
+
" if (!selfTestReachedVerdict) { console.error('no verdict'); process.exit(1); }",
1143
+
'}',
1144
+
'',
1145
+
].join('\n');
1146
+
1084
1147
/**
1085
1148
* The SLOW gate, reduced: a self-test that outlasts the budget it is probed
1086
1149
* under. It sleeps rather than spins -- a control that runs on EVERY invocation
@@ -1340,6 +1403,78 @@ export function runControls() {
1340
1403
`LEDGER ROW INVALID: ${file} carries a field this reader does not read (${fields.join(', ')}); a misspelled \`timeoutMs\` is not a smaller budget, it is NO budget -- the default, and the SIGTERM this field exists to end`);
1341
1404
}
1342
1405
1406
+
// Instrument 3 -- WHICH handshake, one fixture per landed shape and both
1407
+
// directions on each. What is at stake is the question the card was filed
1408
+
// about: every handshake census in this family was a hand-written grep for one
1409
+
// of three spellings, and three of them in one shift gave three wrong answers.
1410
+
say(classifyHandshake(SOUND_GATE)==='sentinel',
1411
+
`HANDSHAKE CONTROL FAILED: a dispatch comparing the self-test's RETURN VALUE against a named verdict read ${classifyHandshake(SOUND_GATE)}, not sentinel`);
1412
+
say(classifyHandshake(WALKING_GATE)==='flag',
1413
+
`HANDSHAKE CONTROL FAILED: a module-level flag set inside the self-test and read negated at the dispatch read ${classifyHandshake(WALKING_GATE)}, not flag`);
`HANDSHAKE CONTROL FAILED: the helper fixture with only its handshake CALL deleted still read ${classifyHandshake(HELPER_HANDSHAKE_GATE_HOLED)}; the flag is still declared and still set, so anything but none is the NAME being read and not the mechanism`);
1423
+
// The ACCIDENT boundary, which is the sharpest thing this recogniser has to
1424
+
// get right: `runSelfTest() === 0` IS a comparison of the return value, and it
1425
+
// is NOT a handshake -- an early return makes it `undefined === 0`, exit 1,
1426
+
// ZERO bytes printed, nothing noticed. Reading it sentinel would publish the
1427
+
// exact accident-versus-handshake confusion this file exists to expose.
1428
+
say(classifyHandshake(ACCIDENT_GATE)==='none',
1429
+
`HANDSHAKE CONTROL FAILED: a return value compared against a LITERAL read ${classifyHandshake(ACCIDENT_GATE)}; that is the ACCIDENT shape, where a comparison against a missing return value exits non-zero having printed nothing`);
`HANDSHAKE CONTROL FAILED: a bare \`process.exit(<expr> ? 0 : 1)\` dispatch read ${classifyHandshake(TERNARY_EXIT_GATE)}; nothing there compares the completion against anything`);
1432
+
// ⭐ NAME-INDEPENDENCE, the direction the card is about. Every landed spelling
1433
+
// is renamed out of all three fixtures -- `SELF_TEST_VERDICT`,
1434
+
// `selfTestReachedVerdict`, `requireReachedVerdict` -- and the verdicts must
1435
+
// not move. A recogniser keyed on those names passes every control above and
1436
+
// fails all three of these; `classifyFloor` keyed on the NAME
1437
+
// `SELF_TEST_BATTERIES` once and called a fixture floored with its roster gone.
'NAME-INDEPENDENCE CONTROL FAILED: the sentinel fixture stopped reading sentinel once its verdict constant was renamed; the recogniser is keyed on a NAME, which is the defect one level up');
'NAME-INDEPENDENCE CONTROL FAILED: the flag fixture stopped reading flag once `selfTestReachedVerdict` was renamed; the recogniser is keyed on a NAME');
'NAME-INDEPENDENCE CONTROL FAILED: the helper fixture stopped reading helper once `requireReachedVerdict` was renamed; the recogniser is keyed on a NAME');
1449
+
1450
+
// The DECOY, and the fixture-validity guards without which it says nothing: a
1451
+
// decoy that is not comment or literal content is testing something else.
`HANDSHAKE DECOY CONTROL FAILED: a handshake spelled only inside a comment and a fixture template was recognised as ${classifyHandshake(HANDSHAKE_DECOY_GATE)}; a census reading raw text credits every gate that merely QUOTES the repair with having it`);
1461
+
// ... and both decoys un-hidden INDEPENDENTLY, which is what makes the verdict
1462
+
// above a reading of the mask rather than of two texts that were never
'CONTROL FIXTURE INVALID: with its comment marker removed the sentinel decoy is still not recognised, so it was never a handshake spelling and the decoy verdict passes for the wrong reason');
'CONTROL FIXTURE INVALID: with the template delimiters removed the flag decoy is still not recognised, so it was never a handshake spelling and the decoy verdict passes for the wrong reason');
1468
+
1469
+
// The BODY EXTENT, on the shape that made three live files read `none`: an
1470
+
// inline arrow argument closing with `});` at column 0 inside the self-test,
'CONTROL FIXTURE INVALID: the fixture no longer closes a brace at column 0 AHEAD of its flag assignment, so a first-column-brace body rule would reach the assignment anyway and the verdict below tests nothing');
1475
+
say(classifyHandshake(EARLY_BRACE_GATE)==='flag',
1476
+
`BODY EXTENT CONTROL FAILED: a self-test whose body contains a column-0 \`});\` read ${classifyHandshake(EARLY_BRACE_GATE)}; its flag is set INSIDE the function and the body extent is what says so -- three live files carry exactly this and read none without brace counting`);
0 commit comments