diff --git a/config.py b/config.py index 027a052..9e2c5a1 100644 --- a/config.py +++ b/config.py @@ -402,7 +402,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.729" +SYSTEM_VERSION = "V10.730" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/docs/AI_INTELLIGENCE_MODULE_SOT.md b/docs/AI_INTELLIGENCE_MODULE_SOT.md index 042e0ae..2dea9a9 100644 --- a/docs/AI_INTELLIGENCE_MODULE_SOT.md +++ b/docs/AI_INTELLIGENCE_MODULE_SOT.md @@ -1,8 +1,8 @@ # PChome 業績成長自動化作戰系統 — AI 競價情報模組 Single Source of Truth > **最後更新**: 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、decision preflight machine evidence monitoring、decision closeout monitoring 與 authorization issuer gate monitoring 已建立,GCP embedding 熔斷延後處理、110 proxy rescue 與 direct host health skip 已建立 -> **適用版本**: V10.729 +> **狀態**: 🟢 四 AI Agent 自動化閉環已落地;LLM 路由紅線升級為 Ollama-first 三主機級聯;PChome 後台業績匯入韌性已補強;產品定位正名為「PChome 業績成長自動化作戰系統」;外部市場來源正規化層、自動同步、作戰清單與價格參考表優先讀取、CSV 備援預檢、前台操作入口、高可見頁面繁中化守門、比價/作戰 UI 工作台化、AI 密集工作台文字密度守門、跨平台來源治理、商品身份 UI 契約、sitewide visual QA runtime readback、PChome auto-policy authorization guard monitoring、decision preflight machine evidence monitoring、decision closeout monitoring、authorization issuer gate monitoring 與 signing decision preflight monitoring 已建立,GCP embedding 熔斷延後處理、110 proxy rescue 與 direct host health skip 已建立 +> **適用版本**: V10.730 --- @@ -245,6 +245,7 @@ SQL漏斗(~300筆) - `/api/ai-automation/smoke` 必須包含 `PChome auto-policy decision preflight`:以本機 deterministic machine evidence adapter 推進 `execute_fetch=True` 的 no-write decision preflight ready path,並明確回報 `payload_source=local_contract_fixture`、`machine_fetch_evidence_source=local_schema_fixture`、`outbound_network=false`、`business_data_source=false`、`writes_database_count=0`、`primary_human_gate_count=0`、`ready_for_database_apply_now=false`、`issues_database_apply_authorization=false`。此 check 不讀 secret、不執行 shell/SQL、不寫 DB、不使用外部 PChome 網路、不把 fixture 當商業資料;`/api/ai-automation/scheduled-health-summary` 需輸出 `pchome_auto_policy_decision_preflight` family,`/metrics` 需暴露對應 `momo_ai_automation_scheduled_health_family_status`。 - `/api/ai-automation/smoke` 必須包含 `PChome auto-policy decision closeout`:以本機 deterministic contract fixture 與 machine evidence adapter 推進 no-write decision closeout ready path,並明確回報 `post_apply_verifier_required_count=1`、`same_run_truth_required_count=1`、`payload_source=local_contract_fixture`、`outbound_network=false`、`business_data_source=false`、`writes_database_count=0`、`primary_human_gate_count=0`、`ready_for_database_apply_now=false`、`issues_database_apply_authorization=false`。此 check 不讀 secret、不執行 shell/SQL、不寫 DB、不發 apply authorization;`/api/ai-automation/scheduled-health-summary` 需輸出 `pchome_auto_policy_decision_closeout` family,`/metrics` 需暴露對應 `momo_ai_automation_scheduled_health_family_status`。 - `/api/ai-automation/smoke` 必須包含 `PChome auto-policy authorization issuer gate`:以本機 deterministic contract fixture 與 machine evidence adapter 推進 no-write issuer gate ready path,並明確回報 `required_issuer_evidence_count=9`、`nonsecret_authorization_claim_count=8`、`payload_source=local_contract_fixture`、`outbound_network=false`、`business_data_source=false`、`writes_database_count=0`、`signs_database_apply_authorization_count=0`、`primary_human_gate_count=0`、`ready_for_database_apply_now=false`、`issues_database_apply_authorization=false`、`signs_database_apply_authorization=false`、`secret_material_included=false`。此 check 不讀 secret、不執行 shell/SQL、不寫 DB、不簽發 apply authorization;`/api/ai-automation/scheduled-health-summary` 需輸出 `pchome_auto_policy_authorization_issuer_gate` family,`/metrics` 需暴露對應 `momo_ai_automation_scheduled_health_family_status`。 +- `/api/ai-automation/smoke` 必須包含 `PChome auto-policy signing decision preflight`:以本機 deterministic contract fixture 與 machine evidence adapter 推進 no-write signing decision preflight ready path,並明確回報 `signing_decision_input_requirement_count=10`、`signing_decision_rejection_reason_count=11`、`payload_source=local_contract_fixture`、`outbound_network=false`、`business_data_source=false`、`writes_database_count=0`、`signs_database_apply_authorization_count=0`、`primary_human_gate_count=0`、`ready_for_database_apply_now=false`、`issues_database_apply_authorization=false`、`signs_database_apply_authorization=false`、`secret_material_required_in_preview=false`。此 check 不讀 secret、不執行 shell/SQL、不寫 DB、不簽發 apply authorization;`/api/ai-automation/scheduled-health-summary` 需輸出 `pchome_auto_policy_signing_decision_preflight` family,`/metrics` 需暴露對應 `momo_ai_automation_scheduled_health_family_status`。 - 健康檢查 API 會將最近檢查結果保存到 JSONL,頁面顯示最近狀態趨勢。 - 健康檢查歷史支援 JSONL 匯出、清理與每日「正常 / 注意 / 嚴重」摘要。 - 健康檢查每日摘要支援手動 Telegram 推播,並由 `momo-scheduler` 每日 09:10 呼叫 `run_ai_smoke_daily_summary_task()`。 @@ -850,6 +851,7 @@ POSTGRES_HOST=momo-db | 2026-07-03 | PChome auto-policy decision preflight 必須有 machine evidence runtime monitoring | V10.727 起 `/api/ai-automation/smoke`、`/api/ai-automation/scheduled-health-summary` 與 `/metrics` 必須輸出 `PChome auto-policy decision preflight` / `pchome_auto_policy_decision_preflight`;此 runtime check 使用本機 deterministic schema evidence adapter 與 `payload_source=local_contract_fixture` 自動驗證 `execute_fetch=True` 的 decision preflight ready path,但明確標記 `outbound_network=false`、`business_data_source=false`、`writes_database_count=0`、`primary_human_gate_count=0`,不讀 secret、不執行 SQL、不寫 DB、不發 apply authorization。 | | 2026-07-03 | PChome auto-policy decision closeout 必須有 runtime monitoring | V10.728 起 `/api/ai-automation/smoke`、`/api/ai-automation/scheduled-health-summary` 與 `/metrics` 必須輸出 `PChome auto-policy decision closeout` / `pchome_auto_policy_decision_closeout`;此 runtime check 自動驗證 decision closeout ready path、post-apply verifier requirement、same-run production truth requirement 與 future authorization decision package,但明確標記 `writes_database_count=0`、`primary_human_gate_count=0`、`ready_for_database_apply_now=false`、`issues_database_apply_authorization=false`,不讀 secret、不執行 SQL、不寫 DB、不發 apply authorization。 | | 2026-07-03 | PChome auto-policy authorization issuer gate 必須有 runtime monitoring | V10.729 起 `/api/ai-automation/smoke`、`/api/ai-automation/scheduled-health-summary` 與 `/metrics` 必須輸出 `PChome auto-policy authorization issuer gate` / `pchome_auto_policy_authorization_issuer_gate`;此 runtime check 自動驗證 issuer gate ready path、required issuer evidence、nonsecret authorization claims 與 final nonsecret envelope,但明確標記 `writes_database_count=0`、`signs_database_apply_authorization_count=0`、`primary_human_gate_count=0`、`ready_for_database_apply_now=false`、`issues_database_apply_authorization=false`、`signs_database_apply_authorization=false`、`secret_material_included=false`,不讀 secret、不執行 SQL、不寫 DB、不簽發 apply authorization。 | +| 2026-07-03 | PChome auto-policy signing decision preflight 必須有 runtime monitoring | V10.730 起 `/api/ai-automation/smoke`、`/api/ai-automation/scheduled-health-summary` 與 `/metrics` 必須輸出 `PChome auto-policy signing decision preflight` / `pchome_auto_policy_signing_decision_preflight`;此 runtime check 自動驗證 signing decision preflight ready path、signing decision input requirements 與 rejection policy,但明確標記 `writes_database_count=0`、`signs_database_apply_authorization_count=0`、`primary_human_gate_count=0`、`ready_for_database_apply_now=false`、`issues_database_apply_authorization=false`、`signs_database_apply_authorization=false`、`secret_material_required_in_preview=false`,不讀 secret、不執行 SQL、不寫 DB、不簽發 apply authorization。 | | 2026-06-29 | PChome DB apply 授權 lane 必須先通過 no-write guard / decision preflight / decision closeout / issuer gate / signing-decision preflight / signing-decision closeout / signing-issuer guard | V10.725 的 PChome mapping backlog auto-policy 已新增 `/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-lane-guard`、`/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-decision-preflight`、`/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-decision-closeout`、`/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-issuer-gate`、`/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-signing-decision-preflight`、`/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-signing-decision-closeout` 與 `/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-signing-issuer-guard`;這些 endpoint 只驗證 final exact request package、same-run production truth requirement、secret rejection、rollback boundary、lane entry requirements、decision input requirements、rejection policy、post-apply verifier、future authorization decision package、final nonsecret authorization envelope、signing decision preflight inputs、unsigned signing decision package 與 signable request boundary,不讀 secret、不執行 shell/SQL、不寫 DB,也不簽發 database apply authorization。 | | 2026-06-29 | PChome DB apply 授權簽署發行者 lane 必須先產出 final signable request package | V10.725 的 PChome mapping backlog auto-policy 新增 `/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-signing-issuer-closeout`;此 endpoint 只把 signing-issuer guard 的 signable request boundary 收斂成 final signable request package 與 closeout contract,確認 fresh production truth、post-apply verifier、migration hash、secret boundary 與 no-side-effect checks,不讀 secret、不簽發 authorization、不執行 shell/SQL、不寫 DB,也不代表正式 DB apply 已授權。 | | 2026-06-29 | PChome DB apply 授權簽署執行 lane 必須先通過 operator-held secret boundary preflight | V10.725 的 PChome mapping backlog auto-policy 新增 `/api/ai/pchome-growth/mapping-backlog/auto-policy-db-apply-authorization-signing-execution-preflight`;此 endpoint 只把 final signable request package 轉成 future signing execution preflight package、operator-held secret boundary contract、nonsecret signing inputs、command-shape preview、rollback boundary 與 abort conditions,不讀 secret、不接受 plaintext secret、不簽發 authorization、不執行 shell/SQL、不寫 DB,也不代表正式 DB apply 已授權。 | diff --git a/docs/guides/pchome_ai_automation_priority_backlog.md b/docs/guides/pchome_ai_automation_priority_backlog.md index fa8901a..aac012c 100644 --- a/docs/guides/pchome_ai_automation_priority_backlog.md +++ b/docs/guides/pchome_ai_automation_priority_backlog.md @@ -9,7 +9,7 @@ 以下是使用者在主線推進期間插入、且必須保留在完整工作項目裡的要求。後續不得再把這些需求漏掉或變成口頭提醒。 1. 正式環境才是最新版本真相;不得用本機檔案、舊筆記、舊分支蓋過 production truth。 -2. 版本不得搞錯;目前正式環境 `/health` 版本維持 `V10.729`,除非有明確版本 bump、部署與 readback。 +2. 版本不得搞錯;目前正式環境 `/health` 版本維持 `V10.730`,除非有明確版本 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。 @@ -41,7 +41,7 @@ 已完成: -- 正式環境版本真相 guard:`/health` 是最高真相,目前維持 `V10.729`。 +- 正式環境版本真相 guard:`/health` 是最高真相,目前維持 `V10.730`。 - Gitea `dev` / `main` source truth 對齊。 - Retry exception controlled apply executor 已落地,目標表為 `pchome_product_matches`。 - 正式 DB 已 controlled apply 4 個 selectors: @@ -113,10 +113,17 @@ - `/api/ai-automation/scheduled-health-summary` 已輸出 `pchome_auto_policy_authorization_issuer_gate` family - `/metrics` 已輸出 `momo_ai_automation_scheduled_health_family_status{family="pchome_auto_policy_authorization_issuer_gate",...}` - 不讀 secret、不執行 SQL、不寫 DB、不簽發 apply authorization,下一個機器動作是 signing decision preflight lane +- PChome auto-policy signing decision preflight runtime monitoring 已完成: + - `/api/ai-automation/smoke` 已加入 `PChome auto-policy signing decision preflight` + - 以本機 contract fixture + machine evidence adapter 自動推進 signing decision preflight ready path + - 明確標記 `signing_decision_input_requirement_count=10`、`signing_decision_rejection_reason_count=11`、`writes_database_count=0`、`signs_database_apply_authorization_count=0`、`primary_human_gate_count=0` + - `/api/ai-automation/scheduled-health-summary` 已輸出 `pchome_auto_policy_signing_decision_preflight` family + - `/metrics` 已輸出 `momo_ai_automation_scheduled_health_family_status{family="pchome_auto_policy_signing_decision_preflight",...}` + - 不讀 secret、不執行 SQL、不寫 DB、不簽發 apply authorization,下一個機器動作是 signing decision closeout lane 進行中 / 下一步,必須照順序: -1. 將 auto-policy authorization issuer gate 往 signing decision preflight lane 推進。 +1. 將 auto-policy signing decision preflight 往 signing decision closeout lane 推進。 完成標準: @@ -283,7 +290,7 @@ 進行中 / 下一步,必須照順序: -1. 將 auto-policy authorization issuer gate 推進到 signing decision preflight lane。 +1. 將 auto-policy signing decision preflight 推進到 signing decision closeout lane。 2. 對其他 safe mapping backlog lanes 套用 receipt / replay / drift verifier 模式。 3. 為每一類 controlled apply 自動產生 rollback evidence package。 4. 把 AI automation metrics 持續整合進既有 observability surfaces。 @@ -358,7 +365,8 @@ | 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 | | P3.6 | PChome auto-policy machine evidence decision preflight monitoring | 已完成 | AI smoke + scheduled family + metrics family prove local contract fixture, no-network machine evidence, decision preflight ready, no DB write, no human primary gate | authorization decision closeout lane | | P3.7 | PChome auto-policy authorization decision closeout monitoring | 已完成 | AI smoke + scheduled family + metrics family prove decision closeout ready, post-apply verifier bound, same-run truth required, no DB write, no apply authorization | P3.8 authorization issuer gate monitoring | -| P3.8 | PChome auto-policy authorization issuer gate monitoring | 已完成 | AI smoke + scheduled family + metrics family prove issuer gate ready, nonsecret envelope bound, no DB write, no signing, no apply authorization | signing decision preflight lane | +| P3.8 | PChome auto-policy authorization issuer gate monitoring | 已完成 | AI smoke + scheduled family + metrics family prove issuer gate ready, nonsecret envelope bound, no DB write, no signing, no apply authorization | P3.9 signing decision preflight monitoring | +| P3.9 | PChome auto-policy signing decision preflight monitoring | 已完成 | AI smoke + scheduled family + metrics family prove signing decision preflight ready, signing inputs bound, no DB write, no signing, no apply authorization | signing decision closeout 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 | diff --git a/services/ai_automation_smoke_service.py b/services/ai_automation_smoke_service.py index 668bdbf..4b434f3 100644 --- a/services/ai_automation_smoke_service.py +++ b/services/ai_automation_smoke_service.py @@ -252,6 +252,14 @@ def build_scheduled_automation_health_summary( if not auto_policy_issuer_gate or not auto_policy_issuer_gate_details: auto_policy_issuer_gate = _pchome_auto_policy_authorization_issuer_gate_check() auto_policy_issuer_gate_details = auto_policy_issuer_gate.get("details") or {} + auto_policy_signing_preflight = _find_check( + source_result, + "PChome auto-policy signing decision preflight", + ) + auto_policy_signing_preflight_details = auto_policy_signing_preflight.get("details") or {} + if not auto_policy_signing_preflight or not auto_policy_signing_preflight_details: + auto_policy_signing_preflight = _pchome_auto_policy_signing_decision_preflight_check() + auto_policy_signing_preflight_details = auto_policy_signing_preflight.get("details") or {} surface_readback = _find_check(source_result, "AI surface HTML readback") surface_details = surface_readback.get("details") or {} sitewide_readback = _find_check(source_result, "Sitewide UI/UX Agent readback") @@ -570,6 +578,152 @@ def build_scheduled_automation_health_summary( "writes_database": False, }, }, + { + "key": "pchome_auto_policy_signing_decision_preflight", + "label": "PChome auto-policy signing decision preflight", + "status": auto_policy_signing_preflight.get("status") or "warning", + "summary": ( + auto_policy_signing_preflight.get("summary") + or "PChome auto-policy signing decision preflight has no latest check." + ), + "next_machine_action": auto_policy_signing_preflight_details.get( + "next_machine_action" + ) + or ( + "continue_pchome_auto_policy_signing_decision_preflight_monitoring" + if auto_policy_signing_preflight.get("status") == "ok" + else "refresh_pchome_auto_policy_signing_decision_preflight" + ), + "details": { + "policy": auto_policy_signing_preflight_details.get("policy"), + "result": auto_policy_signing_preflight_details.get("result"), + "signing_decision_preflight_ready_count": int( + auto_policy_signing_preflight_details.get( + "signing_decision_preflight_ready_count" + ) + or 0 + ), + "authorization_issuer_gate_ready_count": int( + auto_policy_signing_preflight_details.get( + "authorization_issuer_gate_ready_count" + ) + or 0 + ), + "signing_decision_preflight_check_count": int( + auto_policy_signing_preflight_details.get( + "signing_decision_preflight_check_count" + ) + or 0 + ), + "signing_decision_preflight_pass_count": int( + auto_policy_signing_preflight_details.get( + "signing_decision_preflight_pass_count" + ) + or 0 + ), + "signing_decision_preflight_waiting_count": int( + auto_policy_signing_preflight_details.get( + "signing_decision_preflight_waiting_count" + ) + or 0 + ), + "required_issuer_evidence_count": int( + auto_policy_signing_preflight_details.get( + "required_issuer_evidence_count" + ) + or 0 + ), + "nonsecret_authorization_claim_count": int( + auto_policy_signing_preflight_details.get( + "nonsecret_authorization_claim_count" + ) + or 0 + ), + "signing_decision_input_requirement_count": int( + auto_policy_signing_preflight_details.get( + "signing_decision_input_requirement_count" + ) + or 0 + ), + "signing_decision_rejection_reason_count": int( + auto_policy_signing_preflight_details.get( + "signing_decision_rejection_reason_count" + ) + or 0 + ), + "post_apply_verifier_required_count": int( + auto_policy_signing_preflight_details.get( + "post_apply_verifier_required_count" + ) + or 0 + ), + "same_run_truth_required_count": int( + auto_policy_signing_preflight_details.get( + "same_run_truth_required_count" + ) + or 0 + ), + "reads_secret_count": int( + auto_policy_signing_preflight_details.get("reads_secret_count") or 0 + ), + "executes_sql_count": int( + auto_policy_signing_preflight_details.get("executes_sql_count") or 0 + ), + "writes_database_count": int( + auto_policy_signing_preflight_details.get("writes_database_count") or 0 + ), + "signs_database_apply_authorization_count": int( + auto_policy_signing_preflight_details.get( + "signs_database_apply_authorization_count" + ) + or 0 + ), + "primary_human_gate_count": int( + auto_policy_signing_preflight_details.get("primary_human_gate_count") + or 0 + ), + "manual_review_mode": auto_policy_signing_preflight_details.get( + "manual_review_mode" + ), + "payload_source": auto_policy_signing_preflight_details.get("payload_source"), + "execute_fetch": bool( + auto_policy_signing_preflight_details.get("execute_fetch") + ), + "outbound_network": bool( + auto_policy_signing_preflight_details.get("outbound_network") + ), + "business_data_source": bool( + auto_policy_signing_preflight_details.get("business_data_source") + ), + "ready_for_database_apply_now": bool( + auto_policy_signing_preflight_details.get("ready_for_database_apply_now") + ), + "issues_database_apply_authorization": bool( + auto_policy_signing_preflight_details.get( + "issues_database_apply_authorization" + ) + ), + "signs_database_apply_authorization": bool( + auto_policy_signing_preflight_details.get( + "signs_database_apply_authorization" + ) + ), + "secret_material_required_in_preview": bool( + auto_policy_signing_preflight_details.get( + "secret_material_required_in_preview" + ) + ), + "allows_future_authorization_signing_decision_lane": bool( + auto_policy_signing_preflight_details.get( + "allows_future_authorization_signing_decision_lane" + ) + ), + "rejects_direct_database_apply": bool( + auto_policy_signing_preflight_details.get("rejects_direct_database_apply") + ), + "writes_database": False, + }, + }, { "key": "ai_surface_html_readback", "label": "AI surface HTML readback", @@ -1905,6 +2059,212 @@ def _pchome_auto_policy_authorization_issuer_gate_check() -> Dict[str, Any]: ) +def _pchome_auto_policy_signing_decision_preflight_check() -> Dict[str, Any]: + """Read-only monitor for the no-secret authorization signing decision preflight.""" + try: + from services import pchome_mapping_backlog_service as backlog + from services.ai_exception_contract import ( + LEGACY_REVIEW_REQUIRED_COUNT_KEY, + PRIMARY_HUMAN_GATE_COUNT_KEY, + ) + + payload = _pchome_auto_policy_decision_preflight_contract_payload() + preflight = ( + backlog.build_pchome_auto_policy_db_apply_authorization_signing_decision_preflight( + payload, + batch_size=max(1, min(_PCHOME_AUTO_POLICY_DECISION_PREFLIGHT_BATCH_SIZE, 50)), + execute_fetch=True, + timeout_seconds=max( + 1, + min(_PCHOME_AUTO_POLICY_DECISION_PREFLIGHT_TIMEOUT_SECONDS, 30), + ), + http_get=_pchome_auto_policy_machine_fetch_evidence_get, + ) + ) + summary = preflight.get("summary") or {} + decision = preflight.get("future_authorization_signing_decision_preflight") or {} + envelope = preflight.get("signing_decision_preflight_envelope") or {} + safety = preflight.get("safety") or {} + result = str(preflight.get("result") or "UNKNOWN") + + preflight_ready_count = int( + summary.get("authorization_signing_decision_preflight_ready_count") or 0 + ) + issuer_ready_count = int(summary.get("authorization_issuer_gate_ready_count") or 0) + check_count = int(summary.get("signing_decision_preflight_check_count") or 0) + pass_count = int(summary.get("signing_decision_preflight_pass_count") or 0) + waiting_count = int(summary.get("signing_decision_preflight_waiting_count") or 0) + issuer_check_count = int(summary.get("issuer_gate_check_count") or 0) + required_evidence_count = int(summary.get("required_issuer_evidence_count") or 0) + nonsecret_claim_count = int(summary.get("nonsecret_authorization_claim_count") or 0) + input_requirement_count = int( + summary.get("signing_decision_input_requirement_count") or 0 + ) + rejection_reason_count = int( + summary.get("signing_decision_rejection_reason_count") or 0 + ) + verifier_required_count = int(summary.get("post_apply_verifier_required_count") or 0) + same_run_truth_count = int(summary.get("same_run_truth_required_count") or 0) + reads_secret_count = int(summary.get("reads_secret_count") or 0) + executes_sql_count = int(summary.get("executes_sql_count") or 0) + writes_database_count = int(summary.get("writes_database_count") or 0) + signs_database_apply_authorization_count = int( + summary.get("signs_database_apply_authorization_count") or 0 + ) + primary_human_gate_count = int(summary.get(PRIMARY_HUMAN_GATE_COUNT_KEY) or 0) + manual_review_required_count = int(summary.get(LEGACY_REVIEW_REQUIRED_COUNT_KEY) or 0) + side_effect_count = ( + reads_secret_count + + executes_sql_count + + writes_database_count + + signs_database_apply_authorization_count + ) + risk_detected = any( + [ + side_effect_count, + primary_human_gate_count, + manual_review_required_count, + safety.get("reads_secret_in_preview") is not False, + safety.get("executes_script") is not False, + safety.get("executes_sql") is not False, + safety.get("writes_database") is not False, + safety.get("signs_database_apply_authorization") is not False, + decision.get("ready_for_database_apply_now") is not False, + decision.get("issues_database_apply_authorization") is not False, + decision.get("signs_database_apply_authorization") is not False, + envelope.get("ready_for_database_apply_now") is not False, + envelope.get("issues_database_apply_authorization") is not False, + envelope.get("signs_database_apply_authorization") is not False, + envelope.get("secret_material_required_in_preview") is not False, + ] + ) + preflight_contract_present = ( + preflight_ready_count == 1 + and issuer_ready_count == 1 + and check_count >= 12 + and pass_count == check_count + and waiting_count == 0 + and issuer_check_count == 12 + and required_evidence_count == 9 + and nonsecret_claim_count == 8 + and input_requirement_count == 10 + and rejection_reason_count == 11 + and verifier_required_count == 1 + and same_run_truth_count == 1 + and decision.get("ready_for_future_signing_decision_preflight") is True + and decision.get("can_enter_authorization_signing_decision_lane") is True + and envelope.get("machine_verifiable") is True + and envelope.get("allows_future_authorization_signing_decision_lane") is True + and envelope.get("rejects_direct_database_apply") is True + and envelope.get("requires_post_apply_verifier") is True + and safety.get("manual_review_mode") == "exception_only" + ) + + if risk_detected: + status = "critical" + summary_text = ( + "PChome auto-policy signing decision preflight 偵測到 secret、SQL、DB write、" + "簽發授權或人工主 gate 風險" + ) + next_machine_action = ( + "halt_pchome_auto_policy_signing_decision_preflight_and_inspect_risk" + ) + elif preflight_contract_present: + status = "ok" + summary_text = ( + "PChome auto-policy signing decision preflight 已自動完成 " + f"{pass_count}/{check_count} checks,signing inputs 已綁定,authorization signing=0" + ) + next_machine_action = ( + "continue_to_pchome_auto_policy_signing_decision_closeout_lane" + ) + else: + status = "warning" + summary_text = "PChome auto-policy signing decision preflight 尚未達自動監控契約" + next_machine_action = "refresh_pchome_auto_policy_signing_decision_preflight" + + return _check( + "PChome auto-policy signing decision preflight", + status, + summary_text, + { + "policy": preflight.get("policy"), + "result": result, + "source_policy": preflight.get("source_policy"), + "signing_decision_preflight_ready_count": preflight_ready_count, + "authorization_issuer_gate_ready_count": issuer_ready_count, + "signing_decision_preflight_check_count": check_count, + "signing_decision_preflight_pass_count": pass_count, + "signing_decision_preflight_waiting_count": waiting_count, + "issuer_gate_check_count": issuer_check_count, + "required_issuer_evidence_count": required_evidence_count, + "nonsecret_authorization_claim_count": nonsecret_claim_count, + "signing_decision_input_requirement_count": input_requirement_count, + "signing_decision_rejection_reason_count": rejection_reason_count, + "post_apply_verifier_required_count": verifier_required_count, + "same_run_truth_required_count": same_run_truth_count, + "reads_secret_count": reads_secret_count, + "executes_sql_count": executes_sql_count, + "writes_database_count": writes_database_count, + "signs_database_apply_authorization_count": ( + signs_database_apply_authorization_count + ), + "primary_human_gate_count": primary_human_gate_count, + "manual_review_required_count": manual_review_required_count, + "manual_review_mode": safety.get("manual_review_mode"), + "payload_source": "local_contract_fixture", + "machine_fetch_evidence_source": "local_schema_fixture", + "http_get_adapter": "_pchome_auto_policy_machine_fetch_evidence_get", + "execute_fetch": True, + "outbound_network": False, + "business_data_source": False, + "ready_for_database_apply_now": bool( + decision.get("ready_for_database_apply_now") + or envelope.get("ready_for_database_apply_now") + ), + "issues_database_apply_authorization": bool( + decision.get("issues_database_apply_authorization") + or envelope.get("issues_database_apply_authorization") + ), + "signs_database_apply_authorization": bool( + decision.get("signs_database_apply_authorization") + or envelope.get("signs_database_apply_authorization") + ), + "secret_material_required_in_preview": bool( + envelope.get("secret_material_required_in_preview") + ), + "allows_future_authorization_signing_decision_lane": bool( + envelope.get("allows_future_authorization_signing_decision_lane") + ), + "rejects_direct_database_apply": bool( + envelope.get("rejects_direct_database_apply") + ), + "requires_post_apply_verifier": bool( + envelope.get("requires_post_apply_verifier") + ), + "writes_database": False, + "next_machine_action": next_machine_action, + }, + ) + except Exception as exc: + return _check( + "PChome auto-policy signing decision preflight", + "warning", + f"PChome auto-policy signing decision preflight 例行監控暫時無法讀取:{exc}", + { + "writes_database": False, + "writes_database_count": 0, + "signs_database_apply_authorization_count": 0, + "primary_human_gate_count": 0, + "execute_fetch": True, + "outbound_network": False, + "business_data_source": False, + "payload_source": "local_contract_fixture", + "next_machine_action": "refresh_pchome_auto_policy_signing_decision_preflight", + }, + ) + + def _ai_surface_html_readback_check() -> Dict[str, Any]: """Read-only AI product surface guardrail readback.""" try: @@ -2136,6 +2496,7 @@ def collect_ai_automation_smoke(*, record_history: bool = True, history_limit: i _pchome_auto_policy_decision_preflight_check(), _pchome_auto_policy_decision_closeout_check(), _pchome_auto_policy_authorization_issuer_gate_check(), + _pchome_auto_policy_signing_decision_preflight_check(), _ai_surface_html_readback_check(), _sitewide_ui_ux_agent_check(), _sitewide_visual_qa_check(), diff --git a/tests/test_ai_automation_metrics.py b/tests/test_ai_automation_metrics.py index 49ef5c9..d8c6902 100644 --- a/tests/test_ai_automation_metrics.py +++ b/tests/test_ai_automation_metrics.py @@ -107,10 +107,10 @@ def test_system_metrics_exports_scheduled_health_summary(): Gauge, { "summary": { - "ok": 8, + "ok": 9, "warning": 1, "critical": 0, - "total": 9, + "total": 10, "primary_human_gate_count": 0, "writes_database_count": 0, }, @@ -121,6 +121,7 @@ def test_system_metrics_exports_scheduled_health_summary(): {"key": "pchome_auto_policy_decision_preflight", "status": "ok"}, {"key": "pchome_auto_policy_decision_closeout", "status": "ok"}, {"key": "pchome_auto_policy_authorization_issuer_gate", "status": "ok"}, + {"key": "pchome_auto_policy_signing_decision_preflight", "status": "ok"}, {"key": "sitewide_ui_ux_agent", "status": "ok"}, {"key": "sitewide_visual_qa", "status": "ok"}, ], @@ -128,7 +129,7 @@ def test_system_metrics_exports_scheduled_health_summary(): ) output = generate_latest(registry).decode("utf-8") - assert 'momo_ai_automation_scheduled_health_summary_total{status="ok"} 8.0' in output + assert 'momo_ai_automation_scheduled_health_summary_total{status="ok"} 9.0' in output assert 'momo_ai_automation_scheduled_health_summary_total{status="warning"} 1.0' in output assert ( 'momo_ai_automation_scheduled_health_family_status{family="ai_automation_smoke",status="ok"} 1.0' @@ -154,6 +155,10 @@ def test_system_metrics_exports_scheduled_health_summary(): 'momo_ai_automation_scheduled_health_family_status{family="pchome_auto_policy_authorization_issuer_gate",status="ok"} 1.0' in output ) + assert ( + 'momo_ai_automation_scheduled_health_family_status{family="pchome_auto_policy_signing_decision_preflight",status="ok"} 1.0' + in output + ) assert ( 'momo_ai_automation_scheduled_health_family_status{family="sitewide_ui_ux_agent",status="ok"} 1.0' in output diff --git a/tests/test_ai_automation_smoke_service.py b/tests/test_ai_automation_smoke_service.py index 1a932ba..5e77d01 100644 --- a/tests/test_ai_automation_smoke_service.py +++ b/tests/test_ai_automation_smoke_service.py @@ -133,6 +133,51 @@ def _auto_policy_authorization_issuer_gate_history_check(status="ok"): } +def _auto_policy_signing_decision_preflight_history_check(status="ok"): + return { + "name": "PChome auto-policy signing decision preflight", + "status": status, + "summary": "PChome auto-policy signing decision preflight 已自動完成", + "details": { + "policy": ( + "read_only_pchome_growth_auto_policy_db_apply_authorization_" + "signing_decision_preflight" + ), + "result": "DB_APPLY_AUTHORIZATION_SIGNING_DECISION_PREFLIGHT_READY", + "signing_decision_preflight_ready_count": 1, + "authorization_issuer_gate_ready_count": 1, + "signing_decision_preflight_check_count": 12, + "signing_decision_preflight_pass_count": 12, + "signing_decision_preflight_waiting_count": 0, + "required_issuer_evidence_count": 9, + "nonsecret_authorization_claim_count": 8, + "signing_decision_input_requirement_count": 10, + "signing_decision_rejection_reason_count": 11, + "post_apply_verifier_required_count": 1, + "same_run_truth_required_count": 1, + "reads_secret_count": 0, + "executes_sql_count": 0, + "writes_database_count": 0, + "signs_database_apply_authorization_count": 0, + "primary_human_gate_count": 0, + "manual_review_mode": "exception_only", + "payload_source": "local_contract_fixture", + "execute_fetch": True, + "outbound_network": False, + "business_data_source": False, + "ready_for_database_apply_now": False, + "issues_database_apply_authorization": False, + "signs_database_apply_authorization": False, + "secret_material_required_in_preview": False, + "allows_future_authorization_signing_decision_lane": True, + "rejects_direct_database_apply": True, + "next_machine_action": ( + "continue_to_pchome_auto_policy_signing_decision_closeout_lane" + ), + }, + } + + def test_event_router_smoke_reports_queued_deliveries(tmp_path, monkeypatch): from services import ai_automation_metrics as metrics from services import ai_automation_smoke_service as smoke @@ -172,6 +217,7 @@ def test_collect_ai_automation_smoke_uses_worst_status(monkeypatch): monkeypatch.setattr(smoke, "_pchome_auto_policy_decision_preflight_check", lambda: smoke._check("auto-policy preflight", "ok", "ok")) monkeypatch.setattr(smoke, "_pchome_auto_policy_decision_closeout_check", lambda: smoke._check("auto-policy closeout", "ok", "ok")) monkeypatch.setattr(smoke, "_pchome_auto_policy_authorization_issuer_gate_check", lambda: smoke._check("auto-policy issuer", "ok", "ok")) + monkeypatch.setattr(smoke, "_pchome_auto_policy_signing_decision_preflight_check", lambda: smoke._check("auto-policy signing preflight", "ok", "ok")) monkeypatch.setattr(smoke, "_ai_surface_html_readback_check", lambda: smoke._check("surface", "ok", "ok")) monkeypatch.setattr(smoke, "_sitewide_ui_ux_agent_check", lambda: smoke._check("sitewide", "ok", "ok")) monkeypatch.setattr(smoke, "_sitewide_visual_qa_check", lambda: smoke._check("visual", "ok", "ok")) @@ -179,7 +225,7 @@ def test_collect_ai_automation_smoke_uses_worst_status(monkeypatch): result = smoke.collect_ai_automation_smoke(record_history=False) assert result["status"] == "critical" - assert result["summary"] == {"ok": 12, "warning": 1, "critical": 1, "total": 14} + assert result["summary"] == {"ok": 13, "warning": 1, "critical": 1, "total": 15} def test_pchome_controlled_apply_drift_monitor_reports_verified_zero_drift(monkeypatch): @@ -538,6 +584,98 @@ def test_pchome_auto_policy_authorization_issuer_gate_reports_no_write_nonsecret ) +def test_pchome_auto_policy_signing_decision_preflight_reports_no_write_no_signing(monkeypatch): + from services import ai_automation_smoke_service as smoke + from services import pchome_mapping_backlog_service as backlog + captured = {} + + def fake_preflight(*_args, **kwargs): + captured.update(kwargs) + return { + "policy": ( + "read_only_pchome_growth_auto_policy_db_apply_authorization_" + "signing_decision_preflight" + ), + "result": "DB_APPLY_AUTHORIZATION_SIGNING_DECISION_PREFLIGHT_READY", + "source_policy": "read_only_pchome_growth_auto_policy_db_apply_authorization_issuer_gate", + "summary": { + "authorization_signing_decision_preflight_ready_count": 1, + "authorization_issuer_gate_ready_count": 1, + "signing_decision_preflight_check_count": 12, + "signing_decision_preflight_pass_count": 12, + "signing_decision_preflight_waiting_count": 0, + "issuer_gate_check_count": 12, + "required_issuer_evidence_count": 9, + "nonsecret_authorization_claim_count": 8, + "signing_decision_input_requirement_count": 10, + "signing_decision_rejection_reason_count": 11, + "post_apply_verifier_required_count": 1, + "same_run_truth_required_count": 1, + "reads_secret_count": 0, + "executes_sql_count": 0, + "writes_database_count": 0, + "signs_database_apply_authorization_count": 0, + "primary_human_gate_count": 0, + "manual_review_required_count": 0, + }, + "future_authorization_signing_decision_preflight": { + "ready_for_future_signing_decision_preflight": True, + "can_enter_authorization_signing_decision_lane": True, + "ready_for_database_apply_now": False, + "issues_database_apply_authorization": False, + "signs_database_apply_authorization": False, + }, + "signing_decision_preflight_envelope": { + "machine_verifiable": True, + "allows_future_authorization_signing_decision_lane": True, + "issues_database_apply_authorization": False, + "ready_for_database_apply_now": False, + "signs_database_apply_authorization": False, + "rejects_direct_database_apply": True, + "requires_post_apply_verifier": True, + "secret_material_required_in_preview": False, + }, + "safety": { + "reads_secret_in_preview": False, + "executes_script": False, + "executes_sql": False, + "writes_database": False, + "signs_database_apply_authorization": False, + "manual_review_mode": "exception_only", + }, + } + + monkeypatch.setattr( + backlog, + "build_pchome_auto_policy_db_apply_authorization_signing_decision_preflight", + fake_preflight, + ) + + result = smoke._pchome_auto_policy_signing_decision_preflight_check() + + assert result["status"] == "ok" + assert captured["execute_fetch"] is True + assert captured["http_get"] is smoke._pchome_auto_policy_machine_fetch_evidence_get + assert result["details"]["signing_decision_preflight_pass_count"] == 12 + assert result["details"]["signing_decision_input_requirement_count"] == 10 + assert result["details"]["signing_decision_rejection_reason_count"] == 11 + assert result["details"]["payload_source"] == "local_contract_fixture" + assert result["details"]["machine_fetch_evidence_source"] == "local_schema_fixture" + assert result["details"]["outbound_network"] is False + assert result["details"]["business_data_source"] is False + assert result["details"]["primary_human_gate_count"] == 0 + assert result["details"]["writes_database_count"] == 0 + assert result["details"]["signs_database_apply_authorization_count"] == 0 + assert result["details"]["issues_database_apply_authorization"] is False + assert result["details"]["signs_database_apply_authorization"] is False + assert result["details"]["secret_material_required_in_preview"] is False + assert result["details"]["allows_future_authorization_signing_decision_lane"] is True + assert result["details"]["rejects_direct_database_apply"] is True + assert result["details"]["next_machine_action"] == ( + "continue_to_pchome_auto_policy_signing_decision_closeout_lane" + ) + + def test_collect_ai_automation_smoke_persists_recent_history(tmp_path, monkeypatch): from services import ai_automation_smoke_service as smoke @@ -555,6 +693,7 @@ def test_collect_ai_automation_smoke_persists_recent_history(tmp_path, monkeypat monkeypatch.setattr(smoke, "_pchome_auto_policy_decision_preflight_check", lambda: smoke._check("auto-policy preflight", "ok", "ok")) monkeypatch.setattr(smoke, "_pchome_auto_policy_decision_closeout_check", lambda: smoke._check("auto-policy closeout", "ok", "ok")) monkeypatch.setattr(smoke, "_pchome_auto_policy_authorization_issuer_gate_check", lambda: smoke._check("auto-policy issuer", "ok", "ok")) + monkeypatch.setattr(smoke, "_pchome_auto_policy_signing_decision_preflight_check", lambda: smoke._check("auto-policy signing preflight", "ok", "ok")) monkeypatch.setattr(smoke, "_ai_surface_html_readback_check", lambda: smoke._check("surface", "ok", "ok")) monkeypatch.setattr(smoke, "_sitewide_ui_ux_agent_check", lambda: smoke._check("sitewide", "ok", "ok")) monkeypatch.setattr(smoke, "_sitewide_visual_qa_check", lambda: smoke._check("visual", "ok", "ok")) @@ -613,7 +752,7 @@ def test_scheduled_automation_health_summary_reads_history_without_side_effects( json.dumps({ "generated_at": datetime.now().isoformat(timespec="seconds"), "status": "ok", - "summary": {"ok": 14, "warning": 0, "critical": 0, "total": 14}, + "summary": {"ok": 15, "warning": 0, "critical": 0, "total": 15}, "checks": [ { "name": "PChome 受控落地 drift monitor", @@ -631,6 +770,7 @@ def test_scheduled_automation_health_summary_reads_history_without_side_effects( _auto_policy_decision_preflight_history_check(), _auto_policy_decision_closeout_history_check(), _auto_policy_authorization_issuer_gate_history_check(), + _auto_policy_signing_decision_preflight_history_check(), { "name": "AI surface HTML readback", "status": "ok", @@ -692,7 +832,7 @@ def test_scheduled_automation_health_summary_reads_history_without_side_effects( ) assert summary["policy"] == "read_only_ai_automation_scheduled_health_summary" assert summary["status"] == "ok" - assert summary["summary"]["total"] == 11 + assert summary["summary"]["total"] == 12 assert summary["summary"]["primary_human_gate_count"] == 0 assert summary["summary"]["writes_database_count"] == 0 assert pchome_family["status"] == "ok" @@ -746,6 +886,22 @@ def test_scheduled_automation_health_summary_reads_history_without_side_effects( assert issuer_family["details"]["signs_database_apply_authorization_count"] == 0 assert issuer_family["details"]["signs_database_apply_authorization"] is False assert issuer_family["details"]["secret_material_included"] is False + signing_preflight_family = next( + item for item in summary["families"] + if item["key"] == "pchome_auto_policy_signing_decision_preflight" + ) + assert signing_preflight_family["status"] == "ok" + assert signing_preflight_family["details"]["signing_decision_preflight_pass_count"] == 12 + assert signing_preflight_family["details"]["signing_decision_input_requirement_count"] == 10 + assert signing_preflight_family["details"]["signing_decision_rejection_reason_count"] == 11 + assert signing_preflight_family["details"]["payload_source"] == "local_contract_fixture" + assert signing_preflight_family["details"]["outbound_network"] is False + assert signing_preflight_family["details"]["business_data_source"] is False + assert signing_preflight_family["details"]["primary_human_gate_count"] == 0 + assert signing_preflight_family["details"]["writes_database_count"] == 0 + assert signing_preflight_family["details"]["signs_database_apply_authorization_count"] == 0 + assert signing_preflight_family["details"]["signs_database_apply_authorization"] is False + assert signing_preflight_family["details"]["secret_material_required_in_preview"] is False surface_family = next( item for item in summary["families"] if item["key"] == "ai_surface_html_readback" @@ -780,7 +936,7 @@ def test_scheduled_automation_health_summary_can_use_current_smoke_without_recor current_smoke = { "generated_at": "2026-07-02T12:00:00", "status": "critical", - "summary": {"ok": 13, "warning": 0, "critical": 1, "total": 14}, + "summary": {"ok": 14, "warning": 0, "critical": 1, "total": 15}, "checks": [ { "name": "PChome 受控落地 drift monitor", @@ -792,6 +948,7 @@ def test_scheduled_automation_health_summary_can_use_current_smoke_without_recor _auto_policy_decision_preflight_history_check(), _auto_policy_decision_closeout_history_check(), _auto_policy_authorization_issuer_gate_history_check(), + _auto_policy_signing_decision_preflight_history_check(), { "name": "AI surface HTML readback", "status": "ok", @@ -847,7 +1004,7 @@ def test_scheduled_automation_health_summary_falls_back_to_visual_qa_artifact(tm json.dumps({ "generated_at": datetime.now().isoformat(timespec="seconds"), "status": "ok", - "summary": {"ok": 12, "warning": 0, "critical": 0, "total": 12}, + "summary": {"ok": 13, "warning": 0, "critical": 0, "total": 13}, "checks": [], }, ensure_ascii=False) + "\n", encoding="utf-8", @@ -873,6 +1030,11 @@ def test_scheduled_automation_health_summary_falls_back_to_visual_qa_artifact(tm "_pchome_auto_policy_authorization_issuer_gate_check", lambda: _auto_policy_authorization_issuer_gate_history_check(), ) + monkeypatch.setattr( + smoke, + "_pchome_auto_policy_signing_decision_preflight_check", + lambda: _auto_policy_signing_decision_preflight_history_check(), + ) monkeypatch.setattr( surface_service, "build_sitewide_visual_qa_readback", @@ -921,7 +1083,7 @@ def test_scheduled_automation_health_summary_route_returns_compact_payload(tmp_p json.dumps({ "generated_at": datetime.now().isoformat(timespec="seconds"), "status": "ok", - "summary": {"ok": 13, "warning": 0, "critical": 0, "total": 13}, + "summary": {"ok": 14, "warning": 0, "critical": 0, "total": 14}, "checks": [], }, ensure_ascii=False) + "\n", encoding="utf-8", @@ -947,6 +1109,11 @@ def test_scheduled_automation_health_summary_route_returns_compact_payload(tmp_p "_pchome_auto_policy_authorization_issuer_gate_check", lambda: _auto_policy_authorization_issuer_gate_history_check(), ) + monkeypatch.setattr( + smoke, + "_pchome_auto_policy_signing_decision_preflight_check", + lambda: _auto_policy_signing_decision_preflight_history_check(), + ) app = Flask(__name__) with app.test_request_context( @@ -1174,6 +1341,7 @@ def test_surface_html_readback_check_is_part_of_ai_smoke(monkeypatch): monkeypatch.setattr(smoke, "_pchome_auto_policy_decision_preflight_check", lambda: smoke._check("auto-policy preflight", "ok", "ok")) monkeypatch.setattr(smoke, "_pchome_auto_policy_decision_closeout_check", lambda: smoke._check("auto-policy closeout", "ok", "ok")) monkeypatch.setattr(smoke, "_pchome_auto_policy_authorization_issuer_gate_check", lambda: smoke._check("auto-policy issuer", "ok", "ok")) + monkeypatch.setattr(smoke, "_pchome_auto_policy_signing_decision_preflight_check", lambda: smoke._check("auto-policy signing preflight", "ok", "ok")) monkeypatch.setattr(smoke, "_sitewide_visual_qa_check", lambda: smoke._check( "Sitewide visual QA readback", "ok", @@ -1195,7 +1363,7 @@ def test_surface_html_readback_check_is_part_of_ai_smoke(monkeypatch): item for item in result["checks"] if item["name"] == "Sitewide visual QA readback" ) - assert result["summary"]["total"] == 14 + assert result["summary"]["total"] == 15 assert surface_check["status"] == "ok" assert surface_check["details"]["checked_surface_count"] == 10 assert sitewide_check["status"] == "ok"