Repository navigation
Conversation
LocalAreaBreakdownOutput gains constituency_withheld_codes and local_authority_withheld_codes, each list[str] | None defaulting to None: the sorted ONS codes of that level's areas that the run estimated but disclosure control did not publish. An empty list means none were withheld; None means the result does not report them, so results from older executors still validate. The gateway's golden OpenAPI, the entrypoint's OpenAPI test and the gateway README describe the fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the fields defaulting to None, an executor that does not fill them dumped both keys as null. A gateway deployed before the fields existed forbids unknown keys, so it would report such a breakdown as failed if the executor were redeployed first. Both fields now use field-level exclude_if, so a None list is left out of every dump while [] is kept. The contract requires pydantic 2.12, the first release with exclude_if; every lock already resolves 2.13, and the five locks that include the contract record only the new requirement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngelog Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
added a commit
that referenced
this pull request
Oct 28, 2026
The contract and gateway change, with its own changelog entry, moved to #976, which deploys first. This entry now describes only the executor filling the two lists and the stricter beta check, and sits beside the local-area breakdown entry so that merging main later does not touch the same text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been 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.
Fixes #977
Part of #968.
What changes
With this change, the contract and the gateway accept a UK local-area breakdown result (
kind: local_areas) with or without two new optional fields. No executor sends them yet: #975 makes the executor fill them, and it merges only after this PR is merged and deployed.constituency_withheld_codeslist[str] | None, defaultNonelocal_authority_withheld_codeslist[str] | None, defaultNone[]means that no area of the level was withheld.Nonemeans that the result does not report them. Results without the fields still validate, and their JSON leaves both keys out rather than writingnull.Why an unreported list is left out of the JSON
In
simulation-deploy.yml, a push tomainruns thebetajob and then theprodjob. Each one callssimulation-deploy.reusable.yml, where:deploy_executor("Deploy and unit test Modal executor") redeploys the versioned executor app for the pinned .py version,policyengine-simulation-py6-10-0, under the same name, then runs the executor's unit tests.deploy_gateway("Deploy and unit test Modal gateway") needsdeploy_executor. It then redeploys the stable gateway app,policyengine-simulation-gateway.update_routingneeds both, andintegrationruns after it.Both Modal images mount the contract from the checkout (
add_local_python_source(..., "policyengine_simulation_contract", ...)). So a merge of this PR redeploys the 6.10.0 executor with the new contract while the old gateway is still serving, and the old gateway's contract forbids unknown keys.With the fields as plain
= Nonedefaults, the executor's breakdown output (LocalAreaBreakdownBuilder.serialize, which callsmodel_dump(mode="json")) wrote both keys asnull. The executor's existingtest_a_local_area_breakdown_publishes_both_levels_from_one_releasefailed on the first commit alone for that reason, and the old gateway would have reported such a breakdown job as failed.Both fields now use field-level
exclude_if, as #919 does forxandy. ANonelist is left out of every dump, while[]is kept. Until #975 deploys, the executor's breakdown output carries the same keys as before, so the old gateway accepts it. Once this PR's gateway is deployed, it accepts the fields too.Commits
762f2c6fAdd optional withheld-area code lists to the local-area breakdown result. This is Fill the withheld-area code lists in UK local-area breakdown results #975's first commit: the two fields, the gateway's golden OpenAPI, the gateway README's table of breakdown fields, and an entrypoint OpenAPI test. Seen failing first: the contract tests (extra_forbiddenon the new keys) and the entrypoint test (KeyError: 'constituency_withheld_codes').c9b3a89aLeave unreported withheld-code lists out of breakdown result JSON. Addsexclude_ifto both fields. The contract now requires pydantic 2.12 or later, the first release withexclude_if. Every lock already resolves 2.13, and the five locks that include the contract record only the new requirement. Seen failing first: two new contract tests, which foundNonefor both keys in the dump, and the executor's breakdown test above.f78fb6b3Merge origin/main. Brings in Record when each policyengine.py route was published and latest changed #961 and Pass is_tax through to detailed_budget #972, which also change the contract and the golden OpenAPI. The golden still equals the generated document.b4d1f32aDescribe the withheld-code fields the contract now accepts in the changelog. Documentation only.Order with #975
#975 keeps the executor commits and must not merge until this PR is merged and deployed. After this PR merges,
maingets merged into #975, so its diff then shows only the executor commits.Overlap with #919
#919 makes the same
pydantic>=2.12change and adds its own_is_nonehelper tomacro_output.py. Whichever PR merges second resolves the text conflict and keeps one helper.Checks run
test_local_area_breakdown.py,test_gateway_models.pyandtest_macro_output_uk_geography.py;test_openapi.py;test_openapi_golden.py,test_local_area_breakdown.pyandtest_endpoints.py;test_simulation_output_uk_local_areas.py,test_simulation_output_geographic.py,test_simulation_output_impacts.py,test_simulation_api_contracts.pyandtest_runtime_evaluated_annotations.py;test_calculate.pywithout thebeta_onlytests, against a client regenerated with./scripts/generate-clients.sh.uv lock --checkwith uv 0.13.6 passes in each package whose lock changed.make checkpasses: ruff format and lint, and Pyright in every package, with no errors.python scripts/run_quality_guards.pywithGITHUB_BASE_REF=mainpasses every guard.Known check failure
The
PR descriptioncheck requires the first line to beFixes #ISSUE_NUMBER. This description starts withPart of #968on purpose, because #975 is the PR that fixes #968, so that check fails here.The work was done red-green: each behaviour change's tests were written first and seen failing for the expected reason, then the code was written, and both were committed together.
🤖 Generated with Claude Code