feat(kernel-platforms): fs paths become segment arrays - #1057
Draft
ci-belphegor wants to merge 1 commit into
Draft
ci-belphegor wants to merge 1 commit into
ci-belphegor wants to merge 1 commit into
Conversation
Methods take absolute segment arrays, guarded as `M.arrayOf(M.string())`, and `rootDir` becomes a segment `root` checked as a prefix. `makeRootCaveat` moves to the shared module now that it needs no path APIs. A guard can only require strings, so `['srv', 'data/../../etc']` would arrive intact and resolve to `/etc`. Segments carrying a separator, a traversal, or nothing at all are therefore rejected before the prefix check, which is what makes that check sufficient. An empty `root` is a config error. Carries the one `**BREAKING:**` changelog entry for the whole 9a/9b/9c shape change, since the chain squashes to a single commit on main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ci-belphegor
force-pushed
the
grypez/narrowing-9c-fs-segments
branch
from
September 11, 2026 11:42
c034a5d to
3e6a90d
Compare
ci-belphegor
added this pull request to stack #1060
September 11, 2026 11:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
fsmethods now take absolute segment arrays —readFile(['srv', 'data', 'x'], 'utf8')— guarded byM.arrayOf(M.string()).rootDir: stringbecomesroot: string[],makeRootCaveatbecomes an element-wise segment prefix check, andmakeNoSymlinksCaveatjoins segments back into a path forlstatSync.Absolute rather than root-relative, because re-basing a narrowed holder's coordinates means rewriting arguments, and a rewritten argument is not an unaltered forward. The accepted price is that a narrowed holder sees prefix segments it has no authority over.
The prefix check is now element-wise and platform-agnostic, so it moved to
shared.tsand no longer needsnode:path.['srv','data']cannot admit['srv','database','x']— the string-prefix false positive the oldrelative()-based check had to defend against is structurally impossible.This is the subtle PR of the chain, which is why it lands last: a focused diff against an already-exo-shaped file.
Notes for reviewers
"With segments there is nothing to normalize" is false, and this PR is where that was found. A guard can only require strings, so
['srv', 'data/../../etc']passesM.arrayOf(M.string())intact, satisfies a['srv']prefix check, and then resolves to/etc:No pattern can catch this —
@endo/patternshas no regex, glob, or prefix matcher — so it has to be a caveat.assertPlainSegmentsrejects.,.., empty, and any segment containing/or\(both separators regardless of platform, so a POSIX-authored config cannot be exploited on Windows). It runs insidemakeCaveatedFsOperation, one chokepoint every platform shares, before the platform caveat and before segments are joined. Rejecting these is what makes a prefix check sufficient.toPathusesresolve(sep, ...segments)rather than'/' + segments.join('/'), because the design makes a platform prefix a leading segment and onlyresolvegets['C:','srv']→C:\srvright. That does not reintroduce a normalization concern:assertPlainSegmentshas already rejected everythingresolvecould collapse, so it runs on input that provably needs none.The caveat chain is reordered to
withinRoot→noSymlinksso validation precedes thelstatSync. No test depended on the old order — the two pre-existing error cases were mutually exclusive on exactly that axis.Carries the chain's single
**BREAKING:**changelog entry, covering 9a + 9b + 9c: sync operation andexistsSyncgone,fsvended as an exo with a flat method namespace, config flattened tomethodswithrootDirbecoming segmentroot, paths becoming segment arrays, and the Passable-only second-argument tightening.Stack
PR 11 of 12. Base: #1056.