Skip to content

fix(backup): keep Nix-managed config symlinks in verified archives - #136486

Closed
NianJiuZst wants to merge 1 commit into
openclaw:mainfrom
NianJiuZst:codex/backup-nix-absolute-config-symlink
Closed

NianJiuZst wants to merge 1 commit into
openclaw:mainfrom
NianJiuZst:codex/backup-nix-absolute-config-symlink

Conversation

@NianJiuZst

Copy link
Copy Markdown
Contributor

Closes #136326

What Problem This Solves

Fixes an issue where operators using NixOS or Home Manager could not create a native OpenClaw backup when openclaw.json was an absolute symlink to an immutable store file.

Why This Change Was Made

Backup coverage now uses canonical paths, so a lexically in-state config or credentials link that resolves outside the state directory becomes a declared backup asset. During archive write, an absolute symbolic link is rewritten to a portable relative archive link only when its real target is contained by a declared asset. The remapper canonicalizes first-hop readlink values so a chained store symlink still maps onto that declared asset. Arbitrary absolute links still fail closed at the existing archive guard.

Related: #136343

User Impact

Nix-managed installations can create and verify native backups without replacing the managed config link. Undeclared or escaping symbolic links remain rejected.

Evidence

  • New regressions reproduced the 2026.8.2 failure (Archive symbolic link target must be relative) for both a direct absolute config symlink and a two-hop absolute chain.
  • node scripts/run-vitest.mjs src/infra/backup-create.test.ts: 96 passed.
  • node scripts/run-vitest.mjs src/commands/backup-verify.test.ts: 47 passed, 1 skipped.
  • node scripts/check-changed.mjs --base upstream/main -- src/commands/backup-shared.ts src/infra/backup-create.ts src/infra/backup-create.test.ts docs/cli/backup.md: conflict markers, max-lines, assertion SAFETY, format, typecheck core, and typecheck core tests passed. The dead-export Knip scan could not prepare its pnpm dlx cache in this environment.
  • Targeted oxlint on the changed TypeScript files passed.
  • Isolated autoreview (--mode local --base upstream/main --max-priority P2): scoped-clean, patch judged correct at 0.86 confidence.

Real NixOS/Home Manager CLI create-and-verify remains a user-owned proof lane; the regressions use the same layout (in-state absolute symlink to an external file) and call backupVerifyCommand on the published archive.

Canonicalize config/credentials coverage so an in-state absolute symlink to an
external store file is declared as a backup asset, rewrite only those links to
portable relative archive targets, and leave arbitrary absolute links rejected.

Co-authored-by: Cursor <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: S labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 2:08 PM ET / 18:08 UTC.

ClawSweeper review

What this changes

The PR declares resolved Nix-managed config or credentials targets as backup assets and rewrites eligible absolute archive symlinks to portable relative links.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

The patch is a coherent fix for the linked backup failure and current main still has the failing planning/guard combination. No code defect was found in the introduced change, but this external PR needs real installed-layout proof before merge.

Priority: P1
Reviewed head: 90e6d08f009044026bb16a91c74a98a9fb554a84

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and boundary regression are solid on static review, but external-contributor real behavior proof is still missing.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports a passing in-process filesystem/tar regression that calls the archive verifier, but it supplies no after-fix NixOS/Home Manager installed CLI trace; tests are supplemental rather than real user-layout proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports a passing in-process filesystem/tar regression that calls the archive verifier, but it supplies no after-fix NixOS/Home Manager installed CLI trace; tests are supplemental rather than real user-layout proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-main root cause: Current main still skips a lexically in-state config solely from the lexical containment flag, so an absolute external target is not declared as an asset.
Introduced repair boundary: The PR canonicalizes config and credentials before deciding whether lexical in-state paths are already covered, then declares externally resolved targets as assets.
Archive safety invariant: The new remap only accepts a final real target inside a declared asset; the shared guard still requires a portable relative link whose source and destination are both declared assets.
Findings None None.
Security None None.

How this fits together

The backup CLI turns configured state, config, credential, agent, and workspace paths into declared archive assets, then writes and verifies a tar archive. This PR changes the handoff from asset planning to symbolic-link safety validation.

flowchart LR
A[Configured state and config paths] --> B[Backup planner]
B --> C[Declared archive assets]
C --> D[Tar archive writer]
D --> E[Symbolic-link safety guard]
E --> F[Verified backup archive]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports a passing in-process filesystem/tar regression that calls the archive verifier, but it supplies no after-fix NixOS/Home Manager installed CLI trace; tests are supplemental rather than real user-layout proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - This intentionally creates a narrow exception to the archive symlink boundary; require an installed NixOS/Home Manager create-and-verify trace that also preserves rejection of an undeclared absolute link.
  • Resolve merge risk (P1) - Production code is net +46 lines; the canonical-target-to-archive-path conversion is boundary-local and no existing helper covers it without coupling planning to archive writing.
  • Complete next step (P2) - Add redacted post-fix NixOS/Home Manager CLI create-and-verify proof, including retained rejection of an undeclared absolute link, before merge.
Agent review details

Security

None.

PR surface

Source +46, Tests +64, Docs 0. Total +110 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 50 4 +46
Tests 1 64 0 +64
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 115 5 +110

Review metrics

Metric Value Why it matters
Production versus test delta production +50/-4; tests +64; docs +1/-1 The bug fix adds a boundary-local canonical-link remapper and direct archive regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #136326
Summary: This PR is a candidate fix for the canonical Nix-managed backup failure; a second open PR pursues the same root cause but is not a safe supersession target.

Members:

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

Merge-risk options

Maintainer options:

  1. Require installed containment proof (recommended)
    Before merge, add a redacted NixOS/Home Manager CLI create-and-verify trace that confirms the declared-link exception while an undeclared absolute link remains rejected.
  2. Accept fixture-only boundary evidence
    Maintainers may accept the filesystem/archive regression as sufficient evidence for the new symlink exception.

Technical review

Best possible solution:

Keep this canonical planning-and-remapping design, preserve the declared-asset guard, and land only after redacted installed-layout proof confirms create and verify behavior.

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

Yes in source: current main omits the external target from declared assets and then rejects the absolute link; the added direct and chained fixtures encode that layout. This read-only review did not execute the regression.

Is this the best way to solve the issue?

Yes, subject to real behavior proof: canonical asset coverage followed by archive-relative rewriting immediately before the existing shared guard is the narrow owner-boundary repair.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The linked defect prevents verified native backups for affected Nix-managed installations.
  • add merge-risk: 🚨 security-boundary: The patch deliberately permits a narrowly validated form of absolute symbolic link that the archive guard previously rejected.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a passing in-process filesystem/tar regression that calls the archive verifier, but it supplies no after-fix NixOS/Home Manager installed CLI trace; tests are supplemental rather than real user-layout proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The linked defect prevents verified native backups for affected Nix-managed installations.
  • merge-risk: 🚨 security-boundary: The patch deliberately permits a narrowly validated form of absolute symbolic link that the archive guard previously rejected.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a passing in-process filesystem/tar regression that calls the archive verifier, but it supplies no after-fix NixOS/Home Manager installed CLI trace; tests are supplemental rather than real user-layout proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main root cause: Current main still skips a lexically in-state config solely from the lexical containment flag, so an absolute external target is not declared as an asset. (src/commands/backup-shared.ts:268, 1212f991db46)
  • Introduced repair boundary: The PR canonicalizes config and credentials before deciding whether lexical in-state paths are already covered, then declares externally resolved targets as assets. (src/commands/backup-shared.ts:198, 90e6d08f0090)
  • Archive safety invariant: The new remap only accepts a final real target inside a declared asset; the shared guard still requires a portable relative link whose source and destination are both declared assets. (src/infra/backup-create.ts:345, 90e6d08f0090)
  • Regression coverage: The added filesystem/archive test covers direct and two-hop absolute config links, checks the portable relative output, and invokes archive verification. (src/infra/backup-create.test.ts:2981, 90e6d08f0090)
  • Current-main status: None of the four introduced PR paths changed between the PR base and fetched current main, so current main has not incorporated this fix. (src/infra/backup-create.ts:613, 1212f991db46)
  • Feature history: The existing fail-closed archive-link policy dates to the prior backup symlink repair, making its author a relevant routing candidate; exact line-introduction verification was unavailable because required historical blobs were absent locally and the promisor remote could not resolve. (8c7e86a2eada)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Leon-SK668: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted post-fix NixOS/Home Manager openclaw backup create --verify terminal output, including successful verification and the retained rejection of an undeclared absolute link.

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.

@vsumner

vsumner commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for independently validating the chained-link and documentation gaps. I incorporated that follow-up into the earlier #136343 branch, credited you as co-author, removed its unrelated Codex-profile exclusion from the final diff, and added the missing real Nix-store openclaw backup create --verify trace. To reduce duplicate maintainer work, I suggest consolidating on #136343, but I am happy to follow whichever PR the maintainers prefer.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Thanks for consolidating this. I confirmed that #136343 includes the chained-link and documentation follow-up, removes the unrelated Codex-profile exclusion, preserves co-author credit, and supplies the requested real Nix-store openclaw backup create --verify proof. Closing this duplicate in favor of #136343 to avoid splitting maintainer review.

@NianJiuZst NianJiuZst closed this Sep 3, 2026
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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: backup fails for Nix-managed absolute config symlink

2 participants