Files
ewoooc/migrations
OoO 0b13055466 feat(p38): host_health + ppt_audit DB 持久化(B-1 + B-2)
統帥要求:
1. 所有 6 個觀測頁的功能和數據都要完整寫入資料庫儲存
2. Ollama 切 GCP 順序 GCP-A → GCP-B → 111

盤點結果:
- 4/6 頁面已有 DB 表(ai_calls / learning_episodes / rag_query_log / ai_call_budgets)
- 2/6 頁面是即時查詢無歷史:host_health(HTTP probe)、ppt_audit(os.listdir)
- Ollama 99% 已合規,僅 1 處過時註解

修補(B-1):
- services/code_review_pipeline_service.py:207 註解更新
  「直呼內網 Ollama (192.168.0.188)」→ 「走 resolve_ollama_host 三主機級聯 ADR-027」

新增(B-2):
- migrations/029_create_host_health_probes.sql
  - 三主機健康歷史表(label/url/healthy/response_ms/error_msg)
  - 索引:probed_at / (host_label, probed_at)
  - 30 天保留(cron 清理)
- migrations/030_create_ppt_audit_results.sql
  - PPT 視覺審核結果表(status/issues_count/issues_found JSONB/confidence)
  - 索引:audited_at / pptx_filename / failed-only partial
- routes/admin_observability_routes.py:host_health_dashboard
  - 每次 probe 寫入 host_health_probes(失敗安全)
  - 新增 24h 健康趨勢卡片(uptime % / 平均 ms)
- routes/admin_observability_routes.py:ppt_audit_history
  - 從 ppt_audit_results 讀過去 7 日 audit 紀錄
  - 顯示審核時間/檔名/結果/問題數/信心度/耗時
- services/ppt_vision_service.py:check_ppt_file
  - 新增 _persist_audit_result() 跑完寫入 DB(status/issues/confidence/duration)
  - 失敗安全:DB 寫入失敗只 log warning,不擋主流程
- templates/admin/host_health.html + ppt_audit_history.html
  - 新增「24h 健康趨勢」card(host_health)
  - 新增「視覺審核歷史紀錄」card(ppt_audit)

DoD:
- 程式碼語法 ✓
- Jinja 平衡 ✓
- 失敗安全(DB 寫入或讀取失敗都不擋頁面渲染)✓

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 18:55:39 +08:00
..
2026-04-29 22:48:24 +08:00