Skip to content

Export CountryTaxBenefitSystem so the Core CLI can load the NZ model - #36

Merged
MaxGhenis merged 1 commit into
mainfrom
nzhub/issue-15
Dec 3, 2026
Merged

MaxGhenis merged 1 commit into
mainfrom
nzhub/issue-15

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude Code built this pull request for Max Ghenis, and Antigravity harvested the review.

Fixes #15.

What changes

policyengine_nz/system.py defines CountryTaxBenefitSystem as an alias of NewZealandTaxBenefitSystem, but the package never exported it. policyengine-core's CLI looks for that attribute on the package: build_tax_benefit_system raises ImportError without it, and detect_country_package skips the package (policyengine_core/scripts/__init__.py:53–61 and line 81, in Core 3.20.0 and 3.38.0). This PR imports the alias in policyengine_nz/__init__.py, lists it in __all__, and adds policyengine_nz/tests/test_package_exports.py, which checks the attribute, the __all__ entry and that build_tax_benefit_system("policyengine_nz", None, None) returns a NewZealandTaxBenefitSystem. No parameter or variable changes, so no computed value moves.

Tests

  • The three new tests pass on Core 3.20.0 (main's pin) and on Core 3.38.0 (Require policyengine-core 3.38.0 #35's pin), and all three fail with main's __init__.py.
  • I ran Core's parser and handler in-process with test policyengine_nz/tests/policy -c policyengine_nz; it raised ImportError with no items collected on both Cores before the change. After it, the run collected and passed 361 items, and 223 with PYTEST_ADDOPTS=--noconftest, on both Cores. The repo's conftest.py registers a second plugin, so the default run collects each of the 138 YAML cases twice.
  • The full suite on Core 3.20.0 gives 1,796 passed and 1 skipped. On Core 3.38.0, 24 tests fail with or without this change; Require policyengine-core 3.38.0 #35 adapts them to that version.
  • ruff format --check . with ruff 0.15.5 passes in CI.

Follow-ups

  • A CI step could run the Core CLI with PYTEST_ADDOPTS=--noconftest, so each YAML case runs once on that path.
  • The household API and the API v2 simulation executor also read package.Simulation, which the package does not export.
  • PolicyEngine/policyengine-core#681 tracks detect_country_package() selecting packages that lack DATASETS in scripts/run_data.py or Microsimulation in tools/dependency_map.py.

axiom: no RuleSpec change (package export and test)

Claude Code and Antigravity prepared this pull request for Max Ghenis.

policyengine-core's CLI loads a country through
`package.CountryTaxBenefitSystem`, which policyengine_nz defined in
system.py but never exported. Export it, list it in __all__, and test
that Core's build_tax_benefit_system loads the NZ system.

Fixes #15

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

Copy link
Copy Markdown
Contributor Author

Round 1 independent review of 3550561ddd9539e4998ed52a3c6e82be3801ba9b finished (Subfleet job 20261203-001739-nzhub-rev-pe-nz-36-r1, codex-2, gpt-6.2-sol, hard tier; saved at ~/reviews/nz-hub/notes/reviews/pe-nz-36-r1-20261203-001739.md).

  • The reviewer confirmed all three new tests fail on main's __init__.py and pass on 3550561d, build_tax_benefit_system("policyengine_nz", None, None) returns NewZealandTaxBenefitSystem, policyengine-core test policyengine_nz/tests/policy -c policyengine_nz collects and passes 361 items (223 with --noconftest) on both Core 3.20.0 and 3.38.0, and the full Core 3.20.0 suite passes 1,796 tests (1 skipped).
  • The reviewer's VERDICT: REQUEST_CHANGES line cited one P1 (policyengine_core/scripts/run_data.py reading .DATASETS) and one P2 (policyengine_core/tools/dependency_map.py reading .Microsimulation in microdata/both modes). Both are in PolicyEngine/policyengine-core code that this PR does not touch (policyengine_us and policyengine_uk also export CountryTaxBenefitSystem without DATASETS, and policyengine_nz defines no datasets or Microsimulation yet). Under pr-lifecycle.md, those findings are scope creep rather than merge blockers, and I routed them to Implicit country discovery selects packages lacking DATASETS or Microsimulation policyengine-core#681 and the US + core hub.
  • I fixed the P3 passive-wording items in the PR description and added PolicyEngine/policyengine-core#681 to Follow-ups.

All 11 CI checks passed on 3550561ddd9539e4998ed52a3c6e82be3801ba9b, mergeable is MERGEABLE, and the review raised no in-scope finding above P3. Merging on gates.

@MaxGhenis
MaxGhenis marked this pull request as ready for review December 3, 2026 12:53
@MaxGhenis
MaxGhenis merged commit 5b3aaa3 into main Dec 3, 2026
11 checks passed
@MaxGhenis
MaxGhenis deleted the nzhub/issue-15 branch December 3, 2026 12:53
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.

Missing package-level CountryTaxBenefitSystem breaks the policyengine-core CLI

1 participant