From 8fe96f03ea7f8d2a1b490e6f1862dff44594f39e Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 25 May 2026 18:12:20 +0000 Subject: [PATCH] Slice 84: RED tracer-bullet diff test for cohort 000516 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Final cohort cert mapper-vs-hand-built diff test. Cert U985-0001-000516 (Mid-Terrace, main + 19.02 m² RIR, 5 vertical windows + 1 roof window routed to sap_roof_windows per the mapper's `U > 3.0` discrimination). RED with 24 load-bearing divergences — mostly standard Cat A. Closes via Slice 85 (Cat A) + Slice 86 (1:1 window expansion 2 → 5). After 000516 lands GREEN, **all 6 cohort certs are Layer-2 zero- diff** — clearing the way to return to cert 001479 (Slice 62 skeleton, 2/11 cascade pins green; gap −3.02 SAP). Co-Authored-By: Claude Opus 4.7 --- .../tests/test_summary_pdf_mapper_chain.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/backend/documents_parser/tests/test_summary_pdf_mapper_chain.py b/backend/documents_parser/tests/test_summary_pdf_mapper_chain.py index 0beb9ff1..fe3c02e3 100644 --- a/backend/documents_parser/tests/test_summary_pdf_mapper_chain.py +++ b/backend/documents_parser/tests/test_summary_pdf_mapper_chain.py @@ -44,6 +44,7 @@ from domain.sap.worksheet.tests import ( _elmhurst_worksheet_000480 as _w000480, _elmhurst_worksheet_000487 as _w000487, _elmhurst_worksheet_000490 as _w000490, + _elmhurst_worksheet_000516 as _w000516, ) _FIXTURES = Path(__file__).parent / "fixtures" @@ -692,3 +693,33 @@ def test_from_elmhurst_site_notes_matches_hand_built_000490() -> None: f"hand-built EpcPropertyData for cohort cert 000490:\n " + "\n ".join(diffs) ) + + +def test_from_elmhurst_site_notes_matches_hand_built_000516() -> None: + # Arrange — _elmhurst_worksheet_000516.build_epc() is the canonical + # hand-built EpcPropertyData for cert U985-0001-000516 (Mid-Terrace, + # main + 19.02 m² RIR, 5 vertical windows + 1 roof window which the + # mapper routes to `sap_roof_windows` per `U > 3.0` discrimination); + # it cascades to the worksheet PDF's `SAP value 62.7937` at 1e-4. + # Routing the Summary PDF through the Elmhurst mapper MUST produce + # a load-bearing-field-equivalent EpcPropertyData. + pages = _summary_pdf_to_textract_style_pages(_SUMMARY_000516_PDF) + site_notes = ElmhurstSiteNotesExtractor(pages).extract() + mapped = EpcPropertyDataMapper.from_elmhurst_site_notes(site_notes) + hand_built = _w000516.build_epc() + + # Act + diffs: list[str] = [] + for field_name in _LOAD_BEARING_FIELDS: + diffs.extend(_diff_load_bearing( + getattr(mapped, field_name, None), + getattr(hand_built, field_name, None), + field_name, + )) + + # Assert + assert not diffs, ( + f"{len(diffs)} load-bearing divergence(s) between mapped and " + f"hand-built EpcPropertyData for cohort cert 000516:\n " + + "\n ".join(diffs) + )