Skip to content

fix(root): verify restrictive-mode writes through retained descriptors - #154

Merged
steipete merged 2 commits into
mainfrom
steipete/sweet-lederberg-a49386
Aug 28, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/sweet-lederberg-a49386

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On the unmodified released @openclaw/[email protected], root(directory, { mode: 0 }).write("target", "mode-zero-proof") publishes the intended bytes with mode 000, then rejects with EACCES. The native writer already completed publication and permission finalization; Root's outer verification unnecessarily reopened the now-unreadable file.

This is a pre-existing Root bug, not a regression introduced by retained-directory staging.

Repair

  • Verify through the original writer-owned descriptor so POSIX no-read modes do not require a new read open. Preserve regular-file, expected-identity, no-follow pathname, hardlink, canonical containment, and parent/root checks. When Windows cannot report pathname identity, retain the existing guarded reader and compare its fresh path-opened descriptor against the original file; missing metadata is not proof of equality.
  • Integrate with NativeStagedFile through a private owned-write coordinator. Public staged methods remain await-free, receipts expose no descriptors, and disposal retains both operation and cleanup failures.
  • Keep exact bigint identity snapshots through the private verification path, including pathname metadata, without changing legacy numeric helper returns or public read behavior. Add regressions for large identities and one-bit changes hidden by numeric rounding.
  • Preserve genuine post-publication errors without reclassifying them as precommit failures or rolling back a completed publication. Keep the explicit FUSE content-verification contract and pre-existing unreadable-destination access checks.
  • Honor explicit mode zero in copyIn() and fallback mode selection. Update writing/native docs and the Unreleased changelog.

No new public API, staged-file API expansion, Rust change, or release is included.

Validation

On non-root macOS arm64 with Node 24.20.0:

  • Reproduced the released-package failure; the repaired public call fulfills with mode 000, the exact 15 intended bytes, and no extra directory entries.
  • Full repository check passed: 1,377 tests passed, with 312 platform/native skips in the JavaScript-only build. Lint, build, documentation examples, package contents, and public-API checks passed.
  • Native-required Root regressions: 290 passed, 2 expected skips.
  • Related staging/native/FUSE/secret/realpath suites: 142 passed, 6 platform skips; security corpus: 78 passed.
  • Exact-identity regression was demonstrated red before repair, then 26 passed after repair. The Windows opaque-path regression also went red before correction; all 20 compatibility/swap/error cases now pass, and the compiled Windows-branch swap probe matches released 0.5.6's rejection.
  • Required independent Codex review, workflow lint, and whitespace checks passed.

Local native proof used an existing staging-capable macOS build from the merged main checkout; Rust was not rebuilt locally. CI now explicitly runs the four Root regression files with native mode required after building fresh bindings on Linux, macOS, Windows, and Alpine/musl. Hosted results are the fresh-build and real-Windows proof.

Retain the published descriptor through Root verification while preserving exact identity, link, and confinement checks. Avoid a read reopen failure after the mode-000 file has already been published.
@steipete
steipete requested a review from a team as a code owner August 28, 2026 08:38
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 5:35 AM ET / 09:35 UTC.

ClawSweeper review

What this changes

The PR retains the published file descriptor through Root write verification so restrictive modes such as 000 do not require reopening an unreadable file.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open: current main still reopens the published target during Root verification, while this branch retains the writer-owned descriptor and adds focused cross-platform coverage. The captured check state includes an unresolved Node 24 Windows failure, so it needs a refreshed Windows result before merge.

Priority: P2
Reviewed head: fb0d13ff75b3d23e8b640921c9a2f3c1de4fce14

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): ClawSweeper live verification passed on the reviewed terminal surface.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): ClawSweeper live verification passed on the reviewed terminal surface.
Evidence reviewed 5 items Current-main behavior: Current main verifies an atomic write by reopening the destination after rename, which is the mechanism that fails for a completed no-read-mode publication.
Retained-descriptor implementation: The new verifier checks the retained descriptor, pathname identity, canonical containment, guarded parent, and root identity; Windows opaque pathname identity retains a guarded reopen path.
Focused regression coverage: The mode suite covers new/replacement/no-clobber/create/copy operations with modes 000 and 0200 under JavaScript and required-native modes where available.
Findings None None.
Security None None.

Live Verification

Command: FS_SAFE_NATIVE_MODE=off pnpm test test/root-write-mode.test.ts

Result: PASS (completed)

$ vitest run test/root-write-mode.test.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-154-FHUkwk/target

 ✓ test/root-write-mode.test.ts (48 tests | 23 skipped) 146ms

 Test Files  1 passed (1)
      Tests  25 passed | 23 skipped (48)
   Start at  09:35:38
   Duration  639ms (transform 278ms, setup 0ms, import 360ms, tests 146ms, environment 0ms)








































Assertions:

  • PASS expect_output: root-write-mode.test.ts

How this fits together

Root write operations stage or create a file inside a confined directory, publish it, then verify identity, link count, containment, and directory stability. This PR changes the handoff from writers to those final safety checks.

flowchart LR
  A[Root write request] --> B[Confined writer]
  B --> C[Publish and apply final mode]
  C --> D[Retained file descriptor]
  D --> E[Identity and containment checks]
  E --> F[Write success or safety error]
Loading

Before merge

  • Resolve merge risk (P1) - The changed verification path is a filesystem-security boundary, and the captured Node 24 Windows failure must be explained or cleared before landing cross-platform behavior changes.
  • Complete next step (P2) - No source-visible repair is indicated; resolve the captured Windows check state through normal PR validation.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and regression delta production +234/-113; tests +1,023/-25 Most added code is focused regression coverage for a cross-platform filesystem-safety change.
Native CI coverage 4 Root regression files added to native-required Linux/macOS/Windows/musl coverage The workflow now exercises the changed behavior against fresh native bindings.

Merge-risk options

Maintainer options:

  1. Clear the Windows validation result (recommended)
    Identify the completed Node 24 Windows failure and rerun the affected required-native checks on the exact head before merge.

Technical review

Best possible solution:

Preserve the retained-descriptor design and merge after the Windows failure is resolved with fresh required-native validation.

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

Yes in source: current main reopens the completed destination during final verification, which produces the described failure for a non-root restrictive-mode write. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes: retaining the writer-owned descriptor avoids the permission-sensitive reopen while the new verifier preserves pathname, link, containment, parent, and root checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d73327569edf.

Labels

Label justifications:

  • P2: This is a bounded Root-write correctness repair in a security-sensitive public API.
  • merge-risk: 🚨 compatibility: The change affects write and create behavior on restrictive permissions across existing platforms and filesystems.
  • merge-risk: 🚨 security-boundary: It changes the final confinement and file-identity verification performed after publication.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): ClawSweeper live verification passed on the reviewed terminal surface.
  • proof: sufficient: Contributor real behavior proof is sufficient. ClawSweeper live verification passed on the reviewed terminal surface.

Evidence

What I checked:

  • Current-main behavior: Current main verifies an atomic write by reopening the destination after rename, which is the mechanism that fails for a completed no-read-mode publication. (src/root-impl.ts:825, d73327569edf)
  • Retained-descriptor implementation: The new verifier checks the retained descriptor, pathname identity, canonical containment, guarded parent, and root identity; Windows opaque pathname identity retains a guarded reopen path. (src/root-write-verification.ts:50, fb0d13ff75b3)
  • Focused regression coverage: The mode suite covers new/replacement/no-clobber/create/copy operations with modes 000 and 0200 under JavaScript and required-native modes where available. (test/root-write-mode.test.ts:66, fb0d13ff75b3)
  • Feature-history routing: Recent Root-write and retained-directory staging history is concentrated in commits by Peter Steinberger, including the current-main staging change. (src/pinned-write.ts:162, d73327569edf)
  • Hosted validation state: The captured PR checks show a completed Node 24 Windows failure while refreshed Windows native, check, and coverage runs remain in progress; this is unresolved validation rather than a source finding. (fb0d13ff75b3)

Likely related people:

  • steipete: Current-main history shows sustained work on Root write, FUSE identity, and retained-directory staging behavior. (role: recent area contributor; confidence: high; commits: d73327569edf, 91e000f4edf8, b1be2a119986; files: src/root-impl.ts, src/pinned-write.ts, src/native-pinned-write.ts)

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-08-28T08:41:37.947Z sha 8b58650 :: needs maintainer review before merge. :: none

Reopen paths through the guarded reader only when Windows pathname identity is unavailable, then compare the fresh descriptor against the original retained bigint identity. Keep POSIX mode-000 verification unchanged.
@steipete
steipete merged commit a5354d3 into main Aug 28, 2026
39 of 41 checks passed
@vincentkoc
vincentkoc deleted the steipete/sweet-lederberg-a49386 branch September 25, 2026 11:16
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. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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