Commit Graph

20 Commits

Author SHA1 Message Date
ogt
e15d543aa2 清除 AI 自動化 P2 人工語意債
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-07-01 14:01:21 +08:00
OoO
35ad29b04d V10.582 強化比價通知與身份證據
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
2026-06-04 14:03:21 +08:00
OoO
1f2e8b1e84 V10.430 preserve Nemotron decision callback IDs 2026-05-24 16:21:04 +08:00
OoO
0251835999 V10.428 add Nemotron price decision envelopes 2026-05-24 16:03:56 +08:00
OoO
78b6f156ba 強化商品比價身份分級與告警路由
All checks were successful
CD Pipeline / deploy (push) Successful in 1m9s
2026-05-21 14:04:06 +08:00
OoO
84fc60c059 fix: retry nemotron qwen3 across ollama hosts
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-13 21:24:53 +08:00
OoO
6313fdd293 對齊 Ollama-first flag 語義
All checks were successful
CD Pipeline / deploy (push) Successful in 56s
2026-05-13 12:00:21 +08:00
OoO
6aa5bcab88 fix(ollama-first): 3 個 feature flag 翻 ON — Ollama 優先、Gemini 殿後
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
統帥 2026-05-03 23:30 指令:「免費的優先!最後才是 Gemini」

3 個 flag 預設 false → true(GCP Primary qwen3:14b 已拉好,無阻擋):
  1. OPENCLAW_QA_OLLAMA_FIRST=true
     → Telegram 戰略 Q&A 走 qwen3:14b(繁中強制 prompt + Gemini fallback)
     → 預期月省 ~6.7M Gemini tokens(戰前 8.4M × 80%)
  2. OPENCLAW_DAILY_HERMES_TEMPLATE=true
     → 日報走 Hermes 模板 + Gemini 200 字洞察(28K → 8K, -71%)
     → 預期月省 ~600K Gemini tokens
  3. NEMOTRON_OLLAMA_FIRST=true
     → 威脅分派走 GCP qwen3:14b → NIM 備援 → ADR-004 規則引擎兜底
     → 預期月省 ~5M NIM tokens(解配額痛點)

合計月省 ~12M tokens(與 ADR-029 預估 -23.5% 對齊)

緊急停用:env 變數設 false 即可(保留 fail-safe)
品質風險:A7 Q&A 有 _is_low_quality_response 守門 → 低品質自動 fallback Gemini

Operation Ollama-First v5.0 / Phase 6.5 hotfix #2 / 落地統帥指令

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 23:28:45 +08:00
OoO
838267c293 feat(p1+p3): logger 接 13 caller + Q&A/Nemotron/日報 feature flag 灰度
Phase 1 A4 — 13 個呼叫點接 ai_call_logger(覆蓋率 11.8% → 預估 50%+)
- TOP-1 nemoton_dispatcher: nemotron_dispatch caller (NIM 配額追蹤)
- TOP-2 openclaw_strategist: 4 reports (daily/weekly/monthly/meta) + qa caller
- TOP-3 hermes_analyst: hermes_analyst + hermes_intent (順修 commit 00591c5 殘留 bug)
- TOP-4 code_review_pipeline: code_review_hermes/openclaw/elephant 三鏈 (request_id 串)
- TOP-5 openclaw_bot_routes: openclaw_bot_main/gemini/nim 三層 fallback

Phase 3 A7 — OpenClaw Q&A → qwen3:14b(feature flag OFF)
- OPENCLAW_QA_OLLAMA_FIRST 灰度開關
- 繁中強制 system prompt + Gemini fallback chain
- _is_low_quality_response 品質守門(簡體字檢測 + 拒答訊號 + 結構分數)
- 黃金集 A/B 對照測試框架(10 樣本去 PII)

Phase 3 A8 — OpenClaw 日報 → Hermes 模板(feature flag OFF)
- OPENCLAW_DAILY_HERMES_TEMPLATE 灰度開關
- _compute_daily_kpi 純 SQL + Hermes 規則引擎
- _compute_gemini_insight 精簡 200 字洞察 prompt
- templates/daily_report_v2.j2 + _SafeUndefined 缺欄位優雅降級
- scripts/compare_daily_report_versions.py 雙版本盲測

Phase 3 A9 — Nemotron NIM → qwen3:14b(feature flag OFF)
- NEMOTRON_OLLAMA_FIRST 灰度開關(A2 紅燈:deepseek-r1 假支援,改 qwen3)
- _call_qwen3_dispatch + 既有 NIM tool_calls 解析共用
- 保留 ADR-004「🟡 [降級模式]」Hermes 規則引擎兜底

H6 PII fix — chat_id 進 ai_calls.meta 改 SHA1[:8](4 處 Bot Q&A)

Code Review pipeline — N3 動態 provider tag(gcp/secondary/111)+ A4 logger 三鏈

37 unit tests 全綠(routing 15 + golden 5 + qwen3 8 + daily template 8 + nemotron 1)

Operation Ollama-First v5.0 / Phase 1 A4 + Phase 3 A7+A8+A9

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 23:05:38 +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
edfe38e87d refactor(telegram): migrate nemoton_dispatcher sender to EventRouter (ADR-019 Phase 5)
NemoTron Dispatcher 的 _send_telegram() 原本直接 POST Telegram Bot API(含 MarkdownV2
跳脫)+ 透過 self.nm 走 NotificationManager 兩條路。改為統一走 services.event_router.
dispatch_sync(),享 EventRouter 的 retry + 失敗 JSONL queue replay + AI 三層分流。

行為變化:
- 從 _exec_trigger_price_alert / _exec_add_to_recommendation / _exec_flag_for_human_review
  三個工具實作流入 EventRouter,event_type=nemoton_dispatch_alert,severity=alert
- 移除 self.nm._send_telegram_messages() 的 short-circuit;改由 EventRouter 內建
  通道處理 chat_ids/token 解析
- 失敗時保留 logger.error + log fallback,不阻斷主線(同舊行為)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 13:09:34 +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
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
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
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
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
8c6fe961cb feat(nemoton): 新增 route_to_km + mark_for_relearn 工具
All checks were successful
CD Pipeline / deploy (push) Successful in 1m7s
- route_to_km: NIM 決策後靜默歸檔洞察到指定 KM 領域
  (price_competition / sales_anomaly / promotion_opportunity / market_trend)
- mark_for_relearn: 新數據推翻歷史洞察時,批次更新 ai_insights.status='relearn'
  + feedback_down+1,供品質分數重算批次感知
- TOOL_MAP 加入兩個新 handler,Python 獨裁層補 route_to_km threat 注入

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 11:26:48 +08:00
ogt
709efb6e37 feat(adr-004): NIM HTTP 429 → Hermes 規則引擎降級路由
All checks were successful
CD Pipeline / deploy (push) Successful in 1m10s
- _call_nim(): 429 不重試,立即拋出讓上層接管
- _hermes_rule_fallback(): 確定性四規則路由(gap/sales/risk 閾值),
  Telegram 告警加 🟡 降級前綴,行為與 NIM system prompt 一致
- dispatch(): 捕捉 HTTPError 429 → 轉 _hermes_rule_fallback(),
  回傳 nim_stats.degraded=True 供監控追蹤

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 11:23:59 +08:00
ogt
1b4f3a7bbe feat: EwoooC 初始化 — 完整專案推版至 Gitea
Some checks failed
CD Pipeline / deploy (push) Failing after 59s
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml)
- 部署模式: rsync Python 檔案至 188 → docker restart (volume mount)
- Dockerfile/requirements 變動時自動重建 Docker image
- 部署通知: Telegram (開始/成功/失敗)
- 健康檢查: https://mo.wooo.work/health (最多 5 次重試)
- 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19)

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