Skip to content

Commit 7f6dc4c

Browse files
yinlianghuiclaude
andauthored
test(devx): sweep the shrink-only ratchet self-tests for baseline-presence pins — 33 derived, 1 repaired (#12050)
* test(devx): pin the driver-memory census on its ruling authority, not on its ledger's size The self-test asserted `ruledConsumers.length === 2`. That holds only while both ruled arms are still ledgered, so the gate's own LIVE invariant — "a migrated consumer must lose its entry in the same PR" — could not be obeyed without turning the self-test red, and red with a message reading "the ledger lost an entry it must have" when the entry was correctly deleted. #5499/#5704 exist to shrink that set; an equality on its size made it un-burnable by construction. Re-spelled as the claim the pin was actually protecting, which survives the set shrinking to empty: every ruled consumer is admitted by one of the two rulings this programme issued (#5704 Q2 / #6664 A), carried on a witness pair so the positive half stays exercised at zero rows; plus a shrink-only CEILING for the anti-growth half that the equality was also doing. Measured: shrinking the ledger by one entry was EXIT 1 before, EXIT 0 after; growth past the ceiling and a marker neither ruling issued both still red. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjM2ia8Av1v5NqfqQEQmC6 * test(devx): spell the unruled witness with the house synthetic marker `#9999` reads as a real issue reference to the next author, and quoting it in a PR body cross-references an unrelated card. `#0` is what this repo's other gate fixtures already use for a marker that names nothing on purpose. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjM2ia8Av1v5NqfqQEQmC6 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 76ebb6a commit 7f6dc4c

1 file changed

Lines changed: 53 additions & 4 deletions

File tree

scripts/check-driver-memory-census.mjs

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ const DEP_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'opti
124124
/** Binding kinds a ledger entry may claim. `string-literal` is context, never gated. */
125125
const BINDING_KINDS = ['import', 'export-from', 'dynamic-import', 'import-type', 'require', 'mock'];
126126

127+
/**
128+
* Ceiling on `ruledConsumers` — the two arms #5704 Q2 and #6664 A ruled permanent.
129+
*
130+
* A CEILING, deliberately, and not the set's exact size: #5499 froze the driver and
131+
* the programme above this gate exists to shrink the ruled set, so a PR that migrates
132+
* an arm away lowers this number in the same edit. Raising it is a new maintainer
133+
* ruling — the same authority `RULING_ISSUES` names in the self-test.
134+
*/
135+
const RULED_CEILING = 2;
136+
127137
/**
128138
* The disposition vocabulary. Closed on purpose: a free-text axis would let the
129139
* next arrival be waved through with a word nobody has to defend.
@@ -664,8 +674,46 @@ function selfTest() {
664674
expect(`discovery reaches the ruled consumer ${e.file}`,
665675
realScan.bindings.some((b) => b.file === e.file && b.kind === e.kind));
666676
}
667-
expect('the ledger rules exactly the consumers #5704/#6664 named',
668-
(realLedger.ruledConsumers ?? []).length === 2);
677+
// The claim here is about the RULING AUTHORITY, not about the ledger's current
678+
// length.
679+
//
680+
// ⚠️ This was spelled `ruledConsumers.length === 2` — "the ledger rules exactly
681+
// the consumers #5704/#6664 named". That reads identically on the day it is
682+
// written and means something else: it holds only while both arms are STILL
683+
// ledgered, so the gate's own LIVE invariant ("a migrated consumer must lose its
684+
// entry in the same PR") cannot be obeyed without turning this self-test red —
685+
// and red with a message that reads "the ledger lost an entry it must have" when
686+
// the entry was correctly deleted. A pin on the debt rather than on the gate:
687+
// the retirement programme #5499/#5704 exists to shrink this set, and an
688+
// equality on its size makes it un-burnable by construction.
689+
//
690+
// What the pin was actually protecting is the OTHER direction: no third consumer
691+
// may be waved into `ruled-permanent` — the strongest disposition this census
692+
// has — under a marker of its own invention. `validateLedgerShape` already
693+
// requires SOME rulingMarker; it does not require the ruling to be one this
694+
// programme actually issued. So that is the claim, and it survives the set
695+
// shrinking to empty.
696+
const RULING_ISSUES = ['#5704', '#6664'];
697+
const admittedByARuling = (e) => (e.rulingMarkers ?? []).some((m) => RULING_ISSUES.includes(m));
698+
const ruled = realLedger.ruledConsumers ?? [];
699+
700+
// Carried on a WITNESS PAIR rather than on the live rows alone: `[].every(...)`
701+
// is a pass that proves nothing, so the synthetic row keeps the positive half
702+
// exercised once the ledger reaches zero, and the negative witness is what gives
703+
// the case teeth at that point. (The `ESCAPABLE_LITERAL_LEDGER` cases in
704+
// scripts/pm/dispatch-gates.mjs are the worked precedent for the idiom.)
705+
const WITNESS_RULED = { file: 'w/itness.test.ts', kind: 'import', axis: 'ruled-permanent', rulingMarkers: ['#6664'] };
706+
const WITNESS_UNRULED = { file: 'w/itness.test.ts', kind: 'import', axis: 'ruled-permanent', rulingMarkers: ['#0'] };
707+
expect('every ruled consumer is admitted by one of this programme\'s two rulings',
708+
[...ruled, WITNESS_RULED].every(admittedByARuling));
709+
expect('…and that rule can FAIL: a marker neither ruling issued does not admit a consumer',
710+
!admittedByARuling(WITNESS_UNRULED));
711+
712+
// The anti-GROWTH half, as a ceiling rather than an equality. It may be lowered
713+
// by any PR that migrates an arm away; raising it is a new maintainer ruling,
714+
// which is the same authority `RULING_ISSUES` names.
715+
expect(`the ruled set never grows past what those rulings named (${RULED_CEILING} arm(s); it may shrink to empty)`,
716+
ruled.length <= RULED_CEILING);
669717
}
670718

671719
if (failures.length) {
@@ -679,8 +727,9 @@ function selfTest() {
679727
+ 'entry, a log line, a comment), reads dependency fields but not a manifest\'s own `name`, reports an '
680728
+ 'unledgered arrival AND a stale ledger entry AND a changed binding kind, refuses an unknown axis or an '
681729
+ 'empty `why`, fails when a ruling marker is deleted, fails when a ruled file stops stating the census '
682-
+ 'count, shows that growing the ruled set invalidates every sentence still carrying the old count, and '
683-
+ 'proves discovery reaches both ruled consumers in the real tree.',
730+
+ 'count, shows that growing the ruled set invalidates every sentence still carrying the old count, '
731+
+ 'proves discovery reaches every ruled consumer in the real tree, and holds the ruled set to the '
732+
+ 'rulings that admitted it — a claim that survives the set shrinking to empty.',
684733
);
685734
}
686735

0 commit comments

Comments
 (0)