Spaces:
Sleeping
Sleeping
File size: 982 Bytes
db4ba8d dd9584b db4ba8d dd9584b db4ba8d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | """
TradeFlow AI — Cross-Document Validation Node (Step 2.4)
"""
import structlog
from ...services.validation_rules_svc import validation_rules_service
from ..state import ExtractionGraphState
log = structlog.get_logger()
async def validation_node(state: ExtractionGraphState) -> dict:
"""
Step 2.4: Cross-Document Validation against JSON rules.
Gracefully handles rule evaluation errors to avoid crashing the pipeline.
"""
log.info("Running validation_node", batch_id=state["batch_id"])
try:
results, needs_review = validation_rules_service.evaluate(state)
except Exception as exc:
log.warning(
"Validation rules evaluation failed — marking for review",
batch_id=state["batch_id"],
error=str(exc),
)
results = []
needs_review = True
return {
"validation_results": results,
"needs_human_review": needs_review,
"steps": ["validation"]
}
|