Commit Graph

83 Commits

Author SHA1 Message Date
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
ogt
c8ceec1f5f fix: expand rule engine keywords to catch brand/strategy/investment queries
All checks were successful
CD Pipeline / deploy (push) Successful in 1m53s
'品牌','廠商','加碼','投資','策略','建議','市場','機會','成長',
'預測','比較','推薦','最佳' now trigger complex routing → Gemini

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 20:23:12 +08:00
ogt
388260666e perf: reduce Hermes timeout 25s→10s — Gemini handles main response
All checks were successful
CD Pipeline / deploy (push) Successful in 1m16s
Hermes on 111 GPU takes 17s+ due to concurrent load.
Intent classification is just routing hint; Gemini/NVIDIA NIM does
actual heavy analysis. 10s timeout → quick rule engine fallback → faster UX.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 11:09:24 +08:00
ogt
9d0e083504 fix: increase Hermes timeout 20s→25s (measured 17s from container to 111)
All checks were successful
CD Pipeline / deploy (push) Successful in 1m22s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 11:06:15 +08:00
ogt
05f2064346 fix: correct Gemini model name + use accessible NVIDIA NIM model
All checks were successful
CD Pipeline / deploy (push) Successful in 1m17s
gemini-2.5-flash-preview-05-20 → gemini-2.5-flash (correct API name)
nvidia/llama-3.1-nemotron-ultra-253b-v1 → meta/llama-3.3-70b-instruct
(nemotron-ultra requires premium account, llama-3.3-70b confirmed accessible)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 11:03:11 +08:00
ogt
c299abba5d fix: restore Hermes to 111+hermes3 + add NVIDIA NIM auto-fallback for OpenClaw
All checks were successful
CD Pipeline / deploy (push) Successful in 3m0s
Hermes was wrongly redirected to 188 (CPU-only, 60s+ timeout).
111 has hermes3:latest with GPU acceleration (~10s response).

OpenClaw now auto-detects:
  1. Gemini (primary, when GEMINI_API_KEY set)
  2. NVIDIA NIM nemotron-ultra (auto-fallback, NVIDIA_API_KEY already set)
  3. Friendly error only when both are unavailable

This implements the user-requested auto-failover pattern: always try
primary first, silently fall back, restore automatically when primary recovers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 10:31:00 +08:00
ogt
e9e0ddf54f fix: json.dumps dict before psycopg2 insert + remove fatal raise in save_context
All checks were successful
CD Pipeline / deploy (push) Successful in 1m22s
save_context/_save_action_plan passed raw Python dicts as SQL bind params,
causing psycopg2.ProgrammingError that propagated via raise and crashed the
entire AI pipeline, forcing every natural language message to keyword fallback.

Also increase Hermes intent timeout 15s→30s for qwen2.5 cold-start latency.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 10:12:20 +08:00
ogt
e4ad2432fd fix: remove bogus SSHJumpExecutor re-export that broke telegram AI import chain
All checks were successful
CD Pipeline / deploy (push) Successful in 1m43s
SSHJumpExecutor class never existed in auto_heal_service.py.
The dead import caused ImportError blocking telegram_ai_integration
from loading, which broke all natural language conversation in the bot.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 09:47:31 +08:00
ogt
4ff291b596 fix: 修復 AI 對話無法使用 + 全面繁體中文化
All checks were successful
CD Pipeline / deploy (push) Successful in 1m28s
- telegram_ai_integration.py 移至 services/ 解決 ModuleNotFoundError
  (momo-telegram-bot 只掛載 services/,根目錄檔案進不了容器)
- import 路徑更新為 from services.telegram_ai_integration
- 所有英文回覆字串改為繁體中文:
  · 歡迎訊息、fallback 訊息、錯誤提示
  · _enhanced_keyword_matching 全英文段落
  · _handle_complex_ai_response / _handle_simple_ai_response
  · Cancel 按鈕改「 取消」、callback 改 menu:main

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 09:41:55 +08:00
ogt
d5c0feab5e fix: Telegram bot 全功能修復 — 16個await按鈕/AI對話/模型遷移/DB schema
All checks were successful
CD Pipeline / deploy (push) Successful in 1m35s
## Telegram Bot 功能修復
- 補全 16 個 await: 按鈕的 handler(日期選擇/目標設定/促銷追蹤等),
  新增 _handle_await_callback + _process_await_input 完整狀態機
- cmd: 按鈕加入  即時回饋 + try/except 防 BadRequest
- handle_callback 加頂層 try/except 錯誤兜底
- 補 momo:cmd:suggestion + momo:menu:main callback handler
- 修復 _enhanced_keyword_matching context NameError

## AI 模型遷移(hermes3@111 → qwen2.5@188)
- hermes_analyst_service: URL 192.168.0.111→188, hermes3→qwen2.5:7b-instruct
- code_review_pipeline: 改用 HERMES_URL/HERMES_MODEL 常數
- elephant_alpha_orchestrator / nemoton_dispatcher: registry/footprint 同步
- aider_heal_executor: OLLAMA_API_BASE fallback 改 188
- ai_routes: footprint display 字串改 qwen2.5:7b-instruct

## ElephantAlpha 404 修復
- elephant_service: openrouter→NVIDIA NIM, nvidia/llama-3.1-nemotron-ultra-253b-v1
- ai_provider: 模型 ID 同步更新

## TELEGRAM_CHAT_ID 環境變數修正
- cicd_routes + aider_heal_executor: 優先讀 TELEGRAM_CHAT_IDS[0],
  fallback TELEGRAM_CHAT_ID,修復通知靜默失敗

## AI 對話 logging 改善
- telegram_ai_integration: Hermes 降級改 WARNING,OpenClaw 失敗加 exc_info
- hermes_analyst_service: 連線失敗 log 加 host/model context

## DB Schema 修復
- migrations/019: action_plans 補齊全欄位,DROP NOT NULL action_type
- autoheal_models: ActionPlan ORM 同步為超集 schema

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 03:30:14 +08:00
ogt
5ef4151fa5 [V10.4-C] 三 AI NLP 鏈修復:Hermes/NemoTron/OpenClaw 全線串通
修復 P9-2 確認的自然語言對話完全失效問題:

- services/ai_orchestrator.py:
    4 處裸字串 SQL 全部包裝 text(),修復 SQLAlchemy 2.x ArgumentError
- services/hermes_analyst_service.py:
    新增 handle_l1() async 方法(Ollama hermes3 意圖分析 + rule-based fallback)
    asyncio.get_event_loop() → get_running_loop()(Py3.12+ 相容)
- services/nemoton_dispatcher_service.py:
    新增 handle_l2() async 方法(純 Python routing,不消耗 NIM 配額)
- services/openclaw_strategist_service.py:
    新增 generate_strategy_response()(Gemini 2.0 Flash,無 key 時優雅降級)
- telegram_ai_integration.py:
    整合 OpenClaw 為第三層(complexity >= 0.7 或 dispatch_to == "openclaw")
    _format_*_response 全改為繁體中文
    asyncio.get_event_loop() → get_running_loop()
    _extract_date_range "to" → "至"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 01:43:20 +08:00
ogt
3f7fc0aba0 [V10.4-B] Telegram 按鈕安全強化:C2/C3/H4/H6 修復
修復 P9-1 全景盤點所發現的四項高優先問題:

- routes/openclaw_bot_routes.py:
    C3: ALLOWED_USERS/ALLOWED_GROUP 白名單 fail-closed,阻擋非授權 chat
    H4: _seen_update_ids 改用 deque(maxlen=500) LRU 防記憶體洩漏
- services/telegram_bot_service.py:
    C2: 新增 momo:bpa/bpr/eig 三個 callback 分支 + handler 實作
    H6: callback 滑動視窗速率限制(30次/分鐘/用戶)
- services/telegram_templates.py:
    修正 decision_result / ops_action_result ImportError BLOCKER
    新增 _now_taipei_hhmm / _html_escape 輔助函式

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 01:42:58 +08:00
ogt
fcac03379d [V10.4-A] 加強 commit-quality Hook + P9 文件歸檔
新增 Edit/Write/MultiEdit 事件攔截(原僅攔截 git commit Bash 指令),
補齊 getenv fallback 模式偵測,防止 hardcoded Token 透過工具直寫入檔案。

- .claude/hooks/commit-quality.js: 改寫為 PreToolUse JSON 格式,覆蓋 Edit/Write/MultiEdit
- .claude/settings.json: 新增 Edit|Write|MultiEdit|Bash matcher 註冊
- .claude/hooks/__test__/commit-quality.test.sh: 4 case 自動化測試
- docs/guides/DISK_EXPANSION_GUIDE.md: 磁碟擴充 SOP 歸檔
- docs/p9_completion_report_*.md: P9-1 + P9-2 Sprint 完成報告
- docs/refactor/callback_prefix_proposal.md: 308 按鈕回呼前綴分析(Method C)
- docs/refactor/openclaw_bot_routes_split_plan.md: 5999 行神檔拆分計畫

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 01:42:40 +08:00
ogt
e9b2dabffd [V10.3] Telegram Bot AI integration and Traditional Chinese fix | services/telegram_bot_service.py, telegram_ai_integration.py 2026-04-22 15:03:47 +08:00
ogt
9793f7f5ed fix(code-review): EA 決策改為 ADR-014 全自動修復策略
All checks were successful
CD Pipeline / deploy (push) Successful in 1m16s
任何 finding 一律觸發 AiderHeal 自動修復,安全網為 Git+Gitea CI/CD 回滾防線。
移除 HIGH 1-2 → 人工審查的錯誤門檻,fix_files 範圍擴展至所有有問題的檔案。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 09:54:20 +08:00
ogt
b11789db77 fix(telegram+review): 修復 PPT 按鈕無反應 + Code Review 頁面空白
All checks were successful
CD Pipeline / deploy (push) Successful in 1m28s
PPT 按鈕:
- telegram_bot_service.py 新增 cmd:* handler,透過 Thread 轉發到
  OpenClaw Flask 內部 API(/bot/internal/cmd)
- openclaw_bot_routes.py 新增 /bot/internal/cmd 端點,背景執行 handle_cmd()

Code Review 頁面:
- get_history() 補回 findings / openclaw_report 欄位
- code_review.html history 項目可點擊,自動載入詳細內容
- poll() 無 active pipeline 時自動顯示最新歷史記錄

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 08:56:10 +08:00
ogt
0099543c05 fix(security): 全域健檢 — 40 項安全/Bug/品質修復
Some checks failed
CD Pipeline / deploy (push) Failing after 5m18s
🔴 Critical
- auto_heal_service: 補 import re + sqlalchemy.text + 修正 orchestrator 變數名
  + autoheal_playbook→playbooks 表名 + _alert_and_store cooldown 修復
- aider_heal_executor: shell injection 改 shell=False + list 參數
- docker-compose: DISABLE_LOGIN 改 env var + 移除密碼 fallback + POSTGRES_HOST 修正
- app.py: /api/backup /api/run_task 等 6 個管理 API 加 @login_required
- config.py + pg_sync + e2e_test: 移除 wooo_pg_2026 hardcoded 密碼 fallback
- pg_backup.sh: 移除 TELEGRAM_TOKEN= 中間變數,直接用 $TELEGRAM_BOT_TOKEN
- migration 014: trigger_pattern→match_pattern + 補 error_type NOT NULL 欄位

🟡 High
- telegram_bot_service: str(e) 改通用訊息 + session try/finally + 移除 pa:/pr: 舊 callback
- run_scheduler: ElephantAlpha thread 死亡監控 + 自動重啟 + Telegram 告警
  + agent_context 03:30 TTL 定時清理任務
- openclaw_learning_service: build_rag_context 兩路徑加 .limit(200)
- hooks: commit-quality + momo-prod-guard 空 catch 改 stderr+exit(1)
- scripts/code_review: auto_yes 預設改 false
- db_backup_service: PGPASSWORD 透過 env dict 傳遞

📦 Migrations
- 013_autoheal: 修正建表順序 playbooks→incidents(外鍵前向引用)
- 018_add_missing_indexes: heal_logs/incidents 外鍵索引 + cleanup_expired_agent_context()

🟢 Infrastructure
- requirements.txt: 加版本下界 Flask>=2.3 SQLAlchemy>=1.4 等
- cd.yaml: 新增 run_scheduler.py + run_telegram_bot.py 監聽路徑
- .gitignore: insert_playbook_local.py 加入忽略

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 01:12:23 +08:00
ogt
1f7b903d36 fix(code-review): 修復 Hermes 401 與 OpenClaw GEMINI_API_KEY 缺失
All checks were successful
CD Pipeline / deploy (push) Successful in 1m17s
Hermes 掃描:改直呼內網 http://192.168.0.111:11434/api/generate
(棄用 ai_provider_service,避開公網 Ollama 401 認證問題)

OpenClaw 評估:Gemini 優先,降級用 elephant_service(OpenRouter)
(容器內無 GEMINI_API_KEY,但 OPENROUTER_API_KEY 一定存在)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 21:16:44 +08:00
ogt
2e0de960ce feat(code-review): 重建為 Post-Deploy AI Agent Pipeline
All checks were successful
CD Pipeline / deploy (push) Successful in 1m21s
架構重建:
- 移除 pre-commit hook(本機 commit 不再阻塞)
- 改為 CD 健康檢查通過後自動觸發 webhook

新建 services/code_review_pipeline_service.py:
  5-Step Pipeline(後台 daemon thread)
  Step1 system        讀取部署後變更檔案內容
  Step2 Hermes        程式碼掃描(bugs/security/perf,hermes3:latest)
  Step3 OpenClaw      架構品質評估(Gemini 2.5 Flash)
  Step4 ElephantAlpha 決策協調(severity + auto_fix 裁量)
  Step5 NemoTron      action_plans 寫入 + AiderHeal 觸發
  全程 Telegram 告警(啟動/完成/錯誤)+ ai_insights DB 持久化

重建 routes/code_review_routes.py:
  POST /code-review/api/internal/trigger  CD webhook(X-Internal-Token)
  GET  /code-review/api/status            前端即時 polling
  GET  /code-review/api/history           歷史清單
  GET  /code-review/                      前端儀表板

重建 templates/code_review.html:
  深色儀表板,Pipeline 即時進度 + Severity 分佈 + 問題清單 + EA 決策
  3s polling(running)/ 30s(idle)

.gitea/workflows/cd.yaml:
  健康檢查通過後注入「觸發 AI Code Review」step
  continue-on-error: true(不影響部署結果)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 20:55:23 +08:00
ogt
38200a5e93 feat(reports): 新增日報/月報系統,整合圖表推播至 Telegram
All checks were successful
CD Pipeline / deploy (push) Successful in 4m51s
- services/openclaw_strategist_service.py:新增 generate_daily_report()(每日09:00業績快報+競品威脅+2圖表)和 generate_monthly_report()(每月1日07:00月度全景洞察+3圖表+MoM/YoY比較)
- services/chart_generator_service.py:新建圖表生成服務(6種深色商業圖表,revenue_trend / category_revenue / monthly_overview / price_gap / price_history_heatmap / price_trend)
- services/telegram_templates.py:重建訊息模板系統(5類模板:告警/報告/決策/系統/洞察)、新增 send_photo + send_report_with_charts 圖文推播
- scheduler.py:新增 run_daily_report_task / run_monthly_report_task(含 auto_heal 保護)
- run_scheduler.py:每日09:00日報 + 每月1日07:00月報排程(月報用每日gate判斷day==1)
- requirements.txt:新增 matplotlib + matplotlib-inline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 15:17:48 +08:00
ogt
784a3135c1 fix(telegram): 修正 EA 通知格式與 Agent 名稱問題
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
- 禁止 Gemini 音譯 Agent 名稱(赫瑪斯→Hermes, 內莫特朗→NemoTron)
- _AGENT_ZH 改為 _AGENT_LABEL,保留英文原名
- orchestrator system/user prompt 強制 reasoning 必須含具體數字
- _notify_telegram_executed 改為直接組裝訊息,顯示效益/依據/步驟
- _escalate_to_human 使用 _AGENT_LABEL 替換 _AGENT_ZH

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 13:03:49 +08:00
ogt
a62b83f488 feat(aiops): 完整 MCP + OpenClaw 全景電商分析管線
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
- 新增 services/mcp_collector_service.py:Gemini Search Grounding 外部情報收集
- 重寫 services/openclaw_strategist_service.py:真實 Gemini 2.5 Flash 分析,DB 持久化
- scheduler.py:修復 generate_meta_analysis_report ImportError,串接 Meta-Analysis
- elephant_alpha_autonomous_engine.py:新增 weekly_insight 觸發器路由 OpenClaw

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 12:50:35 +08:00
ogt
31dfbcdd4d fix(i18n): 強制 Elephant Alpha Gemini 回應繁體中文
All checks were successful
CD Pipeline / deploy (push) Successful in 1m20s
- aider_heal_executor.py:全檔簡體→繁體,所有 Telegram 通知節點繁化
- elephant_alpha_orchestrator.py:system prompt 與 user prompt 雙層加入語言強制指令,確保 reasoning/expected_outcome 等欄位輸出繁體中文

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 12:22:13 +08:00
ogt
bf5f0d256a fix(aiops): resolve ADR-014 logical bugs
- Fixed target_file context passing in auto_heal_service
- Fixed docker log scanning inside momo-scheduler using SSHJumpExecutor
- Fixed AiderHealExecutor SSH key path
2026-04-20 23:25:49 +08:00
ogt
3127466a85 feat(aiops): implement ADR-014 Autonomous Code Heal Pipeline
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
- Added AiderHealExecutor for SSH remote execution of aider-chat
- Added CODE_FIX action_type to AutoHealService
- Added code_exception trigger to Elephant Alpha engine (Traceback log scanning)
- Added 014 playbook migration script
2026-04-20 23:13:32 +08:00
ogt
b8e6f752fa fix: 修復 Telegram Bot /menu 指令無響應及重複訊息問題
Some checks failed
CD Pipeline / deploy (push) Failing after 55s
- telegram_bot_service: 新增 /menu 指令處理器,映射到 cmd_start
- openclaw_bot_routes: 優化「今日業績資料尚未匯入」訊息邏輯
  - 區分「資料載入異常」vs「確實未匯入」
  - 避免在已有今日資料時仍顯示未匯入訊息

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 22:48:07 +08:00
ogt
48804553cd feat: PPT 簡報系統 V2 — 新增 growth/vendor/bcg 三種報告 + 原生圖表升級
All checks were successful
CD Pipeline / deploy (push) Successful in 1m15s
- ppt_generator.py: 新增 generate_growth_ppt(6頁)、generate_vendor_ppt(5頁)、generate_bcg_ppt(5頁)
- openclaw_bot_routes.py: 新增 query_growth_data()、query_vendor_bcg_data()、_generate_ppt_cmd 三路分支、_submenu_reports 4顆新按鈕、type_labels、await:date_ppt_vendor 流程
- ADR-014: 記錄 V2 完整架構(9種報告類型、圖表技術方案、callback_data 格式)
- CLAUDE.md: 新增 PPT 簡報系統索引表

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 20:26:47 +08:00
ogt
b2803c90be fix: DOCKER_RESTART 改走 SSH 跳板(110→188),修復 AIOps AutoHeal 閉環
All checks were successful
CD Pipeline / deploy (push) Successful in 1m16s
根本原因:scheduler 容器內無 Docker socket,直接執行 docker restart 失敗。
修正:使用 SSHJumpExecutor(wooo@110 → ollama@188)透過跳板執行 docker restart。
SSH key:/app/config/autoheal_id_ed25519(rw mount 已存在)。
同步關閉 9 筆 2026-04-19 過期 DNS_FAIL incidents(根因已由網路修復解決)。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 20:19:46 +08:00