Skip to content

fix(update): finish Windows updates after state migration - #157262

Merged
steipete merged 4 commits into
mainfrom
upd/windows-plugin-convergence-recovery-pending
Sep 24, 2026
Merged

steipete merged 4 commits into
mainfrom
upd/windows-plugin-convergence-recovery-pending

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Windows npm-global updates stopping with recovery pending after candidate Doctor migrates the state database, before post-core plugin convergence and Gateway activation can run.

Fixes #157077. Thanks @joshbunker for the report and the follow-up activation timeline.

User Impact

The repaired driver hands its suspended Scheduled Task to the compatible candidate finalizer without reopening migrated state through the old runtime. A plugin version warning can reach normal activation and completion instead of being stranded before finalization.

This repairs the next update hop driven by this version; installing the candidate cannot patch an already-running 2026.9.5 driver. An installation already left pending by that driver still needs the installed version's openclaw update repair.

Why This Change Was Made

The violated invariant is that, after candidate Doctor advances canonical state beyond the parent's schema contract, only the compatible candidate may reopen that state or finish the update. The Windows Scheduled Task suspension owner retained a callback that checked getUpdateRun() through the old parent. Calling handoff() therefore threw a schema-version refusal before launching the candidate finalizer. All five regression cases failed at that same read before their intended warning, launch-failure, terminal-failure, or changed-service outcome could run.

Remove this redundant history read from the suspension owner. The original live executor fence, caller authority, and native service-identity guards still authorize handoff and compensation. The candidate now receives custody: warning completion is accepted, genuine child failures are reported, and a replaced or changed protected task is still rejected.

Windows disables Scheduled Task autostart and awaits service stop before package replacement and Doctor migration; it enables the task only at candidate activation. Linux/macOS use the same stop-before-mutation barrier and stopped convergence interval, without the Windows autostart handoff callback. The reporter's follow-up confirms the task had stopped: the newer-schema refusal was consistent with the retained updater reopening state, not proof that the old Gateway survived the stop.

Related: the pre-migration snapshot and rollback-restoration decision for #157107/#157077 belongs to L1267. This PR does not add snapshots, reverse migrations, or change rollback policy.

Evidence

Behavior proof and fresh branch review are complete. The changed-file gate passed with the already-merged base fix described below.

  • Five real-ledger schema-refusal regressions fail on the original owner and pass with the repaired owner. The Windows-shaped fixture adapts native filesystem transport and mocks the candidate worker; it proves handoff/result acceptance, not a real Windows Gateway restart.
  • Four focused files / 124 tests passed three times on Blacksmith Testbox: 63.04 s, 54.25 s, and 49.33 s command wall. The changed regression's five cases totaled 1.155 s, 1.815 s, and 1.397 s of test time.
  • Windows CI inventory retains the regression exactly once across five jobs. Approved timing-baseline bump: new Windows suspension/handoff fixtures put two shards at up to 419.4 s raw (420 s rounded), so the inventory assertion now requires predictions below 425 s. The planner algorithm, its 420 s placement target, and coverage checks are unchanged. The three requested tooling suites passed 56 tests three times (3.65 s, 3.22 s, 3.35 s command wall); fresh check:changed passed.
  • Windows-selected tests plus the CI planner contract: 311 passed, 147 expected platform skips, zero failures across 19 test shards on the Linux Testbox (221.23 s command wall). Native Windows-only cases were deferred to the Windows CI job; exact-head native proof is recorded below.
  • Real Linux managed-update rig, pre/post (source a3a4e23cb009b66b406515fe606f2e80769f9921, verified by Crabbox; artifact metadata records its synthetic source-capsule commit): both variants passed published 2026.9.5 → fixture candidate → next fixture version; all four hops exit 0, running build/version matched, readyz and channels ready, settled=true, no plugin errors, no repair entries, and zero transaction residue. PIDs: baseline 618 → 4422 → 11256; repaired 618 → 4422 → 11290. Mock inference requests: 0. The harness relabels only fixture package versions to force both hops. Blacksmith run.
  • Canonical baseline/repaired package builds passed; their unchanged UI size diagnostics remained warnings. No budget or baseline was modified.
  • Fresh autoreview --mode branch --base origin/main: scoped-clean through P2.
  • The previously measured 264.055 s update-cli.test.ts monolith is covered by the coordinator's explicit timing ruling and the split in test(cli): split and speed up update-cli tests #157018; its 515 cases passed. All 36 direct/one-barrel importer files passed: 1,521 tests, including 817 tests in the 30 resumed files (485.09 s command wall).
  • check:changed initially passed all typecheck/guard/dead-export steps, then hit the unchanged 704-line agent-run-registry.ts against its 700-line cap. The owning fix is already merged in refactor: share active run state precedence #157168 (92635da29126). The complete check then passed (exit 0, 36m24s) with that exact upstream patch applied only in the disposable Testbox copy; no suppression, baseline, or PR source change was made for it. This qualification includes all core/test typecheck shards, core/script lint, schema guards, and runtime import-cycle checks. Check Testbox run.
  • Exact-head native Windows proof: checks-windows-node-test-3 passed on 740da0fbe77f551ad33be7400d637faff96c5746. All five regression cases executed and passed: plugin warning 1.092 s, launch failure 1.187 s, failed terminal result 0.995 s, replaced task 1.476 s, changed protected task 1.353 s (6.103 s total case time; containing CLI shard 16.09 s). check-lint-core-1 also passed on that head. The preceding push exposed a no-shadow diagnostic in the new closure assertion; the final commit only renames its callback parameter, with single-file lint and fresh P2 autoreview clean. Auto-merge remains off.
  • Native Windows follow-up: the first Windows job failed all five cases only during cleanupTempDirs with EPERM; none of the handoff assertions failed. The fixture retained an idle SQLite coordinator beneath its temporary Windows home. It now uses the existing coordinator runtime scope with keepAlive: false, and checks that its real SQLite handles have closed before directory cleanup. Production code and the original handoff assertions are unchanged.
  • Before the fixture repair, the new handle-closure assertion failed in all five platform-emulated cases with one real open coordinator handle each. Afterward, all five passed: 24.27 s command wall, 21.11 s Vitest duration, 2.462 s total case time. This is platform-emulated proof; native Windows CI is recorded separately below. Fresh fixture autoreview: scoped-clean through P2.
  • Per-case verdicts: launch failure preserves the child-launch rejection; failed terminal result still uses the candidate response's exit code and leaves the task suspended; replaced task preserves the replacement and refuses compensation; changed protected task preserves the definition-identity refusal. None requires a ledger reread or a change to old-behavior expectations. The plugin-warning case had the same teardown failure.
  • Production: +3/-12 lines; tests: +229/-127 (including formatter indentation for the fixture scope); docs: +8/-0; CI selection: +1/-1. No schema, dependency, or option changes.

@clawsweeper

clawsweeper Bot commented Sep 24, 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 size: S labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 4:21 PM ET / 20:21 UTC (Revision 7).

ClawSweeper review

What this changes

The branch changes Windows update handoff after state migration, adds five regression scenarios and Windows CI selection, and documents recovery for updates driven by older versions.

Regression provenance

Possible regression — suspected (failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: current main still contains the source-backed Windows update failure, and this PR addresses that path. Merge readiness remains blocked by the previously requested real Scheduled Task activation and failure-compensation proof.

Priority: P0
Reviewed head: af7436e1209f854826c5da4637e5bc42409ab6ff

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair and regression coverage are useful, but the claimed Windows service outcome still lacks real task proof.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The repository state marks the author as MEMBER, so the ordinary external-contributor proof gate does not apply. The changed Windows handoff has real-ledger regression cases and a reported real Linux update run, but no observed real Windows Scheduled Task successor update or failed-finalizer compensation; that platform proof remains a repository merge risk. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state marks the author as MEMBER, so the ordinary external-contributor proof gate does not apply. The changed Windows handoff has real-ledger regression cases and a reported real Linux update run, but no observed real Windows Scheduled Task successor update or failed-finalizer compensation; that platform proof remains a repository merge risk. No stored-data contract changes.
Evidence reviewed 9 items Current main still has the old-runtime read: The fetched main revision checks the update-run ledger from the retained Windows updater during task handoff; that read can encounter the newer schema described in the report.
Introduced production change: The pinned merge-base-to-head patch removes that ledger read while retaining the caller and live executor checks in the handoff callback.
Live authority remains in the path: The callback checks the retained executor; the Windows recovery owner checks its guard before task restoration, and the migrated finalizer checks its original executor before handing off.
Findings None None.
Security None None.

How this fits together

The update CLI stops a managed Gateway, installs the new OpenClaw build, and passes finalization to that build. On Windows, a suspended Scheduled Task must remain under update custody until activation or failure compensation finishes.

flowchart LR
A[Update request] --> B[Inspect managed Gateway]
B --> C[Stop Gateway and suspend task]
C --> D[Install build and migrate state]
D --> E[Check live update authority]
E --> F[Candidate finalizer]
F --> G[Activate task or compensate failure]
Loading

Before merge

  • Resolve merge risk (P1) - A patched-driver update has not been shown using a real Windows Scheduled Task to activate the candidate and reach Gateway readiness, or to compensate the task after a failed finalizer. The Windows regression fixture mocks those final effects.
  • Complete next step (P2) - Capture a patched-driver Windows successor update using a real Scheduled Task, showing candidate activation and Gateway readiness, and an isolated failed-finalizer run showing safe task compensation.
Agent review details

Security

None.

PR surface

Source -9, Tests +102, Docs +8, Config 0. Total +101 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 12 -9
Tests 2 229 127 +102
Docs 1 8 0 +8
Config 1 1 1 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 241 140 +101

Review metrics

Metric Value Why it matters
Windows final-effect proof 5 fixture scenarios; 0 real Scheduled Task updates shown The native Windows CI cases execute the fixture, while the remaining merge question concerns actual task activation and compensation.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #157077
Summary: This PR is a candidate repair for the reported Windows migration handoff; the separately reported macOS catalog and rollback behavior is not established as the same cause.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Prove the Windows handoff (recommended)
    Capture an isolated patched-driver successor update with real Scheduled Task activation and Gateway readiness, plus a failed-finalizer run showing safe task compensation.

Technical review

Best possible solution:

Keep the live executor as the handoff authority and verify, on an isolated real Windows Scheduled Task installation, that the candidate reaches readiness and that a failed finalizer leaves the task safely recoverable.

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

Yes, the source gives a high-confidence failure path: after a newer schema is published, the old Windows handoff callback reads the update ledger through the retained runtime. The five regression cases exercise that refusal, though this review did not run them.

Is this the best way to solve the issue?

Yes, removing the incompatible read from the suspension owner is a narrow repair, and the live executor and service-identity checks remain. A real Windows handoff is still needed to establish the claimed end-to-end outcome.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The reported published update left a managed Windows Gateway unavailable until terminal-based repair.
  • merge-risk: 🚨 availability: An unproven Scheduled Task handoff could leave the Gateway stopped after migration if activation or compensation fails.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 repository state marks the author as MEMBER, so the ordinary external-contributor proof gate does not apply. The changed Windows handoff has real-ledger regression cases and a reported real Linux update run, but no observed real Windows Scheduled Task successor update or failed-finalizer compensation; that platform proof remains a repository merge risk. No stored-data contract changes.

Evidence

What I checked:

  • Current main still has the old-runtime read: The fetched main revision checks the update-run ledger from the retained Windows updater during task handoff; that read can encounter the newer schema described in the report. (src/cli/update-cli/update-command-service-maintenance.ts:455, 6b4595575af2)
  • Introduced production change: The pinned merge-base-to-head patch removes that ledger read while retaining the caller and live executor checks in the handoff callback. (src/cli/update-cli/update-command-service-maintenance.ts:445, af7436e1209f)
  • Live authority remains in the path: The callback checks the retained executor; the Windows recovery owner checks its guard before task restoration, and the migrated finalizer checks its original executor before handing off. (src/cli/update-cli/update-command-service-maintenance.ts:227, af7436e1209f)
  • Regression coverage boundary: The five cases use a real SQLite schema refusal, but replace the candidate process and Scheduled Task operations with mocks. They do not observe a real task activation or Gateway readiness. (src/cli/update-cli/update-command-migrated-windows.test.ts:37, af7436e1209f)
  • Prior review proof request persists: The completed prior review requested a patched-driver Windows successor update with real task activation, Gateway readiness, and failed-finalizer compensation. No production or regression-test source changed between that reviewed head and this head. (a9d2f04d61b2)
  • Reporter activation timeline: The reporter says the Windows task stopped before replacement, then recovery stayed pending after a plugin warning; manual update repair completed plugin convergence. A later macOS contention report explicitly cautions against treating its cause as proven identical.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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.

  • Capture real Windows Scheduled Task successor-update readiness and failed-finalizer compensation evidence.

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 (6 earlier review cycles)
  • reviewed 2026-09-24T12:18:17.020Z sha a3a4e23 :: blocked before merge. :: none
  • reviewed 2026-09-24T12:32:51.503Z sha a3a4e23 :: blocked before merge. :: none
  • reviewed 2026-09-24T13:39:00.853Z sha 6bcca8e :: blocked before merge. :: none
  • reviewed 2026-09-24T13:55:25.834Z sha 740da0f :: blocked before merge. :: none
  • reviewed 2026-09-24T14:06:53.794Z sha 740da0f :: blocked before merge. :: none
  • reviewed 2026-09-24T18:32:08.713Z sha a9d2f04 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review September 24, 2026 12:24
@steipete
steipete enabled auto-merge (squash) September 24, 2026 12:31
@steipete
steipete disabled auto-merge September 24, 2026 13:04
@steipete steipete closed this Sep 24, 2026
@steipete steipete reopened this Sep 24, 2026
@clawsweeper clawsweeper Bot added 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 24, 2026
@steipete
steipete enabled auto-merge (squash) September 24, 2026 13:59
@steipete
steipete disabled auto-merge September 24, 2026 17:18
@steipete
steipete force-pushed the upd/windows-plugin-convergence-recovery-pending branch from 740da0f to a9d2f04 Compare September 24, 2026 18:24
@steipete
steipete enabled auto-merge (squash) September 24, 2026 18:26
@steipete
steipete merged commit 2f4fae3 into main Sep 24, 2026
238 checks passed
@steipete
steipete deleted the upd/windows-plugin-convergence-recovery-pending branch September 24, 2026 20:32
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…57262)

* fix(update): finish Windows updates after state migration

* test(update): release Windows fixture coordinators before cleanup

* test(update): avoid shadowing migration database in cleanup assertion

* test(ci): allow small Windows fixture timing overage
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: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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.

Windows update 2026.9.5 to 2026.9.6 strands schema 18 state and requires manual repair

1 participant