feat: coverage ladder + vision-unverified stamping (classic path)

This commit is contained in:
2026-08-18 13:35:21 -05:00
parent 23f6d7fe89
commit 48fefa4007
3 changed files with 246 additions and 15 deletions
+36
View File
@@ -84,3 +84,39 @@ def test_extractor_instruction_fully_substituted():
out = (EXTRACTOR_USER_INSTRUCTION.replace("{sheet_hint}", "")
+ _text_layer_block(page))
assert "{sheet_hint}" not in out
def test_vision_unverified_stamp_when_source_text_not_in_text_layer():
"""Digits ground the object against the page text, but its quoted
source_text is not actually present in the text layer: kept, stamped
vision_unverified (the wave-5b verifier consumes grounding stamps)."""
page_text = "WALL: 2X6 WD STUD @ 16\" O.C. WITH R-13 BATT INSULATION"
parsed = {"sheet": {}, "objects": [
{"object_id": "x1", "name": "stud pack",
"source_text": "(5) 2X6 STUD PACK AT JAMB", # NOT in page text
"attributes": {"count": "5"}}]}
sheet = _normalize_sheet(parsed, 1, page_text=page_text)
assert len(sheet["assertions"]) == 1
assert sheet["assertions"][0]["grounding"] == "vision_unverified"
def test_no_unverified_stamp_when_source_text_in_text_layer():
page_text = "WALL: 2X6 WD STUD @ 16\" O.C. WITH R-13 BATT INSULATION"
parsed = {"sheet": {}, "objects": [
{"object_id": "x1", "name": "stud note",
"source_text": "2X6 WD STUD @ 16\" O.C.",
"attributes": {"size": "2x6"}}]}
sheet = _normalize_sheet(parsed, 1, page_text=page_text)
assert len(sheet["assertions"]) == 1
assert "grounding" not in sheet["assertions"][0]
def test_preset_grounding_stamp_survives_normalization():
"""Fallback/merge rungs stamp grounding upstream; normalization must
preserve a pre-set stamp instead of recomputing it away."""
parsed = {"sheet": {}, "objects": [
{"object_id": "f1", "name": "lumber note",
"source_text": "ALL LUMBER SOUTHERN PINE",
"grounding": "text_layer_fallback"}]}
sheet = _normalize_sheet(parsed, 1, page_text="ALL LUMBER SOUTHERN PINE")
assert sheet["assertions"][0]["grounding"] == "text_layer_fallback"