Repository navigation
fix(test): prevent an untracked child in the mutation baseline - #4416
Conversation
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.
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
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
| assert.equal( | ||
| fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')).length, | ||
| 1, | ||
| 'the refused retry must not launch another marker writer', | ||
| ); |
There was a problem hiding this comment.
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>
| 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 SentinelVerdict: 1 finding(s): 1 minor. 🟡 Minor (1)
Reviewed with this repository's own Sentinel configuration ( Feedback goes in the review comment threads, as a reply under the inline comment of a finding: Reply Useful? Reply Comment |
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 4de8160. The verdict and the full list are in the summary comment.
| assert.equal( | ||
| fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')).length, | ||
| 1, | ||
| 'the refused retry must not launch another marker writer', | ||
| ); |
There was a problem hiding this comment.
🟡 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.
|
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 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. |
Summary
Fix the test fixture that aborted four
kernel-errorsshards 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
4de8160e9f7a7e606cf984eb8805fdf394041826; base:49a28248d81a3b8de68e9458de73724ade67c729.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; receiptrun-E2z8jj,exactCommit=true,checkoutChanged=false.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.