Skip to content

docs: rule the session accessors and record phase 2 as proved - #411

Merged
David-Noble-at-work merged 1 commit into
developfrom
windows-permissions-2b-rulings
Aug 14, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
windows-permissions-2b-rulings

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Summary

Phase 2b of windows-native-permissions.md
(#405) was blocked on two design questions.
Both are ruled here, with rejected alternatives recorded so they are not relitigated.

The rulings

Root — HasRoot() bool plus a Root() that panics when it is false, modeled on
reflect.Value.IsValid: the rule stated once in the predicate's doc, a typed panic rather than a
string, and the producer advertising which constructors can yield a rootless session. The case is
real — cmd/lore/lore/builder.go:108 builds one in production, and seven call sites nil-check the
field today.

Rejected: comma-ok (context.Deadline's shape) on call-site distribution — 75 of 82 sites
structurally have a root, which is exactly why reflect.Value pairs a predicate with panicking
getters; and a bare nil, because fsroot.Root is an interface, so nil does not avoid the
panic, it relocates it into fsroot internals with a stack that never names the mistake.

Scratch — no HasScratch (root's absence is configured, scratch's is not configurable at
all, so the predicate could only ever return true), and Scratch() is an accessor to a
per-session directory inside the OS temp directory
— never a root over the temp directory itself.
That anchoring fails three ways: OpenScratch's Close contract would delete the shared system
temp directory; confinement to a directory every process writes to isolates nothing and collides by
name; and only a directory of our own can be created 0700 and inherit phase 2's DACL protection —
which matters, because scratch holds the most sensitive transient data in the system.

os.TempDir() accessibility is preflighted at environment build like the root's anchor, and
that settles the signature: preflighting supplies the validated premise, so a later MkdirTemp
failure is a failure after verification — an assert. Scratch() fsroot.Dir returns the
directory alone, symmetric with Root().

fsroot.Dir gains CreateTemp and MkdirTemp, landing in 2b.2 alongside the accessors. A
shared per-session directory needs unique names within it, and gather dispatches bodies
concurrently by design — os.CreateTemp supplies that free today, Dir.Create does not. Both trees
carry the methods; the rule for choosing goes verbatim in both doc comments: use Scratch()
unless the bytes must end up in the root's tree atomically
, since a rename out of scratch can
cross a device boundary and degrade to a copy.

Phase 2 is complete

Its CI exit gate was met and never recorded: pkg/fsroot reports ok on
test (windows-latest), so all six TestApplyMode_* DACL tests pass on a real Windows runner and
none appear in that leg's 28 known failures. Call sites are cleared to migrate, which was the
condition phases 3 and 4 were waiting on.

Also

  • PR 2b.1 split into 2b.1a (merged, test(op): build test sessions through the real constructor, not literals #410) and 2b.1b (next), with a branch plan for the
    remaining 13 files / 26 sites naming both traps: starcode's Root: lines are only half
    environment fields, and file/provider_test.go sets a BackupSuffix the constructor never
    defaults.
  • The current-state table separates Windows enforcement through fsroot (works) from
    everywhere else (does not).
  • Recorded from the 2b.1a round-trip: make lint-all is the gate, not gofmt, which never
    reorders import groups. This repository runs no pre-commit hooks, by decision.

Documentation only — no code changes.

Assisted-by: Claude

Phase 2b of the native-Windows-permissions plan (#405) needed two design
questions answered before its 82-site mechanical pass could start. Both
are now ruled, with the reasoning and the rejected alternatives recorded
so neither gets relitigated.

Root: HasRoot() bool plus a Root() that panics when it is false, modeled
on reflect.Value.IsValid -- whose doc states the rule once, whose panic
is typed rather than a string, and whose discipline puts the burden on
the producer to advertise. The case is real: cmd/lore/lore/builder.go
builds a rootless session in production, and seven call sites nil-check
the field today. Comma-ok was rejected on call-site distribution (75 of
82 sites structurally have a root); a bare nil was rejected because
fsroot.Root is an interface, so nil relocates the panic into fsroot
internals rather than preventing it.

Scratch: no HasScratch -- root's absence is configured, scratch's is not
configurable at all, so the predicate could only ever return true.
Scratch() is an accessor to a per-session directory INSIDE the OS temp
directory, never a root over the temp directory itself: OpenScratch's
Close contract would delete the shared tree, confinement to a directory
every process writes to isolates nothing, and only a directory of our
own can be created 0700 and pick up phase 2's DACL protection -- which
matters, because scratch holds the most sensitive transient data.

os.TempDir() accessibility is preflighted at environment build like the
root's anchor, and that decides the signature: preflighting supplies the
validated premise, so a later MkdirTemp failure is a failure AFTER
verification, which is an assert. Scratch() fsroot.Dir returns the
directory alone, symmetric with Root().

fsroot.Dir gains CreateTemp and MkdirTemp, landing in 2b.2 alongside the
accessors. A shared per-session directory needs unique names within it
and gather dispatches bodies concurrently by design; os.CreateTemp gives
that free today and Dir.Create does not. Both trees carry the methods,
and the rule for choosing goes in both doc comments: use Scratch()
unless the bytes must end up in the root's tree atomically, because a
rename out of scratch can cross a device boundary.

Phase 2 is marked complete. Its CI exit gate was met and never recorded:
pkg/fsroot reports ok on test (windows-latest), so all six TestApplyMode
DACL tests pass on a real runner and none appear in that leg's 28 known
failures. Call sites are cleared to migrate.

Also: PR 2b.1 split into 2b.1a (merged, #410) and 2b.1b (next), with a
branch plan for the remaining 13 files and 26 sites naming both traps --
starcode's Root: lines are only half environment fields, and
file/provider_test.go sets a BackupSuffix the constructor never
defaults. The current-state table now separates Windows enforcement
through fsroot, which works, from everywhere else, which does not.

Recorded from the 2b.1a round-trip: make lint-all is the gate to run
before handing off Go changes, not gofmt, which never reorders import
groups. This repository runs no pre-commit hooks by decision.

Assisted-by: Claude
Signed-off-by: David Noble <[email protected]>
@David-Noble-at-work David-Noble-at-work self-assigned this Aug 14, 2026
@David-Noble-at-work
David-Noble-at-work merged commit 5ab6b86 into develop Aug 14, 2026
7 of 8 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the windows-permissions-2b-rulings branch August 14, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant