Repository navigation
fix(scripts): refuse a -t name filter that cannot match the title it spells (objectui#9660) - #9730
Conversation
…t spells (objectui#9660)
`-t` / `--testNamePattern` takes a REGEX. This repo's `describe` titles end in
a literal card reference in parentheses, so the natural copy-paste turns that
pair into a capture group, the pattern matches no test at all, and vitest
reports every test in the named file as SKIPPED — and exits 0.
Measured before the change, from the repo root, with the lit control on the
same instrument and the same corpus:
-t 'the population travels with the reading (objectui#9545)'
=> Test Files 1 skipped (1) / Tests 22 skipped (22) exit 0, tests 0ms
-t 'the population travels with the reading'
=> Test Files 1 passed (1) / Tests 7 passed | 15 skipped (22) exit 0
`passWithNoTests` cannot see it: the FILE filter matched, so the run is not
"no tests found" but "every test found was filtered out", and nothing on
screen says "0 tests matched". Its sibling trap — vitest launched from a
package directory — has been refused outright since objectui#3378; this arm
was not armed.
The new `unmatchable-name-pattern` verdict refuses a name filter that cannot
match the plain text it appears to spell (anchors dropped, `\x` collapsed to
`x`), and prints the escaped spelling that does. The trigger is static, for
the reason the guard's own "Deliberately strict" section already gives: the
guard runs at config load, and "collected zero" would be the weaker signal.
The check runs LAST, so no invocation refused before is refused differently
now.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01UanLVj6xvbS6puBCewLr8L
|
changeset-claim-re-read ✅ Nothing pending names a file this change touchesAn earlier revision of this pull request did. That request to re-read does not apply to the current diff. This comment is updated in place on every re-run rather than posted again, so the thread does not grow one per push. Compared the checked-out tree with |
Removed on the PM's instruction: `AGENTS.md` is a GOVERNED SURFACE — it is the `agents-md` entry in `GOVERNED_SURFACES`, beside `docs/adr/**`, `.claude/**` and `skills/**` — so a pull request touching it needs an approved review from an authorized approver before it can go ready, and governed-surface work belongs to the `domain:skills` lane rather than to this `domain:spec` card. The prose is not lost: it is being filed as its own `domain:skills` card, verbatim, and the mechanical half of the repair stands without it. The file is now byte-identical to the branch point. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01UanLVj6xvbS6puBCewLr8L
|
ACCEPT — card objectui#9660, reviewed by the ⛔ Nothing below is taken from the PR body. ① The evidence obeys the rule the card is ABOUTThis card's subject is a false green, so its own evidence had to show a zero beside a lit control or prove nothing. It does, on one instrument and one corpus:
⭐ Both legs exit 0 before the repair. That is the whole defect in two rows: the exit code is identical and the reading is not, so a seat that reads the exit code learns nothing. The repair makes the two exit codes differ. ② Rung 3, declared — and the reasons 1 and 2 are unreachable are real, not an excuseThis repo's fix order is delete the construction → make the correct form the only spelling → only last, add a check. The PR lands on rung 3 and says why:
⭐ And the thing I asked for: the check REFUSES rather than warns. A warning leaves the false green spellable; a refusal does not. ③ File surface — the governed removal is COMPLETE, verified by hash
⇒ the ④ ⭐ A conflict between two of my own instructions, declared instead of quietly resolvedThe implementer's standing dispatch contract budgets four API writes and says ⛔ do not PATCH a body. I then instructed it to state the ⭐ That is the correct handling and the conflict was mine to own: I issued an instruction that could not be obeyed inside its budget, and I did not notice. A dev that had quietly obeyed either side would have left me unable to tell which. ⑤
|
Fixes #9660
Authored by the
domain:spec@ objectui execution seat, sessionsession_01UanLVj6xvbS6puBCewLr8L(https://claude.ai/code/session_01UanLVj6xvbS6puBCewLr8L).Clause-②: no — no published surface moves. The diff is
scripts/vitest-invocation-guard.mjsand its pin suite, nothing else. No packagesrc/, noexports, no.d.tsmember added, removed, renamed or retyped;node scripts/check-changeset-presence.mjsprints "no changeset is owed" for exactly that reason.0. The documentation half was REMOVED from this branch, on the PM's instruction
The first push of this branch also added a 9-line bullet to
AGENTS.md §测试纪律. It was removed in7d5e9858cbecauseAGENTS.mdis a GOVERNED SURFACE — theagents-mdentry inGOVERNED_SURFACES, besidedocs/adr/**,.claude/**andskills/**— so a pull request touching it needs an approved review from an authorized approver before it can go ready, and governed-surface work belongs to thedomain:skillslane, not to thisdomain:speccard.⛔ Not deleted silently. The prose is being filed as its own
domain:skillscard, verbatim, and it is reachable from this PR's own history at3daed0c67. It is also reproduced here so a reader of this page never has to go looking:After the removal,
AGENTS.mdis byte-identical to the branch point (git hash-object AGENTS.mdequalsgit rev-parse 2dbb49975:AGENTS.md), andnode scripts/check-governed-queue-guard.mjs --test scripts/vitest-invocation-guard.mjs scripts/__tests__/vitest-invocation-guard.test.tsexits 0:✅ NOT GOVERNED — 2 path(s) checked against 5 governed surface(s); none matched.⭐ The mechanical half is the load-bearing rung and it stands without the prose: the guard REFUSES the vacuous spelling, so the false green is unspellable whether or not any document mentions it.
On the
changeset-claim-re-readgate that fired on the first push: it named four pending entries (6357-basechema-bind-declaration.md,6505-predicate-valued-gate-rules.md,7122-spec-17-3-0-parity-reconciliation.md,7714-lookup-draft-stays-client-side.md) only because the diff touchedAGENTS.md. Checked rather than skipped: all four citeAGENTS.md§4 for the node shape, for predicate-valued gate rules, and twice for theminor-rather-than-majorversion-alignment rule — the removed bullet was an addition in a different section and falsified none of them. With the hunk gone, no pending entry names any path in this diff.1. Reproduced first, with a lit control
Instrument DOMAIN:
pnpm exec vitest run FILE -t PATTERN, launched from the repo root.Instrument PREDICATE: the exit code, and how many of that file's tests actually executed.
Corpus (both legs):
scripts/__tests__/body-dialect-census.test.ts, whosedescribetitle ends in a card reference the way this repo's titles do.Both exit codes were captured to a file before any pipe, and both readings are from the tree at
2dbb49975, before the repair.-targumentthe population travels with the reading (objectui#9545)Test Files 1 skipped (1)·Tests 22 skipped (22)·tests 0msthe population travels with the readingTest Files 1 passed (1)·Tests 7 passed | 15 skipped (22)Same instrument, same corpus, same file filter; the only variable is the parenthesised card reference. The control is what makes the first row a reading rather than two zeros on one instrument.
-tis a regex. Pasted verbatim,(objectui#9545)becomes a capture group, so the pattern requiresreading objectui#9545and the real title spellsreading (objectui#9545)— no test matches. Vitest calls a name-filtered-out test skipped, not missing, sopassWithNoTestsnever enters the picture: the FILE filter did match. Nothing on screen says0 tests matched. A seat checking "did the named pin pass?" sees exit 0 next to the file's own name.2. The repair — and the rung it lands on
New verdict
unmatchable-name-patternin the existing guard. It refuses a-t/--testNamePatternvalue that cannot match the plain text it appears to spell — anchors dropped,\xcollapsed tox— and prints the escaped spelling that does:Measured after the repair, same corpus: the pasted form now exits 1 with the box above; the escaped form the message hands back exits 0 with
Tests 7 passed | 15 skipped (22); the plain substring still exits 0 with the same 7 passed.This lands on rung 3 — add a check — and the two higher rungs were not reachable. Stated plainly rather than implied:
-tis Vitest's own documented CLI contract, upstream, and this repo's timezone pin (scripts/__tests__/vitest-timezone-pin-8366.test.ts) spawns a child that depends on it. The other half is the parenthesised card reference indescribetitles, which this repo's own citation convention asks for; a tree-wide rename would trade a live convention for an incomplete fix, because a title carrying[,|or+traps identically.pnpm exec vitest run … -t …is typed directly, by people and by agents. Any wrapper added here would be a second spelling, not the only one, unless the bare form is refused; and refusing it is rung 3. Rewriting argv at config load was considered and rejected: Vitest has already parsed the CLI by then, and commandment Fix documentation deployment for www.objectui.org #6 bans that kind of magic.The trigger is static, decided at config load before collection, which is the same choice the guard's own "Deliberately strict" section already argues for on the cwd arm: "collected zero" is the weaker signal, because a literal title with its metacharacters left live is the wrong command whether or not something else happens to match it.
(a|b) rendersalso cannot match its own literal text, so it is refused too. That is the same strictness the cwd arm already chose, and the message names the one escape hatch every other verdict names (OBJECTUI_VITEST_GUARD=off). No workflow, nopackage.jsonscript and no gate in this tree passes-t; the only programmatic caller is the timezone pin, whose constant is metacharacter-free and is now pinned to stay allowed — read out of that file's source, not copied into the pin.3. Ablation — the repair can fail
Mutation:
judgeNamePatternmade to answernullunconditionally, i.e. the tree as it was before the repair. Run from the committed state, proven on disk before any result was read, restored under atrapwithgit checkout HEAD -- ABSOLUTE_PATH.Restoration is proven twice, by blob equality against the HEAD blob and by an empty
git diff HEAD— not by atraphaving fired and not by an exit code. The script refuses an empty hash as FAILURE rather than reading it as "nothing to compare", and aborts if the pre-mutation blob is not already HEAD's.Direction, declared before the run and observed after: RED, plus the original defect reappearing end to end. 5 of the 11 new cases fail under the mutation; the
'invalid'arm sits before the mutated line and legitimately survives it, which is why it is 5 and not 11.No build step is involved — the guard is loaded as
.mjsbyvitest.config.mtsdirectly, so there is nodist/for a mutation to fail to reach.4. The sibling cwd trap — does the same shape apply?
Yes, and it is the shape used here. objectui#3378 is refused by a static comparison at config load — Vitest's root against the repo root, one equality — and the guard's docstring records that the weaker trigger ("collects zero of its own files") was deliberately rejected. This arm is built the same way: a static predicate, at the same call site, refusing outright, inheriting the same wiring that already covers every entry point (the root config plus each
packages/PKG/vite.config.ts). No new plumbing.Two honest differences:
5. Stop conditions
Tests 57 passed (57)after).-t/--testNamePatternvalue, which nothing in.github/workflows/, no root script and no gate passes.evaluateVitestInvocation, pinned by a case asserting thatdouble-dash-args,package-cwd,missing-path-filterandsubsumed-positional-filterall keep their own codes when a vacuous-trides along. This check only ever ADDS refusals.scripts/check-doc-component-types.mjsandscripts/__tests__/check-doc-component-types.test.tsonly. The file-level intersection with this diff is EMPTY.6. Gates — exit code captured to a file before any pipe
All re-run on the reduced diff, at
7d5e9858c.pnpm exec vitest run scripts/Test Files 170 passed | 2 skipped (172)·Tests 4974 passed | 2 skipped (4976)pnpm exec vitest run scripts/__tests__/vitest-invocation-guard.test.tsTest Files 1 passed (1)·Tests 57 passed (57)pnpm check:control-bytes✅ check-control-bytes: OK (scanned 7825 tracked text file(s); skipped 85 binary)pnpm check:new-line-citationsVERDICT new-cross-file-line-citations: 0 new citation(s), enforcement report-only -> exit 0node scripts/check-changeset-presence.mjs✅ No source or published contract of a released package changed in this range, so no changeset is owed.node scripts/check-governed-queue-guard.mjs --test …✅ NOT GOVERNED — 2 path(s) checked against 5 governed surface(s); none matched.pnpm check:test-path-roots✅ check-test-path-roots: OKpnpm type-check:scriptstsc -p tsconfig.scripts.json, no diagnosticspnpm lint:root✖ 32 problems (0 errors, 32 warnings)— every warning pre-exists onorigin/main; the one in a file this PR touches (VITE_CONFIG_NAMEunused) is at2dbb49975tooDeclared narrowing, and how it is measurable.
pnpm lint(turbo run lint, every package) was not run;pnpm lint:rootwas, and its own config is what defines the population —eslint . --ignore-pattern 'packages/*/**' --ignore-pattern 'examples/*/**' --ignore-pattern 'apps/*/**' --ignore-pattern 'docs/**', which is exactly the region this diff lives in. Type-aware linting is not enabled ineslint.config.js, so no file this PR does not touch can change verdict because of it. Everything else the lane asked for was run in full. CI runs the farm.Self-scan beyond
check:control-bytes, on the changed files:grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]'→ 0 matches.维护者速读(草稿)
改了什么。 给
scripts/vitest-invocation-guard.mjs加了第四条拒绝:-t传进来的名字过滤如果按正则跑在「它自己拼出的那段字面文本」上一个位置都匹配不到,就直接拒绝并印出转义好的正确写法。附带 11 条 pin 测试。原本还改了AGENTS.md,已按 PM 指示移除 —— 那是受管面,归domain:skills车道;原文在上面第 0 节逐字保留。为什么改。 本仓
describe名普遍以(objectui#NNNN)结尾,整段复制粘贴进-t,那对括号成了捕获组 —— 一个测试都匹配不到,而 vitest 把「名字过滤零匹配」算成 skipped、退出码 0。⇒ 一个跑「那条具名 pin 过了没有」的席位拿到的是假绿。它的孪生陷阱(从包目录跑 vitest)早就被这同一个 guard 拒了,这一条一直没装。风险与代价(含回滚)。 代价是一个已知的误报:刻意写的带分组正则(如
(a|b) renders)也会被拒 —— 与 cwd 那条选的严格度一致,逃生口是每条拒绝都印的OBJECTUI_VITEST_GUARD=off。本仓没有任何 workflow / 根脚本 / 门禁传-t,唯一的程序化调用方是时区 pin,它的常量不含元字符且已被钉住。回滚成本 = revert 这个 commit,没有数据迁移、没有发布面、没有 changeset。席位意见。 (留空,待席位定稿)
你要做的。 现在不再是受管面 PR(
AGENTS.md已还原成分支点字节),走普通复核与合并队列即可。Generated by Claude Code