Repository navigation
fix: keep Gateway ready while plugins drain after updates - #206299
Conversation
- Keep ordinary targeted reload drains out of core readiness; recovery failures remain unhealthy. - Move the selected cron lease and existing cleanup stack to preparation, owning the lease before admission can fail. - Release the preparation effect and join the existing session settlement receipt before continuation deletion, then release the generation. - Cover cancelled continuations with real session custody and assert normal cleanup ordering outside warning handling. - Keep drain budgets, stored formats, and active-turn generation pinning unchanged. Related: #205435, #195478; preserves #180877.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. What this changesThis PR keeps ordinary plugin drains out of Gateway readiness failures and gives cron preparation ownership of its selected runtime lease before execution admission. Example: A plugin reload waits behind an admitted request within its 60-second drain budget.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses two source-confirmed lifecycle failures that remain on current main; no introduced correctness defect was found. Reviewed head: Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway readiness owner turns runtime health into HTTP readiness responses, while cron preparation selects a plugin generation and carries its lease through session admission, execution, and cleanup. flowchart TD
A[Plugin reload] --> B[Generation drain]
B --> C[Readiness owner]
C --> D[HTTP readiness response]
E[Cron preparation] --> F[Session admission and execution]
F --> G[Continuation cleanup]
G --> H[Runtime lease release]
Technical reviewBest possible solution: Keep the existing readiness and cron preparation owners, with one runtime disposal path that runs after session settlement and continuation cleanup. Do we have a high-confidence way to reproduce the issue? Current-main source establishes unconditional reload readiness failure and an unowned selected lease when admission fails before execution; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs lease ownership before the failing awaits and preserves the earlier cleanup-order invariant without adding retries, budgets, configuration, or a parallel lifecycle owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5f0743a81c2a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +8, Tests +106, Docs +1. Total +115 across 9 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 26, 2026, 9:37 PM ET / November 27, 2026, 02:37 UTC. |
|
Landed as 2f246fd. Two fixes for the fleet fingerprint git-release:plugins:drain-not-settled-60s (Peanutto update run 94864d80, where readyz returned 503 for 59.7 s during the post-update plugin reload). (1) A targeted plugin reload no longer takes Gateway readiness down while the previous plugin generation keeps serving. A recovering or failed plugin still fails health. (2) A cron run now owns its prepared plugin-generation lease from right after preparation, so a cancellation or rejection before the run starts releases it. Before, the lease stayed referenced and blocked the drain. Cleanup still runs after session admission unwinds, so the #180877 ordering is kept. Proof: a real Gateway's readyz stayed 200→200→200 during a reload that could not drain (it was 200→503→200 on base). The cancellation test failed on main with retainedWorkCount 1 and passes here. CI is green on the exact head, and the review is clean. |
* commit '7df6cb759f9e604921536a700e2f527c5516e7de': (185 commits) docs: clarify what telemetry OpenClaw sends and how to opt out refactor(ui): remove retired stream-follow test seams (#206316) fix: distinguish missing command results from unknown outcomes (#206313) fix(build): reuse stamps after identical pnpm installs (#206282) chore(ci): inventory Gateway model catalog worker lifecycles (#206251) fix: keep failed image inspections inside chat activity (#206283) fix: clarify sent-message labels and chat activity icons (#206048) fix(cron): use the service's free memory for extra automation runs (#206322) test(android): reuse the shared TLS fixture (#206280) fix(ui): restore New Session recovery during startup (#206319) test(macos): align new Gateway URL expectations (#206281) feat: let doctor --fix tell when its startup repairs have nothing to do (#206246) fix(android): pause idle gateway discovery without blocking consumers (#196209) fix(ci): prepare the Android SDK for scheduled CodeQL scans (#203843) fix(memory): read delegated cgroup pressure from the mapped leaf (#206308) improve(config): reuse plugin metadata during auto-enable (#206289) improve: copy only the selected model for agent completions (#206287) fix(pr): refresh tooling before preparing reviewed incoming PRs (#206236) fix: keep Gateway ready while plugins drain after updates (#206299) fix(crabbox): keep unused prepared mirrors reusable (#206267) ...
…06299) Related: openclaw#205435, openclaw#195478 ## What Problem This Solves A plugin reload after an update could make the whole Gateway fail `/readyz` for its 60-second drain, even though the previous plugin generation was still serving. A cancelled cron run could also abandon its selected plugin-generation lease before execution started, leaving future reloads waiting on work that had ended. ## User Impact Ordinary plugin reload drains no longer make the Gateway not-ready. Failed activation or recovery still fails readiness. Cancelling a prepared cron run releases its selected generation. No settings, stored formats, drain budgets, retries, or active-turn pinning rules change. ## Why This Change Was Made The readiness owner treated every reload status as a core outage. It now distinguishes an ordinary reload from failed or recovering activation. Cron preparation acquired its selected execution lease before two awaits, but execution only registered disposal inside the later callback. The preparation owner now owns the lease across resource cleanup, session admission, and execution; the later duplicate ownership is removed. Its existing cleanup stack releases the session preparation hold, joins the session owner's settlement receipt, deletes the continuation after admission unwinds, then releases the lease. This preserves openclaw#180877 without a timer or retry. This fixes a concrete leak on the cron preparation path used by the fleet run. The decision-only path reported in openclaw#205435 is **not yet proven** to have this cause, so that issue remains open. This does not solve openclaw#195478: active turns still retain their admitted plugins; only abandoned cron holds are removed. ## Evidence - Base `a92d5919a899`: the new cron owner regression fails because one real retained plugin work reference remains after cancelled session admission; execution never starts (45 ms test time). - Readiness owner regression fails on the base with `plugin-reload` and passes on the candidate. Recovery/failed-health cases remain covered. - Real isolated source Gateway, with `plugins.reload` unresolved behind an admitted held request: base HTTP **200 → 503 → 200**; candidate HTTP **200 → 200 → 200**. Base run 23.11 s, candidate run 50.34 s. Both Gateways and state were cleaned. - Gateway consumer batch: 8 files / 179 tests passed, including real HTTP readiness during a held drain and after its forced drain failure. - Production delta measured with `tokei`: **+8 code lines** (971 → 979 across the three changed production modules). - Initial focused batch: **15 files / 271 tests passed** in 376.50 s wall time. After the cleanup-order repair, the final three cron owner files passed **21/21 tests**, including openclaw#180877's external ordering assertion and the cancelled-continuation regression (12 ms; 45 ms on the failing base). - `check:changed` passed core production/test typechecks, formatting, and guards. Its dead-export scan reported three untouched exports (`readUpdateDatabaseEngineConfig`, `DoctorContributionPending`, `formatUpdateSnapshotCapacity`); no suppression or unrelated code repair is included. - Final scoped checks passed: formatting, oxlint (zero warnings/errors), core production types, and the services-cron test type graph. Final checks plus the three-file test run took 69.40 s; Vitest itself took 43.60 s. - Local ClawSweeper reviewed `a92d5919a899` → `25e3fdb6b90c` at default service tier: complete, **patch is correct**, zero findings, security cleared. The offline review did not receive execution receipts; the observed runs are summarized above. ### Readiness decision Serving-health readiness is the requested contract for this repair: an ordinary reload does not report the whole serving Gateway as unavailable. New agent runs still wait on the existing replacement gate, visible in status. Recovery and failed activation remain unhealthy. This resolves the local review's advisory product-direction question without changing admission policy. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #205435, #195478 ## What Problem This Solves A plugin reload after an update could make the whole Gateway fail `/readyz` for its 60-second drain, even though the previous plugin generation was still serving. A cancelled cron run could also abandon its selected plugin-generation lease before execution started, leaving future reloads waiting on work that had ended. ## User Impact Ordinary plugin reload drains no longer make the Gateway not-ready. Failed activation or recovery still fails readiness. Cancelling a prepared cron run releases its selected generation. No settings, stored formats, drain budgets, retries, or active-turn pinning rules change. ## Why This Change Was Made The readiness owner treated every reload status as a core outage. It now distinguishes an ordinary reload from failed or recovering activation. Cron preparation acquired its selected execution lease before two awaits, but execution only registered disposal inside the later callback. The preparation owner now owns the lease across resource cleanup, session admission, and execution; the later duplicate ownership is removed. Its existing cleanup stack releases the session preparation hold, joins the session owner's settlement receipt, deletes the continuation after admission unwinds, then releases the lease. This preserves #180877 without a timer or retry. This fixes a concrete leak on the cron preparation path used by the fleet run. The decision-only path reported in #205435 is **not yet proven** to have this cause, so that issue remains open. This does not solve #195478: active turns still retain their admitted plugins; only abandoned cron holds are removed. ## Evidence - Base `caf2a4d4f7dc`: the new cron owner regression fails because one real retained plugin work reference remains after cancelled session admission; execution never starts (45 ms test time). - Readiness owner regression fails on the base with `plugin-reload` and passes on the candidate. Recovery/failed-health cases remain covered. - Real isolated source Gateway, with `plugins.reload` unresolved behind an admitted held request: base HTTP **200 → 503 → 200**; candidate HTTP **200 → 200 → 200**. Base run 23.11 s, candidate run 50.34 s. Both Gateways and state were cleaned. - Gateway consumer batch: 8 files / 179 tests passed, including real HTTP readiness during a held drain and after its forced drain failure. - Production delta measured with `tokei`: **+8 code lines** (971 → 979 across the three changed production modules). - Initial focused batch: **15 files / 271 tests passed** in 376.50 s wall time. After the cleanup-order repair, the final three cron owner files passed **21/21 tests**, including #180877's external ordering assertion and the cancelled-continuation regression (12 ms; 45 ms on the failing base). - `check:changed` passed core production/test typechecks, formatting, and guards. Its dead-export scan reported three untouched exports (`readUpdateDatabaseEngineConfig`, `DoctorContributionPending`, `formatUpdateSnapshotCapacity`); no suppression or unrelated code repair is included. - Final scoped checks passed: formatting, oxlint (zero warnings/errors), core production types, and the services-cron test type graph. Final checks plus the three-file test run took 69.40 s; Vitest itself took 43.60 s. - Local ClawSweeper reviewed `caf2a4d4f7dc` → `25e3fdb6b90c` at default service tier: complete, **patch is correct**, zero findings, security cleared. The offline review did not receive execution receipts; the observed runs are summarized above. ### Readiness decision Serving-health readiness is the requested contract for this repair: an ordinary reload does not report the whole serving Gateway as unavailable. New agent runs still wait on the existing replacement gate, visible in status. Recovery and failed activation remain unhealthy. This resolves the local review's advisory product-direction question without changing admission policy. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2f246fd)
Related: #205435, #195478 A plugin reload after an update could make the whole Gateway fail `/readyz` for its 60-second drain, even though the previous plugin generation was still serving. A cancelled cron run could also abandon its selected plugin-generation lease before execution started, leaving future reloads waiting on work that had ended. Ordinary plugin reload drains no longer make the Gateway not-ready. Failed activation or recovery still fails readiness. Cancelling a prepared cron run releases its selected generation. No settings, stored formats, drain budgets, retries, or active-turn pinning rules change. The readiness owner treated every reload status as a core outage. It now distinguishes an ordinary reload from failed or recovering activation. Cron preparation acquired its selected execution lease before two awaits, but execution only registered disposal inside the later callback. The preparation owner now owns the lease across resource cleanup, session admission, and execution; the later duplicate ownership is removed. Its existing cleanup stack releases the session preparation hold, joins the session owner's settlement receipt, deletes the continuation after admission unwinds, then releases the lease. This preserves #180877 without a timer or retry. This fixes a concrete leak on the cron preparation path used by the fleet run. The decision-only path reported in #205435 is **not yet proven** to have this cause, so that issue remains open. This does not solve #195478: active turns still retain their admitted plugins; only abandoned cron holds are removed. - Base `caf2a4d4f7dc`: the new cron owner regression fails because one real retained plugin work reference remains after cancelled session admission; execution never starts (45 ms test time). - Readiness owner regression fails on the base with `plugin-reload` and passes on the candidate. Recovery/failed-health cases remain covered. - Real isolated source Gateway, with `plugins.reload` unresolved behind an admitted held request: base HTTP **200 → 503 → 200**; candidate HTTP **200 → 200 → 200**. Base run 23.11 s, candidate run 50.34 s. Both Gateways and state were cleaned. - Gateway consumer batch: 8 files / 179 tests passed, including real HTTP readiness during a held drain and after its forced drain failure. - Production delta measured with `tokei`: **+8 code lines** (971 → 979 across the three changed production modules). - Initial focused batch: **15 files / 271 tests passed** in 376.50 s wall time. After the cleanup-order repair, the final three cron owner files passed **21/21 tests**, including #180877's external ordering assertion and the cancelled-continuation regression (12 ms; 45 ms on the failing base). - `check:changed` passed core production/test typechecks, formatting, and guards. Its dead-export scan reported three untouched exports (`readUpdateDatabaseEngineConfig`, `DoctorContributionPending`, `formatUpdateSnapshotCapacity`); no suppression or unrelated code repair is included. - Final scoped checks passed: formatting, oxlint (zero warnings/errors), core production types, and the services-cron test type graph. Final checks plus the three-file test run took 69.40 s; Vitest itself took 43.60 s. - Local ClawSweeper reviewed `caf2a4d4f7dc` → `25e3fdb6b90c` at default service tier: complete, **patch is correct**, zero findings, security cleared. The offline review did not receive execution receipts; the observed runs are summarized above. Serving-health readiness is the requested contract for this repair: an ordinary reload does not report the whole serving Gateway as unavailable. New agent runs still wait on the existing replacement gate, visible in status. Recovery and failed activation remain unhealthy. This resolves the local review's advisory product-direction question without changing admission policy. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2f246fd) Release adaptation: Merge runtime lease ownership and settlement-ordered continuation cleanup into the existing prepareCronRunContext in run-prepare.ts, without the later owner split (3ad2cce). The regression drives the stable preparation path with its existing harness, aborts at continuation initialization, and observes real lease holds and admission unwind. Stable readiness stays in its existing owner. The later same-file 6d86389 only relocates the readiness type; 1ed6fd2 (#207091) adds provider rate-limit reset handling. Neither is needed. Co-authored-by: RomneyDa <[email protected]>
Related: #205435, #195478
What Problem This Solves
A plugin reload after an update could make the whole Gateway fail
/readyzfor its 60-second drain, even though the previous plugin generation was still serving. A cancelled cron run could also abandon its selected plugin-generation lease before execution started, leaving future reloads waiting on work that had ended.User Impact
Ordinary plugin reload drains no longer make the Gateway not-ready. Failed activation or recovery still fails readiness. Cancelling a prepared cron run releases its selected generation. No settings, stored formats, drain budgets, retries, or active-turn pinning rules change.
Why This Change Was Made
The readiness owner treated every reload status as a core outage. It now distinguishes an ordinary reload from failed or recovering activation.
Cron preparation acquired its selected execution lease before two awaits, but execution only registered disposal inside the later callback. The preparation owner now owns the lease across resource cleanup, session admission, and execution; the later duplicate ownership is removed. Its existing cleanup stack releases the session preparation hold, joins the session owner's settlement receipt, deletes the continuation after admission unwinds, then releases the lease. This preserves #180877 without a timer or retry.
This fixes a concrete leak on the cron preparation path used by the fleet run. The decision-only path reported in #205435 is not yet proven to have this cause, so that issue remains open. This does not solve #195478: active turns still retain their admitted plugins; only abandoned cron holds are removed.
Evidence
caf2a4d4f7dc: the new cron owner regression fails because one real retained plugin work reference remains after cancelled session admission; execution never starts (45 ms test time).plugin-reloadand passes on the candidate. Recovery/failed-health cases remain covered.plugins.reloadunresolved behind an admitted held request: base HTTP 200 → 503 → 200; candidate HTTP 200 → 200 → 200. Base run 23.11 s, candidate run 50.34 s. Both Gateways and state were cleaned.tokei: +8 code lines (971 → 979 across the three changed production modules).check:changedpassed core production/test typechecks, formatting, and guards. Its dead-export scan reported three untouched exports (readUpdateDatabaseEngineConfig,DoctorContributionPending,formatUpdateSnapshotCapacity); no suppression or unrelated code repair is included.caf2a4d4f7dc→25e3fdb6b90cat default service tier: complete, patch is correct, zero findings, security cleared. The offline review did not receive execution receipts; the observed runs are summarized above.Readiness decision
Serving-health readiness is the requested contract for this repair: an ordinary reload does not report the whole serving Gateway as unavailable. New agent runs still wait on the existing replacement gate, visible in status. Recovery and failed activation remain unhealthy. This resolves the local review's advisory product-direction question without changing admission policy.