Skip to content

Commit ea2e12a

Browse files
committed
fix(pm): check:adr-anchors declares its whole-tree citation scan to dispatch-gates
collectCitations runs `git grep --untracked` with no pathspec, so the gate reads every text file, but it declared only its path literals and dispatch-gates --commands called it silent for any card editing a file outside them. The gate now carries the whole-tree-population marker, and a live self-test case holds the marker to the scan in both directions. Claude-Session: https://claude.ai/code/session_01ADHkmT9YphoBfbtPDaBJrs Co-authored-by: Claude <noreply@anthropic.com>
1 parent f81e4b6 commit ea2e12a

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

‎scripts/check-adr-anchors.mjs‎

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ const SELF_TEST_BATTERIES = Object.freeze({
291291
'Cited numbers resolve (#6634)': 15,
292292
'Cited decision LETTERS resolve (#9592)': 26,
293293
// ⛔ NOT today's count. This battery runs one case per `KNOWN_NUMBER_COLLISIONS`
294-
// row (3 today) on top of 20 structural cases, and entries only ever LEAVE that
294+
// row (3 today) on top of 21 structural cases, and entries only ever LEAVE that
295295
// list: a resolved collision is meant to be deleted, and the gate already fails
296-
// a stale entry. A floor at 23 would redden every legitimate removal and train
296+
// a stale entry. A floor at 24 would redden every legitimate removal and train
297297
// the next author to edit the floor, which is the one habit these floors exist
298298
// to prevent. Pinned instead is the part that does not move with the list: the
299-
// 20 structural cases ran AND at least one row was actually audited.
300-
'Live tree: green as shipped, red under ablation': 21,
299+
// 21 structural cases ran AND at least one row was actually audited.
300+
'Live tree: green as shipped, red under ablation': 22,
301301
'Stem-qualified citations name ONE record (#26076)': 21,
302302
'the sharded registry\'s assembly (#6957)': 13,
303303
});
@@ -1185,6 +1185,17 @@ function collectAnchorLetterCitations(anchorList) {
11851185
return out;
11861186
}
11871187

1188+
// dispatch-gates: whole-tree-population -- collectCitations below runs `git grep --untracked` with no pathspec, so every tracked and every untracked-not-ignored text file is read for an ADR-NNNN citation and a card adding one anywhere implicates this gate; the literals elsewhere in this file name the registry and the two release-owned changelogs its excuse list holds, never this scan's population.
1189+
//
1190+
// Why the marker and not a narrower scan (#34086): the whole-tree read is the
1191+
// third check's whole point (#6634 — a citation nobody resolves rots wherever it
1192+
// is written), so the population is not narrowed. Without the marker
1193+
// `dispatch-gates --commands` placed this family by its path literals alone and
1194+
// called it silent for every other file: on PR #33975 a fixture string in a
1195+
// `scripts/pm/` tool reddened this gate in CI after a dev ran every command the
1196+
// derivation named. The `live-scan-population-is-declared` self-test case below
1197+
// holds the marker to the scan.
1198+
11881199
/**
11891200
* Every ADR citation in the repo's TRACKED text files.
11901201
*
@@ -2124,6 +2135,29 @@ function selfTest() {
21242135
`${new Set(liveCitations.map((c) => c.file)).size} file(s) — the collector is not reading the tree`,
21252136
);
21262137

2138+
// The scan's population and the population the gate DECLARES must agree
2139+
// (#34086). `dispatch-gates` reads the marker line above collectCitations;
2140+
// without it the family is placed by its path literals alone and reads
2141+
// silent for every card editing a file outside them — which is how a
2142+
// fixture string in a `scripts/pm/` tool reached CI red, unannounced. The
2143+
// other direction is held too: a scan narrowed to one root under a
2144+
// surviving marker would name this gate on every card on no evidence.
2145+
{
2146+
const ownSource = readFileSync(new URL(import.meta.url), 'utf8');
2147+
const declared = /^\/\/ dispatch-gates: whole-tree-population -- \S/m.test(ownSource);
2148+
const roots = [...new Set(liveCitations.map((c) => c.file.split('/')[0]))].sort();
2149+
assert(
2150+
'live-scan-population-is-declared',
2151+
declared === (roots.length > 1),
2152+
declared
2153+
? `the whole-tree-population marker stands, but the scan read citations under ${roots.length} ` +
2154+
`top-level root(s) (${roots.join(', ')}) — narrow the marker with the scan, or restore the scan`
2155+
: `the scan read citations under ${roots.length} top-level roots (${roots.slice(0, 8).join(', ')}, …) ` +
2156+
'and this file carries no whole-tree-population marker, so dispatch-gates --commands will not ' +
2157+
'name this gate for a card that adds a citation outside its path literals — restore the marker',
2158+
);
2159+
}
2160+
21272161
const citeGreen = auditCitedNumbers(
21282162
liveCitations,
21292163
liveRecords,

0 commit comments

Comments
 (0)