Skip to content

fix(native): fall back when renameat2 RENAME_NOREPLACE is unsupported - #834

Merged
steipete merged 3 commits into
mainfrom
fix/gvisor-renameat2-noreplace
Oct 5, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/gvisor-renameat2-noreplace

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Fresh OpenClaw installs on gVisor gofer mounts fail while seeding workspace files: Root.create() receives EINVAL from renameat2(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 with helper-unavailable and names the operation and missing capability.

Fixes #828. Thanks @vishnukool for the report and exact reproduction.

The Linux VFS and rename(2) document EINVAL for 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, including EIO, 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 EINVAL cannot poison capability selection on a healthy device. Cleanup must succeed before a staged write retries. An explicit clone: "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.

Native no-replace owner Unsupported-capability behavior
Root create, no-clobber copy, archive file publication Auto uses the existing guarded JavaScript write path after stage cleanup; require fails closed.
Public staged regular file helper-unavailable, not-published receipt, identity-checked cleanup; no substitute publication contract.
Root no-clobber move helper-unavailable; source and destination are preserved.
Retained symlink (#682), one-way retained entry (#776/#778) Definite not-published result and clear capability error; no JavaScript rename substitute. The existing filesystem admission rules remain in force.
Directory replacement and explicit publishFileExclusive rename-noreplace Fail closed with the named capability; preserve existing recovery ownership.
Isolated sibling producer workspace promotion Auto uses the existing guarded JavaScript handoff; require fails closed. The producer runs once.
Temp workspace quarantine/cleanup Auto with compatible cleanup uses the existing guarded JavaScript path; native require and require-bounded refuse the downgrade.
Replacement rename and Windows native paths Existing publication mechanisms remain in use.

Validation includes isolated Rust seccomp child processes returning EINVAL, ENOSYS, and unsupported-operation errors only for renameat2(RENAME_NOREPLACE), plus a seccomp-wrapped child Node integration test. The Rust test fails on fresh main with raw EINVAL and 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 kernel 4.19.0-gvisor, and a 9p gofer bind mount with cache=remote_revalidating,directfs. The issue’s exact write('b.md', 'x') then create('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.

@steipete
steipete requested a review from a team as a code owner October 5, 2026 03:12
@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 P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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:01 AM ET / 04:01 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: dfcf4da611eab77bcbe343e3b0bafc9bcd330e00

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused safety-preserving repair with real-environment results and substantial coverage; no blocking defect was identified.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body records the changed Root.create staging path on a real AWS gVisor gofer mount: failing main, successful fixed automatic publication without leaked stages, and strict-mode rejection with cleanup. Source regression coverage supplements those observations; no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body records the changed Root.create staging path on a real AWS gVisor gofer mount: failing main, successful fixed automatic publication without leaked stages, and strict-mode rejection with cleanup. Source regression coverage supplements those observations; no stored-data contract changes.
Evidence reviewed 8 items Applicable repository policy: Read the complete root AGENTS.md. No nested AGENTS.md or maintainer notes were found. Applied its confinement, identity, fail-closed, fallback, and public-contract guidance; no target-bundled reviewer or tests were executed.
Pinned introduction and current-main necessity: Reviewed the pinned main-to-head introduced delta. GitHub still reports the PR open and unmerged, with the supplied head and base identities; current main remains 0712807. Its staged publication records unsupported errno as indeterminate rather than initiating the new compatibility retry.
Release and canonical-work checks: Inspected v0.23.0 native documentation, which retains the independent no-replace capability requirement and lacks this compatibility behavior. GitHub search for renameat2 found this PR and #828; older guest publication and openat2 changes concern different execution boundaries.
Findings None None.
Security None None.

How this fits together

fs-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]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and regression coverage production +240/-53; tests and fixtures +503/-1 Production growth supports capability classification, guarded retries, and diagnostics across existing publication owners.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #828
Summary: This PR is the explicit candidate repair for the reported gVisor create failure; the issue remains open until implementation lands.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best 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.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured body records the changed Root.create staging path on a real AWS gVisor gofer mount: failing main, successful fixed automatic publication without leaked stages, and strict-mode rejection with cleanup. Source regression coverage supplements those observations; no stored-data contract changes.

Label justifications:

  • P0: The linked report establishes fresh installations unable to complete their first agent turn on affected gVisor mounts, with recovery requiring environment changes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body records the changed Root.create staging path on a real AWS gVisor gofer mount: failing main, successful fixed automatic publication without leaked stages, and strict-mode rejection with cleanup. Source regression coverage supplements those observations; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records the changed Root.create staging path on a real AWS gVisor gofer mount: failing main, successful fixed automatic publication without leaked stages, and strict-mode rejection with cleanup. Source regression coverage supplements those observations; no stored-data contract changes.

Evidence

What I checked:

  • Applicable repository policy: Read the complete root AGENTS.md. No nested AGENTS.md or maintainer notes were found. Applied its confinement, identity, fail-closed, fallback, and public-contract guidance; no target-bundled reviewer or tests were executed. (AGENTS.md:23, dfcf4da611ea)
  • Pinned introduction and current-main necessity: Reviewed the pinned main-to-head introduced delta. GitHub still reports the PR open and unmerged, with the supplied head and base identities; current main remains 0712807. Its staged publication records unsupported errno as indeterminate rather than initiating the new compatibility retry. (src/native-staged-file.ts:310, 071280712040)
  • Release and canonical-work checks: Inspected v0.23.0 native documentation, which retains the independent no-replace capability requirement and lacks this compatibility behavior. GitHub search for renameat2 found this PR and [Bug]: create() fails when renameat2 RENAME_NOREPLACE returns EINVAL (gVisor), breaks fresh OpenClaw 2026.9.7 installs #828; older guest publication and openat2 changes concern different execution boundaries. (docs/native.md:130, 223a30531ea8)
  • Cleanup before retry and policy preservation: Automatic retry requires a recognized unsupported-capability failure and successful identity-checked stage removal. Native-required mode and clone-always refuse the downgrade. Stream replay reads the retained descriptor; fallback re-enters existing root, parent, mutation-authority, collision, and publication checks. (src/native-staged-file.ts:154, dfcf4da611ea)
  • Latest revision addresses cache poisoning: Cross-parent moves no longer populate the unsupported-device cache. The added regression substitutes a directory in the final check-to-syscall gap, exercises the real native rename, then verifies native-required sibling creation still succeeds. (test/native-noreplace-fallback.test.ts:108, dfcf4da611ea)
  • Captured real-environment results: The complete captured PR body reports an AWS Crabbox lease using runsc release-20260928.0, kernel 4.19.0-gvisor, and a 9p gofer mount. The exact write-then-create scenario fails on main, succeeds after the fix in auto mode without stages, and rejects clearly with successful cleanup in require mode. Native-off and sandbox /tmp controls succeed. These are contributor-recorded observations, not a reviewer rerun.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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:19:24.771Z sha 85ca8cb :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T03:40:44.643Z sha 6a000a0 :: needs maintainer review before merge. :: none

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.
@steipete
steipete force-pushed the fix/gvisor-renameat2-noreplace branch from 85ca8cb to 6a000a0 Compare October 5, 2026 03:36
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.
@clawsweeper clawsweeper Bot added the proof: sufficient Contributor real behavior proof is sufficient. label Oct 5, 2026
@steipete
steipete merged commit 27ba8e4 into main Oct 5, 2026
51 of 52 checks passed
@steipete
steipete deleted the fix/gvisor-renameat2-noreplace branch October 5, 2026 04:06
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.
steipete added a commit that referenced this pull request Oct 6, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient Contributor real behavior proof is sufficient. 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.

[Bug]: create() fails when renameat2 RENAME_NOREPLACE returns EINVAL (gVisor), breaks fresh OpenClaw 2026.9.7 installs

1 participant