Repository navigation
Record the UK area codes disclosure control withholds from a report run - #4305
Merged
Merged
Conversation
…ing) The Modal worker records each UK area disclosure control withheld from a report run in withheld_area_codes, keyed by the run and its two simulation runs, with a v2_uk_area_type enum; the Public API reads them. The revision is generated and its downgrade also drops the enum type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
withheld_area_codes holds one row per constituency or local authority a local-area run withheld, keyed by the report run and its two simulation runs, with the area type as the new v2_uk_area_type enum. The revision is generated, with one documented correction: its downgrade also drops the enum type. The Modal worker role reads and inserts the rows and the Public API's runtime role reads them; the deploy's existing reconcile step grants both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check every managed role's access in the role test, say when an empty list means no area was withheld, stop pinning the head in the revision's own test, and list the table among the simulation side's tables in the simulation runs revision's test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say that an empty list means no area was withheld only for a succeeded run whose writer records it, that the writer, not a constraint, keeps withheld areas out of the area tables, and check that the catalog writer can't read the rows either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 3's quality findings: the writer, not the row, leaves a withheld area out of the area tables, and the database can't tell a run whose writer records the list from one whose writer doesn't. Rewrap the skill entry's paragraph. 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 #4305 +/- ##
==========================================
- Coverage 93.47% 93.45% -0.02%
==========================================
Files 369 369
Lines 21442 21455 +13
Branches 3400 3400
==========================================
+ Hits 20043 20051 +8
- Misses 816 822 +6
+ Partials 583 582 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anth-volk
marked this pull request as ready for review
November 13, 2026 22:22
anth-volk
added a commit
to PolicyEngine/policyengine-sim-api
that referenced
this pull request
Nov 13, 2026
ca4d396e merges PolicyEngine/policyengine-api#4305, whose revision 1e1e3f079f2c adds the withheld_area_codes table that Stage 12 writes a local-area report run's withheld codes to. Since the previous pin it adds no other migration and changes no table sim's persistence models describe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #4304
Summary
withheld_area_codes: one row per UK constituency or local authority that disclosure control withheld from a report run's local-area results. Columns:id,created_at,report_run_id(deleted with the report run),baseline_simulation_run_idandreform_simulation_run_id(RESTRICT, as the other comparison result tables have),area_type(a new native enumv2_uk_area_type:constituency,local_authority) andcode(varchar(64)), unique on (report_run_id,area_type,code). A report run's ORM relationship deletes its rows with it.1e1e3f079f2c, autogenerated (with--rev-id) on0c136a278f29. Its one correction after generation is for reversibility: the downgrade also dropsv2_uk_area_type, which Alembic's generated downgrade leaves behind, as439303be14fedoes for its enums. The upgrade only creates the type and the table, so it writes no data, and the previous revision of the Public API, which doesn't map the table, keeps working. The downgrade drops the table with its rows.V2_ALEMBIC_HEAD_REVISIONmoves to it, and the Alembic skill's list of revisions describes it.SELECT, INSERTand the runtime roleSELECT; the simulation service, Stage 12 and catalog writer roles get nothing. The deploy's existing steps (seed-v2-database.yml, frompush.yml) upgrade the schema and then runreconcile_v2_privileges.py applyandverify, so no deploy step, secret or environment variable changes.The schema follows the local-area design's decision 7 (a new
withheld_area_codestable, in the design's section 4.3 shape). The earlier plan'sreports.parent_report_idis dropped: the design replaced it (decision 6) with ordinary national and local-area reports linked by a key, which a separate change adds.Two other open PRs add v2 revisions on the same parent
0c136a278f29: #4303 and #4297. Whichever merges later moves itsdown_revisiononto the new head and updates the tests that pin the chain (V2_ALEMBIC_HEAD_REVISION, the revision chain intest_alembic_v2, the table count intest_import_side_effects, and the post-baseline table set).Testing
2150a603f, failing), then the change. Unit: the model's columns, enum, unique key and relationship; the manifest's table sets; the revision chain and the revision's contents (generated, one enum drop); the CI lifecycle script listing the new integration module; the v2 table count.tests/integration/test_alembic_v2_withheld_area_codes.py, run by.github/scripts/test_alembic_v2_lifecycle.sh): the revision adds only the table and the type and changes no other table; the downgrade removes both and upgrading again works; a repeated (run, type, code) and an unknown area type are refused; a simulation run that withheld codes name can't be deleted; deleting the report run deletes its codes.test_v2_simulation_role_privileges): the Modal worker inserts and reads rows and can't update or delete them; the runtime role reads them and can't insert; the simulation service, Stage 12 and catalog writer roles can't read them.alembic -c alembic-v2.ini check; a downgrade to base and an upgrade to head;reconcile_v2_privileges.py apply --create-missing-rolesandverify;make quality(through the commit hook);python -m scripts.rules validate; the changelog fragment check.🤖 Generated with Claude Code