The writes check holds a namespace package, sys's modules, a class's attribute set from outside, and gh or git run from Python (#596)

Merged
DO
10d ago
+214-12

Closes #596.

What changes

tools/check_writes.py now refuses the four routes the reads of #587's PR found. Each route is one only code written to hide a write would take, and none is used on main.

RouteNow
A namespace package: with no adapters/__init__.py, import adapters.effects was read as no module of the repo's_package reads a folder of modules with no package module as a namespace package, and _lookup reads its modules. The dotted import reaches what the module writes
A module taken from sys.modules by its nameReading sys.modules, or from sys import modules, is refused as a load by name, like importlib. NAME_LOADERS still exempts tools/mutants.py
A class's attribute set by setattr, or from a function, then called through the class elsewheresetattr is refused. So is setting an attribute on a class to anything but text from a function, or from another module than the class's. Text is allowed because tools/trial_p50_stub.py sets a log path that way, and text reaches nothing
gh or git run as a subprocess from PythonA string that is gh or git, or that opens a command line with either, is refused outside the new RUNNERS list. That list names the eleven files on main that run git to read or read a command they are given: harness/steps.py, five hooks, tools/check_decisions.py, tools/check_trials.py, tools/commits_are_the_maintainers.py, tools/mutants.py and tools/untested.py, which came to main with #634. Adding one is the Maintainer's call, as adding to CALLERS is (decision 0153)

Code that builds a command's name from parts is still not caught; decision 0153 leaves such code to review.

Boundary cases are in tests/test_tools.py: Writes.test_what_cannot_be_read_fails gains seven, and a new test, Writes.test_a_namespace_package_is_read_as_one, removes adapters/__init__.py from a copy. There are twelve new mutants under "Issue 596", all killed. One existing mutant, "import is let through", is repointed to the changed line.

Record 0167 amends decision 0153's two "Not held here" rows for these routes.

Protected paths: none. tools/check_writes.py's RUNNERS is a new list of who may run gh or git. Like CALLERS, it is the Maintainer's to change. The Maintainer accepted its starting list of ten files on 2026-11-08 through the Factory Builder, and approved tools/untested.py as the eleventh the same day, the same way.

Verify

make verify on an export of d0cfced, up to date with main and numbered 0167: 1706 tests, OK (8 expected failures).

Reviews

ReadState
Claude + securityTwo fix rounds. Round 1 (d2a528a): sys re-exported or imported whole, a namespace package's other names, shadowed and unpacked class sets, gh by its path, stale RUNNERS. Round 2 (47d57c8, 9a52324): the half-held .exe match dropped, and wording. Routes that need values read, such as a RUNNERS helper given a write's arguments, aliased classes and getattr(sys, 'modules'), are named as not held and are #640's
ArgonFirst read: three findings, fixed in d2a528a. Its reads of both fix rounds found routes that are now on #640
Musenot run (quota); owed after 2026-11-09
Astranot run (quota)
CodexTwo findings, fixed in d2a528a. Three at 9a52324, after the last fix round, are on #640

šŸ¤– Generated with Claude Code