Repository navigation
fix(backup): continue when files vanish during archive creation - #153395
Conversation
|
🦞👀 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. |
|
Codex review: blocked before merge. Reviewed September 20, 2026, 4:40 AM ET / 08:40 UTC (Revision 6). ClawSweeper reviewWhat this changesBackup creation skips and reports vanished descendants, filters transient filenames across selected roots, and opens files before writing archive headers while preserving platform-specific symbolic-link targets. Merge readiness⛔ Blocked before merge - 1 item remains The disappearance race remains on current main, so this PR is still useful. The prior Windows normalization finding is resolved, and this review found no blocking correctness defect. Priority: P2 Review scores
Verification
How this fits togetherBackup creation combines selected state and workspace files with staged configuration and database snapshots. The archive writer produces a compressed backup and omission reports for verification, restoration, and CLI output. flowchart TD
A[Selected state and workspaces] --> C[Backup resource inventory]
B[Staged configuration and database snapshots] --> D[Archive traversal]
C --> D
D --> E[Open and validate each source]
E --> F[Skip vanished descendants and report]
E --> G[Encode surviving entries]
G --> H[Publish compressed backup and summary]
F --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +47, Tests +347, Docs +2, Other 0. Total +396 across 15 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one archive traversal owner that tolerates ordinary disappearance while preserving required captures, source boundaries, readable archives, and explicit omission reporting. Do we have a high-confidence way to reproduce the issue? Yes, from source: deleting an ordinary workspace file between enumeration and lstat/open makes the current tar traversal emit ENOENT and abort. This review did not execute the reproduction. Is this the best way to solve the issue? Yes. Opening sources before emitting headers permits safe omission without restarting traversal; an onwarn callback cannot recover the dependency's error path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7a48330c1199. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
49312e8 to
f601c48
Compare
Report vanished entries without restarting traversal, apply transient filename policy to selected archive trees, and preserve required roots and source identity boundaries. Keep omission reports outside the bounded restore manifest.
f601c48 to
671dfa9
Compare
|
Merged via squash.
|
…claw#153395) Backups of active workspaces could abort when a file disappeared between directory enumeration and lstat/open. Open regular files before writing archive headers so vanished descendants are omitted with per-path warnings while surviving data remains verifiable and restorable. Keep required roots and captures, unsafe source substitutions, and I/O failures as publication blockers. Use the existing resource inventory and tar Header/Pax encoder; retain truncation retries and keep omission reports outside the size-limited restore manifest. Normalize Windows link targets once before manifest recording and encoding, preserving literal POSIX backslashes. This repairs explicitly requested full backups before updates. The automatic updater's separate configuration snapshot is unchanged. No configuration options, schemas, or dependencies change. Evidence: 285 backup tests passed with 2 existing platform skips across 11 files; check-changed passed; independent P1 review scoped-clean; exact-head CI green. Windows tar path-mode coverage passed; native Windows execution was not independently verified. Thanks to @migelizaga-rgb for the report and reproduction. Fixes openclaw#153250. Related: openclaw#153315.
Fixes #153250. Related: #153315.
What Problem This Solves
openclaw backup createaborts when an active workspace removes a file between directory enumeration andlstatoropen.User Impact
Backups retain surviving entries and report each vanished path and its reason in the result and text warnings. Transient filenames, including
.tmp.*, are filtered across archived roots, while explicitly selected roots remain included. Absolute and dangling symbolic links retain their targets. Windows separators are normalized to forward slashes; POSIX target text, including literal backslashes, is preserved.Why This Change Was Made
The filesystem failures in this path are emitted as errors, so an
onwarncallback does not make traversal resumable. The backup owner now opens regular files before emitting their tar headers, using tar's existing Header/Pax encoder and the frozen resource inventory. Missing descendants can be skipped without corrupting the archive or restarting traversal. Unsafe source substitutions, missing required roots/captures, and I/O errors still prevent publication. Existing retries remain only for truncated reads; the old message-based retry predicate is removed.Per-entry omission reports stay in the result so large volatile trees cannot overflow the restore manifest's existing 1 MiB limit. A single planned source set owns traversal and required-root decisions. POSIX copies remain bound to the opened descriptor through subsequent regular-file renames; platforms without kernel no-follow support retain explicit identity checks.
The automatic updater uses a separate configuration snapshot (
src/cli/update-cli/update-command-package.ts:127→src/config/backup-rotation.ts:174); it does not call this full-archive writer. This fixes the separately requested full backup used before an update. Dangling-link support was already repaired by #141925 and remains covered.Thanks to @migelizaga-rgb for the report and reproduction.
Evidence
.tmp.*, explicit roots ending in.tmp, ordinary atomic replacement, unlink after open, directory/leaf symlink substitution, required-root loss, source I/O errors, and 9,000 volatile files.node scripts/check-changed.mjs: passed, including production/test types, core/script lint, export and import-cycle scans, and repository guards.ENOENT, warning callback count0.Native Windows execution is left to CI; the missing-
O_NOFOLLOWbehavior is exercised locally with real file handles and Windows-equivalent open flags. No live Gateway or operator state was used.ClawSweeper review disposition
The Windows link-target normalization P1 is fixed at 49312e8.
The walker now normalizes Windows separators immediately after
fs.readlink(), before the same target reaches either manifest recording or tar encoding. This matches tar 7.5.22 and preserves literal backslashes on POSIX. No options, environment controls, schemas, or dependencies were added.The regressions
records Windows header link targets matching tar readbackandrecords Windows PAX link targets matching tar readbackuse real filesystem symlinks, the real walker and manifest policy, and tar's existing Windows path-mode fixture in a fresh reader. Both failed before the fix: manifest targetC:\external\workspace, parsed targetC:/external/workspace, manifest equality false. Both pass after the fix with manifest equality true, including the long-target PAX case. The existingbackupCreateCommand and backupRestoreCommand preserve a backslash in an absolute targetregression also passes. The dangling-link fixture now expects the same Windows archive separator convention.Validation: all 11 backup test files passed (285 tests passed, 2 existing platform skips); all four targeted link cases passed again after the final fixture adjustment.
node scripts/check-changed.mjspassed. Fresh final P1 autoreview is scoped-clean. Follow-up delta: production +4/-0; tests +75/-1 (net +74); docs +3/-3.The normalization rank-up move is applied. The Windows proof uses tar's path-mode fixture, not a native Windows host; no native external-junction create/verify/restore claim is made. POSIX create/verify/restore remains covered.
Latest ClawSweeper review (September 20, 2026, 08:40 UTC, revision 6) covers head
671dfa96106ad50de49865103a6b5b2af8cddabeand reports no correctness or security findings. The Windows normalization rank-up move is applied.Disposition of the remaining P2 merge-risk item: additional native Windows create/verify/restore proof is skipped for this landing. The existing approved review, green hosted CI, real tar Header/PAX readback fixtures, Windows-equivalent no-follow fallback coverage, and POSIX create/verify/restore regressions support the bounded repair. The implementation keeps one archive traversal owner and preserves required-source, source-boundary, and publication checks. Native Windows execution remains unverified; this is an accepted proof limitation, not a claim of native platform validation. No semantic change was made after review.