fix(api): include delivered callback replies in observed filter
All checks were successful
CD Pipeline / tests (push) Successful in 1m28s
Code Review / ai-code-review (push) Successful in 12s
CD Pipeline / build-and-deploy (push) Successful in 3m36s
CD Pipeline / post-deploy-checks (push) Successful in 1m51s

This commit is contained in:
Your Name
2026-06-04 20:56:42 +08:00
parent a89a48d1e0
commit ca0b3aece3
2 changed files with 26 additions and 13 deletions

View File

@@ -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

View File

@@ -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"]},