V10.507 接入 Webcrumbs 並收斂 writer approval gate
All checks were successful
CD Pipeline / deploy (push) Successful in 1m21s

This commit is contained in:
OoO
2026-05-31 18:56:13 +08:00
parent b347aa44b9
commit 72ded9e1e5
26 changed files with 2100 additions and 235 deletions

View File

@@ -176,6 +176,7 @@ EwoooC 目前已有 MOMO EDM / 節慶活動資料、`promo_products`、PChome
- 2026-05-31 追加 MCP fetch candidate queue writer review handoff gate`services.market_intel.mcp_fetch_candidate_queue_writer_review_handoff``/api/market_intel/mcp_fetch_candidate_queue_writer_review_handoff` 在 post-closeout inventory review 通過後審核 operator candidate queue review handoff 摘要,檢查 inventory linkage、handoff identity、target table、row count、artifact paths、review contract、forbidden API actions 與 operator confirmationsAPI/UI 不讀 approval token、不執行 CLI、不開 DB、不寫 queue、不更新 review_state、不掛 scheduler只放行到人工 candidate queue review。
- 2026-05-31 追加 MCP fetch candidate queue writer review inventory gate`services.market_intel.mcp_fetch_candidate_queue_writer_review_inventory``services.market_intel.mcp_fetch_candidate_queue_writer_review_inventory_gates``services.market_intel.mcp_fetch_candidate_queue_writer_review_inventory_sample``/api/market_intel/mcp_fetch_candidate_queue_writer_review_inventory` 在 writer review handoff 通過後審核 operator read-only candidate queue inventory 摘要,檢查 handoff identity、target table、row count、dedupe keys、review_state、artifact paths、read-only query result、missing/duplicate rows 與 operator confirmationsAPI/UI 不讀 approval token、不執行 CLI、不開 DB、不寫 queue、不更新 review_state、不做 inventory query、不掛 scheduler只放行到後續人工 candidate queue review。
- 2026-05-31 追加 MCP fetch candidate queue writer review decision gate`services.market_intel.mcp_fetch_candidate_queue_writer_review_decision``services.market_intel.mcp_fetch_candidate_queue_writer_review_decision_gates``services.market_intel.mcp_fetch_candidate_queue_writer_review_decision_sample``/api/market_intel/mcp_fetch_candidate_queue_writer_review_decision` 在 review inventory 通過後審核 operator candidate queue review decision 摘要,檢查 decision identity、target table、row count、dedupe keys、`needs_review` 現態、允許決策集合、evidence refs、matched row exact-identity/variant/overwrite guard、operator confirmations 與 forbidden API actionsAPI/UI 不讀 approval token、不執行 CLI、不開 DB、不寫 decision record、不更新 review_state、不寫 match result、不補 queue、不掛 scheduler只放行到 decision approval / writer preflight 設計。
- 2026-05-31 追加 MCP fetch candidate queue writer review decision approval gate`services.market_intel.mcp_fetch_candidate_queue_writer_review_decision_approval``services.market_intel.mcp_fetch_candidate_queue_writer_review_decision_approval_gates``services.market_intel.mcp_fetch_candidate_queue_writer_review_decision_approval_sample``/api/market_intel/mcp_fetch_candidate_queue_writer_review_decision_approval` 在 review decision 通過後只審核 operator human approval 摘要,確認 decision linkage、approval identity、target table、row count、dedupe keys、`approved_for_writer_preflight` approval result、decision/approval evidence refs、artifact paths、matched row exact-identity/variant/overwrite guard、operator confirmations 與 forbidden API actionsAPI/UI 不讀 approval token、不執行 CLI、不開 DB、不寫 approval record、不寫 decision record、不更新 review_state、不寫 match result、不補 queue、不掛 scheduler只放行到後續 writer preflight 設計。此 endpoint 已拆入 `routes.market_intel_mcp_review_routes`,避免 `routes.market_intel_mcp_run_routes` 超過 800 行治理門檻。
- 2026-05-18 追加 scheduler attach plan preview`services.market_intel.scheduler_plan``/api/market_intel/scheduler_plan` 描述未來 `campaign_discovery_daily``campaign_product_probe``product_match_review_seed` 三個 job 的 cadence、gate、fallback 與安全邊界。此階段不註冊 scheduler job、不啟動 crawler、不連外、不寫 DB排程掛載必須等 migration、seed、MCP fetch gate、manual sample 與人工批准全過。
- 2026-05-18 追加 match review plan preview`services.market_intel.match_review_plan``/api/market_intel/match_review_plan` 定義商品比對訊號、分數門檻、`needs_review → confirmed/rejected` HITL 流程與安全邊界。此階段不建立 review queue、不自動 confirmed、不寫 `market_product_matches`、不呼叫 MCP價格只能作為輔助訊號不能單獨決定同品比對。
- 2026-05-18 追加 opportunity plan preview`services.market_intel.opportunity_plan``/api/market_intel/opportunity_plan` 定義競品低價威脅、促銷缺口、深折重疊、活動即將結束四類規則與分級策略。此階段不建立 opportunity queue、不派送 Telegram、不產生 AI 摘要、不寫 DB高風險項必須先有 confirmed match 與 DB evidence 才能升級。

View File

@@ -0,0 +1,44 @@
# ADR-037: Webcrumbs 共用 UI Runtime 接入
Status: Accepted
Date: 2026-05-31
## Context
momo-pro 的前端已進入 V2/V3 視覺治理階段,後續會需要更穩定的跨頁 UI 元件、microfrontend/plugin loader 與跨專案視覺實驗入口。Webcrumbs 可作為共用 UI runtime但若各專案各自引用官方 CDN、使用 `@latest`,或把上游 repo 整包放進 momo-pro會造成供應鏈、版本漂移、授權與生產可控性風險。
本專案目前仍以 Flask/Jinja 為正式 runtime不能因導入外部 UI runtime 而繞過既有登入、CSRF、health check、部署與真實資料不退化紅線。
## Decision
Webcrumbs 在 momo-pro 中只作為「自架、固定版本、可診斷」的共用 UI runtime/plugin loader不作為主前端框架替代品。
採用以下規則:
1. runtime 由 `WEBCRUMBS_*` 環境變數設定,預設指向 `https://webcrumbs.wooo.work/runtime/@v0.1.5`
2. `ewoooc_base.html` 只在 `WEBCRUMBS_ENABLED=true` 且 runtime URL 通過 http(s) 檢查時輸出 script。
3. 新增 `/webcrumbs` 診斷入口,只顯示 runtime URL、版本與 plugin base 狀態,不連到外部官方站作為正式入口。
4. Webcrumbs plugin 必須使用自架且版本化 URI例如 `https://webcrumbs.wooo.work/plugins/momo-pro/<plugin>/<version>/`
5. 禁止在生產使用官方 `@latest``app.webcrumbs.ai` 或未固定版本的官方 CDN。
6. 不把 Webcrumbs 上游 repo 整包納入 momo-pro 主服務;若修改 runtime 本體,需另外處理 AGPL-3.0 授權義務。
## Alternatives Considered
### A. 每個頁面自行引用官方 Webcrumbs CDN
拒絕。版本不可控,且容易讓正式頁面受外部服務可用性與上游 breaking change 影響。
### B. 把 Webcrumbs repo vendoring 到 momo-pro
拒絕。這會增加主服務體積、授權治理與升級成本,也會讓 UI runtime 與業務後端部署生命週期綁死。
### C. 暫不接任何 runtime只保留純 Jinja/CSS
保留作為 fallback但不足以支援後續跨專案 microfrontend/plugin 化需求。導入 Webcrumbs 時仍維持現有 Jinja 頁面為主,不強制改寫。
## Consequences
- momo-pro 可在不替換 Flask/Jinja 的前提下,逐步嵌入自架 UI plugin。
- 生產部署需同步管理 `WEBCRUMBS_*` 變數與 110 Gateway runtime 路徑。
- 後續任何 Webcrumbs plugin 上線前仍需通過真實資料、權限、RWD、效能與 fallback 檢查。
- 若 runtime URL 無效,系統只會跳過 script 載入並在 config warning / `/webcrumbs` 顯示狀態,不應阻斷主站。

View File

@@ -58,6 +58,7 @@
| [034](ADR-034-dynamic-model-router.md) | Caller × Context 動態 Model Router短文 gemma3 / 複雜 SKU qwen3:14b / 重構 coder:32b | Accepted | 2026-05-04 |
| [035](ADR-035-cross-platform-market-campaign-intelligence.md) | 跨平台市場活動情報系統 | Accepted | 2026-05-06 |
| [036](ADR-036-fastapi-strangler-not-frontend-prerequisite.md) | FastAPI Strangler Migration不作為前端 V3 前置條件 | Accepted | 2026-05-12 |
| [037](ADR-037-webcrumbs-shared-ui-runtime.md) | Webcrumbs 共用 UI Runtime 接入 | Accepted | 2026-05-31 |
## 規範