Skip to content

fix(plugins): recover channels after replacement drain timeouts - #150953

Merged
steipete merged 2 commits into
mainfrom
steipete/fix-plugin-generation-channel-strand-20260917
Sep 17, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/fix-plugin-generation-channel-strand-20260917

Conversation

@steipete

@steipete steipete commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125596, #125990

What Problem This Solves

Fixes channels remaining permanently paused after plugin replacement stops their runtime and then times out waiting for admitted work.

On 2026-09-17, a production Gateway on build 9a4468148bc logged a Discord admitted-work cleanup timeout at 07:05:30Z and Gateway generation 2: replacement not applied. Until its restart at 13:59Z, roughly seven hours later, readiness reported Discord and ClickClack failing. The health monitor retried every 30 seconds but received Channel plugins are reloading; retry the start after reload completes (42+ observed attempts). Plugin health/lifecycle calls rejected retired instances, and chat.metadata / session.discussion.info returned UNAVAILABLE with the failed replacement. No recovery completed automatically.

User Impact

A failed replacement now retries the admitted-work drain for up to 60 seconds with bounded backoff, then restores captured previous code/configuration in fresh registrations and restarts channels. Manual stops remain respected. The monitor preserves its restart budget while a reload actually holds admission paused.

If admitted work outlives that window, or resource cleanup cannot safely succeed, replacement settles as failed, releases reload pauses, and reports plugin-reload with affected plugin IDs and recovery instructions in detailed readiness. Callable channels can restart; unavailable plugins require a later openclaw plugins reload <id> after work settles, or a Gateway restart. Unrelated successful reloads and partial rollbacks preserve unresolved failure diagnostics for plugins they did not restore.

Why This Change Was Made

The existing cleanup contract requires actual write settlement before another registration acquires the same resources. A timeout is not permission to abandon an admitted write. Recovery therefore retries only drain observation (one-, two-, then four-second backoff), never service stop or resource disposal. Channel pause state distinguishes active replacement from settled failure and retains safe account snapshots when old plugin callbacks are unavailable. The Gateway generation owner retains recovery status, consumed directly by readiness before its cache. Publication alone does not clear the failure: errors in later activation hooks or channel startup remain visible even though the new generation committed.

Strict service/channel stop failures and rejected-candidate cleanup failures retain their existing resource barriers; the new drain recovery loop does not retry those side effects. No configuration, schema, dependency, or reload-triggering policy changes.

Update behavior: the installed updater still runs first and the candidate's existing Gateway restart loads this recovery behavior. Existing operator config/state remains the input; no migration, new marker, or updater-side change is required. This does not repair an already wedged old process before restart. The published-driver × exact-candidate cell below verifies that configured channels survive the update. Installed-package regressions separately cover deliberate replacement drain failures.

Evidence

  • Regression first: with current code, an admitted write held for 15 seconds left the old registry stranded; the five-second control recovered. Retained before/after output records the failure and repair.
  • Recovery regression now checks five-second and fifteen-second automatic restoration, a seventy-second held-write terminal failure, actionable readiness, a later safe reload, stale-call rejection, and exactly one completed write. The real installed-package suite also verifies deadline exhaustion, exclusive-resource ownership, fresh-code retry, and partial rollback preserving a retired plugin failure; 8/8 passed.
  • Readiness and monitor regressions failed before the fix: cached green hid recovery, and paused channels consumed restart budget.
  • Focused recovery/activation proof: 13/13 passed. Channel-manager, generation-owner, readiness, and health-monitor suites passed. The combined run had 330/334 passes; four existing transcript-startup cases hit the same capture-wait assertion (expected one capture, observed zero), with different cases affected across runs. Three failed before replacement began. Their waits/assertions remain unchanged; logs are retained for a dedicated flake investigation.
  • Fresh Codex autoreview is scoped-clean at P2. Regressions cover its two findings: post-publication activation failure and partial rollback excluding a retired plugin. Both were reproduced before their fixes.
  • node scripts/check-changed.mjs: passed, including core/test typechecking, lint, line-cap and suppression ratchets, plugin boundaries, dead exports, docs consistency, database guards, and import cycles. git diff --check: passed. The first CI run exposed an installed-package test that still assumed two five-second drains; its fake clock now advances the reported recovery deadline, with unchanged real test timeouts and preserved resource/sibling assertions. Final correction checks also passed. Exact-head CI targets 4969f33e0c844c14758dd3add84fee085ea2be88. Its first attempt passed the plugin-reload shard but hit a 60-second timeout in the unchanged Doctor refusal-receipts process test; that job passed on the prior head. One failed-job rerun was requested without changing code, timeouts, or assertions.

Published updater and configured-channel survival

The required channel-survival assertions passed in Blacksmith Testbox run 35250228316, lease tbx_01m2r52wd3r6wb43ka1pecb47d. A disposable real user-systemd service ran published [email protected] with the maintained external ClickClack HTTP/WebSocket fixture. Its normal openclaw update --tag file:<candidate-tarball> --yes --json path installed and restarted into the exact candidate.

Source binding: approved head 4969f33e0c844c14758dd3add84fee085ea2be88, verified tree 9bffbfed0c20117eaa95c51480105dd2e341272e, tarball SHA-256 65804328a95266feef821955bb66ec257f8415d5caa23edd3d7bfc4e37dadb75. Testbox carrier 7d3208bf975626cff382f748bc533899f3eb2a83 has that same tree; the updater's running-build verification matched 2026.9.4-7d3208bf9756-2026-09-17T17-07-32.332Z.

  • The published updater returned status=ok; its run finished succeeded. Native verification recorded serviceRunning=true, versionMatch=true, channelsReady=true, readyz=true, and settled=true, with the new service PID.
  • The entire configured account set was clickclack/default. Before and after update it was enabled, configured, and running, with lastError=null and no status issues. The fixture had one active WebSocket and its connection generation increased from 1 to 2, proving a new connection after replacement.
  • Candidate readiness reported ready=true, failing=[], and no suppressed or pluginReload state. Channel configuration output was unchanged, and the base unit and operator drop-in hashes matched across the update.
  • Auxiliary probe limitation: the wrapper exited 1, not 0, because an additional gateway status --deep RPC assertion reported DEVICE_IDENTITY_REQUIRED. The identical error occurred on the published baseline and candidate. Both actual gateway call channels.status calls succeeded, and the native updater independently verified the candidate's running build and readiness. The requested channel/update conditions are established by those retained artifacts; the unrelated deep-status failure is preserved. No assertion was removed, weakened, or rerun, and no transport/capacity retry was used.
  • The updater retained recoverable fixture package-convergence and loopback-hosting warnings, then finished successfully with no pending repair entries. The disposable service, account, manager override, fixture server, and Testbox lease were cleaned up.

This is synthetic-channel update proof, not a production deployment or a replacement for the fault-injection lifecycle regressions above. The landing runner inspected the updater receipt, both channel/status/readiness snapshots, fixture connection evidence, source/package binding, and cleanup results.

Docs updated: plugin architecture/lifecycle, config hot reload, and Gateway health/readiness. Production Gateway changes and landing remain outside this PR preparation work.

Retry admitted-work drain before restoring captured previous registrations. Settle failed reload pauses, preserve resource ownership, and expose replacement and activation failures through readiness.
@clawsweeper

clawsweeper Bot commented Sep 17, 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 size: L maintainer Maintainer-authored PR labels Sep 17, 2026
@steipete
steipete marked this pull request as ready for review September 17, 2026 14:43
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 17, 2026, 11:51 AM ET / 15:51 UTC (Revision 3).

ClawSweeper review

What this changes

The PR adds bounded plugin replacement recovery, releases channel pauses after failure, preserves restart budgets, and exposes recovery status through Gateway readiness.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful recovery fix that current main does not provide. No blocking code defect was found in the introduced changes; the repository-required update compatibility evidence remains outstanding.

Priority: P1
Reviewed head: 4969f33e0c844c14758dd3add84fee085ea2be88

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking code defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER authorship exempts this PR from the external-contributor proof gate; inspected synthetic lifecycle tests cover restoration and exclusive resource retention, while the separate policy-required published-updater cell remains outstanding.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER authorship exempts this PR from the external-contributor proof gate; inspected synthetic lifecycle tests cover restoration and exclusive resource retention, while the separate policy-required published-updater cell remains outstanding.
Evidence reviewed 9 items Introduced recovery behavior: The pinned merge-base-to-head diff adds a 60-second recovery window with bounded drain observations and backoff; cleanup side effects remain outside the retry loop.
Current main still needs the repair: Current main's cleanup owner has only bounded drainInstances calls and no drainForRecovery operation. Its reload failure path performs another single drain, and finalization only disposes recovery captures rather than settling channel pauses.
Failure diagnostics survive partial restoration: The generation owner retains previously failed plugin IDs unless the operation actually restores a callable registration; successful unrelated reloads do not erase those failures.
Findings None None.
Security None None.

How this fits together

The Gateway replaces running plugins while coordinating admitted work, resource cleanup, and channel restarts. Its lifecycle owner publishes recovery status to readiness probes and controls when channel health monitoring can resume.

flowchart TD
  A[Plugin reload request] --> B[Pause and stop affected channels]
  B --> C[Drain admitted work]
  C --> D{Work settles safely?}
  D -->|Yes| E[Restore captured plugin runtime]
  E --> F[Restart eligible channels]
  D -->|Deadline or cleanup failure| G[Release pauses and retain resource fences]
  G --> H[Report actionable readiness failure]
Loading

Before merge

  • Resolve merge risk (P1) - Preservation of existing operator configuration and channel state through a published updater driving the candidate remains unverified; lifecycle fixtures do not cover that update boundary.
  • Complete next step (P2) - Add the policy-required published-driver × candidate update evidence showing existing configuration and channel state survive restart.
Agent review details

Security

None.

PR surface

Source +183, Tests +177, Docs +34. Total +394 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 11 260 77 +183
Tests 8 218 41 +177
Docs 3 35 1 +34
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 513 119 +394

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +183 lines; tests and support net +177 lines Production growth is justified by bounded recovery, explicit fence settlement, and lifecycle-owned readiness diagnostics.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep recovery within the existing lifecycle owner, preserve unfinished-write ownership and manual stops, and establish update compatibility with existing operator state.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep recovery within the existing lifecycle owner, preserve unfinished-write ownership and manual stops, and establish update compatibility with existing operator state.

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

Yes, from source: hold an admitted plugin write beyond both existing drain observations after its channels stop; current main can exit without releasing their reload pause. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. Retrying drain observation and restoring captured code through the existing lifecycle owner addresses the failure without abandoning writes or introducing competing recovery ownership.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The reported production failure stranded channels for hours after a replacement timeout, disabling an active messaging workflow.
  • 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: The supplied MEMBER authorship exempts this PR from the external-contributor proof gate; inspected synthetic lifecycle tests cover restoration and exclusive resource retention, while the separate policy-required published-updater cell remains outstanding.

Evidence

What I checked:

  • Introduced recovery behavior: The pinned merge-base-to-head diff adds a 60-second recovery window with bounded drain observations and backoff; cleanup side effects remain outside the retry loop. (src/gateway/server-plugin-reload-cleanup.ts:203, 4969f33e0c84)
  • Current main still needs the repair: Current main's cleanup owner has only bounded drainInstances calls and no drainForRecovery operation. Its reload failure path performs another single drain, and finalization only disposes recovery captures rather than settling channel pauses. (src/gateway/server-plugin-reload-cleanup.ts:51, 27bd778af0c4)
  • Failure diagnostics survive partial restoration: The generation owner retains previously failed plugin IDs unless the operation actually restores a callable registration; successful unrelated reloads do not erase those failures. (src/gateway/server-plugin-runtime-generation.ts:112, 4969f33e0c84)
  • Meaningful recovery regression coverage: The inspected test exercises held writes at 5, 15, and 70 seconds through registered plugin handlers and the channel manager, checking restoration, terminal failure, exactly one completed write, stale-handler rejection, and later reload. These tests were inspected, not executed during this read-only review. (src/gateway/server-plugin-reload.active-call.test-support.ts:20, 4969f33e0c84)
  • Readiness confidentiality remains intact: The HTTP probe serializes detailed readiness only for local-direct or authenticated callers; unauthenticated remote callers receive the aggregate ready boolean. The new plugin status does not bypass this boundary. (src/gateway/server-http-probes.ts:90, 4969f33e0c84)
  • Update proof requirement and prior review continuity: Root policy requires a published-driver × candidate cell for plugin-loading or service-lifecycle changes. The supplied complete PR body explicitly says this cell was not run and limits its proof to synthetic lifecycle fixtures. This independently supports retaining the prior review's specific update-proof request. (AGENTS.md:69, 4969f33e0c84)

Likely related people:

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

Rank-up moves

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

  • Record the required published-driver × candidate update result demonstrating preservation of existing configuration and channel state across restart.

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 (2 earlier review cycles)
  • reviewed 2026-09-17T14:51:31.842Z sha 818f560 :: blocked before merge. :: none
  • reviewed 2026-09-17T15:26:41.771Z sha 4969f33 :: blocked before merge. :: none

Keep failure diagnostics for retired plugins omitted by recovery. Exercise installed plugin retries against the reported deadline while preserving exclusive resources and sibling ownership.
@steipete
steipete merged commit 578690d into main Sep 17, 2026
379 of 382 checks passed
@steipete
steipete deleted the steipete/fix-plugin-generation-channel-strand-20260917 branch September 17, 2026 17:19
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…claw#150953)

* fix(plugins): recover channels after replacement drain timeouts

Retry admitted-work drain before restoring captured previous registrations. Settle failed reload pauses, preserve resource ownership, and expose replacement and activation failures through readiness.

* fix(plugins): retain unresolved partial rollback failures

Keep failure diagnostics for retired plugins omitted by recovery. Exercise installed plugin retries against the reported deadline while preserving exclusive resources and sibling ownership.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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