Skip to content

fix(backup): preserve cyclic symbolic links during archive creation - #146161

Merged
obviyus merged 6 commits into
mainfrom
bugloop/backup-symlink-loop
Sep 12, 2026
Merged

obviyus merged 6 commits into
mainfrom
bugloop/backup-symlink-loop

Conversation

@obviyus

@obviyus obviyus commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

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 #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

  • Pinned main c1a39f89: 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.

@clawsweeper

clawsweeper Bot commented Sep 12, 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 size: XS maintainer Maintainer-authored PR labels Sep 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 12, 2026, 2:43 PM ET / 18:43 UTC (Revision 7).

ClawSweeper review

What this changes

Backup 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
Reviewed head: 057dbc07109607bb061710be22fb087827251b0b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful CLI evidence and the previous blocker resolved; the remaining compatibility choice does not reduce implementation quality.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied PR body records macOS production CLI creation, verification, and restoration with preserved cycle/dangling links, plus exact-head capture-alias refusal before publication and private-byte omission. These observations exercise the changed classifier through its real backup consumers; the reported tests are supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied PR body records macOS production CLI creation, verification, and restoration with preserved cycle/dangling links, plus exact-head capture-alias refusal before publication and private-byte omission. These observations exercise the changed classifier through its real backup consumers; the reported tests are supplemental.
Evidence reviewed 8 items Current main still contains the failure mechanism: The current-main classifier probes marker paths beneath every selected ancestor, including symbolic-link entries; ELOOP becomes an unreadable-marker refusal. This matches the reported cyclic-link failure.
Previous finding resolved: The reviewed head records the selected symbolic-link entry before resolving its target and checks that retained name for paired capture ownership. The previous revision lacked that entry. Added command tests exercise both full and config-only export refusal before publication.
Content admission precedes snapshot capture: SQLite snapshot planning checks both the archive-selected path and the actual database source before capture or reuse. Archive filtering and backup inventory continue to consume the same classifier.
Findings None None.
Security None None.

How this fits together

OpenClaw’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]
Loading

Decision needed

Question Recommendation
Accept the documented requirement to use the updated reader for newly preserved cyclic-link archives? Accept the reader requirement: Preserve cycles and accept that those newly supported archives require the updated reader.

Why: The compatibility run establishes the older-reader failure, but technical correctness alone cannot authorize that recovery tradeoff.

Before merge

  • Resolve merge risk (P1) - New archives containing preserved cycles cannot be restored by v2026.9.4; recovery requires the updated reader. The PR discloses and demonstrates this limitation, but accepting it is a maintainer compatibility choice.
  • Complete next step (P2) - Confirm acceptance of the documented updated-reader requirement for cyclic-link archives.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +37, Tests +165, Docs +7. Total +209 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 97 60 +37
Tests 3 247 82 +165
Docs 1 13 6 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 357 148 +209

Review metrics

Metric Value Why it matters
Production versus test growth production +37 net lines; tests +165 net lines Production growth replaces competing path scans with component-aware classification; test growth covers preservation and privacy through backup commands.

Merge-risk options

Maintainer options:

  1. Accept the demonstrated reader boundary (recommended)
    Approve the documented v2026.9.4 limitation while retaining successful current-reader cycle restoration and older-reader healthy-archive controls.
  2. Pause for a different recovery contract
    Hold the PR if cyclic archives must remain restorable by v2026.9.4.

Technical review

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

Labels

Label justifications:

  • P2: This repairs backup creation for a bounded symbolic-link layout without evidence of an emergency runtime failure.
  • merge-risk: 🚨 compatibility: The newly preserved cyclic archives require a newer restore reader than v2026.9.4.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied PR body records macOS production CLI creation, verification, and restoration with preserved cycle/dangling links, plus exact-head capture-alias refusal before publication and private-byte omission. These observations exercise the changed classifier through its real backup consumers; the reported tests are supplemental.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied PR body records macOS production CLI creation, verification, and restoration with preserved cycle/dangling links, plus exact-head capture-alias refusal before publication and private-byte omission. These observations exercise the changed classifier through its real backup consumers; the reported tests are supplemental.

Evidence

What I checked:

  • Current main still contains the failure mechanism: The current-main classifier probes marker paths beneath every selected ancestor, including symbolic-link entries; ELOOP becomes an unreadable-marker refusal. This matches the reported cyclic-link failure. (src/infra/update-capture-paths.ts:16, 948e897faeaa)
  • Previous finding resolved: The reviewed head records the selected symbolic-link entry before resolving its target and checks that retained name for paired capture ownership. The previous revision lacked that entry. Added command tests exercise both full and config-only export refusal before publication. (src/infra/update-capture-paths.ts:106, 057dbc071096)
  • Content admission precedes snapshot capture: SQLite snapshot planning checks both the archive-selected path and the actual database source before capture or reuse. Archive filtering and backup inventory continue to consume the same classifier. (src/infra/backup-sqlite-snapshot.ts:362, 057dbc071096)
  • Recorded real CLI evidence: The supplied complete PR body records macOS CLI failure on c1a39f8, successful cycle/dangling creation and restoration on 6c58557e, and capture-root alias refusal plus containing-workspace exclusion on 057dbc0. It reports exact restored links and healthy bytes, absent private bytes, and no archive on refused selections. These are contributor-reported observations; this read-only review did not execute them. (057dbc071096)
  • Released-reader compatibility: The v2026.9.4 source retains the older classifier. The PR’s recorded compatibility runs show healthy and privacy-filtered archives restore with that release, but preserved cycles fail restoration and require the updated reader; existing archives remain readable. (src/infra/update-capture-paths.ts:65, 3a9d69db306c)
  • Related merged work is complementary: GitHub confirms fix(backup): preserve symbolic links to external targets #141925 merged as ed0df5b. Its external-link preservation establishes the surrounding archive behavior but does not repair the current private-marker cycle failure. The open fix(update): back up state before migrations and restore it on rollback #144005 concerns update recovery capture and is not a replacement for this fix. (src/infra/backup-create.ts, ed0df5bf09b7)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (6 earlier review cycles)
  • reviewed 2026-09-12T16:10:51.470Z sha 1592886 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T16:38:27.700Z sha 7f0a204 :: blocked before merge. :: none
  • reviewed 2026-09-12T16:56:50.837Z sha 7f0a204 :: blocked before merge. :: none
  • reviewed 2026-09-12T17:08:43.623Z sha 600129f :: blocked before merge. :: none
  • reviewed 2026-09-12T17:57:15.876Z sha 6c58557 :: blocked before merge. :: [P1] Preserve paired capture-root aliases before resolving their targets
  • reviewed 2026-09-12T18:08:59.495Z sha f3a5cb0 :: blocked before merge. :: [P1] Preserve paired capture-root aliases before resolving their targets

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: S and removed size: XS labels Sep 12, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 12, 2026
@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 146161
head: 7f0a204
scope: owner-review

@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 146161
head: 7f0a204
run: 34704060803
attempt: 1

@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 146161
head: 600129f
scope: owner-review

@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 146161
head: 600129f
run: 34707004598
attempt: 1
failed: checks-node-compact-small-29

@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 146161
head: 6c58557
scope: owner-review

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed 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. labels Sep 12, 2026
@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 146161
head: f3a5cb0
scope: owner-review

@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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 12, 2026
@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 146161
head: 057dbc0
scope: owner-review

@obviyus
obviyus merged commit 8e54ce4 into main Sep 12, 2026
187 checks passed
@obviyus
obviyus deleted the bugloop/backup-symlink-loop branch September 12, 2026 18:58
@obviyus

obviyus commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

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.

Before After
Cyclic links prevent backup creation. Backups preserve unresolved links and exclude private targets.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…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]>
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant