Repository navigation
feat(root): check caller authority before filesystem mutations - #296
Conversation
|
🦞👀 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: blocked before merge. Reviewed September 12, 2026, 10:19 PM ET / September 13, 2026, 02:19 UTC (Revision 5). ClawSweeper reviewWhat this changesAdds composed caller-authority checks before Root filesystem mutations, bounded write submissions, direct file removal, documentation, and regression coverage. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: the capability remains absent from main, both prior findings are fixed, and real-filesystem proof supports the authority fence. The remaining blocker is the unresolved removal-compatibility contract. Priority: P2 Review scores
Verification
How this fits togetherRoot confines application filesystem operations to a checked directory. The new callbacks carry caller-defined authority through asynchronous preparation and can refuse subsequent mutation submissions. flowchart TD
A[Application mutation request] --> B[Root and per-call assertions]
B --> C[Path and identity preparation]
C --> D{Live authority allows mutation?}
D -->|Yes| E[Native or JavaScript filesystem submission]
E --> D
D -->|No| F[Refusal and owned cleanup]
E --> G[Verification and completion]
Decision needed
Why: The linked contract discussion explicitly leaves this scope and compatibility choice pending; successful authority proof does not authorize changing existing callers’ recovery behavior. Before merge
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Provide the documented Root dispatch fence while preserving omitted-callback removal behavior, unless owners explicitly accept a compatibility change backed by targeted Windows and error-parity evidence. Do we have a high-confidence way to reproduce the issue? Not applicable as an existing-contract bug: this adds a new authority guarantee. The supplied real-filesystem transcript demonstrates allowed operations and refusal after owner reassignment. Is this the best way to solve the issue? Mostly yes: composed synchronous checks at actual submissions preserve Root’s existing safety machinery. Unconditionally changing omitted-callback removal remains broader than necessary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fec99436d7c3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
e3240f4 to
3f8bf55
Compare
What Problem This Solves
Filesystem writes, moves, and removals can outlive a caller's lease or permission check while waiting for asynchronous preparation.
Why This Change Was Made
Adds an optional synchronous
assertBeforeMutationcallback to Root defaults and mutation options. Root and per-call assertions compose, and checks run immediately before each library-owned mutation dispatch across native and JavaScript paths. Refusals preserve the caller's error; already-admitted work, descriptor disposal, and identity-owned cleanup still settle.User Impact
Consumers can carry revocable authority through Root operations, including configuration publication and workspace file changes. The callback cannot revoke an already-dispatched syscall or guard later writes through a returned raw FileHandle. Existing defaults remain unchanged.
Closes #251.
Evidence
Revoked-authority regression fails on the original implementation and preserves the target after the fix.
259 focused tests passed, including Root behavior and error normalization; native, JavaScript, and simulated Windows cases are covered.
All 32 authority and dispatch tests pass against the rebuilt native binding and current package.
Build, documentation, package, boundary, and file-size checks passed; independent review found no actionable P0-P2 findings.
The broad local run was not completed. Focused mutation, error-contract, and native suites pass; exact-head cross-platform CI supplies the full-suite landing gate.
Tests added or updated when behavior changed
Security and compatibility impact considered
CHANGELOG.mdupdated when release-relevantNo credentials, private paths, private hosts, or sensitive contents included
Actual filesystem dispatch proof
Root removal now submits
unlinkdirectly, and buffered writes share a bounded writer that checks authority before every write submission, including short writes. This avoids the internal async preparation in Node'srmand the later chunks inwriteFile/appendFile. The Node write loop and removal preparation explain the boundary.A standalone built-package consumer used real filesystem operations and async-hooks observation, with no filesystem-operation mocks:
{ "observations": [ { "case": "allowed-write", "bytes": 1048576, "exactBytes": true }, { "case": "reassigned-owner-removal", "rejected": true, "targetPreserved": true }, { "case": "allowed-removal-dispatch", "deferredPreparation": false, "targetRemoved": true }, { "case": "append-owner-reassigned-after-first-write", "requestedBytes": 1048576, "appendedBytes": 524288, "rejected": true, "originalPrefixPreserved": true, "noLaterChunkWritten": true } ], "syntheticFixtureRemoved": true }The regressions fail on the previous PR head. Owned cleanup also rechecks the final file identity after awaited parent guards, preserving a replacement file.
Removal semantics and Windows validation
The maintainer decision is to retain one direct
unlinkpath for Root file removals. Missing targets still reportnot-found; a target disappearing after admission can now reportnot-foundinstead of being silently absorbed by Node'srmrecovery. This intentionally avoids a second asynchronous pathname traversal. Ordinary Windows read-only files remain removable through libuv's handle-based unlink implementation, without adding pathname-based chmod recovery.The exact-head Node 22 Windows job had one 5,000 ms store-overlap timeout. That path exercises
Root.write, but identical production and test bytes passed it in 2,330 ms on the earlier run; its private-mode sibling also slowed from 1,518 to 3,041 ms. Node 24 Windows, native Windows, and Node 22 Windows coverage passed. One exact failed-job rerun was requested without changing source, assertions, or timeouts.The targeted rerun passed. Final head
cd3a12d232f6c8a8c854a9d85726840942f2c032is green in CI (15 jobs), cross-platform coverage, and CodeQL.