fix(887): the rule applied to one config family and not its sibling

Round 7. BLOCKER empty; three real holes, two of them introduced by round six's own
fixes, which is this repo's recorded `each-fix-round-introduces-an-adjacent-defect`
happening inside a single commit.

**`web/vite.config.js` outranks the pinned `.ts` for `vite build`.** Read from the pinned
tarball rather than remembered: vite 8.1.3's `DEFAULT_CONFIG_FILES` is
`["vite.config.js", "vite.config.mjs", "vite.config.ts", …]`. So a `vite.config.js` whose
plugin shells out to the suite runs it in the gitless stage — measured with all 1411
tests green. The governing rule was already written down one family over ("pinning one
config is worthless while a second can outrank it") and had been applied to
`vitest.config.*` and not to this one. The refusal now covers both families.

**The decoy fix counted one SPELLING of the marker.** `text.count("test: {")` is defeated
by writing the real block `test:  {` with two spaces beside a decoy that matches exactly:
count is 1, the comparison takes the decoy, and the live block filters out precisely the
specs #883 broke on. Now `re.finditer(r"\btest:\s*\{")`.

**The plugin pin added in that same commit shipped the identical decoy hole** it was
written next door to fix — a raw `text.count(PINNED_VITE_PLUGINS) == 1` with a decoy
above `defineConfig`. Both `vite.config.ts` pins now share ONE bracket walk and ONE
whitespace-tolerant uniqueness rule, so they cannot drift apart again.

PROSE, and this one is a false completion claim in my own previous commit message: I said
the `PUBLISH_ACTION`/anti-vacuity sentence and the singular "only an `ENV`" residual were
corrected. They were — in the record and the inventory row, and NOT in the guard
docstring, which is the artifact a code reader hits first. Both are now fixed there too,
the route COUNT is removed from the docstring and the record and kept in ONE place, and
the residual that stated its own false version before retracting it now states the
boundary once.

Also: the `--from=` branch never reached the JSON exec-form parser, so
`COPY --from=web-build ["/source/web", "/dest"]` left the receiving stage unpinned; the
revalidate arm of the gating `if:` is now described as a DEPENDENCY on
`ci-detect-already-validated.sh` (graded `MUTATION: NONE`) rather than as something
asserted here, since only the `docs_only` arm is; and the plugin-bodies residual now says
there are TWO plugins, `react()`'s being third-party and unmitigated.

Battery 64 -> 68, 0 missed. One of those four exists because the battery itself briefly
reported NOTHING and exited 0 after a bad splice deleted its `main()` — it now carries an
anti-vacuity assert on its own mutant count.

Refs: #887
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019T79beF1Ufid3dXju4yqkF
This commit is contained in:
2026-08-30 15:34:31 +02:00
co-authored by Claude Opus 5
parent 06b8081664
commit 8141ac7807
5 changed files with 121 additions and 51 deletions
@@ -45,22 +45,33 @@ pin and reddens.
WHAT A PIN IS AND IS NOT IMMUNE TO, stated precisely because an earlier version of this paragraph
claimed the absolute "a pin cannot have a false green" and cold review refuted it by execution. A
pin is immune to the class that defeated the parser: a DIFFERENT SPELLING of the command. It is not
immune to the same text MEANING something else. EIGHT such routes have been IDENTIFIED, and that
number is a running total, not a proof: it was written as five, then six, then seven, and each was
wrong when checked. Six are handled — `working-directory` and the gating step's own `shell:`; the workflow
`defaults.run.shell` and the job-level `defaults` that would override it; a stage `SHELL`, refused
outright; `web/package.json`'s script map, pinned WHOLE after selecting on the literal `vitest`
missed `npm run test`, `npm t`, and the `prebuild`/`preinstall` LIFECYCLE HOOKS npm runs for
`npm run build` and `npm ci`; `web/vite.config.ts`'s `test:` block, which decides what the suite
COLLECTS and is where a filter would now naturally be written; the ABSENCE of any
`vitest.config.*`/`vitest.workspace.*`/`vitest.projects.*`, which vitest resolves in PREFERENCE to
that file — pinning one config is worthless while a second can outrank it, and the measured effect
of adding one was a run that collected zero specs and exited 0, which is worse than a filtered one;
and the gating job's `container:` image, pinned by `test_ci_image_pin_population.py`
and CITED rather than re-asserted, because two guards on one condition mask each other (#685).
immune to the same text MEANING something else. The routes found so far, and what each is worth,
are enumerated ONCE — in `docs/guard-inventory.md`'s row for this guard, which is where the count
lives. It is not repeated here: it existed in three artifacts with two different values at one
point, and re-syncing three copies is how a number stays wrong (`state-the-invariant-not-the-
measurement`). What this file states is the RULE they are instances of, below.
The eighth, an `ENV` rewriting `PATH` so a pinned `RUN` resolves a different `npm`, is not modelled
and is stated as a residual.
Handled here: `working-directory` and the gating step's own `shell:`; the workflow
`defaults.run.shell` and the job-level `defaults` that would override it; a stage `SHELL`, refused
outright; `web/package.json`'s script map, pinned WHOLE after SELECTING on the literal `vitest`
missed `npm run test`, `npm t`, and the `prebuild`/`preinstall` LIFECYCLE HOOKS npm runs for
`npm run build` and `npm ci`; `web/vite.config.ts`'s `test:` block and `plugins:` array, both
extracted by the same bracket walk and required to be UNIQUE, because a decoy copy above
`defineConfig` satisfies a comparison that takes the first match; and the ABSENCE of any config file
that outranks the pinned one — `vitest.config.*` for vitest, and `vite.config.js`/`.mjs` for `vite
build`, whose `DEFAULT_CONFIG_FILES` puts them BEFORE `.ts`. Pinning one config is worthless while a
second can outrank it, and both halves of that were measured: a `vitest.config.ts` made the suite
collect zero specs and exit 0, and a `vite.config.js` ran the suite inside the gitless stage with
all 1411 tests green.
Cited rather than re-asserted: the gating job's `container:` image, pinned by
`test_ci_image_pin_population.py` — two guards on one condition mask each other (#685).
NOT modelled, as a list rather than an "only": an `ENV` in a pinned stage that changes what a pinned
`RUN` resolves or executes; the BODIES of the pinned plugins (there are two, and `react()`'s is
third-party and unmitigated — only `trackedSourceFilesPlugin`'s laziness is a mitigation); a
dependency's own install script, reached through `npm ci` and `web/package-lock.json`; and a publish
through some action other than `docker/build-push-action`.
So: the pin removes the SPELLING problem outright and reduces the MEANING problem to a list that can
be worked through — a much better place than a predicate that was wrong nine times. It is not
@@ -109,12 +120,12 @@ WHAT IS NOT COVERED, stated rather than implied:
copy whose source names `web` — and NOT the wider "has the suite available to run", which is
what an earlier version of this sentence claimed. A stage copy that RENAMES the tree on the way
in (`COPY --from=web-build /source/web /elsewhere`) has no `web` segment in its source and is
not recognised. THAT CLAUSE WAS WRONG THREE TIMES and is now stated from a measurement rather
than from memory: `COPY --from=web-build /source/web /elsewhere` IS recognised (only the
DESTINATION is renamed, and only sources are read). What is not: a source that is an ANCESTOR of
the tree (`COPY --from=web-build /source /src` brings `/source/web` along without naming it) or
names it only as `/source/.`. Both measured, and both backstopped by the substring sweep — an
ancestor-copy stage running `npm t`, `npx vitest` or a new npm script is caught. The
not recognised. What that boundary EXCLUDES, measured: a source that is an ANCESTOR of the
tree (`COPY --from=web-build /source /src` brings `/source/web` along without naming it), and
one that names it only as `/source/.`. Both are backstopped by the substring sweep — an
ancestor-copy stage running `npm t`, `npx vitest` or a new npm script is caught. (This sentence
was wrong three times before it was written from a measurement; a destination rename such as
`/source/web /elsewhere` IS recognised, because only sources are read.) The
false-NEGATIVE direction is what drops a stage out of the check, so the predicate is pinned in
both directions by its own test, and the substring sweep below is the backstop for whatever it
still misses.
@@ -124,7 +135,9 @@ WHAT IS NOT COVERED, stated rather than implied:
equality, a pin going stale goes loudly red, but a SELECTOR going short is silent. It was short
by exactly one entry (`npm t`, npm's own alias, which this file names among the spellings that
defeated the parser) until cold review measured a stage escaping through it. `PUBLISH_ACTION` is
the same category and is covered by the anti-vacuity assertion instead.
the same category and is NOT covered — anti-vacuity proves the selector is non-empty, which the
real `build` job guarantees, and cannot prove it complete: a publish through a different action
is invisible to it. `test_no_run_BODY_builds_or_pushes_an_image` covers only the shell-body form.
* The gating body is compared LINE BY LINE with each line whitespace-normalised, not byte-exact.
Indentation and reflow are free; line boundaries are not, because a newline separates two
commands — changing `run: |` to `run: >` folds them into one and the whole-text comparison could
@@ -231,13 +244,20 @@ VITE_CONFIG = "web/vite.config.ts"
# "No test files found, exiting with code 0" — the gating step green having run NOTHING, and the
# image published. Pinning one file is worthless while a second can outrank it, so the absence of
# every higher-precedence spelling is asserted rather than assumed.
VITEST_CONFIG_PREFIXES = ("vitest.config.", "vitest.workspace.", "vitest.projects.")
# Every config filename that can outrank the pinned one, for EITHER tool. Read out of the pinned
# tarballs rather than remembered: vite 8.1.3's `DEFAULT_CONFIG_FILES` is
# `["vite.config.js", "vite.config.mjs", "vite.config.ts", …]` — so a `vite.config.js` beats the
# pinned `.ts` for `vite build`, which is what the gitless stage runs. Vitest 4.1.9 resolves
# `vitest.config.*` before `vite.config.*`. MEASURED: a `web/vite.config.js` whose plugin shells out
# to the suite ran it in the gitless stage with all 1411 tests green.
OUTRANKING_CONFIG_PREFIXES = ("vitest.config.", "vitest.workspace.", "vitest.projects.", "vite.config.")
# A vite plugin runs inside the same process as the suite and can shell out from a build hook, so a
# `buildStart()` calling `npm test` re-arms ersatztv#887 from the plugin side with every other pin
# matching (measured). The ARRAY is pinned so no plugin joins silently; the plugin BODIES are not,
# and that is a stated residual — `trackedSourceFiles.ts` is deliberately LAZY for this exact
# reason, which its own comment now marks as load-bearing for the image build.
PINNED_VITE_PLUGINS = "plugins: [react(), trackedSourceFilesPlugin()],"
# The ARRAY, as the bracket walk returns it — no `plugins:` prefix, no trailing comma.
PINNED_VITE_PLUGINS = "[react(), trackedSourceFilesPlugin()]"
PINNED_VITE_TEST_BLOCK = """test: {
environment: 'jsdom',
environmentOptions: {
@@ -262,6 +282,25 @@ def _normalise(text: str) -> str:
return " ".join(text.split())
def _bracket_span(text: str, start: int, opener: str, closer: str) -> str:
"""The balanced `opener`…`closer` span beginning at or after `start`.
Shared by both `vite.config.ts` pins so they cannot drift: the plugin array shipped a raw
substring comparison while the `test:` block used a walk, and the substring one was defeated by
the very decoy the walk had just been taught to reject.
"""
begin = text.index(opener, start)
depth = 0
for index in range(begin, len(text)):
if text[index] == opener:
depth += 1
elif text[index] == closer:
depth -= 1
if depth == 0:
return text[begin : index + 1]
raise AssertionError(f"{VITE_CONFIG}: unbalanced {opener}{closer} from offset {begin}")
def _vite_test_block() -> list[str]:
"""The `test: {` … matching `}` block of `web/vite.config.ts`, normalised per line.
@@ -270,17 +309,17 @@ def _vite_test_block() -> list[str]:
explained without the explanation being pinned.
"""
text = _read(VITE_CONFIG)
occurrences = text.count("test: {")
# A decoy `const reviewed = { test: {…} }` copied byte-for-byte from the pin, placed ABOVE
# `defineConfig`, satisfies a comparison that takes the FIRST match while the real block is
# narrowed — measured green. The file already requires exactly ONE step named `Test SPA` for the
# same reason; the reasoning had not been applied here.
assert occurrences == 1, (
f"{VITE_CONFIG} contains {occurrences} `test: {{` blocks, not one. The pin compares the "
f"FIRST, so a second is either a decoy that satisfies it while another block decides, or a "
f"real second config nobody is checking."
# WHITESPACE-TOLERANT, because counting one SPELLING is not counting the marker: a decoy written
# `test: {` beside a real block written `test: {` made `text.count("test: {") == 1` while the
# comparison took the decoy — measured green with the real block filtering out exactly the specs
# ersatztv#883 broke on. One space defeated the previous fix.
matches = list(re.finditer(r"\btest:\s*\{", text))
assert len(matches) == 1, (
f"{VITE_CONFIG} contains {len(matches)} `test:` blocks, not one. The pin compares the FIRST, "
f"so a second is either a decoy that satisfies it while another block decides, or a real "
f"second config nobody is checking."
)
start = text.index("test: {")
start = matches[0].start()
depth = 0
for index in range(start, len(text)):
if text[index] == "{":
@@ -400,6 +439,15 @@ def copies_spa_source(command: str) -> bool:
if not tokens or tokens[0].upper() not in COPY_INSTRUCTIONS:
return False
remainder = " ".join(token for token in tokens[1:] if not token.startswith("--")).strip()
if remainder.startswith("["):
# Parse the exec form BEFORE the `--from=` branch: splitting `["/source/web", "/dest"]` on
# whitespace leaves a trailing comma on the first token, so the segment test never matched
# and the stage went unpinned. Measured False.
try:
parsed = json.loads(remainder)
except ValueError:
return True
remainder = " ".join(str(item) for item in parsed) if isinstance(parsed, list) else ""
if any(token.startswith("--from=") for token in tokens[1:]):
# A stage copy is not a CONTEXT copy, so `--from=build .` brings in that stage's `/`, not the
# repository. But it can still carry the SPA SOURCE across from a stage that has it, and a
@@ -750,10 +798,23 @@ def test_the_VITE_PLUGIN_LIST_is_exactly_what_was_reviewed() -> None:
there is that `trackedSourceFilesPlugin` is deliberately lazy.
"""
text = _read(VITE_CONFIG)
assert text.count(PINNED_VITE_PLUGINS) == 1, (
f"`{VITE_CONFIG}`'s plugin list is not the pinned one ({PINNED_VITE_PLUGINS!r}). A vite "
f"plugin runs in the same process as the suite and can shell out from a build hook, so a "
f"new one is a decision to state. Update the pin deliberately."
# The SAME bracket walk and the SAME uniqueness rule as the `test:` block. The first version of
# this assertion was `text.count(PINNED_VITE_PLUGINS) == 1` — a raw substring — and it shipped
# the decoy hole it was written one function away from fixing: a decoy `const reviewedPlugins =
# { plugins: [react(), trackedSourceFilesPlugin()], }` above `defineConfig` satisfied the count
# while a third plugin sat in the live array. Measured green. That is
# `each-fix-round-introduces-an-adjacent-defect` inside a single commit.
matches = list(re.finditer(r"\bplugins:\s*\[", text))
assert len(matches) == 1, (
f"`{VITE_CONFIG}` contains {len(matches)} `plugins:` arrays, not one. The pin compares the "
f"FIRST, so a second is either a decoy or a real list nobody is checking."
)
array = _bracket_span(text, matches[0].start(), "[", "]")
assert _normalise(array) == _normalise(PINNED_VITE_PLUGINS), (
f"`{VITE_CONFIG}`'s plugin list is not the pinned one.\n pinned: "
f"{_normalise(PINNED_VITE_PLUGINS.rstrip(','))}\n actual: {_normalise(array)}\n"
f" A vite plugin runs in the same process as the suite and can shell out from a build hook, "
f"so a new one is a decision to state. Update the pin deliberately."
)
@@ -770,12 +831,15 @@ def test_NO_OTHER_vitest_CONFIG_outranks_the_pinned_one() -> None:
intruders = sorted(
path
for path in tracked_files._git_ls_files()
if path.startswith("web/") and path.rpartition("/")[2].startswith(VITEST_CONFIG_PREFIXES)
if path.startswith("web/")
and path.rpartition("/")[2].startswith(OUTRANKING_CONFIG_PREFIXES)
and path != VITE_CONFIG
)
assert not intruders, (
f"these files outrank the pinned `{VITE_CONFIG}` in vitest's config resolution: {intruders}. "
f"Whatever they say about `include`/`exclude` decides which specs the gating run collects, "
f"and the pin on `{VITE_CONFIG}` cannot see it — a suite that collects nothing still exits 0. "
f"these files outrank the pinned `{VITE_CONFIG}` in vite's or vitest's config resolution: "
f"{intruders}. Whatever they say decides what the gating run COLLECTS and what `vite build` "
f"loads in the gitless stage, and the pin on `{VITE_CONFIG}` cannot see either — a suite "
f"that collects nothing still exits 0, and a plugin loaded from a `.js` config still runs. "
f"Either fold the settings into `{VITE_CONFIG}` and its pin, or pin this file too."
)