Repository navigation
fix(guest): fall back for directory no-replace publication when RENAME_NOREPLACE is unsupported - #876
Conversation
…E_NOREPLACE is unsupported
|
🦞👀 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 8, 2026, 1:43 PM ET / 17:43 UTC. ClawSweeper reviewWhat this changesAdd checked Linux directory-rename and file-link publication fallbacks when guest filesystems reject no-replace rename. Example: Publish a prepared workspace on a gVisor gofer bind volume
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains necessary: current main still attempts to hard-link directory sources after unsupported no-replace rename. The supplied gVisor proof exercises the repair, and no actionable patch defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe package exports Python filesystem code for container and SSH guests, including a fragment used to publish prepared workspaces. Callers provide admitted directory descriptors and names; the fragment publishes the source or reports failure. flowchart TD
A[Admitted directories and names] --> B[Guest publication helper]
B --> C[Native no-replace rename]
C -->|Success| G[Published destination]
C -->|Unsupported on Linux| D[Verify source and target absence]
D --> E[Directory rename]
D --> F[File link and checked source removal]
E --> G
F --> G
Technical reviewBest possible solution: Keep publication in the shared guest fragment with the documented bounded fallback, then release the package and update the consuming application separately. Do we have a high-confidence way to reproduce the issue? Yes: current-main source clearly reaches directory hard-linking after unsupported rename, and the contributor's real gVisor trace records EINVAL followed by EPERM. The reviewer did not execute the failure. Is this the best way to solve the issue? Yes: the repair belongs in the shared guest publication fragment, retains admitted descriptors, and documents the fallback's limits rather than duplicating workspace logic in a consumer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 71e0d67988c5. Provenance checked
TestingProof path: shipped entry point. Added test files: 2. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment |
Linux guest workspace publication failed when a filesystem rejected
renameat2(RENAME_NOREPLACE): the embedded Python helper fell back to a hard link even for directory sources. This fixes the guest-helper path reported in openclaw/openclaw#167231. Thanks @valkyriweb for the report and gVisor diagnosis.After a definitive unsupported-operation rejection, directories recheck source identity and target absence, then rename through the same admitted directory descriptors. A trailing slash enforces directory source type at the syscall. Non-empty directories and non-directory targets are refused as
EEXIST; an empty directory created concurrently after the absence check can be replaced, matching the bounded native design in #838. No empty claim directory becomes visible before the completed workspace is published. Identity checks are separate from the syscall, with a post-publication identity check.Regular files use the existing no-follow link fallback, now verifying both names against the admitted inode at exactly two links before unlinking the source, then verifying the one-link destination. Exclusive-create cleanup preserves changed payloads and ambiguous link pairs. The guest has no strict/require mode and is independent of host native policy; macOS and other error paths remain fail-closed.
Validation: the new regression suite failed against fresh main
71e0d679before the fix (including directory publication with forcedEINVAL); all 42 focused tests now pass. Tests exercise the exported guest fragment with the existing Python process fault-injection approach and real descriptor-relative filesystem operations, including collisions and identity races.git diff --checkand independent Codex P0–P2 autoreview passed.pnpm checkpassed: 13,586 tests, 4,185 platform/native-feature skips, both WASM builds, documentation checks, boundary/file-size checks, and installed-package checks. The first local build selected Homebrew Rust without the WASM target; using the already-installed rustup toolchain resolved it. Final committed-branch Codex P0–P2 review, including the embedding helper context, is also clean. Rust is unchanged.Real-filesystem proof passed on an AWS Crabbox Linux lease with runsc
release-20260928.0, systrap, and--file-access-mounts=shared. The guest helper ran against an actual gofer bind volume. A direct syscall probe returnedEINVALwith source intact; main reproducedEPERMfrom hard-linking the directory. The fixed fragment preserved directory identity and complete payload, published files with one final link and no source name, and refused existing non-empty-directory, file, and empty-directory targets without changing them. The first proof attempt stopped at a fixture volume-permission error before publication; correcting the isolated fixture permissions produced the successful run.The gVisor syscall trace confirmed:
No release or OpenClaw dependency bump is included. The OpenClaw issue remains open until the fs-safe release and consumer bump.
The task-owned AWS lease has been released after the proof.
Final head
425dd078b4bbd3d67916400466fd08222eb865b3passed all applicable Linux/macOS/Windows CI lanes, ARM64, musl, both glibc 2.28 compatibility lanes, native checks, and Clippy/audit: CI, CodeQL, coverage, and benchmarks. No CI failures, retries, or bypasses were needed.