Skip to content

fix: keep stable updates and recovery free of premature migrations - #196474

Merged
RomneyDa merged 4 commits into
mainfrom
fix/update-stable-migration-recovery
Nov 10, 2026
Merged

RomneyDa merged 4 commits into
mainfrom
fix/update-stable-migration-recovery

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Related: #196371, #196342, #196350. Builds on already-merged #193885.

What Problem This Solves

Fixes stable upgrades failing during rollback preparation before candidate Doctor can migrate credentials, and recovery failing while merely restarting the unchanged Gateway.

User Impact

The updater reserves rollback state without prematurely migrating credentials, then captures the settled database generation before Doctor. Its own bookkeeping no longer invalidates that snapshot. A plain service start or restart no longer requires unrelated runtime-pin migration. Failed activation reports a valid recovery result instead of crashing on a leftover version field.

No new configuration or migration is introduced. Backed-up Doctor still owns credential migration; service-definition rewrites retain their runtime-intent safeguards. These fixes must be in the installed updater: downloading a candidate cannot retroactively change an old driver's initial behavior.

Why This Change Was Made

Use the existing schema-preserving lifecycle lease and existing unsafe-recovery constructor. Capture databases after plugin reservation settles, rather than treating those known writes as an unknown source change. Remove runtime-pin migration from unchanged start/restart operations, which do not consume that metadata. After Doctor completes runtime-pin migration, capture the migrated intent before the existing native service rewrite. Remove stale branches that forced activation back to the old installation against newly migrated state, and their misleading deferred-repair warning. No new owner, fallback loop, or state machine.

The production diff removes 22 net lines. Regression coverage adds 95 net test/support lines, including a mechanical credential-fixture helper extraction to keep the existing credential suite within its file-size limit. The scoped allocation covers legacy credential reservation, recovery-schema validity, and unchanged start/restart behavior.

Evidence

  • Credential-bearing legacy schema regression failed with the original custody error, then passed without changing source rows/schema or creating the local credential store.

  • Unchanged start/restart regressions failed before the fix because runtime-pin migration ran unexpectedly.

  • Recovery regressions reproduced the invalid version field against the real result schema. The initial combined regression wrapper also detected a source change; this is not claimed as a clean full-suite baseline run.

  • Final focused validation before the ordering repair: 101 passed / 5 existing skips across original-service recovery, credential migration, runtime pins, and plugin cohort recovery; Gateway restart consumers also passed 21 tests.

  • Native upgrade then reproduced SQLite migration source changed after update capture. The strengthened test now exercises the actual rollback-capture owner: red before reordering, green after. Credential suite: 10 passed / 5 existing skips; after mechanical fixture extraction, the three affected migration/capture cases passed again.

  • Core, CLI-update, infra and services typechecks; scoped lint/format; diff and test-line budget checks passed.

  • Independent AutoReview of the additional ordering patch: scoped-clean at P0–P2, no actionable findings. Final local ClawSweeper reviewed 21f17afce911a364138fa29fb10e20bffe15a3eb..078feaa62350bcd75203f2f11963e708fb60a50e: complete, no findings, patch correct (0.88). Both were source reviews, not runtime proof.

  • The next native run completed Doctor migration but exposed stale pre-migration runtime-pin routing: it restarted old A, which refused the newer state schema. The revised activation regression fails on 078feaa62350 and passes after removing that forced-A route. Independent AutoReview of this additional patch: scoped-clean at P0–P2, patch correct (0.84); source-only review, no runtime claim. The corrected activation is covered by the combined native evidence below.

  • Final activation regression rerun: 3 passed (45 cases filtered); core/CLI-update typechecks, scoped lint/format, and test-line budget passed. The broader original-service run had 48 passing assertions, but its wrapper rejected a concurrent mechanical source cleanup; it is not claimed as a clean final-source suite run. The final regression rerun used frozen source.

  • An accidentally broad lint invocation found file-length errors in 24 files, all byte-identical to this PR's base; scoped lint of the changed files passed. Those unrelated errors are not suppressed by this PR.

  • Affected restart/service consumers passed 117 tests / 7 existing skips across restart preparation, service activation, and real-process integration.

  • Final local ClawSweeper reviewed 21f17afce911a364138fa29fb10e20bffe15a3eb..fb9cdfe3badbcd86ceb09f1beae0e87132ba36aa: complete, no actionable correctness/security findings, patch correct (0.87). Source-only review; native proof is recorded separately.

Combined native verification

Native Linux/systemd (PID 1, Node 24.22.1) proof used the three companion fixes together on focused Testbox run 42765103716.

  • Stable 2026.11.2 Gateway/state at A upgraded successfully through fixed driver B: actual update exit 0/status ok, effective launcher moved to B, PID changed, candidate serving build matched, and authenticated RPC plus health/readiness passed.
  • Sessions, approvals, and workspace survived. The environment-only drop-in remained byte-identical, remained effective in systemd and the running process, and was not copied into the managed base. No manual post-update restart or repair.
  • The fixed CLI also restarted the unchanged stable service successfully before upgrading it.
  • Package build and integrity checks passed. Upgrade-stage package SHA-256: 3b0757080aedfec5b322c2241fe9fc67237698ca08bbefb321f0537ee8208975; frozen combined source tree: 77289499c424e1ab9162b12bea7d8f1a6b6f19ab. Production files were reconciled against the PR heads, including the shared activation file.
  • Permission-blocked Doctor was proved separately on fresh candidate state: exact unsafe directory reported, service/drop-in unchanged, no false repair-success claim, and authenticated Gateway health/readiness retained. Disposable services/users/runtime files were cleaned up.

Limits: the fixed driver was bootstrapped into B before the actual upgrade. This is not proof that an unmodified released updater fixes its own first hop. No agent/model inference or external channel round trip was tested. The first combined harness finished with a later Doctor-fixture failure after its upgrade stage passed; the isolated Doctor run then exposed an early launcher-guidance defect. Those full runs are not described as passing. The final launcher-specific proof is recorded separately below.

Final launcher-specific native proof

The final candidate passed package build/integrity and the isolated systemd explicit-launcher Doctor case: override-aware guidance and systemctl cat inspection instructions were present, circular Doctor advice was absent, and both managed base and operator drop-in remained unchanged. Summary flow: native-systemd-explicit-launcher-doctor-guidance; status: passed. Disposable user/runtime cleanup passed.

Package SHA-256: ca1f3b0ea7e9f7532f2b0162e93d16e8bd98dd221779bb8d1f5d89c332f1fdf6; combined source tree: 8dbfb8fad7567c41106d76b766f870b2eb7f8713. This tree differs from the successful stable-upgrade/permission proof only in the early Doctor guidance message; unchanged upgrade and permission results were reused. This final run is a launcher-specific proof, not another stable-upgrade run. Full PR CI remains separate from these focused checks.

CI repair

Declared the runtime-pin fixture’s intentional native launchd isolation and removed its retired mock-export baseline entry. Production bytes are unchanged. The mock-export guard reproduced red before the correction and passes afterward; all 23 runtime-pin service tests pass (13.58s wrapper wall time), with targeted lint, format, test-line budget, and diff checks passing.

@clawsweeper

clawsweeper Bot commented Nov 10, 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 cli CLI command changes size: M labels Nov 10, 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR postpones migrations until Doctor, captures databases after rollback reservation, and repairs service recovery results.

Example: An installed 2026.11.2 updater encounters schema-28 shared credentials while preparing an upgrade.

  • Before: Plugin rollback reservation can trigger credential migration before backed-up custody, or invalidate an earlier database capture.
  • After: Reservation preserves the existing schema, and database capture records its settled writes before Doctor runs.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A small, coherent repair with meaningful owner-boundary regressions and limited completed runtime evidence.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; its reported unchanged-stable Gateway restart covers one path, but the corrected native upgrade run has no completed result or artifact establishing existing-state compatibility.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stable upgrades can fail before candidate Doctor runs, and recovery can fail while restarting the unchanged Gateway.
Reason: The maintainer-authored direction restores existing update and recovery contracts without adding configuration, schemas, or public APIs.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it is a useful maintainer-authored repair for current update and recovery failures, with no introduced correctness defect found.

Priority: P1
Reviewed head: 078feaa62350bcd75203f2f11963e708fb60a50e

Before merge

  • 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: Complete a latest-stable upgrade through the corrected installed updater, preserving settings, credentials, and stored data while verifying activation and failed-activation recovery.
Agent review details

How this fits together

The CLI updater coordinates package activation, plugin rollback records, database backups, Doctor migrations, and managed Gateway recovery.

flowchart TD
  A[Installed updater] --> B[Plugin rollback reservation]
  B --> C[Database capture]
  C --> D[Candidate Doctor]
  D --> E[Package activation]
  E --> F[Managed service recovery]
Loading

Technical review

Best possible solution:

Reserve recovery with the existing schema-preserving lease, capture the settled generation, and keep migrations and service-definition safeguards with their existing owners.

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

Current-main source exposes the premature migration, capture-ordering, and strict recovery-schema failures, supported by reported base-failing regressions and native reproduction; this review executed no target code.

Is this the best way to solve the issue?

The patch repairs the existing owners with minimal production changes, preserves mutation safeguards, and mechanically extracts existing test fixtures without introducing parallel state or recovery machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source -5, Tests +81, Docs +9, Other +1. Total +86 across 10 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 15 20 -5
Tests 4 178 97 +81
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 10 203 117 +86

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.

Review metrics

Metric Value Why it matters
Production versus regression growth Production +15/-20 lines; tests/support +178/-97 lines. Production shrinks while distinct reservation, capture-generation, recovery-schema, and service-activation regressions extend existing suites; most helper additions relocate existing fixtures.

Labels

Label changes:

  • add P1: Stable-upgrade preparation and failed-activation Gateway recovery have concrete native failures.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: Stable-upgrade preparation and failed-activation Gateway recovery have concrete native failures.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

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 10, 2026, 1:17 AM ET / 06:17 UTC.

@RomneyDa
RomneyDa merged commit 930e1f7 into main Nov 10, 2026
127 of 130 checks passed
@RomneyDa
RomneyDa deleted the fix/update-stable-migration-recovery branch November 10, 2026 08:24
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…penclaw#196474)

* fix: keep stable update recovery independent of premature migrations

* fix: capture update databases after rollback reservation settles

* fix: activate the candidate after runtime pin migration

* test: declare runtime pin launchd fixture isolation
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Backport adapted from 930e1f7. Preserve release native service owners and omit absent plugin cohort reservation changes.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 16, 2026
…penclaw#196474)

Release-specific adaptation for 2026.11.4: Select only strict recovery-union repair. Runtime-pin migration and cohort capture portions do not affect this release architecture.

Source commit: 930e1f7
Source PR: openclaw#196474

CI qualification pending; source-only verification completed.

Co-authored-by: RomneyDa <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…aw#194058)

Failed-update triage now captures the operator's environment before managed candidate admission, so a coding agent installed only on the operator's PATH is still offered when the Gateway service's PATH differs. Restores the operator-environment contract from openclaw#134490 and keeps the launch confirmation from openclaw#143139.

Proof: shipped CLI on isolated Linux (Crabbox) with a running systemd Gateway: accept launches the operator-only agent, decline starts nothing, base 18bee8e reports no agent found; published 2026.11.1 upgrades to the fix with settings intact.

Co-authored-by: TorstenW <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: steipete <[email protected]>

(cherry picked from commit 7c702c3)

Release adaptation: Capture invoking operator env before candidate admission, forward to interactive triage only; preserve latest target selectors, confirmation and lease cleanup ordering. Exact three authorized production paths plus real lifecycle regression.

Follow-up dispositions: ad4863d fix: preserve the running installation when an agent updates its Gateway (openclaw#201570); dc73ec0 fix: let updates finish when another tool briefly reads OpenClaw's databases (openclaw#202541); d07b530 fix: clarify PostgreSQL schema upgrades for Git installs (openclaw#202098); e60ea9f test(update): add a Git release upgrade-survivor scenario (openclaw#201956); 2ef6f7b fix(update): build and serve Git releases outside node_modules (openclaw#201917); dbc1aa0 fix: keep the openclaw command and Gateway working after updating a pnpm install (openclaw#201735); f5e7641 fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts (openclaw#201600); 2183caf fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database (openclaw#201463); 47e8649 fix: explain why Doctor cannot restore a scheduled job’s account (openclaw#201550); 8f2cfd4 fix: remove updater-only restrictions from agent maintenance guidance; cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 24cb734 fix: keep carried-over scheduled jobs running after updates (openclaw#200653); d1276e1 feat(doctor): check OpenClaw ID member roles and honor an optional roles default (openclaw#197785); 0a39956 fix: finish updates when another tool reads OpenClaw's databases during the update (openclaw#201330); ea1c9d5 fix(update): settle remounted package publications before admission (openclaw#201336); 66b5212 fix(update): isolate malformed retained-install markers (openclaw#201199); 7e79c83 fix: let the next update finish a killed source checkout update (openclaw#201009); d905d8a fix: let the next update finish a killed update after the machine restarted (openclaw#200994); fdf0c95 fix: let the next update finish a killed update that had already installed the new version (openclaw#200866); 0c19bcd chore(release): close out 2026.11.5 on main (openclaw#200577); a1940e0 fix(matrix): keep explicit recovery available during deferred migration (openclaw#200805); 18b4776 improve: explain package baseline drift during updates (openclaw#200802); 1ad4cad fix(doctor): reclaim macOS updater runtimes blocked by non-updater processes (openclaw#200732); 427c857 fix: keep one missing archived transcript from blocking every update (openclaw#200733); 802e3f7 fix(update): keep valid cold archives from blocking updates (openclaw#200659); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); 3afe212 fix: let Doctor publish unchanged plugin migrations in any order (openclaw#200658); f65e4db fix(doctor): reclaim runtimes blocked by unrelated Linux processes (openclaw#200657); dab086c fix(update): let candidate Doctor read plugin dependencies from the staged package (openclaw#200595); 3447bee fix(update): keep updates going when the predecessor writes during its stop (openclaw#200569); 0ce9c77 fix: let the next update settle a package publication that a killed update left behind (openclaw#200550); ae31ea3 fix(update): repair handoffs in the journal-pinned lease store (openclaw#200532); 74020ea fix: continue updates when initial SQLite capture is stale (openclaw#200328); 6747b1e feat(update): run Git checkout installs from releases behind the release link (openclaw#199706); e3f8a67 fix(state): keep completed retained agent stores out of startup upgrade (openclaw#200284); 3c512c5 fix(gateway): move managed update lease operations off the main thread (openclaw#200169); ea69fcb chore(release): close out 2026.11.4 on main (openclaw#199956); 618bf31 fix(state): bound startup upgrade copies and pruning to owned state (openclaw#199929); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); 5dbf569 fix(update): plugin failures never fail an update or Gateway health; 764761e fix(update): refuse missing host prerequisites in one line and record a cause per attempt; 4c4fef4 fix(ui): update dialog claims installation before progress is confirmed (openclaw#199254); 136e1f6 fix(update): retrying an update from a dev checkout is refused after a killed update (openclaw#198673); 3bd03da fix(update): avoid duplicate database copies while the Gateway is stopped (openclaw#198148); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); e333f7e chore(ci): drop retired test-lines allocation records (3/3) (openclaw#197657); fd6fa47 fix: converge Gateway updates with environment-only service overrides (openclaw#196371); 7cf5e75 fix: clarify split-install updates and blocked Doctor repairs (openclaw#196342); 6ff8c86 fix(update): retain lazy sqlite catalog generation (openclaw#197095); 930e1f7 fix: keep stable updates and recovery free of premature migrations (openclaw#196474); a15f737 fix: preserve external plugin data during update rehearsal (openclaw#196301); 92798ae fix: updates survive interrupted heartbeat runs (openclaw#195656); c1e55e2 fix(update): restore LaunchAgent registration after repair contention (openclaw#195406); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685); 689cfc8 fix(update): reclaim dead closing triage repair leases (openclaw#194503); 86bc89e fix(doctor): keep standing Codex parameter advice out of retirement blockers (openclaw#193650); 691bc8d fix(backup): read the backup engine without copying the live database (openclaw#194234); 000542f fix(backup): backups and updates fail on slow storage when a header probe batch misses its deadline (openclaw#194239); 31a65d5 fix(update): skip --no-lazy-fetch on Git versions without it (openclaw#194198); e45e99d fix(update): preserve dev update sources in tag-only Git clones (openclaw#193109)

Validation: Baseline2 intended operator-agent failures/32 controls passed; candidate34/34passed (194058-green.log). Accept launches synthetic operator-only CLI with expected env, decline starts nothing. Isolated updater flow, not live systemd/upgrade qualification.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 6689fd575ada8fe40a9593784deac18ec73041cd)
(cherry picked from commit 92e7a9fa223b0dc35801f25f70be90b472d9a6b7)
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 gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant