Skip to content

fix(backup): continue when files vanish during archive creation - #153395

Merged
steipete merged 2 commits into
mainfrom
upd/backup-vanished-entries
Sep 20, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/backup-vanished-entries

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #153250. Related: #153315.

What Problem This Solves

openclaw backup create aborts when an active workspace removes a file between directory enumeration and lstat or open.

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 onwarn callback 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

  • Real filesystem regressions reproduced both ENOENT aborts before the repair; final coverage exercises archive creation, verification, restoration, and per-path reporting.
  • Additional regressions cover a second agent workspace, .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.
  • Broad backup suites: 285 passed, with 2 existing platform skips across 11 files. All four affected link cases passed again after the final fixture adjustment, including Windows header/PAX manifest equality and POSIX backslash create/verify/restore.
  • Fresh independent P1 review: scoped-clean. Targeted final lint passed.
  • node scripts/check-changed.mjs: passed, including production/test types, core/script lint, export and import-cycle scans, and repository guards.
  • Trusted dependency probe: vanished-file ENOENT, warning callback count 0.

Native Windows execution is left to CI; the missing-O_NOFOLLOW behavior 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 readback and records Windows PAX link targets matching tar readback use 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 target C:\external\workspace, parsed target C:/external/workspace, manifest equality false. Both pass after the fix with manifest equality true, including the long-target PAX case. The existing backupCreateCommand and backupRestoreCommand preserve a backslash in an absolute target regression 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.mjs passed. 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 671dfa96106ad50de49865103a6b5b2af8cddabe and 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.

@clawsweeper

clawsweeper Bot commented Sep 20, 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 commands Command implementations size: XL maintainer Maintainer-authored PR labels Sep 20, 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: 🦐 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 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 20, 2026, 4:40 AM ET / 08:40 UTC (Revision 6).

ClawSweeper review

What this changes

Backup 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
Reviewed head: 671dfa96106ad50de49865103a6b5b2af8cddabe

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent repair with meaningful regression coverage and the previous blocker resolved.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. Inspected regressions exercise the production archive owner with real filesystem mutations through create/verify/restore; the reported Windows evidence is explicitly simulated.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. Inspected regressions exercise the production archive owner with real filesystem mutations through create/verify/restore; the reported Windows evidence is explicitly simulated.
Evidence reviewed 7 items Introduced patch and review continuity: Reviewed the pinned merge-base-to-head changes. The checkout matches the previous completed review's head, and the Windows normalization now occurs immediately after readlink, before manifest recording and archive encoding. git diff --check passed and the working tree remained clean.
Current main still needs the repair: Fetched main still delegates traversal to tar.c with a synthetic stat cache; it does not contain the new resumable walker or vanished-entry callback.
Latest release comparison: The supplied latest release, v2026.9.5, also uses tar.c and the stat cache. The earlier merged symbolic-link repair does not resolve ordinary descendants disappearing during traversal.
Findings None None.
Security None None.

How this fits together

Backup 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
Loading

Before merge

  • Resolve merge risk (P2) - Native Windows create/verify/restore remains unobserved in the supplied evidence; Windows normalization and no-follow fallback coverage use platform fixtures.
Agent review details

Security

None.

PR surface

Source +47, Tests +347, Docs +2, Other 0. Total +396 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 6 257 210 +47
Tests 7 483 136 +347
Docs 1 18 16 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 15 759 363 +396

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +47 lines; tests and test support net +347 lines Production growth provides resumable traversal while retaining tar's encoders; most net growth covers archive behavior and failure boundaries.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one archive traversal owner that tolerates ordinary disappearance while preserving required captures, source boundaries, readable archives, and explicit omission reporting.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label justifications:

  • P2: Concurrent workspace deletion can prevent backup creation, but the report does not establish an emergency or broken core runtime.
  • 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 supplied repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. Inspected regressions exercise the production archive owner with real filesystem mutations through create/verify/restore; the reported Windows evidence is explicitly simulated.

Evidence

What I checked:

  • Introduced patch and review continuity: Reviewed the pinned merge-base-to-head changes. The checkout matches the previous completed review's head, and the Windows normalization now occurs immediately after readlink, before manifest recording and archive encoding. git diff --check passed and the working tree remained clean. (src/infra/backup-tar-walk.ts:48, 671dfa96106a)
  • Current main still needs the repair: Fetched main still delegates traversal to tar.c with a synthetic stat cache; it does not contain the new resumable walker or vanished-entry callback. (src/infra/backup-create.ts:603, 7a48330c1199)
  • Latest release comparison: The supplied latest release, v2026.9.5, also uses tar.c and the stat cache. The earlier merged symbolic-link repair does not resolve ordinary descendants disappearing during traversal. (src/infra/backup-create.ts:603, ec9c1a13db89)
  • Required-source and publication boundaries: The writer distinguishes required roots and staged captures from optional descendants, retains SQLite snapshot exclusions, propagates non-ENOENT failures, and reports omissions outside the bounded restore manifest. The updater's separate configuration snapshot path does not call this archive writer. (src/infra/backup-create.ts:476, 671dfa96106a)
  • Dependency contract inspected: The patch directly consumes tar Header/Pax encoders, establishing the dependency signal. Inspected tar 7.5.22 source: filesystem stat failures emit errors, portable mode matches the replacement writer's permission handling, and Windows link normalization replaces backslashes. Package metadata identifies isaacs/node-tar as the source repository; the tag resolves to the cited dependency commit. (src/normalize-windows-path.ts:6, 2a22bfc5d3a4)
  • Regression coverage and supplied validation: Inspected tests exercising real filesystem removal before lstat/open through backup creation, verification, restoration, and omission reporting, plus replacement, required-root loss, I/O errors, and large omission sets. The captured PR body reports 285 passing tests and two existing platform skips; Windows checks use a path-mode fixture, not native Windows. Tests were not executed during this read-only review. (src/infra/backup-create.vanished.test.ts:13, 671dfa96106a)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • adele-with-a-b: 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 (5 earlier review cycles)
  • reviewed 2026-09-20T03:32:04.141Z sha 1112ffc :: blocked before merge. :: [P1] Normalize Windows link targets before recording them
  • reviewed 2026-09-20T03:52:02.759Z sha 1112ffc :: blocked before merge. :: [P1] Normalize Windows link targets before recording them
  • reviewed 2026-09-20T05:39:01.403Z sha 1112ffc :: blocked before merge. :: [P1] Normalize Windows link targets before recording them
  • reviewed 2026-09-20T06:15:59.941Z sha 49312e8 :: blocked before merge. :: none
  • reviewed 2026-09-20T08:19:20.254Z sha 671dfa9 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 20, 2026 03:39
@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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 20, 2026
@steipete
steipete force-pushed the upd/backup-vanished-entries branch from 49312e8 to f601c48 Compare September 20, 2026 08:08
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.
@steipete
steipete force-pushed the upd/backup-vanished-entries branch from f601c48 to 671dfa9 Compare September 20, 2026 08:11
@steipete
steipete merged commit 4735c02 into main Sep 20, 2026
215 checks passed
@steipete
steipete deleted the upd/backup-vanished-entries branch September 20, 2026 09:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

backup create aborts on any file vanishing mid-walk (ENOENT untolerated), and on a single dangling absolute symlink

1 participant