Deterministically guard the high-heat-retention storage description 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-01 14:30:13 +00:00
parent 01e7e1d831
commit 9711b2e5f5
2 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,11 @@
from __future__ import annotations
from typing import Optional
from domain.epc.property_overrides.main_heating_system_type import (
MainHeatingSystemType,
)
def main_heating_guard(description: str) -> Optional[MainHeatingSystemType]:
raise NotImplementedError

View file

@ -0,0 +1,40 @@
from __future__ import annotations
import pytest
from domain.epc.property_overrides.main_heating_guard import main_heating_guard
from domain.epc.property_overrides.main_heating_system_type import (
MainHeatingSystemType,
)
def test_guard_resolves_high_heat_retention_storage() -> None:
# Arrange — the structured phrasing the LLM funnelled into "old storage" (401).
description = "Electric Storage Systems: High heat retention storage heaters"
# Act
result = main_heating_guard(description)
# Assert — HHRSH has its own archetype (SAP 409), never old storage (ADR-0044).
assert result is MainHeatingSystemType.ELECTRIC_STORAGE_HIGH_HEAT_RETENTION
@pytest.mark.parametrize(
"description",
[
# Other storage subtypes the LLM already classifies correctly — the guard
# only rescues the HHRSH gap, leaving the rest to the fallback classifier.
"Electric Storage Systems: Old (large volume) storage heaters",
"Electric Storage Systems: Modern (slimline) storage heaters",
"Electric Storage Systems: Fan storage heaters",
# Unrelated / varied phrasings are the LLM's job.
"Gas boiler",
"",
],
)
def test_guard_defers_non_hhrsh_descriptions_to_the_llm(description: str) -> None:
# Act
result = main_heating_guard(description)
# Assert
assert result is None