Skip to content

fix: restore default-profile backup archives - #123504

Merged
steipete merged 4 commits into
mainfrom
steipete/backup-restore-symlinks
Aug 14, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/backup-restore-symlinks

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where openclaw backup restore failed for default profiles after backup create and backup verify had succeeded. Fresh profiles publish absolute generated links under plugin-skills/; node-tar rejected those during strict extraction, and cleanup then raced still-pending writes, leaving operators with only an ENOTEMPTY cleanup error instead of the restore cause.

Why This Change Was Made

Backup creation now reports and omits the OpenClaw-owned, regenerable plugin-skills/ symlink index. Verification retains legitimate relative symbolic links whose resolved targets stay inside the archive root, rejects absolute and archive-escaping targets before extraction, and reports the checked symlink count.

Restore keeps node-tar's warning-as-error behavior without its early-rejection race: it captures every recoverable extraction warning, waits for extraction to close, then rethrows the first warning. If cleanup also fails, an AggregateError preserves the extraction error as the primary cause and retains the cleanup error as the second error.

The node-tar 7.5.22 contract behind the failure is dist/esm/unpack.js's STRIPABSOLUTEPATH guard (lines 213-257), which emits TAR_ENTRY_INFO: stripping / from absolute linkpath; dist/esm/warn-method.js lines 13-25 turns that warning into an error in strict mode; and dist/esm/extract.js lines 24-26 rejects on error before the later close event.

AI-assisted: yes (Codex). No agent transcript is included.

User Impact

Operators can create, verify, and restore normal default-profile archives successfully. Unsafe absolute or escaping symlinks fail during verification with the offending entry and target named, incomplete extraction is actually removed before failure returns, and restore output explains how to regenerate plugin-skill links with openclaw skills list or a normal agent session.

Production LOC: +91/-13 (net +78) | Tests: +131/-5 (net +126) | Docs: +10/-4. The production growth implements the create/verify/restore ownership and security contracts; it does not add compatibility or retry paths.

Evidence

  • Before: isolated macOS profile br1 created and verified a 47-entry archive, then restore failed with Backup restore failed and the incomplete target could not be cleaned ... ENOTEMPTY while the original TAR_ENTRY_INFO rejection was swallowed.
  • After: the same isolated state produced a 44-entry archive with plugin-skills reported as regenerable; verify returned symlinkCount: 0; restore completed; openclaw skills list recreated both generated links from current plugin metadata.
  • Unsafe-archive probe: restoring the pre-fix absolute-link archive exited 1 with Archive symbolic link target must be relative ... and did not create the target directory.
  • node scripts/run-vitest.mjs src/commands/backup-restore.test.ts src/commands/backup-verify.test.ts — 35 passed, 1 platform skip.
  • node scripts/run-vitest.mjs src/infra/backup-create.test.ts --testNamePattern 'preserves noncanonical symlinked SQLite paths without dereferencing them' — targeted symlink contract passed.
  • pnpm docs:check-mdx && pnpm docs:check-links — passed; 6,493 internal links checked, 0 broken.
  • node scripts/check-changed.mjs — passed in Blacksmith Testbox; https://github.com/openclaw/openclaw/actions/runs/31773078705
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output — clean after the final error-contract adjustment; no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations labels Aug 14, 2026
@steipete
steipete marked this pull request as ready for review August 14, 2026 05:40
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 14, 2026, 4:31 AM ET / 08:31 UTC.

ClawSweeper review

What this changes

The PR omits regenerated plugin-skill links from new backups, validates archive symlinks, and improves restore cleanup error reporting.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked by patch quality or review findings - 7 items remain

Keep this PR open: its prior P1 remains. The new verifier rejects every absolute symlink, so a default-profile archive created before this PR still fails before restore even though that generated index is fully OpenClaw-owned and regenerable.

Priority: P1
Reviewed head: be2f12f1c1a535ae15f7f41fbb45f6f2ef99347d

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The branch has a concrete P1 compatibility blocker despite useful focused tests and reported behavior evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless describes a real macOS backup/restore run.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless describes a real macOS backup/restore run.
Evidence reviewed 5 items Restore verifies before extraction: Current main calls archive verification before it creates or writes the restore target, so rejecting the generated link blocks the requested restore path.
Generated-link ownership: Plugin skill targets are resolved to absolute paths, then symlinked into a directory documented in code as fully OpenClaw-owned and generated.
Remaining failure admitted by branch evidence: The PR body says restoring a pre-fix archive with an absolute generated link exits with “Archive symbolic link target must be relative”; that is the archive compatibility case this PR is titled to repair.
Findings 1 actionable finding [P1] Restore pre-existing generated plugin-skill links
Security None None.

How this fits together

Backup create packages profile state, verify checks the archive before any writes, and restore extracts it into a fresh staging directory. Plugin skills are published as generated links under the profile state directory.

flowchart LR
A[Profile state] --> B[Backup create]
B --> C[Archive verification]
C --> D[Restore extraction]
D --> E[Restored profile]
C --> F[Archive safety error]
Loading

Before merge

  • Restore pre-existing generated plugin-skill links (P1) - The new verifier rejects every absolute target before restore, but current plugin-skill publication resolves targets to absolute paths and writes them into the fully OpenClaw-owned generated index. Consequently, an archive created before this PR still fails verification; omit only that manifest-derived index before extraction and retain rejection for arbitrary absolute or escaping links.
  • Resolve merge risk (P1) - The selective compatibility exception must be limited to the manifest-derived, OpenClaw-owned plugin-skill index; allowing arbitrary absolute links would weaken archive safety.
  • Resolve merge risk (P1) - The exact node-tar warning lifecycle still needs direct dependency-source confirmation on a fully provisioned review environment.
  • Resolve merge risk (P1) - Production code grows by 90 net lines for a bug fix; the added validation and cleanup behavior should remain centralized rather than becoming a parallel extraction path.
  • Complete next step (P2) - The remaining P1 has a narrow, source-proven repair boundary and a focused regression path.
  • Improve patch quality - Add a regression archive containing the generated absolute plugin-skill link and prove successful restore.
  • Improve patch quality - Keep a separate negative test showing that arbitrary absolute and archive-escaping links are still rejected.

Findings

  • [P1] Restore pre-existing generated plugin-skill links — src/commands/backup-verify.ts:320-323
Agent review details

Security

None.

PR surface

Source +90, Tests +126, Docs +6. Total +222 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 106 16 +90
Tests 2 131 5 +126
Docs 2 10 4 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 247 25 +222

Review metrics

Metric Value Why it matters
Production versus test delta production +106/-16 (net +90); tests +131/-5 (net +126); docs +10/-4 (net +6) The bug fix adds a substantial archive-validation and extraction path, so the old-archive compatibility regression must be covered before merge.

Stored data model

Persistent data-model change detected: serialized state: src/commands/backup-restore.test.ts, serialized state: src/infra/backup-create.test.ts, vector/embedding metadata: docs/install/backups.md. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Restore older generated indexes safely (recommended)
    Add a narrowly scoped pre-extraction omission for only the manifest-derived plugin-skill index and prove that old default-profile archives restore while arbitrary unsafe links remain rejected.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add a pre-fix archive regression that restores a manifest-derived plugin-skills absolute link by omitting that owned index before extraction; keep arbitrary absolute and escaping links rejected.

Technical review

Best possible solution:

Recognize the manifest-derived plugin-skill index as regenerable, omit it before extraction for old and new archives, and continue rejecting every other absolute or archive-escaping link.

Do we have a high-confidence way to reproduce the issue?

Yes, by source: create an archive containing the manifest-derived plugin-skill index with its generated absolute target, then restore it; the proposed verifier rejects it before extraction.

Is this the best way to solve the issue?

No: omitting the index from newly created archives is sound, but rejecting every such link leaves already-created default-profile archives unrestored.

Full review comments:

  • [P1] Restore pre-existing generated plugin-skill links — src/commands/backup-verify.ts:320-323
    The new verifier rejects every absolute target before restore, but current plugin-skill publication resolves targets to absolute paths and writes them into the fully OpenClaw-owned generated index. Consequently, an archive created before this PR still fails verification; omit only that manifest-derived index before extraction and retain rejection for arbitrary absolute or escaping links.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c500ab7cc0d7.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: Default-profile backups created before this PR remain unable to restore.
  • merge-risk: 🚨 compatibility: Changing backup verification can make existing archives fail before any restore output is produced.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The repository state identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless describes a real macOS backup/restore run.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/commands/backup-restore.test.ts src/commands/backup-verify.test.ts.
  • [P1] node scripts/run-vitest.mjs src/infra/backup-create.test.ts --testNamePattern 'preserves noncanonical symlinked SQLite paths without dereferencing them'.
  • [P1] pnpm docs:check-mdx && pnpm docs:check-links.
  • [P1] node scripts/check-changed.mjs.

What I checked:

  • Restore verifies before extraction: Current main calls archive verification before it creates or writes the restore target, so rejecting the generated link blocks the requested restore path. (src/commands/backup-restore.ts:108, c500ab7cc0d7)
  • Generated-link ownership: Plugin skill targets are resolved to absolute paths, then symlinked into a directory documented in code as fully OpenClaw-owned and generated. (src/skills/loading/plugin-skills.ts:122, c500ab7cc0d7)
  • Remaining failure admitted by branch evidence: The PR body says restoring a pre-fix archive with an absolute generated link exits with “Archive symbolic link target must be relative”; that is the archive compatibility case this PR is titled to repair. (be2f12f1c1a5)
  • Feature provenance: The current restore path was introduced by the whole-archive restore feature and is now carried forward on main. (src/commands/backup-restore.ts:112, e69a973bfb74)
  • Dependency signal and inspection gap: The changed restore path directly imports tar, pinned as tar 7.5.22; direct package-source inspection was unavailable because this read-only checkout has no node_modules and outbound DNS failed. (src/commands/backup-restore.ts:4, c500ab7cc0d7)

Likely related people:

  • steipete: History attributes the restore feature and its current carried-forward path to Peter Steinberger; the supplied PR metadata identifies this account as steipete. (role: whole-archive restore author and recent backup contributor; confidence: high; commits: e69a973bfb74, 3e6f08eab9d5; files: src/commands/backup-restore.ts, src/commands/backup-verify.ts, src/infra/backup-create.ts)
  • Vincent Koc: Recent history includes backup archive and SQLite-path maintenance in the same archive-creation surface. (role: recent adjacent backup contributor; confidence: medium; commits: 63cadcf11bbe, f1afaa3d0ecd; files: src/infra/backup-create.ts)

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 (2 earlier review cycles)
  • reviewed 2026-08-14T06:18:08.944Z sha a19c98e :: found issues before merge. :: [P1] Restore previously created default-profile archives
  • reviewed 2026-08-14T08:24:02.432Z sha bf1ae58 :: found issues before merge. :: [P1] Restore existing generated plugin-skill archive entries

@steipete
steipete force-pushed the steipete/backup-restore-symlinks branch from a19c98e to bf1ae58 Compare August 14, 2026 08:17
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 14, 2026
@steipete
steipete merged commit 65597f9 into main Aug 14, 2026
264 of 266 checks passed
@steipete
steipete deleted the steipete/backup-restore-symlinks branch August 14, 2026 08:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
* fix(backup): make default-profile backups restorable

* fix(backup): preserve restore cleanup context

* refactor(backup): drop preserve-caught-error suppression via hoisted cleanup error

* refactor(backup): hoist restore failure handling out of catch scopes
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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant