Repository navigation
fix(backup): preserve cyclic symbolic links during archive creation - #146161
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 12, 2026, 2:43 PM ET / 18:43 UTC (Revision 7). ClawSweeper reviewWhat this changesBackup creation preserves cyclic and dangling symbolic links while applying private-capture exclusions to link names, resolved targets, and SQLite snapshot sources. Merge readiness⛔ Blocked before merge - 3 items remain This fix remains necessary on current main. The latest commit resolves the previous capture-root alias finding, and no blocking code defect remains; the documented older-reader limitation needs a maintainer compatibility decision. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s backup pipeline collects configured files and databases, excludes private recovery captures, and produces archives for verification and restoration. The shared path classifier also protects SQLite, Git, and support exports. flowchart TD
A[Selected files and databases] --> B[Resolve path components]
B --> C[Check capture names and real markers]
C --> D[Exclude private inputs or refuse export]
C --> E[Preserve ordinary and unresolved links]
C --> F[Admit database snapshots]
E --> G[Create and verify archive]
F --> G
G --> H[Restore files and links]
Decision needed
Why: The compatibility run establishes the older-reader failure, but technical correctness alone cannot authorize that recovery tradeoff. Before merge
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +165, Docs +7. Total +209 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one cycle-safe privacy classifier and literal link preservation, with an explicitly accepted updated-reader requirement for cyclic archives. Do we have a high-confidence way to reproduce the issue? Yes: current-main source shows a cycle causing ELOOP during marker probing, and the PR records the corresponding CLI failure on its pinned baseline; this review did not execute a reproduction. Is this the best way to solve the issue? Yes: repairing the shared path classifier preserves existing archive machinery and privacy consumers without adding a parallel export policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 948e897faeaa. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
landpr-approve-admin-merge |
|
landpr-approve-unrelated-red |
|
landpr-approve-admin-merge |
|
landpr-approve-unrelated-red |
|
landpr-approve-admin-merge |
|
landpr-approve-admin-merge |
|
landpr-approve-admin-merge |
|
Thanks @adele-with-a-b! Proof: Cyclic and dangling links survive backup creation and restoration. Marked targets and legacy capture contents are omitted; the marked-target archive also restores on v2026.9.4.
|
…penclaw#146161) ## What Problem This Solves A state directory containing `loop-a -> loop-b -> loop-a` makes `openclaw backup create --verify --json` fail with `Private update capture marker is unreadable; export refused.` No archive is created. ## Why This Change Was Made The decision `whether a selected path is a private update-capture location` is made by exactly one mechanism at `src/infra/update-capture-paths.ts:151`. It resolves links component by component with `lstat`, cycle detection, and a depth limit, retains each selected entry name for legacy capture ownership, and checks real selected and resolved directories for privacy markers. The separate canonical scan is removed. Resolved marked targets remain excluded. Linked directory owners and capture-root aliases still protect legacy capture contents. SQLite snapshots use the same assertion before copying selected contents. The separate update-time backup work in openclaw#144005 writes privacy markers and uses this classifier. ## User Impact Cyclic and dangling links no longer prevent backup creation. Their original link text is preserved. Marked targets and private capture contents stay out of archives, while ordinary unmarked links retain the behavior from openclaw#141925. ## Evidence - Pinned main `3cb434d6`: real CLI exits 1 with the reported error and no archive. Head `6c58557e`: cycle/dangling creation, verification, and restoration succeed with exact links and payload. - The marked-target archive omits the link and private bytes, then verifies and restores on v2026.9.4. A linked sibling owner also excludes legacy capture contents. Malformed and unreadable real markers refuse without publishing an archive. - Head `057dbc07`: config selected through a private capture-root alias refuses export with no archive. A containing-workspace archive omits the alias and private bytes, then verifies and restores on both current code and v2026.9.4 with healthy bytes intact. - All 199 targeted tests passed, including component ordering, repeated links, trailing separators, archive privacy, and support exports. Complete dispositions and compatibility details are retained in `consumers.md`. ## Compatibility The archive format is unchanged. Capture-root alias and marked-target archives restore on v2026.9.4 with zero links and exact healthy bytes. Plain and portable relative-link archives retain their passing compatibility checks. Only cyclic/dangling-link output receives the additional old-reader allowance. v2026.9.4 cannot restore preserved cycles and reports `Backup restore failed; the incomplete target was cleaned: <restore-target>`; the updated reader restores them. Existing restrictions on ordinary absolute links predate this fix. No shim is added. Focused CLI proof runs on macOS; Windows junction coverage depends on CI. ## Consumers - Backup inventory and archive creation preserve unresolved links while excluding resolved private targets and real private ancestors. - Legacy capture exclusion recognizes sibling owners and capture roots reached through directory links. - SQLite archive snapshots apply the same content admission before capture or reuse. ## Invalidation None. Each call inspects current filesystem metadata; no cached classification or persistent state changes. ## Contention No lock, queue, transaction, or asynchronous publication changes. ## Tests `backupCreateCommand` and `backupRestoreCommand` cover marked-target omission, linked-owner exclusion, capture-root alias refusal, loop/dangling preservation, and restored bytes. Real and resolved marker refusals remain covered. The canonical database alias test retains refusal of an incomplete hardlink inventory and the unmarked sanitation control. No tests were deleted. **Follow-ups:** Add command-level coverage for path-resolution edge cases and test path separators on native Windows. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
A state directory containing
loop-a -> loop-b -> loop-amakesopenclaw backup create --verify --jsonfail withPrivate update capture marker is unreadable; export refused.No archive is created.Why This Change Was Made
The decision
whether a selected path is a private update-capture locationis made by exactly one mechanism atsrc/infra/update-capture-paths.ts:151. It resolves links component by component withlstat, cycle detection, and a depth limit, retains each selected entry name for legacy capture ownership, and checks real selected and resolved directories for privacy markers. The separate canonical scan is removed.Resolved marked targets remain excluded. Linked directory owners and capture-root aliases still protect legacy capture contents. SQLite snapshots use the same assertion before copying selected contents. The separate update-time backup work in #144005 writes privacy markers and uses this classifier.
User Impact
Cyclic and dangling links no longer prevent backup creation. Their original link text is preserved. Marked targets and private capture contents stay out of archives, while ordinary unmarked links retain the behavior from #141925.
Evidence
c1a39f89: real CLI exits 1 with the reported error and no archive. Head6c58557e: cycle/dangling creation, verification, and restoration succeed with exact links and payload.057dbc07: config selected through a private capture-root alias refuses export with no archive. A containing-workspace archive omits the alias and private bytes, then verifies and restores on both current code and v2026.9.4 with healthy bytes intact.consumers.md.Compatibility
The archive format is unchanged. Capture-root alias and marked-target archives restore on v2026.9.4 with zero links and exact healthy bytes. Plain and portable relative-link archives retain their passing compatibility checks.
Only cyclic/dangling-link output receives the additional old-reader allowance. v2026.9.4 cannot restore preserved cycles and reports
Backup restore failed; the incomplete target was cleaned: <restore-target>; the updated reader restores them. Existing restrictions on ordinary absolute links predate this fix. No shim is added. Focused CLI proof runs on macOS; Windows junction coverage depends on CI.Consumers
Invalidation
None. Each call inspects current filesystem metadata; no cached classification or persistent state changes.
Contention
No lock, queue, transaction, or asynchronous publication changes.
Tests
backupCreateCommandandbackupRestoreCommandcover marked-target omission, linked-owner exclusion, capture-root alias refusal, loop/dangling preservation, and restored bytes. Real and resolved marker refusals remain covered. The canonical database alias test retains refusal of an incomplete hardlink inventory and the unmarked sanitation control. No tests were deleted.Follow-ups: Add command-level coverage for path-resolution edge cases and test path separators on native Windows.