diff --git a/packages/spec/src/type-alias-convention.pin.test.ts b/packages/spec/src/type-alias-convention.pin.test.ts index 8dfc88732c..e1fb9948ef 100644 --- a/packages/spec/src/type-alias-convention.pin.test.ts +++ b/packages/spec/src/type-alias-convention.pin.test.ts @@ -264,7 +264,14 @@ import type * as M167 from './ui/view.zod.js'; import type * as M170 from './ui/component.zod.js'; // --------------------------------------------------------------------------- -// 717 isomorphic aliases: `z.input` === `z.infer`, so no `XParsed` is declared. +// 823 isomorphic aliases: `z.input` === `z.infer`, so no `XParsed` is declared. +// +// That number is machine-checked, not hand-kept. The runtime companion at the +// bottom of this file recomputes the pin count from the source and asserts that +// every sentence stating it — this header and that case's own title — agrees +// (#6605). Before the check existed this line had been left at 717 while the +// list grew past 800, because the counting assertion reads the `export type +// Iso...` declarations and never the prose sitting beside them. // --------------------------------------------------------------------------- // ai/agent.zod.ts @@ -1604,10 +1611,13 @@ export type AFamilyParsedIsParseState = Assert< // --------------------------------------------------------------------------- describe('ADR-0122 type-alias convention', () => { - // The title tracks the assertion below; it had been left at 751 when #6037 - // moved the count to 754, so it is corrected here rather than left two - // numbers behind. - it('still declares all 755 isomorphic pins', () => { + // The title states the count as well, and hand-tracking it did not hold: it + // was corrected once, from 751 to 754 (#6037), and had drifted again to sit + // 68 behind by the time #6605 looked. Both prose statements of the number — + // this title and the section header above the pin list — are now asserted + // against the recomputed count below, so neither can go stale without a red + // test naming it. + it('still declares all 823 isomorphic pins', () => { // The truth of each pin is proved by tsc, not here — an `Assert>` // that stops holding is a compile error with the alias named. What tsc // cannot notice is a pin that was DELETED: removing the assertion removes @@ -1746,6 +1756,36 @@ describe('ADR-0122 type-alias convention', () => { const self = readFileSync(fileURLToPath(import.meta.url), 'utf8'); const pins = self.match(/^export type Iso\d+ = Assert 822`, `-7`, + // `136 - 17 - 40 - 5 - 1` — and is deliberately NOT matched. Those numbers + // are true about a past state of the file, and rewriting them to today's + // count would destroy the receipts. The phrase caught here is the narrow + // one that can only ever mean "how many pins are in this file right now". + const stated = [...self.matchAll(/(\d+) isomorphic \w+/g)].map((m) => m[0]); + // Guard the guard: if a reword leaves nothing matching, the check below + // passes over an empty list and silently stops existing. + const phrasingMoved = 'no prose states the pin count any more — has the phrasing moved?'; + expect(stated.length, phrasingMoved).toBeGreaterThanOrEqual(2); + const wrong = stated.filter((s) => !s.startsWith(`${pins.length} `)); + expect(wrong, `prose disagreeing with the ${pins.length} pins counted above`).toEqual([]); }); it('leaves the A-family parse behaviour untouched', () => {