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

fix(test-config): state a true reason in the dist-pins guard, and pin it - #8383

Merged
baozhoutao merged 1 commit into
mainfrom
claude/issue-8274-dist-pins-guard-message
Sep 7, 2026
Merged

baozhoutao merged 1 commit into
mainfrom
claude/issue-8274-dist-pins-guard-message

Conversation

@claude

@claude claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #8274

The DIST_PINS_ENABLED guard in vitest.config.mts refused vitest --project dist with a justification that was false about vitest. The guard stays; only its reason changes, plus a pin so the reason cannot rot again.

The probe, re-derived on this branch

Exit code captured by redirect before any pipe. vitest 4.1.10 linux-x64 node-v22.22.2.

$ pnpm exec vitest run --project @object-ui/does-not-exist
Error: No projects matched the filter "@object-ui/does-not-exist".
exit 1

The card's premise holds. An unresolvable --project is loud, not green.

And measured on the real name, by ablating the guard itself (if (false && DIST_PROJECT_NAMED ...)), so the reading is about dist rather than a proxy — mutation proven on disk (blob 77a40ce4 to 4d791046), restore proven byte-identical back to 77a40ce4 with git diff HEAD empty:

$ pnpm exec vitest run --project dist        # guard ablated, OBJECTUI_DIST_PINS unset
Error: No projects matched the filter "dist".
exit 1

So the un-opted run has never been a false green on vitest 4. What it is — and this is the guard's real justification — is a dead end: that refusal names neither OBJECTUI_DIST_PINS nor pnpm test:dist, so it stops the reader without telling them there is a remedy.

The message, before and after

Before:

'vitest --project dist was requested, but OBJECTUI_DIST_PINS is not "1", so the',
'`dist` project is NOT declared and this run would collect ZERO files and exit GREEN.',

After:

'vitest --project dist was requested, but OBJECTUI_DIST_PINS is not "1", so the',
'`dist` project is NOT declared. Left to vitest, this run ends in its generic',
'refusal - `No projects matched the filter "dist"`, exit 1 - which tells you the',
'filter matched nothing but not that the project is env-gated, and names neither',
'OBJECTUI_DIST_PINS nor the task that sets it. Hence this message.',

The remaining five lines of the message (what the dist project holds, pnpm test:dist, the pointers) are unchanged — that half was always true and is the half worth keeping. The comment block above the guard carried the same false premise and is rewritten with it; it now quotes the retracted sentence deliberately, as the record of what was corrected.

Four axes — why this wording

  • 实际业务需求. Measured, not hypothetical: the filing seat reached for this sentence while deciding whether a --project-based package script needed an empty-collection guard, could not trust it, and had to go measure vitest. The wording is chosen to answer the question that reader actually had — what happens if I ignore this and run it anyway — because that is the question a refusal message is read for.
  • 项目长远合理性. Contract-first, applied to prose: the guard's premise is a claim about a dependency's behaviour, so it is stated as what that dependency does, at the granularity someone can check. No workaround, no hedge, no deletion of a guard whose value was never in the false sentence.
  • 防 AI 写代码犯错. The old sentence taught a specific wrong lesson — "vitest silently greens on a bad --project name" — which generalises to "every --project call site needs a name-validity guard". It does not and they do not; the genuinely silent case is a project that resolves and then globs zero files, a different mechanism with a different remedy (--no-passWithNoTests, as objectui#8240 uses). Stating the true behaviour keeps that distinction intact instead of blurring two failure modes into one.
  • 创业阶段不扩散需求. No new surface, no new option, no staged deprecation: five lines of message text and one test file. The guard's behaviour is byte-for-byte what it was.

Sweep

Grepped the tree for the same reasoning — exit GREEN / exits green / collect ZERO files / zero files / matched no project / passWithNoTests across *.ts, *.tsx, *.mts, *.mjs, *.js, *.md, *.json, *.yml.

  • Sites found asserting vitest's behaviour on an unresolvable --project: 2. vitest.config.mts (the throw and its comment — corrected here) and scripts/__tests__/app-test-entry-8240.test.ts.
  • Corrected: 1 (vitest.config.mts, both the throw text and the comment).
  • Left alone: 1. app-test-entry-8240.test.ts states the opposite and states it correctly: "a project name that resolves to nothing is loud: vitest throws No projects matched the filter "..." (measured: exit 1); but a project that resolves and then globs zero files is SILENT". My probe corroborates it verbatim.

Everything else the grep turned up (scripts/vitest-invocation-guard.mjs, package-scripts-vitest-projects.test.ts, the various "a gate that scanned zero files is not a gate" comments) is about path filters or empty collections, not about project resolution. Nothing there is proven false by this probe, so nothing there is touched.

Pin decision — the strong form, because it turned out to be cheap

scripts/__tests__/dist-pins-guard-message-8274.test.ts, five cases, 2.03s for the whole file.

The trade as stated in the brief: a grep pin is weak, a spawn pin is strong but costs a vitest spawn. I priced the spawn before choosing — 1675ms, because the run dies during project resolution and never builds a test graph. That price makes the argument one-sided, so the pin measures the fact:

  • two spawns of a real vitest with an undeclared project name, asserting the loud non-zero exit and that vitest's own message mentions neither OBJECTUI_DIST_PINS nor test:dist (both halves of the justification the guard now states);
  • one spawn of --project dist with the env var unset, asserting the guard fires and the reader gets this message;
  • and the cheap static half — the thrown text must not regress to a silent-green claim.

A grep-only pin would have stayed green in the one direction that matters: vitest changing to swallow the bad filter and exit 0. It also invites the repair of editing the sentence until the grep passes. The spawn cannot be satisfied that way.

Both legs reverse-verified from a committed state, each with a trap-guarded restore and byte-identical restoration proven by blob hash:

mutation expected observed
reinstate the false sentence in the throw static case reds × does not claim the un-opted run exits green or collects zero files — 1 failed, 4 passed
ablate the guard (if (false && ...)) the guard-fires case reds × fires for --project dist without the env var, and reaches the reader first — 1 failed, 4 passed

One assertion was deliberately dropped during that work and the reason is recorded in the test: on a config-load failure vitest echoes the config source back, and that source now quotes No projects matched the filter verbatim, so asserting its absence would fail for a reason unrelated to project resolution.

Gates — each by redirect, exit code captured before any pipe

gate exit
pnpm exec vitest run scripts/__tests__/dist-pins-guard-message-8274.test.ts 0 (5 passed, 2.03s)
pnpm exec vitest run scripts/__tests__/ 0 (121 files, 3580 tests) — see note below
pnpm lint:root 0 (0 errors; the 32 warnings are pre-existing, none in the changed files)
pnpm type-check:scripts 0
pnpm check:control-bytes 0 (6649 tracked text files)
pnpm check:comment-mask-corpus 0 (within the residue objectui#7882 holds open)
node scripts/check-changeset-presence.mjs 0 — "no changeset is owed": 2 files changed, 0 of them published source, 0 a manifest whose published contract moved
node scripts/check-governed-queue-guard.mjs --test on both changed paths 0 — NOT GOVERNED, 2 paths against 5 governed surfaces

Guard behaviour, directly:

invocation result
pnpm exec vitest run --project dist, OBJECTUI_DIST_PINS unset throws with the new message, exit 1
OBJECTUI_DIST_PINS=1 pnpm exec vitest list --project dist guard silent, dist project resolves and lists its pins, exit 0

pnpm check:lint-rule-coverage was not run — the known defect objectui#8369.

One note on the suite run, in the interest of not overclaiming. scripts/__tests__/ was run twice. The first (88.04s) was green. The second, during heavy container contention (191.11s), had one failure: check-unused-dependencies.test.ts → "is green: every gated declaration has a consumer", Test timed out in 15000ms at 16037ms. Re-run in isolation it is green (37 passed, exit 0), and it is untouched by this diff — it scans package.json dependency declarations. It is a load-sensitive flake, filed separately as #8380 rather than shrugged at.

Out of scope, filed


Generated by Claude Code

The `DIST_PINS_ENABLED` guard in `vitest.config.mts` refused
`vitest --project dist` with a justification that was false: that the
un-opted run "would collect ZERO files and exit GREEN". Measured on the
installed vitest 4.1.10, an unresolvable `--project` is not silent — project
resolution throws `No projects matched the filter "dist"` and the run exits 1.

A refusal message is a contract with the operator reading it while blocked, so
the wrong sentence is not a cosmetic nit: it cost a reader a round of measuring
vitest before they could act on it.

Keep the guard — its value never depended on the false claim. Vitest's own
refusal names neither `OBJECTUI_DIST_PINS` nor `pnpm test:dist`, so it stops
the reader without a remedy, and supplying that remedy is the guard's real
job. The message and the comment above it now say so.

Pin the fact rather than the words: a new test spawns a real vitest with an
undeclared project name and asserts the loud exit, so a change in vitest reds
a test instead of rotting a comment. A static half keeps the thrown text from
regressing to a silent-green claim.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

ACCEPT (#8274) — reviewed on the tree at head 744817475 against origin/main ab03bffae, read 2026-09-07T15:30Z; domain:devx @ objectui seat, PM session session_01FhBNJcLRZLe8M87VcUgpKr. Merges clean. Two files, +171/−7.

The probe was re-derived and then sharpened past the brief. The brief asked for --project <nonexistent>; the dev also ablated the guard and ran --project dist — the REAL project name — with the env var unset, confirming No projects matched the filter "dist", exit 1. So the reading is about this project, not a proxy for it. The guard was restored byte-identical, proven by blob hash and an empty git diff HEAD.

The repair is scoped exactly right. The guard is kept; only the justification changed. The new message says what actually happens (vitest refuses loudly but names neither OBJECTUI_DIST_PINS nor the task that sets it, so the reader is stopped without a remedy) and drops the silent-green claim. The comment block above the guard carried the SAME false premise and is corrected in the same PR — inside the brief's sweep clause, since the dev's own probe proves it false there too.

The sweep distinguished two failure modes that the old sentence blurred, and left the correct one alone. scripts/__tests__/app-test-entry-8240.test.ts states the OPPOSITE and states it correctly: an unresolvable project name is LOUD, while a project that resolves and then globs zero files is SILENT. Those are different mechanisms with different remedies, and the old wording generalised to "every --project call site needs a name-validity guard", which is false. Leaving that file untouched is the right call.

The pin is the strong form, and the trade was priced before it was chosen. A grep-only pin stays green in the one direction that matters — vitest changing to swallow a bad filter — and invites the repair of editing prose until the grep passes. The spawn pin cannot be satisfied that way. It costs ~2s because the run dies during project resolution and never builds a test graph, which the dev measured rather than assumed. Reverse-verified both ways: reinstating the false sentence reds the static case; ablating the guard reds the behavioural case.

One assertion was dropped for a good reason, and recorded in the test: on a config-load failure vitest echoes the config SOURCE back, which now quotes No projects matched the filter verbatim — so "vitest's own refusal is absent" would have been satisfied for an unrelated reason.

Flake filed, not smoothed over: #8380 records that check-unused-dependencies.test.ts timed out at 16s against a 15s default under container contention, green in isolation and untouched by this diff. Correctly filed rather than fixed by raising a timeout, which this repo's test discipline forbids. This seat added the finding label; grading is triage's.

No changeset owed; both paths NOT GOVERNED. Fixes #8274.

Next: CI convergence → flip ready → post-flip guard → auto-merge SQUASH → queue confirmation → landing probe (the new message text and the spawn pin on re-fetched origin/main; control: the guard still fires with --project dist and stays silent under OBJECTUI_DIST_PINS=1) → LANDED here and on #8274, which closes via Fixes.


Generated by Claude Code

@baozhoutao
baozhoutao marked this pull request as ready for review September 7, 2026 15:43
@baozhoutao
baozhoutao added this pull request to the merge queue Sep 7, 2026
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Armed: PR #8383 flipped ready at 2026-09-07T15:43:24Z on head 744817475 after CI converged all green (28 checks, read 15:43:16Z); post-flip Governed Surface Queue Guard completed/success at 15:43:45Z; auto-merge SQUASH enabled; queued (timestamp in the REST timeline). Landing stroke on merge: probe on re-fetched origin/main — the corrected message text (no silent-green claim) and the spawn pin file present; control: the guard still fires for --project dist without the env var — then LANDED here and on #8274, which closes via Fixes. — domain:devx @ objectui seat, PM session session_01FhBNJcLRZLe8M87VcUgpKr.


Generated by Claude Code

Merged via the queue into main with commit c8ae764 Sep 7, 2026
31 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-8274-dist-pins-guard-message branch September 7, 2026 15:59
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

LANDED — merged into main at 2026-09-07T15:59:45Z as c8ae7648a (squash), read 16:00:06Z. #8274 closed completed via Fixes.

Content probe on re-fetched origin/main (tip c8ae7648a, read 2026-09-07T16:01Z) — the two claims from the Armed note, plus a control:

  1. Corrected message text present. vitest.config.mts:212-227 — the throw now names vitest's actual generic refusal (No projects matched the filter "dist", exit 1), says that refusal tells the reader nothing about the env gate, and then supplies the remedy (pnpm test:dist, OBJECTUI_DIST_PINS, turbo.json). The docblock at 188-207 states plainly that there is no silent green to prevent.
  2. Spawn pin present. scripts/__tests__/dist-pins-guard-message-8274.test.ts — 149 lines, 5 it() cases, 2 spawnSync call sites.
  3. Control (the one that mattered, and it fired as an expectation this seat had to check rather than assume). exit GREEN and collect ZERO files are not at zero on main: 1 hit each in vitest.config.mts, 2 each in the pin. Both are deliberate counter-examples, not survivals of the false claim — the config hit is line 202 quoting the retired sentence in the act of retiring it ("used to justify itself by asserting … It does not, and never did on vitest 4"), and the pin's are the docblock quotation plus expect(message).not.toMatch(/exit GREEN/i) / not.toMatch(/collect ZERO files/i). The false claim survives on main only in negations of itself. Reverse control: OBJECTUI_DIST_PINS matches in 4 files, so a zero-hit reading would have been an instrument failure, not a clean tree.

⭐ Worth recording because it is the shape this lane keeps wanting: the pin carries its own non-vacuity control (control — the slice really is the guard message, not an empty string), so a moved guard or a changed delimiter reddens instead of silently making the negative assertions pass against an empty string. A negative assertion without that control is a green that asserts nothing — the same defect class this lane admitted #8141 for this afternoon.


Generated by Claude Code

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

2 participants