Repository navigation
NZ walk: pin four rules the review of 04c8379fd found unpinned (#1578) - #1579
Merged
Merged
Conversation
The delta review of #1567's head, 04c8379, approved it with four optional findings: three rules of the static walk that no root pinned, and one form that "What it can't see" didn't list. This commit takes all four. Each new root sits beside the getter roots of #1567: a module with a __getattr__ that answers for name, so Python reads the root's target whenever the module's own bindings miss name. - names_all's ast.Name clause (finding 1). r_getattr_maybe_star_all_walrus_default and _walrus_class star-import a source that binds __getattr__ through a walrus in a top-level def's default, or __all__ through a walrus in a class's bases. Either way the star import brings in nothing. _Module files the def or class under its functions or classes, so only the clause sees the walrus, and a knockout of the clause fails both roots. - names_all's declared test (finding 2). r_getattr_maybe_star_all_global_getter star-imports a source whose function declares global __getattr__ and imports a getter under that name. A knockout that reads only "__all__" in declared fails it. - sure_stars' top-level restriction (finding 3). r_getattr_maybe_star_skipped holds its star import under `if False:`, so the import brings in nothing. A knockout that counts every star import as binding for sure fails it. - "What it can't see" (finding 4) now lists an __all__ that sys.modules[__name__] sets, and the BLIND root r_getattr_self_set_all pins it: Python reads the getter's target, and the walk counts name as bound for sure. The cases hold 212 roots, 249 targets, 14 in OVER, 27 in BLIND and eight decoys. No earlier root, source, OVER or BLIND entry changes, and the walk's code changes only in that docstring entry. On CPython 3.14.7 and 3.13.15, outside pytest, all 212 roots pass the targets and runtime-read checks, and the walk passes the once, fresh-walk and budget checks on every root and on 300 random trees. Each rule's knockout fails exactly its new roots: dropping the clause fails the two walrus roots, reading only "__all__" in declared fails r_getattr_maybe_star_all_global_getter, and counting every star import as sure fails r_getattr_maybe_star_skipped. With the 65e3e79 review's exact text, its two edits that log a pass as adding each fail 18 roots by the once check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take the optional findings of the 00cee93 review and Belgium's review of round D. No code changes: the walk's AST without docstrings and the cases' AST (with TARGETS sorted) equal 00cee93's. - static_reach.py, "What it can't see": the hidden-__all__ entry now names one that a module, itself included, sets as an attribute (through sys.modules[__name__], an import of itself or setattr), and one that globals(), locals(), vars() or exec sets. The review found the self-import, sys.modules.get, import_module(__name__), vars() and locals() spellings each blind in the same way as the BLIND root. Belgium's wording (suggested-doc-D.diff). - static_reach_cases.py: TARGETS is sorted again (getattr_maybe_star_private before getattr_maybe_star_skipped), and BLIND's comment block names an __all__ that a module, itself included, sets as an attribute, which covers r_getattr_self_set_all. Belgium's run with both files: all 212 roots pass the walk and Python's reads on 3.14 and 3.13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
November 11, 2026 19:49
Contributor
Author
|
Merged by the NZ hub (session local_e407a527) at 352c1b5 with --squash. Gates: |
MaxGhenis
added a commit
that referenced
this pull request
Nov 12, 2026
Main moved 58 commits past 27e305d, the main this branch last merged: #1579 (NZ walk pins), #1553 (review follow-ups), #1311 (ACS local artifact writer binding) and #1583 (UK event data, PR3). They change 136 files, and this branch changes none of them, so git merged without a conflict: the tree takes each of main's files whole and keeps this branch's 24 files byte for byte. Two of main's changed files feed the fixture writers. microcosm.data.contract moves five SHA-256 literals (the UK gate battery's policy, gates manifest and spec fingerprint, and the release-cut part's two digests), and tools/build_us_fiscal_refresh_release.py rewords one entry of US_EXPORT_INPUT_MASS_REVIEWED_EXCLUSIONS. No golden reads either, so no fixture byte moves: tools/generate_release_contract_fixtures.py --check passes on the merged tree, with nothing regenerated. On the merged tree, one pytest process over this branch's five test files and main's release, loader, registry and releases-record tests gives 401 passed and 2 skipped (main's live-Hub test, which needs credentials), the counts the branch had before the merge. tools/ci_test_plan.py verify reports ok for 942 test files, and ruff passes on the Python files this branch changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
MaxGhenis
added a commit
that referenced
this pull request
Nov 12, 2026
Main 57a32f8 (#1579, #1553, #1311, #1583, #1584) changes two attested inputs: microcosm.fit.qrf, on the seed protocol's QRF kernel list, and sources.schema.json. #779 changes the immigration kernel, the US source stages and the same schema, so every US F0 digest the two sides pinned moved on both, and four files conflicted. Each conflicted pin was first replaced by a sentinel, and the repository's tools wrote every value from the merged tree: - packages/microcosm-build/src/microcosm/build/spec_engine/inventory_coverage.py: EXPECTED_HASHES seed_map, seed_protocol and source_manifest, from tools/repin_us_spec_engine_contracts.py (source_manifest comes out at the branch's value; main left it alone). The branch's seed groups and counts merged cleanly. - packages/microcosm-build/tests/engine_free/shared/test_spec_engine_loader.py: the minimal-loader golden, from the same repinner (it loads _rich_minimal through load_bundle exactly as the test does). - packages/microcosm-build/tests/engine_workflow/us/test_us_multispine_pool_tool.py: the US spec_sha256, from the same repinner (load_bundle("us")). - docs/evidence/spec-engine/us-f0-coverage.json: regenerated whole by tools/spec_engine_coverage.py (42781/42781 fields, 41/41 checks). The repinner ran twice around the coverage regeneration. Its first pass read the sentinels and wrote covered_item_count 39 into tests/engine_contract/us/test_spec_engine_coverage_tool.py; the second pass put it back to 41, so that file is unchanged from the branch. ruff format changed only quote style on the three Python files. No pin moved without a conflict: - repin_us_spec_engine_contracts.py --legacy-only wrote nothing (main does not touch us/source_stages.json). - tools/build_us_release_input_coverage_manifest.py rewrote us/release_input_coverage_manifest.json byte for byte. - Both repinner --check and spec_engine_coverage.py --check exit 0. The other four files both sides changed merged without conflict and are git's three-way result: sources.schema.json, tools/build_us_acs_local_release.py, tools/build_us_fiscal_refresh_release.py and tests/engine_free/us/test_us_acs_local_release_tool.py. tools/generate_us_bundle_from_constants.py --check was not run: it needs policyengine-us. Main changes no us/spec file and no tools/us_bundle_generation file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
added a commit
that referenced
this pull request
Nov 13, 2026
…1580) (#1582) The review of #1579's last commit found that the static walk's "What it can't see" entry for a hidden __all__ named two families (one a module sets as an attribute, one that globals(), locals(), vars() or exec sets) and left out a third: a store into a module's __dict__, such as src.__dict__["__all__"] = [] or sys.modules[__name__].__dict__["__all__"] = []. The walk misses that spelling the same way. Wording: the docstring entry in test_support/microcosm_build/static_reach.py and BLIND's comment block in static_reach_cases.py now say "sets as an attribute or through its ``__dict__``", the phrase #1580 records as agreed. Both paragraphs reflow. The walk's code doesn't change. Cases: two BLIND cases pin the spelling. Each copies its attribute-store sibling line for line, and only the store changes: - r_getattr_hidden_all_dict (modules ghd_*): another module runs ghd_src.__dict__["__all__"] = []. - r_getattr_self_set_all_dict (modules gssd_*): the module runs sys.modules[__name__].__dict__["__all__"] = []. Each has a TARGETS entry, a ROOTS entry that reaches nothing, and a BLIND entry for the target Python reads through the importer's __getattr__. OVER and DECOYS don't change. The counts move only by the additions (TARGETS 249 -> 251, ROOTS 212 -> 214, BLIND 27 -> 29). Checked outside the repository: - the walk reaches no target from either new root and reaches items only in the root and the star source, as for the siblings; - the cases' python_reads reads each BLIND target on CPython 3.14.7; - built as plain packages, both cases leave name out of the star import on 3.14.7 and 3.13.15, and a control without the store brings it in. Closes #1580. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Round D of the NZ static walk (#1567's follow-up): pins the four rules that the delta review of 04c8379 found no root pinned, and lists one more form in "What it can't see". Closes #1578.
Plan
names_all'sast.Nameclause (finding 1).r_getattr_maybe_star_all_walrus_defaultand_walrus_classstar-import a source that binds__getattr__through a walrus in a top-leveldef's default, or__all__through a walrus in aclass's bases, so the star import brings in nothing and the importer's__getattr__answers._Modulefiles thedeforclassunder its functions or classes, so only the clause sees the walrus.names_all'sdeclaredtest (finding 2).r_getattr_maybe_star_all_global_getterstar-imports a source whose function declaresglobal __getattr__and imports a getter under that name.sure_stars' top-level restriction (finding 3).r_getattr_maybe_star_skippedholds its star import underif False:, so the import brings in nothing and the getter answers.__all__thatsys.modules[__name__]sets. TheBLINDrootr_getattr_self_set_allpins it: Python reads the getter's target, and the walk counts the name as bound for sure."__all__" in declaredfailsr_getattr_maybe_star_all_global_getter, and counting every star import as sure failsr_getattr_maybe_star_skipped. With the 65e3e79 review's exact text, its two edits that log a pass as adding each fail 18 roots by the once check.NZ_CHRONICLE_ARTIFACTskip). D2 changes only wording and the order ofTARGETS, so the result carries over; CI runs the files at 352c1b5.Round D2 (352c1b5)
No code changes: the walk's AST without docstrings, and the cases' AST once
TARGETSis sorted, equal 00cee93's.static_reach.py, "What it can't see": the hidden-__all__entry now names one that a module, itself included, sets as an attribute (throughsys.modules[__name__], an import of itself orsetattr), and one thatglobals(),locals(),vars()orexecsets. The review found the self-import,sys.modules.get,import_module(__name__),vars()andlocals()spellings each blind in the same way as theBLINDroot. The wording is Belgium's.static_reach_cases.py:TARGETSis sorted again, andBLIND's comment block names an__all__that a module, itself included, sets as an attribute, which coversr_getattr_self_set_all.What changes
test_support/microcosm_build/static_reach_cases.py: five roots, five targets and 20 sources. No earlier root, source,OVERorBLINDentry changes, andrandom_treestays the same. The cases hold 212 roots, 249 targets, 14 inOVER, 27 inBLINDand eight decoys.test_support/microcosm_build/static_reach.py: one docstring entry (reworded again in D2). The walk's code doesn't change (its AST, docstrings removed, matches 4fe4132's).Shared with Belgium
Both files sit in Belgium's port's shared walk. Belgium OKs these hunks before this lands.
🤖 Generated with Claude Code