check_purity allows __future__ only as an absolute import's module, and reads an import's names once (#600)
Merged
DO
10d ago+22+22+01234567890123456789-3-3-0123456789
Closes #600.
What changes
In tools/check_purity.py, _special refuses a name written __x__ anywhere in the Kernel's syntax tree, except as the module of from __future__ import. This PR closes the three gaps the last reads of #599 found:
- A relative
__future__is refused. The exemption now holds only when the import is absolute (not node.level). Sofrom .__future__ import g, which names a Kernel module, is refused likefrom kernel.__future__ import g. __future__is refused outside an import's module. New boundary cases:def f(__future__):andfrom kernel.terms import run as __future__.- An import's names are read once. A new assertion checks that
from kernel.terms import __dict__ as nsgives exactly one problem naming__dict__, atx.py:1.
The new cases are in tests/test_tools.py::Purity.test_the_kernel_calls_nothing_it_is_given. Three mutants are added under "Issue 600", and one existing mutant is repointed to the changed line:
| Mutant | Main's test | This test |
|---|---|---|
| a relative future is the one allowed | survives | killed |
| future is allowed wherever it is named | survives | killed |
| an import's names are read twice | survives | killed |
No record: decision 0155 already allows only from __future__ import, and this makes the check hold to it. No protected path is touched.
Verify
Pending.
Reviews
| Read | State |
|---|---|
| Claude + security | pending |
| Argon | pending |
| Muse | not run (quota); owed after 2026-11-09 |
| Astra | not run (quota) |
| Codex | automatic on push |
š¤ Generated with Claude Code