Connector calls, semantic rules, and DuckDB memory keep long runs stable, and stream retry stops chats from stalling. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
1.4 KiB
Python
30 lines
1.4 KiB
Python
"""Golden reconciliation stays unverified until a real panel comparison passes."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict
|
|
|
|
|
|
def reconciliation_verdict(document: Dict[str, Any]) -> Dict[str, Any]:
|
|
periods = document.get("periods") if isinstance(document, dict) else None
|
|
if not isinstance(periods, list) or not periods:
|
|
return {"verified": False, "panel_parity_verified": False, "result": "not_run"}
|
|
for period in periods:
|
|
if not isinstance(period, dict) or period.get("result") != "pass":
|
|
result = "not_run"
|
|
if isinstance(period, dict) and period.get("result"):
|
|
result = str(period.get("result"))
|
|
return {"verified": False, "panel_parity_verified": False, "result": result}
|
|
expected = period.get("panel_expected")
|
|
if not isinstance(expected, dict):
|
|
return {"verified": False, "panel_parity_verified": False, "result": "not_run"}
|
|
for key, value in expected.items():
|
|
if key == "sales_by_owner":
|
|
continue
|
|
if value is None:
|
|
return {"verified": False, "panel_parity_verified": False, "result": "not_run"}
|
|
actual = period.get("kamidso_actual")
|
|
if not isinstance(actual, dict) or not actual:
|
|
return {"verified": False, "panel_parity_verified": False, "result": "not_run"}
|
|
return {"verified": True, "panel_parity_verified": True, "result": "pass"}
|