Skip to content

fix(update): recover interrupted managed updates on 2026.11.3 - #193884

Merged
RomneyDa merged 10 commits into
release/2026.11.3from
openclaw/release-pr-112
Nov 10, 2026
Merged

RomneyDa merged 10 commits into
release/2026.11.3from
openclaw/release-pr-112

Conversation

@tideclaw-bot

@tideclaw-bot tideclaw-bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #188303. Backports #172784, #175890 and #188497.

What Problem This Solves

Fixes recovery paths that leave an update-owned Gateway stop unresolved after an interrupted update, recoverable finalization failure, or completed repair on release/2026.11.3.

User Impact

Restore an owned Gateway only after recovery verifies service ownership, runtime identity, and safe state. Operator stops, named data risks, custody grace, process census, and unknown-owner refusals remain intact. Unowned services receive manual-start guidance rather than failing completed maintenance.

This does not establish that every incident in #188303 is resolved. An already-running old updater cannot acquire these fixes retroactively.

Why This Change Was Made

Adapt the three existing fixes to the release’s current-core and inline helper owners. Preserve compatible failure history, accept the release’s actual finalizer response, and select the verified installed ledger/terminal writer before post-core repair can migrate state and fail. No plugin-cohort subsystem, recovery-owner restructuring, release metadata, versions, or production schema change is included.

Preparation base: 1bec8184bcd9849061bedf7f4e5cc9405039801a. The seven commits since original proof base fc9b9635e6d4142ff42d0409f41d7e306f14c5d0 do not overlap the backport. Original author and human coauthor credit are preserved.

Evidence

  • Original release-base restoration regression failed before the fix and passed afterward. Finalizer-response and operator-stop regressions also reproduced before correction.
  • Retained original-base results: 48 finalizer/cleanup, 23 custody, 7 ledger compaction/capture, and 150 recovery sibling tests passed. These are reused results, not current-head reruns.
  • Final release-base 13 interrupted-helper tests pass, including two terminal-failure regressions that fail on the uncorrected head. They exercise detached helper/publication/persisted terminal-record paths with a synthetic finalizer.
  • Targeted type-aware lint, formatting, and diff checks pass for the correction. Original-base core/infra typechecks passed. Rebound CLI typecheck is blocked by the wrapper refusing linked declaration dependencies outside this checkout; no current-head CLI typecheck pass is claimed.
  • Canonical autoreview via authenticated OpenClaw engine, P0–P2, covered the full prepared range. Its remaining finding was the old indexed terminal writer while the working-tree fix was present; after staging the fix, a fresh correction review against 6189a2636644a0777df90e8ef26a94b738cb66b0 was scoped-clean. Final correction commit: 0e783c4874dd14aff32561b81b96370a521ac8a7.

Rebased onto release/2026.11.3

2026.11.2 shipped on 2026-11-08 without this PR, so it now targets release/2026.11.3 (base 40223c5cc262). Changes from the rebase:

  • Three commits were cherry-picked in order. The only conflict was docs/install/updating.md, resolved by keeping 11.3's SQLite-probe and Doctor-ownership paragraph alongside this PR's recovery paragraph.
  • 23823aff802a became empty on 11.3 and was dropped.
  • Added 0c3954f8f9c0. update-recovery-guidance.test.ts › "uses raw recovery facts for immediate guidance without replacing history" failed on both the original 11.2 head and the rebase. Its saved fixture used reason: "state-migration-started", which this PR's update-run-read.kernel.ts deliberately maps to legacy-state-migration data risk, so the guidance correctly said to keep the Gateway stopped. The fixture now uses a non-migration reason, so the test still proves stale history stays out of immediate guidance. No production code changed.

Proof on the rebased head:

  • 12 changed update test files run one at a time: all pass after the fixture fix (the guidance file: 28/28).
  • pnpm tsgo:core passes. oxfmt --check, oxlint and git diff --check pass on all 63 changed files.

ClawSweeper P1 and CI repairs

  • c8b6453dabe6 fixes the schema-crossing read (ClawSweeper P1). The staged helper is a copy of the old updater's build (stageManagedHandoffRuntime). If the candidate's Doctor advanced the shared schema before the updater was killed, the helper's first reads, the Gateway stop and this run, failed with SqliteSchemaVersionError and recovery never started. On that error, and only that error, the helper now reads and records through the installed runtime, which already owns post-core repair. The new schema-advance boundary case advances the schema past the staged helper before SIGKILL. Without the fix it fails with handoff failed: SqliteSchemaVersionError: This OpenClaw build cannot open your existing data.; with it, the Gateway is restored on 2.0.0 and the run finishes succeeded. The fixture's candidate stands in for a newer build by reading the migrated schema, and this is not a real cross-version package migration. main has the same staged-reader structure and needs this fix too.
  • d173d3392d04 ports the test updates the backport dropped. fix(update): recover stopped gateways after unverified service activation #172784 changed already-current, candidate-activation and node-runtime tests together with the restart-after-failure behavior, and those changes are now applied. The Windows triage and foreground-failure cases now expect the observation main records when recovery leaves an untouched service alone. The package-swap risk fixture now carries the dataAtRisk that release writers set.
  • Local results on d173d3392d04: fresh-doctor 15/15, windows-lifecycle 27/27, failure-recovery 25/25, candidate-activation 13/13, node-runtime 8/8, recovery-guidance 28/28, interrupted handoff 14/14, tsgo:core:test clean. update-cli.already-current › "handles changed service owner before already-current convergence" still fails, identically to the 11.3 base 40223c5cc262. It's inherited and not caused by this PR.

Remaining gates: Exact-head PR CI and packaged actual-candidate upgrade/data-preservation proof remain pending. Native macOS/Windows execution is not established by synthetic manager tests; release validation remains required.

Worked on by

Fewer hard failures (4d16bb6964b9)

  • openclaw update repair / finalize: when the Gateway does not start or verify after maintenance, repair now completes with a warning naming openclaw gateway start and openclaw gateway status --deep, instead of failing the repair. Named data risk and process-cleanup failures still fail.
  • The pre-start service inspection and recovery-admission check now run once, right before the start, instead of being repeated inside the start callback.
  • Managed helper: an unreadable update history while deciding on interrupted recovery is logged, and the helper falls through to its existing failure handling instead of throwing past it.
  • Proof: update-repair-service 23/23 (expectations updated for warning instead of failure), update-managed-service-handoff-interrupted 14/14, cleanup-repair 37/37, post-update-recovery 34/34, post-update-repair 43/43, fresh-doctor 15/15, tsgo:core:test, oxlint and oxfmt clean.

Live stop authority (fb6a0b7b01e4)

  • Preserve 4d16bb6964b9 repair-warning semantics and single ownership inspection. Recheck the current helper lease and same-run pending stop after awaited inspection and before recovery startup, including launchd retries. Carry the existing effect-only check through repair CLI, launchd activation, and Windows scheduled-task/fallback startup, without revoking authority after successful startup.
  • Red/green boundary proof covers stop retirement during inspection/native preparation, replaced helper leases, reassigned service identity, and successful-start self-retirement. The corrected repair regression writes and verifies active-run state; its pre-fix failure starts a service that should remain stopped.
  • Combined targeted evidence: 193 passed, 15 platform skips (21 unchanged recovery tests plus 172 final repair/native tests). Core and targeted infra/CLI-update/services test types pass; targeted lint reports zero errors/warnings; formatting and diff checks pass. Fresh independent native-path and corrected-fixture review found no actionable issues. Prior-head CI is not treated as current-head evidence.
  • Actual published 2026.11.2 baseline onboarding, agent/history, database and backup preparation succeeded. Candidate package proof is still pending: an earlier archive preparation had mismatched source/build-stamp identity and is explicitly rejected as candidate evidence. A fresh build uses the exact combined source.

@clawsweeper

clawsweeper Bot commented Nov 6, 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 commands Command implementations size: XL labels Nov 6, 2026
@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: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR backports managed Gateway recovery after interrupted updates and recoverable finalization failures to release/2026.11.3.

Example: The updater is killed after publishing a candidate labelled 2.0.0.

  • Before: The managed Gateway remains stopped without automatic recovery.
  • After: The surviving helper attempts candidate finalization, restores the verified Gateway, and records the outcome.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful recovery backport with a concrete operator-stop defect and unresolved authority and upgrade gates.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A managed update can leave the Gateway stopped after its updater dies or finalization fails recoverably.
Reason: The maintainer-authored direction restores an established recovery contract; the PR appropriately avoids claiming that every linked launchd incident is resolved.

Merge readiness

⛔ Blocked before merge - 6 items remain

Keep this maintainer-authored release backport open: it addresses a valuable recovery defect, but its helper can still undo a later recorded operator stop.

Priority: P1
Reviewed head: d173d3392d046b59cf11f1adc90f5953ac758dcd

Before merge

  • Add real behavior proof - Authority-chain proof required: supplied detached-helper scenarios exercise real recovery and ledger owners with emulated managers and synthetic finalization, but do not show replaced helper leases or reassigned services rejected before publication or startup. The acknowledged packaged v2026.11.2 upgrade gap also leaves persisted-state compatibility unverified; the schema-advance fixture resets schema markers and is not an actual cross-version migration. Supply sanitized final-effect traces and upgrade results, redacting IPs, keys, phone numbers, and non-public endpoints. 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.
  • Recheck stop intent immediately before native startup (P1) - The newly reachable interrupted-helper recovery checks the ledger here, then awaits native service inspection before starting the Gateway. If a replacement start is recorded during that inspection and the operator leaves the service stopped, the cached stop decision still permits startup: runOwned checks the helper lease, not the retired stop intent. Launchd retries likewise have no fresh stop check. Main already fixes this failure with a pending-stop callback before native effects and a service-inspection regression. Port that callback into the release helper, including bootstrap/kickstart retries, so recovery cannot undo the later recorded stop.
  • Resolve security review attention item - Recovery authority crosses into publication and startup, while lease replacement and service reassignment rejection remain unproven.
  • Resolve merge risk - Recovery authority survives updater death, but whether replacement of the helper lease or reassignment of the service prevents subsequent publication and startup remains unproven.
  • Improve patch quality - Add final-effect proof that replacing the helper lease or reassigning the service prevents publication and native startup.
  • 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

  • [P1] Recheck stop intent immediately before native startup — src/infra/update-managed-service-handoff.ts:418-420

Tests

  • Missing end-to-end proof: Missing proof covers revoked recovery authority at publication/startup and an actual v2026.11.2-to-candidate upgrade preserving configuration, shared state, and agent data.
Agent review details

How this fits together

The update CLI and detached handoff helper coordinate package publication, Doctor maintenance, update history, and native service managers to restore a verified Gateway after failure.

flowchart TD
  A[Update request] --> B[Update CLI]
  B --> C[Detached handoff helper]
  C --> D[Package publication owner]
  C --> E[Installed finalizer]
  C --> F[Native service manager]
  E --> G[Update ledger]
  F --> H[Gateway readiness]
Loading

Technical review

Best possible solution:

Port main’s pending-stop callback into the existing helper and check it immediately before each native startup effect.

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

The release-base source and supplied pre-fix failures establish the interrupted-update recovery defect; this review ran no target code.

Is this the best way to solve the issue?

Reusing the existing publication, finalization, and service owners is appropriate, but the backport needs main’s final-effect stop-intent guard.

Full review comments:

  • [P1] Recheck stop intent immediately before native startup — src/infra/update-managed-service-handoff.ts:418-420
    The newly reachable interrupted-helper recovery checks the ledger here, then awaits native service inspection before starting the Gateway. If a replacement start is recorded during that inspection and the operator leaves the service stopped, the cached stop decision still permits startup: runOwned checks the helper lease, not the retired stop intent. Launchd retries likewise have no fresh stop check. Main already fixes this failure with a pending-stop callback before native effects and a service-inspection regression. Port that callback into the release helper, including bootstrap/kickstart retries, so recovery cannot undo the later recorded stop.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Establish recovery authority before inclusion (recommended)
    The PR owner should demonstrate that a replaced helper lease and a reassigned service reject recovery before package publication or native startup.
  2. Defer release inclusion
    The release owner can retain this PR while the recovery authority uncertainty is resolved.

Provenance checked

  • Interrupted managed handoff keeps the original intent (29503e1: Keep interrupted package publication and service recovery with the surviving helper and original update run.)
  • Failed-update restart policy changes intended behavior with a stated reason (d1a69c0: Validate candidates before stopping the Gateway and restore only verified, compatible generations.)
  • Recovery guidance keeps the original intent (48ff3d1: Derive user guidance from recorded serving facts without treating restart authority as proof of health.)
  • Migration recovery admission keeps the original intent (104dc5a: Normal Doctor completion may omit a settlement receipt, so candidate schema admission determines forward recovery eligibility.)

Testing

Proof path: in-process harness.

Security

Needs attention: Recovery authority crosses into publication and startup, while lease replacement and service reassignment rejection remain unproven.

Evidence

What I checked:

  • Pinned change and clean checkout: Reviewed the introduced release-base diff at d173d33; GitHub confirms that head still targets release/2026.11.3 and is mergeable. The checkout remained clean. (d173d3392d04)
  • Stop intent is checked before awaited inspection: The helper reads stop intent before awaiting native service inspection, then starts the service without another stop-intent check; its immediate effect guard checks lease ownership instead. (src/infra/update-managed-service-handoff.ts:418, d173d3392d04)
  • Existing main correction supplies the narrow repair: fix(update): preserve operator stops and failed repair outcomes #193885 added a pending-stop callback before native startup and launchd retries, with a regression recording a replacement start during service inspection; that callback is absent from this backport. (src/infra/update-managed-service-handoff-recovery-source.ts:55, 21f17afce911)
  • Previous schema-read finding addressed: The correction catches SqliteSchemaVersionError and switches initial history access to a fresh installed-runtime process; the added schema-advance case exercises this path with a synthetic candidate. (src/infra/update-managed-service-handoff-result-source.ts:279, c8b6453dabe6)
  • Proof limitations explicitly acknowledged: The complete supplied body, source revision aca439f629b3d9068d7dbb5cc803daaf7c6a73a848acbbc8f5b2f68158202d1c, acknowledges missing replaced-lease, reassigned-service, and packaged latest-stable upgrade proof; its detached-helper scenarios use emulated managers and synthetic finalization. (d173d3392d04)
  • Compatibility projection: Named recovery risks are stored through retained step failure facts while the additional in-memory field is removed from strict persisted and public recovery objects; focused tests cover reopening and legacy decoding. (src/infra/update-run-codec.ts:343, d173d3392d04)

PR surface

Source +800, Tests +1550, Docs +29. Total +2379 across 70 files. Added test files: 5.

View PR surface stats
Area Files Added Removed Net
Source 37 992 192 +800
Tests 31 1855 305 +1550
Docs 2 29 0 +29
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 70 2876 497 +2379

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: Interrupted managed updates can leave a real Gateway unavailable and require operator recovery.
  • remove P0: Current review triage priority is P1, so this older priority label is no longer current.

Label justifications:

  • P1: Interrupted managed updates can leave a real Gateway unavailable and require operator recovery.
  • merge-risk: 🚨 availability: The helper changes native service recovery and can undo a later recorded stop.
  • merge-risk: 🚨 security-boundary: The new recovery continuation carries lease and service authority into package publication and native startup after updater death.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-06T02:08:58.097Z sha 23823af :: needs real behavior proof before merge. :: [P1] Read initial recovery history through a schema-compatible runtime

Reviewed November 10, 2026, 1:08 AM ET / 06:08 UTC (Revision 2).

steipete and others added 4 commits November 9, 2026 18:45
Adapt #172784, #175890, and #188497 to release/2026.11.2 while retaining the current-core recovery owner and release-line custody grace. Preserve operator stops, named data-risk refusals, and same-run interrupted helper bookkeeping.

Co-authored-by: RomneyDa <[email protected]>
Complete safe post-core repair with a warning when service inspection returns a nonowned verdict. Keep automatic startup disabled and retain live-authority and data-risk checks. Exercise unavailable and absent services through the repair command; align retained-handoff fixtures with the preserved release-line grace period.

Co-authored-by: RomneyDa <[email protected]>
Select the verified installed ledger and terminal writer before post-core repair can migrate state. Retain staged fallback before candidate verification and cover finalizer failure and post-finalize data-risk refusal.

Co-authored-by: RomneyDa <[email protected]>
…igration reason

The release-line run reader maps a legacy "state-migration-started" reason to legacy-state-migration data risk, so the saved fixture correctly kept the Gateway stopped. Use a non-migration reason so the test still proves stale history does not leak into immediate guidance.
@RomneyDa
RomneyDa force-pushed the openclaw/release-pr-112 branch from 23823af to 0c3954f Compare November 10, 2026 03:11
@RomneyDa RomneyDa changed the title fix(update): recover interrupted managed updates on 2026.11.2 fix(update): recover interrupted managed updates on 2026.11.3 Nov 10, 2026
@RomneyDa
RomneyDa changed the base branch from release/2026.11.2 to release/2026.11.3 November 10, 2026 03:11
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat and removed cli CLI command changes commands Command implementations labels Nov 10, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review November 10, 2026 03:11
@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix labels Nov 10, 2026
… advance

The staged managed-update helper is a copy of the old updater's build. When the
candidate's Doctor advances the shared state schema and the updater is then
killed, the helper's first history reads (the Gateway stop and this run) hit
the newer-schema refusal, so recovery never starts and the Gateway stays
stopped.

On a newer-schema refusal, read and record through the installed runtime,
which already owns post-core repair. Other read errors still fail recovery.
The boundary test advances the schema past the staged helper before SIGKILL
and fails without this change.
…kport

The backport took #172784's restart-after-failure behavior without its test
updates, and the release line still expected verified readiness where recovery
now only observes an untouched service. Apply #172784's already-current,
candidate-activation and node-runtime changes, port main's observation
expectations for the Windows triage and foreground-failure cases, and give the
package-swap risk fixture the dataAtRisk field release writers set.
@RomneyDa

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

RomneyDa and others added 4 commits November 9, 2026 23:44
Repair maintenance has already finished when the Gateway fails to start or
verify, so report that as a warning naming `openclaw gateway start` and
`openclaw gateway status --deep` instead of failing the repair. Named data
risk and process-cleanup failures still fail.

Inspect the service and check recovery admission once, right before the
start, instead of repeating the full inspection inside the start callback.

An unreadable update history no longer skips the helper's existing failure
handling when the updater exits without a result.
Require the current helper lease and unretired stop intent after native inspection and before recovery start, launchd bootstrap retries, and kickstart. Keep publication recovery on its existing lease-only authority check.

Exercise late stop retirement, replaced helper leases, and reassigned native service identity through the generated helper boundary.

Co-authored-by: RomneyDa <[email protected]>
Check the pending recovery stop at native dispatch without revoking post-start authority. Carry the existing effect-only callback through launchd activation retries and Windows task startup, preserving repair warning semantics.

Prove late stop retirement through the repair CLI and native preparation boundaries, including successful-start self-retirement.

Co-authored-by: RomneyDa <[email protected]>
Keep the real launchd-system and exec-file export surfaces while overriding only native ownership and command effects in the stop-authority regressions.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL 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.

3 participants