Skip to content

fix(publish): fall back for rename-noreplace publication when RENAME_NOREPLACE is unsupported - #843

Merged
steipete merged 3 commits into
mainfrom
fix/publish-rename-noreplace-fallback
Oct 7, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/publish-rename-noreplace-fallback

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What This Solves

Linux filesystems that reject renameat2(RENAME_NOREPLACE) can now complete regular-file publishFileExclusive({ strategy: "rename-noreplace" }) in native auto mode. This covers both the database snapshot publication and manifest seal reported in openclaw/openclaw#166246. Thanks @MertBasar0 for the detailed report and selective seccomp reproduction.

User Impact

Publication reuses #838's retained-parent native file move: exclusive linkat without following symlinks, exact staged-inode/two-link verification, then source unlinkat and final verification. Success consumes the source and preserves the existing method union; the additive fallback: "link-unlink" field identifies the weaker mechanism. Native require stays fail-closed with details.capability === "rename-noreplace". Unsupported or denied links fail closed naming both capabilities. The link-required and link-or-copy strategies remain unchanged.

Link/unlink is not crash-atomic: interruption between the syscalls can leave both names on the same complete inode. Post-link failures preserve the target and report publication/source-removal state, including verified still-linked after failed unlink. Existing target/source parent synchronization and parent-receipt fencing remain in place. Identity checks and syscalls are separate; this is not source-name compare-and-swap.

OpenClaw Recovery Follow-up

Source inspection at 7880834c19616b5efb871e1755cd4b30cf2f2481 confirms snapshot publication and manifest sealing. No OpenClaw code is changed here.

  • A crash during snapshot publication leaves a snapshot/payload pair before manifest sealing. readUpdateRecoveryBackups() lists the directory as incomplete when no manifest exists. Strict payload readers reject remaining hard links.
  • A crash during manifest sealing leaves manifest.json.partial and manifest.json at nlink=2. The strict manifest reader rejects this, so capture discovery can fail rather than classify that entry as incomplete. There is no automatic pair recovery.
  • retireExpiredStandaloneDoctorCaptures() reads the final manifest with plain readFile; a parseable two-link manifest meeting the existing age/run criteria can be retired after 30 days. OpenClaw should recognize and retain interrupted seals before treating them as sealed, and either keep these pairs as incomplete evidence or perform identity/ownership-checked source removal and directory sync before admitting recovery. Merely accepting arbitrary hard links would weaken its current reader boundary.

The consumer needs the next fs-safe release and an OpenClaw dependency bump. This PR does not release a package or close the OpenClaw issue.

Evidence

The new public Linux seccomp suite was run against fresh main before the fix: five cases failed at the old unsupported-publication refusal and the strict-mode control passed. The suite covers cross-parent payload publication, sibling manifest sealing, collisions, staged-source substitution, link denial, failed unlink, and native require. Rust tests extend the existing seccomp helper with substitutions immediately before link and the ENOSYS link case; existing cases cover the remaining unsupported-link errnos and partial states.

Validation passed: cargo test --workspace --locked (190 tests), cargo clippy --workspace --all-targets --locked, native/package builds, focused Linux tests, full pnpm check (17,285 passing tests plus installed-package validation), and independent Codex P0–P2 review. The full suite caught an existing atomic-rename collision contract; normalization was narrowed to fallback errors, preserving raw EEXIST on the atomic path, then focused tests and the full check passed. Final head d41e0d2546d22a28079569e0426a88bbdc9cd469 has 38 successful checks and five intentional manual-only skips: multi-OS CI, CodeQL, coverage, and benchmarks. No CI retry, CodeQL rerun, or admin bypass was needed. The seccomp proof ran on AWS/Linux; no QNAP hardware run is claimed. The validation lease has been released.

  • Tests added or updated when behavior changed
  • Security and compatibility impact considered
  • CHANGELOG updated for the user-visible fix
  • No credentials, private paths, private hosts, or sensitive contents included

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review October 7, 2026 01:01
@steipete
steipete requested a review from a team as a code owner October 7, 2026 01:01
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:11 PM ET / October 7, 2026, 01:11 UTC (Revision 2).

ClawSweeper review

What this changes

Adds an identity-checked Linux link/unlink fallback for exclusive file publication, with a fallback marker, partial-failure receipts, documentation, and regression coverage.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main and v0.24.1 still refuse unsupported no-replace publication. No actionable introduced defect remains; the latest commit preserves the existing atomic collision contract.

Priority: P2
Reviewed head: d41e0d2546d22a28079569e0426a88bbdc9cd469

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused compatibility extension with explicit durability limits, meaningful regression coverage, and no remaining actionable patch defect.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies a MEMBER author, so ordinary external-contributor proof is exempt. The inspected seccomp fixture exercises the changed publication owner through the real addon, and the captured body reports after-fix validation; this review performed no execution. No stored-format or schema contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies a MEMBER author, so ordinary external-contributor proof is exempt. The inspected seccomp fixture exercises the changed publication owner through the real addon, and the captured body reports after-fix validation; this review performed no execution. No stored-format or schema contract changes.
Evidence reviewed 10 items Repository policy: Read the full root AGENTS.md and contribution guide. Applied guarded-filesystem, bounded-fallback, public-contract, and changelog guidance; no nested AGENTS.md or matching maintainer notes were found. No bundled autoreview helper or tests were executed.
Still necessary on main: The main publication branch calls renameNoReplace directly and turns unsupported capability errors into refusal. The existing Root move fallback does not already implement this publication behavior.
Released baseline: The inspected main baseline is tagged v0.24.1, so the latest release also lacks this fallback.
Findings None None.
Security None None.

How this fits together

Exclusive file publication moves a completed staged file to a destination without overwriting an existing entry. Native filesystem checks and parent-directory synchronization determine whether publication succeeds or returns recovery evidence.

flowchart TD
 A[Completed staged file] --> B[Pin file and parents]
 B --> C[Attempt exclusive rename]
 C --> D[Unsupported in Linux auto mode]
 D --> E[Link and verify inode pair]
 E --> F[Remove source and verify target]
 C --> G[Synchronize parents and return receipt]
 F --> G
 D --> H[Strict mode refuses]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth production +66/-19, net +47; tests +258/-5, net +253 Production growth integrates the shared fallback and receipts, supported by substantially larger focused regression coverage.

Technical review

Best possible solution:

Reuse the retained-parent fallback with explicit mechanism and recovery receipts, preserve strict atomic-only behavior, and keep interrupted-pair recovery in consuming applications.

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

Yes, source establishes main's unsupported-capability refusal, and the selective seccomp fixture supplies a focused reproduction path. This read-only review did not execute it.

Is this the best way to solve the issue?

Yes, the selected compatibility extension reuses the guarded native implementation and preserves strict mode, existing atomic collision errors, and explicit partial-state reporting.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Addresses a bounded Linux filesystem-capability limitation in exclusive publication.
  • merge-risk: 🚨 compatibility: The explicitly selected auto-mode fallback weakens crash atomicity and can leave two linked names after interruption; strict mode retains refusal.
  • 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: Repository State identifies a MEMBER author, so ordinary external-contributor proof is exempt. The inspected seccomp fixture exercises the changed publication owner through the real addon, and the captured body reports after-fix validation; this review performed no execution. No stored-format or schema contract changes.

Evidence

What I checked:

  • Repository policy: Read the full root AGENTS.md and contribution guide. Applied guarded-filesystem, bounded-fallback, public-contract, and changelog guidance; no nested AGENTS.md or matching maintainer notes were found. No bundled autoreview helper or tests were executed. (AGENTS.md:24, d41e0d2546d2)
  • Still necessary on main: The main publication branch calls renameNoReplace directly and turns unsupported capability errors into refusal. The existing Root move fallback does not already implement this publication behavior. (src/publish-file.ts:354, b749881fd7a6)
  • Released baseline: The inspected main baseline is tagged v0.24.1, so the latest release also lacks this fallback. (b749881fd7a6)
  • Introduced production behavior: Inspected the pinned main-to-head delta and complete production owners. Publication enables the shared fallback only in auto mode, records source-removal states, preserves partially published targets, and retains the existing synchronization and final identity fences. (src/publish-file-native.ts:13, d41e0d2546d2)
  • Native safety boundary: The reused native owner checks staged identity and a single source link, rejects symlinks at admission, links without following symlinks, verifies the exact two-link pair before unlink, and verifies the final single-link target. Failed pair verification preserves evidence rather than removing an unverified name. (native/src/move_noreplace.rs:75, d41e0d2546d2)
  • Re-review continuity: The previous completed review had no findings or published rank-up moves. GitHub reads of the exact earlier production blobs show that the new head removes broad EEXIST normalization from publication and confines normalization to fallback errors. The new regression checks atomic EEXIST and omission of the fallback marker. Local earlier-head comparison encountered an unavailable historical blob; the relevant originals were read through the GitHub contents API instead. (test/publish-file-noreplace-fallback.test.ts:30, d41e0d2546d2)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (1 earlier review cycle)
  • reviewed 2026-10-07T01:05:31.373Z sha 3f13570 :: needs maintainer review before merge. :: none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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