Skip to content

fix(containment): measure the module folders pwsh loads in WritableRoots - #62

Merged
raandree merged 5 commits into
mainfrom
ai/writable-roots-module-folders
Nov 15, 2026
Merged

raandree merged 5 commits into
mainfrom
ai/writable-roots-module-folders

Conversation

@raandree

@raandree raandree commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Brief 12: the WritableRoots check of the containment verifier now
measures, beside its escape set, the places PowerShell loads modules
from: every entry of the verifier's own PSModulePath, the Modules
folder of $PSHOME, the folders of the user's and of $PSHOME's
powershell.config.json, and on Windows the two module folders of
Windows PowerShell 5.1, including the relative one that 5.1 searches
in its working directory when the documents folder does not resolve.

  • Such a place fails the check when this identity can write or replace
    it, whether a declared root covers it or not.
  • A place that does not exist is judged by the nearest existing place
    above it; a relative, network or device entry is reported unmeasured
    without being opened.
  • Every path and reason in the check's evidence is relayed as
    printable ASCII and cut at 200 characters, which settles this
    check's part of R11-01.

Q1 to Q4 were decided under the owner's delegation; merging this is
the owner's explicit answer. Stricter verdicts: an identity that can
write or replace its module folders fails, and one without Documents
is unmeasured.

Validation: every behavior red first; 64 mutants on copies, 63 caught,
X09 equivalent except for network access. The full gate before the
Memory Bank commit passed 5,989 tests, 0 failed, 145 skipped, coverage
91.61 %. Review: Request changes twice (R12-01 to R12-09), then
Approve; all fixed. R12-02, the push guard's own exposure under 5.1,
goes to brief 18, which follows.

The Ubuntu and macOS legs of the new tests run here for the first
time. Verifier digest after this merge, superseded by brief 14's:
d7d2b02f3202954e8a6a16d010c47786572fffb403ebb02a354c51d4923bf869
The appender keeps brief 13's digest.

Rebased onto main unchanged, plus one test-only commit from the
publish step. The first CI run of this pull request failed one relay
row on Ubuntu and macOS: its fixture did not map the folder that
holds a file, which the verifier measures off Windows. The row now
maps that folder and runs on both platform branches on every system.

Co-authored-by: AI Assistant ai@example.com
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

raandree and others added 5 commits November 14, 2026 23:34
pwsh puts the account's own module folder ahead of every folder a launcher
names, and the verifier's later commands auto-load modules from it, but
WritableRoots measured only its escape set (the S-18 follow-up, brief 12).

- Get-ModuleSearchSet names every entry of the verifier's own PSModulePath,
  the Modules folder of $PSHOME, and the folders of both
  powershell.config.json files, with each file that exists.
- Test-WritableRoot fails a writable module or configuration place even
  inside a declared root; the six escape entries keep their exemption.
- Measure-EscapePath judges a place that does not exist by its nearest
  existing ancestor: writable with the right to add a folder there, closed
  below a file, unmeasured when nothing on its path exists.
- A relative, network or device entry is reported unmeasured, never opened.
- Every path and reason in the evidence is relayed through
  Format-RelayedText, 200 characters each and 1,000 per list (part of R11-01).

Tests first: 34 of 124 red for the stated reason, then the 29-row relay
table red before any relay. 34 mutants caught on copies outside the working
tree. ContainmentVerifier suites: 1,094 passed, 0 failed, 3 skipped.
The verifier digest becomes 2cea2d64...aab8c3; containment profiles re-pin it.

Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tableRoots

The review of 0b7e4ab asked for changes (R12-01 to R12-07). Fixed as the
controller ruled under the owner's delegation:

- R12-01: a place of the module search set counts as writable while this
  identity can replace it: on Windows by DELETE on it, which the kernel also
  grants through FILE_DELETE_CHILD on the folder that holds it; elsewhere by
  write access to that folder, so a run off Windows is not made unmeasured.
  The remedy, gaps 1 and 3, docs/SECURITY-REVIEW.md and the CHANGELOG take
  the reviewer's wording, and the remedy also removes FILE_DELETE_CHILD and
  DELETE for the identity on Documents. The six escape entries are unchanged.
- R12-02: on Windows the set also names Documents\WindowsPowerShell\Modules
  and %ProgramFiles%\WindowsPowerShell\Modules, resolved without verifying
  that they exist. The guard's own exposure under Windows PowerShell 5.1
  stays open for brief 18, and the README, the review entry, the S-18 rows
  and the CHANGELOG say so.
- R12-03: start the folders empty or re-own an existing tree recursively;
  only each place is judged, not the modules inside it.
- R12-04: a file above an absent place counts as writable when this identity
  can delete it, for every entry.
- R12-05: a profile path without a folder part throws too, and a throw of the
  set leaves WritableRoots Unavailable with the reason relayed, so the run
  gets its report.
- R12-06: four wordings (USERPROFILE, a link on the way to a share, how a link
  is measured, "until it closes them").
- R12-07: rows for a padded entry and a trailing dot; the separator follows
  the platform the check measures, so both separators are pinned on every leg.
- Both switch statements of Test-WritableRoot name Closed, and any other
  state is unmeasured.

Tests first: 18 of 179 Flow and Filesystem tests failed for the stated
reason, then 179 passed. Mutants on copies outside the working tree: 59, all
caught, the reviewer's M11 and M12 among them; the phase 2 mutant M33 was
caught after its test pinned its own reason. Every ContainmentVerifier suite:
1,118 passed, 0 failed, 3 skipped by design. PSScriptAnalyzer: 0 findings.
markdownlint: 0 issues.

Verifier SHA-256: 754a2f9cd8ca3225361b42ee5dd31cd0c4acd9ce441e44228abc770c0f1c7094

Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The scoped re-review of 3eb5d8f found two more ways to a false Pass. Fixed
as the controller ruled under the owner's delegation:

- R12-08: Windows PowerShell 5.1 resolves the documents folder with
  verification, and when that folder does not resolve, it puts the relative
  WindowsPowerShell\Modules first, which resolves against its working
  directory. The set named the unverified absolute path instead, so a closed
  profile without Documents passed. On Windows a local documents folder that
  Directory.Exists does not find, or one that cannot be named, now names
  5.1's relative entry, which Get-SearchPathProblem reports unmeasured.
  DoNotVerify stays, and a share stays a network entry that is never asked
  whether it exists. The README, docs/SECURITY-REVIEW.md and the CHANGELOG
  say that 5.1 searches its working directory then, that a Pass describes
  the state at the check, and that every hook call starts 5.1 afresh, so
  moving or re-pointing Documents during a run reaches the guard, which
  brief 18 owns.
- R12-09: the remedy removes FILE_DELETE_CHILD, DELETE, WRITE_DAC and
  WRITE_OWNER for the identity on Documents, and has an administrator own
  it, because an owner holds WRITE_DAC whatever the access list says.

Tests first: the row of a missing local documents folder and the case of
the reviewer's false Pass failed for the stated reason, and the other 179
tests passed; then 182 of 182. Mutants on copies outside the working tree:
63 of 64 caught. The reviewer's X09 (verification instead of DoNotVerify)
survives: it is now equivalent in what the set names, except for network
access, which a unit test cannot show. Every ContainmentVerifier suite:
1,121 passed, 0 failed, 3 skipped by design. PSScriptAnalyzer: 0 findings.
markdownlint: 0 issues.

Verifier SHA-256: d7d2b02f3202954e8a6a16d010c47786572fffb403ebb02a354c51d4923bf869

Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Brief 12 is done on ai/writable-roots-module-folders, stacked on brief 17's
branch, not pushed. activeContext.md names it as the current focus and
brief 14, then 15 and 18, as next; progress.md gains its milestone and drops
the oldest one; systemPatterns.md gains the pattern that a place a later
process auto-loads code from is judged whatever root covers it, and that
replacement counts as writing, without a new line.

Full gate on a137a19: 5,989 passed, 0 failed, 145 skipped, coverage
91.61 %, 21 tasks, 0 errors, the expected 16 warnings. Memory Bank health:
0 errors, 0 warnings. Memory Bank and secret-scan suites: 79 passed.

Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Off Windows the verifier judges a path below a file by the write
right on the folder that holds the file (Get-ReplacementRight). The
relay row 'an escape path below a file' mapped only the file, so on
Ubuntu and macOS the mock answered Absent for that folder, and the
row read Unavailable instead of Pass. That one case failed both CI
runs of pull request #62 (43649252975 and 43649217522) on Ubuntu and
macOS; Windows, which reads DELETE on the file itself, passed.

Map that folder closed, as the sibling rows already do, and pin the
row to both platform branches, so that a run on any system covers
both. Red first: the POSIX row failed on Windows for that reason;
the whole file then passed, 105 of 105.

Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@raandree
raandree merged commit deca98d into main Nov 15, 2026
10 checks passed
raandree added a commit that referenced this pull request Nov 16, 2026
Brief 19 published the stack of briefs 13, 16, 17, 12, 14, 15 and 18
as #59 to #65, each squash tree equal to its rebased tip and each
pull request's CI green on Ubuntu, macOS and Windows. #62's first CI
failed one relay row off Windows, a fixture gap that a test-only fix
in its squash closed; the CI-platform pattern records the lesson.
~/.copilot was redeployed from bd28133.

The active context moves the merged briefs to previous focuses and
names the owner's remaining steps. Progress records the milestone and
the newest preview, and curates the oldest milestone.

Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@raandree
raandree deleted the ai/writable-roots-module-folders branch November 16, 2026 21:39
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