diff --git a/apps/api/src/services/decision_manager.py b/apps/api/src/services/decision_manager.py index 76e4e121..150040e9 100644 --- a/apps/api/src/services/decision_manager.py +++ b/apps/api/src/services/decision_manager.py @@ -249,7 +249,7 @@ async def _push_decision_to_telegram( resource_name=target[:50], diff_summary=description[:500], ) - elif _notif_type.value == "TYPE-8M" or _alert_category in ("alertchain_health", "flywheel_health"): + elif _notif_type == NotificationType.TYPE_8M or _alert_category in ("alertchain_health", "flywheel_health"): # TYPE-8M:飛輪/告警鏈路健康異常,發到個人 DM(不發群組) tg_result = await gateway.send_meta_alert( incident_id=incident.incident_id, diff --git a/apps/api/src/services/telegram_gateway.py b/apps/api/src/services/telegram_gateway.py index b9aaa6f7..f8421417 100644 --- a/apps/api/src/services/telegram_gateway.py +++ b/apps/api/src/services/telegram_gateway.py @@ -1111,6 +1111,7 @@ class NotificationType(str, Enum): TYPE_3 = "TYPE-3" # 需人工審核(預設) TYPE_4 = "TYPE-4" # AI 無法判斷 TYPE_4_DRIFT = "TYPE-4D" # Config Drift 專屬 + TYPE_8M = "TYPE-8M" # ADR-075: 飛輪/告警鏈路自身健康(Meta-System) def classify_notification( @@ -1134,10 +1135,12 @@ def classify_notification( decision_state: DecisionState 字串 ("COMPLETED" / "ERROR" / ...) """ # ADR-073 Phase 3-1: 優先採用 classify_alert_early() 已設定的 notification_type - # 這樣 TYPE-1/TYPE-4D 告警不需進入 LLM 分析路徑 (2026-04-12 ogt) + # 這樣 TYPE-1/TYPE-4D/TYPE-8M 告警不需進入 LLM 分析路徑 (2026-04-12 ogt) _early_type = getattr(incident, "notification_type", None) if _early_type == "TYPE-4D": return NotificationType.TYPE_4_DRIFT + if _early_type == "TYPE-8M": + return NotificationType.TYPE_8M if _early_type == "TYPE-1": return NotificationType.TYPE_1 @@ -1388,14 +1391,7 @@ class TelegramGateway: ("🔍 查健康狀態", f"action:check_health:{incident_id}"), ("📋 查 Log", f"action:check_log:{incident_id}"), ], - "alertchain_health": [ - ("🔍 查 Alertmanager", f"action:check_log:{incident_id}"), - ("🔄 重載設定", f"action:reload_config:{incident_id}"), - ], - "flywheel_health": [ - ("🔍 查飛輪狀態", f"action:check_health:{incident_id}"), - ("📋 查 Log", f"action:check_log:{incident_id}"), - ], + # alertchain_health / flywheel_health → TYPE-8M → send_meta_alert,不走此字典 "ai_system": [ ("🔀 切換 Provider", f"action:switch_provider:{incident_id}"), ], diff --git a/apps/api/tests/test_classify_alert_early.py b/apps/api/tests/test_classify_alert_early.py index 8f747767..d1ede5b5 100644 --- a/apps/api/tests/test_classify_alert_early.py +++ b/apps/api/tests/test_classify_alert_early.py @@ -1,10 +1,14 @@ """ -classify_alert_early() 分類函數單元測試 — ADR-073 Phase 2-2 +classify_alert_early() 分類函數單元測試 — ADR-073 Phase 2-2 + ADR-075 -覆蓋 7 條分類規則的正常路徑與邊界情況: - config_drift, info, backup, infrastructure, kubernetes, database, general +覆蓋 13 條分類規則、10 種告警分類: + config_drift (TYPE-4D) + alertchain_health, flywheel_health (TYPE-8M) — beats severity + info, backup (TYPE-1) + host_resource, infrastructure, kubernetes, database, + storage, devops_tool, external_site, ssl_cert, general (TYPE-3) -2026-04-12 ogt (ADR-073 P2-2 測試補強) +2026-04-12 ogt (ADR-073 P2-2 測試補強 + ADR-075 七類新增) """ import pytest