check_purity: a Kernel module is called only at its functions; the Kernel raises nothing and names no special attribute (#593)
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 #593 | Now |
|---|---|
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 map | map, filter and type (UNHANDED_BUILTINS) are never handed to be called |
Three-argument type, and raise of a handed class | type 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 submodule | Both refused, unless the package binds that very submodule |
| A walrus in a top-level function's default | What a top-level definition reads binds in the module, as already for a nested function |
A default for _decision | Already 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 methods | Named 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.
| File | Change |
|---|---|
tools/check_purity.py | The rules above; _packages for the package rules |
tests/test_tools.py | Cases 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.py | New 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.md | The record; kernel/AGENTS.md's first row names raise and special names, and the calls row names the module test |
Protected paths
None.
Reviews
| Round | Head | Reader | Read, and what changed |
|---|---|---|---|
| 1 | 2abddff | Claude, with security | Approve; type(*parts) passed, the _decision default row overstated, a dead Starred test: fixed in 399a750 |
| 1 | 2abddff | Codex | type(*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 |
| 1 | 2abddff | Astra, 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 |
| 1 | 2abddff | Argon | type(*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 |
| 1 | 399a750, 9d40420 | checks | The record named kernel/ paths bare and an issue without its title; a kernel/AGENTS.md line over 260: fixed in 399a750 and 9d40420 |
| 2 | 9653ae8 | Claude | No 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 |
| 2 | 9653ae8 | Argon | A pattern's kwd_attrs and other fields _special did not read; finer mutants: fixed in 5dfa5f9, _special reading every name the tree holds |
| 3 | 5dfa5f9 | Claude, Argon | A 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