feat(governance): persist remediation dry run history
All checks were successful
Code Review / ai-code-review (push) Successful in 12s
CD Pipeline / tests (push) Successful in 1m4s
CD Pipeline / build-and-deploy (push) Successful in 3m44s
CD Pipeline / post-deploy-checks (push) Successful in 1m24s

This commit is contained in:
Your Name
2026-05-14 22:38:42 +08:00
parent 36cb9d6aeb
commit 6aaaf87ade
6 changed files with 253 additions and 24 deletions

View File

@@ -1,3 +1,30 @@
## 2026-05-14 | T26 Remediation dry-run 寫入 history試跑結果不再只停在前端暫存
**背景**T25 已讓 Operator 能在 `/governance` 補救佇列點「試跑」,但結果只存在當次 UI state。這仍無法完全回答「這次 dry-run 是否真的發生、跑到哪個流程、MCP 有沒有用到、後續是否能從 Incident history 回看」。
**修正**
- `Adr100RemediationService.dry_run()` 完成後會寫入兩條既有稽核軌道,不新增資料表:
- `alert_operation_log`:使用 `PRE_FLIGHT_PASSED` / `PRE_FLIGHT_FAILED`context schema `adr100_remediation_dry_run_history_v1`,保留 `work_item_id / auto_repair_id / playbook_id / mode / checks / post_state_summary / mcp_route / writes_*`
- `timeline_events`:寫 `event_type=verifier`、title `ADR-100 remediation dry-run`,讓 Incident Timeline 能看到 verifier 階段真的有 dry-run。
- dry-run API response 新增 `history.recorded / alert_operation_id / timeline_event_id`
- `/governance` 補救佇列試跑完成後,如果 history 寫入成功會顯示「已寫入歷史」。
**本地驗證**
- `python -m py_compile apps/api/src/services/adr100_remediation_service.py apps/api/tests/test_adr100_remediation_service.py`pass。
- `ruff check --select F,E9 apps/api/src/services/adr100_remediation_service.py apps/api/tests/test_adr100_remediation_service.py`pass。
- `DATABASE_URL=postgresql+asyncpg://test:test@localhost:5432/test python -m pytest tests/test_adr100_remediation_service.py tests/test_adr100_slo_status_service.py tests/test_ai_governance_endpoints.py -q`35 passed。
- `pnpm --filter @awoooi/web typecheck`pass。
- `pnpm --dir apps/web exec next lint --file src/app/[locale]/governance/tabs/slo-tab.tsx`pass。
- `NEXT_PUBLIC_API_URL=https://awoooi.wooo.work pnpm --filter @awoooi/web build`pass。
**推版與 production 驗證**
- 待 T26 commit 推 Gitea main 後驗證。
**目前整體進度**
- Alertmanager 低風險自動修復主線:約 98%。
- 完整 AI 自動化管理產品化:約 91%。
- T26 補上 dry-run 的 durable history。下一段應把這些 history 聚合回「工作鏈路 / Incident 詳情 / Telegram 詳情」同一視角,讓使用者不必猜流程走到哪一格。
## 2026-05-14 | T25 補救佇列新增安全試跑入口replay/reverify 可先讀證據不改狀態
**背景**T24 已把 non-success verifier rows 轉成 `remediation_queue`,但 Operator 仍只能看見「應該 replay / reverify」無法從前端或 API 直接觸發一個安全、可觀測、低風險的試跑步驟。這會讓「AI 可接手」停在文字標籤,還沒有形成可操作入口。