Skip to content

Commit bd9b1ea

Browse files
committed
test(dogfood): derive the authz probe reach from the route ledgers; retire the hand-written census
The 1,691-line `authz-probe-blind-spot.census.ts` pinned registration-site counts, control counts and two blind-spot totals, and every route added anywhere in @objectstack/rest had to re-measure it by hand or red main. `authz-probe-blind-spot.test.ts` now reads population and reach from the ledgers themselves and goes red only on a ledger row the discover() ledger probes cannot name. The matrix docblock stops stating ledger row counts, so the #17111 pin holds only the family / domain figures. discover()'s UNCLASSIFIED / STALE ratchet is unchanged. Claude-Session: https://claude.ai/code/session_01ADHkmPfdxeQ7cdMHou5dY1 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6746140 commit bd9b1ea

7 files changed

Lines changed: 227 additions & 1870 deletions

File tree

‎packages/qa/dogfood/test/authz-conformance.matrix.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@
2424
// hand-curated regex table reaching 1 of 17 REST registrars and 4 of 17
2525
// dispatcher domain files.
2626
//
27-
// The population comes from `packages/rest/src/rest-route-ledger.ts` (81 rows
28-
// / 18 families) and `packages/runtime/src/route-ledger.ts` (105 rows / 23
27+
// The population comes from `packages/rest/src/rest-route-ledger.ts` (18
28+
// families) and `packages/runtime/src/route-ledger.ts` (23
2929
// domains) because those two are enumerated from a RUNNING server and guarded
3030
// in both directions by their own conformance tests — so a new family or
3131
// domain cannot be silently absent from them, and therefore cannot be silently
3232
// absent from here.
3333
//
34-
// [#17111] Those four figures are DERIVED, not hand-typed. The companion test
34+
// [#17111] Those two figures are DERIVED, not hand-typed. The companion test
3535
// parses THIS sentence and asserts each number against a scoped read of the
36-
// ledger the sentence names, so a row, family or domain arriving or leaving
37-
// reds CI here instead of rotting into a false present tense. That pin is the
36+
// ledger the sentence names, so a family or domain arriving or leaving reds CI
37+
// here instead of rotting into a false present tense. ⛔ Row counts are not
38+
// stated, on purpose (ruling 6433001130): a route added inside an existing
39+
// family or domain changes nothing this claim depends on, and a stated row
40+
// count made every such route edit this file or red `main`. That pin is the
3841
// only reason the present tense above is safe to write at all; an undated
3942
// hand-typed count in this position is what #17111 was filed about, and what
4043
// #16307/#16954 were filed about before it.

‎packages/qa/dogfood/test/authz-conformance.test.ts‎

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ const tripwireKey = (surface: string): string => `${surface}(${TRANSPORT_WIRED_M
9898
// them with one number is the mistake this declaration exists to prevent: it
9999
// reads working tripwires as holes and gate pins as route enumerations. The
100100
// taxonomy was established by the reach census
101-
// (`authz-probe-blind-spot.census.ts`) and lived there as PROSE; it lives here
101+
// (`authz-probe-blind-spot.census.ts`, retired after commit 67461403) and
102+
// lived there as PROSE; it lives here
102103
// now, as data on the probe it describes, because a comment cannot be checked
103104
// and a `kind` can.
104105
//
@@ -144,7 +145,7 @@ interface Probe {
144145
* registrar bodies into modules of their own, so they read every file on the
145146
* registrar list (`packages/rest/src/rest-server-registrar-files.ts`,
146147
* imported above) and a transport wired in a moved body still trips them.
147-
* `file` stays the one file the entry NAMES — what the probe-table census and
148+
* `file` stays the one file the entry NAMES — what `authz-probe-blind-spot.test.ts` and
148149
* the matrix header count — and the minted key is unchanged.
149150
*/
150151
alsoReads?: readonly string[];
@@ -200,8 +201,9 @@ const PROBES: readonly Probe[] = [
200201
// stayed 80. Only the headline split moved, earlier and unrelatedly: 50/30
201202
// became 51/29 when `registerUiEndpoints`, the one route in that file
202203
// resolving no identity, was guarded. Recorded so the next reader does not
203-
// re-derive a figure that has now been checked; the full reading lives in
204-
// `authz-probe-blind-spot.census.ts`, the authority on this population.
204+
// re-derive a figure that has now been checked; the full reading is in
205+
// `authz-probe-blind-spot.census.ts` at commit 67461403 (the census was
206+
// retired after it; its derived successor is `authz-probe-blind-spot.test.ts`).
205207
//
206208
// What these two probes supply is the POPULATION; the classification stays a
207209
// reviewed row.
@@ -337,8 +339,8 @@ const PROBES: readonly Probe[] = [
337339
//
338340
// ⚠️ It is re-declared TRIPWIRE, NOT deleted, and the difference matters:
339341
// deleting it would make this gate see LESS. As a declared tripwire its zero
340-
// is a CHECKED reading rather than an accident — the census carries a
341-
// positive control from this same file so a zero from a moved or emptied
342+
// is a CHECKED reading rather than an accident — `authz-probe-blind-spot.test.ts`
343+
// holds a positive control from this same file so a zero from a moved or emptied
342344
// file cannot pass as "nothing found" — and the day a `/data` route is
343345
// mounted here again the key appears and the surface is UNCLASSIFIED, which
344346
// is exactly a tripwire's promise.
@@ -352,7 +354,8 @@ const PROBES: readonly Probe[] = [
352354
// ⚠️ The live spelling this pattern watches for exists one file away, in
353355
// `current-user-endpoints.ts` (3 mounts, none of them `/data`), which this
354356
// table does not name. Naming it is a POPULATION decision and is deliberately
355-
// not taken here — see the census's population-source record.
357+
// not taken here — see the retired census's population-source record
358+
// (`authz-probe-blind-spot.census.ts` at commit 67461403).
356359
{
357360
kind: 'TRIPWIRE',
358361
file: 'packages/plugins/plugin-hono-server/src/hono-plugin.ts',
@@ -715,7 +718,8 @@ function checkLedgerPopulationBaselineWith(
715718
// ⛔ The exemption is not an escape hatch for a probe that has gone blind.
716719
// Re-declaring a ROUTE_ENUMERATION probe as TRIPWIRE to clear a red is only
717720
// honest when its population really is gone AND the zero is backed by a
718-
// positive control from that same file (the reach census holds one per file) —
721+
// positive control from that same file (`authz-probe-blind-spot.test.ts` holds
722+
// one per TRIPWIRE file) —
719723
// the hono probe above is written that way, dated evidence and all.
720724
function checkProbeInstrumentIntegrity(probes: readonly Probe[]): string[] {
721725
const problems: string[] = [];
@@ -1813,10 +1817,18 @@ describe('#7976 — row ↔ proof attribution is mutual', () => {
18131817
// reads ZERO against the very file that carries it. The control leg below
18141818
// pins that failure, because a zero from an instrument that cannot see the
18151819
// shape is not a reading of absence.
1820+
//
1821+
// ⛔ ONLY THE GROUP COUNT IS STATED AND PINNED (ruling 6433001130 on #26410).
1822+
// The docblock used to state each ledger's ROW count too, and this pin held it:
1823+
// every route added inside an existing family or domain then had to edit the
1824+
// matrix docblock or red `main`, though the claim the docblock makes is at
1825+
// family / domain granularity and a new row changes nothing it says. A new
1826+
// family or domain still moves the stated figure here, alongside the
1827+
// `discover()` classification it needs anyway.
18161828

18171829
const MATRIX_FILE = 'authz-conformance.matrix.ts';
18181830

1819-
/** One figure pair the matrix docblock states, and how its ledger spells a row. */
1831+
/** One figure the matrix docblock states, and how its ledger spells a row. */
18201832
interface DocblockLedgerClaim {
18211833
/** Repo-relative ledger path, exactly as the docblock backticks it. */
18221834
file: string;
@@ -1886,22 +1898,15 @@ function flattenLineComments(src: string): string {
18861898
* Every figure the (already-folded) docblock states for one ledger.
18871899
*
18881900
* Anchored on the backticked ledger PATH immediately followed by the
1889-
* parenthesised pair — not on the bare numbers, which also appear in the dated
1901+
* parenthesised group count — not on the bare numbers, which also appear in the dated
18901902
* drift note one paragraph down and must not be pinned as present-tense
18911903
* claims. Every match is returned so the caller can refuse a SECOND copy: an
18921904
* unpinned duplicate is exactly how a third carrier of a stale figure appears.
18931905
*/
1894-
function claimedFigures(flat: string, claim: DocblockLedgerClaim): { rows: number; groups: number }[] {
1906+
function claimedFigures(flat: string, claim: DocblockLedgerClaim): { groups: number }[] {
18951907
const path = claim.file.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1896-
const re = new RegExp('`' + path + '` \\((\\d+) rows / (\\d+) ' + claim.groupNoun + '\\)', 'g');
1897-
return allMatchPairs(flat, re);
1898-
}
1899-
1900-
function allMatchPairs(flat: string, re: RegExp): { rows: number; groups: number }[] {
1901-
const out: { rows: number; groups: number }[] = [];
1902-
let m: RegExpExecArray | null;
1903-
while ((m = re.exec(flat)) !== null) out.push({ rows: Number(m[1]), groups: Number(m[2]) });
1904-
return out;
1908+
const re = new RegExp('`' + path + '` \\((\\d+) ' + claim.groupNoun + '\\)', 'g');
1909+
return allMatches(flat, re).map((n) => ({ groups: Number(n) }));
19051910
}
19061911

19071912
/** Disagreements between the docblock's stated figures and the ledgers, on folded text. */
@@ -1911,7 +1916,7 @@ function checkFoldedDocblockFigures(flat: string): string[] {
19111916
const claimed = claimedFigures(flat, claim);
19121917
if (claimed.length === 0) {
19131918
problems.push(
1914-
`${claim.file}: the docblock states no (N rows / M ${claim.groupNoun}) figure for it — the pin has lost its subject`,
1919+
`${claim.file}: the docblock states no (N ${claim.groupNoun}) figure for it — the pin has lost its subject`,
19151920
);
19161921
continue;
19171922
}
@@ -1928,9 +1933,6 @@ function checkFoldedDocblockFigures(flat: string): string[] {
19281933
continue;
19291934
}
19301935
for (const c of claimed) {
1931-
if (c.rows !== actual.rows) {
1932-
problems.push(`${claim.file}: docblock says ${c.rows} rows, the table holds ${actual.rows}`);
1933-
}
19341936
if (c.groups !== actual.groups) {
19351937
problems.push(
19361938
`${claim.file}: docblock says ${c.groups} ${claim.groupNoun}, the table holds ${actual.groups}`,
@@ -1983,31 +1985,13 @@ describe("#17111 — the matrix docblock's ledger figures are pinned to the ledg
19831985
expect(checkDocblockFigures(matrixText())).toEqual([]);
19841986
});
19851987

1986-
it('a stale ROW count is RED — the #14503 drift, replayed', () => {
1988+
it('a stale GROUP count is RED — the #20102 drift (a family leaving), replayed', () => {
19871989
// Doctored from the MEASURED value, so this case hand-types no count of
19881990
// its own — the thing the card was filed about.
1989-
const { rows, groups } = measureLedgerTable(REST);
1991+
const { groups } = measureLedgerTable(REST);
19901992
const flat = flattenLineComments(matrixText());
1991-
const doctored = flat.replace(
1992-
`(${rows} rows / ${groups} families)`,
1993-
`(${rows + 3} rows / ${groups} families)`,
1994-
);
1993+
const doctored = flat.replace(`\`${REST.file}\` (${groups} families)`, `\`${REST.file}\` (${groups + 1} families)`);
19951994
expect(doctored, 'the doctoring must land, or this case proves nothing').not.toBe(flat);
1996-
expect(
1997-
checkFoldedDocblockFigures(doctored).some((p) =>
1998-
p.includes(`docblock says ${rows + 3} rows, the table holds ${rows}`),
1999-
),
2000-
).toBe(true);
2001-
});
2002-
2003-
it('a stale GROUP count is RED too — both halves of the pair are pinned', () => {
2004-
const { rows, groups } = measureLedgerTable(REST);
2005-
const flat = flattenLineComments(matrixText());
2006-
const doctored = flat.replace(
2007-
`(${rows} rows / ${groups} families)`,
2008-
`(${rows} rows / ${groups + 1} families)`,
2009-
);
2010-
expect(doctored).not.toBe(flat);
20111995
expect(
20121996
checkFoldedDocblockFigures(doctored).some((p) =>
20131997
p.includes(`docblock says ${groups + 1} families, the table holds ${groups}`),
@@ -2018,18 +2002,18 @@ describe("#17111 — the matrix docblock's ledger figures are pinned to the ledg
20182002
it('DELETING the figure is RED — the pin cannot be silenced by dropping its subject', () => {
20192003
// Otherwise the cheapest way to green this gate would be to remove the
20202004
// sentence, which is the claim, not the defect.
2021-
const { rows, groups } = measureLedgerTable(REST);
2005+
const { groups } = measureLedgerTable(REST);
20222006
const flat = flattenLineComments(matrixText());
2023-
const doctored = flat.replace(`\`${REST.file}\` (${rows} rows / ${groups} families)`, `\`${REST.file}\``);
2007+
const doctored = flat.replace(`\`${REST.file}\` (${groups} families)`, `\`${REST.file}\``);
20242008
expect(doctored).not.toBe(flat);
20252009
expect(
20262010
checkFoldedDocblockFigures(doctored).some((p) => p.includes('the pin has lost its subject')),
20272011
).toBe(true);
20282012
});
20292013

20302014
it('a SECOND present-tense copy of a figure is RED — a new carrier cannot arrive unpinned', () => {
2031-
const { rows, groups } = measureLedgerTable(REST);
2032-
const one = `\`${REST.file}\` (${rows} rows / ${groups} families)`;
2015+
const { groups } = measureLedgerTable(REST);
2016+
const one = `\`${REST.file}\` (${groups} families)`;
20332017
const flat = flattenLineComments(matrixText());
20342018
const doctored = flat.replace(one, `${one} and again ${one}`);
20352019
expect(doctored).not.toBe(flat);

0 commit comments

Comments
 (0)