Repository navigation
fix(diagnostics): allow captures on the supported Bun runtime - #166933
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: needs maintainer review before merge. Reviewed October 8, 2026, 6:23 AM ET / 10:23 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch enables CPU profiles, allocation profiles, and heap snapshots on OpenClaw’s Bun runtime while refusing environment-started debugger conflicts. Example: An administrator requests diagnostics.cpuProfile on a Bun Gateway.
Review scores
ProductKind: Feature · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains useful and has no actionable patch findings. The merged shared Bun update resolves the previous review’s runtime prerequisite; recorded native qualification supports the change, with ordinary exact-head CI still pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway diagnostics let administrators inspect JavaScript CPU use and memory retention. A shared capture owner checks conflicts and request lifetimes, runs the native profiler, and returns sanitized profiles or metadata for private snapshot files. flowchart TD
A[Administrator diagnostic request] --> B[Gateway authorization]
B --> C[Shared capture owner]
C --> D[Debugger and lifetime checks]
D --> E[Node or Bun native capture]
E --> F[Native cleanup and validation]
F --> G[Sanitized profile or private snapshot metadata]
Technical reviewBest possible solution: Use the existing shared capture owner with the qualified bundled Bun runtime, preserving its privacy and lifecycle contracts. Do we have a high-confidence way to reproduce the issue? Not applicable as an existing-behavior regression: Bun rejection was an explicit restriction, confirmed in current-main source. Is this the best way to solve the issue? Yes, extending the existing capture owner is the narrowest maintainable solution, and the required native runtime repairs are now selected by the merged shared pin. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bcd0d15a431d. Provenance checked
TestingProof path: in-process harness. Added test files: 4. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +36, Docs +7. Total +44 across 9 files. View PR surface stats
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 HistoryReview history (1 earlier review cycle)
|
Use the native profiling owner on Node and Bun while preserving admission, redaction, bounds, and cleanup. Exercise CPU, heap, and snapshot captures on the selected runtime, retain a genuine Node oracle for V8 tracking, and reject Bun environment-started debugger conflicts. The consumer cutover depends on the shared Bun pin including openclaw/bun#140 and openclaw/bun#141. Node 24 and the combined fixed Bun pass all 112 targeted cases; the previous pin still fails the integral heap-profile contract.
35c3043 to
3a46a8b
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…aw#166933) Enable CPU profiles, allocation profiles, and heap snapshots through the existing diagnostics owner on the supported Bun runtime. Preserve debugger/tracing conflicts, authorization, cancellation, redaction, limits, and native cleanup; use the current runtime in native tests and genuine Node for the V8 object-ID regression. The shared 42bd pin includes integral heap sampling and snapshot metadata cleanup. Linux and macOS each passed 112/112 diagnostics tests on Node 24 and pinned Bun, with zero skips. P2 review and exact-head ClawSweeper found no actionable issues; CI run 37762723772 passed. The unrelated local full-tree unused-export failure from openclaw#167089 was reproduced on clean main and retained in PR evidence.
What Problem This Solves
Fixes CPU profiles, allocation profiles, and heap snapshots being rejected when the Gateway runs on OpenClaw's supported Bun runtime.
User Impact
Administrators can capture diagnostics on Node and the bundled Bun runtime with the existing authorization, cancellation, size limits, redaction, and cleanup behavior. Captures open no debugger listener. Bun heap-space readings describe its aggregate JavaScriptCore heap rather than separate V8 regions.
The shared runtime dependency is now satisfied: #167092 pins
42bd1d282ad16189ff71789ddbf81fa89dcd9d3a, including integral allocation accounting and snapshot metadata cleanup.Why This Change Was Made
The shared diagnostics owner rejected Bun by runtime identity after the fork implemented the required native APIs. It now uses its existing capability and capture checks, with additional conflict detection for Bun's environment-started debugger, which can be absent from
inspector.url().Native CPU, allocation, and snapshot tests explicitly launch their current runtime and assert its identity. The V8 object-ID cleanup regression explicitly selects genuine Node, even when the suite runs under Bun. The fork's separate native regression proves JavaScriptCore snapshot metadata cleanup. The existing Windows CPU-smoke exclusion and the distinction between opt-in capture and lightweight memory heartbeats remain intact.
Evidence
Rebased without conflicts onto the shared-pin merge
4c099357f6f35c3cc0ecff8015c14141ff910f9b; range-diff confirms the diagnostics patch is unchanged. Qualified head:3a46a8b73d581077eb62a98bd7801c65a2facffd.Linux x64 (Node 24.19.0) and macOS arm64 (Node 24.21.0) each pass 112/112 on Node and 112/112 on pinned Bun 42bd, zero skips. Both Bun binaries were staged through the maintained pin-verification script. Each complete file ran once per runtime with isolated home/state/temp directories; no reruns, changed assertions, or raised limits.
src/logging/diagnostic-cpu-profile.test.tssrc/logging/diagnostic-heap-profile.test.tssrc/gateway/server-methods/diagnostics.heap-snapshot.test.tssrc/logging/diagnostic-memory.test.tssrc/gateway/server-methods/diagnostics.cpu-profile.test.tsMeasured with the maintained Vitest wrapper and
--maxWorkers=1, matching the original comparison. Native captures validate real output, runtime identity, attribution, private snapshot permissions, size limits, and listener-free cleanup; mocked writes cannot establish those contracts.P2 AutoReview is scoped-clean. The previous pinned runtime produced 111 passes and one real heap-profile failure from fractional allocation sizes; that dependency evidence remains in the earlier qualification. The selected 42bd runtime contains both required native repairs.
Static validation: all selected typechecks, formatting, changed-file lint, repository guardrails, and both runtime/Madge import-cycle checks pass. The original changed-check run remains failed at the full-tree unused-export scan. The identical five-symbol failure reproduces on clean main
245b7f6fb2ad8974a5c481359635f9fa50070caf:LocalRemoteShellSpawnResultinsrc/agents/sandbox/remote-fs-bridge.test-helpers.ts, andTURN_MODEL_PERSISTED_CHANNEL_REF,TURN_MODEL_PERSISTED_PEER_REF,TURN_MODEL_SESSION_REF, andTurnModelSelectionPathinsrc/test-utils/turn-model-selection-differential.ts. Merged #167089 removed their last external users; neither defining helper is changed by this PR. All checks that followed the failed scan were executed separately and passed. No failure was rerun to green or suppressed.Exact-head CI run 37762723772 passed on the exact reviewed head: 47 successful jobs, 25 intentional skips, and a green aggregate gate. Emitted CI wrapper costs: CPU-profile file 78.45s, heap-profile file 8.52s, Bun memory file 12.58s, and the shared Gateway-methods group 11.39s. The last number includes sibling files and is not a per-file snapshot/RPC timing.
Release-note context: diagnostics captures now support the bundled Bun runtime, with existing privacy and lifecycle limits retained. Known debugger, profiler, coverage, and tracing conflicts remain visible refusals.