Skip to content

fix(update): recover migrated Gateways after verification failure - #175890

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1678
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1678

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #175865

What Problem This Solves

After state migration, an unverified activation could leave the installed Gateway stopped and report verifying: exit unknown, package-backup-retention: exit 1, and state-migrated-no-rollback.

User Impact

Recovery can start and verify the installed candidate after normal Doctor completion. Verified activation still succeeds when obsolete backup removal is blocked; its warning now preserves the filesystem cause and retained path. The original verification failure remains visible when recovery cannot establish that the whole update completed successfully.

Why This Change Was Made

A normal, fully settled Doctor often emits no process-settlement step. Forward recovery incorrectly required that step or a database-rollback attempt before it would inspect the candidate schemas. The existing recovery owner now admits that inspection when candidate schema metadata is available, then uses its existing migration check, owned-service restart, and health verification. Failed writer settlement, other named data risks, foreign services, and restored databases retain their existing restrictions.

The package cleanup owner already bounds obsolete backup work and classifies ordinary filesystem errors as maintenance warnings. Its fallback discarded the deletion and rename causes. Both are now included, including EPERM and EBUSY, without adding retries or changing backup custody.

Evidence

  • Before the fix, the new composed regression reproduced all three reported phases and ended stopped-free. Afterward, the same real retained package transaction and finalization path recover and verify the candidate. The focused new case takes 827 ms of test time; the complete invocation took 90.26 s including a 63.1 s runtime build.
  • The new cleanup case injects EPERM during removal and EBUSY during fallback rename. It checks that the candidate and launcher remain active, the old backup remains retained, the persisted run succeeds, and the report includes both causes. The pre-fix run failed because those causes were missing.
  • The published v2026.10.3 driver already records candidateSchemaVersions in update-command-execution.ts and carries it through the existing migrated-worker handoff. No new driver marker or input field is required. This is source compatibility evidence, not a claimed live Windows upgrade.
  • node scripts/run-vitest.mjs <38 importer files in original discovery order> --maxWorkers=2: 858 passed, 37 files passed, one existing file / six tests skipped; exit 0 in 747.52 s. The three runtime groups reported 436 + 260 + 162 passing tests. Exact imports were discovered from the two changed production owners plus their update-command-service / package-update-swap barrels.
  • In the complete run, the new migration case took 413 ms, and the retained-backup case 504 ms. The complete modified files used 22.193 s and 10.639 s of summed test time, respectively.
  • Core and CLI-update test tsgo, type-aware Oxlint on all four TypeScript files, Oxfmt, git diff --check, the line-cap ratchet, MDX validation, and Madge (zero cycles) passed.
  • Independent Codex review: scoped-clean at P0–P2. The simplification pass retains the existing owners and adds no new policy, configuration, schema, dependency, or retry mechanism.
  • Windows native execution was not performed. Proof uses isolated HOME/state, real package swaps and recovery orchestration, with filesystem/service I/O fixtures. The issue's redacted diagnostics do not establish whether Defender, another open handle, permissions, or path length caused the original Windows error.
  • Full check:changed was replaced with the campaign-authorized targeted checks; its SQLite inventory was skipped for time. PR CI supplies broad proof.

Production: +6/-4 (net +2). Tests: +41/-11 (net +30). Documentation: +7/-0. The test growth extends two existing scenario tables to cover the missing recovery and error-reporting contracts.

Existing slow files (summed test time):

  • src/cli/update-cli/update-command-original-service.test.ts: 182.674 s.
  • src/cli/update-cli/update-command-database-rollback.test.ts: 164.438 s.
  • src/cli/update-cli.windows-lifecycle.test.ts: 153.314 s.
  • src/cli/update-cli/update-command-lease.test.ts: 138.372 s.
  • src/cli/update-cli.service-authority.test.ts: 123.326 s.

These unchanged scenarios repeatedly exercise real package/database copies and native-process lifecycle fixtures. The campaign's pre-existing slow-suite exception applies; no timeout, retry, skip, or baseline was changed. CI timings are not yet available.

@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@steipete
steipete marked this pull request as ready for review October 17, 2026 22:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 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-10-17T22:45:49.124175Z f23e14c 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Allow schema-checked Gateway recovery after normal Doctor completion and preserve filesystem causes in backup-cleanup warnings.

Example: Doctor completes normally, databases migrate, and subsequent Gateway verification fails.

  • Before: Recovery rejects the candidate because neither a Doctor settlement receipt nor a database rollback step exists, leaving the Gateway stopped.
  • After: Recovery inspects candidate schemas and can restart and verify the owned Gateway while preserving the original update failure.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is focused and source-consistent, with useful composed regressions; the explicit installed-update acceptance requirement remains unproven.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A failed verification after migration can leave the Gateway stopped even when the installed candidate can safely serve.
Reason: The maintainer-authored direction restores availability through existing recovery owners and improves actionable cleanup diagnostics with minimal change.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it narrowly repairs a current recovery-admission defect, preserves existing safety restrictions, and introduces no identified correctness bug.

Priority: P1
Reviewed head: f23e14cbb7739dab4729637a849ab51dc9a7751d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied tests do not exercise the documented published-driver × candidate recovery cell with a real managed Gateway and preserved migrated state.
Agent review details

How this fits together

The update finalizer consumes package, migration, and stopped-service observations, then coordinates safe recovery and publishes durable update outcomes.

flowchart TD
A[Update finalizer] --> B[Recovery admission]
B --> C[Candidate schema inspection]
C --> D[Owned service restart]
D --> E[Readiness verification]
A --> F[Package backup cleanup]
E --> G[Update report]
F --> G
Loading

Technical review

Best possible solution:

Retain this focused recovery fix and diagnostic improvement, with acceptance through the existing published-driver update boundary.

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

Source establishes that normal Doctor completion without settlement or rollback steps rejects recovery despite available candidate schemas; the author reports a failing-before/passing-after composed regression, which was inspected but not executed.

Is this the best way to solve the issue?

The patch is the smallest complete repair for the demonstrated admission defect: it reaches existing schema and service owners while preserving their restrictions, and uses the existing error formatter for cleanup diagnostics.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit d69a5e7 adds src/infra/package-update-filesystem.ts:473 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d69a5e74895c; files: src/infra/package-update-filesystem.ts)

PR surface

Source +2, Tests +30, Docs +7. Total +39 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 6 4 +2
Tests 2 41 11 +30
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 54 15 +39

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +6/-4; tests +41/-11 The modest growth extends existing scenarios for receipt-free recovery and retained-backup diagnostics without adding production machinery.

Labels

Label changes:

  • add P1: The addressed update failure can leave an installed Gateway stopped after migration.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The addressed update failure can leave an installed Gateway stopped after migration.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Supply the documented published-driver × candidate recovery evidence through a real managed Gateway.

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 October 17, 2026, 6:59 PM ET / 22:59 UTC.

@steipete
steipete merged commit 104dc5a into main Oct 17, 2026
213 of 215 checks passed
@steipete
steipete deleted the upd/upd-l1678 branch October 17, 2026 23:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…enclaw#175890)

After an update migrated state and activated the new package (state-migrated-no-rollback), a later failure such as package-backup-retention left the Gateway stopped (stopped-free): final recovery required a Doctor settlement receipt, which a normal Doctor completion may omit, so it never reached the candidate schema check. Recovery now admits that case through the existing candidate schema inspection, restarts the owned Gateway on the migrated candidate and verifies it. Backup-retention warnings now include the underlying filesystem cause (e.g. EPERM/EBUSY).

Fixes openclaw#175865
RomneyDa added a commit that referenced this pull request Nov 10, 2026
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]>
RomneyDa added a commit that referenced this pull request Nov 10, 2026
* fix(update): backport managed recovery to 2026.11.2

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]>

* fix(update): retain manual guidance for nonowned services

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]>

* fix(update): retain terminal outcomes after post-core failure

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]>

* test(update): keep the raw-recovery guidance fixture off the legacy migration 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.

* fix(update): read interrupted-update history after a candidate schema 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.

* test(update): port recovery expectations for the managed recovery backport

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.

* fix(update): report unrestored Gateways as repair warnings

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.

* fix(update): recheck stop authority before recovery startup

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]>

* fix(update): retain repair stop authority through native startup

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]>

* test(update): preserve native authority mock exports

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]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: Dallin Romney <[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 docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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.

Update failure: gateway-recovery-verification (2026.10.3)

1 participant