Repository navigation
fix(root): verify restrictive-mode writes through retained descriptors - #154
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 5:35 AM ET / 09:35 UTC. ClawSweeper reviewWhat this changesThe PR retains the published file descriptor through Root write verification so restrictive modes such as Merge readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherRoot 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]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
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.
Problem
On the unmodified released
@openclaw/[email protected],root(directory, { mode: 0 }).write("target", "mode-zero-proof")publishes the intended bytes with mode000, then rejects withEACCES. 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
NativeStagedFilethrough a private owned-write coordinator. Public staged methods remain await-free, receipts expose no descriptors, and disposal retains both operation and cleanup failures.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:
000, the exact 15 intended bytes, and no extra directory entries.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.