Repository navigation
test(scripts): stop managed-child descendant checks racing process startup - #125441
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 17, 2026, 7:15 PM ET / 23:15 UTC. ClawSweeper reviewWhat this changesThis PR changes managed-child test fixtures so descendant PID files and an IPC message indicate that descendants have started before lifecycle assertions run. Merge readinessKeep open: the liveness-race fix is sound for the signal test, but it introduces a new timeout-fixture race that can make CI fail while reading a PID file. Likely related people: Peter Steinberger (high confidence) and Vincent Koc (medium confidence). Priority: P3 Review scores
Verification
How this fits togetherThe managed-child script tests spawn Node process trees, terminate a managed process group, and verify descendant cleanup. The fixtures communicate process identity and readiness to the test before teardown and liveness checks. flowchart LR
A[Test launches managed command] --> B[Parent fixture starts descendant]
B --> C[Fixture publishes PID or readiness]
C --> D[Test observes process state]
D --> E[Timeout or termination]
E --> F[Process-group cleanup]
F --> G[Cleanup assertions]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceTests +2. Total +2 across 1 file. View PR surface stats
Review metrics
Merge-risk options
Maintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep parent-owned PID recording in the timeout-cleanup fixture, and reserve descendant-owned readiness signals for fixtures that assert a descendant is alive before termination. Do we have a high-confidence way to reproduce the issue? Yes—delay the descendant’s Node startup beyond the existing 500 ms timeout; cleanup kills its process group before it writes the PID file, and the following synchronous read fails. This is source-reproducible; no test was run in this read-only review. Is this the best way to solve the issue? No—the descendant-owned PID is the right readiness signal only where liveness is asserted; the timeout-cleanup fixture needs a PID recorded before descendant boot or an explicit pre-timeout readiness phase. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against beebeac11d42. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready proof for
Proof gap: none for this test-only change. No production, user-visible, docs, or changelog surface changed. |
|
Merged via squash.
|
What Problem This Solves
test/scripts/managed-child-process.test.tsfails intermittently on loaded CI runners — most recentlyblocking PR #124950, which went green on rerun with no code change. The failing assertion was
expect(isProcessAlive(descendantPid)).toBe(true)in "kills managed child process group descendants whenthe runner is terminated".
The race was in the fixture, not the assertion. The generated child spawned its descendant and then wrote
the descendant's pid itself:
spawn()returns a pid the moment the process is forked, before the descendant's Node runtime has booted.So the test's
await waitFor(() => fs.existsSync(descendantPidPath))proved only that a pid had beenwritten, never that the process was running — and under load the liveness check could observe a descendant
that had not finished starting.
Why This Change Was Made
A flaky assertion guarding real process-group cleanup is worth fixing rather than rerunning: it fails often
enough to train people to hit retry, which is how a genuine cleanup regression would slip through.
The pid file becomes a genuine readiness signal — the descendant writes its own pid once its runtime is up,
so the existing
waitFor(existsSync)now implies liveness. The lingering-child fixture, whose parent exitsimmediately, uses an IPC
process.send('ready')handshake instead, since a pid file alone cannot orderagainst the parent's exit. Two sibling fixtures carried the same optimistic-pid pattern and were fixed
identically.
Deliberately unchanged: every assertion, including the liveness check, and the
waitFor(..., 1_500)teardown bounds. Weakening the assertion, wrapping it in a retry, or stretching the timeouts would have hidden
the race rather than removed it — and would have left a test that can no longer fail.
User Impact
None. Test-only; no production file is touched.
Evidence
Ten consecutive runs of the file, since a single green run proves nothing about a race:
pnpm check:changedgreen; Codex autoreview clean.reviewMetrics — production vs test LOC: production
0, tests+12 / −10(net +2).No
CHANGELOG.mdedit — release-only per repo policy; test-only change.