LearnNewsExamplesServices
Frontmatter
id18750
titleA spec mutation whose needle drifts stops testing without going red
stateClosed
labels
bugaitesting
assigneesneo-opus-vega
createdAtSep 15, 2026, 8:20 PM
updatedAtSep 15, 2026, 8:52 PM
githubUrlhttps://github.com/neomjs/neo/issues/18750
authorneo-opus-vega
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 15, 2026, 8:52 PM

A spec mutation whose needle drifts stops testing without going red

neo-opus-vega
neo-opus-vega commented on Sep 15, 2026, 8:20 PM

[!CAUTION] Corrected by the author before implementation — the count below is wrong and so is the fix it implies.

This ticket says 12 mutation .replace() sites, 0 guarded, and prescribes a shared helper plus a placement decision. I reproduced that 12 by running the same syntactic pattern @neo-opus-ada ran — and never checked what the sites were. Reproducing a count is not verifying a claim.

Read in context, 11 of the 12 are ordinary string normalisation, which this ticket's own Out of Scope already excludes: comment-stripping in dockSplitterLayering:56,57, selector normalisation in dockRailTabLayering:72,122, path manipulation in esmDistTransforms:364,365 and dockSplitterLayering:173, gitignore pattern normalisation in gitignoreNegationReachability:62,62,67,117.

Exactly ONE site is a fixture-mutation arm: util/check-block-alignment.spec.mjs:149 — and it is the absence-asserting CONTROL: one, so the defect is real and is the worst shape. But it is one arm, not a class: no shared helper is warranted, no new .mjs, and the placement question is moot. The "four asserting absence" figure was derived from the same bad set and is void.

Scope is now a three-line change to one arm. ACs superseded by the correction comment.

Context

Measured by @neo-opus-ada while tracing neo-agent-skills#77's red, and re-measured here independently. The skills repository turned out to be safe — expectMutationFailure has carried assert.notEqual(mutated, source) since it was written, so a dead mutation there fails loudly. This repository has no such helper and no such guard.

mutation .replace() sites in test/playwright/unit/buildScripts/**:  12
spec files asserting the replacement changed anything:               0  (of 50)

Both counts reproduce. My first pass counted only string-literal needles (2) and undercounted; a regex needle that stops matching returns the source unchanged just as silently, so all 12 belong to the class.

The Problem

String.prototype.replace with a needle that is absent returns the string unchanged and throws nothing. A spec that mutates a fixture to introduce a violation then runs its checker against the pristine fixture — and the arm's verdict is whatever the unmutated source produces.

The dangerous subset is the arms asserting an absence, and there are four. util/check-block-alignment.spec.mjs:149 is the clearest:

test('CONTROL: a blank-line separation is deliberate and draws no notice', () => {
    const {status, output} = run(write('blank.mjs', SPLIT.replace('    // prose about the next key', '')));

    expect(status).toBe(0);
    expect(output).not.toContain('an alignment group starts here')
});

If that comment ever leaves SPLIT, the replace does nothing, the pristine fixture is written, and status is still 0 — because the pristine fixture has no violation either. The expected outcome and the failed-mutation outcome are identical, so the arm passes forever, having silently stopped testing "a blank-line separation is deliberate."

That is the "a control that cannot fail proves nothing" shape, and this one is labelled CONTROL: in its own title.

Presence-asserting arms are luckier: a dead mutation leaves the checker silent where the arm expects a violation, so they go red. Noisy, but honest. The four absence-asserting arms are the ones that go quiet.

The Architectural Reality

Skills solved this in the one place that scales — inside the shared helper:

// neo-agent-skills scripts/test-reusable-pr-baseline.mjs
assert.notEqual(mutated, source, `${label}: fixture mutation changed nothing`);

This repository has no equivalent seam. The 12 sites are inline .replace() calls inside run(write(...)) expressions across 8 files, so there is nothing central to add one line to. That is the real difference between the two repositories and it is why this cannot be a copy of the skills fix.

The trigger differs too, and it is worse here. Skills' needles drift when an action version bumps — dated, visible, and dependabot generates it. Here they drift when someone edits a fixture constant or renames a comment, which is untracked and arrives without an event.

The Fix

A shared assertion helper for the mutation idiom, in the spec tree, used by the 12 sites — something of the shape:

/**
 * @summary Applies one fixture mutation and refuses to proceed if the needle has drifted.
 */
function mutate(source, needle, replacement = '') {
    const mutated = source.replace(needle, replacement);

    expect(mutated, 'fixture mutation changed nothing — the needle has drifted').not.toBe(source);

    return mutated
}

Then SPLIT.replace(x, '') becomes mutate(SPLIT, x). The four absence-asserting arms are the priority; the other eight gain the same protection for free.

Placement is the open question and belongs in the PR: test/playwright/unit/buildScripts/ has no shared test-util module today, so this either introduces one or lives beside the specs. That decision wants structural-pre-flight before the file is written.

Decision Record impact

none. A test-only helper; no runtime, contract or guard behaviour changes.

Acceptance Criteria

  • A shared mutation helper exists in the spec tree and refuses a no-op mutation with a message naming the drifted needle.
  • All 12 sites use it — enumerated in the PR, so the count is checkable rather than asserted.
  • The four absence-asserting arms are named individually in the PR, since they are the subset whose failure mode is silence.
  • A meta-arm proves the helper fails on a drifted needle — deliberately passing an absent needle and asserting the helper rejects it. Without this the fix is itself an unfalsifiable control.
  • check-block-alignment.spec.mjs:149 keeps its CONTROL: semantics: still asserts status === 0, but now cannot reach that assertion on an unmutated fixture.
  • Full unit suite green; no arm's verdict changes as a result of the refactor.

Out of Scope

  • neo-agent-skills — already guarded at test-reusable-pr-baseline.mjs:237, and #78/#79 documented that guard after two reviewers independently proposed adding it.
  • Regex-needle .replace() calls outside mutation arms (ordinary string transformation) — the defect is specific to "mutate a fixture, then assert on the result".
  • The neo-agent-brain spec tree. Unmeasured here; worth the same scan, separately.
  • Converting these specs to a different mutation strategy. The idiom is fine; it needs a guard, not a rewrite.

Avoided Traps

⛔ Do not "fix" this by making the needles regexes. A regex that stops matching is exactly as silent — that is why the honest count is 12 and not 2.

⛔ Do not assume a presence-asserting arm is safe and skip it. It fails loudly rather than silently, which is better but still a failure with a misleading message: "expected a violation, got none" points at the checker, not at the drifted fixture.

Do not copy the skills helper wholesale. It asserts with node:assert inside a plain script; these are Playwright specs using expect. Same idea, different assertion surface.

Related

  • neo-agent-skills#78 / #79 — the version-pin symptom, and the @summary that documents the guard this repository lacks.
  • neo-agent-skills#77 — the dependabot bump that surfaced the class.
  • neo-agent-brain#358 — unrelated mechanism, same lesson: a batch hides what it batches.

Sweeps. Live latest-open: newest 10 open issues read at 2026-09-15T18:20:10Z (#18748 … #18064) plus an exact search on mutation/replace/needle/control terms — zero results. A2A in-flight claim sweep over the latest 30 messages, all read-states: @neo-opus-ada measured this class and wrote "I am not filing a neo twin… say so and I will file neo's separately"; #78 closed narrow to the version pin, so the neo half is unowned and I am taking it rather than leaving it in the offer. She is notified. Memory Core rationale sweep on the problem's nouns: no prior decision on mutation-needle drift. Own-assignment sweep: #18379, #18376, #18532, #18064, #17918, #16358, #16212, #15202 — none covers the spec tree.

Origin Session ID: a2868f57-a008-4abf-b493-b87be1636964

Retrieval Hint: spec mutation replace needle drift silent pass absence-asserting control arm buildScripts

tobiu referenced in commit ab31747 - "test(buildScripts): the blank-line CONTROL arm notices its own dead mutation (#18750) (#18751) on Sep 15, 2026, 8:52 PM
tobiu closed this issue on Sep 15, 2026, 8:52 PM