Skip to content

NZ walk: pin four rules the review of 04c8379fd found unpinned (#1578) - #1579

Merged
MaxGhenis merged 2 commits into
mainfrom
nzhub/g8x2d-pins
Nov 11, 2026
Merged

MaxGhenis merged 2 commits into
mainfrom
nzhub/g8x2d-pins

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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'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, so the star import brings in nothing and the importer's __getattr__ answers. _Module files the def or class under its functions or classes, so only the clause sees the walrus.
  • 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.
  • 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 and the getter answers.
  • "What it can't see" (finding 4) lists an __all__ that sys.modules[__name__] sets. The BLIND root r_getattr_self_set_all pins it: Python reads the getter's target, and the walk counts the name as bound for sure.
  • Checks outside pytest, on CPython 3.14.7 and 3.13.15: 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.
  • The composing property on every pair of the 212 roots (22,366 pairs), seeded draws and the composite of all 212: 0 walk failures and 0 Python mismatches on 3.14.7 (2,000 draws, the hub's run) and on 3.13 and 3.14 (3,000 draws, Belgium's run at 00cee93).
  • Local run of the three test files that exercise the walk, at 00cee93 (Belgium's run): 1,765 passed and 1 skipped (the NZ_CHRONICLE_ARTIFACT skip). D2 changes only wording and the order of TARGETS, so the result carries over; CI runs the files at 352c1b5.
  • Belgium's OK on both shared files at 352c1b5 (static_reach.py sha256 77fbbe41…, static_reach_cases.py 2f59c025…).
  • Independent delta review of 4fe4132..00cee93: APPROVE, no required findings. D2 takes its optional findings 1-3; finding 4 (a 95-character line in 00cee93's message) goes in the squash message.

Round D2 (352c1b5)

No code changes: the walk's AST without docstrings, and the cases' AST once TARGETS is 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. The wording is Belgium's.
  • static_reach_cases.py: TARGETS is sorted again, 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 D2 files: all 212 roots pass the walk and Python's reads on 3.14 and 3.13.

What changes

  • test_support/microcosm_build/static_reach_cases.py: five roots, five targets and 20 sources. No earlier root, source, OVER or BLIND entry changes, and random_tree stays the same. The cases hold 212 roots, 249 targets, 14 in OVER, 27 in BLIND and 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

MaxGhenis and others added 2 commits November 11, 2026 10:28
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
MaxGhenis marked this pull request as ready for review November 11, 2026 19:49
@MaxGhenis
MaxGhenis merged commit 83b1a34 into main Nov 11, 2026
12 checks passed
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Merged by the NZ hub (session local_e407a527) at 352c1b5 with --squash. Gates: gh pr checks exit 0 and every check pass or skipping (green: buckets: pass=12); MERGEABLE; not draft; no CHANGES_REQUESTED review. Reviewed head: 352c1b5. NZ hub landing. Reviews: independent delta review of 4fe4132..00cee93 APPROVE (no required findings); independent delta review of 00cee93..352c1b5 APPROVE (no code change; one optional docstring note, tracked as a follow-up issue). Belgium OK'd both shared walk files at 352c1b5 (static_reach.py 77fbbe41, static_reach_cases.py 2f59c025). CI: 12 checks pass on 352c1b5 (read 19:49Z).

@MaxGhenis
MaxGhenis deleted the nzhub/g8x2d-pins branch November 11, 2026 19:50
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NZ walk: pin four rules the review of 04c8379fd found unpinned (#1567 follow-up)

1 participant