Skip to content

Commit d2b6232

Browse files
fix(pm): check:adr-anchors declares its whole-tree citation scan, so dispatch-gates derives it for every card (#34114)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi92Vt19B5bTPa1d6K7Nf4xkL)_ Fixes #34086 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:门禁 `check:adr-anchors` 在源码里声明「我读整棵树」(dispatch-gates 现有的 whole-tree-population 标记),派发工具 `dispatch-gates` 同步认得 `git grep` 这种全树读法;从此每张卡的 `--commands` 都会派出这个门禁。 - 为什么改:这个门禁用 `git grep` 扫全仓所有文本文件里的 `ADR-NNNN` 引用,却只声明了 4 个路径;改它们之外的文件时派发清单不点它,开发者本地全绿、CI 才红(PR #33975 就是一个 `scripts/pm/` 脚本里的测试字符串触发的)。 - 风险与回滚:只改三个工具脚本,不发布任何包。每张卡多派一条命令,实测约 11 秒。dispatch-gates 只在识别清单末尾追加一条,原有三条及其下标不动。回滚即还原本 PR。 - 先看:`scripts/check-adr-anchors.mjs` 的 `collectCitations` 上方新标记行与自测 `live-scan-population-is-declared`;`scripts/pm/dispatch-gates.mjs` 的 `REPO_ROOT_WALK_SPELLINGS` 第四条。 - 两分钟验证:`node scripts/pm/dispatch-gates.mjs --commands scripts/pm/check-governed-merges.mjs | grep adr-anchors`,预期一行 `pnpm check:adr-anchors`(修复前零行)。 - 需要你做的:无,席位落地(非受管面)。 ## What changes `check:adr-anchors`' third check (#6634) collects citations with `git grep --untracked -IonE …` and no pathspec, so it reads every tracked and every untracked-not-ignored text file. Its source spelled only four path literals (`docs/adr`, its own script and the two release-owned `CHANGELOG.md` files on its excuse list), so `dispatch-gates` placed the family by those alone and scored it `silent` for any other file. Measured on main f81e4b6: 10,237 tracked files cite an ADR, 10,078 of them outside those literals; `--commands scripts/pm/check-governed-merges.mjs` derived 33 commands and not this one. **Route: declare, don't narrow.** The whole-tree read is the point of the check (a citation nobody resolves rots wherever it is written), so the scan stays as it is. `wide-population` was also rejected: it keeps a family out of `--commands`, which is the opposite of the acceptance and of "a miss fails toward deriving more". The existing `whole-tree-population` marker (the channel `check:nul-bytes` and seven other families use) is the fit. No new declaration grammar. | File | Change | |:--|:--| | `scripts/check-adr-anchors.mjs` | The `// dispatch-gates: whole-tree-population -- …` line above `collectCitations`, with a note on why the scan is not narrowed. A live self-test case, `live-scan-population-is-declared`, holds the marker to the scan in both directions: a scan reading more than one top-level root needs the marker, and a marker over a one-root scan is red too. The live battery's floor moves 21 → 22 for that case. | | `scripts/pm/dispatch-gates.mjs` | `REPO_ROOT_WALK_SPELLINGS` gains limb D, `a \`git grep\` search of the tracked corpus`, appended after limbs 0–2 (unchanged). Without it the marker was REFUSED ("its own source carries no recognised repo-root walk … EXTEND REPO_ROOT_WALK_SPELLINGS"). The regex is held to the execFile shape (`'git'` then an argv array holding `'grep'`), so the system `spawnSync('grep', …)` over one named file in `check-skill-compatibility-version.mjs` does not match. Out of the card's file surface: declared to the seat before the edit and approved, with the claim's surface amended. | | `scripts/pm/dispatch-gates.self-test.mjs` | Two fixture cases beside limbs A–C: limb D reads the execFile `git grep`; the system grep is not a walk. | ## Tests - `node scripts/check-adr-anchors.mjs --self-test`: 134 assertions pass, floor included. - `pnpm check:pm-dispatch-gates` (fast tier): 2207 cases pass, 335 s. - Acceptance, before and after: on f81e4b6 `node scripts/pm/dispatch-gates.mjs --commands scripts/pm/check-governed-merges.mjs` printed 33 lines, 0 naming `check:adr-anchors`; on a6876cc it prints 34, including `pnpm check:adr-anchors`, placed under "Always runs (declared population)" with the marker's reason. The always-runs block grows 8 → 9 families. - No forced edits to existing test rows. ## Acceptance notes - Price: every card's `--commands` now carries `pnpm check:adr-anchors` (self-test plus scan, about 11 s measured here). - Serial: PR #34080 (in the merge queue) and card #34084 also edit `scripts/pm/dispatch-gates.mjs`, in other regions; whichever lands second resolves. - The claim's acceptance line asks for `check-governed-merges.mjs --pr` and the tier; the reading is in the os-dev-report on the card. ## Verification Local gates on a6876cc (main f81e4b6 is the base): `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 33 commands; all 33 exit 0. `--ran`: **33 derived, 33 run, 0 NOT-MEASURED, 0 UNRUN**. No package touched, so no build closure and no package test is owed; no changeset (`skip-changeset`). <details><summary>The 33 commands and their exit codes</summary> ```text node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-declaration-mirrors.mjs :: exit 0 node scripts/check-declaration-mirrors.mjs --self-test :: exit 0 node scripts/check-self-test-wired.mjs :: exit 0 node scripts/check-self-test-wired.mjs --self-test :: exit 0 node scripts/check-self-test-workflow-commands.mjs :: exit 0 node scripts/check-self-test-workflow-commands.mjs --self-test :: exit 0 node scripts/check-whole-set-label-write.mjs :: exit 0 node scripts/check-whole-set-label-write.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/pm/bare-root-worklist.mjs --self-test :: exit 0 pnpm check:adr-anchors :: exit 0 pnpm check:agent-test-spelling :: exit 0 pnpm check:bash32-floor :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:cli-command-ids :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:declared-population-live :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:entry-guard :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:parse-guard :: exit 0 pnpm check:pm-dispatch-gates :: exit 0 pnpm check:pm-governed-merges :: exit 0 pnpm check:pnpm-filter-targets :: exit 0 pnpm check:pnpm-flag-spellings :: exit 0 pnpm check:ratchet-remedy-authority :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:scripts-symbol-anchors :: exit 0 pnpm check:watch-hint-literal :: exit 0 ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmT9YphoBfbtPDaBJrs)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c1c86a3 commit d2b6232

3 files changed

Lines changed: 59 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` 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,

‎scripts/pm/dispatch-gates.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,6 +4071,18 @@ export const REPO_ROOT_WALK_SPELLINGS = [
40714071
label: 'a walk whose DEFAULT PARAMETER is the repo-root binding',
40724072
re: /[({,]\s*[A-Za-z_$][\w$]*\s*=\s*(?:REPO_ROOT|REPO_ROOT_DIR|ROOT_DIR)\s*[,)}]/,
40734073
},
4074+
{
4075+
// `git grep` searches the tracked corpus by default — the same population
4076+
// limb A enumerates, read in one call (`check-adr-anchors`'s citation scan,
4077+
// #34086). Held to the execFile shape, `'git'` then an argv array whose
4078+
// element is `'grep'`, because a bare `'grep'` is also the system grep run
4079+
// over one named file (`check-skill-compatibility-version`), which reads
4080+
// no tree. Like every limb this is necessary, not sufficient: a pathspec
4081+
// after the pattern narrows the search, and the declaration's reason is
4082+
// where a reader judges that.
4083+
label: 'a `git grep` search of the tracked corpus',
4084+
re: /['"`]git['"`]\s*,\s*\[[^\]]*?['"`]grep['"`]/,
4085+
},
40744086
];
40754087

40764088
/**

‎scripts/pm/dispatch-gates.self-test.mjs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7018,6 +7018,15 @@ export function selfTest({ tier = 'full' } = {}) {
70187018
repoRootWalkSpelling('export function collectSources(root = REPO_ROOT) { return walk(root); }')
70197019
=== REPO_ROOT_WALK_SPELLINGS[2].label,
70207020
);
7021+
t(
7022+
'limb D reads a git grep of the tracked corpus in the execFile shape (check-adr-anchors)',
7023+
repoRootWalkSpelling("out = execFileSync('git', ['grep', '--untracked', '-IonE', pattern], { cwd: ROOT });")
7024+
=== REPO_ROOT_WALK_SPELLINGS[3].label,
7025+
);
7026+
t(
7027+
'the system grep over one named file is not a walk — limb D needs git as the command (check-skill-compatibility-version)',
7028+
repoRootWalkSpelling("const r = spawnSync('grep', ['-vxF', '-f', listFile, movedFile], { encoding: 'utf8' });") === null,
7029+
);
70217030
// The measured tightening. Written to accept a trailing argument, limb B
70227031
// selected `resolve(REPO_ROOT, maskerPath)` — a path BUILD — and would have
70237032
// vouched for practically any gate holding a REPO_ROOT constant, which is a

0 commit comments

Comments
 (0)