Skip to content

fix(update): Gateway stays down when the updater is killed after a plugin cohort was reserved - #191201

Merged
steipete merged 5 commits into
mainfrom
codex/issue-164800-cohort
Nov 2, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/issue-164800-cohort

Conversation

@steipete

@steipete steipete commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: #164800

What Problem This Solves

Fixes: when the openclaw update process dies during a managed (Gateway-started) update after the package swap starts, or while Doctor runs, the Gateway stays down until someone runs openclaw update repair. When it dies just before the swap, the Gateway comes back, but the next update is refused until a manual repair.

User Impact

User impact: a managed update whose updater is killed (SIGKILL, OOM, a killed process group) now recovers on its own at every point we could kill it. The handoff helper settles that update's own plugin cohort and restarts a verified Gateway, and the next update is admitted without a manual repair. A cohort that belongs to another update, recorded data risk, lost ownership, and unverifiable runtimes still stop recovery and name the next step. Like #188497, this needs the helper that started the update to contain the fix; a helper from an older release cannot be repaired by the candidate.

Why This Change Was Made

#188497 made the still-running handoff helper finish an interrupted publication and run openclaw update finalize as the same update's continuation. #188978 (plugin cohorts restored on core rollback) records a plugin-cohort recovery reservation before the package swap. Finalize opened with the generic "no unfinished recovery" admission, so the helper's continuation refused its own run's reservation ("Update has unfinished recovery; reconcile it before starting another update.") and the Gateway stayed down. Only update repair could settle the reservation, and repair deliberately refuses inside a handoff.

The fix makes the run's live owner settle its own cohort:

  • Shared settlement. Repair's cohort settlement moves into settleInterruptedUpdatePluginCohort, so repair and the helper follow one rule: roll back a pending cohort, and commit only on the recorded candidate.
  • Finalize as the helper's continuation. Finalize first calls settleManagedHandoffPluginCohort. It acts only for the handoff continuation (OPENCLAW_UPDATE_RUN_HANDOFF=1 plus the run id), only for a cohort recorded for that same run, and only under the executor it borrows from the helper's live lease for that run (assertUpdateRequesterContinuationOwner plus assertPluginCohortRecoveryContinuation). Any other pending recovery still refuses.
  • Restored-original path. When activation never started, the helper restores the original runtime. If its run reserved a cohort, it runs the same finalize on that original runtime before restarting the Gateway. This is best-effort: a failure records warning:plugin-cohort-recovery and names openclaw update repair, and the original Gateway still restarts. Recorded data risk still keeps the Gateway stopped.

Rejected alternatives:

  • Letting the helper call update repair: repair claims its own handoff and adopts a new repair run, which conflicts with the helper's live lease and same-run bookkeeping.
  • Relaxing the generic admission for any OPENCLAW_UPDATE_RUN_HANDOFF process: env alone is not authority.

Evidence

Native Linux/systemd proof (Crabbox AWS lease, managed update.run from a ready Gateway, updater tree SIGKILLed). These use the same harness and kill points as #188497. Packages were built from main 8689fa8f6b8 (red: 2026.10.121 → 2026.10.122) and from this head 2026813714f (green: 2026.10.125 → 2026.10.126). The helper that starts the update has to come from the build under test.

Kill point Red (main) Green (this PR)
Pre-swap Gateway ready after 135 s; no recovery rows Gateway ready after 135 s; run rolled-back; no recovery rows
Mid-swap (package missing) Gateway still down 6 min later; pending update.recovery and update.pluginCohort (pending) Gateway ready on 2026.10.126 after 190 s; run succeeded (managed-service-handoff-recovered); no recovery rows
During candidate Doctor Gateway still down 6 min later; the same pending pair Gateway ready on 2026.10.126 after 190 s; run succeeded; no recovery rows

On red, the helper log shows the finalize continuation refusing with "Update has unfinished recovery; reconcile it before starting another update." On green, no recovery rows are left, so the next update is admitted.

Shipped driver, no kill: published 2026.10.9 → 2026.10.126 (this head) succeeded, ready, with no recovery rows. 2026.10.9's helper predates #188497, so kill recovery cannot be proven from it. That is the shipped first-hop rule.

Reviews:

  • $autoreview (Codex) on the final head: scoped-clean. The earlier pass found one P1: failed rollback finalization dropped recorded data risk. It is fixed by rereading the run, and covered by the risk case below.
  • Independent codex exec review on the final head: NO FINDINGS.

Boundary tests: src/infra/update-managed-service-handoff-interrupted.test.ts runs the real sealed helper, the real borrowed executor, and a real cohort reservation:

  • Own cohort, killed after publication: the cohort is settled, the run succeeds, and the Gateway is restored.
  • Own cohort, killed after publication preparation: the cohort is settled, the run is rolled back, and the Gateway is restored.
  • Foreign cohort: it is left pending, the continuation refuses, and the Gateway is not restarted.
  • Repair records data risk and then fails during rollback recovery: the Gateway stays stopped.

Each own/risk case is red with its fix removed and green with it. Local runs:

  • That file: 13/13.
  • Repair and finalize consumers (update-repair-package-activation, update-repair-command, update-command-finalize-refusal, update-managed-service-handoff-cleanup-repair, update-managed-service-handoff-recovery, update-repair-service): 195/195.
  • PR-wrapper closure tests: 39/39.
  • tsgo:core, oxlint (core shard) and oxfmt are clean.

@clawsweeper

clawsweeper Bot commented Nov 2, 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 cli CLI command changes labels Nov 2, 2026
@steipete
steipete marked this pull request as ready for review November 2, 2026 15:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T15:39:32.430909Z 2026813 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR lets a managed update’s live handoff continuation settle its own interrupted plugin cohort before restoring the Gateway.

Example: A Linux managed update from 2026.10.121 to 2026.10.122 loses its updater during package publication.

  • Before: The helper completes publication, but finalize refuses the pending plugin reservation and leaves the Gateway stopped.
  • After: The helper’s authorized continuation settles its own reservation, completes finalization, and restores the verified Gateway.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source-consistent, but required final-effect authority and persisted-state compatibility evidence remain incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A killed managed updater leaves the Gateway stopped or the next update blocked until manual repair.
Reason: Automatic recovery has clear availability value, and maintainer authorship establishes direction; Related wording correctly preserves the linked issue’s separate stalled-updater work.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this maintainer-authored PR addresses a verified recovery gap still present on main, and inspection found no definite introduced code defect.

Priority: P0
Reviewed head: 2026813714f06364ce26d68688edda693d0a3135

Before merge

  • Add real behavior proof - Authority-chain proof required: the boundary cases exercise own-run and foreign-run admission, but use empty plugin publications and a synthetic finalize launcher; they do not show revoked or reassigned custody preventing actual plugin settings and artifact writes. Native after-fix Linux proof is explicitly still in progress. Compatibility also needs a latest-stable upgrade with populated plugin state and settings preserved, accounting for the documented older-helper first-hop limitation. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve merge risk - Before merge, the PR author must establish that revoking or replacing the borrowed executor prevents this new continuation from restoring plugin settings or artifacts.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Supply after-fix shipped-entry-point recovery evidence, populated-state upgrade compatibility, and allowed/foreign/revoked-owner final-effect coverage; redact credentials and non-public endpoints.
Agent review details

How this fits together

The managed-update helper retains installation custody after updater death; it coordinates package recovery, installed-runtime finalization, plugin recovery, and Gateway restoration.

flowchart TD
  A[Managed update] --> B[Updater exits unexpectedly]
  B --> C[Live handoff helper]
  C --> D[Recover package publication]
  D --> E[Finalize under borrowed executor]
  E --> F[Settle own plugin cohort]
  F --> G[Doctor and plugin convergence]
  G --> H[Restore verified Gateway]
Loading

Technical review

Best possible solution:

Keep one shared cohort-settlement owner, preserve exact-run live custody, and complete recovery validation before landing.

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

Yes: source shows the helper calling finalize while its cohort reservation remains pending, and the PR records matching Linux/systemd failures on pinned main.

Is this the best way to solve the issue?

The patch uses the smallest coherent approach: extract repair’s settlement, authorize only the helper’s own continuation, and retain data-risk and foreign-run refusals.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify revoked-owner refusal (recommended)
    Exercise populated cohort settlement through the production continuation, replace its live lease during preparation, and show that plugin filesystem and settings writes are refused.

Provenance checked

  • Finalize admission and plugin settlement changes intended behavior with a stated reason (6fd646e: Retain recoverable plugin state and require fresh repair rather than granting effects from saved facts; this PR explains why a verified live same-run continuation can reuse that settlement.)
  • Interrupted managed-update recovery keeps the original intent (29503e1: The surviving helper restores verified runtimes while preserving ownership and named-data-risk refusals; this patch completes the explicitly deferred cohort path.)
  • Installation identity during explicit repair keeps the original intent (6df00ff: Repair must retain the saved package-slot identity and canonical installation custody during npm-to-Git recovery; the extraction preserves those caller-held checks.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 29503e1 adds src/infra/update-managed-service-handoff-interrupted.ts:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 29503e14a2d3; files: src/infra/update-managed-service-handoff-interrupted.ts)
  • RoboClaw: Raw commit 6fd646e adds src/cli/update-cli/update-repair-command.ts:237 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6fd646e86cd7; files: src/cli/update-cli/update-repair-command.ts)

PR surface

Source +85, Tests +117, Docs +8. Total +210 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 139 54 +85
Tests 5 118 1 +117
Docs 2 12 4 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 269 59 +210

Review metrics

Metric Value Why it matters
Production versus test changes Production +139/-54; tests and support +118/-1 Production growth extracts existing repair settlement and adds the same-run continuation; test growth covers forward recovery, restored-original recovery, foreign reservations, and recorded data risk.

Labels

Label changes:

  • add P0: A community user’s managed update can leave the Gateway unavailable with recovery requiring terminal commands.
  • add merge-risk: 🚨 security-boundary: The new continuation consumes borrowed execution authority to restore plugin artifacts and settings; final-effect refusal after authority replacement remains unproven.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P0: A community user’s managed update can leave the Gateway unavailable with recovery requiring terminal commands.
  • merge-risk: 🚨 security-boundary: The new continuation consumes borrowed execution authority to restore plugin artifacts and settings; final-effect refusal after authority replacement remains unproven.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof for a foreign run and for lease revocation or reassignment before plugin settings and artifact I/O.
  • Complete native after-fix recovery and latest-stable populated-state upgrade verification.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 2, 2026, 10:53 AM ET / 15:53 UTC.

@steipete
steipete merged commit e8f9136 into main Nov 2, 2026
294 of 300 checks passed
@steipete
steipete deleted the codex/issue-164800-cohort branch November 2, 2026 16:36
@steipete

steipete commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…ugin cohort was reserved (openclaw#191201)

* fix(update): settle the helper's own plugin cohort after an updater kill

* fix(update): settle the run's plugin cohort when interrupted recovery rolls back

* style: format interrupted recovery imports

* docs(update): describe helper plugin cohort settlement

* fix(update): keep the Gateway stopped when a failed rollback repair records data risk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant