Repository navigation
fix(native): fall back for no-replace moves when RENAME_NOREPLACE is unsupported - #838
Conversation
…unsupported Keep auto-mode file and directory moves through retained parents, preserve inode and collision checks, and expose a stable unsupported-capability classifier with partial-state receipts. Require mode stays fail-closed. Refs openclaw/openclaw#165617; related to #828 and #834. Thanks @StarGazer1995, @bbs2i58, and @MertBasar0 for the reports and trace.
|
🦞👀 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: blocked before merge. Reviewed October 6, 2026, 3:33 AM ET / 07:33 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR adds Linux file and directory move fallbacks through retained parent directories, capability-error classification, partial-state reporting, documentation, and regression coverage. Merge readiness⛔ Blocked before merge - 4 items remain The move fallback remains useful and is not implemented on current main. The latest test-cleanup correction introduces no identified defect, but the previously raised directory collision-contract decision remains unresolved. Priority: P2 Review scores
Verification
How this fits togetherfs-safe gives Node.js applications guarded filesystem roots for untrusted paths. Root moves admit source and destination parents, perform native filesystem operations, and verify identities and outcomes. flowchart TD
A[Root move request] --> B[Path and mutation admission]
B --> C[Retained parent directories]
C --> D[Atomic no-replace rename]
D --> E[Unsupported capability]
E --> F[Strict mode refusal]
E --> G[Auto file or directory fallback]
G --> H[Identity checks and outcome]
Decision needed
Why: Documentation and deterministic coverage establish the behavior, but do not establish acceptance of the weaker filesystem-safety contract. Before merge
Findings
Agent review detailsSecurityNeeds attention: No supply-chain regression was found; the deliberate weakening of directory collision protection still needs explicit acceptance. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the identity-checked file fallback and atomic directory moves, with unsupported directory moves remaining fail-closed unless maintainers explicitly approve the documented collision tradeoff. Do we have a high-confidence way to reproduce the issue? Yes: current main source establishes unsupported-move refusal, and supplied Linux/FUSE baseline and after-fix observations exercise that path. This reviewer did not execute it. Is this the best way to solve the issue? Partly: retained-parent file link/unlink is focused and preserves collisions; directory fallback introduces a safety-policy choice that can be narrowed to atomic no-replace behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c237b390ffe7. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What 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
History |
Add copyRootFileSync to the advanced surface for synchronous plugin captures. Retain the admitted source, create an exclusive guarded destination, reuse the bounded native clone/copy-range/byte engine, and return the owned destination descriptor for hashes and receipts. Refs openclaw/openclaw#161739. Validated with Rust workspace tests and Clippy, native and TypeScript builds, focused race/bounds/clone tests, package and declaration checks, the full serial check, Codex review at P0-P2, and exact-head all-OS CI, coverage, and CodeQL. Rebased onto #838; no release.
…E_NOREPLACE is unsupported (#876) Use descriptor-relative, identity-checked directory rename after definitive Linux no-replace rejection. Preserve non-empty directories and file targets; document that a concurrently created empty directory can be replaced. Verify both file links at nlink=2 before source removal and preserve ambiguous create staging. Reported in openclaw/openclaw#167231; follows the native design in #838. Thanks @valkyriweb for the report and gVisor diagnosis. Verified failing-main regressions, 42 focused tests, pnpm check, actual runsc release-20260928.0 shared-gofer-volume baseline/fix proof, and exact-head multi-OS CI, CodeQL, coverage, benchmarks, and Codex P0-P2 review. No release is included.
Linux filesystems that reject
renameat2(RENAME_NOREPLACE)can now completeRoot.move()in nativeautomode through the already-retained, identity-checked parents. This addresses the native move failure in openclaw/openclaw#165617 and completes the move fallback deliberately left fail-closed by #834 (related: #828). Thanks @StarGazer1995 and original QNAP reporter @bbs2i58 for the reports, and @MertBasar0 for tracing the consumer error-classification gap.Files publish with
linkatwithoutAT_SYMLINK_FOLLOW, verify the exact two-link source/target inode pair, then recheck and unlink the source. Admission and final publication require one link. Collisions cannot overwrite the target. Denied or unsupported links fail closed naming both capabilities;EPERMmay be a per-file restriction, not filesystem-wide lack of hard links. Post-publication errors preserve the target and exposedetails.publicationanddetails.sourceRemoval, including target-published/source-still-linked and source-removed/final-verification-failed states.Directories recheck the source and target absence, then use plain
renameatthrough the retained parents. Non-empty directories and non-directory competitors reject asalready-exists; a concurrently created empty directory can be replaced. A trailing slash enforces directory type at syscall time, preventing a substituted file or symlink from clobbering a file. Identity checks and the syscall remain separate; this is not source-name compare-and-swap. Nativerequirenever takes either fallback.The existing per-binding cache remains bounded to 128 devices. Only distinct sibling rejections populate it; cross-parent directory-ancestry
EINVALcannot poison it.isNoReplaceUnsupported(error), exported from@openclaw/fs-safeand/errors, recognizeshelper-unavailablewithdetails.capability === "rename-noreplace". Consumers no longer need internal native cause-code matching. Docs, API snapshot, and method benchmark coverage are updated.auto;requirerefuses.movePathWithCopyFallback()rename-noreplacepublicationIsolated seccomp tests cover file/directory success, collision races, the empty-directory edge, source file/symlink substitution, changed target, third links, link-denial/unsupported errnos, failed source unlink, failed final target inspection, and strict mode. Public Root and standalone move integration covers both modes and capability/partial-state classification. The original native move path failed before fallback admission was added.
Real-filesystem proof used an AWS Crabbox lease and a FUSE passthrough filesystem whose rename callback rejects nonzero flags. Actual absent-target
renameat2returnedEINVALfor files and directories. A separately built fresh-main baseline (c237b390) refused the file move and still disallowed no-replace directory moves. The fixed public Root API preserved inode and payload inauto;requirerefused both.straceshowed the actual fallback syscalls:The AWS lease has been released. This is Linux/FUSE evidence, not a claim to have tested QNAP or OpenZFS. The reporter subsequently confirmed absent-target
EINVALfor both files and directories in all five tested locations: Public, Container, media, Docker data, and container-local overlay/tmp, on kernel5.10.60-qnap. This corrects the original share-specific diagnosis: the rejection is host-wide in the reported environment. Successful plugin installs took ClawPack and made norenameat2calls. The patched build has not yet been tested on that QNAP. Current OpenClaw npm staging callsmovePathWithCopyFallback(), which already uses ordinary replacing rename; the reporter's older-state plugin installation still needs end-to-end confirmation.Validation passed:
cargo test --workspace --locked,cargo clippy --workspace --all-targets --locked, native/package builds, focused tests,pnpm check(17,225 passing tests, 731 platform/feature skips, plus installed-package validation), and independent Codex P0–P2 review. Local method smoke passed inoff(996 cases / 322 callable exports and methods) andrequire(1,030 / 335) modes. CI caught and prompted fixes for ARM's 32-bit link count, mandatory benchmark registration, and filtered-child cleanup on ARM; no assertions or syscall denials were weakened. Final head8ef4593c06d420d5e96c7e385403c232aa4dd48ahas 41 successful checks and six intentional skips, including every applicable Linux/macOS/Windows lane, ARM64, musl, and glibc 2.28: CI, CodeQL, and coverage. No admin bypass or CodeQL retry was needed.After the OpenClaw bump, remove the unsupported-native-rename branch and raw/internal errno matching in
moveLegacyMigrationFileNoReplace()(src/infra/state-migrations.no-replace-move.ts, from openclaw/openclaw#164748). Keep exact two-link inspection/recovery for interrupted moves. Missing-addon/native-off fallback compatibility is a separate contract; removing that path requires an explicit policy decision. Use the public classifier and fallback details for capability diagnostics and deferral.No release or package publication is included.