Repository navigation
fix(test-config): state a true reason in the dist-pins guard, and pin it - #8383
Conversation
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
|
ACCEPT (#8274) — reviewed on the tree at head The probe was re-derived and then sharpened past the brief. The brief asked for 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 The sweep distinguished two failure modes that the old sentence blurred, and left the correct one alone. 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 Flake filed, not smoothed over: #8380 records that No changeset owed; both paths NOT GOVERNED. 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 Generated by Claude Code |
|
Armed: PR #8383 flipped ready at 2026-09-07T15:43:24Z on head Generated by Claude Code |
|
LANDED — merged into Content probe on re-fetched
⭐ Worth recording because it is the shape this lane keeps wanting: the pin carries its own non-vacuity control ( Generated by Claude Code |
Fixes #8274
The
DIST_PINS_ENABLEDguard invitest.config.mtsrefusedvitest --project distwith 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.The card's premise holds. An unresolvable
--projectis loud, not green.And measured on the real name, by ablating the guard itself (
if (false && DIST_PROJECT_NAMED ...)), so the reading is aboutdistrather than a proxy — mutation proven on disk (blob77a40ce4to4d791046), restore proven byte-identical back to77a40ce4withgit diff HEADempty: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_PINSnorpnpm test:dist, so it stops the reader without telling them there is a remedy.The message, before and after
Before:
After:
The remaining five lines of the message (what the
distproject 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
--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.--projectname" — which generalises to "every--projectcall 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.Sweep
Grepped the tree for the same reasoning —
exit GREEN/exits green/collect ZERO files/zero files/matched no project/passWithNoTestsacross*.ts,*.tsx,*.mts,*.mjs,*.js,*.md,*.json,*.yml.--project: 2.vitest.config.mts(the throw and its comment — corrected here) andscripts/__tests__/app-test-entry-8240.test.ts.vitest.config.mts, both the throw text and the comment).app-test-entry-8240.test.tsstates the opposite and states it correctly: "a project name that resolves to nothing is loud: vitest throwsNo 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:
OBJECTUI_DIST_PINSnortest:dist(both halves of the justification the guard now states);--project distwith the env var unset, asserting the guard fires and the reader gets this message;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:× does not claim the un-opted run exits green or collects zero files— 1 failed, 4 passedif (false && ...))× fires for --project dist without the env var, and reaches the reader first— 1 failed, 4 passedOne 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 filterverbatim, so asserting its absence would fail for a reason unrelated to project resolution.Gates — each by redirect, exit code captured before any pipe
pnpm exec vitest run scripts/__tests__/dist-pins-guard-message-8274.test.tspnpm exec vitest run scripts/__tests__/pnpm lint:rootpnpm type-check:scriptspnpm check:control-bytespnpm check:comment-mask-corpusnode scripts/check-changeset-presence.mjsnode scripts/check-governed-queue-guard.mjs --teston both changed pathsGuard behaviour, directly:
pnpm exec vitest run --project dist,OBJECTUI_DIST_PINSunsetOBJECTUI_DIST_PINS=1 pnpm exec vitest list --project distdistproject resolves and lists its pins, exit 0pnpm check:lint-rule-coveragewas 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 15000msat 16037ms. Re-run in isolation it is green (37 passed, exit 0), and it is untouched by this diff — it scanspackage.jsondependency declarations. It is a load-sensitive flake, filed separately as #8380 rather than shrugged at.Out of scope, filed
check-unused-dependencies.test.tswhole-repo scan flakes on the 15s defaulttestTimeoutunder container load #8380 —check-unused-dependencies.test.ts's whole-repo scan inherits the 15s defaulttestTimeoutand flakes under container load. Unassigned, unlabelled, left for triage.Generated by Claude Code