Skip to content

Disclosure release: area codes that don't match skip the nesting and prior-public checks without an error #625

Open

Description

@vahid-ahmadi

What's wrong

The release check matches areas by their code strings, and two inputs are never checked against the areas the release holds. A mismatch does not raise: the check simply finds nothing to check.

  1. parent_of values are not validated. For a weight-matrix level, Release._groups (src/policyengine/disclosure/release.py:337-346) checks that every child area has an entry in parent_of, but not that the entry is one of the parent level's area codes. If it isn't, every parent group comes out empty and the nesting check passes with no finding.
  2. Prior publications are not validated. _known_cells (release.py:269-277) and _check_prior (release.py:805-819) use PriorPublic.cells as given. A prior cell whose area code matches no area of that level is silently ignored, so a region the release withholds but an earlier publication showed is treated as still hidden, and the "already public" finding never fires.
  3. UK region codes differ by dataset. The adapter keys regions on region_code_oa when present, else region (src/policyengine/outputs/uk_geography_disclosure.py:36-40). On the Microcosm local file that is a GSS code (E12000007); on a national file it is the engine enum (LONDON). The Autumn Budget dashboard's constituencies_2024.csv uses a third spelling (London, Eastern). So regional results published from the national dataset, passed as prior_public to a seat release from the local file, match nothing, and a seat-to-region map built from the dashboard's CSV matches nothing.

This is exactly the Budget plan in PolicyEngine/uk-autumn-budget-dashboard-2026#24: regions first from the national dataset, then seats from the local file or the eFRS matrix.

Evidence

Synthetic probe (no survey data): 400 records in two regions, a 4 × 400 seat matrix, one seat withheld because three records carry it.

  • parent_of with the region level's own codes: the seat is withheld and the check returns three blocking recoverable_remainder findings (the withheld seat is its region minus the other seat).
  • The same release with parent_of naming the regions differently: the seat is still withheld, and the check returns no findings.

Proposed fix

  • In _groups, raise DisclosureError when any parent_of value is not in parent.areas.area_codes.
  • In Release.__init__ or check(), raise (or return a blocking finding) for any prior_public cell whose level is in the release but whose area code is not an area of that level.
  • In the UK adapter, normalise region codes to one scheme (GSS, as Microcosm writes) whether they come from region_code_oa or region, and document it so publishers use the same codes in prior_public and parent_of.
  • Add the probe above as a test.

Priority

High. Before any seat-level release that follows a published regional release (about 24 October), and ideally before the regional release on about 20 October, so its codes are the ones later releases will match.

Related: #589, #605, PolicyEngine/uk-autumn-budget-dashboard-2026#24, PolicyEngine/microcosm#1241.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions