Skip to content

fix: restore gateways left stopped by interrupted updates during repair - #186328

Closed
steipete wants to merge 1 commit into
mainfrom
codex/issue-164800-repair
Closed

steipete wants to merge 1 commit into
mainfrom
codex/issue-164800-repair

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw update repair can wait 45 minutes after both managed-update owners have died, then finish successfully while leaving the Gateway that the interrupted update stopped offline.

Refs #164800 (repair backstop, items 3 and 4).

User Impact

Repair can reclaim a handoff immediately when every recorded owner is positively dead. After successful finalization, it starts and verifies the managed Gateway only when the recovered update recorded stopping it without a later successful start. Operator-stopped Gateways stay stopped; named data risks, lost ownership, and live or unverified descendants still prevent unsafe recovery.

Why This Change Was Made

The grace check in src/infra/update-managed-service-handoff-cleanup.ts:93 used elapsed time even after reclamation had established owner death. It now distinguishes positively dead owners from unknown custody while retaining the descendant census and transactional ownership checks. The separate reboot flag retains its existing census meaning.

Standalone finalization previously always returned restart: false (src/cli/update-cli/update-command-finalize.ts:526 on the base). Repair now consumes the existing service-stop step and restart/verification facts, finalizes first, then restores through the existing installation executor, native service lock/start, and readiness machinery. It records health in both the recovered run and repair run and reports the result in human and JSON output. Failures direct operators to openclaw gateway status --deep.

No new stop-time fact or schema is needed. Repair records completed service-start or service-running steps in the active repair run before awaiting readiness. These retained facts survive thrown errors and later stopped health snapshots; ordinary step writes cannot mutate terminal original runs. Later repair retries readiness on a running service and leaves a subsequently stopped Gateway stopped. A blanket restart of every stopped service was rejected because it would override operator intent. Treating positively dead parents as the reboot flag was rejected because that would weaken descendant inspection. Keeping the grace for proven-dead owners would preserve the original outage.

Evidence

  • Red proof against the unchanged base: all four selected regressions failed as expected (three grace refusals and finalization without Gateway start/verification).
  • Green proof: 156 tests passed across handoff recovery, repair service, repair handoff, repair command, repair history, finalization refusal, and finalization lifecycle suites. Commands use node scripts/run-vitest.mjs with --maxWorkers=1.
  • The first six-file run passed 128/129; its one failure was an existing test that expected fresh, proven-dead custody to remain blocked by grace. The fixture now uses an unverified descendant, and its targeted rerun passes. The separately selected lifecycle suite passed 20/20.
  • Additional review regressions reproduced lost readiness settlement and a repeated native start after a thrown readiness wait; both were red before their fixes. The final service suite covers all 15 service/retry cases.
  • node scripts/run-tsgo.mjs passed for tsconfig.core.json and test/tsconfig/tsconfig.core.test.cli-update.json. Targeted oxlint, oxfmt --check, docs MDX sanity, and git diff --check passed.

The CLI regressions invoke registered repair, real finalization, and the SQLite ledger, with synthetic host service/readiness responses and the existing Doctor/plugin fixture. The live Linux/systemd SIGKILL reproduction has not been rerun here; combined-lane validation remains necessary.

Final isolated Codex autoreview: scoped-clean, no actionable P0–P2 findings. Accepted review findings about readiness retries, thrown probes, and overwritten liveness evidence were fixed and covered by repair-boundary tests. Startup evidence is retained in the active repair run rather than attempting to append ordinary steps to a terminal original run.

Diff against the base: production +283/-7 (net +276), tests/harness +339/-25 (net +314), docs +38/-11 (net +27). The production growth is the missing restart orchestration; it reuses existing ownership, service, readiness, and ledger owners rather than adding a persistence mechanism. The simplification pass kept one history-based restoration decision, reused the existing fences, and replaced the obsolete grace expectations.

Let repair bypass custody grace for positively dead owners while preserving descendant checks. Restore gateways stopped by interrupted managed updates, retain startup evidence across readiness failures, and preserve later operator stops.

Refs #164800.
@clawsweeper

clawsweeper Bot commented Oct 27, 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: L labels Oct 27, 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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The PR removes unnecessary recovery grace for proven-dead update owners and restores Gateways stopped by interrupted updates after successful repair.

Example: A Linux systemd managed update is killed after stopping the Gateway, and both update owners are confirmed dead.

  • Before: Repair can require a 45-minute wait and then finish without restarting the Gateway.
  • After: Repair can reclaim custody immediately, finish maintenance, and start and verify the update-stopped Gateway.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The repair direction and focused regressions are useful, but the startup-receipt defect and missing upgrade compatibility evidence prevent approval.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: An interrupted managed update leaves the Gateway offline even after repair reports completion.
Reason: The maintainer-authored direction addresses a reproduced availability failure while preserving explicit data-risk refusals and operator stops; the linked issue also contains separate unresolved stalls.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this maintainer-authored PR addresses a verified recovery outage, but its startup evidence can be silently dropped, allowing a later repair to restart an intentionally stopped Gateway.

Priority: P0
Reviewed head: cba5693c4a2e3335bae5afd4b048d547967c6bd4

Before merge

  • Persist startup evidence as a required recovery receipt (P2) - These completed service-start/service-running steps are ordinary bookkeeping under isRequiredUpdateRunStep. If the history database stays locked for its one-second bookkeeping timeout, recordUpdateRunStep returns undefined and this code continues without recording the successful start. If readiness then fails or throws and the Gateway is stopped, subsequent repair finds no startup evidence and starts it again, defeating the operator-stop protection this change promises. Use a required recovery receipt and confirm persistence before relying on it for retry decisions, with a contention regression through repair.
  • 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

  • [P2] Persist startup evidence as a required recovery receipt — src/cli/update-cli/update-repair-service.ts:162-169

Tests

  • Missing end-to-end proof: The supplied red/green regressions do not show the fixed CLI recovering a real systemd Gateway after updater SIGKILL or preserving existing settings and data through a latest-stable upgrade.
Agent review details

How this fits together

Update repair reads persisted update history and process custody, runs Doctor and plugin finalization, and uses the existing installation executor and native service owners to restore and verify the Gateway.

flowchart TD
  A[Update repair CLI] --> B[Process and custody checks]
  B --> C[Doctor and plugin finalization]
  C --> D[Update history stop decision]
  D --> E[Installation and native service owners]
  E --> F[Gateway readiness verification]
  F --> G[History and repair outcome]
Loading

Technical review

Best possible solution:

Keep explicit repair as the recovery owner, persist startup receipts reliably, verify native readiness, and make recovery accessible through a visible command launcher.

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

The linked maintainer reproduction and current-main grace/finalization paths establish the recovery failure; this read-only review executed no target code and does not establish the original activation-stall trigger.

Is this the best way to solve the issue?

Explicit repair is a justified recovery owner and reuses existing custody, service selection, and readiness machinery, but restart decisions must not depend on a history write that can silently fail.

Full review comments:

  • [P2] Persist startup evidence as a required recovery receipt — src/cli/update-cli/update-repair-service.ts:162-169
    These completed service-start/service-running steps are ordinary bookkeeping under isRequiredUpdateRunStep. If the history database stays locked for its one-second bookkeeping timeout, recordUpdateRunStep returns undefined and this code continues without recording the successful start. If readiness then fails or throws and the Gateway is stopped, subsequent repair finds no startup evidence and starts it again, defeating the operator-stop protection this change promises. Use a required recovery receipt and confirm persistence before relying on it for retry decisions, with a contention regression through repair.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Managed-handoff recovery grace changes intended behavior with a stated reason (9680e57: Conservative explicit reclamation required owner death, descendant census, rollback checks, and elapsed grace; later work added prior-boot settlement.)
  • Standalone repair service activation changes intended behavior with a stated reason (48447a6: Repair restoration remained with the maintenance parent, and fix(update): report when repair leaves an already stopped Gateway offline #157134 documented leaving previously stopped services offline.)
  • Cancelled-custody settlement keeps the original intent (45314c9: Explicit repair settles dead cancelled custody through transactional claims and durable settlement receipts while retaining unsafe families.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-vitest.mjs src/cli/update-cli/update-repair-service.test.ts src/cli/update-cli/update-repair-command.test.ts src/cli/update-cli/update-repair-handoff.test.ts src/infra/update-managed-service-handoff-recovery.test.ts --maxWorkers=1
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --noEmit
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.cli-update.json --noEmit
  • git diff --check
  • Replay isolated Linux systemd/npm-global update.run interruption, repair, readiness failure, operator stop, and retry; verify settings and data remain intact when upgrading from v2026.10.8.

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 48447a6 adds src/cli/update-cli/update-command-finalize.ts:274 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 48447a63c6d1; files: src/cli/update-cli/update-command-finalize.ts)
  • Jason (Json): Raw commit 45314c9 adds src/infra/update-managed-service-handoff-reclamation.ts:347 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 45314c992e24; files: src/infra/update-managed-service-handoff-reclamation.ts)
  • Dallin Romney: Raw commit 8346eba adds src/cli/update-cli/update-command-finalize.ts:410 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 8346eba79034; files: src/cli/update-cli/update-command-finalize.ts)

PR surface

Source +276, Tests +314, Docs +27. Total +617 across 12 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 283 7 +276
Tests 4 339 25 +314
Docs 2 38 11 +27
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 660 43 +617

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The linked production reproduction shows an in-product managed update leaving the core Gateway unavailable, with recovery requiring terminal commands or reboot.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 27, 2026, 5:46 PM ET / 21:46 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Superseded by #188497, which consolidates this draft and its sibling onto current main and adds the live Crabbox proof.

@steipete steipete closed this Oct 30, 2026
@steipete
steipete deleted the codex/issue-164800-repair branch November 2, 2026 06:30
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 P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant