Resolve a UPRN to its historic EPC record by exact match 🟩

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-06 08:17:54 +00:00
parent 4bbcdb6a61
commit f9f80f7184

View file

@ -35,8 +35,17 @@ class HistoricEpcResolver:
)
def record_for_uprn(self, uprn: str, postcode: str) -> Optional[HistoricEpc]:
"""The postcode shard's certificate for ``uprn``, or None."""
return None
"""The postcode shard's certificate for ``uprn``, or None on a miss.
Exact UPRN equality only the prediction path must never import a
fuzzy address match's attributes as if observed (ADR-0054)."""
if not uprn:
return None
records: list[HistoricEpc] = self._repo.get_for_postcode(Postcode(postcode))
certs: list[HistoricEpc] = [r for r in records if r.uprn == uprn]
if not certs:
return None
return max(certs, key=lambda r: r.lodgement_date)
def resolve_uprn(
self, user_address: str, postcode: str