Skip to content

Share one population-aggregate list and one known-period walker (Route A follow-up) - #1028

Merged
MaxGhenis merged 2 commits into
mainfrom
route-a/post-merge-followups
Sep 25, 2026
Merged

MaxGhenis merged 2 commits into
mainfrom
route-a/post-merge-followups

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to PR-4 (#1025) and PR-5 (#1024), as #1025's body promised. It also fixes one docs sentence left stale by #992. No behaviour change for either scoring path.

What changes

  • One list. US_POPULATION_AGGREGATE_VARIABLES is the single population-aggregate list. POST_EXPORT_POPULATION_AGGREGATE_VARIABLES, an identical tuple, is gone.
  • One walker. _engine_known_periods serves both batched target materialization and post-export scoring; _post_export_known_periods is gone.
    • The shared walker is the superset: it follows live branches, branches that target materialization records before they are detached, and a reform= engine's baseline.
    • Post-export scoring behaves exactly as before. policyengine-core sets baseline only when reform= is passed (simulation.py:247-253), and the scorer passes the reform's tax_benefit_system alone (_construct). So a post-export engine has no baseline to follow, and it never carries the recorded-branch list.
  • Both list-pinning scans are kept. They use different markers, so each is an independent drift detector for the one list.
  • Docs (docs/us-release-build-rule.md):

Invariant

For any graph of engines linked by live branches, recorded detached branches and baseline, cycles included, _engine_known_periods(root, watched) returns exactly the known (variable, str(period)) pairs of the watched variables in every engine reachable from the root.

A Hypothesis test (test_known_period_walker_matches_a_reference_traversal, 200 examples) checks this against an independent breadth-first walk. Dropping any one of the three links makes it fail, and each was tried.

Tests

  • test_us_post_export_scoring.py: 35 passed (fast), plus 3 slow real-engine tests. The walker property and the baseline-only refusal test also pass on the final head.
  • test_us_fiscal_refresh_builder.py: 313 passed, 2 skipped.
  • test_target_materialization.py: 46 passed.
  • test_us_batched_target_materialization.py: 41 passed, including the new baseline-only refusal test, which fails when the walker's baseline step is removed.
  • ruff check, ruff format --check and tools/ci_test_groups.py --verify are clean.
  • The walker property test imports Hypothesis with pytest.importorskip. The wheels CI job installs no test extras and skips it; with a stub hypothesis that raises ImportError, the file still collects.

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits September 25, 2026 10:16
PR-4 (post-export scoring) and PR-5 (batched target materialization)
each defined the same four-variable population-aggregate list and a
walker over an engine's known periods. They now share
US_POPULATION_AGGREGATE_VARIABLES and _engine_known_periods.

The shared walker is the superset: live branches, the branches target
materialization records before they are detached, and a reform= engine's
baseline. policyengine-core sets baseline only when reform= is passed
(simulation.py:247-253), and the post-export scorer passes the reform's
tax_benefit_system alone, so post-export scoring behaves exactly as
before. Both list-pinning scans are kept; they use different markers.

Tests:
- The known-period walker returns exactly what an independent
  breadth-first walk over random engine graphs (cycles allowed) finds.
  Dropping any of its three links fails the test.
- Both refusal paths see a value held only on baseline.

The docs now say an assembled table needs a complete, non-null
<entity>_source_id (#992 round 8) and name the shared list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wheels CI job installs the built packages into a clean venv without
test extras, so a module-level Hypothesis import failed collection of
the whole post-export test file. The property test now imports it with
pytest.importorskip: the workspace jobs (uv sync --all-packages, which
brings Hypothesis through microcosm-graph) still run it, and an
environment without it skips just that test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis merged commit 3131568 into main Sep 25, 2026
23 checks passed
@MaxGhenis
MaxGhenis deleted the route-a/post-merge-followups branch September 25, 2026 15:35
MaxGhenis added a commit that referenced this pull request Sep 26, 2026
Brings in the 19 main merges since 6442030: the Route A remediation stack
(#1016, #1018, #1017, #1025, #1024, #1028), #1029, #1005, #1008, #1004, #992,
#1031, #1015, #1033, #994, #954, #966, #1006 and #1010.

Eight conflicted paths, each recorded in docs/native-integration-20260923.md:
- test.yml keeps the native sharded matrix (main's --durations=25 is already
  in every native pytest call);
- the us_runtime facade stays lazy and gains main's three fiscal-target
  exclusion exports (the parent union, 920 names; the facade-union test is
  re-pinned to that union's digest);
- reform_validation.py keeps main's _released_engine_state and the native
  explicit-constructor default_simulate_factory;
- build_us_fiscal_refresh_release.py carries the native explicit consumer
  seams (formula metadata, dataset and microsimulation constructors, SPM
  selection) onto main's household-batched post-export scorer and batched
  base materialization; omitted seams keep main's exact calls, and _main
  supplies none. Three native test files that addressed the removed
  frame-based factory now address the scorer with the same assertions;
- identity pins observed on the merged tree: five EXPECTED_HASHES entries,
  the regenerated F0 coverage report (42,239/42,239 fields, 41/41 checks),
  the US spec identity 2dfa51b8... and the loader golden f2047cb9...

tools/generate_us_bundle_from_constants.py --check, tools/ci_test_groups.py
--verify, the CI matrix contract and ruff pass. The fiscal consumer,
formula-metadata, shared target/solve and calibration-attachment files pass;
the rest of the fiscal battery and the known pre-existing failures are
follow-up work on this branch.

No actual-data native run, release certification or publication.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant