fix: xref member-mark regex covers single-letter marks; recheck sheet diversity after cap

This commit is contained in:
2026-08-10 11:23:06 -05:00
parent f21eb5d912
commit c8af430143
2 changed files with 32 additions and 2 deletions
+27
View File
@@ -45,3 +45,30 @@ def test_xref_scope_joins_shared_member_tag():
scopes = build_link_scopes(sheets)
xref = [s for s in scopes if s.scope_id.startswith("xref:")]
assert xref
def test_xref_scope_joins_single_letter_member_mark():
# W-shapes (W12X26) are the most common steel marks and have one leading letter
sheets = [
_sheet("S102", 5, "roof", [_assertion("a1", tag="W12X26")]),
_sheet("S401", 30, "unknown", [_assertion("a2", tag="W12X26")]),
]
scopes = build_link_scopes(sheets)
xref = [s for s in scopes if s.scope_id.startswith("xref:")]
assert xref, "single-letter member marks (W12X26) must join xref scopes"
def test_xref_scope_rechecks_sheet_diversity_after_cap(monkeypatch):
from backend import config
monkeypatch.setattr(config, "AGENT_LINK_MAX_ASSERTIONS", 2)
sheets = [
_sheet("S401", 30, "roof", [_assertion("a1", ref="A/S205"),
_assertion("a2", ref="A/S205")]),
_sheet("S205", 20, "roof", [_assertion("a3", ref="A/S205")]),
]
scopes = build_link_scopes(sheets)
xref = [s for s in scopes if s.scope_id.startswith("xref:")]
for scope in xref:
sheets_in_scope = {a["sheet_number"] for a in scope.payload["assertions"]}
assert len(sheets_in_scope) >= 2, \
"capped xref scope must still span two sheets"