Repository navigation
fix(native): fall back when renameat2 RENAME_NOREPLACE is unsupported - #834
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 12:01 AM ET / 04:01 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR restores guarded automatic file creation when native no-replace rename is unsupported, preserves strict native requirements, and adds capability diagnostics and regression coverage. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main and the latest release still expose the reported failure. No introduced blocking defect was found, including in the revised device-cache handling. Priority: P0 Review scores
Verification
How this fits togetherfs-safe admits untrusted paths within filesystem roots and publishes completed files without overwriting existing destinations. Native staging feeds publication and cleanup; automatic mode can reuse the guarded JavaScript implementation when a capability is unavailable. flowchart TD
A[Root file creation] --> B[Retained native stage]
B --> C[No-replace publication]
C --> D[Supported publication]
C --> E[Definite capability rejection]
E --> F[Identity-checked cleanup]
F --> G[Guarded automatic retry]
F --> H[Strict-mode capability error]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Preserve the existing guarded compatibility path for automatic mode while retaining precise capability rejection and recovery ownership for native-only operations. Do we have a high-confidence way to reproduce the issue? Yes: the reported write-then-create sequence follows a clear failing current-main publication path, and the captured body records before/after gVisor results. This read-only review did not execute it. Is this the best way to solve the issue? Yes: reusing the existing guarded JavaScript path after definite rejection and successful cleanup avoids introducing a second native publication primitive while preserving strict contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 071280712040. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Classify unsupported no-replace publication as definite non-publication, clean owned stages before guarded JavaScript retry, and preserve native-required and clone-always policies. Audit all native no-replace owners and retain primary publication diagnostics. Fixes #828. Thanks @vishnukool for the report.
85ca8cb to
6a000a0
Compare
A source swap can make an ordinary move reject directory ancestry with EINVAL. Keep capability memoization confined to sibling publication and quarantine, and cover the real check-to-syscall namespace race.
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.
…unsupported (#838) Allow Linux auto-mode Root moves through retained parents after unsupported no-replace rename: identity-checked link/unlink for files, and directory rename with a kernel-enforced directory source. A concurrent empty directory can be replaced; non-empty directories and non-directory targets are preserved. Require mode stays strict. Expose isNoReplaceUnsupported and precise file-move partial-state receipts. Preserve the bounded sibling-only capability cache and native-only publication contracts. Cover collision/source races, link denial, partial states, real FUSE EINVAL, and cross-platform CI. Refs openclaw/openclaw#165617; related to #828 and #834. Thanks @StarGazer1995, @bbs2i58, and @MertBasar0 for the reports and trace.
Fresh OpenClaw installs on gVisor gofer mounts fail while seeding workspace files:
Root.create()receivesEINVALfromrenameat2(RENAME_NOREPLACE), preserves its stage as though publication were uncertain, and reports a misleading file-type error. Auto mode now removes the identity-checked unpublished stage and uses the existing native-off JavaScript path. Native-required mode fails closed withhelper-unavailableand names the operation and missing capability.Fixes #828. Thanks @vishnukool for the report and exact reproduction.
The Linux VFS and
rename(2)documentEINVALfor unsupported flags. For a regular file renamed to a distinct sibling with this fixed flag, the directory-ancestry and invalid-flag alternatives do not apply.EINVAL,ENOSYS, and unsupported-operation errors from the syscall are definite non-publication. Other errors, includingEIO, retain uncertain-publication behavior. No native link/unlink primitive was added.Unsupported capability is cached by the retained parent’s exact device number, bounded to 128 devices per loaded binding. Only sibling publication and quarantine failures populate this cache; a real cross-parent source-swap regression ensures directory-ancestry
EINVALcannot poison capability selection on a healthy device. Cleanup must succeed before a staged write retries. An explicitclone: "always"remains fail-closed because byte copying cannot satisfy it. Completed one-shot streams replay from the retained readable, unlinked descriptor in bounded chunks. The producer is not called again. Publication failures remain primary when cleanup also fails.helper-unavailable, not-published receipt, identity-checked cleanup; no substitute publication contract.helper-unavailable; source and destination are preserved.publishFileExclusiverename-noreplaceValidation includes isolated Rust seccomp child processes returning
EINVAL,ENOSYS, and unsupported-operation errors only forrenameat2(RENAME_NOREPLACE), plus a seccomp-wrapped child Node integration test. The Rust test fails on fresh main with rawEINVALand passes with this change. TypeScript regressions also failed before the fix. Coverage includes device-scoped caching, collision races, no stage leaks, one-shot streams, cleanup failure, error precedence, and native-only owners.Real proof used an AWS Crabbox lease with runsc
release-20260928.0, guest kernel4.19.0-gvisor, and a9pgofer bind mount withcache=remote_revalidating,directfs. The issue’s exactwrite('b.md', 'x')thencreate('a.md', 'x')reproduction fails on main, succeeds in fixed auto mode without leftover stages, and gives the clear error with successful stage cleanup in require mode. Main native-off succeeds as a control; native-required publication also succeeds on the sandbox’s/tmp. Normal ext4, tmpfs, and APFS native publication is covered by focused tests.Gates: workspace Rust tests, Clippy, package/native builds, focused tests, full
pnpm check, independent Codex P0–P2 review, and exact-head CI/CodeQL. The initial broad local run was stopped after timeout failures on a heavily loaded host; the isolated Linux full check passed, including installed-package checks. All 43 final-head checks passed: CI, CodeQL, and coverage. The AWS proof lease has been released. No release or package publication is included.