Repository navigation
feat(diagnostics): attribute Code Mode GC storms to reasons and runs - #172945
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 changesThis PR adds bounded GC callback-reason labels and rate-limited Code Mode storm warnings with worker and run attribution. Example: A parked Code Mode cell records 101 major collections over 10 seconds.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep open: this PR adds useful, maintainer-directed diagnostics that current main lacks, with two focused repairs needed for CI and transport accounting. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherNative GC observers feed the existing worker memory transport and diagnostics event owner; Prometheus exports bounded labels, while the worker registry attaches physical-worker identity to storm logs. flowchart LR
A[Native GC observer] --> B[Code Mode worker]
A --> C[Diagnostics events]
B --> D[Worker memory port]
D --> E[Worker registry]
E --> C
E --> F[Storm warning log]
C --> G[Prometheus exporter]
Technical reviewBest possible solution: Keep the existing observer, transport, and registry ownership while fixing the new mock factories and counting storm-message crossings. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the omitted transport accounting and rejected mock-factory shapes, and exact-head CI confirms the mock-exports failure; no target code was executed. Is this the best way to solve the issue? The existing observer and memory-port path are appropriate owners for this observability addition, with no need for another sampler, registry, configuration option, or execution-policy change. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9b2bc0ed7e13. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +135, Tests +220, Docs +24. Total +379 across 18 files. Added test files: 1. 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, 5:01 AM ET / 09:01 UTC. |
|
Merged reviewed head
The worker E2E shard passed on the merged head, including |
…penclaw#172945) * feat(diagnostics): attribute Code Mode GC storms to reasons and runs * fix(diagnostics): keep storm logging within the existing wrapper closure * test(diagnostics): explain GC storm fixture isolation * fix(diagnostics): count GC storm memory-port messages * test(qa): include run errors in skill-library failures
What Problem This Solves
Code Mode GC storms can occur with a small live heap, but the GC histogram omits Node's callback flags and cannot correlate a busy slot with its current run.
User Impact
Operators gain bounded GC reasons per thread/slot and a rate-limited warning identifying the active worker/cell and isolate memory counters, supplying evidence for a later causal fix.
Why This Change Was Made
The native GC observer carries a fixed
reasonlabel:none, six named Node flags, orotherfor combinations/unknown values. SDK diagnostic ingress bounds it once.openclaw_gc_duration_secondsretains thread/slot attribution, including its_countseries. These are Node callback flags, not V8's complete internal collection cause.The existing Code Mode observer emits a snapshot after a window of at least 10 seconds exceeds 600 major collections/minute, at most once per worker/minute. It uses the existing memory port, including while parked or warm; the main-thread registry supplies the authoritative reusable slot. Warnings carry generated Code Mode run ID, session-key hash, cell counts, bounded bridge methods, heap/external/arrayBuffers counters, and V8 heap limit. Completed cells clear run attribution; parked cells retain it. Attribution describes the cell at callback delivery, not necessarily the cause of every collection in the window.
No guest source, arguments, results, or raw session keys are logged. No configuration, schema, retention, execution-policy, or near-limit fatal-guard change. This explicitly requested observability requires +136 production lines (166 added, 30 removed) for the telemetry contract, warning window, and correlation plumbing. It adds no competing GC or worker owner.
Evidence
Before: no reason dimension or per-run storm warning. After: deterministic VM-cell/memory-port proof warns for 101 majors/10 seconds, suppresses another warning within the minute, clears completed attribution, and ignores incremental-only collections and exactly 600 majors/minute. No speedup or memory reduction is claimed; no production benchmark or deployment was performed. The real storm reason and representative guest workload remain unknown.
Focused tests passed: GC observer/transport 6 tests; Prometheus event-loop 9; Code Mode lifecycle 15; new GC storm regression 1. Wrapper-source closure passed 3 tests. The transport-accounting regression fails before the fix (0 instead of 2 unknown-size messages) and passes afterward. File-scoped formatting/lint and
git diff --checkpass. No full local validation or Testbox/Crabbox leases. The first lint wrapper attempted declaration preparation and was stopped; its task-owned lock was removed after process exit.Independent subagent review (autoreview route unavailable): clean. The helper rejected the requested provider/operator-configuration mismatch; configuration was not changed. Each substantive follow-up was independently reviewed. CI/review findings fixed here: remove the extra logging dependency that broke wrapper closure; explain three closed test mocks; count storm messages on the existing memory transport.
Exact-head CI and inherited failures
Current head:
1b4afc31a09941fde11f04e5b2159d1fd5f8028c. CI run 38719828237, tested merged7c3029bab01e093d748862ab81378d1dc303bbbinto main parent129049bbc3a5dbcc6b83bbabf5703e1d847d714a.The following failures have matching baseline evidence; none is claimed fixed:
session-management.sidebar.e2e.test.ts, both personal-pin cases, expected 4 child rows to be 0 at line 13747b0a1cc734cbfc5dd7fc40548bd5c8ec6bdac87.session-management.promotion.e2e.test.ts, native-pointer nested promotion, child-row visibility timeout at line 35chat-pull-requests.e2e.test.ts:167, expected#103469, receivedopenclaw/openclaw#103469e8eef4f656d0(#172836) changed the renderer without updating this expectation. Exact earlier CI base86380bba721a2719434d701f2badfaf629fda87cand tested merge6f25763a5d10e04d3a3ebfa93ae44bf462017a49both fail identically (42.06s / 40.10s; 1 failed, 11 skipped). Entire UI diff is empty.session-row-projection.worker-read.test.ts:361, replacement shared-state bytes while agent-row preparation is pending; promise resolvesundefinedinstead of rejecting129049bbc3a5dbcc6b83bbabf5703e1d847d714aand tested merged7c3029bab01e093d748862ab81378d1dc303bbbboth fail the same case, 1 failed / 15 passed each (21.56s / 21.26s Vitest; 39.97s / 39.28s wrappers). Test and relevant projection owners have an empty diff.Paired reproductions used isolated synthetic Team sandboxes, Node 24.19.0, scoped CPUs/memory and low priority, own HOME/OPENCLAW_HOME/TMPDIR, and high loopback ports. The projection proof used eight CPUs and an 8192 MiB heap. Only failing files/cases and their required preparation ran. All sandboxes were removed and remaining process counts verified zero. No CI rerun was requested.
Earlier CI findings and remaining uncertainty
An earlier head failed Bun
runtime.retention.test.tsrecovery-bundled cjs/mjs weak-reference assertions. Exact earlier base86380bba...and PR head9598548b...passed 5/5 single-file runs each, 15/15 cases per run, on pinned Bun 1.4.3-canary.1+65d94e715 and Node 24.19.0. Its bundled recovery path executes unchanged PluginInstance/module-loader/cache code and no changed behavioral branch, satisfying the standing unrelated-flake criterion. The defect remains unidentified; current-head CI determines admission.The preceding head also failed the first local turn of
skill-library-worker-wire.e2e.test.tswithagent.waitstatuserror. Exact CI base9abed103...and merge98eab362...each passed 5/5 single-file replays (50.20–53.35s / 49.82–54.51s), and newer scheduled main passed. Those passing replays do not establish inheritance or a fix because generic changed worker transport code is on the fixture's path.The assertion now includes its synthetic marker and complete
agent.waitresponse so a recurrence exposes the previously hidden error. RPC arguments, timeouts, ordering, and requiredstatus: "ok"are unchanged. That diagnostic improvement passed once on the exact earlier merge plus patch using CI's Node version, eight CPUs, and 8192 MiB heap: 1/1 passed, 69.18s. It is not presented as a causal repair. No test expectations, retries, or timeouts were weakened.Final CI: all planned jobs completed on the current head. The only failing test jobs are the four attributed entries above; the aggregate gate reports those failures. The worker E2E job passed, including
skill-library-worker-wire.e2e.test.ts(1/1, 99.95s), so the earlier unexplained error did not recur. Its diagnostic change is not claimed to have fixed the underlying failure. Current-head security checks and independent review are clean. Landing uses the operator-authorized inherited-failure exception; CI is not described as green. A PR-context check caught changed template headings during the evidence rewrite; the required headings are restored without a code change or CI rerun.