Skip to content

feat(update): offer to remove old recovery copies when an update is short on space - #196873

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/update-offer-space-cleanup
Nov 11, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/update-offer-space-cleanup

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: an update refuses with snapshot-capacity-insufficient when the disk is short, even when old recovery copies from earlier updates are using the space and could already be removed.

User Impact

User impact: when space is short, an interactive openclaw update lists the recovery copies that openclaw update cleanup already counts as retirable, with their sizes. It asks whether to remove them permanently, defaulting to no. On yes, it removes them and checks space again before changing anything.

--yes, --json, updates without a terminal, and Control UI updates never delete anything. Their refusal names the reclaimable size and the next step.

Why This Change Was Made

  • One eligibility owner. Cleanup's existing inventory decides what may go, so protected, unverified and unmanifested copies are never offered.
  • Ownership. Removal goes through the same state-owner route as post-update cleanup: the running Gateway's update.recovery.cleanup handler, or local offline ownership when no Gateway runs.
  • When it asks.
    • Package updates make the offer at their existing preflight.
    • Git updates check space mid-update, just before staging, so they get the offer in the target phase while nothing has changed. That later check still decides whether to refuse, and it only reports.
  • Line cap. The target phase's space check moves to update-command-target-space.ts to keep update-command-target.ts under its line cap.

Evidence

  • src/cli/update-cli/update-command-package-space.test.ts drives updateCommand with a real shortfall and a superseded copy. The JSON refusal now names 1 recovery copy from earlier updates … can be removed. This fails on main and passes here; nothing is removed and staging never starts.
  • New src/cli/update-cli/update-snapshot-space-cleanup.test.ts uses real recovery copies and the real cleanup owner. Only the person's answer and the space reading are stubbed.
    • Interactive yes: only the superseded copy is removed, the latest copy stays, space is checked again, and the update proceeds.
    • Declining leaves everything and the original refusal.
    • --yes, --json, no terminal, and the mid-update report-only check never prompt or delete, and they append the guidance.
    • With nothing retirable, the refusal is unchanged.
  • 40 test files that import the target, git or update command modules: 309 of 310 pass. The one failure, update-command-node-engine-preflight.test.ts (service 26.8.2 case), fails the same way on main 1651ee19, so it is unrelated to this change.
  • 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 200-line allocation.
  • Autoreview (codex, P0–P2, high): scoped-clean, patch is correct (0.8).
  • Not covered: a live interactive update on a full disk. The interactive path is proven at the helper boundary with the real cleanup owner.

@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 size: M labels Nov 10, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature 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 real behavior proof before merge.

What this changes

This PR offers interactive removal of eligible recovery copies when an update lacks disk space, then checks capacity again.

Example: An update needs more space and an older successful update has a superseded recovery copy.

  • Before: The update refuses and requires the operator to discover and run cleanup separately.
  • After: The update lists reclaimable copies and asks permission to remove them before checking space again.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful direction and appropriate owner reuse, but destructive consent can exceed the displayed selection and authority-boundary proof is incomplete; latest-stable upgrade compatibility for retained recovery artifacts is also unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: An operator encounters a disk-space refusal even though existing recovery cleanup could reclaim space.
Reason: A default-no offer improves an existing recovery workflow without adding configuration, and maintainer authorship establishes direction.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: the guided cleanup is useful and maintainer-authored, but approval can delete recovery originals that the prompt never listed.

Priority: P2
Reviewed head: 93d8d8c06d27c1f92f7ef7489f22227ad95da0fd

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied helper tests demonstrate consent for a single superseded capture, but do not exercise exclusion of an unlisted verification-required original or revocation before final deletion through the running-Gateway route; provide allowed and forbidden final-effect evidence with sensitive details redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Restrict retirement to the recovery copies approved in the prompt (P1) - With one candidate capture and one verification-required historical original, the prompt lists only the capture because it filters outcome === "candidate". This call then uses full manual retirement with confirm always true: doctor-session-sqlite-retirement.ts verifies the historical original, promotes it to candidate, and deletes it too. The running-Gateway route has the same problem because it sends only dryRun false and its worker also confirms the expanded manual selection. This requires no concurrent inventory change and contradicts the promise to remove "these recovery copies." Bind approval to the exact verified selection on both routes, refusing or reconfirming any expansion.
  • Resolve security concern: Deletion consent expands across owner routing - Existing owner-liveness checks protect state custody, but they do not bind the CLI's consent to the final artifact selection.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Restrict retirement to the recovery copies approved in the prompt — src/cli/update-cli/update-snapshot-space-cleanup.ts:50-51
  • [medium] Deletion consent expands across owner routing — src/cli/update-cli/update-snapshot-space-cleanup.ts:51

Tests

  • Missing end-to-end proof: Supply production-path proof that approving the displayed selection cannot remove an unlisted historical original, through both offline and running-Gateway cleanup.
Agent review details

How this fits together

The CLI update preflight measures snapshot and activation capacity; this change connects a shortfall to the existing recovery inventory and routes deletion through the Gateway or exclusive offline state owner.

flowchart TD
A[Update CLI] --> B[Capacity assessment]
B --> C[Recovery inventory]
C --> D[Interactive confirmation]
D --> E[State owner routing]
E --> F[Recovery retirement]
F --> B
Loading

Technical review

Best possible solution:

Keep the existing inventory and retirement owners, but bind both local and Gateway deletion to the exact verified selection the user approved.

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

Source establishes the failure path: combine one listed candidate with a verification-required historical original whose import verifies successfully; approving the prompt reaches manual retirement that selects both.

Is this the best way to solve the issue?

Reusing cleanup eligibility and state ownership is appropriate, and the target-space extraction serves the existing line limit; the missing invariant is that final deletion must stay within the approved selection.

Full review comments:

  • [P1] Restrict retirement to the recovery copies approved in the prompt — src/cli/update-cli/update-snapshot-space-cleanup.ts:50-51
    With one candidate capture and one verification-required historical original, the prompt lists only the capture because it filters outcome === "candidate". This call then uses full manual retirement with confirm always true: doctor-session-sqlite-retirement.ts verifies the historical original, promotes it to candidate, and deletes it too. The running-Gateway route has the same problem because it sends only dryRun false and its worker also confirms the expanded manual selection. This requires no concurrent inventory change and contradicts the promise to remove "these recovery copies." Bind approval to the exact verified selection on both routes, refusing or reconfirming any expansion.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: The new destructive confirmation does not preserve the user's approved artifact scope through the final cleanup owner.

Evidence

Security concerns:

  • [medium] Deletion consent expands across owner routing — src/cli/update-cli/update-snapshot-space-cleanup.ts:51
    Existing owner-liveness checks protect state custody, but they do not bind the CLI's consent to the final artifact selection.
    Confidence: 0.99

What I checked:

PR surface

Source +193, Tests +200, Docs +12, Other +2. Total +407 across 10 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 4 238 45 +193
Tests 3 204 4 +200
Docs 2 14 2 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 10 458 51 +407

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: This is a useful improvement to an explicit CLI recovery workflow with a focused deletion-consent defect.
  • add merge-risk: 🚨 security-boundary: Interactive approval for listed recovery copies currently authorizes a broader destructive cleanup selection.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a useful improvement to an explicit CLI recovery workflow with a focused deletion-consent defect.
  • merge-risk: 🚨 security-boundary: Interactive approval for listed recovery copies currently authorizes a broader destructive cleanup selection.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

… short

An update that would refuse for lack of space now lists the recovery copies
that update cleanup already counts as retirable. In a terminal it asks before
removing them and checks space again; --yes, --json and Gateway-driven updates
never remove them and name their size in the refusal instead. The target
phase's space check moves to a sibling module.
@fuller-stack-dev
fuller-stack-dev force-pushed the fix/update-offer-space-cleanup branch from 93d8d8c to 521a4a3 Compare November 11, 2026 07:12
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) November 11, 2026 07:16
@fuller-stack-dev
fuller-stack-dev merged commit 5d53756 into openclaw:main Nov 11, 2026
149 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
… short (openclaw#196873)

An update that would refuse for lack of space now lists the recovery copies
that update cleanup already counts as retirable. In a terminal it asks before
removing them and checks space again; --yes, --json and Gateway-driven updates
never remove them and name their size in the refusal instead. The target
phase's space check moves to a sibling module.
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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant