Commit Graph

117 Commits

Author SHA1 Message Date
OoO
4380fa641c ci(observability): gate frontend deploys with QA suite
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 23:39:00 +08:00
OoO
3db8f5c5b2 chore(observability): polish QA entrypoint docs
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 23:37:00 +08:00
OoO
7225e81c08 chore(observability): pass QA target args through quick review
All checks were successful
CD Pipeline / deploy (push) Successful in 2m7s
2026-05-05 23:32:13 +08:00
OoO
7ce74e32fe docs(memory): record observability UI QA guardrails 2026-05-05 23:28:06 +08:00
OoO
65eea5eb9a chore(observability): add noninteractive QA quick review flags
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 23:25:55 +08:00
OoO
ce7dd6068c docs(deploy): require observability QA for frontend changes 2026-05-05 23:24:33 +08:00
OoO
be1d1aec03 test(observability): include health in smoke suite
All checks were successful
CD Pipeline / deploy (push) Successful in 4m4s
2026-05-05 23:20:45 +08:00
OoO
cdcbcf1d80 chore(observability): centralize QA page contract
All checks were successful
CD Pipeline / deploy (push) Successful in 1m33s
2026-05-05 22:19:25 +08:00
OoO
346e9672a6 chore(observability): add CSS mirror sync helper
All checks were successful
CD Pipeline / deploy (push) Successful in 1m33s
2026-05-05 22:16:41 +08:00
OoO
15f7c8660d fix(observability): serve CSS from Flask static path
All checks were successful
CD Pipeline / deploy (push) Successful in 1m34s
2026-05-05 22:14:47 +08:00
OoO
6d015c5b6b test(observability): assert design system markers
All checks were successful
CD Pipeline / deploy (push) Successful in 2m24s
2026-05-05 22:08:44 +08:00
OoO
422137efa8 test(observability): validate sidebar route coverage
All checks were successful
CD Pipeline / deploy (push) Successful in 1m41s
2026-05-05 21:46:28 +08:00
OoO
e7d567c6be test(observability): assert page content markers
Some checks failed
CD Pipeline / deploy (push) Failing after 4m55s
2026-05-05 15:53:39 +08:00
OoO
8643ed12ad test(observability): validate nav active page contract
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 15:48:39 +08:00
OoO
3fca720fa1 test(observability): guard sidebar navigation design
Some checks failed
CD Pipeline / deploy (push) Failing after 2m11s
2026-05-05 15:41:39 +08:00
OoO
6a0d5c138d test(observability): add one-shot QA suite
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 15:39:55 +08:00
OoO
b963dcf209 test(observability): add production page smoke check
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 15:35:47 +08:00
OoO
62276f8b0c chore(observability): wire UI guard into quick review
Some checks failed
CD Pipeline / deploy (push) Failing after 1m57s
2026-05-05 15:31:04 +08:00
OoO
07c9e200d0 test(observability): add UI regression guard
Some checks failed
CD Pipeline / deploy (push) Failing after 1m39s
2026-05-05 15:04:21 +08:00
OoO
fa3e0884ad docs(observability): 補齊 UI 治理規範
Some checks failed
CD Pipeline / deploy (push) Failing after 1m38s
2026-05-05 14:59:45 +08:00
OoO
054685826a feat(observability): 重塑 AI 觀測台戰情室 UI
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 13:17:42 +08:00
OoO
390c32b05d feat(p21): Caller × Context 動態 Model Router + ADR-034
All checks were successful
CD Pipeline / deploy (push) Successful in 2m45s
Operation Ollama-First v5.0 / Phase 21 — 動態路由治理

services/llm_model_router.py (160+ 行)
- 純規則引擎,零 LLM 成本(Python lambda predicate)
- 6 caller × 12 條路由規則:
  • sales_copy: 短文 < 100 字 → gemma3:4b / 長文 → llama3.1:8b
  • hermes_analyst: gap > 20% 或銷量 < -50% → qwen3:14b / 預設 hermes3
  • aider_heal: diff > 200 行 → qwen2.5-coder:32b / 預設 7b
  • openclaw_qa: query > 200 字或 multi_turn → qwen3:14b / 預設 qwen2.5:7b-instruct
  • ppt_vision: minicpm 不健康 → llava / 預設 minicpm-v
  • ea_engine: require_chain_of_thought → deepseek-r1:14b / 預設 Gemini
- feature flag MODEL_ROUTER_ENABLED 預設 OFF(向下相容)
- 失敗安全:predicate 例外 skip 到下一條

tests/test_llm_model_router.py (18 tests 全綠)
- T1 flag OFF 不路由
- T2 sales_copy 短/長文路由
- T3 hermes 簡單/複雜 SKU
- T4 aider_heal 簡單/重構
- T5 ppt_vision 主備援
- T6 ea_engine CoT 路由
- T7 predicate 例外容錯
- T8 utility 函數

ADR-034 — Caller × Context 動態 Model Router
- 6 caller 路由規則對應表
- 5 段否決方案(LLM-based / hardcode / 配置檔 / 統一升級)
- Phase 21.2-21.6 戰略性遷移計畫
- V1-V3 驗收 SQL(caller 整合後 model 分布觀察)

關聯:Primary + Secondary 兩台 GCP 已備齊 10 模型(67GB 對稱)支援所有
路由規則;caller 整合可分階段進行(Phase 21.2-21.5)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 10:54:12 +08:00
OoO
c13dc22639 feat(p20)+docs: cost auto-throttle + LLM 模型完整評估
All checks were successful
CD Pipeline / deploy (push) Successful in 2m44s
Operation Ollama-First v5.0 / Phase 20 + LLM 模型治理

services/cost_throttle_service.py (新檔, 200+ 行)
- evaluate_throttle_status() 每小時 cron 跑
- 查 ai_call_budgets monthly × 累計 spent → 月底線性外推
- 推估 > 預算 110% → 標 throttled(hysteresis:降到 95% 才解除)
- _push_throttle_alerts: 狀態變化推 Telegram
- is_provider_throttled(provider) public API(給 anthropic/gemini caller 啟動 check)
- COST_THROTTLE_ENABLED 預設 OFF(避免戰時誤節流)

run_scheduler.py 加 2 cron + task wrapper
- 每 1 小時:cost_throttle_evaluate
- 每日 00:05:cost_throttle_reset_if_new_month

docs/llm_model_full_evaluation_20260504.md (260+ 行)
- 場景 × 模型對應矩陣(4 大層次)
  戰術層 / 戰略層 / 多模態 / 雲端 API
- 本次啟動的追加 4 模型(qwen2.5-coder:32b / deepseek-r1:14b /
  llava / gemma3:4b)— Primary + Secondary 並行拉
- Phase 21 路由優化建議(context size + complexity 動態選 model)
- Phase 22 多供應商編排 + cost throttle 整合
- 儲存 / RAM / 延遲評估
- 模型治理 SOP(新增 / 替換 / 淘汰)
- COST_TABLE 對齊(含 deepseek 直連價格)

啟用前置(待統帥):
1. Primary + Secondary 4 模型拉完(背景進行中)
2. .env: COST_THROTTLE_ENABLED=true(觀察 1 週後)
3. ANTHROPIC_API_KEY 設後 Code Review 自動切 Claude Opus 4.7

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 10:36:56 +08:00
OoO
98063059c2 feat(p14-18): PPT vision + DeepSeek 直連 + caller_registry + Hermes 強化 + postmortem
All checks were successful
CD Pipeline / deploy (push) Successful in 2m50s
Operation Ollama-First v5.0 / Phase 14-18 全套(statesman 批准全部)

Phase 14 — services/ppt_vision_service.py (新檔, 200+ 行)
- minicpm-v:latest(GCP Primary 已拉 5.5GB,代替 qwen2-vl 不存在)
- check_image(image_path) → VisionResult.issues_found 視覺異常清單
- 走 resolve_ollama_host 三主機 retry + mark_unhealthy
- 繁中強制 system prompt + 結構化解析 ⚠️ marker
- feature flag PPT_VISION_ENABLED 預設 OFF

Phase 15 — services/deepseek_service.py (新檔, 170+ 行)
- DeepSeek API 直連 (api.deepseek.com/v1),OpenAI-compatible
- 取代部分 OpenRouter 路徑(直連便宜 ~30-50% + 延遲低)
- deepseek-chat ($0.014/$0.28) / deepseek-reasoner ($0.14/$2.19)
- feature flag DEEPSEEK_DIRECT_ENABLED 預設 OFF
- DeepSeekResponse 含 input_tokens/output_tokens/duration_ms

Phase 16 — services/llm_caller_registry.py (新檔, 130+ 行)
- CALLER_REGISTRY frozenset 集中管理 35+ 個 caller 名(ADR-028 白名單)
- assert_known_caller(strict=False) 整合到 ai_call_logger __init__
- 不在 registry → log warning(不 raise,保留擴展彈性)
- list_callers_by_service() 分組除錯
- 解 critic-A11 第 3 輪 L4 修補(命名分散三層)

Phase 17 — _is_low_quality_response 4 條新規則(A2 警訊深化)
- 規則 5:純英文回應(中文字元 < 30%)
- 規則 6:thinking-mode 漏洞(<think>...</think> 洩漏)
- 規則 7:重複迴圈偵測(前 50 字出現 ≥ 3 次)
- 規則 8:佔位符未填充({{var}} / [TODO] / <待填>)

Phase 18 — docs/operation_ollama_first_v5_postmortem.md (新檔)
- 戰役完整時間軸(Day 1-2)
- 3 大決策替代分析
- 4 個 critical hotfix 教訓
- Owen 三護欄落地對照
- KPI 達成度(Wave 1 提前 4 天 / Wave 2 提前 10 天)
- 統帥手動清單 + 7 條未來戰役教訓

Phase 13 補強(合併本 commit):
- ai_call_logger COST_TABLE 補 7 個新模型(qwen3:14b / qwen2.5:7b-instruct
  / qwen2.5-coder:32b / qwen2-vl:7b / deepseek-r1:14b / gemma3:4b / minicpm-v)

regression: 214 unit tests 全綠(4:02 跑完),2 skipped

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 10:19:13 +08:00
OoO
4e82acc0f5 feat(p10)+docs(adr): MCP 自建 Stack docker-compose + ADR-031
Operation Ollama-First v5.0 / Phase 10 + Phase 12 收尾

docker-compose.mcp.yml — 4+3 容器 MCP stack
- postgres-mcp (port 3001): Claude 直連 momo_pro DB read-only RBAC
- mcp-omnisearch (3003): Tavily 主 + Exa 備(取代 Gemini Grounding)
  避開 Brave(2026-02 取消免費 tier)
- firecrawl-self (3002): 自建爬蟲,SPA 反爬蟲
- filesystem-mcp (3004): 跨主機檔案 read-only

護欄 #2 落地(Owen v5.0 鐵律 / ADR-033):
  firecrawl-self mem_limit:2g + cpus:1.5
  PLAYWRIGHT_BROWSER_POOL_MAX=3
  chrome-reaper sidecar 每小時清 Chrome zombies

安全設計:
- 全部 127.0.0.1 暴露(不外網)
- read-only volume mount(filesystem 只能讀)
- postgres-mcp RBAC mcp_readonly role 限 SELECT 6 熱表
- API key 全走 env var 不寫死

ADR-031 — MCP 自建 Stack 治理決策
- 取代 Gemini Grounding 唯一通路(多供應商策略)
- 預期 70%+ grounding 流量走免費 Tavily
- 188 主機資源 +4-5GB RAM 可控
- Migration Plan:6 步驟(含 Tavily/Exa key 申請 + mcp_readonly role 預建)

啟用前置(待統帥):
1. .env 加 TAVILY_API_KEY / EXA_API_KEY / MCP_POSTGRES_PASSWORD / FIRECRAWL_AUTH_KEY
2. momo-db 建 mcp_readonly role + GRANT SELECT
3. ssh wooo@110 → ssh ollama@188 → docker compose -f docker-compose.mcp.yml up -d

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 09:02:07 +08:00
OoO
c29ce83653 docs(adr): ADR-032 RAG 自主學習迴圈 + ADR-033 三護欄
Operation Ollama-First v5.0 / Phase 12 Wave 2 收尾

ADR-032 — RAG 自主學習迴圈
- 雙表分離:rag_query_log (audit) / learning_episodes (蒸餾池) / ai_insights (知識庫)
- Distiller 規則引擎(純 Hermes 零 LLM 成本)
- PromotionGate 4 階段晉升閘
- Telegram 反饋環(rag_feedback / promotion_review keyboard)
- feature flag RAG_ENABLED 預設 OFF
- V1-V4 驗收 SQL(命中率 / 晉升通過率 / 反饋分布 / embedding 一致性)

ADR-033 — RAG 三護欄(Owen v5.0 鐵律)
- 護欄 #1 Promotion Gate:強制反饋門檻,weight>=0.8 必經人工驗收
- 護欄 #2 Firecrawl 資源:Docker mem_limit:2g + chrome-reaper sidecar + 1.8GB 告警
- 護欄 #3 BGE-M3 一致性:embedding_signature SHA1[:12] + 啟動跨主機驗證
- 五案否決理由完整(包含「不要反饋按鈕」「不限資源」「:latest 接受漂移」)

Migration Plan 對照:
   migration 026/028 schema + service 已落地
   Phase 12+ 補:embedding 寫入 / worker cron / Telegram 推播 / Firecrawl 部署 / signature 回填

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 00:01:19 +08:00
OoO
d3d90121cf docs(adr): ADR-030 Frontier 多供應商策略 — Anthropic + Google + OpenRouter
Operation Ollama-First v5.0 / Phase 12 / Phase 7 落地後追認

Phase 7 引入 Anthropic Claude(Opus 4.7 接 Code Review)後,
戰役有 2 家 Frontier 供應商,需明確治理準則:

決策矩陣(與 ADR-028 鎖定 7 場景對齊):
- 場景 #5 Code Review : Claude Opus 4.7 (Arena Elo 1548)
  → Gemini 2.5 Flash → ElephantAlpha 49B (3 層 fallback)
- 其他 6 場景維持 Gemini 主鏈

Prompt cache 戰術:
- Anthropic 5min ephemeral:Code Review 命中率預估 80%+,省 ~90% 成本
- Google Gemini:隱式 server-side cache,不可預測

預估月成本:~$32 USD
- Claude $10 + Gemini $8 + NIM $5×2 + OpenRouter $3 + Ollama $0.02

新增供應商 SOP:
1. service wrapper 加 feature flag + is_available() 檢查
2. budget 種子 + ai_calls.provider 白名單
3. unit test (fallback 鏈 + cache hit/miss)
4. 獨立 ADR

對齊:
- migration 024(claude in provider 白名單)
- migration 025(claude $10/月 budget 種子)
- ai_call_logger COST_TABLE(claude-opus/sonnet/haiku 三模型)
- services/anthropic_service.py(Phase 7 落地)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 23:42:36 +08:00
OoO
2f20d8d7ba db(p11): rag_query_log + learning_episodes — RAG 自主學習迴圈基礎
All checks were successful
CD Pipeline / deploy (push) Successful in 3m30s
Operation Ollama-First v5.0 / Phase 11 RAG + 自主學習

migrations/027 — rag_query_log(每次 RAG 查詢的 audit log)
- query_text 4KB CHECK + 90 天保留
- VECTOR(1024) bge-m3 embedding (與 ai_insights 一致簽名)
- ivfflat lists=100 索引
- saved_call 欄位追蹤「成功攔截 LLM 呼叫」次數
- feedback_score 1-5(NULL=未反饋)
- 6 條 CHECK 含 chk_rag_saved_consistent

migrations/028 — learning_episodes(蒸餾池 → ai_insights 前哨)
- 8 狀態機:pending/approved/awaiting_review/rejected_*4/expired
- weight 0-1(>=0.8 觸發 PromotionGate Stage 4 人工驗收)
- 9 條 CHECK 含 chk_le_approved_consistent / chk_le_review_consistent
- partial index idx_le_status WHERE in (pending, awaiting_review)
- distilled_text 16KB 上限

docs/phase11_db_design — 設計文檔
- 6 大決策(兩表分離 / ivfflat / partial index / 軟連結 / 90天保留 / 應用層白名單)
- 6 大風險評估(R1 PII / R2 蒸餾失誤 / R3 ivfflat 退化 / R4 dangling FK / R5/R6 trade-off)
- Phase 11 上線後驗收 SQL(EXPLAIN ANALYZE)

PromotionGate 4 階段(v5.0 護欄 #1, ADR-033):
  Stage 1: quality_score >= 0.7
  Stage 2: 無幻覺檢測(規則引擎,零 LLM)
  Stage 3: 與既有 insight 相似度 < 0.95
  Stage 4: weight >= 0.8 必經 Telegram 👍/👎(24h 無回應 → expired)

A4 fullstack-engineer 同時在寫 services/rag_service.py + learning_pipeline.py,
service 完成後一起部署啟用。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 23:39:47 +08:00
OoO
3ea7004a6f refactor(p4)+docs(p5+p6): Meta 降頻 + LOCKED-GEMINI + ADR-028/029
Phase 4 A10 — OpenClaw 雙塔重劃
- run_scheduler.py: Meta 自審 cron 6h → 每日 12:00(月省 2.25M Gemini, +20% 達標)
- scheduler.py: 移除 icaim 內 2 處 inline meta 觸發
- openclaw_strategist 抽 _push_report_with_charts (call×3) + _collect_mcp_intel (call×2)
- 行數目標 -25% 未達(4 報告函數結構差異大,A10 採保守抽出避險)
- 主戰果:Meta 降頻月呼叫 300 → 30(-90%)

Phase 5 — 5 處 LOCKED-GEMINI 註解(涵蓋鎖定 7 場景)
- services/mcp_collector_service.py:32 (場景 #1: Google Search Grounding)
- services/openclaw_strategist_service.py:40 (場景 #2/3/4: 週/月/年報)
- services/code_review_pipeline_service.py:46 (場景 #5: 100K+ token diff)
- services/elephant_alpha_orchestrator.py:88 (場景 #6: EA HITL)
- routes/openclaw_bot_routes.py:98 (場景 #7: PPT 簡報)

Phase 6 A12 — 憲法級 ADR 三份
- ADR-028「LLM 路由統一準則」(269 行)
  - 5 大支柱:三主機級聯 / Ollama 優先 / 雙塔分工 / Gemini 鎖 7 場景 / 可觀測性
  - 8 個 provider 白名單(DB CHECK 對齊)
  - 30+ caller 名單分「已實作 / 規劃中」
- ADR-029「Hermes-First 雙塔分工」(222 行)
  - 12 項職責重劃表 + A7/A8/A10 落地對照
  - Gemini 月支出 -23.5%(critic 第 3 輪 B5 算術修正)
- ADR-027 附錄(+69 行)
  - 三主機架構(Primary/Secondary/Fallback)
  - 4 條獨立 fallback 鏈
  - 廢止「188 Ollama」概念
- README 索引更新

A11 critic 第 3 輪修補:5 BLOCKER 全清
- B1: 行數 1831 → 2677 (含 baseline 對照)
- B2: 場景 #4 行號 759/1267 → 1102/1628 + annual 不存在註明
- B3: 虛構 caller 改實存(ea_hitl_prefetch → ea_engine 等)
- B4: 白名單三層對齊(DB 8 = ADR 8 = token_report 補 ollama_secondary)
- B5: KPI 算術 50→38 = -23.5% 重核

services/telegram_templates.py: A5 daily_token_report() 函數
services/mcp_collector_service.py: 加 LOCKED-GEMINI 註解
services/elephant_alpha_orchestrator.py: 加 LOCKED-GEMINI 註解

103/103 unit test 全綠(zero regression)

Operation Ollama-First v5.0 / Phase 4 A10 + Phase 5 + Phase 6 A12

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 23:06:08 +08:00
OoO
4648673423 db(p1): ai_calls/mcp_calls/budgets schema + bge-m3 signature
migrations 024/025/026 — 統一 LLM 遙測 + 預算告警 + RAG 一致性護欄
- 024: ai_calls 表 + 5 索引 + 6 CHECK constraint(H1/H2/M3/L3)
- 025: mcp_calls + ai_call_budgets + 10 種子預算(含 ollama_secondary)
- 026: ai_insights.embedding_signature + pgcrypto + CONCURRENTLY index

A11 critic 三輪審查記錄完整保留:
- Phase 1 schema review: 2 BLOCKER + 4 HIGH + 6 MEDIUM 全處理
- Phase 1 final sign-off: 0 BLOCKER + 2 HIGH + 4 MEDIUM
- Phase 6 ADR review: 5 BLOCKER + 6 HIGH 全修

Operation Ollama-First v5.0 / Phase 0+1+6 護欄

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 23:04:42 +08:00
OoO
ce270edc5d docs(adr): ADR-026 PPT price_elasticity + complete v3 campaign roadmap
收尾 v3 PPT 戰役(ADR-022~026 共 5 份 ADR):

完成總計:
- 18 commits(38967ce → 16b169d)
- 16 種有效 PPT 報表
- 2 種 DEPRECATED(bcg / growth)
- 5 ADR 涵蓋完整戰役決策

報表角色覆蓋:
- 戰情/早會:daily / weekly
- BU 主管:monthly / quarterly / half_yearly / forecast / strategy
- CEO/CFO:annual / ttm / market_intel
- 採購/PM:vendor / category / new_product / price_elasticity
- 行銷:promo / promo_compare / customer / market_intel
- 競品:competitor

Wave 4 待辦(受資料層 / 外部整合限制):
- clv (需 user_id 會員系統)
- competitor v4 五力(需外部 SKU/品牌力資料整合)
- inventory / operations / finance(需新 DB schema)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:50:25 +08:00
OoO
9862edeb44 docs(adr): ADR-025 PPT Wave 3 (new_product + market_intel_weekly)
Wave 3 完成 2 種橫向資訊整合型報表:
- new_product (95a74c3) — 30 天追蹤,PostgreSQL CTE 識別新品
- market_intel_weekly (fe3cba8) — 8 個外部 API 彙整,fail-safe 設計

累計報表清單:13 種有效 + 2 種 DEPRECATED + 4 種待資料層支援。

Wave 3 餘項(受資料層限制):
- clv (需 user_id)
- price_elasticity (需長期定價歷史)
- competitor v4 五力 (需外部 SKU/品牌力資料)

Wave 4 待辦(依資料層 schema):
- inventory / operations / finance

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:41:12 +08:00
OoO
af6157f8ba docs(adr): ADR-024 PPT Wave 2 (forecast + promo_compare) + deprecate bcg/growth
All checks were successful
CD Pipeline / deploy (push) Successful in 2m41s
Wave 2 完成 2 種新報表:
- forecast_pre_event (9f04dc3) — 檔期前 14 天備戰策略 (BU 主管用)
- promo_compare (958f705) — 多活動 ROI 並排比較 (行銷主管覆盤)

正式廢除(DEPRECATED 標記,函式保留作 internal helper):
- bcg — 與 strategy 報表功能重疊(strategy 已含 BCG 五級分類)
- growth — 已被 quarterly + half_yearly + annual + ttm 完全取代

報表體系現況:16 種有效(v3 重做 6 + Wave 1 新增 8 + Wave 2 新增 2)+ 2 種
DEPRECATED;4 種角色覆蓋(採購/PM/行銷/CFO/CEO)。

forecast 核心:baseline 日均 × 21 天 × lift_factor,含 8 種檔期靜態知識
(雙11 1.65× / 母親節 1.40× 等),封面倒數天數徽章自動切換。

promo_compare 核心:N 場活動並排 KPI 表 + 拉抬 % 排序橫條 + 4 排名亮點
(最高拉抬/最低拉抬/最佳毛利/最高業績)。

Wave 3 待辦:market_intel_weekly / new_product / clv / price_elasticity
Wave 4 待辦:inventory / operations / finance(依資料層)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:30:35 +08:00
OoO
5461c92cf8 docs(adr): ADR-023 PPT system Wave 1 expansion (4 commits, 8 new types)
紀錄 Wave 1 擴展戰役:從 6 種 PPT 報表擴展到 14 種。

新增報表類型:
- vendor (b6fdb4f) — 採購主管視角,集中度警示 + 議價優先
- quarterly / half_yearly / annual / ttm (1af96f5) — period_review 共用
  generator 一份解 4 種,省 60% 程式碼
- category (d8260fc) — PM/採購視角,90 天縱向 + 子品類 + CTE 新進榜
- customer (48e3dac) — 行銷主管簡化 RFM,受限於無 user_id 做訂單級

技術亮點:
- 共用 Generator 模式(period_review 解 4 種)
- 期間徽章自動切換
- PostgreSQL CTE 做新進榜判定(recent EXCEPT early)
- 限制聲明的誠實設計(customer 無 user_id 註腳)

Wave 2-4 待辦清單見 ADR 內文。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 02:20:05 +08:00
OoO
abd722986e fix(autoheal): preflight + shell || true 結合性 — 解 24h 100% no-op
All checks were successful
CD Pipeline / deploy (push) Successful in 2m23s
Debugger 五階段方法論 root cause(2026-05-03):
ADR-020 政策層 100% 達成(reasoning 全 auto_fix=enabled),但 AiderHeal
執行層 24 小時 0 次 push 成功,全部 silent fail。

兩根因疊加:
  #1 (config) AIDER_REPO_PATH=/home/wooo/ewoooc 在 110 主機不存在
            → 寫 SOP docs/runbooks/aider-heal-110-setup-sop.md 給統帥手動執行
  #2 (code)  setup_cmds 結尾 `git stash 2>&1 || true` 因 shell 結合性等同
            `(A && B && C && D) || true`,cd 失敗整 chain rc=0 被吞,
            line 261 if rc != 0 永不觸發 → setup_failed 從未被 log
  #4 (code)  缺 preflight,環境壞掉時靜默走完整 pipeline 印 no_diff

本次程式碼修復:
  • execute_code_fix 開頭加 L0 preflight(test -d $REPO/.git)
    失敗 fail-fast + Telegram 嚴重告警 + 指向 SOP
  • setup_cmds 改 `A && B && C && (D || true)` 用 subshell 限縮 || true
  • 全檔 5 處 `cd $REPO_PATH` 統一改 `cd shlex.quote(REPO_PATH)`
    避免下次有人複製 cd chain 又踩同類 shell quoting bug

SOP 同步處理 critic High-2 + Medium-6:
  • 步驟 2 改用 SSH clone(git clone gitea-autoheal:...)
    避免 HTTP clone 在 private repo 卡帳密 + 跟步驟 1 部署的 key 不關聯
  • 步驟 4b 修引號嵌套(heredoc + 單引號保護),原版永遠 false positive

Critic 審過 Approve to commit;Medium-2/3/4(速率限制 / log 加 stderr /
新增 preflight unit test)排 follow-up,不阻擋本次。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 01:55:34 +08:00
OoO
9010a4e6fa docs(adr): add ADR-022 PPT v3 redesign + warm paper + matplotlib + cache versioning
紀錄本次 PPT 全面重做的架構決策:
- 視覺:暖紙風(_BG_PAPER #F3EEE2)取代暖墨黑封面
- 圖表:matplotlib 暖色系(橫條/折線/帕雷托)取代 python-pptx 原生
- 字型:lxml 直寫 a:latin/a:ea 中英分軌(Consolas + JhengHei)
- 快取:TEMPLATE_VERSIONS 字典自動注入 cache key (tpl_ver)
- AI prompt:升級到顧問深度(市場趨勢脈絡 + SMART 框架)
- 安全:admin 白名單(OPENCLAW_ADMIN_USER_IDS)+ cleanup dry_run 預設

涵蓋 8 commit chain:38967ce → 3b0b4b352c06f61c81866b5a2b09c7b7cee92b80355a7012f

Critic 全清紀錄:0 critical / 2 HIGH / 4 medium / 3 info 全部修補。

對應 memory:
- reference_ppt_system.md(既存)已更新到 v3 實況
- project_ppt_v3_campaign_20260502.md(新建)戰役紀錄含三大踩坑
- feedback_template_version_cache_pattern.md(新建)可重用設計模式

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:25:09 +08:00
OoO
00591c5489 feat(ea-hitl): ADR-021 EA 升級審核 pre-fetch + 競價告警金額影響量化
根治 2026-05-02 統帥反映的三層 EA escalation 訊息空泛問題:

1. _escalate_to_human 對 price_drop_alert / market_opportunity /
   threat_escalation 三類觸發,送 Telegram 前先 await Hermes 取具體
   SKU 清單覆蓋 plan 元流程文字(5s 短超時,失敗 fallback 原 plan)
2. NemoTron 競價告警新增 _compute_business_impact helper:
   過去 7 日營收流失(gap_pct>0 才算)+ 跟進競品建議價,
   dispatch 主路徑 / 防線二 / Hermes rule fallback 三條全部 Python
   獨裁注入,告警含「📉 NT$ X」「🎯 NT$ Y」具體金額
3. 補實 telegram_bot_service.handle_callback 的 momo:eig: prefix
   handler,HITL「🛑 忽略此事件」按鈕首次有對應 audit 寫入

Critic 審查通過(5 項必修全綠):
- Critical-1: user_label HTML escape 防 Telegram username XSS
- High-1: pre-fetch 改 asyncio.wait_for(5s) 防阻塞 escalation
- High-2: 全部行缺金額時 return None 觸發 plan fallback
- Medium-2: 空 event_id callback 拒絕避免 audit 污染
- Medium-3: gap_pct≤0 時 revenue_loss_7d 強制歸 0 不誤導降價

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:03:38 +08:00
OoO
6cad59f83e feat(code-review): ADR-020 全自動修復政策 — 拆掉 CRITICAL/HIGH HITL 閘門
All checks were successful
CD Pipeline / deploy (push) Successful in 2m23s
post-deploy code review pipeline 改為「任何 finding 一律觸發 AiderHeal」,
局部覆寫 ADR-012 L3 HITL(不影響 schema migration / 流量切換 /
customer-facing 廣播 / AIOps prod SSH 等其他 L3 場景)。安全網改為
Git revert + Gitea CI/CD 健康檢查 + 主開關 CODE_REVIEW_AUTO_FIX_ENABLED。

實作:
  • _ea_orchestrate / _guard_ea_decision / rule fallback 三條路徑統一為
    has_findings AND AUTO_FIX_ENABLED → auto_fix=true
  • _guard 強制 LLM 即使回 auto_fix=False 也升級為 true(核心保證)
  • CODE_REVIEW_AUTO_FIX_ENABLED 預設 false → true
  • Telegram 文案移除「需人工審查」,改顯示主開關狀態
  • action_plan status pending_review → auto_disabled(語意對齊)
  • aider_heal_executor 標頭 ADR-014 → ADR-020、補「直推 main」分支策略

文件:
  • 新增 docs/adr/ADR-020-code-review-full-autoheal.md
  • ADR-012 加 Note 行反向引用 ADR-020
  • README 索引收錄

測試:tests/test_code_review_pipeline_security.py 反轉 HITL 期望,
新增 5 case(含 LLM 降級被 guard 拒絕、LLM human_review_needed=true 被改 false)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 23:44:01 +08:00
OoO
4c6e4ca5fb style(ppt): align PPT palette perfectly with MOMO Pro v2 design tokens (Beige, Warm Ink, Caramel Orange) as per frontend upgrade roadmap 2026-05-02 15:01:55 +08:00
OoO
db02ecf2cf feat(telegram): ADR-019 Phase 1 - PPT data freshness gate + store_insight fix
All checks were successful
CD Pipeline / deploy (push) Successful in 2m55s
ADR-019 Phase 1 (止血):PPT 生成前 probe 資料新鮮度。月初/缺資料期間用戶按
ppt:monthly/daily 不再產出空白報告,改主動 inline keyboard 詢問:
  - 改看最新有資料的月份/日期(一鍵)
  - 自訂月份/日期(接 await:date_ppt_*)
  - 取消

新增 PPTDataInsufficientError exception + _ppt_check_data_freshness() helper。
_generate_ppt_cmd 簽章加 _reply_to=None;_ppt_background 靜默吞此例外。

順手修同檔 :1976/:1993 兩處 store_insight() positional args 錯位 bug —
原本 (date, report_type, ai_text) 對應 signature (insight_type, content, period)
完全錯位,導致 period varchar(50) 被 2000 字 AI 內容截斷、INSERT 失敗、
ai_insights 表寫入永久失敗。改成 kwargs 呼叫。

ADR-019 (Telegram Bot Agentic Conversation Layer) 同步落地,Status: Accepted。
六 Phase 路線圖見 ADR 文件,本 commit 完成 Phase 1。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 12:52:45 +08:00
OoO
7d46ff9ba5 feat(competitor): persist match attempts
All checks were successful
CD Pipeline / deploy (push) Successful in 2m9s
2026-05-01 20:56:17 +08:00
OoO
b9d6186d68 feat(frontend): sync latest MOMO Pro prototype styling
All checks were successful
CD Pipeline / deploy (push) Successful in 2m18s
2026-05-01 20:32:23 +08:00
OoO
9e2337764b fix(ai): supersede old product picks
All checks were successful
CD Pipeline / deploy (push) Successful in 2m48s
2026-05-01 16:24:15 +08:00
OoO
b3d00a011c fix(dashboard): warm cache after AI pick refresh
All checks were successful
CD Pipeline / deploy (push) Successful in 3m37s
2026-05-01 16:16:39 +08:00
OoO
b447aefcfb fix(ai): clear dashboard cache after pick regeneration
All checks were successful
CD Pipeline / deploy (push) Successful in 2m27s
2026-05-01 16:10:51 +08:00
OoO
3920701e1a feat(dashboard): optimize cache and AI pick confidence
All checks were successful
CD Pipeline / deploy (push) Successful in 2m46s
2026-05-01 16:01:52 +08:00
OoO
0334051aa7 feat(dashboard): 匯出 AI 挑品操作清單
All checks were successful
CD Pipeline / deploy (push) Successful in 2m39s
2026-05-01 15:43:57 +08:00
OoO
1d1a7f6e94 feat(dashboard): 強化 AI 挑品清單決策資訊
All checks were successful
CD Pipeline / deploy (push) Successful in 2m22s
2026-05-01 15:22:21 +08:00
OoO
a5de082437 feat(dashboard): 顯示 50 品 AI 挑品清單
All checks were successful
CD Pipeline / deploy (push) Successful in 3m12s
2026-05-01 15:08:41 +08:00
OoO
6bce46bbc7 fix(runtime): 強化健康檢查監控韌性
All checks were successful
CD Pipeline / deploy (push) Successful in 2m29s
2026-05-01 14:46:49 +08:00