fix(data): drop the Welsh school GIAS does not type as Welsh #109

Merged
tudor merged 1 commits from fix/welsh-establishment-leak into main 2026-08-20 21:59:39 +00:00
Owner

Follow-up to #107. Verifying the staging sitemap count (25,189) turned up one Welsh school still standing.

Beechwood College, URN 142458, Sully, CF64 5SE. GIAS types it a Special post 16 institution (32) rather than a Welsh establishment (30), so filtering on establishment type alone left it behind. It was also why Vale of Glamorgan was still in the authority list on staging — 154 authorities where #107 predicted 153.

What went wrong in the original verification

#107 claimed the type codes mapped onto the Welsh authorities in both directions. That was checked exhaustively for Cardiff (144 of 144) and by count-matching for Swansea, Powys and Gwynedd. Vale of Glamorgan was never checked — and it was the one that did not hold.

The fix

LA code, not establishment type. GIAS gives the 22 Welsh unitary authorities the contiguous block 660-681, which English authorities never use (they occupy 201-384 and 800-938).

Not postcode. A postcode filter looks tempting and is wrong: Redbrook CofE, Tutshill CofE, Dean Close St John's, Wyedean School and Lift Offa's Mead are Gloucestershire schools carrying NP16/NP25 postcodes, because Royal Mail areas straddle the border. They are English schools with English performance data. A new e2e test pins three of them so this cannot be "simplified" into a postcode filter later.

How this is guarded

The 660-681 range is documented GIAS structure that this project cannot verify from its own data — local_authority_code is not exposed anywhere the app can assert on. So the range filters and the authority name checks: assert_england_only_schools now also fails if any of the 22 Welsh authority names survives in dim_location. If the range is ever wrong or incomplete, the pipeline fails loudly instead of the corpus quietly regrowing a Welsh tail.

The dbt test's authority list and the e2e WELSH_AUTHORITIES list were cross-checked programmatically and agree at 22 names.

Scan evidence

Paged all 25,186 staging schools and checked every postcode against the wholly-Welsh areas (CF, LL, NP, SA, LD). Six hits: five Gloucestershire border schools (correctly kept) and Beechwood College (the leak). No other Welsh school remains.

⚠️ Needs another staging Airflow run

Same as #107 — school_data_daily, then regenerate the sitemap, before the e2e gate.

🤖 Generated with Claude Code

https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj

Follow-up to #107. Verifying the staging sitemap count (25,189) turned up one Welsh school still standing. **Beechwood College**, URN 142458, Sully, CF64 5SE. GIAS types it a *Special post 16 institution* (32) rather than a *Welsh establishment* (30), so filtering on establishment type alone left it behind. It was also why **Vale of Glamorgan** was still in the authority list on staging — 154 authorities where #107 predicted 153. ## What went wrong in the original verification #107 claimed the type codes mapped onto the Welsh authorities in both directions. That was checked exhaustively for Cardiff (144 of 144) and by count-matching for Swansea, Powys and Gwynedd. Vale of Glamorgan was never checked — and it was the one that did not hold. ## The fix LA code, not establishment type. GIAS gives the 22 Welsh unitary authorities the contiguous block **660-681**, which English authorities never use (they occupy 201-384 and 800-938). **Not postcode.** A postcode filter looks tempting and is wrong: Redbrook CofE, Tutshill CofE, Dean Close St John's, Wyedean School and Lift Offa's Mead are Gloucestershire schools carrying NP16/NP25 postcodes, because Royal Mail areas straddle the border. They are English schools with English performance data. A new e2e test pins three of them so this cannot be "simplified" into a postcode filter later. ## How this is guarded The 660-681 range is documented GIAS structure that this project cannot verify from its own data — `local_authority_code` is not exposed anywhere the app can assert on. So **the range filters and the authority name checks**: `assert_england_only_schools` now also fails if any of the 22 Welsh authority names survives in `dim_location`. If the range is ever wrong or incomplete, the pipeline fails loudly instead of the corpus quietly regrowing a Welsh tail. The dbt test's authority list and the e2e `WELSH_AUTHORITIES` list were cross-checked programmatically and agree at 22 names. ## Scan evidence Paged all 25,186 staging schools and checked every postcode against the wholly-Welsh areas (CF, LL, NP, SA, LD). Six hits: five Gloucestershire border schools (correctly kept) and Beechwood College (the leak). No other Welsh school remains. ## ⚠️ Needs another staging Airflow run Same as #107 — `school_data_daily`, then regenerate the sitemap, before the e2e gate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj
tudor added 1 commit 2026-08-20 21:54:45 +00:00
fix(data): drop the Welsh school GIAS does not type as Welsh
PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m2s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 10s
PR Checks / Build Frontend (no push) (pull_request) Successful in 45s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 38s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 54s
3aad5101a8
Beechwood College (URN 142458, Sully, CF64 5SE) survived the England-only
filter. GIAS types it a Special post 16 institution (32), not a Welsh
establishment (30), so filtering on establishment type alone left it behind —
the last Welsh school on the site, and the reason Vale of Glamorgan was still
in the authority list.

The earlier verification claimed the type codes mapped onto the Welsh
authorities in both directions. That was checked exhaustively for Cardiff and
by count for three others; Vale of Glamorgan was never checked, and it was the
one that did not hold.

LA code is the reliable discriminator: GIAS gives the 22 Welsh unitary
authorities the contiguous block 660-681, which English authorities never use.
Filtering on postcode would have been wrong — Redbrook, Tutshill, Wyedean and
two other Gloucestershire schools carry NP16/NP25 postcodes because Royal Mail
areas straddle the border, and they are English schools with English data. An
e2e test now pins those five so the fix cannot be simplified into a postcode
filter later.

The 660-681 range is documented GIAS structure this project cannot verify from
its own data, so the range filters and the authority NAME checks: if the range
is ever wrong, a Welsh authority reappears in assert_england_only_schools and
the pipeline fails loudly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj

🤖 AI Code Review (Claude Code)

This PR extends the England-only corpus filter to also exclude Welsh schools by local authority code (660-681), fixing a gap where Beechwood College (GIAS-typed as 'Special post 16 institution' rather than 'Welsh establishment') slipped through the existing type-code filter. The fix is applied consistently to dim_location.sql and dim_school.sql, backed by a new dbt test asserting no Welsh-named authority reappears in the corpus, and covered by new Playwright e2e tests including a regression guard for English schools with Welsh-looking postcodes. The change is well-scoped, internally consistent (column types, API response shape, and filter logic all verified), and includes thoughtful documentation of why a postcode-based filter was rejected.

✅ No issues found.

## 🤖 AI Code Review (Claude Code) This PR extends the England-only corpus filter to also exclude Welsh schools by local authority code (660-681), fixing a gap where Beechwood College (GIAS-typed as 'Special post 16 institution' rather than 'Welsh establishment') slipped through the existing type-code filter. The fix is applied consistently to dim_location.sql and dim_school.sql, backed by a new dbt test asserting no Welsh-named authority reappears in the corpus, and covered by new Playwright e2e tests including a regression guard for English schools with Welsh-looking postcodes. The change is well-scoped, internally consistent (column types, API response shape, and filter logic all verified), and includes thoughtful documentation of why a postcode-based filter was rejected. ✅ No issues found.
tudor merged commit 8ad2070e76 into main 2026-08-20 21:59:39 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tudor/school_compare#109