Skip to content

feat(diagnostics): report runtime capabilities - #182379

Merged
steipete merged 4 commits into
mainfrom
fix/runtime-capability-report
Oct 24, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/runtime-capability-report

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Operators cannot tell which diagnostic capabilities their running Node/Bun process supports, and native heap snapshots fail when that runtime lacks the unrelated inspector sampling domain.

User Impact

Doctor reports runtime flavor and capabilities. The read-only diagnostics.capabilities RPC reports the serving Gateway, and support exports include separate redacted snapshots for the exporting process and the Gateway. Reports distinguish debugger breakpoints, CPU profiling, heap sampling, native snapshots, string code generation, executable-memory policy, interpreter availability, and the packaged native-module inventory.

Unknown capability states remain explicit. This does not run generated code, load optional addons, open a debugger port, or start a profile. Native-module inventory is not a claim of backend compatibility: each target, signature, libc, and selected backend still needs qualification.

Why This Change Was Made

Build metadata and the existing capture owners supply the facts; diagnostics does not infer every capability from an AOT/JIT label. Explicit captures record independent observed outcomes, keeping unsupported methods separate from temporary admission failures. Native heap snapshots no longer depend on HeapProfiler.enable, while Node retains its required inspector cleanup to release snapshot object tracking.

Evidence

  • Small probes compiled with experimental Bun at 5d8fe974f reproduce the heap-sampling prerequisite failure (-32601) and pass with native snapshots. The before/after runs took 0.599s/0.657s; compile times were 4.584s/2.741s. A bundled capability-owner probe compiled in 1.387s and ran in 0.594s with correct AOT identity and independent unknown profiling states. No full application AOT build or interpreter tripwire was used.

  • The actual snapshot owner also passed under the same experimental Bun in an isolated environment: 2,037,504-byte snapshot written and removed, capability recorded as available, exit 0 in 2.914s.

  • Owning Node tests: heap snapshots 9/9 (430.923s wall, including cold worker preparation), capabilities RPC 2/2 (249.929s), runtime facts 3/3 (42.561s), heap profiling 19/19 (304.237s). The snapshot regression failed against the original owner; the unchanged real Node test confirms V8 object IDs are released after capture.

  • Grouped Doctor, support-export and CPU-profile run: Doctor 104/104 and 54 logging tests passed. Two strict ZIP entry expectations needed the new local capability file; both corrected cases passed the focused rerun (203.833s). The grouped command took 362.106s. Together these runs cover 193 selected tests with passing evidence.

  • The existing PR-wrapper inventory regression reproduced the new module missing from extracted tooling. Adding its single source-inventory entry makes the same test pass (105.17s wall).

  • Targeted types, production/test lint, formatting and whitespace checks passed. Independent Codex review completed clean through P2. Native/backend qualification remains specific to the exact target, signature, libc, and selected backend.

  • CI on the previous head caught three CLI export expectations that still assumed only the health RPC. Their correction requires both read-only RPCs and verifies the serving Gateway capability data in the actual ZIP for all three modes. Focused types, source-backed lint, and independent Codex review pass. Local Node/Bun runners stalled before executing these cases; the final exact-head Node CI jobs pass and supply this proof.

  • Integration with the shared startup-option parser is complete: diagnostics now consumes node-runtime-env.mjs after the parser relocation. The affected capability tests pass 3/3 (123.80s wall), and the extracted-tooling import closure passes 3/3 (77.21s). Targeted types, lint, and formatting pass. The small AOT capability probe still reports the correct flavor and independent unknown snapshot state after the move (0.26s bundle, 2.04s compile, 0.81s run).

The parser-cutover review is complete and clean through P2. Final exact-head CI 40080123045 completed: 68 jobs passed, 25 were skipped, and only two UI E2E shards plus their aggregate failed. All Android and security jobs passed. The three UI failures independently match scheduled main CI 40078639310: home-attention activity publication, archive Undo visibility, and active-turn navigation to /usage. Their UI/client/protocol/QA input objects are unchanged in the actual tested merge. Landing uses the authorized native pre-existing-failure route; the red results are retained.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 24, 2026 07:42
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations labels Oct 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T09:00:50.572995Z 152cd1d New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 152cd1dfeda350967d06486cb95b53e216ccd8f5
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/methods/core-descriptors.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 24, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR adds passive runtime-capability reports to Doctor, Gateway diagnostics, and support exports while removing the heap-sampling prerequisite from native snapshots.

Example: A Bun runtime supports native snapshots but rejects HeapProfiler.enable with error -32601.

  • Before: diagnostics.heapSnapshot fails before writing a snapshot.
  • After: Native capture can complete, and diagnostics.capabilities records snapshot support independently of heap sampling.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful direction and focused owner evidence, with a verified Bun cleanup regression and diff-caused failing consumer tests.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body supplies isolated experimental-Bun capability and snapshot-owner results, supported by Node tests, rather than shipped reporting-flow evidence.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot distinguish unsupported diagnostic operations from temporary capture refusals or identify the capabilities of the serving process.
Reason: The maintainer-authored direction adds useful support information through existing diagnostics surfaces without active probes or new configuration.

Merge readiness

⛔ Needs changes before merge - 3 items remain

Keep this maintainer-authored PR open: capability reporting is useful, but Bun snapshot cleanup regresses and the added export RPC breaks three existing CLI tests.

Priority: P2
Reviewed head: 214e715132da9a21f50a4e0e057f238eb3642016

Before merge

Findings

  • [P2] Preserve Bun snapshot-metadata cleanup — src/logging/diagnostic-heap-snapshot.ts:89-94
  • [P2] Update CLI export tests for the added capability request — src/cli/gateway-cli/register.ts:180-181

Provenance

Tests

  • Missing end-to-end proof: Supplied evidence exercises isolated owners rather than the shipped Doctor, Gateway capability RPC, or support-export commands.
Agent review details

How this fits together

Runtime metadata and explicit capture outcomes feed one capability collector, whose reports reach Doctor, authenticated Gateway clients, and redacted support archives.

flowchart LR
  A[Runtime build facts] --> C[Capability collector]
  B[Explicit diagnostic captures] --> C
  C --> D[Doctor report]
  C --> E[Gateway diagnostics RPC]
  C --> F[Redacted support archive]
Loading

Technical review

Best possible solution:

Keep the shared passive collector, preserve Bun snapshot-metadata cleanup without requiring heap sampling, and update the existing CLI export tests.

Do we have a high-confidence way to reproduce the issue?

The base source requires HeapProfiler.enable before native capture, matching the author's reported -32601 reproduction; the introduced cleanup regression is established by the exact pinned Bun source, and CI directly records the CLI test failures.

Is this the best way to solve the issue?

One passive collector shared by existing consumers is appropriate, but runtime identity must not bypass snapshot cleanup that the supported Bun implementation still requires.

Full review comments:

  • [P2] Preserve Bun snapshot-metadata cleanup — src/logging/diagnostic-heap-snapshot.ts:89-94
    On the supported pinned Bun runtime, a successful native snapshot retains JavaScriptCore snapshot metadata until HeapProfiler.disable or a local Session.disconnect clears it. The new Bun branch performs neither, so a long-lived Gateway retains the snapshot map and its GC bookkeeping after capture. This cleanup contract is explicitly established by fix(diagnostics): allow captures on the supported Bun runtime #166933 and fix(inspector): release retained snapshot metadata on session cleanup bun#141, and remains present at pinned Bun ef37c31de3d3c5c59243bba51d420f9efda9d689. Remove the sampling-enable prerequisite while preserving supported-runtime cleanup, and cover metadata release under Bun as well as Node.
    Confidence: 0.99
  • [P2] Update CLI export tests for the added capability request — src/cli/gateway-cli/register.ts:180-181
    Every support export now makes an additional diagnostics.capabilities RPC, but the three export cases in src/cli/gateway-cli.coverage.test.ts:461 still use expectGatewayCall, which requires exactly one health call. Exact-head CI job https://github.com/openclaw/openclaw/actions/runs/40076253423/job/120820461321 fails all three cases with the added request shown in the assertion trace. Update these consumer tests to verify both requested snapshots and their resulting archive content.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against dd5e80de5c15.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cli/gateway-cli.coverage.test.ts --maxWorkers=1
  • pnpm test src/gateway/server-methods/diagnostics.heap-snapshot.test.ts --maxWorkers=1
  • OPENCLAW_VITEST_RUNTIME=bun pnpm test src/gateway/server-methods/diagnostics.heap-snapshot.test.ts --maxWorkers=1
  • pnpm test src/infra/runtime-capabilities.test.ts src/logging/diagnostic-heap-profile.test.ts --maxWorkers=1
  • git diff --check

What I checked:

  • Introduced Bun cleanup regression: The introduced Bun branch replaces inspector cleanup with an empty close operation; current main still disables HeapProfiler and disconnects after snapshots. (src/logging/diagnostic-heap-snapshot.ts:90, 214e715132da)
  • Pinned runtime requires explicit snapshot cleanup: The PR executes this dependency's native snapshot API. At OpenClaw's exact pinned Bun revision, Session.disconnect and HeapProfiler.disable invoke clearInspectorHeapSnapshots, whose native implementation calls HeapProfiler.clearSnapshots. The retained native regression establishes that snapshot metadata remains resolvable before cleanup. This contract was introduced in fix(inspector): release retained snapshot metadata on session cleanup bun#141. (src/js/node/inspector.ts:485, ef37c31de3d3)
  • Prior supported-Bun contract: fix(diagnostics): allow captures on the supported Bun runtime #166933 explicitly preserved native cleanup and relied on the Bun snapshot-metadata repair; removing the sampling prerequisite does not remove that cleanup obligation. (src/logging/diagnostic-heap-snapshot.ts:90, 24af679b2200)
  • Diff-caused CI failure: The exact-head failed shard reports three gateway-cli.coverage.test.ts export cases expecting one health RPC but receiving health plus diagnostics.capabilities; the aggregate CI gate fails as a consequence. (src/cli/gateway-cli.coverage.test.ts:461, 214e715132da)
  • Product direction and supplied validation: The maintainer-authored body reports an isolated experimental-Bun snapshot-owner capture producing 2,037,504 bytes, capability-owner probes, and selected Node tests; it does not claim a full application AOT build. Current-head security status recognizes maintainer authority. (214e715132da)
  • Repository policy and checkout integrity: Read the root and applicable Gateway, docs, and scripts instructions; the maintainer-notes directory is absent, and the checkout remains clean. (AGENTS.md:1, 214e715132da)

Likely related people:

  • Peter Steinberger: Raw commit 02e1ac8 adds src/logging/diagnostic-heap-snapshot.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 02e1ac8391f8; files: src/logging/diagnostic-heap-snapshot.ts)
  • Gustavo Madeira Santana: Raw commit 28818f9 adds src/logging/diagnostic-support-export.ts:86 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 28818f914074; files: src/logging/diagnostic-support-export.ts)

PR surface

Source +299, Tests +239, Docs +42, Other +1. Total +581 across 22 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 12 429 130 +299
Tests 8 242 3 +239
Docs 1 46 4 +42
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 22 718 137 +581

Labels

Label changes:

  • add P2: This is a useful operator-diagnostics improvement with a bounded native cleanup regression and a focused CI repair.
  • add merge-risk: 🚨 compatibility: The Bun branch removes an existing supported-runtime cleanup contract, leaving snapshot metadata retained after successful capture.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a useful operator-diagnostics improvement with a bounded native cleanup regression and a focused CI repair.
  • merge-risk: 🚨 compatibility: The Bun branch removes an existing supported-runtime cleanup contract, leaving snapshot metadata retained after successful capture.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 24, 2026, 4:16 AM ET / 08:16 UTC.

@steipete
steipete force-pushed the fix/runtime-capability-report branch from d1acbf3 to 152cd1d Compare October 24, 2026 08:58
@steipete
steipete merged commit dffaec4 into main Oct 24, 2026
158 of 164 checks passed
@steipete
steipete deleted the fix/runtime-capability-report branch October 24, 2026 09:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
* feat(diagnostics): report runtime capabilities

* fix(diagnostics): retain capabilities in maintainer tooling

* test(diagnostics): cover capability snapshots in CLI exports

* fix(diagnostics): use shared runtime option parser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:feature Preliminary submission classification; full source review pending. cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant