Commit Graph

110 Commits

Author SHA1 Message Date
OoO
72fa166729 fix(ai): 遷移 Ollama embedding 至 api embed
All checks were successful
CD Pipeline / deploy (push) Successful in 1m46s
2026-04-30 10:24:15 +08:00
OoO
91ad98e621 feat(ai): 強化 ElephantAlpha NIM fallback
All checks were successful
CD Pipeline / deploy (push) Successful in 1m48s
2026-04-30 09:33:39 +08:00
OoO
d5f4fd7198 加入 AI Smoke 每日摘要推播
All checks were successful
CD Pipeline / deploy (push) Successful in 1m15s
2026-04-29 23:57:36 +08:00
OoO
10bbd55f5b 補齊 AI Smoke 趨勢管理
All checks were successful
CD Pipeline / deploy (push) Successful in 1m13s
2026-04-29 23:54:23 +08:00
OoO
81159b5b3d 保存 AI Smoke 趨勢紀錄
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
2026-04-29 23:50:44 +08:00
OoO
cde8b0cd3e 新增 AI 自動化 Smoke Dashboard
All checks were successful
CD Pipeline / deploy (push) Successful in 1m16s
2026-04-29 23:46:48 +08:00
OoO
e6a1c9d09f 補齊 AI 自動化可觀測性指標
All checks were successful
CD Pipeline / deploy (push) Successful in 1m15s
2026-04-29 23:41:03 +08:00
OoO
162a76b8f9 落地 L2 安全記憶動作
All checks were successful
CD Pipeline / deploy (push) Successful in 1m9s
2026-04-29 23:29:45 +08:00
OoO
5b25f55340 補齊 EventRouter 失敗通知回放
All checks were successful
CD Pipeline / deploy (push) Successful in 1m10s
2026-04-29 23:26:02 +08:00
OoO
d4865983d8 補強 ElephantAlpha 執行與通知閉環
All checks were successful
CD Pipeline / deploy (push) Successful in 1m10s
2026-04-29 23:14:09 +08:00
OoO
78eebfbcfc 加入告警去重與洞察向量回補
All checks were successful
CD Pipeline / deploy (push) Successful in 1m19s
2026-04-29 23:10:27 +08:00
OoO
0c2e9bbced 串接 AI 洞察向量化與漏通知入口
All checks were successful
CD Pipeline / deploy (push) Successful in 1m13s
2026-04-29 23:05:46 +08:00
OoO
f0e044aa48 補齊自癒稽核與 OpenClaw 記憶閉環
All checks were successful
CD Pipeline / deploy (push) Successful in 1m16s
2026-04-29 23:02:06 +08:00
OoO
1c2dc6cd61 補強 AI 自動化閉環與安全降級
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
2026-04-29 22:56:00 +08:00
OoO
0875dd8fda 補強 5.5 自癒安全回看
All checks were successful
CD Pipeline / deploy (push) Successful in 1m11s
2026-04-29 22:48:24 +08:00
OoO
779b27f676 修復 P0 告警自癒鏈與測試收集
All checks were successful
CD Pipeline / deploy (push) Successful in 9m39s
2026-04-29 22:37:20 +08:00
OoO
4cbd775c1b fix(aiops): 補齊 Elephant Alpha trigger context
All checks were successful
CD Pipeline / deploy (push) Successful in 1m39s
部署閘門修復:補 autonomous engine 的 confidence/max decision 初始化與 _build_trigger_context,避免 scheduler autonomous monitoring 持續噴 AttributeError。
2026-04-29 21:48:41 +08:00
OoO
4d5a995718 chore: 刪除孤兒 AI service 並補齊 env 範例
ADR-017 Phase 3f-5:刪除未被 runtime 引用的 elephant_alpha_decision_router、telegram_ai_integration、watcher_agent;補 .env.example 的 Aider/AutoHeal/NVIDIA/OpenClaw/backup/report/PG sync 等實際讀取變數。
2026-04-29 21:46:24 +08:00
OoO
9528d6c23e fix(stability): 補強 scheduler 例外處理與 vendor 模板路徑
ADR-017 Phase 3f-3:移除 scheduler 裸 except,P1 任務失敗改走 EventRouter notify_failure 同步入口;清理 docker-compose vendor 死 mount;修正 vendor_bp template_folder 指向專案 web/templates。
2026-04-29 21:39:25 +08:00
OoO
13fa165ee2 refactor(cache): 統一 cache SOT 並啟用 gunicorn preload
ADR-017 Phase 3f-2:新增 services/cache_manager.py,讓 sales/import/export/daily/dashboard 共用同一份 in-memory cache;cache_service 改為相容 shim;Dockerfile/docker-compose 啟用 gunicorn --preload。
2026-04-29 21:35:56 +08:00
OoO
f4149d4c05 fix(db): 補全 metadata model import 與 realtime sales ORM
ADR-017 Phase 3f-0
2026-04-29 21:00:46 +08:00
OoO
3971fd4020 fix(daily_sales): cache 失效改 DB fingerprint + clear_cache 加 @login_required
All checks were successful
CD Pipeline / deploy (push) Successful in 1m12s
回應 critic 對 8fefea0 的 4 個 HIGH finding(debugger/web-researcher/migration-engineer 三方共識):

HIGH-3 修復:
- /api/daily_sales/clear_cache 加 @login_required,避免外部 DoS 攻擊清快取

HIGH-4 修復(核心):
- 新增 _get_data_fingerprint(engine):SELECT MAX(snapshot_date), COUNT(*) FROM daily_sales_snapshot
- _is_cache_valid 改雙閘:TTL(保險絲)+ DB fingerprint(強一致)
- 三個 cache 寫入點同步記錄 fingerprint
- 移除 services/import_service.py 的 4-worker N-POST hack(命中率僅 9.4%,
  coupon collector 機率:4!/4^4 = 0.094)
- 資料寫入後指紋自動跳號,4 worker 下次 request 各自偵測失效並重載 → 強一致

附帶修:
- 統一 export/export_marketing 兩處 cache 寫入結構(補 timestamp/fingerprint),
  解決 db-expert 標記的「export 端點 cache 缺 timestamp 導致主看板每次都重讀」瑕疵

未處理(留待後續):
- HIGH-2: app.py 仍有 43 處 _SALES_PROCESSED_CACHE(sales_analysis 等其他路由的獨立 cache)
  待後續 P9 統一抽 services/cache_manager.py

[P7-COMPLETION]
方案: critic + debugger + web-researcher + migration-engineer 四方共識的方案 B
影響: routes/daily_sales_routes.py + services/import_service.py 兩檔
Regression: 每 request 多 1 次 SELECT MAX/COUNT(< 5ms),其餘行為等價
2026-04-29 09:10:23 +08:00
OoO
8fefea05da fix(daily_sales): 啟用 bp 版改進邏輯 + import 後跨 worker 清 cache,根除 #24 隱形 bug
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
- 從 app.py 刪除 396 行的 /daily_sales、/daily_sales/export、/daily_sales/export_marketing
  三條 @app.route(行 5911-6306),讓 routes/daily_sales_routes.py 的 daily_sales_bp
  生效(first-registered wins,原 app.py 版本 shadow 了 bp)。
- bp 版改進點:_is_cache_valid() 帶 5 分鐘 TTL、/api/daily_sales/clear_cache 端點、
  完整模板參數(datetime_now / active_page)。
- services/import_service.py process_daily_sales_import return True 前,
  新增跨 gunicorn worker 清 daily_sales cache 邏輯:依 GUNICORN_WORKERS 次數呼叫
  internal /api/daily_sales/clear_cache,避免 4 worker 各持 5 分鐘舊快取
  導致「匯入 15323 筆但當日業績看不到」隱形 bug。

[P7-COMPLETION]
- 方案正確: 雙重佐證(refactor-specialist + web-researcher)確認 Flask first-registered
  wins,刪 app.py 內 route 即可讓 bp 接管;helper 函式(preprocess_daily_sales_data 等)
  為 dead code 但保守保留不影響執行。
- 影響完整: 全 repo grep 確認 _SALES_PROCESSED_CACHE 在 app.py 仍有 30+ 處使用
  (sales_analysis 等其他路由),未動到;helper 函式無外部 caller。
- Regression 風險: 低,bp 版簽名與行為相容;新 cache 清除走 internal HTTP 帶 try/except
  不影響主流程;若 GUNICORN_WORKERS 未設則默認 4 與生產一致。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 21:18:17 +08:00
OoO
333fc159ae fix: CodeReview Gemini 模型從已下架 preview 換成 gemini-2.5-flash
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
services/code_review_pipeline_service.py:41 OPENCLAW_MODEL 預設值
gemini-2.5-flash-preview-05-20 已被 Google 下架(404 not found),
改為穩定 GA 版本 gemini-2.5-flash。

驗證:直接 API 測試
- gemini-2.5-flash → 200 
- gemini-2.5-flash-preview-05-20 → 404 

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 21:01:44 +08:00
ooo
c91dc273f0 refactor(p1-01f): JSON 持久化抽到 services/json_storage.py
All checks were successful
CD Pipeline / deploy (push) Successful in 1m9s
- load_categories / save_categories / load_scheduler_stats 三個函數搬出
- CATEGORIES_JSON_PATH / SCHEDULER_STATS_PATH 常數同步搬移
- app.py 改 import 維持原呼叫路徑

行數變化: app.py 7,070 → 7,053 (-17)
2026-04-28 19:42:05 +08:00
ooo
d4ea555030 refactor(p1-06/07): daily_sales 純函數抽到 services/
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
- 新增 utils/df_helpers.py 放共用 find_col(避免 routes/services 雙向依賴)
- 新增 services/daily_sales_service.py 收:
  * get_taiwan_holiday(date)
  * prepare_calendar_data(df, selected_month)
  * prepare_marketing_summary(df, ...)
- routes/daily_sales_routes.py 改為 import service,行數 949 → 713(-236)
- 行為 100% 保留,僅檔案位置搬移
2026-04-28 15:37:07 +08:00
OoO
421395eb86 config: 暫停 valentine_520 與 labor_day 爬蟲(LPN 不存在)
Some checks failed
CD Pipeline / deploy (push) Failing after 1m50s
- 520 情人節主會場尚未上線(預計 5/10~5/15 momo 才會發布)
- 勞動節 momo 歷年無獨立主會場,常合併進春日/桃金日活動
- 清空兩者 lpn_code 避免共用 mothers_day LPN 灌入錯誤標籤資料
- 加註 pause_reason 與 paused_date 供後續 LPN 補回時參考

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 15:26:20 +08:00
OoO
b49b704e82 fix(post-3.5g): restore generate_embedding for KM dual-write (CRIT-1)
從 4349db2~1 撈回 OllamaService.generate_embedding,補齊被誤刪的方法。

問題:
- services/openclaw_learning_service.py:67 仍呼叫 ollama_service.generate_embedding(...)
- 4349db2 大改時把這個方法刪掉,導致每次 NemoTron 寫入學習資料時觸發
  AttributeError: 'OllamaService' object has no attribute 'generate_embedding'
- pgvector KM 因此完全停寫,違反 ADR-007 雙寫鐵律

修法:
- 把 method paste 回 OllamaService 末端(line 508)
- 對齊現代 config:os 已在檔案頂部 import,移除方法內重複 import
- embedding 走 EMBEDDING_HOST(Hermes 主機,內網免認證)
- model 預設 bge-m3:latest(ADR-003 對齊)

驗證:
- AST parse OK
- grep 'def generate_embedding' 已存在

Critic finding: CRIT-1
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 14:40:22 +08:00
OoO
5d0a9606d6 config: 填入 LPN 代碼並啟用三個促銷活動爬蟲 (O7ylWdZJHj8)
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
2026-04-28 14:10:31 +08:00
OoO
af260c4a01 feat: 新增三個促銷活動爬蟲支援(母親節、520情人節、勞動節)
All checks were successful
CD Pipeline / deploy (push) Successful in 1m12s
- 新增通用促銷活動爬蟲函式 run_promo_event_task()
- 更新 crawler_config_loader.py 新增三個活動配置
- 更新 run_scheduler.py 動態註冊促銷活動爬蟲
- 新增 API 端點 /api/run_promo_event_task
- 新增三個前端儀表板路由(/edm/mothers_day, /edm/valentine_520, /edm/labor_day)
- 更新所有儀表板頁籤列表
- 新增配置檔案 services/data/crawler_config.json
- 新增使用文件 docs/guides/promo_event_crawler_guide.md
- 更新 agent_actions.py 允許重試列表
2026-04-28 13:57:44 +08:00
OoO
1ecec162dd fix: increase Ollama health check timeout to prevent false offline status
All checks were successful
CD Pipeline / deploy (push) Successful in 1m18s
2026-04-28 12:35:58 +08:00
OoO
d67d309ada fix(post-3.5e): store_conversation 簽章對齊呼叫端 (E4 P1 bug)
問題:3 個呼叫點傳 6 個 positional args,但定義只接 3 個,
TypeError 被 thread 內 except 吞掉,OpenClaw 答題對話沉澱靜默失敗,
違反 ADR-007 持久化鐵律(AI 學習數據必雙寫 DB+KM)。

修法(方案 A 元數據保留):
- 簽章:(user_id, user_message, bot_response)
       → (user_id, chat_id, user_message, bot_response, source='', used_sources=None)
- chat_id / source / used_sources 全部進 metadata,給未來分析用
- 呼叫點不需改動(args 已是 6 個,對齊新簽章)

驗證:AST inspect 確認 3 個呼叫點全部對齊新簽章。

Out-of-scope(暫不處理):
- 呼叫端寫死 user_id=0、chat_id=0,留給下一輪修
- 內部 store_insight 雙寫邏輯不動

錨點:services/openclaw_learning_service.py:330
呼叫點:routes/openclaw_bot_routes.py:4113, 4166, 4214
2026-04-28 12:29:48 +08:00
OoO
b766edfde2 fix: store_conversation signature, MCP model, and AI fallback message
All checks were successful
CD Pipeline / deploy (push) Successful in 1m18s
2026-04-28 12:26:49 +08:00
OoO
67509a4e42 fix(post-3.5c): Hermes 降級 logger 等級從 error → warning
Item #5:
- services/hermes_analyst_service.py:122 降級到規則引擎是預期 fallback
  路徑(不是錯誤),改用 logger.warning 與同檔 :175 一致

調查範圍(已查 grep "logger.error" + "降級|hermes|fallback"):
- services/nemoton_dispatcher_service.py:486 NIM content 解析失敗 → 真錯誤,保留 error
- services/nemoton_dispatcher_service.py:564 fallback 派發單筆失敗 → 真錯誤,保留 error
- routes/openclaw_bot_routes.py:4168 無 logger.error,候選位置無此 pattern(已查,無異狀)
2026-04-28 12:15:59 +08:00
OoO
b954cc37cf fix(post-3.5c): nemoton dispatcher IP 殘留集中化
餘震 C-1:
- services/nemoton_dispatcher_service.py:287 env fallback hardcoded
  192.168.0.111,違反 ADR-008 集中化原則
- 改從 config.HERMES_URL 集中讀取

Out-of-scope finding(不在本次修復範圍):
- line 286 仍寫死 "qwen2.5:7b-instruct",但實際模型是 hermes3:latest
  (與 hermes_analyst_service.py:30 不一致,應由後續 PR 處理)
2026-04-28 12:15:59 +08:00
OoO
60a7917634 fix(post-3.5c): 修正 hermes_analyst_service docstring 模型名稱誤導
餘震 B:
- services/hermes_analyst_service.py:7 註解寫 qwen2.5:7b-instruct
  但實際 line 30 HERMES_MODEL = "hermes3:latest"
- 同步修正 host 描述為「HERMES_URL(預設 192.168.0.111:11434)」
2026-04-28 12:15:59 +08:00
OoO
5340475570 fix(post-3.5c): hermes timeout 雙標統一 + 補 keep_alive
餘震 A — 昨天 Hermes timeout 真因(incident 核心):
- services/hermes_analyst_service.py:158 硬編碼 timeout=10,與 :406 用
  HERMES_TIMEOUT=120 雙標;payload 也沒帶 keep_alive,被別模型擠下後
  冷啟動 30+s 必中 timeout
- HERMES_TIMEOUT 從檔內常數提升至 config.py 集中管理(ADR-008)
- 兩個 payload (intent/batch) 都補 keep_alive=24h(ADR-012)
- intent 路徑 timeout 從 10s 改用 HERMES_TIMEOUT;keep_alive 確保熱駐留時
  實測仍 < 10s,不會撐到 120s 上限

檔案:
- config.py: 新增 HERMES_TIMEOUT 常數
- services/hermes_analyst_service.py: 移除檔內 HERMES_TIMEOUT、新增
  HERMES_KEEP_ALIVE、補 payload keep_alive、line 158 timeout 統一
2026-04-28 12:15:59 +08:00
OoO
32ac92b8f0 fix: _ssh_exec signature in ElephantAlpha
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-04-28 12:15:42 +08:00
OoO
3dd73dce03 fix: missing sqlalchemy text import and _ssh_exec in ElephantAlpha
All checks were successful
CD Pipeline / deploy (push) Successful in 1m20s
2026-04-28 12:13:44 +08:00
OoO
bc7113bc86 fix: ElephantAlpha crash, AiderHeal Ollama host, MCP integration for Hermes/NemoTron, and MCP hallucination
All checks were successful
CD Pipeline / deploy (push) Successful in 1m18s
2026-04-28 12:11:33 +08:00
OoO
30fc7609df fix: 將預設 Ollama 模型改為 111 主機已有的 llama3.1:8b
All checks were successful
CD Pipeline / deploy (push) Successful in 1m17s
2026-04-28 12:00:57 +08:00
OoO
4349db2015 feat: AiderHeal 支援 ssh 與 Ollama 設為首選 AI 引擎
All checks were successful
CD Pipeline / deploy (push) Successful in 8m40s
2026-04-28 11:41:12 +08:00
OoO
213216b495 fix: 優化 Telegram Bot 自然對話體驗,移除強制選單並串接 AI 引擎
All checks were successful
CD Pipeline / deploy (push) Successful in 1m18s
2026-04-28 11:33:02 +08:00
ogt
4a648ea6bf refactor: fix reverse dependencies — logger_manager→utils, dashboard_service extraction
- Move SystemLogger implementation to utils/logger_manager.py (pure utility, no deps)
- services/logger_manager.py becomes a backward-compat re-export shim
- database/manager.py and database/vendor_manager.py now import from utils layer
- Extract get_dashboard_stats() to services/dashboard_service.py
- services/task_runner.py no longer imports from routes layer
- routes/dashboard_routes.py get_dashboard_stats() delegates to service layer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 21:28:23 +08:00
ogt
b9fe98f591 refactor: centralize config — HERMES_URL, SSH params, validate_critical_config()
- config.py: add HERMES_URL (default 192.168.0.111:11434), SSH jump params, validate_critical_config()
- services/hermes_analyst_service.py: remove hardcoded HERMES_URL, import from config
- app.py: call validate_critical_config() on startup, log warnings for optional missing vars

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 21:27:47 +08:00
ogt
237d3af76f fix: Phase 2 P0 全清零 — 14 項安全與功能修復完成
Some checks failed
CD Pipeline / deploy (push) Failing after 2m59s
P0-06: google_drive_service.py — pickle.load() 改 JSON token(消除 RCE 風險)
P0-07: bot_api_routes.py:30 — BOT_API_TOKEN 移除硬編碼預設值 clawdbot_momo_2026
P0-08: auto_import_index.html — showAlert innerHTML 改 createTextNode(XSS 修復)
P0-09: abc_analysis_detail.html + dashboard.html + daily_sales.html — Jinja2 | e 轉義
P0-10: openclaw_bot_routes.py:2634 — vendor PPT 補 return ppt_path(廠商報告恢復)
P0-11: telegram_bot_service.py:177-214 — cmd_start/cmd_help 補 try/except
P0-12: app.py:689-712 — 10 個 Blueprint 補齊 register(消滅 404 路由)
P0-13: auto_heal_service.py — 實作 _write_heal_log(),AIOps 稽核閉環補完
P0-14: monitoring/prometheus.yml — 取消 alert_rules comment;新增 alert_rules.yml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 21:11:52 +08:00
ogt
f59b23f969 security: P0 修復 S1-S5 — 移除所有硬編碼密碼與 SQL Injection 漏洞
S1: config.py — LOGIN_PASSWORD 移除硬編碼預設值 0936223270,改 fail-fast
S2: config.py — SECRET_KEY 移除弱預設值,無值或預設值時 sys.exit(1)
S3: services/user_service.py — create_initial_admin 改讀 INITIAL_ADMIN_PASSWORD env
S4: app.py — 匯入流程 table_name 正規表達式白名單驗證,date_list 格式驗證
S5: database/manager.py — ALLOWED_SALES_TABLES frozenset 白名單,日期改參數化查詢

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 20:34:15 +08:00
ogt
b3a7909b2b fix: add try/except guards to all unprotected Telegram handler functions
All checks were successful
CD Pipeline / deploy (push) Successful in 1m29s
- Replace 2 silent `except Exception: pass` with logger.warning in handle_callback
- Wrap _handle_await_callback, _handle_main_menu_callback with top-level try/except (query.answer on error)
- Wrap _handle_complex_ai_response, _handle_simple_ai_response, _enhanced_keyword_matching, _process_await_input with top-level try/except (update.message.reply_text on error)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 19:47:49 +08:00
ogt
b4d208d34a fix: replace raise with warning in nemotron/hermes + fix hardcoded host in footprint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 19:46:04 +08:00
ogt
ac56139e74 fix: translate _get_query_suggestions to zh-TW + add missing promo_range await prompt
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 19:45:52 +08:00