Skip to content

fix(update): settle recovery when the handoff lease database is missing - #165238

Merged
steipete merged 1 commit into
mainfrom
upd/upd-recovery-lease-db-missing-enoent
Oct 5, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-recovery-lease-db-missing-enoent

Conversation

@steipete

@steipete steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes openclaw update repair failing with update-recovery-pending when a reboot or temporary-filesystem cleanup removes the recorded handoff lease database.

Closes #164254. Thanks @Hensarj and @dawid-sitko for the reports and diagnostics.

User Impact

Repair from a CLI containing this fix recreates the missing coordination store through its existing owner, closes the orphaned package operation as recovery-lease-missing, and admits the next update. It retains recovery evidence and leaves the installed package and launchers intact. Another live update owner still prevents settlement.

Repair then reaches the existing Doctor/plugin-convergence flow. Deferred migration warnings clear only when the plugin owners complete their work; this does not claim that all migrations on the reporters' installations have been verified. An older installed updater needs the documented manual installation hop before using the new repair.

Why This Change Was Made

The replacement recovery added in #164849 captures the current database identity before acquiring its recovery fence. A missing file throws ENOENT before that settlement can begin. This extends the same package-custody owner and completion receipt handling, without a second recovery path or a SQLite schema change.

Linux can reuse the deleted database's inode. The recorded missing-lease intent therefore survives an interrupted archival attempt, so retrying cannot mistake the recreated store for the original authority. Fresh executor ownership still fences every custody change; dangling symlinks and unrelated filesystem errors are not treated as an absent store.

Evidence

  • Pre-fix public repair-command fixture: replaced database passes; deleted database fails with ENOENT in settlePendingPackageActivation (12 passed, 1 failed). The cold macOS run took 365.81 seconds, dominated by transformation; compiled-worker preparation alone took 165.03 seconds.
  • Blacksmith Testbox tbx_01m44q9bttxqyejs1ad0ycdvve, run environment: candidate HEAD and all seven changed file checksums verified before execution, with isolated OPENCLAW_STATE_DIR.
  • pnpm test src/cli/update-cli/update-repair-package-activation.test.ts --maxWorkers=1, three runs: 16/16 passed each. Runner wall time: 21.81 / 9.05 / 8.94 seconds; measured test work: 2.209 / 2.247 / 2.278 seconds. Covers missing/replaced stores, retained artifacts, next preparation, live-owner refusal, interrupted archival with deterministic inode reuse, and dangling-symlink refusal.
  • All 31 files selected by rg -l 'package-update-activation' --glob '*.test.ts' src extensions packages test, plus update-command-resume-completion.test.ts and doctor-config-preflight.plugin-deferral.test.ts: 527 passed, 13 existing platform-specific cases skipped, 273.24 seconds across five routed shards. The skips require Linux root or macOS; no test was added to a skip list. The registered update repair Doctor continuation and plugin-owned data migration fixtures pass. No reporter live state or Raspberry Pi was used.
  • Independent Codex P1 review: scoped-clean, no accepted/actionable P0/P1 findings. The managed review completed through the configured API route after diagnosing a local CLI history-backfill startup stall; sandbox controls remained enabled.
  • node scripts/check-changed.mjs --base 678572811dd8b10c19ee69e2107947d099dd33c1: exit 0 on the same Testbox (22m47.401s), including core types, all 27 core test type graphs, lint, and ownership/storage guards. The explicit base avoids the hydrated Testbox's stale origin/main selecting unrelated changes. Local changed-file formatting and git diff --check also pass. The repository source-snapshot wrapper stalled before allocation; the installed Crabbox CLI used the same Testbox provider, with a frozen-lockfile dependency install and per-file source checksums.

Production: +45/-8 lines; tests: +57/-8; documentation: +9/-0. No production module was added or removed.

Recreate an absent handoff coordination store through its existing owner,
then settle obsolete package custody as recovery-lease-missing under a
fresh executor fence. Preserve recovery evidence and completed receipts,
including interrupted archival when a recreated file reuses its old inode.

Keep live-owner and unsafe-path refusals intact. Extend the public repair
fixture and document the existing Doctor migration continuation.

Reported by @Hensarj and @dawid-sitko in #164254.
@clawsweeper

clawsweeper Bot commented Oct 5, 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 Oct 5, 2026
@steipete
steipete marked this pull request as ready for review October 5, 2026 01:09
@clawsweeper

clawsweeper Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 4, 2026, 9:16 PM ET / October 5, 2026, 01:16 UTC.

ClawSweeper review

What this changes

The PR lets update repair recreate a missing coordination database, archive orphaned package recovery safely, and permit another update.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

The missing-database recovery is still needed on current main. The patch addresses the reported failure, but two interruption cases can leave recovery blocked, and published-updater compatibility evidence remains incomplete.

Priority: P0
Reviewed head: 16a4b863a462e8b050ded98c9b8f8ac5f36f4fdc

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair and substantial boundary validation are useful, but interruption defects and incomplete upgrade evidence prevent a merge-ready rating.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts ordinary contributor runtime proof. Reported Testbox fixtures exercise the repair entrypoint and real lease/journal/filesystem owners, with finalization mocked; they do not cover the two identified retry windows. Independently, the new persisted intent lacks the required published-driver missing-store compatibility cell.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts ordinary contributor runtime proof. Reported Testbox fixtures exercise the repair entrypoint and real lease/journal/filesystem owners, with finalization mocked; they do not cover the two identified retry windows. Independently, the new persisted intent lacks the required published-driver missing-store compatibility cell.
Evidence reviewed 10 items Pinned introduced change: Reviewed the complete merge-base-to-head diff. The introduced changes are confined to missing-store settlement, its journal intent and completion readers, boundary regressions, and recovery documentation.
Current main still needs the fix: The fetched-main source captures the recorded database identity without handling ENOENT, so a missing coordination database still prevents settlement. Local access to this main blob failed during Git object retrieval; its complete source was inspected successfully through the GitHub contents API.
Concrete missing-store report: The Raspberry Pi follow-up at #164254 reports official 2026.9.8, a reboot clearing tmpfs, repeated ENOENT package-recovery refusal, and repair failing to clear the update gate even after offline Doctor completed.
Findings 2 actionable findings [P2] [P2] Preserve lease loss across interruption before journal settlement
[P2] [P2] Carry lease loss into an already-started supersession
Security None None.

How this fits together

Package activation tracks an interrupted package installation and its recovery artifacts. Update repair uses the coordination database to acquire exclusive ownership before settling those artifacts and continuing maintenance.

flowchart TD
  A[Update repair] --> B[Read recovery journal]
  B --> C[Inspect coordination database]
  C --> D[Recreate missing store]
  C --> E[Acquire fresh update ownership]
  D --> E
  E --> F[Archive retained recovery]
  F --> G[Record completion]
  G --> H[Continue Doctor and next update]
Loading

Before merge

  • [P2] Preserve lease loss across interruption before journal settlement (P2) - If the recreated database reuses the recorded inode and repair exits after this creation but before supersedePackageActivationCustody records its intent, the next invocation loses leaseWasMissing. For an unfinished publication with the recorded package still installed, identity comparison then reports no change and takes the pending-recovery refusal at lines 232–240. The existing inode-reuse regression starts after the intent is durable, so it misses this window. Preserve the loss across interruption before recreating the store can erase the distinguishing observation.
  • [P2] Carry lease loss into an already-started supersession (P2) - When manual-install supersession is interrupted and a reboot subsequently deletes its lease database, this branch recreates the store and selects recovery-lease-missing. However, the custody owner ignores the supplied reason when the journal is already superseded, retaining superseded-by-manual-install. After settlement, receipt reading still validates the obsolete database identity and replaceCompleted rejects the next preparation. Persist the newly observed lease loss under the fresh fence while preserving the original replacement fact, and cover deletion between archival interruption and retry.
  • Resolve merge risk (P1) - Existing-state compatibility is not yet demonstrated with a published updater's retained journal and helper across missing-store repair, interrupted retry, completion reading, and next preparation.
  • Complete next step (P2) - Repair both interruption cases and provide published-updater compatibility evidence for missing-store recovery before merge.

Findings

  • [P2] [P2] Preserve lease loss across interruption before journal settlement — src/infra/package-update-activation.ts:209-212
  • [P2] [P2] Carry lease loss into an already-started supersession — src/infra/package-update-activation.ts:219-223
Agent review details

Security

None.

PR surface

Source +37, Tests +49, Docs +9. Total +95 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 45 8 +37
Tests 1 57 8 +49
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 111 16 +95

Review metrics

Metric Value Why it matters
Persisted recovery contract 1 new intent kind; 0 SQL table changes The new durable intent needs existing-state compatibility validation even without a SQL migration.
Production versus test growth production +45/-8; tests +57/-8 The stated production growth extends the existing recovery owner and completion handling.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #164254
Summary: This PR targets the missing-database variant reported in the canonical issue; the earlier merged recovery change covers replacement.

Members:

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

Merge-risk options

Maintainer options:

  1. Verify the published recovery state (recommended)
    Exercise a published updater's retained journal and helper through missing-store settlement and retry, verifying preserved artifacts, readable completion, and successful next preparation.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add published-driver compatibility evidence for missing-store recovery, interrupted settlement, completion receipt reading, and next package preparation while preserving existing live-owner and unsafe-path refusals.

Technical review

Best possible solution:

Keep one recovery owner that durably remembers lease loss across every interruption and safely completes both new and already-started settlements without changing installed package bytes.

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

Yes, source establishes the missing-store failure on current main and two retry failures in the proposed patch; this review did not execute them.

Is this the best way to solve the issue?

The existing custody owner is the right repair boundary, but the patch must preserve lease-loss provenance before recreation and when resuming an older supersession intent.

Full review comments:

  • [P2] [P2] Preserve lease loss across interruption before journal settlement — src/infra/package-update-activation.ts:209-212
    If the recreated database reuses the recorded inode and repair exits after this creation but before supersedePackageActivationCustody records its intent, the next invocation loses leaseWasMissing. For an unfinished publication with the recorded package still installed, identity comparison then reports no change and takes the pending-recovery refusal at lines 232–240. The existing inode-reuse regression starts after the intent is durable, so it misses this window. Preserve the loss across interruption before recreating the store can erase the distinguishing observation.
    Confidence: 0.89
  • [P2] [P2] Carry lease loss into an already-started supersession — src/infra/package-update-activation.ts:219-223
    When manual-install supersession is interrupted and a reboot subsequently deletes its lease database, this branch recreates the store and selects recovery-lease-missing. However, the custody owner ignores the supplied reason when the journal is already superseded, retaining superseded-by-manual-install. After settlement, receipt reading still validates the obsolete database identity and replaceCompleted rejects the next preparation. Persist the newly observed lease loss under the fresh fence while preserving the original replacement fact, and cover deletion between archival interruption and retry.
    Confidence: 0.95

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 a2affcf76e93.

Labels

Label changes:

  • add P0: Reported stable installations remain blocked in update recovery, and reaching a corrected CLI currently requires a manual installation hop.
  • add merge-risk: 🚨 compatibility: The new persisted intent and interrupted-settlement handling can leave existing recovery journals unable to supply a usable completion receipt or admit the next preparation.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.

Label justifications:

  • P0: Reported stable installations remain blocked in update recovery, and reaching a corrected CLI currently requires a manual installation hop.
  • merge-risk: 🚨 compatibility: The new persisted intent and interrupted-settlement handling can leave existing recovery journals unable to supply a usable completion receipt or admit the next preparation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.

Evidence

Acceptance criteria:

  • [P1] pnpm test src/cli/update-cli/update-repair-package-activation.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs --base 6785728.
  • [P1] git diff --check.
  • [P1] Verify a published-updater × candidate missing-store recovery cell, including interrupted retry, preserved artifacts, completion receipt reading, and next preparation.

What I checked:

  • Pinned introduced change: Reviewed the complete merge-base-to-head diff. The introduced changes are confined to missing-store settlement, its journal intent and completion readers, boundary regressions, and recovery documentation. (src/infra/package-update-activation.ts:192, 16a4b863a462)
  • Current main still needs the fix: The fetched-main source captures the recorded database identity without handling ENOENT, so a missing coordination database still prevents settlement. Local access to this main blob failed during Git object retrieval; its complete source was inspected successfully through the GitHub contents API. (src/infra/package-update-activation.ts:186, a2affcf76e93)
  • Concrete missing-store report: The Raspberry Pi follow-up at [Bug]: Linux 2026.9.8 managed handoff lease database identity changed leaves update-recovery-pending #164254 reports official 2026.9.8, a reboot clearing tmpfs, repeated ENOENT package-recovery refusal, and repair failing to clear the update gate even after offline Doctor completed.
  • Loss is not durable before recreation: The new store is created before fresh executor admission and before the journal records recovery-lease-missing. Only an already-superseded missing-lease intent survives retry; interruption before that transition can lose the missing-store fact when the recreated inode matches the recorded identity. (src/infra/package-update-activation.ts:209, 16a4b863a462)
  • Existing supersession reason survives lease loss: Custody settlement records the supplied reason only when the phase is not already superseded. An interrupted manual-install settlement resumed after lease deletion therefore retains superseded-by-manual-install; completion receipt reading and next journal replacement still require its obsolete database identity. (src/infra/package-update-activation-custody.ts:236, 16a4b863a462)
  • Fresh authority remains enforced: Executor admission acquires a new lease and refuses another current updater. The custody owner checks that fence and the journal before filesystem transfers and subsequent durable transitions; no concrete cross-principal authorization bypass was found. (src/cli/update-cli/update-command-executor.ts:336, 16a4b863a462)

Likely related people:

  • steipete: 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.

  • Prove retry after interruption between database recreation and durable settlement intent with deterministic inode reuse.
  • Cover lease deletion between interrupted manual-install archival and retry, including completion reading and next preparation.
  • Record a published-updater × candidate missing-store compatibility cell.

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.

@steipete
steipete merged commit 5ae6497 into main Oct 5, 2026
189 of 190 checks passed
@steipete
steipete deleted the upd/upd-recovery-lease-db-missing-enoent branch October 5, 2026 01:47
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
RomneyDa added a commit that referenced this pull request Oct 8, 2026
Backport all required recovery fixes to 2026.10.1: #167302, #167330,
#167358, and #167377. Include their missing settlement prerequisites
#164997, #165238, and #165607.

Close obsolete recovery custody durably before best-effort evidence archival;
keep unfinished rollback and current mutation authority strict. Completed
history cannot block subsequent updates. Qualify authentic interruptions
from pinned 9.8/9.9 updaters plus the unchanged 9.7-to-9.8 negative control.

Adapt donor APIs to the release-owned publication and lease database owners.
No version, dependency, budget, permission, or publication changes.

Proof:619 focused tests passed, including14 release-profile cases;
fresh complete69-file P0-P2 review clean. Complete changed gate passed.
Exact combined release build and stable/all/soak qualification remain pending.

Sources:
3ed1e21 (#167302)
4821885 (#167330)
8879e5e (#167358)
bc860ad (#167377)
9497527 (#164997)
5ae6497 (#165238)
fb84dd5 (#165607)

Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
steipete added a commit that referenced this pull request Oct 9, 2026
…eanup (#167564)

Adds recovery regressions for the three ways OS temp cleanup removes the managed-update handoff lease database (missing file, recreated parent directory, replacement inode), as reported in #167506 and #167557: recovery settles and admits the next package preparation. Main already settles these via #165238 and #164849; 2026.9.9 does not include them. Refs #167506 #167557.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…eanup (openclaw#167564)

Adds recovery regressions for the three ways OS temp cleanup removes the managed-update handoff lease database (missing file, recreated parent directory, replacement inode), as reported in openclaw#167506 and openclaw#167557: recovery settles and admits the next package preparation. Main already settles these via openclaw#165238 and openclaw#164849; 2026.9.9 does not include them. Refs openclaw#167506 openclaw#167557.
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 size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Linux 2026.9.8 managed handoff lease database identity changed leaves update-recovery-pending

1 participant