Commit Graph

208 Commits

Author SHA1 Message Date
OoO
4079f1c0ac 守住 CD migration 全範圍執行 2026-05-13 11:22:05 +08:00
OoO
58ba95ba5e 守住月結匯入 append 路徑 2026-05-13 11:21:08 +08:00
OoO
2e2b775608 守住 V2 import 清理狀態 2026-05-13 11:19:54 +08:00
OoO
6c86839350 守住盤點誤判依賴 2026-05-13 11:18:35 +08:00
OoO
b24241f361 守住 migration blocker 修補 2026-05-13 11:17:16 +08:00
OoO
8026b9379b 守住 scheduler 早晨排程錯開 2026-05-13 11:14:10 +08:00
OoO
b22cbb2aa0 守住 scheduler 失敗告警覆蓋 2026-05-13 11:13:13 +08:00
OoO
4e6e9bfe5d 綁定自動匯入日期查詢參數 2026-05-13 10:28:48 +08:00
OoO
0359e8154a 加速月份總表特殊趨勢載入
All checks were successful
CD Pipeline / deploy (push) Successful in 55s
2026-05-13 10:12:01 +08:00
OoO
5625032a8d 記錄 AI caller registry 匯入失敗
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-13 10:04:45 +08:00
OoO
0a75d11a28 記錄 Claude 成本節流檢查失敗
All checks were successful
CD Pipeline / deploy (push) Successful in 59s
2026-05-13 10:03:13 +08:00
OoO
f49413e78a 記錄 EA short-circuit 遙測失敗
All checks were successful
CD Pipeline / deploy (push) Successful in 56s
2026-05-13 10:01:46 +08:00
OoO
c300e496c5 記錄 ROI 月報反饋區塊失敗
All checks were successful
CD Pipeline / deploy (push) Successful in 55s
2026-05-13 10:00:04 +08:00
OoO
317ff1bf02 共用匯入檔名日期解析
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-13 09:58:56 +08:00
OoO
ba8510eac7 補齊 MCP 早退狀態
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-13 09:40:55 +08:00
OoO
d7ae243ece 清空 Telegram webhook 使用者上下文
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-13 09:40:19 +08:00
OoO
a335ab523f 修正 AutoHeal Telegram 觸發者審計
All checks were successful
CD Pipeline / deploy (push) Successful in 56s
2026-05-13 09:39:09 +08:00
OoO
5785a584c4 補齊 scheduler 觀測任務失敗告警
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-13 09:37:22 +08:00
OoO
34db2db5fd 修正 scheduler 合成告警 trace
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-13 09:35:57 +08:00
OoO
d15b2215f1 細分 MCP 呼叫遙測狀態
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-13 09:35:27 +08:00
OoO
bdb74b1354 告警 BGE embedding 一致性異常
All checks were successful
CD Pipeline / deploy (push) Successful in 55s
2026-05-13 09:34:03 +08:00
OoO
2068a3719d 修正 Telegram 分類按鈕預設 callback
All checks were successful
CD Pipeline / deploy (push) Successful in 55s
2026-05-13 09:27:34 +08:00
OoO
44eb36992e 補上 MCP filesystem 唯讀白名單
All checks were successful
CD Pipeline / deploy (push) Successful in 55s
2026-05-13 09:26:12 +08:00
OoO
20cab6ed64 補上 RAG hit logger 回歸測試 2026-05-13 09:23:26 +08:00
OoO
36d0e5d5f3 標記 RAG 命中節省 LLM 呼叫
All checks were successful
CD Pipeline / deploy (push) Successful in 56s
2026-05-13 09:21:50 +08:00
OoO
f2b91beb61 記錄 RAG 人工審核者 hash
All checks were successful
CD Pipeline / deploy (push) Successful in 58s
2026-05-13 09:13:29 +08:00
OoO
bb65ba71ba 補上 cache TTL 單一來源測試 2026-05-13 09:12:00 +08:00
OoO
eb9cac0d19 改善活動看板手機導覽排版
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-12 23:50:18 +08:00
OoO
b1013d1a25 鎖定 requirements 最低版本
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-12 23:41:35 +08:00
OoO
bc3f9cc61a 補上 action_plans 寫入護欄
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-12 23:35:25 +08:00
OoO
caa6263872 同步 incidents 相容欄位寫入
All checks were successful
CD Pipeline / deploy (push) Successful in 56s
2026-05-12 23:31:33 +08:00
OoO
1652ff3a59 補齊核心業務表 migration baseline
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
2026-05-12 23:24:14 +08:00
OoO
14c5349b69 補齊 AI 觀測表 ORM 與 embedding 簽名
All checks were successful
CD Pipeline / deploy (push) Successful in 56s
2026-05-12 23:13:20 +08:00
OoO
fccc80858d 修復 Wave 0 阻塞與 market intel 入庫 2026-05-12 22:49:56 +08:00
OoO
30a173cf69 統一全站暖色視覺與市場情報骨架
All checks were successful
CD Pipeline / deploy (push) Successful in 58s
2026-05-06 20:24:46 +08:00
OoO
153e4c9734 fix(observability): revert unrelated quick review commit files
All checks were successful
CD Pipeline / deploy (push) Successful in 58s
2026-05-06 19:50:52 +08:00
OoO
308efdce25 chore(observability): clarify quick review completion copy
All checks were successful
CD Pipeline / deploy (push) Successful in 1m4s
2026-05-06 19:49:28 +08:00
OG T
0904a60237 fix(scheduler): quiet cold-start noise gates
All checks were successful
CD Pipeline / deploy (push) Successful in 1m29s
2026-05-06 00:31:30 +08:00
OoO
326285d8b9 test(p55): 觀測台 mutation endpoint logged-in success path 補測 (23/23 PASS)
P53 之前 mutation endpoint 只測 anon block (302),logged-in 成功路徑零覆蓋:
- /playbooks/toggle/<id>: 翻 is_active 邏輯
- /budget/force_throttle: cost_throttle.evaluate() 呼叫
- /ai_calls/trigger_code_review: code_review_pipeline 觸發
- /host_health/trigger_autoheal: autoheal playbook 觸發

新增 5 cases:
- test_playbook_toggle_404_on_missing: fetchone()=None 必回 404
- test_playbook_toggle_flips_active_flag: False→True 翻轉 + 中文 message
- test_budget_force_throttle_invokes_evaluate: monkeypatch 假 throttle service
- test_ai_calls_trigger_code_review_returns_json: 至少回 JSON 不爆
- test_host_health_trigger_autoheal_returns_json: 至少回 JSON 不爆

設計重點:對未來 service 重構容忍(status code 收 200/400/500/503)
但堅持「JSON response shape」契約 — 防 HTML error page 漏出。
2026-05-05 12:17:54 +08:00
OoO
118f10701b test(p54): get_host_label / get_provider_tag 補測 (20/20 PASS)
P53 commit 7a10d27 加了 K8s Nginx Proxy 路由判斷
(192.168.0.110:11435/11436 → GCP-A/B),但無單測。
未來改 IP / 加 provider 容易破而不自知。

覆蓋:
- TestGetHostLabel × 9 cases:
  empty / GCP-A 直連 / GCP-B 直連 / Nginx 11435 / Nginx 11436 /
  111 備援 / 188 本地 / localhost / unknown fallback
- TestGetProviderTag × 5 cases + parametrize × 6 row:
  empty / GCP×2 路徑 / Secondary×2 路徑 / 111 / unknown
  + 6 row 對齊 migration 024 ai_calls.provider CHECK 白名單

特別防 regression:K8s 環境 192.168.0.110:11435 不再 fallback "未知"
(這正是 P53 commit 修的問題)。
2026-05-05 01:12:35 +08:00
OoO
a142e85880 test(p53): 觀測台 smoke 涵蓋 P38-P52 新增 11 endpoint (18/18 PASS)
戰役從 P27 6 路由擴展到 P52 共 20 路由(含 5 新 GET / 5 新 POST),
原 12 tests 只蓋 P27-31 範圍,P38-P52 共 11 endpoint 無 regression 防護。

新增測試:
- test_overview_index_200: /observability/ root index
- test_overview_dashboard_200: P45 總覽頁
- test_rag_queries_200: P51 RAG 召回詳情
- test_business_intel_200: P48 商業面 × AI 編排
- test_agent_orchestration_200: P46 Agent 編排矩陣
- test_health_indicator_api_returns_json: P52 topbar 健康燈 JSON API
- test_anon_get_redirects_to_login: 12 GET 路徑全強制 login (擴充 6→12)
- test_anon_post_blocked: 8 POST mutation 全強制 login (擴充 3→8)

prod 實證:mo.wooo.work 11 endpoint 全 Flask 200/308 服務(curl 已驗)。
20/20 routes @login_required 100% 覆蓋(python regex audit)。
2026-05-05 01:09:52 +08:00
OoO
86f1fd5f50 fix(p33): admin observability auth hardening — Critic CRITICAL 修正
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
Critic 1 CRITICAL 發現:6 個觀測端點零認證 + csrf_exempt
→ Flask 一旦對外可達,任何人可 POST 晉升 episode / 改月預算
→ X-Forwarded-User header client 偽造 = 偽造 admin 身份

修正:
1. 全 8 個 route handler 加 @login_required(session-based auth)
   - GET: ai_calls / promotion_review / quality_trend / host_health /
          budget / ppt_audit_history
   - POST: promotion_review/approve, .../reject, budget/update/<id>
2. promotion_review_approve approver_hash 改從 Flask session 取
   (get_current_user().username)— 不再信 X-Forwarded-User header
3. app.py 移除 csrf.exempt(admin_observability_bp)
4. 12 tests(10 原 + 2 新 auth gate)全 PASS:
   - test_anon_get_redirects_to_login: 6 GET 路由匿名 → 302
   - test_anon_post_blocked: 3 POST mutation 匿名 → 302
2026-05-04 14:19:54 +08:00
OoO
99d2f3c543 fix(p32): admin URL prefix /admin → /observability — 避開 188 nginx SPA shadow
All checks were successful
CD Pipeline / deploy (push) Successful in 2m25s
Root cause(curl 實證):
  prod 188 nginx 對 /admin/* 設 try_files → SPA index.html fallback
  → Phase 27-31 的 6 個 Flask admin 路由全被 nginx 攔截
  → 外部 GET /admin/ai_calls 回 7480 byte 靜態 HTML(同 etag = SPA shell)
  → 我之前說「6 admin 頁 prod 200」是回了 200,但 body 不是 Flask 渲染

修法:
  Blueprint url_prefix /admin → /observability
  → 6 個觀測頁實際生效在 /observability/* 不被 SPA 遮蔽
  → SPA frontend 仍擁有 /admin/* 命名空間(不破壞既有前端)

更新範圍:
  - routes/admin_observability_routes.py: url_prefix + 註解全改
  - 6 templates: 所有 href / fetch() 路徑改 /observability/
  - tests/test_admin_observability_routes.py: client.get/post 路徑改
  - 10/10 smoke tests 仍 PASS

統帥訪問新路徑:
  http://192.168.0.188/observability/ai_calls
  http://192.168.0.188/observability/host_health
  http://192.168.0.188/observability/budget
  http://192.168.0.188/observability/promotion_review
  http://192.168.0.188/observability/quality_trend
  http://192.168.0.188/observability/ppt_audit_history
2026-05-04 14:13:27 +08:00
OoO
82595ab4ac test(p31): admin observability 6 路由 smoke tests (10/10 PASS)
防 Phase 27/28/29 6 個 admin 頁未來被改壞無人察覺。

覆蓋:
- /admin/ai_calls         200 + DB error fallback (2 cases)
- /admin/promotion_review 200
- /admin/quality_trend    200
- /admin/budget           200
- /admin/budget/update/<id> 輸入驗證 (3 cases: 拒負 budget / 拒 alert>100 / 收正常)
- /admin/ppt_audit_history 200 (掃 reports/ 不需 DB)
- /admin/host_health      200 (mock requests.get 三主機全 down 仍 render)

技術重點:
- 全 mock get_session,不接真 DB
- jinja2 csrf_token() stub 避免 base.html 渲染失敗
- requests.get monkeypatch 避免測試誤打三主機 11434

跑法:venv pytest tests/test_admin_observability_routes.py -v
2026-05-04 13:51:07 +08:00
OoO
c7d04b2855 test(p26): 修 libreoffice not installed test patch path 2026-05-04 11:16:30 +08:00
OoO
72a7c385d5 feat(p26): PPT 視覺審核 daily 22:00 cron — minicpm-v 自動掃當天新生 .pptx
All checks were successful
CD Pipeline / deploy (push) Successful in 2m54s
Operation Ollama-First v5.0 / Phase 26 — PPT 自我審視整合

services/ppt_vision_service.py 擴充:
- check_ppt_file(pptx_path, max_slides=5) — 整檔視覺檢查
  • LibreOffice headless 轉每張 slide 為 png
  • 對前 N 張跑 check_image
  • 彙總 issues + 平均 confidence
  • fail-safe:LibreOffice 不在 / 轉檔失敗 → 回 skip 不阻擋
- audit_recent_ppts(reports_dir, hours=24, max_files=10)
  • 掃 reports/ 過去 24h 新生 .pptx(getmtime filter)
  • 對每個檔跑 check_ppt_file
  • 彙總總 issues
- push_ppt_audit_to_telegram(summary)
  • 有 issues 才推 Telegram(避免「無問題」洗版)
  • 每檔最多 3 張 slide / 每張 2 個 issue 列出

run_scheduler.py — 每日 22:00 cron
- run_ppt_vision_audit task wrapper
- PPT_VISION_ENABLED=false 時 service 內部 skip(不打 LLM)

設計哲學:
不動既有 5 個 prs.save() 呼叫點(risk 高)→ 改寫獨立 daily cron 集中處理
零侵入 PPT 生成主流程 / 零 risk regression / feature flag OFF 預設

部署需求:
LibreOffice headless(apt install libreoffice)— 不在則 cron task 自動 skip + log

tests/test_ppt_vision_audit.py (9 tests 全綠)
- flag OFF skip / 目錄不存在 / 無 .pptx
- 舊檔(>hours)filter / LibreOffice 不在 fail-safe
- check_ppt_file flag/missing 容錯
- Telegram 推播:無 issues 不推 / 有 issues 推

regression: ppt_vision_service 既有 6 tests 全綠

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 11:16:11 +08:00
OoO
bd32e04dad feat(p25): 反饋環深化 — caller-level quality 趨勢追蹤 + ROI 月報整合
All checks were successful
CD Pipeline / deploy (push) Successful in 3m2s
Operation Ollama-First v5.0 / Phase 25 — 反饋環自主學習深化

services/feedback_quality_tracker.py (180+ 行)
- 純 SQL 統計,零 LLM 成本
- 4 個閾值常數(demote 👎×5/avg<2.5 / promote 👍×10/avg>=4.5)
- compute_caller_quality_trend(days=7) — 取近 N 日各 caller 反饋
- get_caller_recommendations() — 給 token 日報/ROI 月報用
  • 規則 1: 👎 ≥ 5 次 → review
  • 規則 2: avg < 2.5 + 樣本足 → review
  • 規則 3: 👍 ≥ 10 + avg ≥ 4.5 → promote(建議關閉 Gemini fallback)
- should_demote_caller(caller) — 自動降權判斷(戰役預設不啟用)
- render_quality_summary() — 給訊息用 emoji 摘要

ROI 月報整合(services/roi_report_service.py):
- 加 Section 「💬 Caller 反饋趨勢(30 日)」TOP 10 by 最低 avg
- 加 Section 「🔮 智能建議」最多 3 條(review / promote)
- 失敗 swallow 不影響月報主流程

訊息範例:
  💬 Caller 反饋趨勢(30 日)
    ⚠️ openclaw_qa: avg 1.85/5 (👍2 👎8 n=12)
     hermes_analyst: avg 3.10/5 (👍5 👎3 n=10)
     ppt_gemini: avg 4.75/5 (👍12 👎0 n=15)
  🔮 智能建議
    ⚠️ openclaw_qa: 近 30 日 👎 反饋 8 次 (avg 1.85/5) — 建議統帥檢視 prompt 或切換 model
     ppt_gemini: 近 30 日 👍 反饋 12 次 — 可考慮關閉 Gemini fallback 純走 Ollama

tests/test_feedback_quality_tracker.py (10 tests 全綠)
- 4 閾值常數 / DB fail 安全 / 空 trends 容錯
- demote 規則(👎 多次)/ promote 規則(👍 多次)/ neutral 不觸發
- should_demote_caller 樣本不足保護
- trend 分類(positive/negative/neutral/no_data)正確

依 ADR-032 RAG 自主學習迴圈 + ADR-033 護欄 #1
不直接改 caller 行為(避循環自動修正失控),只產出建議給統帥審視。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 11:12:52 +08:00
OoO
0476d3ae4e feat(p24): ROI 月報生成器 — 每月 1 日 09:00 推 Telegram
All checks were successful
CD Pipeline / deploy (push) Successful in 2m49s
Operation Ollama-First v5.0 / Phase 24 — 戰役 ROI 自動量化

services/roi_report_service.py (200+ 行)
- BASELINE 戰前估算(gemini 50M/$20、nim 5.8M、ollama 30M、total $25/月)
- query_last_month_stats() — SQL 查上月 ai_calls + mcp_calls + rag_query_log
- render_roi_report(stats) — HTML 訊息(含 5 區塊:成本攔截/provider 分布/RAG/MCP+Cache/KPI)
- generate_and_send_roi_report() — 主入口,推 Telegram + 寫 ai_insights 長期記錄
- 達標標記:Gemini -23.5%  / RAG 命中 ≥25% 

Telegram 訊息範例:
  📊 ROI 月報 2026年04月
  💰 成本攔截
    Gemini: 35,000,000 tokens / $14.00
    vs 戰前: 50,000,000 / $20.00
     攔截: 15,000,000 tokens / $6.00 (30.0%)
  🤖 Provider 分布
  🧠 RAG 自主學習(含 saved_call / 反饋分數)
  🔧 MCP + Cache
  📈 戰役 v5.0 KPI  達標

run_scheduler.py — 每日 09:00 跑(內部判斷月初第 1 日才送)
- run_roi_monthly_report_if_new_month task wrapper
- 失敗 swallow log,不影響其他排程

tests/test_roi_report_service.py (7 tests 全綠)
- BASELINE 必要欄位 / 月份範圍計算 (1月→去年12月)
- 達標訊息含  + 攔截數字
- 未達標訊息含 ⚠️
- 空 stats 容錯 / DB fail 回空 dict 不 raise

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 11:04:14 +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
f11b0cc732 test(p19): 補 Phase 14/15/16/17 unit test — 27 tests 全綠
Operation Ollama-First v5.0 / Phase 19 — 補完戰役紀律

tests/test_caller_registry.py (7 tests)
- registry 含 30+ 核心 caller (ADR-028 對齊)
- is_known_caller / assert_known_caller strict=False/True 行為
- ai_call_logger 整合:未知 caller log warning 不阻擋
- frozenset 不可變動

tests/test_deepseek_service.py (6 tests)
- is_available() 需 KEY + flag 雙條件
- generate flag OFF / 200 success / 500 / timeout
- usage tokens 解析(prompt_tokens / completion_tokens)

tests/test_ppt_vision_service.py (6 tests)
- flag OFF 不打 HTTP / 檔不存在
-  無視覺異常 / ⚠️ marker 解析
- HTTP 500 觸發 mark_unhealthy / timeout fail-safe

tests/test_low_quality_response_v2.py (8 tests)
- 規則 5 純英文回應 (中文 < 30%)
- 規則 6 thinking-mode 漏洞 <think>...</think>
- 規則 7 重複迴圈 (前 50 字 ≥ 3 次)
- 規則 8 佔位符 ({{var}} / [TODO] / <待填>)
- 合法繁中商業文字應通過 8 條規則

regression: 全戰役 unit test 累計 241 tests
- Phase 1: 52 (logger + report)
- Phase 2: 14 (ollama_resolve)
- Phase 3: 36 (qa/golden/nemotron/daily)
- Phase 7: 23 (anthropic + code_review)
- Phase 11: 70 (rag + learning + promotion)
- Phase 10.5: 8 (mcp_router)
- Phase 13: 10 (retry chain)
- Phase 19: 27 (caller_registry + deepseek + ppt_vision + lq_v2)  新

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 10:27:35 +08:00