feat(smoke): monitor pchome auto policy guard
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-03 08:00:01 +08:00
parent 4ccd3c413a
commit 16c615c9ee
6 changed files with 367 additions and 23 deletions

View File

@@ -1,8 +1,8 @@
# PChome 業績成長自動化作戰系統 — AI 競價情報模組 Single Source of Truth
> **最後更新**: 2026-07-02 (台北時間)
> **狀態**: 🟢 四 AI Agent 自動化閉環已落地LLM 路由紅線升級為 Ollama-first 三主機級聯PChome 後台業績匯入韌性已補強產品定位正名為「PChome 業績成長自動化作戰系統」外部市場來源正規化層、自動同步、作戰清單與價格參考表優先讀取、CSV 備援預檢、前台操作入口、高可見頁面繁中化守門、比價/作戰 UI 工作台化、AI 密集工作台文字密度守門、跨平台來源治理商品身份 UI 契約已建立GCP embedding 熔斷延後處理、110 proxy rescue 與 direct host health skip 已建立
> **適用版本**: V10.725
> **最後更新**: 2026-07-03 (台北時間)
> **狀態**: 🟢 四 AI Agent 自動化閉環已落地LLM 路由紅線升級為 Ollama-first 三主機級聯PChome 後台業績匯入韌性已補強產品定位正名為「PChome 業績成長自動化作戰系統」外部市場來源正規化層、自動同步、作戰清單與價格參考表優先讀取、CSV 備援預檢、前台操作入口、高可見頁面繁中化守門、比價/作戰 UI 工作台化、AI 密集工作台文字密度守門、跨平台來源治理商品身份 UI 契約、sitewide visual QA runtime readback 與 PChome auto-policy authorization guard monitoring 已建立GCP embedding 熔斷延後處理、110 proxy rescue 與 direct host health skip 已建立
> **適用版本**: V10.726
---
@@ -241,6 +241,7 @@ SQL漏斗(~300筆)
- `/metrics` 在尚無事件時仍輸出 `momo_ai_*` zero-baseline series讓 Prometheus/Grafana 重啟後可立即看到 metric names。
- `/ai_automation_smoke` 提供登入後 AI 自動化健康檢查頁。
- `/api/ai-automation/smoke` 提供 read-only JSON 狀態,不做外部網路呼叫。
- `/api/ai-automation/smoke` 必須包含 `PChome auto-policy authorization guard`read-only 組裝 PChome auto-policy DB apply guard lane檢查 no-secret、no-SQL、no-DB-write、machine-verifiable contract、`manual_review_mode=exception_only``primary_human_gate_count=0`。此 check 不做外部 fetch、不寫 DB、不發 authorization`/api/ai-automation/scheduled-health-summary` 需輸出 `pchome_auto_policy_authorization_guard` family`/metrics` 需暴露對應 `momo_ai_automation_scheduled_health_family_status`
- 健康檢查 API 會將最近檢查結果保存到 JSONL頁面顯示最近狀態趨勢。
- 健康檢查歷史支援 JSONL 匯出、清理與每日「正常 / 注意 / 嚴重」摘要。
- 健康檢查每日摘要支援手動 Telegram 推播,並由 `momo-scheduler` 每日 09:10 呼叫 `run_ai_smoke_daily_summary_task()`

View File

@@ -9,7 +9,7 @@
以下是使用者在主線推進期間插入、且必須保留在完整工作項目裡的要求。後續不得再把這些需求漏掉或變成口頭提醒。
1. 正式環境才是最新版本真相;不得用本機檔案、舊筆記、舊分支蓋過 production truth。
2. 版本不得搞錯;目前正式環境 `/health` 版本維持 `V10.725`,除非有明確版本 bump、部署與 readback。
2. 版本不得搞錯;目前正式環境 `/health` 版本維持 `V10.726`,除非有明確版本 bump、部署與 readback。
3. GitHub 全面 freeze不得使用 GitHub、`gh`、GitHub API、GitHub Actions、PR、issue、mirror 或 read-only GitHub 流程。
4. 實作結果必須推到 Gitea `dev``main`;若改到 runtime 行為,還必須部署到正式環境並回讀。
5. 主方向是 AI 自動化,不是人工審核;人工欄位只能當 evidence / ledger / UI truth不得阻擋低爆炸半徑、可驗證、可回滾的 controlled apply。
@@ -30,7 +30,7 @@
| P0 | Runtime truth + AI controlled apply closure | 進行中,核心閉環已完成多段 | 先證明 AI 真的在正式環境可執行、可回讀、可驗證、可回滾 |
| P1 | 產品可視化 + 專業網站體驗 | 進行中 | 使用者要看得到實作結果AI 自動化不能只藏在 artifact / log |
| P2 | 外部主流 benchmark 落成 guardrails | 已完成第一版,持續擴充 | 把主流專業做法變成可測規則,不只是參考口號 |
| P3 | 擴大 AI 自動化覆蓋面 | 未開始 | 把目前 PChome retry lane 的閉環模式複製到更多安全場景 |
| P3 | 擴大 AI 自動化覆蓋面 | 進行中 | 把目前 PChome retry lane 的閉環模式複製到更多安全場景 |
| P4 | Source / deployment governance | 持續進行 | 保證版本、Gitea、正式環境、DB 安全紅線不再混亂 |
## P0 - Runtime Truth And AI Controlled Apply Closure
@@ -41,7 +41,7 @@
已完成:
- 正式環境版本真相 guard`/health` 是最高真相,目前維持 `V10.725`
- 正式環境版本真相 guard`/health` 是最高真相,目前維持 `V10.726`
- Gitea `dev` / `main` source truth 對齊。
- Retry exception controlled apply executor 已落地,目標表為 `pchome_product_matches`
- 正式 DB 已 controlled apply 4 個 selectors:
@@ -86,10 +86,16 @@
- `PRODUCT_SURFACE_CLEAR`
- `finding_count=0`
- `primary_human_gate_count=0`
- PChome auto-policy authorization guard runtime monitoring 已完成:
- `/api/ai-automation/smoke` 已加入 `PChome auto-policy authorization guard`
- read-only 組裝 auto-policy DB apply guard lane檢查 no-secret / no-SQL / no-DB-write / machine-verifiable / exception-only
- `/api/ai-automation/scheduled-health-summary` 已輸出 `pchome_auto_policy_authorization_guard` family
- `/metrics` 已輸出 `momo_ai_automation_scheduled_health_family_status{family="pchome_auto_policy_authorization_guard",...}`
- 不做外部 fetch、不寫 DB、不發 apply authorization下一個機器動作是補 machine fetch evidence 與後續 controlled authorization lane
進行中 / 下一步,必須照順序:
1.PChome retry lane 的 receipt / replay / drift / product dashboard pattern 複製到下一條 safe automation lane。
1.auto-policy authorization guard 往下一條 machine-fetch evidence / authorization decision preflight lane 推進
完成標準:
@@ -254,12 +260,12 @@
目的: 把目前 PChome retry mapping lane 的 controlled apply 閉環模式擴展到更多安全場景。
未開始 / 下一步,必須照順序:
進行中 / 下一步,必須照順序:
1. 對其他 safe mapping backlog lanes 套用 receipt / replay / drift verifier 模式
2. 增加 scheduled automation health summaries
1. 將 auto-policy authorization guard 補齊 machine fetch evidence推進到 authorization decision preflight lane
2. 對其他 safe mapping backlog lanes 套用 receipt / replay / drift verifier 模式
3. 為每一類 controlled apply 自動產生 rollback evidence package。
4. 把 AI automation metrics 整合進既有 observability surfaces。
4. 把 AI automation metrics 持續整合進既有 observability surfaces。
完成標準:
@@ -327,7 +333,8 @@
| P3.1 | Extend receipt / replay / drift pattern to more lanes | 已完成 | direct mapping candidate decision lane closeout route + focused tests | P3.2 scheduled automation health summaries |
| P3.2 | Scheduled automation health summaries | 已完成 | `/api/ai-automation/scheduled-health-summary` + smoke service focused tests | P3.3 rollback evidence packages |
| P3.3 | Rollback evidence packages | 已完成 | controlled apply rollback evidence route + focused tests | P3.4 observability metrics integration |
| P3.4 | Observability metrics integration | 已完成 | `/metrics` exports scheduled health summary gauges + focused tests; AI surface HTML readback now feeds smoke and scheduled health | P4 source / deployment governance ongoing |
| P3.4 | Observability metrics integration | 已完成 | `/metrics` exports scheduled health summary gauges + focused tests; AI surface HTML readback now feeds smoke and scheduled health | P3.5 auto-policy guard monitoring |
| P3.5 | PChome auto-policy authorization guard monitoring | 已完成 | AI smoke + scheduled family + metrics family read no-write/no-secret/exception-only guard; focused tests | machine fetch evidence / authorization decision preflight lane |
| P4.1 | Source / deployment / runtime truth package | 已完成 | `scripts/ops/report_source_deploy_runtime_truth.py` + focused tests | 每次 Gitea push / production deploy 後執行 P4 report |
| P2.2 | Benchmark guardrails applied to core AI surfaces | 已完成 | `/ai_intelligence` + `/observability/overview` golden-signal strips + focused tests | 後續 safe automation lanes 套同樣 first-viewport summary |