Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions scripts/check-adr-anchors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ const SELF_TEST_BATTERIES = Object.freeze({
'Cited numbers resolve (#6634)': 15,
'Cited decision LETTERS resolve (#9592)': 26,
// ⛔ NOT today's count. This battery runs one case per `KNOWN_NUMBER_COLLISIONS`
// row (3 today) on top of 20 structural cases, and entries only ever LEAVE that
// row (3 today) on top of 21 structural cases, and entries only ever LEAVE that
// list: a resolved collision is meant to be deleted, and the gate already fails
// a stale entry. A floor at 23 would redden every legitimate removal and train
// a stale entry. A floor at 24 would redden every legitimate removal and train
// the next author to edit the floor, which is the one habit these floors exist
// to prevent. Pinned instead is the part that does not move with the list: the
// 20 structural cases ran AND at least one row was actually audited.
'Live tree: green as shipped, red under ablation': 21,
// 21 structural cases ran AND at least one row was actually audited.
'Live tree: green as shipped, red under ablation': 22,
'Stem-qualified citations name ONE record (#26076)': 21,
'the sharded registry\'s assembly (#6957)': 13,
});
Expand Down Expand Up @@ -1185,6 +1185,17 @@ function collectAnchorLetterCitations(anchorList) {
return out;
}

// dispatch-gates: whole-tree-population -- `collectCitations` 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.
//
// Why the marker and not a narrower scan (#34086): the whole-tree read is the
// third check's whole point (#6634 — a citation nobody resolves rots wherever it
// is written), so the population is not narrowed. Without the marker
// `dispatch-gates --commands` placed this family by its path literals alone and
// called it silent for every other file: on PR #33975 a fixture string in a
// `scripts/pm/` tool reddened this gate in CI after a dev ran every command the
// derivation named. The `live-scan-population-is-declared` self-test case below
// holds the marker to the scan.

/**
* Every ADR citation in the repo's TRACKED text files.
*
Expand Down Expand Up @@ -2124,6 +2135,29 @@ function selfTest() {
`${new Set(liveCitations.map((c) => c.file)).size} file(s) — the collector is not reading the tree`,
);

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

const citeGreen = auditCitedNumbers(
liveCitations,
liveRecords,
Expand Down
12 changes: 12 additions & 0 deletions scripts/pm/dispatch-gates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4071,6 +4071,18 @@ export const REPO_ROOT_WALK_SPELLINGS = [
label: 'a walk whose DEFAULT PARAMETER is the repo-root binding',
re: /[({,]\s*[A-Za-z_$][\w$]*\s*=\s*(?:REPO_ROOT|REPO_ROOT_DIR|ROOT_DIR)\s*[,)}]/,
},
{
// `git grep` searches the tracked corpus by default — the same population
// limb A enumerates, read in one call (`check-adr-anchors`'s citation scan,
// #34086). Held to the execFile shape, `'git'` then an argv array whose
// element is `'grep'`, because a bare `'grep'` is also the system grep run
// over one named file (`check-skill-compatibility-version`), which reads
// no tree. Like every limb this is necessary, not sufficient: a pathspec
// after the pattern narrows the search, and the declaration's reason is
// where a reader judges that.
label: 'a `git grep` search of the tracked corpus',
re: /['"`]git['"`]\s*,\s*\[[^\]]*?['"`]grep['"`]/,
},
];

/**
Expand Down
9 changes: 9 additions & 0 deletions scripts/pm/dispatch-gates.self-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6871,6 +6871,15 @@ export function selfTest({ tier = 'full' } = {}) {
repoRootWalkSpelling('export function collectSources(root = REPO_ROOT) { return walk(root); }')
=== REPO_ROOT_WALK_SPELLINGS[2].label,
);
t(
'limb D reads a git grep of the tracked corpus in the execFile shape (check-adr-anchors)',
repoRootWalkSpelling("out = execFileSync('git', ['grep', '--untracked', '-IonE', pattern], { cwd: ROOT });")
=== REPO_ROOT_WALK_SPELLINGS[3].label,
);
t(
'the system grep over one named file is not a walk — limb D needs git as the command (check-skill-compatibility-version)',
repoRootWalkSpelling("const r = spawnSync('grep', ['-vxF', '-f', listFile, movedFile], { encoding: 'utf8' });") === null,
);
// The measured tightening. Written to accept a trailing argument, limb B
// selected `resolve(REPO_ROOT, maskerPath)` — a path BUILD — and would have
// vouched for practically any gate holding a REPO_ROOT constant, which is a
Expand Down
Loading