Skip to content

fix(update): updates keep a full pre-update copy until the next update - #196872

Merged
fuller-stack-dev merged 2 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-retire-verified-capture
Nov 10, 2026
Merged

fuller-stack-dev merged 2 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-retire-verified-capture

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: every successful update leaves a full copy of the pre-update state, and the Doctor .bak backups its migrations made, on disk until the next update succeeds. Large installs run out of space on their next update.

User Impact

User impact: once an update's Gateway passes its health verification, that update deletes its own pre-update copy and the Doctor migration backups it produced. Updates that aren't verified healthy keep their copies as before, including failed, rolled-back, unfinished, --no-restart, and already-current runs.

To keep a downgrade path, create a backup with openclaw backup create before updating. That is already the documented downgrade path: these copies are recovery sources for a failed update, not a full pre-update backup.

Why This Change Was Made

Cleanup kept the latest update's copy until a later update started. A copy is only needed until the update proves it works. A successful update whose Gateway verification is confirmed (service running, version match, readiness, settled channels, no plugin errors) now supersedes:

  • its own original-state capture (verified-update-capture);
  • migration originals that completed before that update finished.

The automatic cleanup that runs after each update applies this. Its guard against clock skew still keeps an unverified run's own copy. Older shipped updaters reach the same code through the Gateway's update.recovery.cleanup RPC.

Evidence

  • Real update, published driver × candidate. OPENCLAW_PUBLISHED_DRIVER_LEGACY_SQLITE=1 scripts/e2e/published-driver-update-docker.sh, with the shipped 2026.11.3 updater driving each run:
    • main 1651ee19: PASS … readyz=200; post-update cleanup removed 4 files (632 logical bytes), and the update's own copy is kept.
    • this branch: PASS … readyz=200; post-update cleanup removed 8 files (31043914 logical bytes), so the update's ~31 MB copy is gone.
  • New case in src/commands/update-automatic-cleanup.test.ts: a verified update removes its own copy and a .bak its activation produced. It fails on main ([true, true]) and passes here. An unverified control keeps both, on main and here.
  • src/cli/update-cli/update-command-capture-cleanup.test.ts:
    • The verified latest success is now verified-update-capture.
    • A new unverified success keeps the awaiting-later-verified-update protection that case used to prove.
    • Already-superseded captures keep their superseded-update-capture reason.
  • 24 test files that import the cleanup classifier, inventory, retirement or automatic cleanup pass (323 tests, 3 platform skips).
  • node scripts/check-changed.mjs passes, with the dead-export scan skipped because it already fails on main for untouched files. The test-lines ratchet passes with a 35-line allocation.
  • Autoreview (codex, P0–P2, high): scoped-clean, patch is correct (0.83).

A successful update kept a full copy of the pre-update state, plus the
Doctor migration originals it produced, until the next update succeeded.
Once the update's Gateway health verification is recorded, nothing it
captured is still needed for recovery, so automatic cleanup retires them.
@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 cli CLI command changes commands Command implementations size: S 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. 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: needs maintainer review before merge.

What this changes

Verified healthy updates immediately retire their own recovery captures and eligible Doctor migration originals.

Example: The published 2026.11.3 updater completes an update and confirms Gateway readiness.

  • Before: Cleanup removes 632 logical bytes while retaining the update's approximately 31 MB capture.
  • After: The reported candidate run removes 31,043,914 logical bytes, including its own capture.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused implementation with meaningful preservation controls and public stable-updater output; no actionable correctness or security finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The public body supplies stable 2026.11.3-to-candidate Docker update output showing Gateway readiness and the changed cleanup result; the named shipped-update harness checks retained durable content and SQLite state.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Preference · Worth it: Yes · Fix scope: Complete
User problem: Large installations retain a full recovery generation after healthy updates, reducing space available for the next update.
Reason: This changes intentionally designed retention rather than repairing a broken classifier contract; the maintainer-authored PR supplies the owner decision and explains the backup tradeoff.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it makes a focused retention change absent from current main, and review found no actionable introduced defect.

Priority: P2
Reviewed head: c77e544e8291c872008e0eb17f1a3a51f84bcf2a

Before merge

None.

Findings

None.

Agent review details

How this fits together

Update completion records and Doctor manifests feed the shared recovery inventory; the existing state owner verifies eligible artifacts and deletes recovery originals while preserving live state.

flowchart TD
  A[Update completion] --> B[Recorded Gateway verification]
  B --> C[Shared recovery inventory]
  D[Doctor migration manifests] --> C
  C --> E[State owner and retirement checks]
  E --> F[Eligible recovery copies removed]
Loading

Technical review

Best possible solution:

Use the existing cleanup owners to release verified updates' recovery copies while retaining unverified and unresolved recovery sources.

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

Current-main classifiers demonstrably retain the latest update's copies, and the body reports a matching stable-updater reproduction; this review executed no target code.

Is this the best way to solve the issue?

The patch is a small, complete retention-policy change using existing inventory and retirement owners, with distinct verified and unverified regression coverage.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6f18dd48112d.

Provenance checked

  • Update capture supersession changes intended behavior with a stated reason (4f1158a: Capture cleanup required a later successful update before retiring recovery originals.)
  • Automatic cleanup's current-generation protection changes intended behavior with a stated reason (fb9e117: Automatic cleanup reclaimed superseded recovery copies while retaining the just-finished update's rollback generation.)
  • Doctor migration backup retention changes intended behavior with a stated reason (6ced196: Recorded migration backups remained protected until migration completion and a subsequent successful update.)
  • Incomplete capture and unresolved recovery safeguards keeps the original intent (db04f90: Unverified successes cannot supersede incomplete recovery evidence, and unresolved failed originals remain protected.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned change and current-main behavior: The introduced diff changes the existing capture classifier, migration-original cutoff, and automatic cleanup guard; fetched main still retains the current successful update's recovery generation. (src/commands/update-capture-cleanup.ts:109, c77e544e8291)
  • Intentional retention tradeoff: The earlier automatic-cleanup implementation deliberately retained the latest rollback generation. Its author also authors this maintainer-associated PR, which explicitly shortens retention after recorded health verification and directs downgrade users to an independent backup. (src/commands/update-automatic-cleanup.ts:49, fb9e117745a7)
  • Distinct regression and preservation control: The added production-path test removes both the triggering capture and a migration backup only with confirmed verification; its unverified control retains both. The body reports the verified case failing on main and passing on the branch. (src/commands/update-automatic-cleanup.test.ts:771, c77e544e8291)
  • Stable-updater behavior evidence: The public body reports a real 2026.11.3-to-candidate Docker update with readyz=200 and increased cleanup output. The named harness checks durable session content, running build identity, preserved sidecar bytes, and SQLite state after restart. (scripts/e2e/lib/upgrade-survivor/published-driver.mjs:464, c77e544e8291)
  • Deletion safeguards remain shared: Retirement still refreshes selection, verifies artifact and destination identities, preserves unresolved dependencies, and checks current state-owner authority before deletion; the patch adds no competing deletion path. (src/commands/doctor-session-sqlite-retirement.ts:233, c77e544e8291)
  • Related work is complementary: feat(update): offer to remove old recovery copies when an update is short on space #196873 addresses pre-update disk shortages by offering existing eligible cleanup; this PR changes post-verification eligibility, so neither replaces the other.

Likely related people:

  • Jason (Json): Raw commit fb9e117 adds src/commands/update-automatic-cleanup.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fb9e117745a7; files: src/commands/update-automatic-cleanup.ts)
  • Peter Steinberger: Raw commit 78d2d91 adds src/commands/doctor-session-sqlite-recovery-inventory.ts:120 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 78d2d914db75; files: src/commands/doctor-session-sqlite-recovery-inventory.ts)
  • Ayaan Zaidi: Raw commit 4f1158a adds src/commands/update-capture-cleanup.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4f1158a559a3; files: src/commands/update-capture-cleanup.ts)

PR surface

Source +20, Tests +35, Docs +16, Other +2. Total +73 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 32 12 +20
Tests 3 39 4 +35
Docs 3 25 9 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 10 98 25 +73

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.

Labels

Label changes:

  • add P2: Recovery copies can consume substantial disk space, but this is a bounded retention improvement rather than an established urgent runtime regression.
  • add merge-risk: 🚨 compatibility: Existing installations lose the latest verified update's recovery originals sooner; the maintainer-authored direction explicitly accepts this tradeoff and documents independent backups for downgrades.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Recovery copies can consume substantial disk space, but this is a bounded retention improvement rather than an established urgent runtime regression.
  • merge-risk: 🚨 compatibility: Existing installations lose the latest verified update's recovery originals sooner; the maintainer-authored direction explicitly accepts this tradeoff and documents independent backups for downgrades.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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, 4:43 PM ET / 21:43 UTC.

@fuller-stack-dev
fuller-stack-dev merged commit 30d1342 into openclaw:main Nov 10, 2026
138 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/update-retire-verified-capture branch November 10, 2026 22:09
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
openclaw#196872)

* fix(update): retire a verified update's own recovery copies

A successful update kept a full copy of the pre-update state, plus the
Doctor migration originals it produced, until the next update succeeded.
Once the update's Gateway health verification is recorded, nothing it
captured is still needed for recovery, so automatic cleanup retires them.

* test: allocate verified update capture retirement lines
roboclaw-bot added a commit that referenced this pull request Nov 11, 2026
* fix(test): keep unverified recovery captures in disk usage fixtures

Preserve protected and retirable reporting coverage after verified updates began retiring their own capture in #196872. No retention policy or assertion changes.

Co-authored-by: steipete <[email protected]>
Co-authored-by: obviyus <[email protected]>

* fix(test): preserve protected recovery-copy reporting coverage

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 6303da83-3c06-83ad-a7cd-e5f1f5817e37

---------

Co-authored-by: steipete <[email protected]>
Co-authored-by: obviyus <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…law#197138)

* fix(test): keep unverified recovery captures in disk usage fixtures

Preserve protected and retirable reporting coverage after verified updates began retiring their own capture in openclaw#196872. No retention policy or assertion changes.

Co-authored-by: steipete <[email protected]>
Co-authored-by: obviyus <[email protected]>

* fix(test): preserve protected recovery-copy reporting coverage

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 6303da83-3c06-83ad-a7cd-e5f1f5817e37

---------

Co-authored-by: steipete <[email protected]>
Co-authored-by: obviyus <[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 commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant