Skip to content

fix(update): check snapshot capacity before staging - #147908

Merged
steipete merged 5 commits into
mainfrom
steipete/upd-disk-space-preflight
Sep 14, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/upd-disk-space-preflight

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Updates can stage a replacement before discovering that no eligible filesystem can hold the required private state snapshot. Requested by Vyctor (@vyctorbrzezowski) in Discord #maintainers.

Builds on / complements #147883, merged as e7f19d4. This branch is rebased onto main containing that change. Refs #117415 and #118886.

User Impact

Before staging, the updater reports exact bytes for each known SQLite family and the snapshot requirement versus free bytes at each eligible destination. It refuses only when every destination has a known shortfall under the snapshot owner's existing capacity requirement: the private state copy cannot be taken safely. Unknown capacity, incomplete measurements, or a usable alternative remain warnings and proceed to the existing complete check after staging.

Package-space warnings remain advisory under #147883. Already-current package and Git targets keep their no-op behavior. An already-installed 2026.9.3 updater can still fail late on its own first hop because this check runs in the installed driver.

Why This Change Was Made

Reuse the snapshot owner's initial inventory, sizing, and placement policy: twice the known SQLite-family bytes, three times the largest family, and the existing 64 MiB metadata allowance. Families include database, WAL, SHM, and journal files. The destinations remain TMPDIR, the capture directory beside state, and the system temporary directory; a state-directory mount does not imply its sibling is on the same filesystem.

Package replacements consume this assessment in target resolution after no-op detection. Git consumes the same assessment after its resolved no-op check and before worktree allocation; package-to-Git conversion checks before cloning. Diagnostics use the existing run ledger and warning projection. The full candidate inventory and post-staging check are unchanged.

Plugin copies and registered external databases remain explicitly unknown at this early point. The updater preserves a config copy, not a full-state backup. This diff adds no package/source-size estimator, configuration option, database schema, protocol, retention policy, or UI changes.

Evidence

  • Five package CLI regressions failed with the rebased-main target owner restored, then passed with the snapshot checkpoint. Seven selected CLI cases pass, including fix(update): show status refresh feedback and earlier disk warnings #147883's early advisory package warning and an already-current update with zero reported free space.
  • Two real-change Git regressions failed before the snapshot hook while two no-op controls passed; all four now pass through both direct and private-inspection routes.
  • The six earlier update-CLI CI failures pass under the narrowed implementation.
  • All 54 existing canary/resource tests pass, preserving the complete post-staging snapshot behavior.
  • Fresh independent Codex autoreview: P1 scoped-clean. The ClawSweeper review also found no actionable defect and its completed revision accepted the live qualification.
  • pnpm check:changed passed in full on the final committed diff (production/test types, changed-file lint, formatting, dead exports, and all selected guards). An earlier whole-core lint run also found an unrelated existing max-lines failure at ui/src/test-helpers/app-sidebar-cases/session-ownership.ts:765; that file is byte-identical to the rebase base.
  • Exact-head CI is green for 57a02a0faf69bcd495fd5274839a5a40f2cf2dc5: run 34836629616, attempt 2. The first attempt hit a Gateway config.patch request timeout and an ENOTEMPTY memory-watcher cleanup failure in owners byte-identical to the tested main parent; both passed one failed-job rerun with unchanged source and test settings. The earlier lint, startup-budget, and ClawHub fixture gates also passed. Both empty CI refresh commits preserve the source tree used by the regression and live qualification below.
  • Published 2026.9.3 → candidate → future passed through the canonical pnpm test:docker:update-first-hop-compat lane on Blacksmith Testbox tbx_01m2fask4dd7ycv7hr5hpcyqq8 (run). Both hops exited 0, preserved active service intent, and left zero residue; the future updater ran without legacy compatibility chunks. The wrapper verified source d2ce6bafe4c6706d0a400f21e48ef5d8e46288f8 and its exact tree before building the frozen package.
  • Final constrained-filesystem proof passed on Blacksmith Testbox tbx_01m2fbg961smc6d50fmw6qjwcf (run), using this exact source tree. All three snapshot destinations were bounded 64 MiB tmpfs mounts: the updater reported 74,993,664 bytes needed versus 66,990,080 / 67,108,864 / 67,092,480 bytes free, named both SQLite families, refused before staging, persisted snapshot-capacity-insufficient, and preserved config/runtime hashes. The final harness also verified the ledger's normal path redaction. L326_RESULT=passed; wrapper exit 0; lease stopped. An earlier harness run stopped on the unredacted-path expectation, which was corrected without product changes. Testbox backing Actions runs can show cancellation after successful delegated cleanup.

Release-note context: updates report state-snapshot capacity before staging and refuse only a known all-destination snapshot shortfall, preserving best-effort warnings otherwise.

Regression commands and trimmed results

With the rebased-main target owner temporarily restored:

node scripts/run-vitest.mjs src/cli/update-cli.test.ts -t 'checks initial snapshot capacity before staging'
FAIL checks initial snapshot capacity before staging (insufficient)
AssertionError: promise resolved "undefined" instead of rejecting
Tests  5 failed | 497 skipped (502)

With the fix, plus the advisory-package and no-op controls:

node scripts/run-vitest.mjs src/cli/update-cli.test.ts -t 'checks initial snapshot capacity before staging|records low disk space before target lookup|keeps an explicit same-version channel no-op'
Tests  7 passed | 495 skipped (502)
node scripts/run-vitest.mjs src/infra/update-candidate-canary.test.ts src/infra/update-candidate-rehearsal.resources.test.ts src/cli/update-cli/update-command-git-snapshot.test.ts
pnpm check:changed
Canary/resource tests: 54 passed
Git snapshot/no-op tests: 4 passed
check:changed: exit 0

ClawSweeper review

The completed 11:26 UTC review covers this exact head, accepts the retained published-updater and constrained-filesystem qualification, and finds no actionable defect. Earlier installation-size and Git no-op findings were already resolved in the reviewed source. No additional code fixups or skipped findings were needed. One re-review request was posted after the first tree-identical CI refresh.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 gateway Gateway runtime cli CLI command changes commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 14, 2026
@steipete
steipete marked this pull request as ready for review September 14, 2026 04:45
@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 7:26 AM ET / 11:26 UTC (Revision 5).

ClawSweeper review

What this changes

The updater checks known state-snapshot space before staging package or Git replacements, reports capacity diagnostics, and preserves already-current updates.

Merge readiness

✅ Ready for maintainer review

This remains useful work beyond current main. The earlier findings are resolved, the qualification evidence remains applicable to the unchanged source tree, and no actionable patch defect was found.

Priority: P2
Reviewed head: 57a02a0faf69bcd495fd5274839a5a40f2cf2dc5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with applicable real qualification, meaningful regression coverage, and no remaining actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The captured Testbox results exercise the updater's snapshot assessment on constrained filesystems and show refusal before staging with preserved state; the published-updater round trip covers upgrade compatibility. Identical source trees preserve that qualification across both CI-refresh commits; raw logs were inaccessible to this reviewer.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The captured Testbox results exercise the updater's snapshot assessment on constrained filesystems and show refusal before staging with preserved state; the published-updater round trip covers upgrade compatibility. Identical source trees preserve that qualification across both CI-refresh commits; raw logs were inaccessible to this reviewer.
Evidence reviewed 7 items Pinned source and review continuity: The diff from the previous reviewed head to HEAD is empty. HEAD and qualified source d2ce6ba both resolve to tree 08cf0e7e23ab4fee8cf70f3db51a38cd1d81495d. The complete merge-base delta was inspected locally, including hunks omitted from the supplied patch.
One snapshot-capacity owner: The initial assessment and complete snapshot preparation share the existing database inventory, budget formula, and destination selection. Early refusal requires every candidate to have a known shortfall; measurement failure remains advisory. No installation-size estimator remains.
No-op ordering and production callers: Package target resolution skips the assessment for already-current targets. Git invokes the hook after resolving its no-op decision and before allocating the candidate worktree; the inspection adapter forwards the hook. Package-to-Git conversion checks before cloning.
Findings None None.
Security None None.

How this fits together

OpenClaw validates updates against a private copy of operator state before replacing the running installation. This change checks the snapshot owner's existing space requirement earlier, using local database sizes and destination free space.

flowchart TD
  A[Requested update] --> B{Already current?}
  B -->|Yes| C[Skip replacement]
  B -->|No| D[Measure known database families]
  D --> E{All destinations have known shortfall?}
  E -->|Yes| F[Report refusal before staging]
  E -->|No| G[Stage replacement]
  G --> H[Complete snapshot and candidate validation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +190, Tests +216, Docs +6. Total +412 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 8 204 14 +190
Tests 2 217 1 +216
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 427 15 +412

Review metrics

None.

Technical review

Best possible solution:

Keep the early assessment within the existing snapshot owner, preserving best-effort warnings, no-op updates, and complete post-staging validation.

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

Yes, from source: a non-current update with insufficient space at every snapshot destination reaches the existing check only after staging. The supplied regression results establish that ordering failure; no runtime reproduction was executed in this review.

Is this the best way to solve the issue?

Yes. Reusing the existing snapshot budget and allocator destinations avoids competing estimates, while the narrowed refusal preserves advisory behavior and already-current updates.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This bounded update reliability fix avoids staging work when the required private snapshot cannot fit.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The captured Testbox results exercise the updater's snapshot assessment on constrained filesystems and show refusal before staging with preserved state; the published-updater round trip covers upgrade compatibility. Identical source trees preserve that qualification across both CI-refresh commits; raw logs were inaccessible to this reviewer.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Testbox results exercise the updater's snapshot assessment on constrained filesystems and show refusal before staging with preserved state; the published-updater round trip covers upgrade compatibility. Identical source trees preserve that qualification across both CI-refresh commits; raw logs were inaccessible to this reviewer.

Evidence

What I checked:

  • Pinned source and review continuity: The diff from the previous reviewed head to HEAD is empty. HEAD and qualified source d2ce6ba both resolve to tree 08cf0e7e23ab4fee8cf70f3db51a38cd1d81495d. The complete merge-base delta was inspected locally, including hunks omitted from the supplied patch. (57a02a0faf69)
  • One snapshot-capacity owner: The initial assessment and complete snapshot preparation share the existing database inventory, budget formula, and destination selection. Early refusal requires every candidate to have a known shortfall; measurement failure remains advisory. No installation-size estimator remains. (src/infra/update-candidate-snapshot.ts:98, 57a02a0faf69)
  • No-op ordering and production callers: Package target resolution skips the assessment for already-current targets. Git invokes the hook after resolving its no-op decision and before allocating the candidate worktree; the inspection adapter forwards the hook. Package-to-Git conversion checks before cloning. (src/infra/update-runner-git-preflight.ts:599, 57a02a0faf69)
  • Focused regression coverage: The package cases cover insufficient space, a usable alternative, unknown capacity, ample capacity, and package-only pressure. Four Git cases exercise changed versus current targets through direct and private-inspection routes, asserting no candidate allocation or installed-state mutation on refusal. These were inspected, not executed during this read-only review. (src/cli/update-cli.test.ts:7824, 57a02a0faf69)
  • Current-main necessity and related work: Current main retains snapshot capacity checking inside candidate snapshot preparation without this initial assessment. GitHub confirms fix(update): show status refresh feedback and earlier disk warnings #147883 merged as e7f19d4; its advisory package-space warnings complement this change. The snapshot module is absent at the supplied latest release v2026.9.4, so no released implementation of this checkpoint was established. (src/infra/update-candidate-snapshot.ts:154, f4ffd8c21fcd)
  • Real qualification and inspection limits: The captured body at sourceRevision bee7742e6affe378080a1a161331f379c7434ee9ad5aacb55adcfa38edaea745 reports published 2026.9.3 → candidate → future qualification with service intent preserved and zero residue: https://github.com/openclaw/openclaw/actions/runs/34815020718. Its constrained-filesystem run reports 74,993,664 bytes required against three smaller destinations, refusal before staging, persisted diagnostics, path redaction, and preserved config/runtime hashes: https://github.com/openclaw/openclaw/actions/runs/34815907946. Raw log retrieval redirected to an allowlist-blocked storage host; assessment preserves the detailed captured results and previously accepted qualification. Prepared screenshots were inspected and belong to the related status-feedback PR, not this snapshot proof. (d2ce6bafe4c6)

Likely related people:

  • steipete: 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 (4 earlier review cycles)
  • reviewed 2026-09-14T04:56:47.406Z sha c236978 :: blocked before merge. :: [P1] Exclude unrelated Git files from the blocking capacity estimate | [P2] Preserve Git no-op detection before requiring staging capacity
  • reviewed 2026-09-14T06:52:24.025Z sha d2ce6ba :: blocked before merge. :: none
  • reviewed 2026-09-14T07:22:48.734Z sha d2ce6ba :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T09:29:24.827Z sha 04543a6 :: blocked before merge. :: none

Estimate installation, config-copy, and initial canary snapshot costs on their actual filesystems before staging. Preserve the full post-staging inventory and warn when capacity estimates are incomplete.
Build on the target-resolution warning checkpoint from #147883. Reuse the snapshot owner’s known SQLite-family budget and placement policy; refuse only a known shortfall at every eligible destination and record warnings otherwise. Preserve no-op updates and the complete post-staging check.
@steipete
steipete force-pushed the steipete/upd-disk-space-preflight branch from c236978 to d2ce6ba Compare September 14, 2026 06:42
@steipete steipete changed the title fix(update): refuse staging below the known disk-space bound fix(update): check snapshot capacity before staging Sep 14, 2026
@clawsweeper clawsweeper Bot added 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 14, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The branch received one empty CI refresh commit after the main gate repairs landed. The reviewed source tree is unchanged. The PR Evidence section now contains the completed published-updater round trip and constrained-filesystem qualification requested by the last review.

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label Sep 14, 2026
This was referenced Oct 27, 2026
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 maintainer Maintainer-authored PR 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: 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