Repository navigation
feat(root): follow directory aliases while rejecting final symlinks - #297
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: needs maintainer review before merge. Reviewed September 12, 2026, 11:00 PM ET / September 13, 2026, 03:00 UTC (Revision 5). ClawSweeper reviewWhat this changesAdds separate read and mutation policies that allow contained directory aliases while rejecting final symlinks, with publication checks, public types, documentation, and regression coverage. Merge readiness✅ Ready for maintainer review This remains a useful, distinct addition absent from current main and v0.9.0. The earlier absolute-entry defect is fixed, real behavior proof remains applicable, and verified repository-admin acceptance resolves the prior policy-decision blocker. No blocking finding remains. Priority: P2 Review scores
Verification
How this fits togetherfs-safe’s Root API confines filesystem operations to a trusted directory. Caller paths and policies pass through shared resolution and identity checks before reads, writes, moves, or removals reach the filesystem. flowchart TD
A[Caller path and policies] --> B[Root boundary resolution]
B --> C[Resolve contained directory aliases]
C --> D[Reject final symlink]
D --> E[Guarded read or mutation]
E --> F[Publication and identity checks]
F --> G[Result or refusal]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep the additive policies on the shared guarded filesystem paths, preserving existing defaults and the explicitly accepted best-effort publication contract. Do we have a high-confidence way to reproduce the issue? Not applicable as an existing-behavior bug: this adds a policy mode. The supplied public-API transcript demonstrates its allowed and rejected cases after the fix. Is this the best way to solve the issue? Yes. Extending shared resolution and guarded publication avoids consumer-side preflight checks, preserves defaults, and implements the administrator-accepted contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cc10fd89ac85. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
a87cc73 to
3976203
Compare
f008a60 to
faae58b
Compare
What Problem This Solves
Workspace tools need to follow contained directory aliases while refusing a symlink at the final file, but currently have to canonicalize and check those paths outside fs-safe.
Why This Change Was Made
Adds
follow-parents-within-rootto read policies and a separate opt-inmutationSymlinkspolicy for Root mutations. The shared path resolver preserves raw path components, and publication checks reject a final symlink introduced during staging. Keeping mutation policy separate preserves the existing read-policy defaults and mutation behavior.User Impact
Consumers can use directory aliases without following or replacing a final symlink, including paths ending in a slash or dot. Root containment, existing native/fallback identity checks, and omitted-option behavior remain intact. This does not promise an atomic compare-and-swap against external filesystem writers.
Evidence
198 combined tests pass across policy, mutation authority, publication, Windows fallback, cleanup, low-level adapters, and raw-path suites.
Before-fix regressions reproduce both staging-time final aliases and absolute-entry aliases that canonicalization previously erased. Public API proof below verifies native and JavaScript paths.
Build, generated API inventory, documentation, package, boundary, and whitespace checks passed.
Independent review of the complete combined candidate is clean through P2. Reanchoring onto the landed authority commit preserved the tested source tree exactly; final cross-platform CI, coverage, and CodeQL are green.
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
Absolute-entry behavior proof
Verified the built
@openclaw/fs-safepublic exports atfaae58b8cbaa09e8be4c7de87f1b48755e2e279aon macOS using synthetic temporary files, with both JavaScript fallback (off) and required native mode. A directory alias outside the lexical workspace successfully reads and writes the contained file. A final file alias outside the lexical workspace rejects both operations withsymlink; its link and target bytes remain unchanged. Before the repair, both modes accepted the final alias and changed its target bytes.Reproduction command from the repository checkout after building the host native binding:
Observed output:
The source correction enforces the final-component policy before absolute-entry canonicalization discards the original leaf. Regression coverage also checks final directory aliases with trailing
/and/., async/sync low-level public opens, and every supported mutation entry; existing absolute-path rejection for move/remove/mkdir remains unchanged.Integration validation: 198 targeted tests pass across policy, authority dispatch, publication, Windows fallback, cleanup, adapter, and raw-path suites. Combined append/create regressions complete one real two-byte write, then confirm a symlink swap or authority revocation prevents a second write and preserves the replacement. Managed review is clean through P2. Reanchoring onto the landed authority commit preserves the complete tested tree exactly.
Windows CI exposed four test expectations that assumed POSIX refusal codes. The tests now preserve Windows' existing
outside-workspaceandsymlinkresults while retaining every source, link, and target-content assertion. This follow-up changes no production code; 66 focused tests and independent review pass. The previous candidate passed all native, package, Linux, macOS, CodeQL, and benchmark checks; the final test revision passed cross-platform CI.Maintainer decision: accept the separate opt-in read and mutation policies with the documented best-effort publication guarantee. The resolver must preserve final-component provenance, and publication must reject a final symlink after awaited preparation; atomic compare-and-swap against independent filesystem writers is outside this contract. Existing defaults remain unchanged.
Final head
49dc3c0377c2fdade8a3aabbea0d0b37db2782adpassed CI, coverage, and CodeQL. One Node 24 Windows job was rerun after an unchanged PowerShell ACL query hit its existing 30-second timeout; the targeted rerun passed without source or timeout changes.