Skip to content

fix(update): retire migration backups after supervisor acceptance - #197705

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-migration-backup-retention-20260919
Nov 12, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-migration-backup-retention-20260919

Conversation

@steipete

@steipete steipete commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes migration originals accumulating after externally supervised updates: update finish recorded successful acceptance but never invoked the existing recovery-retirement owner.

User Impact

After a later native update is accepted, verified migration originals from Doctor and startup migrations become eligible for automatic cleanup. The current update's originals remain protected through the supervisor's rollback window. Unknown, incomplete, replaced, or unverified artifacts remain protected. No configuration or schema changes are required.

Why This Change Was Made

Call the existing owner-routed cleanup after recording acceptance and return its diagnostics and recoverable warnings. This uses the same manifest, successful-update history, identity checks, and Gateway/offline ownership as ordinary updates; it adds no age-only deletion policy. Native receipts without a start time cannot prove succession and do not trigger cleanup.

The production change is eight added lines. The existing owner already implements retirement, so removing or duplicating it would expand the fix. The added regression exercises real migrate/finish entry points and verifies protection before acceptance, deletion after a successor, recorded diagnostics, and retry history.

Evidence

The original native migrate/finish regression fails on parent 83e3641e092125c009d3421e60560fda8af75c86 and passes with the fix. All 65 focused migration/cleanup tests pass. First-head CI correctly caught the existing container-upgrade test's obsolete manual-cleanup expectation; that failure reproduced locally and the updated consumer passes, asserting all three physical paths disappear only after acceptance while live data and the unmanifested original remain. Fresh Codex autoreview is scoped-clean; targeted lint and format pass.

Published 2026.11.3 → candidate 1d28c64ceb419082033aeaa21a7c1fcf3504a9cf passed using an isolated synthetic installation and the real CLI: stable Doctor produced two recovery originals; candidate native migration advanced agent schema 27 → 41; an isolated Gateway reached readiness; native finish removed the eligible originals after acceptance. Both originals and the native rollback capture existed before acceptance. The candidate CLI read back the session and gateway.mode=local; workspace contents and the unmanifested original survived. No operator data was used. The first candidate attempt retained recovery state after an unsafe fixture TMPDIR refusal; the supported new-prefix retry with the host's secure TMPDIR completed. Optional plugins were disabled and no inference account was configured, so this proves stored-data and lifecycle compatibility, not model inference.

Production-shaped synthetic measurement: 35.09 GiB live agent DB, 3,000 sessions, 62,000 workspace files / 1.181 GB. Backup creation is outside the measured native-finish interval. A/A controls on the same shared macOS/APFS host:

Native finish Baseline A/A Candidate A/A
Elapsed seconds 1.479 / 3.170 83.511 / 85.985
Process CPU user seconds 0.247 / 0.300 49.750 / 49.376
Process CPU system seconds 0.042 / 0.080 8.778 / 9.749
Logical backup bytes reclaimed per run 0 37,679,878,144

The added work is verified reclamation, not a speedup. Every candidate run checks source identity/size/mtime and all 3,000 sessions. Five interleaved A/B timing pairs and two separate allocation pairs are complete (18 runs including A/A controls). Every reclamation and source-preservation assertion passed. Final paired results:

Metric Baseline Candidate
Median native-finish seconds (n=5) 1.276 72.575
p95 seconds, nearest rank (n=5; observed maximum) 4.423 83.023
Median process user CPU seconds 0.245 47.986
Median process system CPU seconds 0.033 7.486
Median sampled caller JS allocation MiB (n=2) 49.3 134.4
Logical backup bytes reclaimed 0 37,679,878,144–37,679,886,336

Allocation samples include collected objects and cover the caller isolate, not all worker/native allocations. CPU excludes child processes. This shared-host APFS measurement does not qualify btrfs or predict physical free-space recovery. Reproduce with scripts/perf/migration-backup-retention-measure.ts against the pinned parent and candidate.

pnpm check:changed completed: all gates passed except seven inherited unused exports and an own shadowed name that was fixed with a passing targeted lint rerun. The exact parent reproduced all seven exports; #197615 removed their last consumers and #197679 already repaired that main regression. No unrelated repair is included. Final-head CI is green with no failed jobs: https://github.com/openclaw/openclaw/actions/runs/43214791876. ClawSweeper re-reviewed this head with zero open items and zero findings.

Invoke the existing owner-routed recovery cleanup after native update finish records acceptance. Preserve the current migration originals until a later accepted update, and surface cleanup diagnostics and warnings. Cover the real migrate/finish flow and provide a production-scale synthetic measurement.
@clawsweeper

clawsweeper Bot commented Nov 12, 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 scripts Repository scripts size: M labels Nov 12, 2026
@steipete
steipete marked this pull request as ready for review November 12, 2026 11:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T12:07:37.106530Z 1d28c64 New commits
ℹ️ 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.

@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. P2 Normal backlog priority with limited blast radius. 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 Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR invokes existing recovery cleanup after a supervisor accepts a native update and returns cleanup diagnostics.

Example: A supervisor accepts a later native update after Doctor created two verified migration originals.

  • Before: The originals remain on disk until manual cleanup runs.
  • After: Native finish automatically retires eligible originals while preserving the current generation and unmanifested backups.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused integration with recorded real upgrade coverage and the previous regression repaired; broad CI has not finished.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The body and follow-up record the real published-stable-to-candidate CLI upgrade, isolated Gateway readiness, retirement after native acceptance, and preserved session/config/workspace data; the synthetic measurement separately quantifies reclamation cost.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Verified migration backups accumulate after supervisor-managed updates despite successful acceptance.
Reason: The maintainer-authored change brings native finish into the existing cleanup lifecycle without changing eligibility rules or adding configuration.

Merge readiness

✅ Ready for maintainer review

This PR completes automatic recovery cleanup for supervisor-managed updates. The earlier container-upgrade finding is resolved, and no new blocking defect was found; exact-head CI remains pending.

Priority: P2
Reviewed head: 1d28c64ceb419082033aeaa21a7c1fcf3504a9cf

Before merge

None.

Findings

None.

Agent review details

How this fits together

The native update CLI records supervisor acceptance, then routes cleanup through the serving Gateway or exclusive offline owner; the existing manifest and update-history classifiers select recovery artifacts for retirement.

flowchart TD
  A[Supervisor accepts candidate] --> B[Native update finish]
  B --> C[Record successful update]
  C --> D[Existing state owner router]
  D --> E[Gateway or offline custody]
  E --> F[Manifest and history eligibility]
  F --> G[Retire eligible recovery artifacts]
  G --> H[Diagnostics and advisory warnings]
Loading

Technical review

Best possible solution:

Use the existing owner-routed cleanup after durable native acceptance, preserving its current-generation protections and advisory failure handling.

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

Current-main source shows that native finish records success without invoking cleanup; the PR reports its new migrate/finish regression failing on the pinned base and passing with the change.

Is this the best way to solve the issue?

This is the smallest complete production fix: connect the omitted entry point to the existing retirement owner rather than introduce another policy or artifact scanner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native acceptance and successor ordering keeps the original intent (ddf2e98: Record accepted native updates using their migration start time so earlier originals become eligible while current originals remain protected.)
  • Automatic cleanup ownership keeps the original intent (fb9e117: Retire eligible recovery artifacts after durable completion through the existing state owner, without changing the accepted update outcome on cleanup failure.)
  • Container-upgrade manual retirement expectation changes intended behavior with a stated reason (6ced196: Verify migration-original eligibility and safe retirement after a subsequent successful update; the PR explains replacing explicit manual retirement with automatic removal assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit ddf2e98 adds src/cli/update-cli/update-command-migrate.ts:453 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ddf2e9803fcf; files: src/cli/update-cli/update-command-migrate.ts)

PR surface

Source +8, Tests +51, Docs +9, Other +208. Total +276 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 8 0 +8
Tests 2 62 11 +51
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 208 0 +208
Total 5 287 11 +276

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.

Review metrics

Metric Value Why it matters
Production versus regression changes Production +8/-0; tests +62/-11 Small integration change reuses the retirement owner; regression growth covers successor ordering, retry bookkeeping, and the affected container-upgrade consumer.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Native finish now automatically deletes eligible persisted recovery artifacts; the maintainer-authored direction accepts this behavior while preserving current-generation and unverified originals.
  • 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 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Fixes retained recovery files accumulating on externally supervised installations, with limited scope and an existing manual cleanup path.
  • merge-risk: 🚨 compatibility: Native finish now automatically deletes eligible persisted recovery artifacts; the maintainer-authored direction accepts this behavior while preserving current-generation and unverified originals.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-12T11:56:31.535Z sha 3cd97b5 :: blocked before merge. :: [P2] Update the container-upgrade regression for automatic retirement

Reviewed November 12, 2026, 7:21 AM ET / 12:21 UTC (Revision 2).

@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Nov 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed both items on 1d28c64ceb419082033aeaa21a7c1fcf3504a9cf:

  1. Container-upgrade regression: lines 190–216 now record all three original paths before acceptance, assert their physical removal after native finish, and preserve the live DB/unmanifested-backup checks. Removed the obsolete manual-retirement call. The CI failure reproduced locally before this correction; the corrected test passes (31.776 s). The separate native regression at lines 70–86 protects the current generation until a later accepted update and verifies diagnostics/retry history.

  2. Data-model compatibility: completed a published 2026.11.3 → candidate native CLI upgrade with synthetic persisted state. Verified registry tarball integrity; stable Doctor produced two recovery originals and retained a session at schema 27. Candidate migration advanced to schema 41, preserved both originals and its native rollback capture before acceptance, and an isolated candidate Gateway reached /readyz with ready=true, coreReady=true, and no failing checks. Native finish then retired both stable-produced originals. Candidate CLI read back the session and gateway.mode=local; the workspace marker and unmanifested original remained unchanged. The PR body records setup recovery and the scope limit (no model inference). No schema change is introduced by this patch.

The PR body also contains completed 35 GiB A/A reclamation and CPU results; additional paired/allocation samples are still running. Fresh Codex autoreview is clean. Final-head CI is attached and running.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 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. labels Nov 12, 2026
@clawsweeper clawsweeper Bot removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@steipete
steipete merged commit 56b8dde into main Nov 12, 2026
159 checks passed
@steipete
steipete deleted the steipete/perf-micro-migration-backup-retention-20260919 branch November 12, 2026 13:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…enclaw#197705)

* fix(update): retire migration backups after supervisor acceptance

Invoke the existing owner-routed recovery cleanup after native update finish records acceptance. Preserve the current migration originals until a later accepted update, and surface cleanup diagnostics and warnings. Cover the real migrate/finish flow and provide a production-scale synthetic measurement.

* test(update): assert automatic retirement after container upgrade
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. scripts Repository scripts size: M 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