Skip to content

feat(diagnostics): trace completed harness commentary - #156343

Merged
vincentkoc merged 5 commits into
mainfrom
feat/diagnostics-harness-commentary-20260923
Sep 23, 2026
Merged

vincentkoc merged 5 commits into
mainfrom
feat/diagnostics-harness-commentary-20260923

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Related: #156330

What Problem This Solves

Operators cannot correlate completed assistant commentary with the harness activity in a diagnostic trace.

User Impact

Supported harnesses emit agent.commentary diagnostics and openclaw.agent.commentary events on their harness spans. Existing debug logging records completion metadata. The existing diagnostics.otel.captureContent setting controls trace text; no configuration fields, defaults, or storage formats are added.

Content remains off by default. When enabled, visible commentary is capped at 16,384 characters before queueing and passes through the existing exporter redaction. Ordinary logs and public diagnostic events receive metadata only.

Why This Change Was Made

Subscribe at the harness attempt lifecycle after core event ownership checks. Capture the harness trace before asynchronous transport callbacks, suppress recent duplicate completions, and unsubscribe on every exit. Claude CLI registers after preparation publishes its effective config and execution owner.

Commentary shares the diagnostic FIFO with harness completion, so it reaches the existing span before that span ends. It remains best-effort telemetry; queue pressure and normal SDK event limits apply.

Evidence

  • Final reviewed head: aee0a1d970544b09a30be764b036744df2ce4716, rebased on 9bb3ccca699058b17196d803f14c6da1f8ae5d29. Independent review confirmed the earlier CLI conflict adaptation preserves operator-model admission, revocation, cleanup, and diagnostic subscription ownership. All five commits are patch-identical across this second refresh, including the test-only fixture correction.
  • The reviewed feature tree at 7a38f1c11d76d476393723356363e49f823f9f0e and frozen dependency inputs were verified on Testbox. All 61 tests passed across five files: harness lifecycle, CLI diagnostics, CLI operator-model execution, diagnostic stability, and real OpenTelemetry SDK commentary events. The four Vitest shards completed in 86.54 seconds.
  • Four new producer cases failed on the original source because no commentary event was recorded, then passed with the feature. Coverage includes default-off private content, bounded opt-in text, real SDK redaction, completed-only capture, duplicate suppression, unrelated runs, callbacks outside the original async scope, resolved CLI ownership/config, error cleanup, and commentary immediately before span completion.
  • Core and plugin typechecks, targeted lint, formatting, and whitespace checks passed during feature qualification. The rebased candidate additionally passed core typecheck, targeted CLI lint, and the line-cap ratchet. No cap or baseline was relaxed.
  • The stability switch explicitly excludes commentary content. Shared event fields and pure snapshot-query parsing live in sibling modules; existing diagnostic exports, query defaults, retention, and privacy behavior remain unchanged.
  • Codex protocol inspected directly at 414782450952a196bbb64b1605a458c2531c47b6: MessagePhase, AgentMessage, and phase-free deltas.
  • CI also exposed an inherited test-fixture wiring error on the frozen base: the scroll-ownership fixture omitted the controller’s scroll-pane identity argument. A one-line test-only correction supplies the fixture’s existing key and preserves every assertion. The existing ownership file passed all 123 tests (13.18 seconds through the repository wrapper), and test/tsconfig/tsconfig.core.test.ui-chat.json passed on Node 24.19.0 with frozen dependencies. The fixture, controller, all direct test-helper inputs, and relevant configs are identical in both commentary PRs; fresh CI still qualifies each final head independently.
  • The second refresh incorporates main’s gateway fixture settlement revert, which names the inherited revoked-reader failures observed in CI. On the exact final candidate tree with unchanged dependencies, all 177 tests across server.sessions.permission-root, server.sessions.create, and server.sessions.permissions-hooks passed in 214.09 seconds.
  • Gateway follow-up: an earlier visible-yield CI case lost yield metadata despite a lifecycle event carrying yielded: true and aborted: true. The unmodified reset → complete file passed both cases on the frozen new base (65.30 seconds) and final candidate (44.70 seconds), with the same runtime and dependencies. The earlier trigger remains unproven; no yield production change or test weakening is included here.
  • Delta against the new base, excluding upstream changes: production +169 lines for lifecycle-owned commentary telemetry and exporter handling; tests +231; docs +15.

Fresh exact-head CI and ClawSweeper review remain the merge gates.

@vincentkoc vincentkoc self-assigned this Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel agents Agent runtime and tooling size: M labels Sep 23, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 23, 2026 08:44
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper automerge is enabled.

  • Head: aee0a1d97054
  • Label: clawsweeper:automerge (pause labels cleared)
  • Action: exact-head review queued (workflow sweep.yml, event repository_dispatch).
  • Flow: review this head, repair/rebase only if needed, then re-review the exact repaired head before merge.

Draft PRs stay fix-only until GitHub marks them ready for review. Pause with /clawsweeper stop.

Automerge progress:

  • 2026-09-23 09:33:01 UTC review queued d5f7d1251967 (queued)
  • 2026-09-23 10:08:46 UTC review queued d5f7d1251967 (queued)
  • 2026-09-23 09:54:05 UTC review passed d5f7d1251967 (structured ClawSweeper verdict: pass (sha=d5f7d1251967f7446f060999bf62b452f49...)
  • 2026-09-23 11:24:35 UTC review queued aee0a1d97054 (queued)

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 8:32 AM ET / 12:32 UTC (Revision 4).

ClawSweeper review

What this changes

Adds completed assistant commentary to diagnostic harness traces with optional bounded, redacted text, updates documentation and tests, and corrects a UI test fixture.

Merge readiness

✅ Ready for maintainer review

The PR remains useful, and no actionable correctness or security defect was found. The previous pause was explicitly resolved; the subsequent handoff does not reopen that decision.

Priority: P3
Reviewed head: aee0a1d970544b09a30be764b036744df2ce4716

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful boundary coverage and no supported blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored PR is exempt from external-contributor proof. Reported Testbox validation and inspected producer/real-SDK tests cover collection, cleanup, redaction, and span ordering; they are not described as a live harness-to-collector run. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from external-contributor proof. Reported Testbox validation and inspected producer/real-SDK tests cover collection, cleanup, redaction, and span ordering; they are not described as a live harness-to-collector run. No stored-data contract changes.
Evidence reviewed 11 items Pinned introduction and merge ownership: Reviewed the merge-base-to-head diff. The test merge's raw parents exactly match the pinned base followed by the reviewed head; its UI fixture has no net difference from that base. Base-only workflow and Gateway changes are not attributed to this PR.
Bounded collection and private content: The observer accepts completed preambles for one run, retains at most 256 duplicate hashes, bounds captured text to 16,384 UTF-16 units, and uses the existing content policy. Text enters private diagnostic data; debug logging contains metadata only.
Exporter ordering and privacy coverage: The recorder rejects untrusted events, resolves the existing tracked span, applies established content normalization and redaction, and adds the event with its source timestamp. The real-SDK test covers capture off/on, secret redaction, untrusted input, immediate completion, and post-completion events. These are inspected tests, not reviewer-executed live proof.
Findings None None.
Security None None.

How this fits together

Agent harnesses emit progress events while running a turn. Diagnostics observes completed commentary and attaches metadata or explicitly enabled text to the existing OpenTelemetry harness span.

flowchart LR
  A[Harness progress events] --> B[Existing run ownership checks]
  B --> C[Completed commentary filter]
  C --> D[Duplicate suppression and content policy]
  D --> E[Diagnostic event queue]
  E --> F[Redaction and harness span]
  D --> G[Metadata-only debug log]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +169, Tests +231, Docs +15. Total +415 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 10 258 89 +169
Tests 4 234 3 +231
Docs 2 15 0 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 507 92 +415

Review metrics

Metric Value Why it matters
Configuration surface 0 new settings; 1 diagnostic event kind The feature reuses the documented additive event contract and existing content-capture control.
Production versus test growth Production net +169 lines; tests net +231 lines Production growth supports lifecycle-owned collection and export; tests cover privacy, ordering, and cleanup.

Root-cause cluster

Relationship: partial_overlap
Canonical: #156330
Summary: The parent request combines diagnostic traces and Control UI presentation; this PR implements the diagnostic portion.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep commentary telemetry lifecycle-owned, best-effort, and governed by the existing opt-in content policy.

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

Not applicable as a bug reproduction: this adds a diagnostic capability, and source inspection confirms the recorder is absent from fetched main.

Is this the best way to solve the issue?

Yes. Observing normalized completed events at the existing lifecycle owner avoids harness-specific duplication and preserves the established exporter privacy controls.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P3: This improves optional operator diagnostics without changing normal agent execution or message delivery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Pinned introduction and merge ownership: Reviewed the merge-base-to-head diff. The test merge's raw parents exactly match the pinned base followed by the reviewed head; its UI fixture has no net difference from that base. Base-only workflow and Gateway changes are not attributed to this PR. (aee0a1d97054)
  • Bounded collection and private content: The observer accepts completed preambles for one run, retains at most 256 duplicate hashes, bounds captured text to 16,384 UTF-16 units, and uses the existing content policy. Text enters private diagnostic data; debug logging contains metadata only. (src/agents/harness/commentary-diagnostics.ts:18, aee0a1d97054)
  • Exporter ordering and privacy coverage: The recorder rejects untrusted events, resolves the existing tracked span, applies established content normalization and redaction, and adds the event with its source timestamp. The real-SDK test covers capture off/on, secret redaction, untrusted input, immediate completion, and post-completion events. These are inspected tests, not reviewer-executed live proof. (extensions/diagnostics-otel/src/service.commentary.test.ts:17, aee0a1d97054)
  • Existing contracts preserved: Commentary and harness completion share the asynchronous diagnostic queue. Subscription cleanup runs in finally; Claude CLI subscribes after preparation supplies effective config and execution identity. Operator-model admission, current-authority checks, and release remain intact. No persisted format or configuration default changes. (src/agents/cli-runner.ts:261, aee0a1d97054)
  • Additive diagnostic contract: The existing documentation explicitly treats diagnostic event kinds as additive. This branch documents the new event, default-off content, and best-effort queue behavior without adding a parallel plugin API or content setting. Public docs: docs/gateway/opentelemetry/spans-and-events.md. (docs/gateway/opentelemetry/spans-and-events.md:79, aee0a1d97054)
  • Still necessary on fetched main: The fetched-main harness recorder has lifecycle and context recorders but lacks the commentary recorder. REST confirms this PR remains open and unmerged at the pinned head. Historical release-file inspection failed because the requested object was unavailable; no shipped-fix claim is made. (extensions/diagnostics-otel/src/service-recorders-harness.ts:15, a26bf69563b0)

Likely related people:

  • Patrick-Erichsen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-23T09:52:49.160Z sha d5f7d12 :: passed. :: none
  • reviewed 2026-09-23T10:48:03.547Z sha 7a38f1c11d76d476393723356363e49f823f9f0e :: needs changes before merge. :: none
  • reviewed 2026-09-23T11:12:00.839Z sha aee0a1d :: blocked before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper stop

Pause only this diagnostics PR at d5f7d1251967f7446f060999bf62b452f497242b for maintainer repair ownership. The repair worker is terminal failure and did not push its candidate.

Validation reached passing core and extension type checks, then the offline deadcode invocation lacked required tarballs and wrote to its dependency store. The checkout-identity guard rejected the resulting node_modules mutation. Do not repeat that unchanged cloud command or weaken the guard.

The maintainer will resolve the current merge conflict in the existing task checkout, obtain remote proof, and re-enroll this PR for exact-head review and gated squash merge. The existing diagnostics.otel.captureContent setting remains the only content-capture control; no new configuration is authorized.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
Got it. ClawSweeper will leave this item for human review.

I added clawsweeper:human-review, removed clawsweeper:automerge, and paused the automation trail until a maintainer asks again.

@clawsweeper clawsweeper Bot added clawsweeper:human-review Needs maintainer review before ClawSweeper can continue and removed clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge labels Sep 23, 2026
@vincentkoc
vincentkoc force-pushed the feat/diagnostics-harness-commentary-20260923 branch from d5f7d12 to 7a38f1c Compare September 23, 2026 10:41
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 7a38f1c11d76d476393723356363e49f823f9f0e. The PR body now records the reviewed rebase onto 94c6b207, exact-tree Testbox proof (61 tests across five files), and passing core typecheck, targeted lint, and line-cap gates. The prepared CLI context remains inside main’s operator-model admission/release flow.

No configuration was added: commentary text uses the existing diagnostics.otel.captureContent; normal logs and public events remain metadata-only. Source repair remains intentionally paused while fresh CI and this read-only review finish.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. labels Sep 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 23, 2026
@vincentkoc
vincentkoc force-pushed the feat/diagnostics-harness-commentary-20260923 branch from 514d329 to aee0a1d Compare September 23, 2026 11:04
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head aee0a1d970544b09a30be764b036744df2ce4716 and the current PR body. The final refresh incorporates main’s accepted gateway fixture revert 9bb3ccca699058b17196d803f14c6da1f8ae5d29; independent range review confirms all five PR commits remain patch-identical. All 177 tests in the three formerly failing session files passed on the exact candidate. The unmodified visible-yield reset → complete control passed both cases on the frozen base and candidate; its earlier CI trigger is recorded as a gateway follow-up, with no yield code change.

The inherited scroll fixture correction also passed all 123 ownership tests and its ui-chat test-type graph. Diagnostics still reuses diagnostics.otel.captureContent; no configuration, privacy, or production scope was added by these prerequisite changes.

This is a read-only exact-head review request. Source repair remains paused while fresh CI runs.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

Explicit maintainer decision: resume landing for exact reviewed head aee0a1d970544b09a30be764b036744df2ce4716. The bounded local repair and validation are complete, and no source worker remains active.

Both required openclaw/ci-gate entries are SUCCESS: CI https://github.com/openclaw/openclaw/actions/runs/35852393053 and the automatic Security Review aggregate https://github.com/openclaw/openclaw/actions/runs/35854040382. The latest exact-head ClawSweeper review has no actionable/security findings; this explicitly resolves its pause/resume decision. Diagnostics reuses the existing diagnostics.otel.captureContent setting; no new config is added. Continue the native guarded squash landing flow.

@clawsweeper clawsweeper Bot added clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge and removed clawsweeper:human-review Needs maintainer review before ClawSweeper can continue labels Sep 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper stop

Pause the hosted automerge/source-repair controller for an ownership handoff to the canonical scripts/pr landing workflow. The exact reviewed head remains aee0a1d970544b09a30be764b036744df2ce4716; all required checks are green, and the completed review bundle exact-review-35854391304-1 has no findings, security concerns, rank-up moves, or remaining maintainer decision.

The explicit maintainer landing decision remains in force. This pause prevents competing hosted mutations while the canonical native wrapper performs the guarded exact-head squash; it does not request another review or source repair.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
Got it. ClawSweeper will leave this item for human review.

I added clawsweeper:human-review, removed clawsweeper:automerge, and paused the automation trail until a maintainer asks again.

@clawsweeper clawsweeper Bot added clawsweeper:human-review Needs maintainer review before ClawSweeper can continue and removed clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge labels Sep 23, 2026
@vincentkoc
vincentkoc merged commit 904f9c0 into main Sep 23, 2026
215 of 216 checks passed
@vincentkoc
vincentkoc deleted the feat/diagnostics-harness-commentary-20260923 branch September 23, 2026 12:33
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 23, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
* feat(diagnostics): trace completed harness commentary

* fix(diagnostics): keep commentary event type internal

* fix(diagnostics): account for commentary in stability projection

* refactor(diagnostics): separate event fields and snapshot queries

* test(ui): provide scroll pane identity in ownership fixture
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui clawsweeper:human-review Needs maintainer review before ClawSweeper can continue docs Improvements or additions to documentation extensions: diagnostics-otel Extension: diagnostics-otel gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant