Skip to content

fix(backup): state-only backup fails on files under a shared workspace base - #139598

Merged
obviyus merged 2 commits into
openclaw:mainfrom
ayaangazali:fix/backup-shared-workspace-base
Sep 6, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
ayaangazali:fix/backup-shared-workspace-base

Conversation

@ayaangazali

@ayaangazali ayaangazali commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #139549.

openclaw backup create --no-include-workspace --verify can fail before writing an archive when an explicit multi-agent roster shares a workspace base containing an absolute symlink. Ordinary scratch files beneath that base also leak into state-only archives.

Why This Change Was Made

State-only backup discovery now excludes the configured shared base as well as effective agent workspaces. It reads the base only from a valid configuration snapshot, preserving partial backups for invalid configurations. The existing inventory continues to preserve nested agent state, active configuration, and credentials.

Full-backup selection, destructive cleanup discovery, and archive link containment keep their existing behavior.

User Impact

Operators can create a verified state-only backup without removing unrelated workspace files. Explicit nested owners remain included, and invalid configurations retain their recovery path.

Evidence

  • Current main 4da5d447f695def5c1d5ac9c81479710a46e45e1: the real CLI rejects the shared-base absolute link, exits 1, and writes no archive. A separate link-free run includes unwanted scratch content.
  • Repaired candidate: the same CLI completes with verified: true; extracted archives omit ordinary workspace content and retain state, active configuration, credentials, and nested agent state.
  • Full-backup controls cover shared bases inside and outside the state directory. Included-state links remain rejected. Bases equal to or containing the state root retain ordinary state. Missing, syntax-invalid, and numeric-workspace configurations retain partial-backup behavior.
  • Focused backup and cleanup tests: 164 passed. The archive regression fails on main at the link guard; the invalid-workspace regression fails on the original candidate at its unvalidated string operation.
  • Formatting, maximum-line and assertion-safety checks passed. Independent source-blind CLI acceptance passed all nine contract observations and supplementary controls, with 57 archived fixture files matching their original bytes.

Original shared-base repair by @ayaangazali; maintainer validation and recovery correction are AI-assisted.

Workspace discovery collects effective agent workspaces only. With an explicit
roster the agents resolve to subdirectories of agents.defaults.workspace, so the
base itself is never in that set: <base>/main is excluded while <base> is walked.
An ordinary file beneath the base, such as an absolute venv symlink in its tmp
subtree, then fails a --no-include-workspace backup.

Add the configured base to the excluded set. This is done where includeWorkspace
is known rather than in collectWorkspaceDirs, because that helper also supplies
the archive set for --include-workspace; adding the base there would newly
archive the base's scratch contents and hit the same symlink that breaks the
state-only run today.

The existing guard dropping excluded aliases that are or contain the state root
still applies, so pointing the base at the state directory cannot drop ordinary
state, config, or credential files from the archive.
Copilot AI lite review requested due to automatic review settings September 6, 2026 01:22
@clawsweeper

clawsweeper Bot commented Sep 6, 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 10:42 PM ET / September 6, 2026, 02:42 UTC.

ClawSweeper review

What this changes

Exclude the configured shared workspace base from state-only backups while preserving nested agent state and partial backups of invalid configurations.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and the latest release retain the reported gap. The supplied CLI proof covers successful backup creation and recovery controls, and no blocking patch defects were found.

Priority: P2
Reviewed head: 5fa229552d69c84ce73982d02032f47aef4c7d7d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow owner-level repair with meaningful regressions and real CLI evidence covering the failure and preservation boundaries.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured isolated-home CLI evidence exercises backup discovery through actual archive creation and verification: excluded shared-base links no longer abort creation, durable nested owners remain archived, and full-backup and invalid-config recovery controls retain their behavior.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured isolated-home CLI evidence exercises backup discovery through actual archive creation and verification: excluded shared-base links no longer abort creation, durable nested owners remain archived, and full-backup and invalid-config recovery controls retain their behavior.
Evidence reviewed 8 items Pinned change and recovery guard: The complete host-provided merge-base-to-head patch changes backup discovery and two regression suites. At the reviewed head, shared-base discovery runs only for state-only backups with a valid configuration snapshot. Unrelated model-catalog endpoint drift is not part of this PR.
Current main still needs the repair: Fetched main passes only cleanup-discovered effective workspaces into the backup inventory; it does not add the configured shared base. Cleanup discovery iterates resolved agent workspaces, whose unpinned multi-agent paths are children of that base.
Latest release retains the gap: The supplied latest-release commit for v2026.9.2 has the same discovery path without the shared-base exclusion. No implemented-on-main or shipped-fix closure is supported.
Findings None None.
Security None None.

How this fits together

The backup planner combines configuration, workspace paths, and durable state ownership into an archive inventory. Archive creation uses that inventory to skip workspace content, preserve nested state, and validate included symbolic links.

flowchart TD
  A[Configuration and local state] --> B[Backup scope selection]
  B --> C[Workspace exclusion discovery]
  C --> D[Durable state inventory]
  D --> E[Filtered archive traversal]
  E --> F[Symbolic link validation]
  F --> G[Verified backup archive]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +8, Tests +27. Total +35 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 0 +8
Tests 2 88 61 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 96 61 +35

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139549
Summary: This PR is the explicit implementation candidate for the shared-workspace-base backup defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep workspace exclusion discovery in the backup planner and reuse the existing inventory to preserve durable owners and archive containment.

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

Yes: current source supports the explicit-roster/shared-base symlink reproduction, and the supplied CLI comparison records the failure. This read-only review did not execute it.

Is this the best way to solve the issue?

Yes: adding the missing exclusion at backup discovery preserves full-backup and cleanup behavior while reusing established nested-owner protection.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 95f963e342ab.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a bounded backup failure affecting configurations with a shared workspace base.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured isolated-home CLI evidence exercises backup discovery through actual archive creation and verification: excluded shared-base links no longer abort creation, durable nested owners remain archived, and full-backup and invalid-config recovery controls retain their behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured isolated-home CLI evidence exercises backup discovery through actual archive creation and verification: excluded shared-base links no longer abort creation, durable nested owners remain archived, and full-backup and invalid-config recovery controls retain their behavior.

Evidence

What I checked:

  • Pinned change and recovery guard: The complete host-provided merge-base-to-head patch changes backup discovery and two regression suites. At the reviewed head, shared-base discovery runs only for state-only backups with a valid configuration snapshot. Unrelated model-catalog endpoint drift is not part of this PR. (src/commands/backup-shared.ts:603, 5fa229552d69)
  • Current main still needs the repair: Fetched main passes only cleanup-discovered effective workspaces into the backup inventory; it does not add the configured shared base. Cleanup discovery iterates resolved agent workspaces, whose unpinned multi-agent paths are children of that base. (src/commands/backup-shared.ts:600, 95f963e342ab)
  • Latest release retains the gap: The supplied latest-release commit for v2026.9.2 has the same discovery path without the shared-base exclusion. No implemented-on-main or shipped-fix closure is supported. (src/commands/backup-shared.ts, 3928bad9badf)
  • Existing backup contract: The backup documentation promises that state-only archives omit ordinary workspace sources while preserving configured agent directories, including roots nested inside workspaces. It also documents partial recovery for malformed configuration. Workspace documentation identifies the configured default as a shared base for unpinned multi-agent entries. Public docs: docs/cli/backup.md. (docs/cli/backup.md:245, 5fa229552d69)
  • Nested owners and containment remain protected: The existing inventory lets explicit included paths override their enclosing exclusions and keeps ancestors traversable to reach them. Planning rejects exclusions equal to or containing the state root. Archive traversal filters excluded entries before the unchanged symbolic-link validation. (src/commands/backup-resource-inventory.ts:200, 5fa229552d69)
  • After-fix real CLI evidence: The captured PR body and contributor comment at fix(backup): state-only backup fails on files under a shared workspace base #139598 (comment) describe an isolated-home CLI comparison: the baseline rejects an absolute interpreter symlink and writes no archive; the repaired CLI exits successfully with verified: true and excludes workspace content. The updated body additionally records extracted state/config/credentials/nested-agent preservation, full-backup controls, state-root overlap controls, malformed-config recovery, and 57 fixture files matching their original bytes. These are supplied observations, not reviewer-executed tests.

Likely related people:

  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Victor Sumner: 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 (2 earlier review cycles)
  • reviewed 2026-09-06T01:26:29.975Z sha 265b054 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T01:50:58.725Z sha 265b054 :: needs maintainer review before merge. :: none

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Added the CLI proof the review asked for.

Same fixture on both sides, in an isolated home: explicit roster, agents.defaults.workspace at <state>/workspace, main inheriting it, helper on its own workspace, and the reported absolute symlink at <state>/workspace/tmp/venv/bin/python.

openclaw backup create --no-include-workspace --verify on pristine main exits 1 with Archive symbolic link target must be relative: .../workspace/tmp/venv/bin/python -> /usr/bin/python3 and writes nothing. On this branch it exits 0 with verified: true, zero workspace assets, and state still included. Both agent roots are still resolved, so excluding the base does not drop separately owned agent state. Details are in the Evidence section.

Worth noting for the record: the earlier unit test asserted the planner, this asserts the command. I kept both, since the unit test is what fails on reverted source and pins the reason.

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
@obviyus obviyus self-assigned this Sep 6, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 6, 2026
@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 139598
head: 5fa2295
run: 34006942063 attempt: 1
failed: check-additional-boundaries job=101415974426 conclusion=failure
check: openclaw/ci-gate

Using the standing approval for proven unrelated CI failures.

The completed run has 137 successful jobs, 17 skipped jobs, and one failed child, check-additional-boundaries. The aggregate CI status reports that same failure.

The child fails only because the services test group contains 721 roots, above its unchanged limit of 720. PR #139592, authored and merged by @steipete as 41fba39c40aa2840d7a3a8bb24eeac525c871ac9, adds src/logging/diagnostic-gc.test.ts. Its actual parent 11fe45e6181f33a4b480b7ce2f53216ae856d9ae has 720 roots; that single added file raises the count to 721. The partition configuration and guard are unchanged. GitHub is the raw commit's committer.

This run executed merge 78aaae74577f8994ba0cc61e0363c28302364c7f, combining main 8ffe7768940e9f1d25035d62aa74dd341a7344c1 with the reviewed head. That main tree has the same 721-root inventory as the introducing commit. This backup PR changes three existing command/infra files and adds no service test root or guard change. Independent compiler inventories and a native boundary probe confirm the 720-to-721 transition.

The repaired backup CLI, independent archive-content acceptance, 164 focused tests, full changed-file checks, and final exact-head review passed.

@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 139598
head: 5fa2295
run: 34006942063 attempt: 1
failed: check-additional-boundaries job=101415974426 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit 8bb7998 into openclaw:main Sep 6, 2026
212 of 215 checks passed
@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks @ayaangazali!

Proof: The real backup CLI reproduced the failure on main, then produced verified state-only archives with the repair. Independent source-blind checks inspected archive contents and confirmed all 57 retained fixture files kept their original bytes. Focused backup and cleanup tests: 164 passed.

  • Bug: Shared-base scratch content was traversed despite --no-include-workspace, causing link errors or unwanted archive contents.
  • Fix: State-only discovery excludes the validated shared workspace base while preserving nested owners and invalid-config partial recovery.
Before After
Shared-base absolute link prevents archive creation. Verified state-only archive omits workspace content.
Link-free scratch files leak into state-only archives. State, configuration, credentials, and nested agent state remain intact.

Full-backup selection, cleanup discovery, overlapping state paths, and included-state link rejection were also verified.

CI exception: Run 34006942063 completed with 137 successful and 17 skipped jobs. Its only failed child was check-additional-boundaries, which reported services 721 test roots above the unchanged 720 limit; the aggregate gate reports that failure.

PR #139592, authored and merged by @steipete as 41fba39c40aa2840d7a3a8bb24eeac525c871ac9, introduced diagnostic-gc.test.ts. Its actual parent has 720 service roots; adding that file raises the count to 721. The config and guard stay unchanged. GitHub is the raw commit's committer.

This CI run tested merge 78aaae74577f8994ba0cc61e0363c28302364c7f against main 8ffe7768940e9f1d25035d62aa74dd341a7344c1, which has the same 721-root set. This PR adds no service test root or partition change. Direct parent-relative source evidence, compiler inventories, and a native boundary reproduction establish the cause; a matching main CI run was not used. Landing used the recorded approved exception, with full public cause details.

vincentkoc added a commit to ylcn91/openclaw that referenced this pull request Sep 6, 2026
* origin/main:
  fix(ci): rebalance services test roots below the memory bound (openclaw#139645)
  fix(backup): exclude shared workspace files from state-only archives (openclaw#139598)
  fix(config): preserve plugin secret references in Settings saves (openclaw#139536)
  fix(ui): retain real-Gateway browser proof across reruns (openclaw#134274)
  fix(browser): preserve node filenames in proxy media (openclaw#139559)
  fix(qa): give hot-reload maintenance proofs their own budgets (openclaw#139580)
  fix(streaming): preserve assistant items and settled output (openclaw#139507)
  fix(android): reconnect secondary gateways after rapid lifecycle changes (openclaw#139319)
  fix(gateway): restart inside a marker-less LaunchAgent no longer kills its caller (openclaw#139628)
vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit '5b099995413589f41904cef1413c62239542aa7c':
  fix(ci): rebalance services test roots below the memory bound (#139645)
  fix(backup): exclude shared workspace files from state-only archives (#139598)
  fix(config): preserve plugin secret references in Settings saves (#139536)
  fix(ui): retain real-Gateway browser proof across reruns (#134274)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…penclaw#139598)

Exclude the configured shared workspace base only for state-only backups with a validated configuration. Preserve nested state owners and invalid-config partial recovery without changing full-backup selection, cleanup discovery, or link containment.

Fixes openclaw#139549. Verified with real CLI archives, independent source-blind acceptance, and focused backup and cleanup regression tests.

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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

[Bug]: State-only backup traverses the shared workspace base

3 participants