fix(incidents): keep list endpoint pure read
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 1m7s
CD Pipeline / build-and-deploy (push) Successful in 3m26s
CD Pipeline / post-deploy-checks (push) Successful in 1m17s

This commit is contained in:
Your Name
2026-05-06 21:17:25 +08:00
parent ea6b7d8f27
commit a0179cec6e
4 changed files with 106 additions and 17 deletions

View File

@@ -1,3 +1,22 @@
## 2026-05-06 | Incident 列表改回純讀,停止前端輪詢觸發 AI 推理
**背景**:部署 AwoooP 首頁後production log 顯示載入 `/zh-TW/awooop` 期間會打 `GET /api/v1/incidents`,接著出現 `phase24_ai_router_used provider=ollama` 與 GCP-A Ollama 推理耗時約 55 秒。這代表列表查詢仍會背景啟動 AI 決策,導致前端輪詢佔用 GCP Ollama 推理槽,極端情況下也可能 fallback 到 Gemini 產生成本。
**根因**
- `GET /api/v1/incidents` 註解雖寫「不等待 AI」但對缺少 decision token 的 incident 仍會 `asyncio.create_task(decision_manager.get_or_create_decision(...))`
- 多個前端頁面與面板會輪詢 `/api/v1/incidents`,所以「只是查列表」等同於「背景產生 proposal」。
**本次修補**
- `GET /api/v1/incidents` 新增 `generate_missing_decisions=false` 預設參數。
- 預設只讀取既有 decision token缺少 token 時回傳 `decision=null`,不再背景觸發 Ollama / OpenClaw / Gemini。
- 若維運人員明確需要舊行為,可用 `generate_missing_decisions=true` 觸發背景生成;正式修復建議仍應走 `POST /api/v1/incidents/{incident_id}/proposal` 或 AwoooP Operator Run。
- 新增 regression test鎖定列表查詢預設不會呼叫 `get_or_create_decision()`
**驗證**
- `python -m py_compile apps/api/src/api/v1/incidents.py apps/api/tests/test_incidents_list_pure_read.py`
- `pytest tests/test_incidents_list_pure_read.py tests/test_telegram_message_templates.py -q` → 18 passed。
- `ruff check src/api/v1/incidents.py tests/test_incidents_list_pure_read.py` → All checks passed。
## 2026-05-06 | Telegram 事故通知語義收斂與 AwoooP 首頁總覽
**背景**SRE 戰情室截圖顯示 ACTION REQUIRED、AI 自動修復失敗、Escalation、Code Review、Config Drift 等訊息混在同一條流中;值班者很難快速分辨哪些是 AI 已修復、哪些是 AI 無法修復需要人工、哪些只是報表或治理通知。