Skip to content

feat(gateway): hot reload diagnostics service settings - #138556

Merged
steipete merged 3 commits into
mainfrom
codex/hot-reload-otel
Sep 5, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/hot-reload-otel

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Changes to diagnostics.otel.* and diagnostics.enabled take effect without restarting the Gateway or every plugin. Successful exporter replacements preserve unrelated services, sessions, channels, and operator connections while adopting the configured endpoint, headers, service name, metric prefix, and enabled signals.

Why This Change Was Made

Plugin services can declare existing configuration paths through optional reload.configPrefixes metadata. The planner preserves established core, plugin, and channel policy before adding service ownership. The existing service lifecycle then replaces only the selected generations after configuration publication, using the same start/stop, lease, cron, and cleanup owners. Full plugin replacement subsumes selected service reload. If cleanup or startup fails, the existing Gateway recovery path takes over; this failure path can interrupt otherwise unrelated connections.

The Gateway owns diagnostic enablement, heartbeat, and shutdown together. Telegram webhook shutdown no longer stops the host heartbeat, and webhook diagnostics use the canonical retained-config reader at emission. Explicit standalone configurations remain scoped. Exporter cleanup uses one generation state object, and the managed reload wrapper forwards its existing owner callbacks directly.

User Impact and Compatibility

No new or removed configuration keys, changed defaults, wire protocol, or storage schema. Existing host-owned OpenTelemetry SDK providers remain host-owned. The optional plugin-service reload metadata is an additive SDK capability explicitly accepted for this work and documented with precedence and failure-recovery semantics. The shared config reader and SDK budget increment landed in #138638 and are deduplicated here.

Production LOC: +310/-196 (net +114); tests/test support +1056/-88 (net +968); docs +31/-2 (net +29). The production growth implements selected service generations, lease ownership, and recovery after consolidating duplicated lifecycle and callback plumbing.

Validation

Failed-before regressions cover service fallback suppressing established reload policy, lost managed-owner callbacks, stale diagnostic observations after re-enable, and webhook teardown or scoped configuration affecting host diagnostics. Selected-service tests preserve sibling instances and counters, fence old capabilities and callbacks, and cover cleanup/start failure plus cron ownership.

The first main integration passed 1,040 tests in 14 files, covering Gateway reload/planner/startup/close/generation, service/cron lifecycle, diagnostics, Telegram webhook, retained config, and OTLP receiver behavior. The complete changed gate passed formatting, guards, every type project, SDK boundaries, dead-code scans, typed lint, and import-cycle checks. Independent full review found only a duplicate test declaration introduced during rebase; the staged two-line removal passed a focused follow-up review. The subsequent registry-owner integration at 102452c8b93d566582b3e440987666341869a445, based on pinned main a592554b536c8d3ba6d833252718588451321b0d, passed another 393 tests in 8 files, core/core-test typechecking, merged-file formatting, and independent review. The only further conflict retained generic parameter forwarding, including main’s new Gateway registry callback. Final exact-head Linux proof and required CI 33936454662 both passed.

Final Exact-Head Linux Proof

Built and exercised 102452c8b93d566582b3e440987666341869a445 on Linux in run 33936577463. Full build and all five groups passed: initial global enablement; endpoint/header/service-name/metric-prefix replacement; metrics-only operation; exporter disable/re-enable; and global disable/resume while retaining Prometheus counters. Real loopback collectors received OTLP protobuf traces, metrics, and logs with generation-specific headers/resources. Gateway PID 9721, boot ID aeae44c1-ed06-4728-9d24-5d456a824534, and the existing operator connection survived throughout (one hello, zero closes). Joined shutdown produced no late exports for two configured intervals plus 200 ms. State and upstream traffic were synthetic, with no credentials or model/provider calls.

Command and wrapper exited 0. The verified 17,039-byte receipt archive has SHA-256 5d0246ac0fea7bff904432d2876ab4293aac24a029c6bd5c000a1befc6a5ec2b. Source and build identity both match the published head; verified tree ce746af45c1ca2c80d15a8b0ceec471f4886bb2a, transport carrier f4b6f1ff178d0fefdb007ccd517257d5c7997d92. The owned lease was stopped and native status confirmed completed. Full build took 236.5 seconds; the live phase took 39.9 seconds.

The scoped run invokes the committed helper. The aggregate hot-reload QA entrypoint also calls it; that aggregate and its startup-only gateway.controlUi.basePath positive control have static/type coverage. Externally preloaded SDK ownership and injected replacement failures are covered by focused lifecycle tests rather than this successful-transition collector run.

Review Disposition

The latest completed ClawSweeper review of 55832bac found no code or security defects. Its SDK-budget/integration rank-up is addressed by reusing the reader already on main and validating the combined owner paths. The documented recovery tradeoff is retained intentionally: failed replacement enters canonical recovery instead of leaving a partially replaced service generation active. Compatibility is unchanged apart from the accepted optional service metadata. Exact integrated CI and the final Linux proof both passed. No additional configuration, protocol, or storage changes were introduced by the main integration.

@clawsweeper

clawsweeper Bot commented Sep 4, 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 channel: telegram Channel integration: telegram gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel extensions: qa-lab plugin: file-transfer size: XL maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 19:42
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 10:07 PM ET / September 5, 2026, 02:07 UTC.

ClawSweeper review

What this changes

Adds selective background-service reload so diagnostics settings apply without restarting the Gateway, and gives the Gateway ownership of the shared diagnostic heartbeat.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open for landing: current main does not provide selective diagnostics-service reload, and no blocking introduced defect was found. The earlier precedence/scoping findings and SDK-integration rank-up are addressed; the recovery tradeoff has an explicit maintainer disposition.

Priority: P2
Reviewed head: 102452c8b93d566582b3e440987666341869a445

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Good ownership-focused implementation with strong exact-head collector evidence and the previous actionable review items addressed.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured exact-head Linux evidence maps config.patch through the real Gateway, selected service owner, and OTLP clients to five successful transition groups with unchanged process/connection identity and preserved sibling counters. The committed helper matches those observations; artifact-download limitations do not invalidate the supplied proof. Preloaded-provider and failure paths have supplemental lifecycle coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured exact-head Linux evidence maps config.patch through the real Gateway, selected service owner, and OTLP clients to five successful transition groups with unchanged process/connection identity and preserved sibling counters. The committed helper matches those observations; artifact-download limitations do not invalidate the supplied proof. Preloaded-provider and failure paths have supplemental lifecycle coverage.
Evidence reviewed 11 items Pinned introduction and merge identity: The checkout matches the original head. Raw test-merge parents are the pinned base followed by that head, and its base-relative file list matches the introduced surface; unrelated endpoint drift was excluded. Diff whitespace checks passed and the checkout remained clean.
Capability remains absent from fetched main: Fetched main has plugin/channel reload policies but no service-policy catalog or selected-service reload handle. Its unknown diagnostics paths retain restart classification, so the branch still contributes distinct behavior.
Prior planner findings addressed: Established rules precede service declarations on equal-prefix ties, narrower rules retain precedence, and inherited channel/account actions are preserved. Focused planner tests cover gateway/discovery restarts, logging no-ops, overlapping service owners, and account-scoped channel restarts.
Findings None None.
Security None None.

How this fits together

Gateway reload translates configuration changes into subsystem lifecycle actions. Diagnostic events flow through a process-owned dispatcher to plugin exporters, which send telemetry to collectors.

flowchart TD
  A[Configuration edit] --> B[Reload policy planner]
  B --> C[Commit settings]
  C --> D[Diagnostic dispatcher and heartbeat]
  C --> E[Selected service lifecycle]
  C --> G[Unrelated services stay running]
  D --> E
  E -->|Successful replacement| F[Telemetry collectors]
  E -->|Replacement failure| H[Gateway recovery]
Loading

Before merge

  • Resolve merge risk (P1) - The collector run covers successful transitions, not injected replacement failures; those failures can invoke the intentionally accepted Gateway-wide recovery and interrupt unrelated connections.
  • Resolve merge risk (P1) - Independent inspection of pinned OpenTelemetry SDK sources was unavailable; dependency confidence rests on unchanged SDK operations, existing real-SDK lifecycle coverage, and the supplied execution evidence.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

Source +114, Tests +968, Docs +29, Other 0. Total +1111 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 16 310 196 +114
Tests 15 1054 86 +968
Docs 3 31 2 +29
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 2 0
Total 35 1397 286 +1111

Review metrics

Metric Value Why it matters
Production versus validation growth Production +114 net; tests/support +968 net; docs +29 net Production growth implements selected service generations and ownership while consolidating existing cleanup and callback plumbing.
Configuration and SDK surface 2 existing diagnostics paths hot-applied; 1 optional service reload declaration; 0 new configuration keys or defaults The additive SDK capability is documented and explicitly accepted without requiring configuration migration.

Merge-risk options

Maintainer options:

  1. Retain documented recovery (recommended)
    Keep the explicitly accepted Gateway recovery path when selected-service cleanup or startup fails, acknowledging its possible connection interruption.

Technical review

Best possible solution:

Keep selective replacement inside the existing service lifecycle, preserve established reload precedence, and retain the explicitly accepted recovery policy rather than adding exporter-specific restart machinery.

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

Not applicable as a feature reproduction: current-main source lacks selected-service reload, and the supplied exact-head collector run demonstrates the new behavior. No tests or application code were executed during this read-only review.

Is this the best way to solve the issue?

Yes: extending the existing service lifecycle avoids restarting all plugins or creating a second exporter-control path, while reusing main's retained-config reader. The SDK addition and failure-recovery policy already have explicit acceptance.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded operational improvement to diagnostics configuration, not an established urgent runtime outage.
  • merge-risk: 🚨 availability: A failed diagnostics-only service replacement can escalate to Gateway recovery and interrupt otherwise unrelated connections.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured exact-head Linux evidence maps config.patch through the real Gateway, selected service owner, and OTLP clients to five successful transition groups with unchanged process/connection identity and preserved sibling counters. The committed helper matches those observations; artifact-download limitations do not invalidate the supplied proof. Preloaded-provider and failure paths have supplemental lifecycle coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head Linux evidence maps config.patch through the real Gateway, selected service owner, and OTLP clients to five successful transition groups with unchanged process/connection identity and preserved sibling counters. The committed helper matches those observations; artifact-download limitations do not invalidate the supplied proof. Preloaded-provider and failure paths have supplemental lifecycle coverage.

Evidence

What I checked:

  • Pinned introduction and merge identity: The checkout matches the original head. Raw test-merge parents are the pinned base followed by that head, and its base-relative file list matches the introduced surface; unrelated endpoint drift was excluded. Diff whitespace checks passed and the checkout remained clean. (102452c8b93d)
  • Capability remains absent from fetched main: Fetched main has plugin/channel reload policies but no service-policy catalog or selected-service reload handle. Its unknown diagnostics paths retain restart classification, so the branch still contributes distinct behavior. (src/gateway/config-reload-plan.ts:244, f9967ce8d40f)
  • Prior planner findings addressed: Established rules precede service declarations on equal-prefix ties, narrower rules retain precedence, and inherited channel/account actions are preserved. Focused planner tests cover gateway/discovery restarts, logging no-ops, overlapping service owners, and account-scoped channel restarts. (src/gateway/config-reload-plan.ts:307, 102452c8b93d)
  • Canonical service lifecycle and stale-capability fencing: Selected replacements serialize, join startup, stop only selected owners, revoke old leases, and create fresh service contexts. Shutdown prevents successor startup. services.reload.test.ts covers retained siblings, routes, health, stale emitters, shutdown races, and rejected cleanup/start; services.cron.test.ts checks queued old-owner operations reject without changing stored rows. (src/plugins/services.ts:323, 102452c8b93d)
  • Publication, service replacement, and recovery ordering: The managed wrapper forwards the owner callbacks, startup binds reload to the attached service handle, and hot reload invokes selected replacement only after configuration publication. Full plugin replacement subsumes it; failure uses the existing recovery coordinator. The PR body explicitly accepts the resulting possible connection interruption. (src/gateway/server-reload-hot.ts:523, 102452c8b93d)
  • Process-owned diagnostics and scoped Telegram reads: Gateway lifecycle now applies diagnostic enablement and always stops its heartbeat during close. Telegram reads the canonical retained configuration at emission and no longer stops that process-wide resource. Tests cover scoped, unrelated, late-bound, and runtime-owned inputs plus disable/re-enable observation retirement without resetting tool-loop or poll policy. (src/gateway/server-lifecycle.ts:624, 102452c8b93d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Robin Winkelewski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SunnyShu: 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 (4 earlier review cycles)
  • reviewed 2026-09-04T19:53:37.024Z sha 3e2b6bd :: blocked before merge. :: [P1] Preserve default reload policy before service declarations | [P2] Keep standalone webhook diagnostics disabled
  • reviewed 2026-09-04T20:51:40.171Z sha 3e2b6bd :: blocked before merge. :: [P1] Preserve default restart policy before service declarations
  • reviewed 2026-09-04T21:50:54.377Z sha e96d3ef :: blocked before merge. :: none
  • reviewed 2026-09-04T23:07:01.725Z sha 55832ba :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 4, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. and removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Sep 4, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 4, 2026
@steipete
steipete force-pushed the codex/hot-reload-otel branch from e96d3ef to 55832ba Compare September 4, 2026 22:26
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 4, 2026
@steipete
steipete force-pushed the codex/hot-reload-otel branch from 55832ba to 102452c Compare September 5, 2026 01:32
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Sep 5, 2026
@steipete
steipete merged commit 46aaa58 into main Sep 5, 2026
192 of 193 checks passed
@steipete
steipete deleted the codex/hot-reload-otel branch September 5, 2026 02:09
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation extensions: diagnostics-otel Extension: diagnostics-otel extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant