Spaces:
Sleeping
Sleeping
github-actions[bot]
Automated deployment from GitHub Actions: d0b87cbe4fdaf86c5c12e61d54b1acd8b234b76c
dd9584b | """ | |
| 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"] | |
| } | |