refactor(understand): one reading of units, plan copies, scale and rooms

Groups U and N were built side by side, so the takeoffs carried narrow
stand-ins for what group U reads properly. On main they read through U:

- describe.drawing_units is the one call every reader makes (kept records,
  labelled room faces as evidence); describe, scale_check and the takeoffs
  all use it. Without the room faces, a layout that declares inches over
  millimetres can tie three ways and fall to the header.
- layout_tags takes its plan copies from describe.prepare, room_regions its
  rooms from describe.find_rooms, and pipe_rows its scale from scale_check,
  per-room groups included. scale_stand_in and the takeoff's own unit bands
  and cluster grid are gone.
- test_understand_one_reading pins the agreement: one unit, one plan copy,
  one verdict and one set of rooms per drawing, across drawing_understand,
  drawing_scale_check and the two takeoffs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-24 14:45:27 +03:00
co-authored by Claude Opus 5.5
parent c4759e696d
commit 8c1a6cb27c
6 changed files with 244 additions and 347 deletions
+8 -4
View File
@@ -44,9 +44,14 @@ import statistics
from itertools import combinations
from engineering.arch.faces import face_containing
from engineering.understand.describe import FACE_TOL_FRACTION, find_rooms, prepare, tag_occurrences
from engineering.understand.describe import (
FACE_TOL_FRACTION,
drawing_units,
find_rooms,
prepare,
tag_occurrences,
)
from engineering.understand.snapshot import Snapshot
from engineering.understand.units import infer_units
__all__ = ["MIN_TAGS", "SCHEMATIC_SHARE", "TO_SCALE_SHARE", "WITHIN", "match_tags", "scale_check"]
@@ -190,8 +195,7 @@ def scale_check(a: Snapshot, b: Snapshot, *, min_pair_mm=2000.0) -> dict:
("a", a, side_a, None),
("b", b, side_b, rooms_b),
):
areas = [row["face"]["area"] for row, _f in rooms["labelled"]] if rooms else []
u = infer_units(snap, records=side["kept"], room_areas=areas)
u = drawing_units(snap, prep=side, rooms=rooms)
units[key] = {
"unit": u["inferred"],
"mm_per_unit": u["mm_per_unit"],