diff --git a/apps/api/src/services/awooop_truth_chain_service.py b/apps/api/src/services/awooop_truth_chain_service.py index dfe733de..efbd546d 100644 --- a/apps/api/src/services/awooop_truth_chain_service.py +++ b/apps/api/src/services/awooop_truth_chain_service.py @@ -1200,6 +1200,7 @@ async def fetch_truth_chain(source_id: str, project_id: str = "awoooi") -> dict[ WHERE project_id = :project_id AND ( run_id::text = :source_id + OR provider_event_id = :source_id OR content_preview ILIKE :source_needle OR ( :fingerprint_needle != '' diff --git a/apps/api/tests/test_awooop_truth_chain_service.py b/apps/api/tests/test_awooop_truth_chain_service.py index 48315a50..6b28e303 100644 --- a/apps/api/tests/test_awooop_truth_chain_service.py +++ b/apps/api/tests/test_awooop_truth_chain_service.py @@ -1,5 +1,6 @@ from __future__ import annotations +import inspect from datetime import datetime, timedelta, timezone from types import SimpleNamespace @@ -15,6 +16,7 @@ from src.services.awooop_truth_chain_service import ( _incident_fingerprints, _summarize_gateway_mcp, _truth_status, + fetch_truth_chain, summarize_automation_quality_records, ) from src.services.drift_repeat_state import ( @@ -51,6 +53,12 @@ def test_incident_fingerprints_reads_signal_labels() -> None: assert fingerprints == ["fp-direct", "fp-label"] +def test_fetch_truth_chain_can_match_inbound_provider_event_id() -> None: + source = inspect.getsource(fetch_truth_chain) + + assert "provider_event_id = :source_id" in source + + def test_truth_status_marks_no_action_approval_as_manual_required() -> None: status = _truth_status( incident={"incident_id": "INC-1", "status": "INVESTIGATING"},