fix(api): include delivered callback replies in observed filter
This commit is contained in:
@@ -38,8 +38,8 @@ from src.db.awooop_models import (
|
||||
from src.db.base import get_db_context
|
||||
from src.db.models import IncidentRecord, MCPAuditLog
|
||||
from src.services.audit_sink import write_audit
|
||||
from src.services.awooop_approval_token import issue_approval_token, record_approval
|
||||
from src.services.awooop_ansible_audit_service import summarize_ansible_execution
|
||||
from src.services.awooop_approval_token import issue_approval_token, record_approval
|
||||
from src.services.awooop_truth_chain_service import (
|
||||
_summarize_gateway_mcp,
|
||||
_summarize_mcp,
|
||||
@@ -376,18 +376,6 @@ async def list_callback_replies(
|
||||
"m.source_envelope #>> '{callback_reply,status}' = :raw_status"
|
||||
)
|
||||
params["raw_status"] = raw_status
|
||||
elif callback_reply_status == "observed":
|
||||
where_clauses.append(
|
||||
"""
|
||||
COALESCE(m.source_envelope #>> '{callback_reply,status}', '')
|
||||
NOT IN (
|
||||
'callback_reply_sent',
|
||||
'callback_reply_fallback_sent',
|
||||
'callback_reply_rescue_sent',
|
||||
'callback_reply_failed'
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
if callback_action:
|
||||
where_clauses.append(
|
||||
@@ -3937,6 +3925,8 @@ def _callback_reply_summary_matches_status(
|
||||
if callback_reply_status is None:
|
||||
return True
|
||||
status_value = str((summary or {}).get("status") or "no_callback")
|
||||
if callback_reply_status == "observed":
|
||||
return status_value != "no_callback"
|
||||
return status_value == callback_reply_status
|
||||
|
||||
|
||||
|
||||
@@ -1965,6 +1965,19 @@ def test_callback_reply_summary_matches_status_filter() -> None:
|
||||
{"status": "sent"},
|
||||
"failed",
|
||||
)
|
||||
assert _callback_reply_summary_matches_status(
|
||||
{"status": "sent"},
|
||||
"observed",
|
||||
)
|
||||
assert _callback_reply_summary_matches_status(
|
||||
{"status": "fallback_sent"},
|
||||
"observed",
|
||||
)
|
||||
assert _callback_reply_summary_matches_status(
|
||||
{"status": "failed"},
|
||||
"observed",
|
||||
)
|
||||
assert not _callback_reply_summary_matches_status(None, "observed")
|
||||
assert _callback_reply_summary_matches_status(None, "no_callback")
|
||||
|
||||
|
||||
@@ -1977,6 +1990,16 @@ def test_callback_reply_status_filter_rejects_unknown_value() -> None:
|
||||
assert "callback_reply_status" in str(exc_info.value.detail)
|
||||
|
||||
|
||||
def test_list_callback_replies_observed_filter_keeps_delivered_statuses() -> None:
|
||||
source = inspect.getsource(platform_operator_service.list_callback_replies)
|
||||
|
||||
assert "callback_reply_status == \"observed\"" not in source
|
||||
assert "callback_reply_sent" not in source
|
||||
assert "callback_reply_fallback_sent" not in source
|
||||
assert "callback_reply_rescue_sent" not in source
|
||||
assert "callback_reply_failed" not in source
|
||||
|
||||
|
||||
def test_remediation_summary_matches_incident_id_filter() -> None:
|
||||
assert _remediation_summary_matches_incident_id(
|
||||
{"incident_ids": ["INC-20260514-F85F21"]},
|
||||
|
||||
Reference in New Issue
Block a user