Skip to content

docs(scripts): point the fixture justifications at the AST walk that replaced the regex - #7921

Merged
baozhoutao merged 1 commit into
mainfrom
claude/issue-6996-stale-regex-justification-comments
Sep 6, 2026
Merged

docs(scripts): point the fixture justifications at the AST walk that replaced the regex#7921
baozhoutao merged 1 commit into
mainfrom
claude/issue-6996-stale-regex-justification-comments

Conversation

@claude

@claude claude Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #6996

Six test suites under scripts/__tests__/ explained how they spell their fixtures by describing scripts-type-check.test.ts as a text matcher over scripts/ — one that "greps this directory for import statements" and "cannot tell a string literal from an import". objectui#4902 replaced that regex with workspaceImportSpecifiers(), an AST walk over ImportDeclaration / ExportDeclaration / ImportEqualsDeclaration nodes, and pinned the string-literal case directly. Every one of those statements described a matcher that no longer exists.

The sweep decided the shape

The card found two sites by exact wording. The triage comment made the wide sweep a precondition for deciding anything else, and it changed the answer: eight statements across six files, not two.

file what it claimed
check-i18n-dead-keys.test.ts "its regex cannot tell a string literal … from a real import statement"
check-i18n-call-site-keys.test.ts (x2) same; plus "whose regex only looks for workspace-package specifiers"
check-i18n-en-drift.test.ts "whose regex looks for workspace-package specifiers"
check-doc-component-types.test.ts "that grep cannot tell a string literal — or a comment quoting one — from a real import"
check-package-self-import.test.ts (x2) "greps every file in the scripts tsconfig program … cannot tell a comment from an import"
check-spec-symbol-derivation.test.ts "it looks for that import TEXT — so a fixture string carrying one trips it"

Probes run (positive control first, so a silent zero-hit sweep is distinguishable from a clean one): the card's exact wording (returns the two known sites), greps this directory, every mention of scripts-type-check, every citation of 4902, every mention of workspaceImportSpecifiers, grep-plus-import prose repo-wide, cannot tell scoped to scripts/, and "needs no build" prose repo-wide. Nothing outside scripts/__tests__/ describes the gate — docs and AGENTS.md are clean.

With six copies, correcting each in place leaves six things that can drift again. So: the authoritative account stays where it already was — workspaceImportSpecifiers()'s own docstring — that docstring now says siblings should point at it rather than restate it, and the six sites became pointers.

The constants are KEPT, and that was measured

Decision (a) from the card was whether I18N_PKG and its twin die with the comments or survive with a corrected reason. Two independent measurements, because the triage forbids removing a constant a live reader depends on:

Enumeration — every text-level reader of scripts/, derived from package.json's check:* scripts and .github/workflows/, not from a hand-list:

  • check-phantom-dependencies, check-unreferenced-sources, check-package-self-import, check-shell-escape-residue — scan roots exclude scripts/ (confirms the card's one checked gate, and extends it to the set).
  • check-pre-install-import-graph, check-vi-mock-specifiers, check-vi-mock-inherit — do read scripts/ textually, but mask comments and literals through js-comment-mask.mjs, so a specifier in a string is not an edge to them either.
  • check-entry-guard, ci-cd-pipeline-doc.test.ts — read scripts/ for other tokens entirely.
  • e2e-type-check.test.ts:306 and vitest-setup-type-check.test.ts:138 — the only surviving raw from '...' regexes in the tree. They read the e2e and vitest-setup programs, not scripts/. These are the closest thing to the reader the comments imagined, and they look elsewhere.

Probe — inlined the specifier at all 41 fixture sites and deleted both constants, proved the mutation reached disk, then ran the readers. All green, scripts-type-check.test.ts included (15/15). Restored, git diff HEAD empty.

So nothing forces the constants. They are kept on their own merit: one spelling across the fixtures, one edit on a package rename. The fixtures are template literals either way, so there is no "interpolation tax" being paid at the call sites — the only thing the old comment cost was a false belief.

No gate behaviour change

Comments only, in all seven files. No constant removed, no assertion touched, no scan root moved.

Gates (all at fad24dc6f)

gate verdict
the 7 touched suites, vitest run --maxWorkers=2 Test Files 7 passed (7), Tests 348 passed (348); lock wrapper VERDICT command-exit 0
pnpm type-check:scripts exit 0
pnpm lint:root exit 0 (33 problems (0 errors, 33 warnings), all pre-existing)
pnpm check:control-bytes check-control-bytes: OK (scanned 6400 tracked text file(s); skipped 85 binary)
pnpm check:i18n-keys exit 0
pnpm check:i18n-dead-keys exit 0
pnpm check:i18n-drift exit 0
pnpm check:self-import No package names itself inside its own src/.
pnpm check:spec-symbols spec member citations: no comment cites a key its spec symbol does not declare.
node scripts/check-changeset-presence.mjs No source or published contract of a released package changed in this range, so no changeset is owed.
check-governed-queue-guard --test NOT GOVERNED — 7 path(s) checked against 5 governed surface(s); none matched.

Draft, no auto-merge.


Generated by Claude Code

…replaced the regex (objectui#6996)

Six test suites under `scripts/__tests__/` justified how they spell their
fixtures by describing `scripts-type-check.test.ts` as a TEXT matcher over
`scripts/` that "cannot tell a string literal from an import". objectui#4902
replaced that regex with `workspaceImportSpecifiers()`, an AST walk over
`ImportDeclaration`/`ExportDeclaration`/`ImportEqualsDeclaration` nodes, and
pinned the string-literal case directly — so every one of those eight
statements described a matcher that no longer exists.

A wide sweep (not just the two sites found by exact wording) is what settled
the shape: with six copies of the description, correcting each one in place
just leaves six things that can drift again. So the authoritative account
stays in `workspaceImportSpecifiers()`'s own docstring, that docstring now
says siblings should point at it rather than restate it, and the six sites
became pointers.

The interpolation constants (`I18N_PKG` in both i18n suites) are KEPT, with
corrected justifications. Measurement, not assumption: no live text-level
reader of `scripts/` matches an import edge from text. `check-phantom-
dependencies`, `check-unreferenced-sources`, `check-package-self-import` and
`check-shell-escape-residue` all exclude `scripts/`; `check-pre-install-
import-graph` and the `check-vi-mock-*` pair read text but mask comments and
literals via `js-comment-mask.mjs`; the live `from '...'` regexes in
`e2e-type-check.test.ts` and `vitest-setup-type-check.test.ts` read the e2e
and vitest-setup programs, not `scripts/`. A probe that inlined the specifier
at all 41 fixture sites and dropped both constants left every one of those
readers green, `scripts-type-check.test.ts` included. The constants therefore
survive on their own merit — one spelling across the fixtures — not as a
workaround, and the fixtures are template literals either way, so nothing is
paying an interpolation tax.

No gate behaviour changes: comments only.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013uAaxiwgYDybsTNV9xwa1M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

finding(scripts): two i18n gate tests still justify their fixtures by a scripts-type-check regex that #4902 replaced with an AST walk

2 participants