fix(telegram): separate ssh diagnosis from repair failures
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 1m27s
CD Pipeline / build-and-deploy (push) Successful in 4m19s
CD Pipeline / post-deploy-checks (push) Successful in 1m25s

This commit is contained in:
Your Name
2026-05-06 22:03:19 +08:00
parent 53994e75f0
commit 9dfecc4d1b
5 changed files with 107 additions and 8 deletions

View File

@@ -576,6 +576,7 @@ async def _push_decision_to_telegram(
alert_category=_alert_category,
notification_type=_notification_type,
playbook_name=_playbook_name,
automation_state=proposal_data.get("automation_state", ""),
)
# 2026-04-09 Claude Sonnet 4.6: 存 message_id → 後續狀態更新在原訊息延續
@@ -3519,6 +3520,8 @@ class DecisionManager:
token.proposal_data["decision_state"] = DecisionState.READY.value
token.proposal_data["auto_executed"] = False
token.proposal_data["mcp_all_failed"] = True
if _tool == "ssh_diagnose":
token.proposal_data["automation_state"] = "diagnosis_failed_manual_required"
await self._save_token(token)
_fire_and_forget(
_escalate_decision_auto_repair_unavailable(
@@ -3528,14 +3531,15 @@ class DecisionManager:
attempted_actions=f"decision_manager._ssh_execute -> {_tool}",
)
)
_fire_and_forget(
_push_auto_repair_result(
incident,
action,
success=False,
error=token.error,
if _tool != "ssh_diagnose":
_fire_and_forget(
_push_auto_repair_result(
incident,
action,
success=False,
error=token.error,
)
)
)
_fire_and_forget(_push_decision_to_telegram(incident, token.proposal_data))
return
@@ -3545,6 +3549,7 @@ class DecisionManager:
token.proposal_data["auto_executed"] = False
token.proposal_data["ssh_diagnosis_collected"] = True
token.proposal_data["ssh_diagnosis_preview"] = output_preview
token.proposal_data["automation_state"] = "diagnosis_collected_manual_required"
await self._save_token(token)
_fire_and_forget(
_escalate_decision_auto_repair_unavailable(

View File

@@ -215,6 +215,7 @@ class TelegramMessage:
# 2026-04-16 ogt + Claude Sonnet 4.6: 告警分類與修復鏈路顯示 (ADR-076)
alert_category: str = "" # host/k8s/database/service/external_site/secops 等
playbook_name: str = "" # 匹配到的 Playbook 名稱(空字串=規則匹配)
automation_state: str = "" # diagnosis_collected_manual_required / diagnosis_failed_manual_required
# ==========================================================================
# Phase 22: Nemotron 協作欄位 (ADR-044)
@@ -273,7 +274,12 @@ class TelegramMessage:
mode = self._automation_mode()
action = (self.suggested_action or "").upper()
text = f"{self.root_cause} {self.suggested_action}".lower()
state = (self.automation_state or "").lower()
if state == "diagnosis_collected_manual_required":
return "🔎 AI 已完成只讀診斷,需人工判斷"
if state == "diagnosis_failed_manual_required":
return "🔴 AI 診斷工具失敗,需人工排查"
if mode == "llm_timeout_manual_gate":
return "🔴 AI 分析超時,需人工排查"
if action in {"NO_ACTION", "待分析", ""} or "invalid_target" in text:
@@ -1874,6 +1880,7 @@ class TelegramGateway:
notification_type: str = "",
# 2026-04-16 ogt + Claude Sonnet 4.6: 修復鏈路顯示 (ADR-076)
playbook_name: str = "",
automation_state: str = "",
) -> dict:
"""
推送待簽核卡片到 Telegram (v7.0 含 SignOz 整合)
@@ -1950,6 +1957,7 @@ class TelegramGateway:
# 2026-04-16 ogt + Claude Sonnet 4.6: 修復鏈路顯示 (ADR-076)
alert_category=alert_category,
playbook_name=playbook_name,
automation_state=automation_state,
)
# 格式化訊息 — Phase 22: 如果 Nemotron 啟用,使用雙軌格式