Skip to content

fix: reject unallocated AL postal-code prefixes (#118)#134

Merged
bk86a merged 1 commit into
mainfrom
fix/al-prefix-strict
Jul 3, 2026
Merged

fix: reject unallocated AL postal-code prefixes (#118)#134
bk86a merged 1 commit into
mainfrom
fix/al-prefix-strict

Conversation

@bk86a

@bk86a bk86a commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Follow-up to #133, addressing a Codex review finding.

Problem

The Albania block resolver used a continuous bisect, so every 4-digit code ≥ 1000 resolved to its enclosing district block — including codes whose 2-digit prefix belongs to no district (e.g. 1900, 2100, 9999). Those non-existent codes were returned as match_type="estimated", confidence 0.9 — indistinguishable from a real answer. Associating a confident region with a code that doesn't exist is a false signal.

Fix

Key on the allocated 2-digit district prefix instead of a continuous range. A code resolves only when its prefix maps to a real district; otherwise it returns not-found.

  • Real coverage is unchanged: all 489 previously-shipped codes and every Albania (AL) postal-code coverage completeness (GeoNames gaps) #118 gap code (Tirana 1055, Gramsh 33xx, Peqin 35xx, Tepelenë 63xx, Përmet 64xx) still resolve identically — the golden regression test is untouched and green.
  • Non-existent codes now 404 instead of getting a fabricated region: 1900 → None, 9999 → None.
  • Codes within a real district's space still resolve (1099 → AL022) — the block scheme is authoritative at district (2-digit) granularity, which is the finest our data supports.

This aligns AL with the rest of the service's quality-over-coverage stance (0.85 geocode threshold, cross-border guard): prefer no answer over a confident wrong one.

Tests: 49 passed across the AL + data_loader suites, ruff clean. README + CHANGELOG updated.

…ing (#118)

The block resolver used a continuous bisect, so any 4-digit code >=1000
resolved to its enclosing district block — including codes in prefixes that
belong to no district (e.g. 1900, 9999), which were returned as high-confidence
regions despite not existing. Key on the allocated 2-digit district prefix
instead: real codes and every #118 gap code still resolve identically (the
golden test is unchanged), but non-existent codes now return not-found rather
than a fabricated region. Flagged by Codex review on #133.
@bk86a bk86a merged commit d1d5cad into main Jul 3, 2026
10 checks passed
@bk86a bk86a deleted the fix/al-prefix-strict branch July 4, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant