Repository navigation
fix(code-mode): distinguish worker retirement causes - #173382
Conversation
Carry bounded owner reasons into lifecycle diagnostics, preserve native crash and GC-thrash attribution before cleanup, and count only confirmed exits. Keep the current four-worker warm-cache policy unchanged.
|
🦞👀 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fc86f350b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs maintainer review before merge. What this changesThis PR distinguishes Code Mode worker retirement causes in existing lifecycle counters and documents the resulting metric labels. Example: Six Code Mode cells complete concurrently under one resource host.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it adds useful worker-lifecycle attribution that current main lacks, preserves the existing retirement policy, and introduces no identified blocking defect. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCode Mode submits JavaScript cells to Node worker pools; pool owners select retirement causes, and the existing worker registry publishes confirmed exits to diagnostic snapshots and Prometheus. flowchart LR
A[Code Mode cells] --> B[Node executor]
B --> C[Worker task pool]
C --> D[Native worker lifetime]
C --> E[Lifecycle registry]
D --> E
E --> F[Diagnostics and Prometheus]
Technical reviewBest possible solution: Retain this focused attribution change through the existing lifecycle owner while preserving worker retention, cancellation, and native-exit semantics. Do we have a high-confidence way to reproduce the issue? Current-main source shows Code Mode retirement paths calling close without a specific cause, while the generic pool records closed; no target code was executed during this review. Is this the best way to solve the issue? The change is appropriately placed: existing pool owners supply causes, the existing registry preserves first-cause attribution, and confirmed native exit remains the counting boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9b12483b9065. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +27, Tests +43, Docs +19. Total +89 across 10 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, 2:49 PM ET / 18:49 UTC. |
* fix(code-mode): distinguish worker retirement causes Carry bounded owner reasons into lifecycle diagnostics, preserve native crash and GC-thrash attribution before cleanup, and count only confirmed exits. Keep the current four-worker warm-cache policy unchanged. * docs(code-mode): align retirement metric references
What Problem This Solves
Code Mode worker churn was grouped under
closed, hiding whether warm workers were evicted, expired, explicitly disposed, or shut down with their host.User Impact
Operators can attribute Code Mode starts and retirements through existing Prometheus lifecycle counters and diagnostic stability logs. No execution, cache-capacity, configuration, schema, or persistence changes.
Why This Change Was Made
The pool owner now supplies bounded close reasons (
eviction,idle-expiry,dispose,shutdown, and existingrotation/memory_pressure). Native Code Mode errors are attributed ascrashorgc-thrashbefore generic failure cleanup. The existing lifecycle owner preserves the first cause and counts retirement only after native exit. Starts retain their script label; a newly started worker has no retirement cause.Current main already retains four warm workers, expires surplus workers after 30 seconds, and keeps one for five minutes. This change first makes that policy measurable rather than increasing the retained set.
Evidence
src/infra/worker-cpu.test.ts(19 passed) andsrc/agents/code-mode-node.lifecycle.test.ts(19 passed); 58.34 seconds wrapper wall time. Final lifecycle rerun after review fix: 19 passed, 46.70 seconds wrapper wall time. Test execution itself was under one second per file; source transformation dominated.git diff --checkpassed. Exact-head CI completed successfully on9dfde4f1642e208471a82f6ae139c3c8cffa86cf; 80 checks passed and the required CI gate was green. The earlier run was superseded by the documentation correction; no CI reruns or inherited-failure exception were needed. No Testbox/Crabbox lease allocated under the current validation policy.rotation. Autoreview preflight rejected the requested provider route because it differed from operator configuration; no configuration was changed.4668b290d506e508ae0ab1263fc9077e0e8fd3db; measured implementation:6fc86f350b6fe084b518854f96641e74b5971753. Final head9dfde4f1642e208471a82f6ae139c3c8cffa86cfonly aligns the canonical Prometheus and troubleshooting docs after hosted review; runtime bytes are unchanged. That documentation follow-up received a clean independent review and passed formatting and diff checks.The observed result is neutral: identical startup counts and retained worker counts, with overlapping idle-heap ranges. These are accelerated synthetic cadence rates, not production starts/hour or RSS measurements. Source-loader overhead contributes to absolute heap sizes. Full Gateway load and production cadence distribution were not reproduced.
The 15-second case now reports 40
eviction, 3idle-expiry, and 1shutdown; the 35-second case reports 40eviction, 30idle-expiry, and 1shutdown, replacing undifferentiatedclosedcounts. No extra counters or log pipeline were introduced.A sandbox-only MRU candidate reused and protected the most recently active worker. It raised mixed-workload starts from 68 to 113/hour (+66%) while still retaining one worker after quiet time, so it was rejected and is absent from this PR. Keep the existing four-worker/30-second-surplus policy; no memory-neutral startup improvement was established.
The error-attribution tests inject native error events; actual out-of-memory and GC-watchdog execution remain covered by existing executor tests in PR CI.