Repository navigation
Description
Design: 4.5-fsroot-variants.md
Filed as a three-variant rename; rewritten 2026-08-19 after the design collapsed to two types. The original
ordering constraint no longer applies -- it existed to stop one name silently acquiring a wider meaning, and the
wider meanings are now deleted rather than renamed.
Target
| Opener | Type | Lifetime |
|---|---|---|
OpenConfined(dir) |
confinedDir |
the caller's |
OpenScratch(pattern) |
confinedScratchDir |
removes its tree on Close |
Both confine reads and writes through *os.Root. Nothing else.
Why the other variants go
The write-confined variant has no real consumers -- two production references, both internal plumbing --
and the requirement it was meant to meet was never implemented: fourteen mutators return errReadOnly because
its name was read as "this root cannot write" rather than "unconfined for reads only".
The unconfined variant's ~20 callers all anchor at a tree they own. The one recorded reason is
bootstrapping: "the prefix need not exist yet ... a confined root requires its anchor to exist." With open
ruled a query and a missing root ruled an error, such a caller opens a confined root at an existing
ancestor, creates the chain through it, then opens the target. / always exists, so an ancestor always does.
The work, in order
- Verify the premise. Trace every
OpenWritableUnconfinedcall site and confirm none writes outside its
anchor. Sampled, not exhaustively traced. This is the only thing that can invalidate the design, so it
goes first. - Migrate the call sites. Tests against
t.TempDir()becomeOpenConfineddirectly, since the directory
already exists. The bootstrapping cases -- prefix,ConfigHome,StateHome,CacheHome,installPath--
create through an ancestor root, then open. - Delete
unconfinedRootReader,unconfinedRootReaderWriter,rootBase,errReadOnly,Modeand its
constants,Open,OpenUnconfined,OpenWritableUnconfined. - Rename
confinedRoot->confinedDir,scratchRoot->confinedScratchDir. WithRoot(path, mode)->WithRoot(path), andWithRootModewith it. Two production call sites plus
tests.
Five types become two. The Dir interface stops being a substitution point for confinement policy and survives
as the seam every provider already programs against.
Also in scope
TestIsPrivateMode and TestNewPath are exported from non-test files, so they sit in the public API. They
belong in _test.go files, or unexported.
Not in scope
Symlink target validation. The kernel restricts following rather than making, deliberately, and fsroot matches
it -- see 4.5 section 4, which also inverts
#556 from "fix the guard" to "delete it".
Activity
[-]Rename fsroot's variants to say which operations they confine[/-][+]Collapse fsroot to one confinement behaviour and two types[/+]David-Noble-at-work commentedon Aug 19, 2026
Step 1 is done: the premise holds
Traced every
OpenWritableUnconfinedcall site. No production or fixture caller writes outside its anchor.Every path handed to one of these roots is relative to it:
prefixRootaddressesbinandshare/man/man1,configRootaddressesconfig.yamlandconfig.d,stateRootaddressesGraphsDir()andlatest.yaml, andso on.
Two candidates examined and dismissed
store.gohands a root anchored at~/.config/devlorea path at~/.ssh/id_ed25519. Not a breach: thepath goes to
loadSSHKeyfiledirectly, bypassing the root, andsigning.DefaultSignercarries thejustification the
Dirdoc requires -- "the publisher's own SSH directory is not ours to confine ... a rootanchored at our config tree cannot address it."
devlore-test/runner.goclaimed a confined root "refuses by design" because scripts under test addressabsolute paths. False, and it was the last thing making the variant look necessary. An absolute path inside
the anchor is fine, since
fsroot.Pathderives its root-relative half from it. The fixture paths that genuinelysit outside --
"/some/dir/file.txt"forfile.nameandfile.parent, and the"/tmp/fake.*"arguments toarchive and encryption -- are pure string operations or plan-shape fixtures that never execute against a real
file. Corrected in step 2.
Step 2 is up, and it found eight fixtures reaching across trees
Confining the test roots failed eight tests, all for the same underlying reason: fixtures reached across trees
because nothing stopped them.
testFileResourcecalledt.TempDir()itself so a copy's source sat in a secondtree; the archive fixtures wrote their tarball one level above the root they extracted into; and two tests used
"/nonexistent/path"as a convenient absent value.Worth recording because production has been confined all along --
plan/provider.go:488anddeploy/plan.go:387-- so these tests were exercising a path production never takes. All eight are fixedin step 2.
refactor(cli): open CLI trees confined, creating them when absent (#570)
fix(star): close the test Applications, and move the knowledge target…
refactor(fsroot): delete the unconfined variants (#573)
refactor(fsroot): rename confinedRoot to confinedDir, scratchRoot to …
fix(archive): symlink targets go to the kernel; digests and compares …