check_purity: a Kernel module is called only at its functions; the Kernel raises nothing and names no special attribute (#593)

Merged
DO
11d ago
+291-25

Closes #593, on the Factory Builder's story of 2026-11-07. tools/check_purity.py refuses the plainly written ways the reads of #591 found for the Kernel to call a value it is handed. The record names what the check leaves to the review Role. Its record is 0155.

What changes

Way, from #593Now
A module's value, a name it lacks, or what its __getattr__ returns, called through the module (terms.LIMIT(), terms.apply(fetch, xs))Refused: a call of a Kernel module is of a function it defines or imports
An imported name or a module's attribute handed to be called (sorted(xs, key=LIMIT))Refused unless it is a Kernel function
map or filter handed to another mapmap, filter and type (UNHANDED_BUILTINS) are never handed to be called
Three-argument type, and raise of a handed classtype takes one argument written out, never a spread; raise is refused in the Kernel (none on main)
a.__dict__.update(...), a module's or package's __getattr__Any __x__ name the Kernel's syntax tree holds is refused, but a constant's and the from __future__ module (none on main)
A module beside a package of its name; a package binding a name that also names its submoduleBoth refused, unless the package binds that very submodule
A walrus in a top-level function's defaultWhat a top-level definition reads binds in the module, as already for a nested function
A default for _decisionAlready refused by the default rule; a test now holds it
A caller outside kernel/; deliberate evasion through Python's own workings; listed methods on non-built-in values and special methodsNamed as not held in the record, with the reason

A name a comprehension binds stays read as its scope's, as in a function's body: stricter than Python, and kept on purpose.

Also from Argon's read of #591: finer mutants for the two guards of the forwarding test and the lambda half of the taker-placement test. if spread or not said: was always true where it stood (an empty said is the only way to reach it), so it is gone, not split.

FileChange
tools/check_purity.pyThe rules above; _packages for the package rules
tests/test_tools.pyCases in the two existing Purity tests; test_a_module_is_called_into_only_at_its_functions; test_a_package_is_read_as_python_imports_it
tools/mutants.pyNew mutants under "Issue 593", and 7 of #591's repointed at the lines they mutate now. All 73 check_purity mutants parse and are killed
docs/decisions/0155-…, kernel/AGENTS.mdThe record; kernel/AGENTS.md's first row names raise and special names, and the calls row names the module test

Protected paths

None.

Reviews

RoundHeadReaderRead, and what changed
12abddffClaude, with securityApprove; type(*parts) passed, the _decision default row overstated, a dead Starred test: fixed in 399a750
12abddffCodextype(*args): fixed in 399a750. Comprehension names in a top-level default read as the module's: kept, as 0152 reads a function's body, and named in the record
12abddffAstra, as Muse's stand-in (Muse: not run, quota)type(*args), a package's __getattr__, an imported __dict__: fixed in 399a750 by refusing every special name
12abddffArgontype(*xs): fixed. type() and a _decision taker handed to map or key= were already refused: tests added in 9653ae8. Decorators and nested defaults were already refused or read
1399a750, 9d40420checksThe record named kernel/ paths bare and an issue without its title; a kernel/AGENTS.md line over 260: fixed in 399a750 and 9d40420
29653ae8ClaudeNo blocker; a keyword's and an alias's special name, a dotted from module, a pattern's attribute, the module test off the row: fixed in 5dfa5f9
29653ae8ArgonA pattern's kwd_attrs and other fields _special did not read; finer mutants: fixed in 5dfa5f9, _special reading every name the tree holds
35dfa5f9Claude, ArgonA relative from .__future__ import passes; no test holds __future__ refused outside an import's module, or an import's names read once. Round 2 was the last fix round: all three are in #600

Verify

make verify on an export of 2e21a76, main merged in and the record numbered 0155, each Boundary naming its mutants as decision 0154 asks: 1656 tests, OK. Every check_purity mutant is killed by the test its row names. Muse's read is owed after 2026-11-09 (not run, quota); Astra read in its place.

šŸ¤– Generated with Claude Code