From 3bbb9aa1a23f8a72eeaf33608352d083834cd228 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 2 Jun 2026 18:11:28 +0000 Subject: [PATCH] S0380.181: tighten heat-systems corpus residual tolerances to 1e-4 (all metrics) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The corpus residual-pin tolerances had drifted looser than the comment above them claimed ("pin at 1e-4 relative to lodged precision"): SAP was 1e-3, cost ±£0.01, CO2 ±0.1 kg, PE ±0.1 kWh. A ±0.1 kg CO2 band could silently mask a ~0.09 kg drift on a variant we report as EXACT. The worksheet pins are extracted from the P960 PDF text, which prints 4 d.p., so the hard residual floor is ~5e-5 (half a unit in the last printed digit) regardless of cascade precision. 1e-4 sits just above that floor. All 41 variants hold at uniform 1e-4 on continuous SAP, cost, CO2 AND PE — confirming the 37 EXACT variants are genuinely exact to PDF print-rounding and the looser bands were masking nothing. Aligns the guard with [[feedback-zero-error-strict]] / [[feedback-continuous-sap-tolerance]] (basically zero error across all four metrics). Test-only change; no cascade behaviour touched. Co-Authored-By: Claude Opus 4.8 --- .../tests/test_heating_systems_corpus.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/documents_parser/tests/test_heating_systems_corpus.py b/backend/documents_parser/tests/test_heating_systems_corpus.py index 14ccc2d9..a09e3ae7 100644 --- a/backend/documents_parser/tests/test_heating_systems_corpus.py +++ b/backend/documents_parser/tests/test_heating_systems_corpus.py @@ -68,13 +68,18 @@ _CORPUS_ROOT = ( # Per-pin absolute tolerances. Worksheet `SAP value` lodges 4 d.p., -# (255) total fuel cost 4 d.p., (272) total CO2 4 d.p., (286) Total -# Primary energy kWh/year 4 d.p. — pin at 1e-4 relative to lodged -# precision so any drift outside cascade float noise fires. -_SAP_RESID_ABS_TOLERANCE = 0.001 -_COST_RESID_ABS_TOLERANCE_GBP = 0.01 -_CO2_RESID_ABS_TOLERANCE_KG = 0.1 -_PE_RESID_ABS_TOLERANCE_KWH = 0.1 +# (255)/(355) total fuel cost 4 d.p., (272)/(383) total CO2 4 d.p., +# (286)/(483) Total Primary energy kWh/year 4 d.p. — so the hard floor +# on any residual is ~5e-5 (half a unit in the last printed digit), +# independent of cascade precision. Pin at 1e-4 on EVERY metric (per +# [[feedback-zero-error-strict]] / [[feedback-continuous-sap-tolerance]] +# — basically zero error across continuous SAP, cost, CO2 and PE) so +# any drift beyond PDF print-rounding fires loudly. All 41 variants hold +# at this tolerance; closures re-pin the smaller residual, never widen. +_SAP_RESID_ABS_TOLERANCE = 0.0001 +_COST_RESID_ABS_TOLERANCE_GBP = 0.0001 +_CO2_RESID_ABS_TOLERANCE_KG = 0.0001 +_PE_RESID_ABS_TOLERANCE_KWH = 0.0001 @dataclass(frozen=True)