refactor(telegram): migrate aider_heal_executor sender to EventRouter (ADR-019 Phase 5)

services/aider_heal_executor.py 的 _notify_telegram() 為 ADR-013 AutoHeal 閉環
通知出口(aider 自動修復進度)。原直接 POST sendMessage,timeout=5s(非阻塞)。
改走 services.event_router.dispatch_sync()。

行為變化:
- 失敗仍靜默 pass,caller(execute_code_fix 等)行為完全不變
- severity=warning 會被 EventRouter classify 為 L0 或 L1(無 trace 時 L0),
  輕量分流不會拖慢自動修復流程
- 享 EventRouter 內建 retry + JSONL queue replay;舊版 timeout=5 失敗即丟訊息
  的問題改善(可從 queue 重送)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
OoO
2026-05-02 13:08:45 +08:00
parent 84786be06f
commit 3e9d53c98c

View File

@@ -154,15 +154,26 @@ def _wait_for_health(
def _notify_telegram(message_html: str) -> None:
"""非阻塞通知,失敗靜默忽略。"""
"""
非阻塞通知,失敗靜默忽略。
ADR-019 Phase 5: 改走 EventRouter 統一入口event_type=aider_heal_event,
severity=warning會走 L0/L1 由 EventRouter 內部分流)。失敗仍靜默 pass
caller 行為不變。
"""
if not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
return
try:
requests.post(
f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
json={"chat_id": TELEGRAM_CHAT_ID, "text": message_html, "parse_mode": "HTML"},
timeout=5,
)
from services.event_router import dispatch_sync
dispatch_sync(event={
"event_type": "aider_heal_event",
"severity": "warning",
"source": "AiderHealExecutor",
"title": "Aider 自動修復通知",
"summary": message_html[:400],
"status": "heal_notification",
"payload": {"raw_message_html": message_html},
}, admin_chat_ids=[TELEGRAM_CHAT_ID])
except Exception:
pass