diff --git a/apps/api/src/services/decision_manager.py b/apps/api/src/services/decision_manager.py index e8dcbbae..999a7064 100644 --- a/apps/api/src/services/decision_manager.py +++ b/apps/api/src/services/decision_manager.py @@ -842,15 +842,11 @@ async def _push_auto_repair_result( from src.db.models import IncidentRecord from sqlalchemy import update as _upd_outcome _outcome = "auto_repaired" if success else "auto_repair_failed" - _verification = ( - f"自動修復{'成功' if success else '失敗'}:{action[:120] if action else '未知'}" - + (f" | 錯誤:{error[:80]}" if error else "") - ) async with get_db_context() as _odb: await _odb.execute( _upd_outcome(IncidentRecord) .where(IncidentRecord.incident_id == inc_id) - .values(outcome=_outcome, verification_result=_verification) + .values(outcome=_outcome) ) await _odb.commit() logger.info("outcome_written", incident_id=inc_id, outcome=_outcome) @@ -1018,13 +1014,15 @@ def expert_analyze(incident: Incident) -> dict[str, Any]: "source": "expert_system", "action": rule["action"].format(target=target), "description": rule["description"], + "diagnosis_description": rule["description"], # openclaw.py reads this key "risk_level": rule["risk_level"], "reasoning": f"[規則匹配] {rule['reasoning']}", # 明確標示來源 "confidence": 0.0, # 🔴 規則匹配不是 AI 仲裁,信心度設 0 "kubectl_command": rule["action"].format(target=target), "matched_rule": matched_rule, + "initial_diagnosis": matched_rule, # openclaw.py reads this key "from_cache": False, - "is_rule_based": True, # 新增標記 + "is_rule_based": True, } diff --git a/apps/api/src/services/failure_watcher.py b/apps/api/src/services/failure_watcher.py index c5426a36..bf00d4d9 100644 --- a/apps/api/src/services/failure_watcher.py +++ b/apps/api/src/services/failure_watcher.py @@ -569,9 +569,9 @@ class FailureWatcherService(IFailureWatcher): 整合 SignOz 監控數據提供更精準的 RCA。 """ try: - from src.services.openclaw import get_openclaw_service + from src.services.openclaw import get_openclaw - openclaw = get_openclaw_service() + openclaw = get_openclaw() # 建構告警上下文 alert_context = { @@ -738,7 +738,7 @@ class FailureWatcherService(IFailureWatcher): f"└ 💡 建議: {analysis.get('suggested_repair', '需人工分析')}\n\n" f"請在 Dashboard 授權或使用 /repair {audit_log_id[:8]}" ) - await tg.send_message(message) + await tg.send_notification(message) logger.info( "repair_request_sent", @@ -770,7 +770,7 @@ class FailureWatcherService(IFailureWatcher): f"├ 📋 AuditLog: {audit_log_id[:8]}...\n" f"└ 📝 結果: {repair_result}" ) - await tg.send_message(message) + await tg.send_notification(message) except Exception as e: logger.warning(