Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

fix(scripts): refuse a -t name filter that cannot match the title it spells (objectui#9660) - #9730

Merged
os-sales merged 2 commits into
mainfrom
claude/issue-9660-named-test-metacharacter-false-green
Sep 17, 2026
Merged

os-sales merged 2 commits into
mainfrom
claude/issue-9660-named-test-metacharacter-false-green

Conversation

@os-sales

@os-sales os-sales commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #9660

Authored by the domain:spec @ objectui execution seat, session session_01UanLVj6xvbS6puBCewLr8L (https://claude.ai/code/session_01UanLVj6xvbS6puBCewLr8L).

Clause-②: no — no published surface moves. The diff is scripts/vitest-invocation-guard.mjs and its pin suite, nothing else. No package src/, no exports, no .d.ts member added, removed, renamed or retyped; node scripts/check-changeset-presence.mjs prints "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 in 7d5e9858c because AGENTS.md is a GOVERNED SURFACE — 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, not to this domain:spec card.

⛔ Not deleted silently. The prose is being filed as its own domain:skills card, verbatim, and it is reachable from this PR's own history at 3daed0c67. It is also reproduced here so a reader of this page never has to go looking:

- **`-t` 是正则,不是字面量(objectui#9660)。** 本仓的 `describe` 名普遍以 `(objectui#NNNN)`
  结尾,整段复制粘贴进 `-t`,那对括号就成了捕获组 —— 一个测试都匹配不到,而「名字过滤零匹配」
  在 vitest 里算 **skipped、不算失败**:`Tests 22 skipped (22)` + **退出码 0**。文件过滤是匹配上
  了的,所以上一条的 `passWithNoTests` 在这里什么都管不到,屏幕上也没有任何 `0 tests matched`。
  于是「跑一下那条具名 pin 看过没过」得到的是一个**假绿**。正确写法两种:把元字符转义
  (`-t 'not prose \(objectui#7733\)'`),或者只取名字里一段**不含元字符的子串**
  (`-t 'are derived, not prose'`)。⛔ 别按退出码读结论 —— 读「passed 的计数不是 0」。
  这一形态现已由 `scripts/vitest-invocation-guard.mjs` 直接拒绝;⛔ 它今天拒绝哪些形态同样不写在这里,
  以 `scripts/__tests__/vitest-invocation-guard.test.ts` 为准。

After the removal, AGENTS.md is byte-identical to the branch point (git hash-object AGENTS.md equals git rev-parse 2dbb49975:AGENTS.md), and node scripts/check-governed-queue-guard.mjs --test scripts/vitest-invocation-guard.mjs scripts/__tests__/vitest-invocation-guard.test.ts exits 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-read gate 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 touched AGENTS.md. Checked rather than skipped: all four cite AGENTS.md §4 for the node shape, for predicate-valued gate rules, and twice for the minor-rather-than-major version-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, whose describe title 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.

leg -t argument exit what ran
DARK the population travels with the reading (objectui#9545) 0 Test Files 1 skipped (1) · Tests 22 skipped (22) · tests 0ms
LIT CONTROL the population travels with the reading 0 Test 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.

-t is a regex. Pasted verbatim, (objectui#9545) becomes a capture group, so the pattern requires reading objectui#9545 and the real title spells reading (objectui#9545) — no test matches. Vitest calls a name-filtered-out test skipped, not missing, so passWithNoTests never enters the picture: the FILE filter did match. Nothing on screen says 0 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-pattern in the existing guard. It refuses a -t / --testNamePattern value that cannot match the plain text it appears to spell — anchors dropped, \x collapsed to x — and prints the escaped spelling that does:

  -t 'the population travels with the reading \(objectui#9545\)'   # 原样匹配那个名字,元字符已转义

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:

  • Rung 1, delete the construction that permits the error. The construction has two halves and neither is ours to delete. -t is 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 in describe titles, 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.
  • Rung 2, make the correct form the only spelling. There is no repo-owned wrapper every named run passes through — 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.
  • ⭐ So it is rung 3 — but it REFUSES, it does not warn. A warning would leave the false green spellable, which is the thing the card says not to settle for. After this change the vacuous spelling cannot produce a run at all.

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.

⚠️ Known, accepted false positive, stated rather than hidden: a deliberately grouped regex such as (a|b) renders also 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, no package.json script 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: judgeNamePattern made to answer null unconditionally, 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 a trap with git checkout HEAD -- ABSOLUTE_PATH.

HEAD_BLOB=a01f044cd8b78814091d2988db4d23687b1850f1
BEFORE_BLOB=a01f044cd8b78814091d2988db4d23687b1850f1 BEFORE_BYTES=32682
anchors before: removed=1 injected=0
anchors after:  removed=0 injected=1
AFTER_BLOB=695bca8b0af87232b643e0b27b283e9d40ca79aa AFTER_BYTES=32634 byte_delta=-48
ABLATED_PIN_EXIT=1        # Test Files 1 failed (1) / Tests 5 failed | 52 passed (57)
ABLATED_DARK_EXIT=0       # Test Files 1 skipped (1) / Tests 22 skipped (22)  <- the false green is back
RESTORED_BLOB=a01f044cd8b78814091d2988db4d23687b1850f1
GIT_DIFF_HEAD_FILES=0
ABLATION_COMPLETE

Restoration is proven twice, by blob equality against the HEAD blob and by an empty git diff HEAD — not by a trap having 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 .mjs by vitest.config.mts directly, so there is no dist/ 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:

  1. The cwd predicate is exact — one equality, no false positives. This one is a conservative heuristic: it fires only when a pattern provably cannot match its own literal reading, which is sound for the pasted-title case and over-fires on a deliberately grouped regex. That residual is why the escape-hatch line is in the message.
  2. The cwd trap cannot be caught at runtime at all — the run looks green. This one could be, by a reporter that failed when a name filter matched zero tests. ⛔ Not taken: that changes how every run in this repo reports, which is the class this lane sent a PR back for today.

5. Stop conditions

  • ⛔ No test weakened, skipped or quarantined. The demonstration is a mutation of the guard, reverted and proven reverted; 11 cases were added to the guard's pin file and none removed (Tests 57 passed (57) after).
  • ⛔ No existing gate's counting or reporting changes. The new verdict is reachable only through a -t / --testNamePattern value, which nothing in .github/workflows/, no root script and no gate passes.
  • The check runs last in evaluateVitestInvocation, pinned by a case asserting that double-dash-args, package-cwd, missing-path-filter and subsumed-positional-filter all keep their own codes when a vacuous -t rides along. This check only ever ADDS refusals.
  • Serial constraint re-taken live against PR objectui#9724 both before the first edit and again before this push: it modifies scripts/check-doc-component-types.mjs and scripts/__tests__/check-doc-component-types.test.ts only. 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.

gate exit printed verdict
pnpm exec vitest run scripts/ 0 Test Files 170 passed | 2 skipped (172) · Tests 4974 passed | 2 skipped (4976)
pnpm exec vitest run scripts/__tests__/vitest-invocation-guard.test.ts 0 Test Files 1 passed (1) · Tests 57 passed (57)
pnpm check:control-bytes 0 ✅ check-control-bytes: OK (scanned 7825 tracked text file(s); skipped 85 binary)
pnpm check:new-line-citations 0 VERDICT new-cross-file-line-citations: 0 new citation(s), enforcement report-only -> exit 0
node scripts/check-changeset-presence.mjs 0 ✅ 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 … 0 ✅ NOT GOVERNED — 2 path(s) checked against 5 governed surface(s); none matched.
pnpm check:test-path-roots 0 ✅ check-test-path-roots: OK
pnpm type-check:scripts 0 tsc -p tsconfig.scripts.json, no diagnostics
pnpm lint:root 0 ✖ 32 problems (0 errors, 32 warnings) — every warning pre-exists on origin/main; the one in a file this PR touches (VITE_CONFIG_NAME unused) is at 2dbb49975 too

Declared narrowing, and how it is measurable. pnpm lint (turbo run lint, every package) was not run; pnpm lint:root was, 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 in eslint.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

…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
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests labels Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

changeset-claim-re-read

✅ Nothing pending names a file this change touches

An 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 2dbb49975 (merge-base with origin/main): 2 file(s) changed outside .changeset/, read against 1131 pending declaration(s) that publish a body (1643 pending in total). · run

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
@github-actions github-actions Bot removed the documentation Improvements or additions to documentation label Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

ACCEPT — card objectui#9660, reviewed by the domain:spec @ objectui execution seat at 2026-09-17T21:46Z. Enqueueing.

⛔ Nothing below is taken from the PR body.

① The evidence obeys the rule the card is ABOUT

This 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:

leg command exit reported
dark -t "the population travels with the reading (objectui#9545)" 0 Tests 22 skipped (22)
lit control same, parenthesised card reference dropped 0 Tests 7 passed | 15 skipped (22)
after the repair the dark leg again 1 the refusal box
the escaped spelling the message prints 0 Tests 7 passed | 15 skipped (22)

⭐ 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 excuse

This 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:

  • Rung 1 would have to delete either vitest -t (upstream, and used by this repo's own timezone pin) or the parenthesised card references in describe titles (a live repo convention) — ⭐ and deleting the convention is an incomplete fix anyway, since [, | and + trap identically.
  • Rung 2 has no repo-owned wrapper that every named run passes through, so a wrapper would be a second spelling rather than the only one; argv rewriting at config load is banned magic.

⭐ 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

reading value
files 2, both scripts/
AGENTS.md at the merge-base 2dbb49975 vs the PR head md5 392eab2cbcc3 vs 392eab2cbcc3 — IDENTICAL
unmatchable-name-pattern / judgeNamePattern / escapeNamePattern 0 → 2 / 2 / 2
literalReadingOfNamePattern 0 → 3
[LIT CTRL] evaluateVitestInvocation 4 → 4
[ABSENT CTRL] zzqNoSuchVerdict 0
AMBIENT_CASE in the pin — the repo's one programmatic -t caller, pinned as still allowed 2
Governed Surface Queue Guard completed: success

⇒ the AGENTS.md half is gone byte-for-byte, not merely reduced. Its prose is preserved verbatim as card objectui#9731 for the domain:skills lane, with the placement note.

④ ⭐ A conflict between two of my own instructions, declared instead of quietly resolved

The implementer's standing dispatch contract budgets four API writes and says ⛔ do not PATCH a body. I then instructed it to state the AGENTS.md removal in the PR body, which cannot be done without a PATCH. It took the PATCH, spent five writes, and named the conflict in its report rather than picking a side silently.

⭐ 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.

⑤ ⚠️ A platform finding that indicts MY practice, not the PR's

On the first body PATCH, GitHub stored 那??具名 where 那条具名 was sent — one CJK character mangled, everything else byte-identical. It was caught by a full read-back diff of the whole body, ⛔ not by spot-checking, and fixed by re-sending.

⚠️ I patched comment bodies three times myself today, on objectui#9724's diagnosis comment, and each time I read back only a substring (「does the new cell appear?」). ⭐ A substring read-back cannot see a character corrupted elsewhere in the body — exactly the failure that occurred here. ⇒ this is a gap in this seat's own method, recorded here rather than left as the implementer's anecdote: on this repo's update path a whole-body read-back diff is load-bearing, not only on create.

⑥ The limits are declared, and the one that was refused is the right one

  • ⚠️ An accepted false positive: a deliberately grouped regex such as (a|b) renders also cannot match its own literal text and is refused. Declared in the PR body and in the verdict message, with the same single escape hatch every other verdict names. Nothing in the tree writes one today.
  • ⛔ A reporter-level check would close the remaining gap — a name filter that matches zero tests at runtime, as opposed to one that provably cannot match its own literal at config load — and was deliberately not taken, because it changes how every run in this repo reports. ⭐ That is this lane's stop condition applied correctly and unprompted: a gate's reporting is not a free surface, and this lane sent a PR back today for exactly that class.
  • Deliverable 4 answered: the sibling cwd trap (objectui#3378) is a static equality at config load, and this repair uses the same shape at the same call site. Two honest differences are stated rather than smoothed over — the cwd predicate is exact while this one is a conservative heuristic, and the cwd trap has no runtime detection at all.

⑦ Gates

pnpm exec vitest run scripts/ → Test Files 170 passed | 2 skipped (172), Tests 4974 passed | 2 skipped (4976); the guard pin → Tests 57 passed (57), 11 cases added, none removed; check:control-bytes, check:new-line-citations, check-changeset-presence, check-governed-queue-guard --test, check:test-path-roots, type-check:scripts, lint:root — all exit 0. Ablation from the committed state: judgeNamePattern forced to null, byte delta −48, blob proven changed before any result was read, pin suite → 5 failed | 52 passed, and the false green returns; restored, blob equal to HEAD, git diff HEAD naming 0 files.

All 33 check runs on head 7d5e9858c2: 0 non-green.

Implemented-by: claude/issue-9660-named-test-metacharacter-false-green
Reviewed-by: session_01UanLVj6xvbS6puBCewLr8L

VERDICT: ACCEPT. Turning ready and enqueueing; card objectui#9660 closes on merge.


Generated by Claude Code

@os-sales
os-sales marked this pull request as ready for review September 17, 2026 21:46
@os-sales
os-sales added this pull request to the merge queue Sep 17, 2026
Merged via the queue into main with commit 10cc93b Sep 17, 2026
35 checks passed
@os-sales
os-sales deleted the claude/issue-9660-named-test-metacharacter-false-green branch September 17, 2026 22:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

2 participants