From 83dc5ae5dce9c5f89e5e1e27ccd2a5a49c568088 Mon Sep 17 00:00:00 2001 From: Tudor Date: Tue, 22 Sep 2026 06:41:59 +0100 Subject: [PATCH] docs: correct the metric rule for "16 plus" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The spec said the metric follows the template the page renders. That is no longer true for GIAS phase 6: a sixth-form college renders the primary template but is matched, correctly, against secondaries. The rule is phase group membership, decided once in is_secondary_phase — and the section's lede noun comes from the school's phase rather than its template for the same reason. Co-Authored-By: Claude Opus 5 --- ...026-09-21-similar-schools-nearby-design.md | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/superpowers/specs/2026-09-21-similar-schools-nearby-design.md b/docs/superpowers/specs/2026-09-21-similar-schools-nearby-design.md index bb65fb8..6f87035 100644 --- a/docs/superpowers/specs/2026-09-21-similar-schools-nearby-design.md +++ b/docs/superpowers/specs/2026-09-21-similar-schools-nearby-design.md @@ -163,12 +163,25 @@ reader to assume otherwise. | `metric_key` | `rwm_expected_pct` or `attainment_8_score` — see below | | `metric_year` | the year the figure is from | -The metric follows the template the page is rendering, not the neighbour's own -phase, so a row of cards never mixes two scales. Primary and **all-through** -pages use `rwm_expected_pct`, matching `PrimarySchoolSections`, which is the -template all-through schools render with; secondary pages use -`attainment_8_score`. Where the neighbour has no value for that key, the card -reads "Not published" rather than falling back to the other key. +The metric follows the phase side the school was *matched* on, not the +neighbour's own phase, so a row of cards never mixes two scales. The secondary +side uses `attainment_8_score`; the primary side uses `rwm_expected_pct`. Where +the neighbour has no value for that key, the card reads "Not published" rather +than falling back to the other key. + +Which side a school takes is decided once, in +`similar_schools.is_secondary_phase`, by membership of `PHASE_GROUPS["secondary"]` +minus all-through — never by testing for the substring "secondary", which misses +`16 plus` (GIAS phase 6) and hands a sixth-form college the primary bucket. +All-through is the exception in the other direction: `PHASE_GROUPS` lists it on +both sides, but it takes the primary metric. + +This is usually the same thing as "the template the page renders", but not +always. `computeSchoolFlags` decides the template with that same substring test, +so a `16 plus` school renders `PrimarySchoolSections` while being matched — +correctly — against secondaries. The section therefore takes its lede noun from +the school's own phase rather than from its template, or it would print "Other +primary schools near " above a row of secondaries. `tier` is carried explicitly rather than inferred from the contents of `shared`, because the frontend needs it for two separate decisions — whether the @@ -355,6 +368,8 @@ synthetic frame rather than live marts: - tiers stop relaxing once three are found: four tier-1 matches never open tier 2 - more than six qualifying schools returns the six nearest - an all-through school is offered on both phase sides +- a `16 plus` school is matched against secondaries and colleges, never primaries +- `is_secondary_phase` and `PHASE_GROUPS` agree on every GIAS phase value - fewer than two qualifying schools returns `[]` - distances match a hand-computed haversine for a known pair