Skip to content

fix(test): prevent an untracked child in the mutation baseline - #4416

Merged
thymikee merged 1 commit into
mainfrom
fix/mutation-weekly-retry-fixture
Nov 11, 2026
Merged

thymikee merged 1 commit into
mainfrom
fix/mutation-weekly-retry-fixture

Conversation

@thymikee

@thymikee thymikee commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix the test fixture that aborted four kernel-errors shards in Mutation Weekly.

The retry mock spawned a real second child before throwing, so the client never received its handle. That child could write a startup marker after the first child's cleanup. Refuse the retry before spawning, and assert that only one fixture child exists so detection does not depend on process scheduling.

One test file changed. No production behavior, timeout, score threshold, or sweep-completeness policy changed. No separate issue.

Validation

  • Head: 4de8160e9f7a7e606cf984eb8805fdf394041826; base: 49a28248d81a3b8de68e9458de73724ade67c729.
  • Added assertion failed before the fix: two fixture children instead of one. The same focused Vitest command passed after the fix; all 26 startup-race tests passed.
  • pnpm gate mutation --modules kernel-errors --shard 4/5: passed on the patched base, including 5,883 baseline tests and the mutation sweep.
  • pnpm check:affected --run --base origin/main --head HEAD: all six checks passed at head; receipt run-E2z8jj, exactCommit=true, checkoutChanged=false.
  • Hosted PR checks and a fresh weekly sweep remain pending; local macOS evidence does not replace the full Ubuntu sweep.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

The retry mock launched a second real child before throwing, leaving its marker outside the client cleanup contract. Refuse before spawning and assert one fixture entry so detection is independent of child scheduling.
@github-actions

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.21 MB 6.21 MB +491 B
Package (unpacked) 6.21 MB 6.21 MB +491 B
Package (download) 1.88 MB 1.88 MB +65 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 23.0 ms 21.1 ms -1.9 ms
CLI --help 50.5 ms 47.4 ms -3.1 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/daemon-client/src/__tests__/daemon-client-startup-race.test.ts">

<violation number="1" location="packages/daemon-client/src/__tests__/daemon-client-startup-race.test.ts:420">
P2: The new `fixture-entries` count only proves no fixture child was written; it does not prove the retry was never attempted, because the refused spawn throws and is swallowed as a startup error. Assert the spawn count directly after the rejection so a retry attempt fails the test.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment on lines +420 to +424
assert.equal(
fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')).length,
1,
'the refused retry must not launch another marker writer',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new fixture-entries count only proves no fixture child was written; it does not prove the retry was never attempted, because the refused spawn throws and is swallowed as a startup error. Assert the spawn count directly after the rejection so a retry attempt fails the test.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/daemon-client/src/__tests__/daemon-client-startup-race.test.ts, line 420:

<comment>The new `fixture-entries` count only proves no fixture child was written; it does not prove the retry was never attempted, because the refused spawn throws and is swallowed as a startup error. Assert the spawn count directly after the rejection so a retry attempt fails the test.</comment>

<file context>
@@ -418,6 +417,11 @@ test('a busy contender that exits sweeps its own pre-lock marker before the retr
       (error: unknown) =>
         error instanceof AppError && error.details?.kind === 'daemon_startup_failed',
     );
+    assert.equal(
+      fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')).length,
+      1,
</file context>
Suggested change
assert.equal(
fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')).length,
1,
'the refused retry must not launch another marker writer',
);
assert.equal(
spawn.mock.calls.length,
1,
'the refused retry must not reach spawn again',
);

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel

Verdict: approve

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
packages/daemon-client/src/__tests__/daemon-client-startup-race.test.ts:420 New assertion checks the mock's own throw, so it cannot fail on any production change

Reviewed with this repository's own Sentinel configuration (9478a4369c9d).

Feedback goes in the review comment threads, as a reply under the inline comment of a finding:

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Comment @apex-sentinel-staging review on this conversation to run a full review.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 4de8160. The verdict and the full list are in the summary comment.

Comment on lines +420 to +424
assert.equal(
fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')).length,
1,
'the refused retry must not launch another marker writer',
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Minor · New assertion checks the mock's own throw, so it cannot fail on any production change

The fixture-entries count is vacuously true: the mock's own guard at lines 398–399 throws before spawnRegisteredDaemonFixture runs, so a second entry directory can never appear regardless of what production code does. A production change that launched a third attempt or retried past the boundary would still pass this assertion. This is a mock asserting its own inputs, which docs/agents/test-authoring.md prohibits.

Suggested change

assert.equal(spawn.mock.calls.length, 1, 'the refused retry must not launch another marker writer');

Details

Also raised here

Also raised at this location by persona javascript: New assertion can fail with a raw ENOENT instead of its own message — If the client stops launching any fixture child at all — a regression where sendToDaemon rejects with daemon_startup_failed before the spawn — fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')) throws ENOENT: no such file or directory rather than reporting the intended message, because that directory exists only as a side effect of a spawn in registered-daemon-fixture.ts. The intended released === true check at line 430 never runs, so the failure reads as a missing file. Assert the spawn count first (a mock count, not a filesystem side effect); the directory then exists whenever the count is 1.

Also raised at this location by persona senior-developer: Test reaches into the fixture helper's private 'fixture-entries' layout — The new assertion hardcodes the fixture-entries directory name owned by packages/test-kit/src/registered-daemon-fixture.ts:92, so a rename of that internal layout makes fs.readdirSync throw ENOENT for this path instead of the assertion's own message. Prefer the observable seam the test already has (spawn.mock.calls.length), or have the fixture helper expose a count, so the failure names the invariant rather than a missing directory.

persona: senior-developer, javascript

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 4de8160. The change is one daemon-client test file, and the earlier Mutation Weekly failure was an assertion in that same test, so the diff covers the failing route. All 17 checks are green, and there are no conflicts. I did not run the test, the mutation gate or check:affected. I relied on the job log, code reading and the hosted checks. The stray marker pid 5948 in the failed run is tied to the second fixture child by code reading, not by pid logging. A fresh Mutation Weekly sweep is still pending and will show whether the Ubuntu baseline is now stable.

Not blocking: the fixture-entries count at line 420 does not show that the retry reached the refusal, so asserting spawn.mock.calls.length === 2 there, as the busy-retry test does, would pin it. The title says "untracked child", but the fixture did track the second child and only the client lacked its handle, so "a second fixture child leaked a startup marker into the baseline" would be more exact. Take or leave both.

The two open test-shape threads do not apply, so you can resolve them. The count at line 420 proves the fixture wrote one child, which is the defect fixed here. The assertion that cannot fail on a production change is fine because the PR changes no production code, and the later deepEqual still fails if the sweep is removed.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 11, 2026
@thymikee
thymikee merged commit b660429 into main Nov 11, 2026
17 checks passed
@thymikee
thymikee deleted the fix/mutation-weekly-retry-fixture branch November 11, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant