Skip to content

fix(backup): refuse restores that exceed target capacity - #164492

Merged
RomneyDa merged 1 commit into
mainfrom
fix/backup-restore-capacity
Oct 3, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/backup-restore-capacity

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 3, 2026

Copy link
Copy Markdown
Member

Related: #125416

What Problem This Solves

Fixes: a full backup restore can fill the target filesystem before failing when the uncompressed archive does not fit.

User Impact

User impact: operators get an actionable capacity error before OpenClaw creates or extracts into the restore target.

Why This Change Was Made

The verified archive inventory now carries its regular-file extraction size into restore admission. Restore requires that size plus a 256 MiB safety reserve on the target volume; hardlinks do not count their referenced data twice. If filesystem capacity cannot be determined, restore keeps the existing best-effort behavior.

Evidence

  • pnpm test src/commands/backup-restore.test.ts --maxWorkers=1: 21/21 passed; Vitest duration 19.82s, wall time 25.02s.
  • Regression covers refusal before target creation, exact-capacity admission, and preserved hardlink identity.
  • Affected command-test TypeScript graph and changed-file Oxlint pass.
  • git diff --check passes.
  • Independent P1 AutoReview: scoped-clean.

@clawsweeper

clawsweeper Bot commented Oct 3, 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.

@RomneyDa
RomneyDa marked this pull request as ready for review October 3, 2026 19:42
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Oct 3, 2026
@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. 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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 3, 2026, 3:47 PM ET / 19:47 UTC.

ClawSweeper review

What this changes

The PR measures regular-file archive bytes and refuses full restores before target creation when available space cannot cover the payload plus a 256 MiB reserve.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: the restore safeguard is absent from current main and the latest release, and no introduced correctness defect was found. The MEMBER-authored PR also requires explicit maintainer handling.

Priority: P2
Reviewed head: 2c5cbf77b57ece423ad1659e630f09a7d29fc0ac
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful boundary coverage and no concrete defect; the reserve tradeoff remains a maintainer choice.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its regression exercises restore admission with mocked capacity observations; no live execution is claimed, and no stored-data format changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its regression exercises restore admission with mocked capacity observations; no live execution is claimed, and no stored-data format changes.
Evidence reviewed 8 items Introduced changes and merge result: The pinned introduction adds only archive-size accounting, restore admission, and its regression. The verified test merge preserves the same restore change against its main parent.
Current main still needs the guard: Current main proceeds from archive preparation to target creation without measuring full extraction capacity.
Latest release comparison: The v2026.9.8 restore implementation also lacks full-target capacity admission; this PR is not redundant with the latest shipped release.
Findings None None.
Security None None.

How this fits together

Full backup restore verifies a local or downloaded archive, then extracts it into a fresh staging directory. The new capacity check controls admission to extraction without activating or rewriting live state.

flowchart TD
  A[Local or downloaded backup] --> B[Archive verification]
  B --> C[Regular file byte total]
  D[Target volume free space] --> E[Payload plus reserve fits]
  C --> E
  E -->|Yes or measurement unavailable| F[Fresh staging extraction]
  E -->|No| G[Actionable capacity error]
Loading

Decision needed

Question Recommendation
Should full restore refuse an otherwise fitting archive when it would leave less than 256 MiB free? Retain the hard reserve: Explicitly accept the low-headroom refusal to match the existing SQLite verification reserve pattern.

Why: This intentionally changes an existing recovery path; source correctness cannot determine whether preserving host headroom outweighs allowing that restore.

Before merge

  • Resolve merge risk (P1) - Existing low-headroom recovery workflows will now refuse even when the archive itself fits if less than 256 MiB would remain; confirm that this unconditional reserve is the intended restore policy.
  • Complete next step (P2) - Confirm whether fitting restores must be refused when they would leave less than 256 MiB free.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +47, Tests +76. Total +123 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 48 1 +47
Tests 1 77 1 +76
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 125 2 +123

Review metrics

Metric Value Why it matters
Restore admission floor Payload bytes + 256 MiB This new unconditional threshold changes which existing recovery attempts are admitted.
Production versus test growth production +47 net lines; tests +76 net lines Production growth is justified by archive-byte accounting and admission before extraction.

Merge-risk options

Maintainer options:

  1. Accept the recovery headroom floor (recommended)
    Confirm that rejecting fitting archives below the 256 MiB remaining-space floor is intentional.
  2. Preserve fitting low-headroom restores
    Keep payload insufficiency blocking while reporting reserve-only insufficiency as an actionable warning.

Technical review

Best possible solution:

Keep capacity admission in the restore owner, with an explicitly accepted reserve policy and best-effort behavior when measurement is unavailable.

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

Yes, from source: current main starts full extraction without checking whether the archive fits its target volume. No runtime reproduction was executed in this read-only review.

Is this the best way to solve the issue?

Yes for the implementation boundary: reuse the existing filesystem probe and carry archive inventory into restore admission. The unconditional reserve remains an explicit recovery-policy choice.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded restore reliability improvement without evidence of an urgent widespread regression.
  • add merge-risk: 🚨 compatibility: The fixed reserve can prevent previously successful restores on volumes where the payload fits but 256 MiB of headroom does not.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its regression exercises restore admission with mocked capacity observations; no live execution is claimed, and no stored-data format changes.

Label justifications:

  • P2: This is a bounded restore reliability improvement without evidence of an urgent widespread regression.
  • merge-risk: 🚨 compatibility: The fixed reserve can prevent previously successful restores on volumes where the payload fits but 256 MiB of headroom does not.
  • 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 MEMBER-authored PR is exempt from ordinary contributor proof. Its regression exercises restore admission with mocked capacity observations; no live execution is claimed, and no stored-data format changes.

Evidence

What I checked:

  • Introduced changes and merge result: The pinned introduction adds only archive-size accounting, restore admission, and its regression. The verified test merge preserves the same restore change against its main parent. (src/commands/backup-restore.ts:176, 2c5cbf77b57e)
  • Current main still needs the guard: Current main proceeds from archive preparation to target creation without measuring full extraction capacity. (src/commands/backup-restore.ts, fe6414a23399)
  • Latest release comparison: The v2026.9.8 restore implementation also lacks full-target capacity admission; this PR is not redundant with the latest shipped release. (src/commands/backup-restore.ts, fc23bc864e45)
  • Existing measurement owner: The reused probe resolves the nearest existing ancestor, measures bavail times block size, and returns null when measurement is unavailable. Restore retains best-effort behavior for that null result. (src/infra/disk-space.ts:36, 2c5cbf77b57e)
  • Reserve compatibility tradeoff: The unconditional payload-plus-256-MiB requirement rejects otherwise fitting archives on low-headroom volumes. SQLite verification already uses the same reserve pattern, but the PR extends refusal to full restore targets; its body proposes this behavior without a separate acceptance of the recovery tradeoff. (src/commands/backup-restore.ts:91, 2c5cbf77b57e)
  • Focused regression coverage: The added test exercises the production restore command with injected statfs observations, checks refusal leaves no target, admits the exact logical-byte threshold, and verifies hardlink inode identity. The body reports 21 passing tests and 25.02 seconds wall time; this read-only review did not execute tests. (src/commands/backup-restore.test.ts:425, 2c5cbf77b57e)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Abdel Gomez-Perez: 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.

@RomneyDa
RomneyDa enabled auto-merge (squash) October 3, 2026 22:33
@RomneyDa
RomneyDa merged commit dd64b3b into main Oct 3, 2026
193 of 194 checks passed
@RomneyDa
RomneyDa deleted the fix/backup-restore-capacity branch October 3, 2026 22:33
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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