fix(adr-075): CR P0/P1 修補 — TYPE_8M enum + 死碼清理 + docstring 更新
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
P0-2: NotificationType 新增 TYPE_8M = "TYPE-8M"
classify_notification 早期回傳 TYPE-8M
decision_manager 改用 NotificationType.TYPE_8M enum 比較(移除字串字面量)
P1-1: 移除 _CATEGORY_BUTTONS 中不可達的 alertchain_health/flywheel_health 條目
P1-4: test_classify_alert_early.py docstring 更新為 13 條規則/10 分類
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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}"),
|
||||
],
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user