Implement document reconciliation v2

This commit is contained in:
plx
2026-08-05 23:55:33 +00:00
parent 4a60607503
commit 29382ec6c1
25 changed files with 2082 additions and 343 deletions

View File

@@ -743,7 +743,8 @@ def _select_default_documents(template: MessageTemplate, docs: Sequence[Dict[str
return []
expected = {kind.lower() for kind in template.expected_document_kinds}
matching = [doc for doc in docs if str(doc.get("document_kind") or "").lower() in expected]
current = [doc for doc in matching if str(doc.get("role") or "current") in {"current", "accepted"} and bool(doc.get("is_primary", True))]
current = [doc for doc in matching if str(doc.get("relationship") or "").upper() == "PRIMARY"
and str(doc.get("status") or "").upper() not in {"CANCELLED", "CANCELED"}]
chosen = current or matching
if not chosen:
return []