fix(backup): sweep stale temp artifacts before creating new backup#95600
fix(backup): sweep stale temp artifacts before creating new backup#95600zhfnini-rgb wants to merge 2 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 3:26 AM ET / 07:26 UTC. Summary PR surface: Source +157, Tests +148. Total +305 across 2 files. Reproducibility: yes. source-level: current main uses timestamped default/directory backup basenames, while the PR only sweeps archive temp files matching the current run's basename. I did not run a destructive hard-kill repro in this read-only review. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Repair the archive-temp matcher to cover prior OpenClaw timestamped backup temp basenames under the same age and owner guards, then land after maintainer acceptance of the cleanup policy. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main uses timestamped default/directory backup basenames, while the PR only sweeps archive temp files matching the current run's basename. I did not run a destructive hard-kill repro in this read-only review. Is this the best way to solve the issue? No, not as submitted. The startup sweep is the right layer, but the archive-temp matching is too narrow for the documented default and directory-output flows. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0ce10d779302. Label changesLabel justifications:
Evidence reviewedPR surface: Source +157, Tests +148. Total +305 across 2 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
04e6ef6 to
6fe6f0f
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…w backup On hard kill (SIGKILL, OOM, host reboot), the in-process finally block in createBackupArchive cannot fire, orphaning multi-GB staging dirs (openclaw-backup-*) and temp archives (*.uuid.tmp) in os.tmpdir(). Nothing reaps them, so they accumulate across interrupted runs. Add sweepStaleBackupArtifacts() that runs at the start of each backup create, removing the tool's own stale artifacts older than a 1-hour grace window. This follows the same pattern as openclaw#92891 (memory backend reindex temps). Fixes openclaw#95582
57750e7 to
300d72b
Compare
|
Hi maintainers, quick status update on this PR:
Could a maintainer take a look when available? |
|
This pull request has been automatically marked as stale due to inactivity. |
What Problem This Solves
Fixes an issue where interrupted
backup createruns can leave stale backup staging directories and full-size temporary archive files behind. A hard kill, OOM, host reboot, or process restart skips the in-process cleanup block, so these artifacts can accumulate and consume disk space across later backup runs.Fixes #95582
Why This Change Was Made
The backup startup path now sweeps only OpenClaw-owned stale backup artifacts older than one hour before creating a new archive. The sweep is scoped to the selected backup staging temp root for
openclaw-backup-*directories and to the requested output path's sibling temp files matching<output basename>.<uuid>.tmp, avoiding broad deletion of unrelated shared-temp files.Active backup runs now write owner markers for both artifact classes. Startup cleanup checks those owner markers and skips artifacts whose owner PID is still live, so long-running or concurrent backups are not removed by an age-only sweep.
User Impact
Users and operators can rerun
backup createafter a killed or interrupted backup and have old OpenClaw backup temp artifacts cleaned automatically before the new backup starts. Recent artifacts and artifacts owned by a live backup process remain protected.Evidence
pnpm install --frozen-lockfilepnpm exec vitest run -c test/vitest/vitest.infra.config.ts src/infra/backup-create.test.ts -t "sweepStaleBackupArtifacts"-> 7 passed, 38 skippedgit diff --check-> passednode scripts/run-vitest.mjs src/infra/backup-create.test.tsreached 28 passed before existingcreateBackupArchivetests failed on Windows withEBUSYunlinking temp SQLite files during test cleanup.node scripts/run-vitest.mjs src/commands/backup.atomic.test.ts src/commands/backup.test.tshadbackup.atomic.test.tspass;backup.test.tshad 13 passed and 1 WindowsEBUSYcleanup failure on a temp SQLite WAL file.