Repository navigation
fix(update): keep updating when a pre-migration database image does not fit - #201579
Conversation
…refusing the update
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Proof recordings for the snapshot-space preflight on a real 70 GiB APFS disk image (shared database 25 GiB, no mocks). RED, base GREEN, head RED (base 999e873): red.mp4GREEN (head 1ac9972): green.mp4 |
|
Codex review: needs changes before merge. What this changesThe PR lets updates continue without a pre-migration database image when it cannot fit, while retaining a separate migration-space requirement. Example: A 25 GiB shared SQLite database has 70 GiB free on its volume.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep open: this maintainer-authored PR addresses a concrete low-space update problem, but needs focused correctness and consumer-test repairs before merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe updater measures database families before staging, captures recovery images during activation, runs candidate Doctor migrations, and uses schema compatibility plus retained images to decide whether rollback is possible. flowchart TD
A[Update command] --> B[Initial space assessment]
B --> C[Stage candidate]
C --> D[Activation database capture]
D --> E[Candidate Doctor migrations]
E --> F[Gateway verification]
F --> G[Rollback or fix forward]
Technical reviewBest possible solution: Keep optional images, enforce migration capacity independently at activation, and align the existing backup consumer tests with that contract. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows the image-space refusal, and the supplied real-disk terminal trace demonstrates its preflight outcome; no target code was executed during this review. Is this the best way to solve the issue? The existing sizing, capture, cleanup, and rollback owners can implement the approved behavior without new state or configuration, but image admission must not replace migration admission. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 96189709bc50. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +157, Tests +160, Docs +17. Total +334 across 16 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 18, 2026, 9:53 PM ET / November 19, 2026, 02:53 UTC. |
|
GREEN re-recorded on the current head green-c82e86e.mp4 |
…ure and migration peak
…ses-for-snapshot-space
|
Final recordings on a real 70 GiB APFS disk image (shared database 40 GiB, no mocks). RED, base red-final.mp4GREEN, head green-final.mp4 |
|
Merged via squash.
|
…ot fit (openclaw#201579) * fix(update): skip a pre-migration image that does not fit instead of refusing the update * fix(update): keep an earlier run's images and skip Git release snapshot checks * test(update): capture no longer reserves restore output on source volumes * fix(update): skip only a measured image shortfall and budget the capture and migration peak
- main's #201579 gives a Git release no pre-migration snapshot check: it takes no database image and migrates at Gateway start. Every Git install is a release here, so remove the check from updateGitInstall, the runner's beforeGitStaging hook, the snapshot-source parameters, and the test of that check. - main's #201463 treats a Git release as opening no state before its restart; with no in-place runner that is every Git update. - Format the work-directory prefix line in state-upgrade-activity.ts.
What Problem This Solves
openclaw updaterefused to start whenever the disk could not hold about five times the size of the shared database. That covered a backup copy, a second copy, three more for restore scratch, and room on every other volume. For a 20 GiB database it wanted 100 GiB free, even when the migration itself needed far less. Git release updates take no database backup at all, yet ran the same check and refused for it.User Impact
An update no longer refuses because a pre-migration database image does not fit. When the backup measures that the image will not fit, the update skips it before copying anything, records a warning that names the space needed and free and what is given up, and continues. What is given up: once the new version's migration commits, the previous version cannot be restored and a failed update is fixed forward. The update still refuses, before changing anything, when the disk cannot hold the migration itself, and the message says how much to free. Git release updates run no snapshot check.
Why This Change Was Made
The owner approved "skip the snapshot and continue instead of refusing the update" after the proof in the copy inventory. Every schema step commits in one SQLite transaction with its version bump. 94 SIGKILLs across
doctor --fixandgateway run, plus a disk-full run, lost nothing. A pre-migration image matters only for running the previous build after a migration commits. This change keeps that image whenever it fits and stops refusing when it does not.One owner of the space calculation (
src/infra/update-database-backup-space.ts). It demands only what the image writes: the families once, plus the larger of two needs that never overlap:Restore already checks its own space before it moves any live database (
update-database-restore.ts), so capture no longer reserves restore output.The migration's room is the largest database plus 64 MiB. A schema migration's write-ahead log holds about one copy of each rewritten page; the report measured 685 MB of log for a shared database of about 0.7 GB. This is the only refusal left. It is always smaller than the old bound, so no update that passed before refuses now. The message gives the shortfall in MiB/GiB and in bytes.
The preflight reports a skipped image as a warning and refuses only for migration room. It returns
{ step, shortfall }, so the interactive offer to remove retirable recovery copies still appears when the image would be skipped. Without a terminal, it adds the removal advice as a warning instead of "then retry".The activation capture,
captureUpdateDatabases, skips only the backup owner's own measured shortfall (UpdateCaptureSpaceError, which crosses the worker boundary). That check runs before any family is checkpointed or copied, so no partial image or server capture exists. In that case the capture:database snapshotstep with exit code 0 and the warning.With no backup, the existing rollback owner already refuses to put the previous code on migrated state (
state-migrated-no-rollback). Any other failure still fails the update before migration. That includes a disk that fills during a copy, and a shortfall joined by a cleanup failure.Git release (
gitReleases) no longer runssnapshot-space-preflightbefore staging or before a package-to-Git clone. Release boots migrate at Gateway start, under that path's own space rules.The interactive cleanup offer is skipped for an install already serving from a Git release.
Not changed here, by scope:
openclaw update migrate(the supervisor capture), database migration capture, standalone Doctor's capture comparison and the original-state capture still refuse when their image does not fit. They now refuse at the smaller "what it writes" bound, keeping the "Free disk space before retrying; the databases have not been migrated" guidance. Their callers need the image as a receipt.requiredSnapshotBytes, used only when an older published updater drives) keeps its current check. Its refusal belongs to a contract with shipped updaters.Update behavior for published updaters: this changes the updater's own preflight and capture. An installed updater older than this change keeps its refusal until the first update after this lands has replaced it. The candidate side needs nothing. All install kinds share this code. Package and Git checkout updates get the skip-and-continue rule. Git release takes no image and runs no check.
Steps left to a person: none. Freeing space is optional: it only lets a later update keep its image. When the migration itself has no room, the refusal says how much to free; that is a migration that would fail, not a snapshot. The agent route
openclaw triagecovers it.Evidence
End-to-end, real disk, nothing mocked: a real 70 GiB APFS disk image (
hdiutilsparse image) holds a state directory whose shared database reports 40 GiB, as a valid sparse SQLite file whose header page count wins, plus an agent database. The realassessInitialUpdateSnapshotCapacityran from each checkout against it:999e873a916:exitCode: 1 (update refused), "Update database backup needs 200 GiB … only 70 GiB is available".a23f19641d1:exitCode: 0 (update continues). Warning: "No pre-migration database image: it needs 80 GiB … and 70 GiB is free. Without it, the previous version cannot be restored once the new version's database migration commits; a failed update then stays on the new version and is fixed forward." Migration room: 40 GiB needed, 70 GiB free.Recordings (playable MP4):
Earlier recordings on superseded heads are in the PR comments. Full raw logs are not attached because the artifact store rejected uploads from this machine.
Raw terminal output (paths redacted)
Through
updateCommand(update-command-package-space.test.ts, the real command with the fixture's staging stub). Free space is faked only at the owner's seam,tryReadDiskSpace.snapshot-capacity-insufficientbefore staging (this was the file's previous test).Capture (
update-command-database-retention.test.ts): the owner's measured shortfall skips the image, removes its empty directory, and records exit code 0 with the exact warning. The update still fails for an integrity failure, for a disk that filled mid-copy, and for a shortfall joined by a cleanup failure. RED on the previous headc82e86eeba9: the last two were skipped. GREEN now.Git release (
update-command-git-snapshot.test.ts):updateGitInstallhands the runner a staging space check only outside release mode, and running that check reads the snapshot source. RED with baseupdate-command-git.ts: a check was handed in release mode. GREEN now.Space owner (
update-database-backup-space.test.ts), with a sparse 20 GiB shared database:Checks run on the exact head
node scripts/run-vitest.mjson the eight touched test files: 106 tests passed.pnpm tsgo:core,pnpm tsgo:test:src: passed.pnpm check:baseline-ratchets: all ok.pnpm check:docs: passed.git diff --check: passed.origin/mainwas merged in; the core typecheck was rerun after the merge.Review rounds and what changed
Independent reviewer (fresh read-only subagent):
<root>.databasesexclusively (mkdirwithoutrecursive), and only the owner's measured shortfall, raised before any copy, is skipped.unchanged, and a Git release test added.ClawSweeper round 1 (head
c82e86eeba9): overall F, proof F, patch D. Findings:Test files audited in full:
update-database-backup-space.test.ts(rewritten).update-command-package-space.test.ts: the two refusal tests were replaced, because refusing for image space is the removed behavior; the migration-room refusal is kept.update-snapshot-space-cleanup.test.ts: the assess shape changed, and a skip case was added.update-command-git-snapshot.test.ts: refusal wording, and a release test added.update-command-database-retention.test.ts: skip and still-fails cases added.update-candidate-rehearsal.resources.test.ts: the preflight case now asserts skip, not refuse.update-command-git-timeout.test.ts: the mock shape.update-database-backup.test.ts: the case "preflights a separate source volume" asserted that capture reserved restore output, which is removed on purpose. It now asserts that capture succeeds on a tight or unknown source volume without a warning, and that the snapshots are intact.Why the removals are safe: each removed assertion checked the refusal this change removes, and its replacement checks the new outcome at the same seam.
Not proven:
openclaw updateof an installed package across a schema change on a full disk, end to end. The capture skip is proven atcaptureUpdateDatabases, with the backup owner stubbed at its boundary; the real owner's shortfall before any copy is proven inupdate-database-backup-space.test.ts.autoreviewdoes not run on this machine; an independent reviewer subagent was used instead.