Skip to content

fix(diagnostics): preserve OTEL startup failure during rollback - #119747

Merged
vincentkoc merged 1 commit into
mainfrom
fix/otel-startup-rollback-preserve-20260805
Aug 5, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/otel-startup-rollback-preserve-20260805

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Fixes #119746

Related context:

What Problem This Solves

Fixes an issue where operators starting diagnostics OTEL could receive only a rollback cleanup failure when the OpenTelemetry SDK had already failed to start. The secondary shutdown error masked the failure that actually prevented telemetry startup.

Why This Change Was Made

The SDK startup owner now keeps the original startup error primary and preserves an owned rollback cleanup failure alongside it in an AggregateError, with the startup error retained as the cause. The diagnostics owner also logs the formatted rollback cleanup failure before rethrowing, so the host-visible service error retains both actionable failures. Cleanup still drains through the existing lifecycle order.

This follow-up does not change ordinary service-stop behavior, signal-specific protocol routing, gateway recovery, configuration, or exporter ownership. It preserves the protocol behavior landed in #119708.

Root cause: the SDK startup catch awaited the shared lifecycle cleanup before rethrowing the captured startup error. Because diagnostics-owned exporter cleanup may reject, that rejection could escape first and replace the already-captured startup failure. The initial aggregate preserved both errors structurally, but its static message left the nested cleanup detail invisible through the host logger, which records error.message.

Production LOC: +16/-1.
Test LOC: +67/-0.

User Impact

Operators now retain the primary reason telemetry startup failed and receive the rollback cleanup failure needed to diagnose incomplete exporter shutdown.

Evidence

  • Focused diagnostics lifecycle and plugin-service tests: 173/173 passed across two Vitest shards.
  • Added regression proof that SDK startup failure remains the cause and first aggregate error when rollback shutdown also fails.
  • Added proof that rollback cleanup detail is logged at the diagnostics owner and remains visible beside the host startup failure.
  • Added proof that the failed-start service is fully drained and a later stop resolves.
  • oxfmt --check: clean on all three changed files.
  • Targeted oxlint: clean on all three changed files.
  • git diff --check: clean.
  • Fresh P0-P2 autoreview: no findings; patch correct at 0.93 confidence.
  • Direct dependency contract proof: installed @opentelemetry/[email protected] types declare start(): void and shutdown(): Promise<void>; its build/src/sdk.js shutdown implementation returns Promise.all(...), confirming that provider cleanup rejection is an upstream-supported outcome.
  • Exact-head hosted CI: passed at 6de8714e29e6a94806f28e81391b6eeb28f61366 in https://github.com/openclaw/openclaw/actions/runs/31053078525.
  • Exact-head ClawSweeper: no code findings at 6de8714e29e6a94806f28e81391b6eeb28f61366 in fix(diagnostics): preserve OTEL startup failure during rollback #119747 (comment).
  • ClawSweeper dispositions: dependency proof completed; exact-head CI completed; latest rank-up moves confirmed against the current head.

Local note: the full repo oxlint wrapper was blocked before target linting by an unrelated current-main plugin-SDK boundary diagnostic in packages/terminal-core/src/ansi.ts:194 (TS2554). The changed files pass isolated oxlint, and hosted CI remains the full-repo gate.

@vincentkoc vincentkoc self-assigned this Aug 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added extensions: diagnostics-otel Extension: diagnostics-otel size: XS maintainer Maintainer-authored PR labels Aug 5, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head a0027e010ad01f683ccf2c13577a54325833f4b3.

This is the bounded follow-up regression repair for #119705 and #119694, rebased onto #119708.

The fix preserves the primary NodeSDK startup failure when diagnostics-owned rollback cleanup also fails. Ordinary service-stop behavior, cleanup ordering, signal-specific protocol routing, gateway recovery, and configuration remain unchanged.

Proof on this exact head:

  • Diagnostics lifecycle tests: 153/153 passed.
  • Lifecycle plus plugin-service tests: 172/172 passed.
  • oxfmt --check, targeted oxlint, and git diff --check: clean.
  • Fresh P0-P2 autoreview: no findings; patch correct at 0.95 confidence.
  • Production LOC +13/-1; tests +25/-0.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@vincentkoc
vincentkoc marked this pull request as ready for review August 5, 2026 21:50
@vincentkoc
vincentkoc force-pushed the fix/otel-startup-rollback-preserve-20260805 branch from a0027e0 to 7c7f728 Compare August 5, 2026 21:56
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 7c7f7286e1c4bcae18497f60b58d99312cab37d0.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@vincentkoc
vincentkoc force-pushed the fix/otel-startup-rollback-preserve-20260805 branch from 7c7f728 to 6de8714 Compare August 5, 2026 22:31
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head: 6de8714e29e6a94806f28e81391b6eeb28f61366.

Disposition of the prior exact-head rank-up move: applied. Diagnostics OTEL now logs the formatted rollback cleanup failure at its owner before preserving both startup and cleanup failures in the aggregate, and the plugin-service regression proves that detail remains host-visible without broadening generic service or gateway behavior.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 6:37 PM ET / 22:37 UTC.

ClawSweeper review

What this changes

The PR retains the primary OpenTelemetry SDK startup error during rollback, logs any rollback cleanup failure at the diagnostics owner, and adds focused regression tests.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still lets a rollback shutdown rejection replace the original OTEL SDK startup failure; this focused owner-boundary repair preserves both failures, with no blocking code finding found.

Priority: P2
Reviewed head: 6de8714e29e6a94806f28e81391b6eeb28f61366

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful regression coverage and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored diagnostics repair is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused regression evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored diagnostics repair is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused regression evidence.
Evidence reviewed 6 items Current-main failure path: Current main awaits rollback cleanup before logging and rethrowing the captured SDK startup error, so a rejected cleanup can escape instead.
Owner-boundary repair: The PR logs the primary failure, attempts existing cleanup, logs any cleanup failure, and throws an aggregate with the startup failure as cause and first error.
Host logging contract: The generic plugin-service host records only error.message on failed starts, making the diagnostics-owner cleanup log necessary to expose nested rollback detail without broadening generic policy.
Findings None None.
Security None None.

How this fits together

The diagnostics OpenTelemetry plugin starts and cleans up telemetry SDK resources for the plugin-service host. Startup failures flow to the host logger, so rollback must not hide the error that stopped telemetry from starting.

flowchart LR
  A[Plugin service startup] --> B[Diagnostics OTEL plugin]
  B --> C[OpenTelemetry SDK start]
  C --> D{Startup succeeds?}
  D -->|Yes| E[Active telemetry service]
  D -->|No| F[Rollback cleanup]
  F --> G[Preserved startup and cleanup errors]
  G --> H[Plugin-service host logs]
Loading

Before merge

  • Resolve merge risk (P1) - The checkout lacks installed OpenTelemetry source/types and network access prevented upstream inspection; the patch preserves failures from an existing cleanup path rather than changing SDK calls, but direct dependency-contract proof remains incomplete.
  • Complete next step (P2) - No mechanical repair remains; retain this maintainer-owned PR for normal exact-head CI and final review.
Agent review details

Security

None.

PR surface

Source +15, Tests +67. Total +82 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 1 +15
Tests 2 67 0 +67
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 83 1 +82

Review metrics

Metric Value Why it matters
Production versus test LOC production +16/-1 (net +15); tests +67/-0 The small production increase is justified by preserving the lifecycle error contract and making rollback diagnostics visible at their owner.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the diagnostics-local aggregate-and-log repair, then merge after exact-head CI and the latest ClawSweeper rank-up moves are confirmed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the diagnostics-local aggregate-and-log repair, then merge after exact-head CI and the latest ClawSweeper rank-up moves are confirmed.

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

Yes—current main’s SDK-start catch awaits cleanup before rethrowing the captured error, and a rejecting cleanup path is explicitly rethrown by the lifecycle owner.

Is this the best way to solve the issue?

Yes—the diagnostics plugin owns both startup and rollback state; changing the generic plugin host would broaden behavior for unrelated services while losing the typed primary-error relationship.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded operator-observability failure during diagnostics startup, with no evidence of broader runtime outage or data loss.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored diagnostics repair is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused regression evidence.

Label justifications:

  • P2: This is a bounded operator-observability failure during diagnostics startup, with no evidence of broader runtime outage or data loss.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored diagnostics repair is not subject to the external-contributor real-behavior-proof gate; the PR supplies focused regression evidence.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the merged diagnostics lifecycle and protocol repairs that establish the current service shape and this follow-up owner-local fix. (role: recent diagnostics lifecycle contributor; confidence: high; commits: 880dde979b5e, 92b4757227a7; files: extensions/diagnostics-otel/src/service.ts, extensions/diagnostics-otel/src/service.test.ts)
  • Peter Steinberger: Recent history includes core plugin-service work adjacent to the host error-reporting path. (role: adjacent plugin-services contributor; confidence: medium; commits: 6edf4a2b7ed0; files: src/plugins/services.ts, src/plugins/services.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let required exact-head CI complete before merge.
  • Confirm the latest ClawSweeper rank-up moves apply to the current head before merge.

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.

@vincentkoc

Copy link
Copy Markdown
Member Author

ClawSweeper disposition for exact head 6de8714e29e6a94806f28e81391b6eeb28f61366:

No code or head change was made after the exact-head review.

@vincentkoc
vincentkoc merged commit 397a605 into main Aug 5, 2026
133 of 135 checks passed
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

@vincentkoc
vincentkoc deleted the fix/otel-startup-rollback-preserve-20260805 branch August 5, 2026 22:41
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 5, 2026
…cope

* origin/main:
  perf(agents): isolate concurrency benchmark workers (openclaw#119749)
  fix(diagnostics): preserve OTEL startup failure (openclaw#119747)
  fix(agents): seed fresh session identity before transcript append (openclaw#119473)
  fix: steering reaches active runs across agent harnesses (openclaw#119594)
  fix(cli): report accurate filtered node totals (openclaw#119744)
  fix(skills): keep installed verdicts scoped to publisher (openclaw#119672)
  fix(diagnostics): honor signal-specific OTLP protocols (openclaw#119708)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: diagnostics-otel Extension: diagnostics-otel maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: diagnostics-otel rollback failure masks SDK startup error

1 participant