Repository navigation
fix(openshell): preserve nested host symlinks during mirror sync - #131122
Conversation
Reconcile mirror entries recursively so trusted host symlinks and their ancestors survive remote edits and deletions. Preserve unlink-before-copy hardlink safety and drain pending filesystem work before returning an error. Cover the repair with unit regressions and the real OpenShell E2E flow. Fixes #131111
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 3:09 PM ET / 19:09 UTC. ClawSweeper reviewWhat this changesThe PR replaces OpenShell’s directory-copy logic with recursive reconciliation so nested trusted host symlinks survive mirror synchronization while ordinary remote files, directories, and deletions still synchronize. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer landing: the focused mirror repair appears correct, but its exact-head OpenShell E2E is still in progress and the PR carries the protected maintainer label. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherOpenShell mirrors a trusted Gateway-host workspace into and back from a sandbox used for command execution. The mirror layer filters unsafe filesystem entries and publishes safe sandbox changes back to the host workspace. flowchart LR
A[Host workspace] --> B[Upload staging]
B --> C[Sandbox workspace]
C --> D[Remote command]
D --> E[Download reconciliation]
E --> F[Updated host files]
E --> G[Preserved host symlinks]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +14, Tests +152, Docs +6. Total +172 across 4 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one recursive reconciler, then land only after the exact-head OpenShell E2E confirms host-link preservation and ordinary mirror updates through the real sandbox boundary. Do we have a high-confidence way to reproduce the issue? Yes, source reproducible: current main’s top-level deletion loop removes an ordinary ancestor of a nested link, and the focused regression cases encode the resulting failure. I did not execute the suite because even Is this the best way to solve the issue? Yes. A shared recursive reconciler repairs the owning traversal while retaining source-link exclusion and unlink-before-copy hardlink protection, rather than adding a downstream exception. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a9f163ff25ba. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
The remaining live-proof request in the latest ClawSweeper review is now satisfied on b2e35d4. The full Proof environment: isolated Ubuntu 24.04 arm64 container, Node 24.19.0, pnpm 11.22.0, OpenShell 0.0.109, nested Linux Docker 29.1.3 with vfs storage. Source hashes matched the reviewed head. The isolated gateway used authenticated mTLS; protected Exact-head CI is green, the full local OpenShell suite passed 101 tests, and changed-file type/lint/guard checks passed. The net +14 production lines retain one recursive owner rather than adding backup/restore or downstream paths: the required state carries protected-link ancestry and drains started filesystem mutations before the workspace lease is released. Tests are +168/-16; docs +6/-0. No actionable code findings remain. Proceeding with normal maintainer landing through the repository's native PR workflow. |
|
Merged via squash.
|
…nclaw#131122) * fix(openshell): preserve nested host symlinks during mirror sync Reconcile mirror entries recursively so trusted host symlinks and their ancestors survive remote edits and deletions. Preserve unlink-before-copy hardlink safety and drain pending filesystem work before returning an error. Cover the repair with unit regressions and the real OpenShell E2E flow. Fixes openclaw#131111 * chore(openshell): satisfy mirror callback lint rules
Closes #131111
What Problem This Solves
Fixes an issue where OpenShell mirror users lose existing host symlinks inside subdirectories after an ordinary sandbox command, even when that command changes nothing. The previous download replacement preserved immediate symlink children but recursively deleted their parent directories.
Why This Change Was Made
Upload staging and download publication now share one recursive reconciliation flow. Existing host symlinks and the directories needed to retain them take precedence over conflicting remote entries; ordinary remote edits, deletions, and file/directory changes still apply. Sandbox symlinks and special files remain excluded. Regular destinations are unlinked before copying, preserving the existing protection against writing through a host hardlink into an outside inode.
The traversal also drains all started filesystem operations before reporting an error, so the workspace lease cannot be released while a sibling copy is still mutating the host. No new dependency, configuration, storage, or protocol surface is introduced. The old whole-directory deletion and duplicate copy loops are removed.
Production LOC: +81/-67 (net +14). This growth implements recursive preservation of host links and their ancestors, plus error settlement at the same owner boundary. Tests: +168/-16; docs: +6/-0.
User Impact
Host symlinks survive mirror round-trips at any depth, including dangling links and links whose remote parent was deleted or replaced. A remote replacement that conflicts with such a preserved host path is ignored, matching the existing rule that host links win. The OpenShell guide documents this boundary.
Evidence
ENOENT,EINVAL, orENOTDIR).node scripts/run-vitest.mjs extensions/openshellpassed 101 tests across 6 files. Coverage includes nested and dangling links, remote ancestor conflicts, normal deletions/type changes, outside hardlink canaries, and draining delayed copies after a sibling failure.pnpm docs:list, targeted formatting, andgit diff --checkpassed.pnpm test:e2e:openshell. Source hashes matched the PR head. The existing fixture host-IP override used the actual task-owned Docker bridge gateway. The suite verified host links after real upload/SSH/download, ancestor conflicts, remote-link exclusion, outside hardlink canaries and ordinary writes.The affected deletion logic is already present in stable v2026.7.1. The retained local history carries it through e357203; that shallow-history boundary does not establish who originally introduced the defect. Upstream OpenShell v0.0.109 upload/download behavior was checked directly in
crates/openshell-cli/src/run.rsandssh.rsat pinned commit 8d67250a5d17348eb96c4fa46226b06d8041f2ba.AI-assisted; the implementation, boundary behavior, and regression evidence were reviewed.