Skip to content

feat: add opt-in telemetry for Windows node tool calls - #1015

Merged
shanselman merged 10 commits into
openclaw:mainfrom
calebeden:calebeden-instrument-node-tools
Jul 21, 2026
Merged

shanselman merged 10 commits into
openclaw:mainfrom
calebeden:calebeden-instrument-node-tools

Conversation

@calebeden

@calebeden calebeden commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.

What Problem This Solves

Operators can see that a Windows node tool failed, but existing telemetry does not explain whether it was rejected by exec policy, blocked before sandbox execution, failed inside the command, timed out, was canceled, or could not deliver its response. Gateway and local MCP invocations also lack a shared end-to-end diagnostic view.

Why This Change Was Made

Adds provider-neutral, privacy-reviewed instrumentation for gateway and MCP node tool calls without changing either protocol. Typed diagnostics preserve command execution semantics while reporting stable outcomes, failure categories, authorization/run phases, sandbox application and fallback details, and response-delivery failures.

User Impact

Operators can diagnose why an agent tool failed from traces, metrics, and bounded failure-only logs. system.run telemetry distinguishes exec-policy denial, unsupported sandbox requests, MXC availability/fallback, command failure, timeout, cancellation, and transport failure without exporting command arguments, payloads, output, paths, credentials, IDs, URLs, or error messages.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

Current tested head: a61e0bc104a855463e041f4f5ad94050057d356d
Current origin/main merged normally: 653327abe5ed72806e9323e22252d9ce5563e299

Validation Result
./build.ps1 Passed, all 5 projects
Shared tests 3,107 passed, 31 skipped
Tray tests 1,862 passed
WinNode CLI tests 126 passed on parent head; CLI surface unchanged by a61e0bc1
Focused telemetry 40 Shared and 51 Tray passed
Terminal status matrix 3 passed: Success/Ok, Failure/Error, Canceled/Unset
Exporter disable/queue/generation race proofs 4 passed on parent head; exporter code unchanged by a61e0bc1
Hosted current-head CI Passed: test, setup-connect, network-recovery, revocation-recovery, win-x64, win-arm64, hygiene, advanced setup gate
./scripts/validate-mxc-e2e.ps1 without -AllowSkip Exact-head blocked during fresh gateway fixture startup, before either MXC assertion

Exact-head MXC blocker

A clean pre-run audit found zero OpenClawE2E-* distros, OpenClaw processes, or relevant listeners. The single authorized exact-head retry used fresh fixture 0ece580a and newly selected port 57765. Pinned upstream OpenClaw 2026.6.11 (e085fa1) installed successfully, but its own systemd gateway again reported gateway already running under systemd and EADDRINUSE until fixture initialization timed out.

Both required tests failed in E2ESetupFixture.InitializeAsync, so neither system.run/MXC assertion ran. Post-run cleanup proof:

HEAD=a61e0bc104a855463e041f4f5ad94050057d356d
FIXTURE=0ece580a
PORT=57765
SELF_SYSTEMD_CONFLICT=True
EADDRINUSE=True
START_GATEWAY_FAILED=True
CLEANUP_E2E_DISTROS=0
CLEANUP_OPENCLAW_PROCESSES=0
CLEANUP_PORT_LISTENERS=0

Artifacts are under TestResults/E2E/0ece580a and TestResults/MxcE2E/OpenClaw.E2ETests.Mxc.trx. Two prior parent-head attempts reproduced the same blocker with fixtures 5cab2143/port 54578 and e10fdbfe/port 64284. No further loop was attempted.

Real behavior proof

Environment: Windows x64, .NET SDK 10.0.302, official otelcol-contrib 0.156.0. The tray ran with isolated data. Collector evidence and MCP output below were captured from exact head a61e0bc1.

Verified canceled-span fix

Both OTLP/HTTP protobuf and OTLP/gRPC collector runs produced the same mapping:

Case Root/execute status Exported outcome Error category
Allowed system.run Ok success omitted/none metric tag
Exec-policy denial Error failure exec_policy_denied
Real MCP cancellation Unset canceled other

Canceled collector excerpt:

Name           : openclaw.node.tool.execute
Status code    : Unset
openclaw.node.tool.name: system.run
openclaw.node.tool.transport: mcp
openclaw.outcome: canceled
openclaw.error.category: other

Name           : openclaw.node.tool.invoke
Status code    : Unset
openclaw.node.tool.system_run.approval.pipeline: legacy
openclaw.outcome: canceled
openclaw.error.category: other

This fixes the verified review finding: canceled operations are no longer marked successful, while openclaw.outcome=canceled and error-category semantics are preserved.

Exact-head OTLP/HTTP and OTLP/gRPC proof

For each protocol, the official collector received:

  • success, failure, and canceled invoke/execute traces
  • system.run authorize/run children with explicit parentage
  • openclaw.node.tool.invocations and openclaw.node.tool.duration
  • failure/cancellation-only OpenClaw.Telemetry.NodeTool logs with static event NodeToolInvocationFailed
  • exporter probes for traces, metrics, and logs with the configured protocol

Real MCP cancellation returned HTTP 204 for notifications/cancelled and an MCP tool error containing cancelled.

Canceled failure log fields remained bounded and content-free:

openclaw.node.tool.name: system.run
openclaw.node.tool.transport: mcp
openclaw.outcome: canceled
openclaw.error.category: other
openclaw.node.tool.duration_ms: <numeric>
openclaw.node.tool.system_run.approval.pipeline: legacy

Exported data-boundary matrix

Signal Exported node-tool fields Bounds/source Explicitly excluded
Traces canonical command or unknown; transport; outcome; finite error category; approval pipeline; finite sandbox fields; exception type only Registry canonical name and finite enums/constants args, argv, command text, payload, stdout/stderr, cwd/path, env, IDs, URLs, tokens, credentials, messages
Metrics command, transport, outcome, error category Exactly four tags approval/sandbox fields, identifiers, content
Failure/cancel logs trace fields plus numeric duration_ms; static event/body Failure/cancel only; nonblocking queue capped at 256; exporter generation stamped formatted messages, scopes, exception objects/messages, arbitrary local logs, success logs
Resource metadata service name/version, process PID, SDK metadata, SDK-generated service instance ID Existing tray resource metadata gateway/device/session/request identity and endpoint URL

Exact-head collector output was scanned for both success proof strings and Start-Process, calc, ping 127.0.0.1, stdout, stderr, cwd, request.id, session, and credential. Every match count was zero.

Review results

  • Verified Codex finding fixed: canceled activities now map to ActivityStatusCode.Unset.
  • Independent privacy/security review: no high-confidence security or privacy defect.
  • Rubber-duck review: no blocking defect; tests use real listeners/protocol dispatch and deterministic concurrency seams.
  • Previous exact-head ClawSweeper review called the patch correct but recommended keeping it open pending the telemetry-boundary decision and successful gateway/MXC proof.

The prior screenshot gallery was removed because it predates the exporter-generation safeguards and approval-pipeline field.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? Yes
  • Command or tool execution surface changed? No
  • Data access scope changed? No
  • Mitigation: Export remains opt-in through the existing user-configured endpoint. Empty endpoint means no exporter. Fields are finite and allowlisted. Shared has no OpenTelemetry SDK/exporter dependency; tray exclusively owns exporter setup. Stale generations are discarded instead of crossing to a replacement endpoint.

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No
  • Migration needed? No

Residual risk and landing confidence

Implementation/privacy confidence: 96%. The cancellation-status defect is fixed and proven through both OTLP protocols on exact head, and hosted CI is green. The remaining landing decision is explicit maintainer acceptance of the telemetry contract and whether the reproducible upstream gateway fixture blocker can be accepted alongside earlier-head MXC evidence. Exact-head gateway/MXC execution is blocked, not passed.

Review Conversations

  • Every concrete bot finding addressed by this PR is fixed or documented.
  • Only the telemetry-contract decision and upstream gateway fixture blocker remain for maintainer judgment.

Add privacy-preserving gateway and MCP telemetry with typed outcomes, system.run phase diagnostics, bounded failure logs, and delivery-aware completion.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
Nest authorization and run phases under tool execution, replace the redundant sandbox span with explicit containment attributes, and report finite host-side sandbox denial reasons.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 20, 2026, 1:28 PM ET / 17:28 UTC.

Summary
The branch adds opt-in OpenTelemetry spans, metrics, and bounded failure logs for gateway and local-MCP Windows node tool calls, including typed system.run authorization, execution, sandbox, and response-delivery outcomes.

Reproducibility: not applicable. This PR proposes a new diagnostics capability rather than reporting a failing current behavior. The claimed runtime behavior can be verified with a configured collector, gateway invocation, and local MCP invocation, but no inspectable current-head artifact has been supplied.

Review metrics: 2 noteworthy metrics.

  • Patch scope: 18 files affected; 2,375 additions and 224 deletions. The feature changes shared dispatch, MCP delivery, MXC execution metadata, tray export, documentation, and focused tests, so privacy and compatibility review should cover the complete data path.
  • Focused test coverage: 4 test files changed; 1 telemetry test file added. The patch adds coverage for bridge completion, command dispatch, MXC metadata, telemetry constants, and endpoint log/export behavior.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Attach redacted current-head collector or terminal output for a gateway system.run denial and a successful invocation.
  • [P1] Add separate live local-MCP invocation evidence showing delivery-aware completion.
  • Obtain maintainer approval for the documented telemetry attribute and log contract.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR describes successful live collector and MXC testing but provides no inspectable redacted artifact, and its declared tested commit is 37b84d86 rather than current head 86fa840d; attach current-head gateway and local-MCP collector or terminal output with private endpoints, IPs, tokens, and credentials redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging introduces a new operational-data export stream for node-tool calls; even with finite allowlisted attributes, maintainers need to explicitly accept the privacy and retention contract for gateway and local-MCP invocations.
  • [P1] The only claimed collector observation is not attached and was recorded against 37b84d86, not the current head 86fa840d; review cannot independently confirm the emitted span hierarchy, attributes, or redaction boundary.

Maintainer options:

  1. Confirm privacy contract and attach live proof (recommended)
    Before merge, approve the finite node-tool export schema and add redacted current-head collector or terminal evidence for both gateway and local-MCP paths.
  2. Land a narrower telemetry schema
    If any exported execution or sandbox fields are not acceptable for the endpoint contract, remove them and update the focused tests and telemetry documentation before merge.

Next step before merge

  • [P1] The remaining blockers are contributor-supplied current-head behavior proof and a maintainer decision on the telemetry privacy boundary, not a narrow mechanical repair.

Maintainer decision needed

  • Question: Should this repository adopt the proposed node-tool telemetry contract—covering gateway and local-MCP invocations, finite failure categories, sandbox metadata, and failure-only logs—for export to a user-configured OTLP endpoint?
  • Rationale: This is a product and privacy-boundary choice, not a mechanical correctness question: the implementation creates a durable operational-data contract that operators and downstream collectors may rely on.
  • Likely owner: shanselman — The available repository history points to this person as the closest adjacent owner for tray diagnostics and the Windows node execution surface.
  • Options:
    • Approve the narrow contract after proof (recommended): Keep the documented finite allowlist and require redacted current-head collector evidence for gateway and local-MCP behavior before merge.
    • Narrow the exported contract: Reduce or remove selected execution, sandbox, or failure fields before accepting the feature if their operational value does not justify the privacy surface.
    • Defer node-tool export: Pause this feature until the repository has a broader maintainer-approved telemetry schema for node execution diagnostics.

Security
Cleared: No concrete secret-handling, dependency, supply-chain, permission, or code-execution regression is evident in the diff; the remaining security concern is maintainer acceptance and runtime proof of the new telemetry data boundary.

Review details

Best possible solution:

Keep the exported fields narrowly allowlisted, obtain maintainer approval for the gateway-and-MCP telemetry privacy contract, and attach redacted current-head collector or terminal proof covering both successful and denied system.run paths.

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

Not applicable: this PR proposes a new diagnostics capability rather than reporting a failing current behavior. The claimed runtime behavior can be verified with a configured collector, gateway invocation, and local MCP invocation, but no inspectable current-head artifact has been supplied.

Is this the best way to solve the issue?

Unclear: the finite, typed telemetry design is a maintainable direction, but its exported gateway-and-MCP privacy contract requires maintainer approval and real current-head collector evidence before it is the best accepted solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bd6c4bf8e575.

Label changes

Label justifications:

  • P2: This is a substantial but non-urgent operational-diagnostics feature that needs normal maintainer review.
  • merge-risk: 🚨 security-boundary: The PR creates a new opt-in OTLP export path for node-tool operational data, requiring explicit approval of the allowlisted privacy boundary.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR describes successful live collector and MXC testing but provides no inspectable redacted artifact, and its declared tested commit is 37b84d86 rather than current head 86fa840d; attach current-head gateway and local-MCP collector or terminal output with private endpoints, IPs, tokens, and credentials redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • Telemetry contract implementation: The new node-tool telemetry types use finite outcome, error-category, transport, execution-mode, and sandbox-denial values, while the PR documentation explicitly excludes command arguments, outputs, paths, credentials, and error messages. (src/OpenClaw.Shared/Telemetry/NodeToolTelemetry.cs:1, 86fa840d6cad)
  • Existing exporter integration: The branch routes node-tool completion through the existing tray OpenTelemetry endpoint connection and its allowlisted telemetry log categories rather than adding an exporter SDK to OpenClaw.Shared. (src/OpenClaw.Tray.WinUI/Services/OpenTelemetryEndpointConnection.cs:1, 86fa840d6cad)
  • Repository telemetry policy: The repository policy requires telemetry changes to retain opt-in export, avoid sensitive user and command data, add focused tests, and provide current-head collector proof or document a blocker. The submitted tests and documentation address several requirements, but the PR body has no durable collector artifact. (docs/TELEMETRY.md:255, 86fa840d6cad)
  • Proof remains insufficient: The PR body says its live collector test ran at 37b84d86, while the current head is 86fa840d; it also explicitly states that no durable collector screenshot/link and no separate local-MCP proof were captured. The earlier ClawSweeper proof request therefore remains unresolved. (86fa840d6cad)
  • Current-main check: Current main is bd6c4bf8e575d414b5a3da750c7d6c16ea62f526; the node-tool telemetry implementation is introduced by this unmerged branch, so this PR is neither implemented nor mostly implemented on main. (src/OpenClaw.Shared/Telemetry/NodeToolTelemetry.cs:1, bd6c4bf8e575)

Likely related people:

  • shanselman: Repository history and release materials identify substantial ownership of the Windows tray, telemetry-adjacent diagnostics, and system.run execution path; the feature crosses those established surfaces. (role: likely adjacent owner; confidence: low; commits: bd6c4bf8e575; files: src/OpenClaw.Tray.WinUI/Services/OpenTelemetryEndpointConnection.cs, src/OpenClaw.Shared/Capabilities/SystemCapability.cs, docs/TELEMETRY.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-18T01:29:55.809Z sha 37b84d8 :: needs real behavior proof before merge. :: none

@calebeden calebeden changed the title improve: explain Windows node tool failures with telemetry feat: add opt-in telemetry for Windows node tool calls Jul 20, 2026
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
@calebeden
calebeden marked this pull request as ready for review July 21, 2026 00:37
calebeden and others added 4 commits July 20, 2026 17:53
Preserve the V2 direct-argv approval path while extending the existing authorize and run telemetry to approved executions and compatibility denials.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
Add a finite legacy or v2 approval-pipeline attribute to system.run traces and failure logs while keeping metrics unchanged.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 8274c0b2-0aa9-4726-bc8c-b991f5b8e125
@calebeden

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@shanselman

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 602f2cbd-ce10-434a-9485-851e676869aa
@shanselman

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@shanselman

Copy link
Copy Markdown
Collaborator

GitHub Copilot maintainer-assistant approval — automated, not written personally by Scott.

Final reviewed head: a61e0bc104a855463e041f4f5ad94050057d356d.

The maintainer review accepts the documented node-tool telemetry contract: export remains opt-in through a user-configured OTLP endpoint; exported fields are limited to canonical bounded tool names, transport, finite outcome/error/phase/sandbox values, durations/counts, and exception type names. Prompts, chat content, command argv/input/output, cwd/paths, file content, credentials/tokens, error messages, and arbitrary logs are excluded. OpenClaw.Shared remains SDK/exporter-free and the tray owns exporter setup and the explicit log-category allowlist.

Current-head proof covers OTLP/HTTP protobuf and OTLP/gRPC traces, metrics, and bounded failure logs; local MCP success, denial, and cancellation; cancellation uses neutral ActivityStatusCode.Unset; sensitive-term scan is clean; required build/Shared/Tray/focused telemetry suites and hosted CI/E2Es are green. Local MXC proof is documented as blocked before invocation by the reproducible upstream 2026.6.11 WSL gateway startup self-race, not claimed as passing on this head. Prior MXC proof and hosted setup/recovery E2Es remain supporting evidence.

Independent exact-head reviews found no blocking privacy, security, cardinality, concurrency, exporter-generation, or protocol behavior defect (93% and 97% confidence).

@shanselman
shanselman merged commit fb95382 into openclaw:main Jul 21, 2026
12 checks passed
@calebeden
calebeden deleted the calebeden-instrument-node-tools branch July 21, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants