Repository navigation
Conversation
The US household years no longer fall back to the US society-wide years. certified_spm_forecast_years() now raises SPMValidationError (SPM_CONFIGURATION_UNAVAILABLE) when the bundle certifies no SPM forecast or the certified one fails to load, so building the US metadata fails with that error instead of offering other years. build_household_options() no longer copies the society-wide years for a country other than the US and the UK; it raises ValueError for any country the Public API does not serve, and no longer takes economy_options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4166 +/- ##
===========================================
+ Coverage 53.29% 88.22% +34.93%
===========================================
Files 276 288 +12
Lines 15936 17130 +1194
Branches 2579 2812 +233
===========================================
+ Hits 8493 15113 +6620
+ Misses 6730 1315 -5415
+ Partials 713 702 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was previously deployed
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.
Tracking issue: none yet.
Summary
Removes the two fallbacks in the household year list (
household_options.time_period) that #4159 added to/{country}/metadata.economy_options.time_period) with a logged warning.certified_spm_forecast_years()now raisesSPMValidationErrorwith codeSPM_CONFIGURATION_UNAVAILABLEinstead of returningNone, andbuild_household_options()no longer catches anything. Building the US metadata therefore fails with that error, and no other years are offered.build_household_options()copied such a country's society-wide years. That code is gone: the method builds years forusandukonly and raisesValueErrorfor any other country. It no longer takeseconomy_options, which only the fallbacks used.The US society-wide years are about to be narrowed to start at 2024. With fallback 1 in place, a missing forecast would then have silently removed US household 2022 and 2023.
The served US and UK years, the response shape and
economy_optionsare unchanged. With the locked packages the US household years are still 2035 to 2022, newest first, and the UK years still followuk_economy_years.Behaviour when the certified forecast is missing
The SPM code already treats a missing certified forecast as follows:
spm_metadata("us")reports{"available": false}.normalize_spm_selectionraisesSPM_CONFIGURATION_UNAVAILABLE. The readiness check (/health) then answers 503, which stops the staging deploy's health check, and every US request fails with that code.measurements.spm),normalize_spm_selectionreturnsNoneand SPM runs as it did before canonical SPM.certified_spm_forecast_years()now raisesSPM_CONFIGURATION_UNAVAILABLEin every case in whichspm_metadatareports SPM as unavailable, the older-bundle case included. The message names the cause, for exampleThe certified US SPM forecast is unavailable: The installed bundle has no certified SPM measurement configuration.The metadata is built when
policyengine_api.countryis imported, so this error stops the Public API from starting. Before choosing this, I checked that no configuration that starts the Public API today lacks a certified forecast that loads:policyengine==6.12.0pinsmeasurements.spm(forecast hash3d86d5c4…, scenarioce_trend).spm_calculator.rolling_forecast.load_forecastreads that forecast from thespm-calculator==1.0.0wheel and never downloads it. Bothpolicyengine-us==2.2.1andpolicyengine[models]depend onspm-calculator, so every install fromuv.lockhas it.uv.lock. In that environmentcertified_spm_forecast_years()returns 2022 to 2035. Tests that patch the bundle to an uncertified one do so afterCOUNTRIESis built and never rebuild the US metadata. The Public API cannot start without the bundle at all:policyengine_api.constantsraisesRuntimeErrorwhen the manifest is missing.gcp/cloud_run/Dockerfilewithuv sync --frozen --no-dev. Production/us/metadatareportsspm.available: truewith the same forecast hash; it does not servehousehold_optionsyet. Staging was not queried directly. It runs the same image, and its deploy already requires/health, which already fails when the certified SPM configuration cannot be resolved.A future bundle without a usable certified forecast now stops the Public API from starting instead of serving a substitute list. The pull request that installs such a bundle would also fail CI, because the tests import
policyengine_api.country.Other changes
supported_countriesdocstring lists a household year rule among the things a new country needs.changelog.d/household-year-fallbacks.changed.md.Tests
The tests that covered the removed fallbacks are replaced:
tests/unit/test_household_options.py::test_us_household_years_fail_without_a_certified_forecast: no certified forecast with an older US model, no certified forecast with a canonical-SPM US model, and a certified forecast that fails to load. Each raisesSPM_CONFIGURATION_UNAVAILABLE.tests/unit/test_household_options.py::test_a_country_the_public_api_does_not_serve_has_no_household_yearstests/unit/test_spm_settings.py::test_certified_forecast_years_raise_without_a_certified_forecasttests/unit/test_spm_settings.py::test_certified_forecast_years_raise_when_the_forecast_cannot_loadThese seven cases were run by node ID and pass.
ruff formatandruff checkpass on the changed files,scripts/run_quality_guards.pypasses, and.github/scripts/check_changelog_fragment.shfinds the fragment. The full test suite was not run locally; CI runs it.🤖 Generated with Claude Code