feat(awooop): surface callback replies on run list
All checks were successful
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / tests (push) Successful in 1m25s
CD Pipeline / build-and-deploy (push) Successful in 3m35s
CD Pipeline / post-deploy-checks (push) Successful in 1m50s

This commit is contained in:
Your Name
2026-05-18 15:24:39 +08:00
parent 584bd4b31b
commit 20d62ee0cf
5 changed files with 356 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ from src.services.platform_operator_service import (
_remediation_summary_matches_incident_id,
_remediation_summary_matches_status,
_remediation_timeline_summary,
_run_callback_reply_summary,
_run_remediation_list_summary,
_timeline_sort_key,
)
@@ -129,6 +130,11 @@ def test_collect_run_incident_ids_reads_source_refs_and_legacy_text() -> None:
]
outbound_messages = [
SimpleNamespace(
source_envelope={
"source_refs": {
"incident_ids": ["INC-20260518-CB0001"],
},
},
content_preview="詳情INC-20260513-79ED5E",
send_error=None,
)
@@ -140,7 +146,84 @@ def test_collect_run_incident_ids_reads_source_refs_and_legacy_text() -> None:
outbound_messages=outbound_messages,
)
assert incident_ids == ["INC-20260514-F85F21", "INC-20260513-79ED5E"]
assert incident_ids == [
"INC-20260514-F85F21",
"INC-20260518-CB0001",
"INC-20260513-79ED5E",
]
def test_run_callback_reply_summary_marks_latest_fallback() -> None:
summary = _run_callback_reply_summary([
SimpleNamespace(
source_envelope={
"callback_reply": {
"status": "callback_reply_sent",
"action": "detail",
"incident_id": "INC-20260513-79ED5E",
}
},
sent_at=datetime(2026, 5, 18, 6, 1, 0),
queued_at=datetime(2026, 5, 18, 6, 1, 0),
provider_message_id="100",
),
SimpleNamespace(
source_envelope={
"callback_reply": {
"status": "callback_reply_fallback_sent",
"action": "history",
"incident_id": "INC-20260513-79ED5E",
}
},
sent_at=datetime(2026, 5, 18, 6, 2, 0),
queued_at=datetime(2026, 5, 18, 6, 2, 0),
provider_message_id="101",
),
])
assert summary["status"] == "fallback_sent"
assert summary["total"] == 2
assert summary["sent"] == 1
assert summary["fallback_sent"] == 1
assert summary["latest_action"] == "history"
assert summary["latest_incident_id"] == "INC-20260513-79ED5E"
assert summary["latest_provider_message_id"] == "101"
assert summary["needs_human"] is False
def test_run_callback_reply_summary_marks_failed_as_human_attention() -> None:
summary = _run_callback_reply_summary([
SimpleNamespace(
source_envelope={
"callback_reply": {
"status": "callback_reply_failed",
"action": "detail",
"incident_id": "INC-20260513-79ED5E",
}
},
sent_at=None,
queued_at=datetime(2026, 5, 18, 6, 3, 0),
provider_message_id="telegram_callback_reply:failed",
)
])
assert summary["status"] == "failed"
assert summary["failed"] == 1
assert summary["needs_human"] is True
def test_run_callback_reply_summary_marks_no_callback() -> None:
summary = _run_callback_reply_summary([
SimpleNamespace(
source_envelope={},
sent_at=datetime(2026, 5, 18, 6, 1, 0),
queued_at=datetime(2026, 5, 18, 6, 1, 0),
provider_message_id="100",
)
])
assert summary["status"] == "no_callback"
assert summary["total"] == 0
def test_remediation_timeline_summary_surfaces_route_and_write_flags() -> None: