Skip to content

check_writes: a name is read where it is stored, every class and owner it may be, and exec only where a binding always runs (#655) - #686

Merged
don-petry merged 8 commits into
mainfrom
tools/check-writes-routes-655
Nov 10, 2026
Merged

don-petry merged 8 commits into
mainfrom
tools/check-writes-routes-655

Conversation

@don-petry

@don-petry don-petry commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #655 ("check_writes: routes still open after issue 640, an aliased stored name, a second class traced, exec by a binding that never runs"). That covers the issue's routes and the four that Muse's read of the merged #650 added. Every route is refused by tools/check_writes.py, so none is left named as "not held".

Route Now
A name stored under an if, a try or a walrus, imported under another name (from a import P as Q) Read back to the module that stores it (_origin)
A name declared global in another module's function That module's global assignments are read
A second class, or a second owner, that a name may be (a PATCHERS file's second owner too) Every class is read; each owner is given apart, so PATCHERS allows each only by name
vars(other) or other.__dict__ held by a name, then handed to a call Read back through the name (_namespaces), whether a function's or the module's
A nonlocal value two steps away Read in the nested function that assigns it
exec, eval or compile bound by an import that may never run, under an if or a try, in a function, or deleted Only an unconditional top-level import or definition exempts the name, and only if it is never deleted
A loader reached by name: getattr(m, 'importlib'), m.__dict__['importlib'] A load by name. So are sys, modules, __builtins__ and __import__, by a literal key, getattr or get
__builtins__ as a module's attribute; sys or modules given to get A load by name
Shell words: timeout -s KILL 60 git push, eval, watch, stdbuf, a case pattern's ) A command
An unbound fill on another module's container: dict.update(portinst.TABLE, ...), list.append(...) Read as the bound fill is
_READ keyed on id(fn); two files of one module name Keyed on the node itself; two files of one module are refused

Holds.

  • tests/test_tools.py::test_the_routes_issue_655_names_are_refused gives each route a boundary case. It also checks that an unconditional top-level import of exec still passes, and so does a module filling its own container.
  • There are 21 new mutants, one for each rule. 19 existing mutants follow the lines this change rewrote, each still breaking what it broke before.
  • A filtered run of all 40 killed every one, with CI: make verify runs in three legs, and a mutant its named tests miss is an error, not a whole-suite run #666's named_test_does_not_kill guard on.
  • Main still passes the check.

Record. docs/decisions/0177-… (number given by the Factory Builder) amends 0171's "Still not held" row. CI's gap check fails until 0176 (#689) is on main. Main is merged in and verified before enqueue.

Review rounds. Two full rounds of Argon, Muse, Claude and the Claude security review, then CI's twelve mutant shards, found more routes of the same kinds. Each one is now refused with a boundary case and a mutant, or named in 0177 as not held:

  • Accessors. pop, setdefault and __getitem__, bound or unbound.
  • exec. By a literal key, getattr or accessor (len.__self__). Used before its binding, inside it, or in a function called first; or after except ... as exec.
  • Fills. Unbound fills by any name for a container type (D = dict, MutableMapping, __ior__, __iadd__), with the receiver read too.
  • Shell words. setsid, coproc, ionice, unbuffer, caffeinate, doas; and timeout, flock, taskset and chrt with their first word.
  • case patterns. |, a leading (, and the ;;, ;& and ;;& leads. A ) leads a command only after in, ;;, ;& or ;;&, so prose with a ) before git passes.
  • Stored names. Top-level tuple parts; a store beside a plain assignment, a def or an import; every import hop followed; a global through a local alias for its module.
  • vars(). Held by a global, an imported name or another module's attribute, or handed on by a walrus.
  • Bound two ways. A name a def binds and an if stores.
  • Problems told once.

0177 states the deliberate refusals:

  • A function-level from re import compile.
  • A mapping read by a module-like key such as 'modules'.
  • Prose that puts a wrapper word before git.

Verification. make checks passes, and so does the Writes test class (10 tests). A make verify on an export of the head is running.

Protected edits: none outside tools/ and docs/decisions/. No RUNNERS, CALLERS or PATCHERS entry changes. Labelled factory:hands-off.

🤖 Generated with Claude Code

…r it may be, and exec only where a binding always runs (#655)

Issue 655 and the four routes Muse's read of the merged pull request for issue 640 added, each refused:
- a name stored under an if or declared global is read back to the module that stores it, through any import of it;
- every class and every owner a name may be is read, a PATCHERS file's second owner too;
- vars(m) or m.__dict__ held by a name before it is handed on, and an unbound fill, dict.update(other.TABLE, ...);
- a nonlocal value is read in the nested function that gives it;
- exec, eval and compile are the module's own only by an unconditional top-level import or definition, not deleted;
- a loader, sys, modules, __builtins__ or __import__ by a literal key, getattr or get, and __builtins__ as an attribute;
- a command after a case pattern's ), after eval, watch or stdbuf, and after timeout's options with their values;
- two files of one module are refused, and a reading is cached under its node, never its id.

Record 0174 (number to be confirmed at enqueue) amends 0171's row "Still not held". Each rule has a boundary case in
test_the_routes_issue_655_names_are_refused and a mutant it kills; 19 mutants follow the lines they mutate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@don-petry
don-petry requested a review from a team as a code owner November 9, 2026 18:43
@don-petry don-petry added the factory:hands-off A person's mark: the Factory writes nothing on this pull request (kernel/terms.py LABEL_HANDS_OFF) label Nov 9, 2026
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T18:43:12.665852Z
We couldn’t complete this review. Comment @codex review to try again.
73f812a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

don-petry and others added 4 commits November 9, 2026 13:07
… a command only after a case pattern

Muse, Argon and the Claude reviews of 73f812a found more of the same kind, each now refused with its boundary case and
mutant: sys or modules by pop, setdefault or __getitem__; a name stored plainly beside an if; a global through a local
name for its module, or one the importing module's own function assigns (every hop of an import is read); vars held by a
global or an imported name, in its own scope; exec, eval or compile by a literal key, getattr or accessor (len.__self__),
used before or inside its own binding, or after an except deletes it; an unbound fill by any name for a container's type
(D = dict, MutableMapping, __ior__, __iadd__), its receiver read too; setsid, coproc, ionice, taskset, chrt, unbuffer,
caffeinate, doas and flock; a top-level tuple's parts. A ) leads a command only after in or ;;, so prose with a ) before
git passes; one problem is told once; and the old sys key clause, which BY_NAME now holds, goes with its mutant moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ord 0174 names this round's routes and refusals

A run of all 224 check_writes mutants found four that no test killed: exec's top-level filter duplicated _before, so it
goes, and _before refuses an import from builtins; a local D = dict and a name that may be a type or a container now
have their cases; and the exec mutants follow the lines they mutate. Record 0174 names the second round's routes, the
refusals it makes on purpose (a function's own import of re.compile, a mapping read by a module's name, prose that puts
a word that runs the next before git), and what is still not held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ve its use, and a name bound two ways is refused where it is set

Muse's and the Claude reviews of 49936ad: a case pattern's alternatives, opening ( and the ;; ;& ;;& leads; taskset and
chrt take a first word; an unbound accessor's key, dict.get(d, 'sys'), is read; exec, eval or compile is the module's
own only for a use below its binding, a function's body too, since the function may run first; a name a class or def
binds and an if stores is bound two ways, and refused where it is set on; vars held by another module's name reached as
its attribute, by any name for that module, or handed on by a walrus. Record 0174 names them, and what is still not held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s read beside any binding, and the container read keeps its scope

Argon's second read: an import of a name beside a store of it in the same module is followed to where it is stored; what
each hop stores is read whatever the name resolves to first; _container reads a nested value in its own scope, keys what
it has seen by scope, and reads a binding's module plainly. A name a def binds and an if stores is bound two ways only
where no plain assignment already makes it so, so each rule keeps a mutant of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
don-petry and others added 3 commits November 9, 2026 16:12
…ssignments, and the record takes 0177

CI's shards found two mutants that no test killed once every hop's stored values were read: the constant's plain
assignments were read twice. The hop now reads only what a plain assignment does not already give, so the plain read
keeps its own mutant, and the duplicate plain-read mutant goes. The record takes 0177, the Factory Builder's number;
CI's gap check reads it once 0176 is on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s no key, and 0177 names what is still not held

Muse's, Argon's and the Claude reviews of 409932e, each with its boundary case and mutant: case leads with no space;
exec deleted by globals().__delitem__; getattr as an attribute; a key in an f-string of constants; vars behind a second
name through an attribute, a walrus or getattr(holder, 'd'), and through a holder's re-export; an imported container filled
by an augmented assignment; a container's type a module stores read in its own scope, one a default gives under a
shadowing name, and one imported from another module of the repo's; a module-level alias as an attribute's base; a def
an if stores. A bound accessor's key is its first argument and an unbound one's its second, so a get's default passes
again. Record 0177 names each, and the routes still not held: a dict subclass, a key built from parts or starred, a
container's type a global gives, other unpackings and a def under an if.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@don-petry
don-petry added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 62074b2 Nov 10, 2026
26 checks passed
@don-petry
don-petry deleted the tools/check-writes-routes-655 branch November 10, 2026 00:01
don-petry added a commit that referenced this pull request Nov 10, 2026
…head merged so the numbers run whole

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

factory:hands-off A person's mark: the Factory writes nothing on this pull request (kernel/terms.py LABEL_HANDS_OFF)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check_writes: routes still open after issue 640, an aliased stored name, a second class traced, exec by a binding that never runs

1 participant