Skip to content

Relax manifest check + bump country-model pins to 3.9-compatible releases#282

Merged
MaxGhenis merged 8 commits intomainfrom
relax-manifest-check
Apr 18, 2026
Merged

Relax manifest check + bump country-model pins to 3.9-compatible releases#282
MaxGhenis merged 8 commits intomainfrom
relax-manifest-check

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

@MaxGhenis MaxGhenis commented Apr 17, 2026

Summary

Two related changes to unblock pypkg's post-merge publish pipeline and prevent this class of breakage from recurring:

1. Relax UKTaxBenefitModel / USTaxBenefitModel manifest check from ValueError to UserWarning

Previously both models raised ValueError on any mismatch between the bundled manifest's pinned model version and the installed policyengine-uk / policyengine-us version. That made every routine country-model patch bump require a coordinated pypkg manifest update, and when downstream core tightened its parameter validation (core 3.24.0's strict breakdown validator), every post-merge pypkg publish broke at import time because the stale pins in pypkg's extras couldn't install cleanly against modern core.

Calculations now run against whatever country-model version is installed. Dataset compatibility is still advertised via model.release_manifest; downstream code that cares about exact pinning can inspect it.

2. Bump the pinned country-model versions to 3.9-compatible releases

  • policyengine-us==1.602.0==1.647.0 (first release with 3.9 support + breakdown fixes)
  • policyengine-uk==2.74.0==2.88.0 (first release with 3.9 support)
  • policyengine_core>=3.23.6>=3.24.2 (includes _fast_cache + assert_near fixes)
  • Manifest JSON files + related test assertions updated to match

Without the relaxation in (1), this bump would fail old pins; without (2), the pipeline still can't install modern core. Together they land clean.

Supersedes

Closes #280 (this is #280 + the manifest-warning change from #282 merged into one PR).

Test plan

MaxGhenis and others added 5 commits April 17, 2026 19:59
`UKTaxBenefitModel.__init__` / `USTaxBenefitModel.__init__` previously
raised `ValueError` on any mismatch between the bundled manifest's
pinned model version and the installed `policyengine-uk` /
`policyengine-us` version. That made every routine country-model
patch bump require a coordinated pypkg manifest update, and when
downstream core tightened its parameter validation (core 3.24.0's
strict breakdown validator), every post-merge pypkg publish broke
at import time because the stale pins in pypkg's extras couldn't
install against modern core.

Swap the `ValueError` for a `UserWarning`. Calculations now run
against whatever country-model version is installed; dataset
compatibility is still advertised via `model.release_manifest`,
and downstream code that cares about exact pinning can inspect it.

Adds a regression test verifying both models emit a UserWarning
instead of raising on a version drift.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- `policyengine-us==1.602.0` -> `1.647.0` (first version with 3.9
  support + breakdown fixes)
- `policyengine-uk==2.74.0` -> `2.88.0` (first version with 3.9
  support)
- `policyengine_core>=3.23.6` -> `>=3.24.1` (includes ParameterScale
  fix)

The stale `1.602.0` and `2.74.0` pins no longer install cleanly under
modern `policyengine-core` because the strict breakdown validator
added in core 3.24.0 rejects the older country-model parameter data.
The post-merge push workflow for #278 surfaced this as the first
test failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Follow-up to the pyproject.toml pin bump in this PR. The
`src/policyengine/data/release_manifests/{us,uk}.json` bundled
manifests carry `model_package.version` / `built_with_model_version`
/ `certified_for_model_version` fields that are exact-matched against
the installed country-model version at `UKTaxBenefitModel.__init__`
(and equivalent in us). Bumping the pyproject pins without also
bumping the manifests would make the exact-match check fail at
import time:

  ValueError: Installed policyengine-uk version does not match the
  bundled policyengine.py manifest. Expected 2.74.0, got 2.88.0.

Bump the us manifest to `1.647.0` and the uk manifest to `2.88.0`
to match the new extra pins. Data-package versions (`us-data 1.73.0`,
`uk-data 1.40.4`) are unchanged — the bumped country-model releases
read the same dataset artefacts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tests/test_models.py and tests/test_release_manifests.py had exact-string
assertions on the bundled manifest version / bundle_id fields. Now that
those manifest values are bumped to match the new pins
(us 1.647.0, uk 2.88.0, bundle_id N.N.6), update the matching
assertions.

Remaining occurrences of "1.602.0" in tests/test_release_manifests.py
are inside test-local fixtures that construct their own synthetic
manifests; they don't reflect the bundled manifest and don't need to
be bumped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The `bundle_id` / `policyengine_version` fields track the
policyengine.py package version itself, not the bundled country-model
versions. Bumping them to 3.4.6 broke downstream tests
(`test__given_manifest_certification__then_release_bundle_exposes_it`
and friends) that assert against the live pypkg version. Restore
them to `3.4.0` — only the country-model version fields
(`model_package.version`, `built_with_model_version`,
`certified_for_model_version`) should change in this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MaxGhenis MaxGhenis changed the title Relax manifest-vs-installed check to UserWarning Relax manifest check + bump country-model pins to 3.9-compatible releases Apr 18, 2026
MaxGhenis and others added 3 commits April 17, 2026 20:11
UKTaxBenefitModel / USTaxBenefitModel don't exist — the concrete
classes are PolicyEngineUKLatest / PolicyEngineUSLatest, which is
where the __init__ with the manifest check lives.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previous version fully instantiated PolicyEngineUKLatest /
PolicyEngineUSLatest, but their __init__ chains into
certify_data_release_compatibility which hits Hugging Face.
Without HUGGING_FACE_TOKEN env, instantiation fails before the
version-warn branch is exercised.

Rewrite the test to patch the network-dependent downstream calls
(certify_data_release_compatibility, _get_runtime_data_build_metadata,
TaxBenefitModelVersion.__init__) so only the version-check branch
runs. Any downstream exceptions are caught since by then the
warning has already been emitted (or the raise has already fired,
which would fail the test correctly).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
test__given_manifest_certification__then_release_bundle_exposes_it asserted
  data_build_model_version == 2.74.0 — bump to 2.88.0 (uk manifest pin).

test__given_private_manifest_unavailable__then_bundled_certification_is_used
  passed runtime_model_version="1.602.0", which no longer matches the
  bundled us manifest's certified_for_model_version (1.647.0). Bump
  to 1.647.0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit 368e2cd into main Apr 18, 2026
11 checks passed
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