Skip to content

fix(copy): fall back from tree cloning when FICLONE is denied - #835

Merged
steipete merged 3 commits into
mainfrom
fix/tree-clone-eperm
Oct 5, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/tree-clone-eperm

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

On XFS/ZFS inside a container that denies ioctl(FICLONE) with EPERM, the filesystem probe selects native tree cloning but copyTree({ clone: "auto" }) currently rejects instead of copying bytes. PR #829 fixed the separate single-file path; this closes the remaining tree-copy gap needed by openclaw/openclaw#165257.

Share the single-file capability classifier with the strict tree file job: EPERM, ENOTTY, EINVAL, EXDEV, ENOSYS, and ENOTSUP/EOPNOTSUPP become CLONE_UNAVAILABLE. Other errors remain raw. The target has just been created exclusively, so the kernel's immutable/append-only destination EPERM case cannot apply. Rust still does no byte-copy fallback; TypeScript owns the policy choice.

The existing native worker owner already settles admitted jobs and removes partial output. TypeScript then creates an exclusive fresh destination for byte copying. Regression tests verify this handoff, always reporting unsupported-platform, and refusal to merge into residue after unsuccessful cleanup. Btrfs uses its separate subvolume-snapshot path and is unchanged.

Validation:

  • Added isolated seccomp file-job and worker-pool regressions; both failed on baseline 0712807 with raw EPERM, then passed with the fix. Reuses fix(atomic): fall back when Linux FICLONE is denied with EPERM #829's filter and isolation helper.
  • Linux cargo test --workspace --locked: 188 tests passed; worker cleanup covered concurrency 1, 4, and 32. Linux Clippy passed with warnings denied.
  • macOS cargo test --workspace --locked, Clippy, pnpm build && pnpm native:build, and focused copy/clone tests passed.
  • pnpm check: 17,170 tests passed (692 test files); package, docs, WASM allocator, and boundary checks passed.
  • Codex autoreview: clean at P0–P2.
  • Final head 7a37d00d8d6fd0077666d5f7f0353e98083270f6: all 28 active CI jobs passed, including every OS lane; CodeQL passed, with no retries. Coverage, benchmarks, and all three public mutation-proof lanes also passed.

Linux validation ran in a local Rust 1.98.1 container. Its overlay directory-link-count behavior fails an unrelated metadata-observation test; running fixtures on tmpfs passes the complete suite. The optional AWS XFS loop-mount proof could not acquire a lease: the broker rejected admission at the shared active-lease limit. No AWS lease was acquired or left running.

No release is included.

@steipete
steipete requested a review from a team as a code owner October 5, 2026 03:54
@clawsweeper

clawsweeper Bot commented Oct 5, 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.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. 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 Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 12:37 AM ET / 04:37 UTC (Revision 3).

ClawSweeper review

What this changes

The PR makes Linux directory copying recognize unavailable file reflinks, allowing automatic byte-copy fallback after cleanup while preserving strict cloning failures.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and v0.23.0 still reject denied tree reflinks. The prior merge-conflict blocker is resolved, and no actionable correctness or security defect was found.

Priority: P2
Reviewed head: 7a37d00d8d6fd0077666d5f7f0353e98083270f6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with substantial regression coverage, aligned documentation, and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts this PR from the external-contributor proof gate. Reported Linux seccomp runs exercise the changed native file job and worker cleanup; TypeScript handoff tests use a mocked clone owner. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Verified repository-admin authorship exempts this PR from the external-contributor proof gate. Reported Linux seccomp runs exercise the changed native file job and worker cleanup; TypeScript handoff tests use a mocked clone owner. No stored-data contract changes.
Evidence reviewed 9 items Introduced production change: The pinned main-to-head delta changes only the tree job's FICLONE classification and extracts the existing single-file classifier; remaining native changes are test support and regressions.
Still necessary on main and latest release: Both current main and v0.23.0 classify only OPNOTSUPP as CLONE_UNAVAILABLE in the Linux tree file job; EPERM remains raw. The merged single-file fix explicitly left strict tree cloning unchanged: #829.
Guarded cleanup and fallback: Native tree ownership settles and joins workers before identity-checked cleanup. TypeScript rechecks retained directories, and portable copying uses exclusive directory creation, so unsuccessful cleanup cannot cause a merge into residue.
Findings None None.
Security None None.

How this fits together

fs-safe copies immutable, caller-owned directory trees into absent destinations. Native Linux workers attempt file reflinks; the TypeScript copy policy decides whether an unavailable clone should fall back to ordinary copying.

flowchart TD
 A[Source tree and copy policy] --> B[Filesystem capability probe]
 B --> C[Native reflink workers]
 C --> D{Clone available}
 D -->|Yes| E[Independent cloned tree]
 D -->|No| F[Settle workers and clean output]
 F --> G{Automatic copying}
 G -->|Yes| H[Exclusive byte copy]
 G -->|No| I[Unsupported operation error]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and regression growth production net +4 lines; tests net +190 lines Production growth is limited to sharing the capability classifier, with most added code covering denied cloning and cleanup.

Technical review

Best possible solution:

Keep clone availability classification shared while retaining policy-controlled fallback, settled cleanup, exclusive destination creation, and terminal access or identity failures.

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

Yes, source establishes the failure path: an XFS/ZFS probe selects tree cloning, FICLONE returns EPERM, and main propagates it instead of selecting automatic fallback. No reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes, sharing the existing single-file classifier is a narrow repair that preserves the established TypeScript policy and cleanup boundaries.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 27ba8e4e4955.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded Linux tree-copy failure when container policy denies an optional cloning capability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Verified repository-admin authorship exempts this PR from the external-contributor proof gate. Reported Linux seccomp runs exercise the changed native file job and worker cleanup; TypeScript handoff tests use a mocked clone owner. No stored-data contract changes.

Evidence

What I checked:

  • Introduced production change: The pinned main-to-head delta changes only the tree job's FICLONE classification and extracts the existing single-file classifier; remaining native changes are test support and regressions. (native/src/clone_linux.rs:169, 7a37d00d8d6f)
  • Still necessary on main and latest release: Both current main and v0.23.0 classify only OPNOTSUPP as CLONE_UNAVAILABLE in the Linux tree file job; EPERM remains raw. The merged single-file fix explicitly left strict tree cloning unchanged: fix(atomic): fall back when Linux FICLONE is denied with EPERM #829. (native/src/clone_linux.rs:170, 223a30531ea8)
  • Guarded cleanup and fallback: Native tree ownership settles and joins workers before identity-checked cleanup. TypeScript rechecks retained directories, and portable copying uses exclusive directory creation, so unsuccessful cleanup cannot cause a merge into residue. (native/src/clone_linux.rs:457, 7a37d00d8d6f)
  • Security and metadata contract: Classification applies only to FICLONE after guarded exclusive target creation. File-open errors, identity failures, and metadata errors retain their existing handling. The documented automatic-copy contract already permits byte copying without ACL or extended-attribute preservation; no new authority-bearing value or stored-data format is introduced. (native/src/unix.rs:887, 7a37d00d8d6f)
  • Regression coverage and reported validation: Rust regressions inject actual kernel EPERM into the production file job and tree worker owner, checking cleanup at concurrency 1, 4, and 32. TypeScript tests supplement this with mocked clone handoff, strict-mode failure, and residue rejection. The captured PR body reports baseline failures and after-fix passes; this read-only review did not execute tests. (native/src/clone_linux.rs:514, 7a37d00d8d6f)
  • Prior conflict resolved: Raw commit records confirm the refreshed original head incorporates pinned main. The verified GitHub test merge has main then head as its exact parents and the same result tree as the head. Live GitHub reports mergeable=true; no reviews request changes. (d8782b624730)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Mohl: 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-10-05T03:59:41.782Z sha 7323117 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T04:16:20.660Z sha 7323117 :: needs changes before merge. :: none

@steipete
steipete merged commit 04e370a into main Oct 5, 2026
48 of 49 checks passed
@steipete
steipete deleted the fix/tree-clone-eperm branch October 5, 2026 04:42
steipete added a commit that referenced this pull request Oct 5, 2026
Prepare `@openclaw/fs-safe` 0.23.1 from main, using the same 13-file scope as #826: root, native workspace, seven platform package versions, exact optional-dependency pins, and regenerated Cargo/pnpm lock entries. No implementation or dependency changes are included.

Finalize the 2026-10-04 changelog with an empty Unreleased section above it. Highlights cover no-replace publication on gVisor/9p and other unsupported filesystems (#834, fixes #828), container-denied FICLONE fallback for single-file and tree copies (#829, #835), and nonblocking macOS FIFO watching (#830). The six fixes include PR links and contributor credit, including @Mohl and co-author @foxsky, @vishnukool, and @SebTardif.

Validation: `pnpm build`, `pnpm check` (662 test files and 13,431 tests passed; 65 files and 4,108 tests skipped), `pnpm pack:check`, `node scripts/release-notes.mjs 0.23.1`, and `git diff --check` passed. The local build selected the installed rustup compiler explicitly because the default Homebrew Rust compiler could not see the WASM target. Codex autoreview is scoped-clean at P0–P2. Both generated lockfile diffs are limited to the intended version changes.

Release publication remains exclusively through the signed v0.23.1 tag and release.yml trusted publishing. Exact-head CI passed on `26e42f21a6b568d3f6a37408dea6f3b89ccf10b3`: [CI](https://github.com/openclaw/fs-safe/actions/runs/37265555433), [coverage](https://github.com/openclaw/fs-safe/actions/runs/37265555421), [mutation proofs](https://github.com/openclaw/fs-safe/actions/runs/37265555402), [benchmarks](https://github.com/openclaw/fs-safe/actions/runs/37265555459), and [CodeQL](https://github.com/openclaw/fs-safe/actions/runs/37265555471). No runner reruns or failure exceptions were needed. Main remained at `04e370a3e39eb6e98e6cb54877a5941b6d688cde` before merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant