Skip to content

fix(update): fence retained rollback and simplify recovery lifecycle - #143791

Merged
fuller-stack-dev merged 7 commits into
mainfrom
fix/update-rollback-ownership
Sep 10, 2026
Merged

fuller-stack-dev merged 7 commits into
mainfrom
fix/update-rollback-ownership

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Fixes #143750

Issue: #143750
Related: #143752 (package activation recovery remains separate).

Builds on Jason (@fuller-stack-dev)'s rollback work in #140339. His contribution on this branch is preserved in the signed merge history; the connected lifecycle cleanup is now included in this PR, not a separate stack.

What Problem This Solves

Fixes an issue where a managed update could continue replacing package or launcher entries after its original executor lost ownership during rollback. The outer check detected ownership loss only after those filesystem effects.

Why This Change Was Made

Carries the original executor assertion through retained rollback and completion, including awaited planning, package restoration, launcher compensation, cross-device copy-source cleanup, and backup retirement. Repeated calls remain bound to that first owner.

Removes dormant package-recovery execution/writers and the no-op replay prepass, leaving one active lifecycle. Persisted record schemas, readers, admission checks, and refusal behavior remain intact. Native EXDEV and relative-launcher behavior are preserved.

User Impact

Ownership loss stops subsequent protected filesystem operations and preserves recovery material. Already-dispatched filesystem operations are not cancellable.

This does not provide crash-atomic activation, interrupted-package repair, a new recovery journal, or full-state/migration-crossing rollback. The activation gap in #143752 is not fixed by this PR.

Evidence

Head: a0fe5c66827dc6730aa4768e83615f25f1fa0a41; tree: 2551da6a71639ae2e7f59f8f398c974e90b6fc45.

  • Real retained-transaction regressions fail on the original implementation with unauthorized package/launcher mutations.
  • Final-source remote proof: all three canonical dead-export scans reported zero; update-command-run.test.ts passed 35 tests with zero skips; full pnpm build passed in 4m20.5s; isolated dist-backed node openclaw.mjs update --help passed. The command wrapper exited 0. Proof run: https://github.com/openclaw/openclaw/actions/runs/34453609190 (selected source is the head above, not the workflow-control branch).
  • Earlier exact tree 342e51ae1a2c5b15cafd4d7e7b7f87fee114d25f, shared by 60e4882fd1b4b81c7eb717ac77b1b21032d5d6bc and reconciliation merge b8f48827956da1a2cfbdf9a78cd5621c42af04bf, passed 31 tests across the rollback-executor/native-transaction files, full build, dist CLI help, and core test typechecking. The final source differs only by removing an unused export, covered by the final-source proof above.
  • Broader focused proof passed 991 tests across 27 files with zero skips at 868d456eef6894d8539f89549a11d8ce35f3e3e7. Subsequent changes were two erased test type arguments, a test-local variable rename, and the unused-export removal. These overlapping runs are not summed.
  • Independent source review and fresh autoreview covered the combined change and final export cleanup, with no actionable P0-P2 findings. The published @openclaw/fs-safe 0.8.5 callback contracts were inspected directly; targeted formatting, lint, and whitespace checks passed.
  • Against pinned base 1c0d32c78f248a5f328eadc751457097e265d147: 32 paths; production +113/-950 (net -837), tests +717/-1226 (net -509).

Pending: hosted CI and human review on this exact published head. Prior-head CI is not evidence that the new head is fully green; this is ready for review, not a claim of merge readiness.

@fuller-stack-dev: please review the combined original-owner fencing and lifecycle simplification, including preservation of persisted readers/admission and the real filesystem regressions.

@vincentkoc vincentkoc self-assigned this Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 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 cli CLI command changes size: L maintainer Maintainer-authored PR labels Sep 10, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 10, 2026 06:54
@fuller-stack-dev

fuller-stack-dev commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Review/proof history: the original ten sealed #143750 cases pass unchanged on Vincent's ownership repair. Two settled runs passed 300 focused tests on the original canonical production patch; runtime build and CLI import passed. The unchanged baseline preserves three passing controls and seven demonstrated unauthorized effects.

Vincent fixed the redundant deferred types in 5c202e7c31a1546256f67c5d30a06602e311f49a. I prepared the two remaining lint corrections: rename the native-test observation and extract existing launcher-backup capture into its filesystem owner, preserving immediate backup-directory registration and the shared partial launcher array. The 700-line rule is unchanged.

Publication/coordination overlap: the exact pre-push read showed 5c202e7 and no author reply. Native leased preparation published GitHub-signed 8503ad3a0d389f52e457efc6a27e50a29c9066f4 (commit timestamp 07:16:19 UTC), preserving 5c202e7 as its parent. I then read your 07:16:24 UTC hold request: #143791 (comment). The correction was already published when I read it. Sorry for the overlap.

I have paused further branch changes, approval, and merge. Please carry your combined cleanup on this canonical branch as planned; it can supersede the helper extraction. I will review the resulting exact head and rerun only affected proof, without a competing PR or a second recovery design.

The published tree ba300c754de54b76e0acb6a30413d6591a75c287 exactly matches the qualified local amendment: 162 tests in nine files passed, including the same ten sealed cases; complete check:changed passed for all 18 changed files (core/core-test typechecks, dead exports, lint and final guards). These overlap the earlier 300 and are not additive. A stable independent autoreview completed with no findings at its default P0 threshold; this is not a P0-P2 clean claim. Full manual ownership review covered all mutation/retirement paths and the installed fs-safe 0.8.5 callbacks. No new authority, persistence, or retention change.

Exact-head CI run: https://github.com/openclaw/openclaw/actions/runs/34449137935 . It is still pending, not claimed green. Installed Linux/full-journey proof remains unrun and separately coordinated.

Combined-head review: a0fe5c6

I reviewed your published combined head a0fe5c66827dc6730aa4768e83615f25f1fa0a41, tree 2551da6a71639ae2e7f59f8f398c974e90b6fc45, following the updated PR-body request. The former wait for unpublished cleanup is superseded by this head; no further extraction or unrelated repair was added here.

  • Native scripts/pr review-tests 143791 passed 304 tests across 12 files, with no skips and completed worker cleanup. All 10 original sealed cases pass unchanged, including real lease loss, original run/fence identity replacement, launcher absence and failed-rename compensation. The original failing baseline was not rerun.
  • Manual source review and a fresh independent autoreview --mode branch --max-priority P2 found no actionable P0/P1/P2 issue in the combined change. The removed hooks had no production producer. Persisted descriptor/effect schemas, artifact-preserving readers and canonical pre-write admission remain intact.
  • Read the installed @openclaw/fs-safe 0.8.5 move and copy-cleanup implementation directly. Original callbacks guard publication and per-entry source cleanup; no later assertion substitutes for the retained caller.
  • The test wrapper's runtime build passed. An isolated, dist-backed node openclaw.mjs update --help exited 0. These are local component results, not installed Linux or full migration-journey proof.
  • Live main 58080e69543eacffdbbc00323ecd3eb2fb06db71 still has identical blobs for the original three defect files. The scoped repair remains necessary.

Required exact-head CI is still running: https://github.com/openclaw/openclaw/actions/runs/34454616518 . I have not approved or merged ahead of it. Separate surviving-child custody and final-result/cleanup-reporting followups remain separate and are not claimed fixed by this PR.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 4:27 AM ET / 08:27 UTC (Revision 4).

ClawSweeper review

What this changes

The PR stops retained update rollback and backup cleanup after executor ownership is lost, removes inactive recovery machinery, and adds filesystem and retained-record regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix for a source-confirmed gap on current main. No actionable introduced defect was found, and the combined cleanup resolves the earlier unpublished-work concern and prior lint findings.

Priority: P2
Reviewed head: a0fe5c66827dc6730aa4768e83615f25f1fa0a41

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-boundary repair with meaningful regression coverage and no actionable findings; remote command results were not independently confirmed.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor proof gate is exempt for this MEMBER-authored PR. Inspected regressions cover the actual rollback owner and filesystem effects under revocation, with no unresolved introduced authority case identified; reported remote execution remains only partially independently verified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor proof gate is exempt for this MEMBER-authored PR. Inspected regressions cover the actual rollback owner and filesystem effects under revocation, with no unresolved introduced authority case identified; reported remote execution remains only partially independently verified.
Evidence reviewed 10 items Current main still needs the repair: The supplied current-main revision calls packageTransaction.rollback() without carrying its executor assertion into the transaction.
Original authority remains bound: The retained transaction stores its first assertion and reuses it for rollback, repeated calls, and completion. Restoration and retirement pass that assertion through to filesystem effects.
Inactive hook removal preserves admission: Inspection of the pinned base found no production hook provider outside the removed plumbing; the ordinary execution owner supplies neither recovery hook. Canonical admission still checks retained recovery before writable state access and run creation.
Findings None None.
Security None None.

How this fits together

The update CLI stages a candidate package and retains the previous package and launchers for compatibility-checked rollback. Its transaction owner restores or retires those files before final service recovery and reporting.

flowchart TD
  A[Staged package update] --> B[Retained package and launchers]
  B --> C[Rollback or completion request]
  C --> D{Original executor still owns work?}
  D -->|Yes| E[Restore files or retire backups]
  D -->|No| F[Stop further effects and preserve recovery material]
  E --> G[Service recovery and outcome reporting]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -837, Tests -509. Total -1346 across 32 files.

View PR surface stats
Area Files Added Removed Net
Source 17 113 950 -837
Tests 15 717 1226 -509
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 32 830 2176 -1346

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #143750
Summary: This PR targets the rollback ownership issue; interrupted activation remains a distinct design gap.

Members:

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

Technical review

Best possible solution:

Keep one compatibility-checked rollback lifecycle whose original executor gates every subsequent protected filesystem effect, while preserving unsupported retained records unchanged.

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

Yes, from source: revoke the original executor during retained-package inspection and current main can continue restoration without that fence. The PR supplies focused fault-injection regressions; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Passing the existing executor assertion into the transaction repairs the effect-owning boundary, and removing unused hooks preserves the active admission and persisted-reader contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 15b5fc24a7fe.

Labels

Label justifications:

  • P2: This repairs a bounded update-rollback ownership gap; production frequency and released-user impact remain unmeasured.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 ordinary contributor proof gate is exempt for this MEMBER-authored PR. Inspected regressions cover the actual rollback owner and filesystem effects under revocation, with no unresolved introduced authority case identified; reported remote execution remains only partially independently verified.

Evidence

What I checked:

  • Current main still needs the repair: The supplied current-main revision calls packageTransaction.rollback() without carrying its executor assertion into the transaction. (src/cli/update-cli/update-command-rollback.ts:303, 15b5fc24a7fe)
  • Original authority remains bound: The retained transaction stores its first assertion and reuses it for rollback, repeated calls, and completion. Restoration and retirement pass that assertion through to filesystem effects. (src/infra/package-update-swap.ts:355, a0fe5c66827d)
  • Inactive hook removal preserves admission: Inspection of the pinned base found no production hook provider outside the removed plumbing; the ordinary execution owner supplies neither recovery hook. Canonical admission still checks retained recovery before writable state access and run creation. (src/cli/update-cli/update-command-run.ts:140, a0fe5c66827d)
  • Revocation and replay coverage: The inspected tests exercise real retained filesystem transactions with injected ownership loss during integrity inspection, displacement, compensation, launcher replacement, and retirement, including rejection of later calls with a replacement assertion. These tests were inspected, not executed in this review. (src/infra/package-update-swap.ownership.test.ts:65, a0fe5c66827d)
  • Persisted compatibility remains intact: The patch removes execution-only types while retaining descriptor/effect schemas and redirects the existing reader import to their contract module. Added cases verify byte-preserving inspection and refusal for current, legacy, interrupted, and invalid retained records. (src/infra/update-run-recovery-package-schema.ts:5, a0fe5c66827d)
  • Filesystem dependency boundary: Native rollback now supplies rename, mutation, and publication assertions to movePathWithCopyFallback, which OpenClaw re-exports from @openclaw/fs-safe/atomic; package.json pins version 0.8.5. This is the relevant dependency contract. (src/infra/package-update-swap.ts:537, a0fe5c66827d)

Likely related people:

  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-10T07:02:56.505Z sha b86c371 :: needs changes before merge. :: [P3] Remove the redundant deferred type arguments
  • reviewed 2026-09-10T07:12:49.461Z sha 5c202e7 :: needs changes before merge. :: [P3] Rename the shadowed filesystem observation result | [P3] Extract a cohesive helper to restore the existing line budget
  • reviewed 2026-09-10T07:23:25.818Z sha 8503ad3 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 10, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@fuller-stack-dev: please hold the local extraction and do not push it; we are carrying the remaining corrections. Thanks for the exact-head checks and coordination.

We plan to fold the already-reviewed dormant package-recovery engine cleanup into this PR, rather than open a separate cleanup PR or add a temporary launcher-backup helper extraction. It removes unused writers/hooks and the no-op replay prepass while preserving historical record schemas/readers, canonical admission, and the fence's ownership checks. The combined swap fits the unchanged 700-line rule.

We are fixing the inherited native-test shadow, then qualifying the final combined head with review, lint, tests, and build. That cleanup is not yet in the published head, which remains 5c202e7c31a1546256f67c5d30a06602e311f49a; no combined green result is claimed.

The package-activation journal proposal remains separate under #143752. Storage implementation is still held pending maintainer acceptance; this consolidation does not implement process-interruption repair.

@vincentkoc vincentkoc changed the title fix(update): stop rollback writes after executor ownership is lost fix(update): fence retained rollback and simplify recovery lifecycle Sep 10, 2026

@fuller-stack-dev fuller-stack-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed combined head a0fe5c66827dc6730aa4768e83615f25f1fa0a41 for the original-executor ownership boundary. No actionable P0/P1/P2 findings. The full captured caller assertion reaches restoration, compensation and retirement; repeated calls remain bound to the original owner. Removed recovery hooks have no production provider, while historical schemas/readers and canonical read-only admission remain.

Ran the native focused suite: 304 tests across 12 files, zero skips, including all 10 unchanged sealed real-transaction authority cases. Worker cleanup completed. Fresh independent P0/P1/P2 review was scoped-clean; the required local runtime build and isolated dist-backed update --help passed. Detailed evidence is in the existing coordination comment.

Approval is for this scoped rollback correction. Required exact-head CI still gates landing. This does not claim installed whole-journey proof or repair separate surviving-child custody, cleanup-outcome reporting, premature terminal success, or interrupted activation (#143752). Thanks Vincent for the fix and combined-source reconciliation.

@fuller-stack-dev
fuller-stack-dev merged commit 654eb84 into main Sep 10, 2026
184 of 186 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/update-rollback-ownership branch September 10, 2026 08:47
@fuller-stack-dev

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…penclaw#143791)

* fix(update): stop rollback writes after executor ownership is lost

* test(update): remove redundant deferred type arguments

* refactor(update): remove dormant package recovery execution

* refactor(update): keep rollback ownership helpers within lint limits

* test(update): avoid shadowing the native copy result

* refactor(update): keep admission environment resolution local

---------

Co-authored-by: Jason (Json) <[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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

[Bug]: Update rollback can mutate packages and launchers after executor ownership is lost

2 participants