Repository navigation
fix(code-mode): retire idle workers after persistent GC storms - #173577
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesRetire persistently storming warm Code Mode workers and drain active workers before retirement. Example: A completed worker records 101 major collections in each of two consecutive 10-second windows.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this PR provides useful maintainer-directed containment absent from current main, and inspection found no concrete introduced correctness or security defect. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Node Code Mode worker reports GC observations through its existing memory port; the executor pool owns reuse, continuation custody, and native retirement. flowchart LR
A[V8 GC samples] --> B[Worker storm detector]
B --> C[Existing memory port]
C --> D[Code Mode pool owner]
D --> E[Retire completed worker]
D --> F[Drain active or parked cell]
F --> E
E --> G[Lazy replacement]
Technical reviewBest possible solution: Retain the bounded containment in the existing pool lifecycle alongside the separate sampler repair. Do we have a high-confidence way to reproduce the issue? Current-main source permits below-limit storms to continue until idle expiry, and supplied synthetic regressions exercise that missing retirement path; the production storm itself was not reproduced. Is this the best way to solve the issue? The patch uses the established detector, transport, and lifecycle owner while preserving active work, making it a reasonable bounded containment measure rather than a claim to repair the underlying GC cause. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 44998b0afc07. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +43, Tests +94, Docs +7. Total +144 across 8 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 15, 2026, 8:25 PM ET / October 16, 2026, 00:25 UTC. |
CI Attribution and Landing EvidenceThe exact-head CI run 38827361061 has one substantive failed shard: checks-node-changed-19. Its only file, The failing path is workspace skill discovery/admission. This PR changes neither that owner nor the native-workspace fixture. The test uses plain-text responses without Code Mode cells, and the failed run has no Code Mode storm signal or retirement. The new diagnostic control branch handles only that absent signal. Independent source review found no connection from the changed retirement path to this failure. Under the operator-authorized unrelated-flake rule, ran the single failing file five times on each revision in an isolated Linux sandbox, with Node 24.19.0 matching CI, an unprivileged user, synthetic state, private loopback networking, and one Vitest worker: node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/required-native-same-session.e2e.test.ts --maxWorkers=1
CI tested merge Relevant sibling CI proof also passed: Code Mode detector 1 test, lifecycle 22, executor 15, watchdog 3, and worker CPU lifecycle 19. Production/test typechecks, lint, guards, docs, UI E2E, and security checks passed. No module, export name, or test file was added. GitHub code review and independent review found no actionable code defects; ClawSweeper's sole requested action was to establish CI attribution, covered here. Landing classification: unrelated workspace E2E flake under the standing five-passing-runs-on-base-and-head exception. No CI rerun, branch update, or unrelated source change was used to obtain green. Native storm/V8-crash reproduction remains a stated gap; the requested containment is covered by synthetic detector transport and lifecycle regressions. |
What Problem This Solves
Idle Code Mode workers can continue a sustained major-GC storm far below their heap limit. The near-limit watchdog does not retire them, so they remain in the Gateway process until ordinary idle expiry.
User Impact
A persistently storming warm worker is retired with reason
gc-storm, and the next cell acquires a healthy worker on demand. Active cells and parked continuations retain their worker until completion, cancellation, timeout, or existing continuation expiry. No configuration or schema changes.Why This Change Was Made
The existing detector now sends a small control signal after two consecutive windows above 600 major collections/minute, each at least 10 seconds. Warning/profile cadence stays unchanged. The existing Code Mode pool lifecycle owns the decision: retire completed warm workers, mark other workers draining, and never return a draining worker to the warm pool. At most one worker enters draining per minute across the executor; later detector windows retry other candidates. Deferred exits can coincide when continuations settle.
This is containment, independent of the GC-observer feedback-loop repair in #173574;
gc-observer.tsis unchanged. The two PRs have no overlapping files, and the replacement sampler preserves the GC sample contract consumed here. It does not establish or fix the underlying native V8 crash cause.Evidence
gc-storm, replacement is lazy, and active/parked work survives until completion or disposal.node scripts/run-vitest.mjs src/agents/code-mode-node.lifecycle.test.ts src/agents/code-mode-node.gc.test.ts --maxWorkers=1— 23 passed, 22.40 s wrapper wall time (19.25 s Vitest, mostly transformation; test bodies below one second).git diff --check. Broad validation belongs to PR CI; no Testbox/Crabbox lease, production access, or load benchmark.Related: #172945, #173306, #173382.
CI Attribution and Landing Evidence
The exact-head CI run 38827361061 has one substantive failed shard: checks-node-changed-19. Its only file,
test/e2e/qa-lab/runtime/required-native-same-session.e2e.test.ts, failed withimplicit-main after-agent-wait run failed before settlement; the terminal error wasWorkspaceAccessUnavailableError: Remote workspace skill discovery failed, before the first native inference request. The aggregate CI gate remains red; it is not represented as passing.The failing path is workspace skill discovery/admission. This PR changes neither that owner nor the native-workspace fixture. The test uses plain-text responses without Code Mode cells, and the failed run has no Code Mode storm signal or retirement. The new diagnostic control branch handles only that absent signal. Independent source review found no connection from the changed retirement path to this failure.
Under the operator-authorized unrelated-flake rule, ran the single failing file five times on each revision in an isolated Linux sandbox, with Node 24.19.0 matching CI, an unprivileged user, synthetic state, private loopback networking, and one Vitest worker:
012bb1ccaf0b63696b2608599b1cf4ea869a42455a423e8cfb9026037517bbe895140af4a4dae65bCI tested merge
26853b2c6be18f35da1effc99c272645d1cecb9c, whose ordered parents are the baseline and PR head above. Each replay reportedTest Files 1 passed (1)andTests 1 passed (1). These are validation durations, not performance measurements. The matchingqaRuntimebuild preparation passed on both revisions. Initial root-user attempts hit the fixture's explicit root-quiescence refusal and are excluded from attribution; an initial full build also exceeded an unrelated declaration-size budget by 1,272 bytes, while the required QA build profile passed.Relevant sibling CI proof also passed: Code Mode detector 1 test, lifecycle 22, executor 15, watchdog 3, and worker CPU lifecycle 19. Production/test typechecks, lint, guards, docs, UI E2E, and security checks passed. No module, export name, or test file was added. GitHub code review and independent review found no actionable code defects; ClawSweeper's sole requested action was to establish CI attribution, covered here.
Landing classification: unrelated workspace E2E flake under the standing five-passing-runs-on-base-and-head exception. No CI rerun, branch update, or unrelated source change was used to obtain green. Native storm/V8-crash reproduction remains a stated gap; the requested containment is covered by synthetic detector transport and lifecycle regressions.