Commit Graph

34 Commits

Author SHA1 Message Date
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
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
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
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
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
c2e38be43d docs(modularization): 建立模組化治理守門
All checks were successful
CD Pipeline / deploy (push) Successful in 1m36s
2026-04-30 14:07:10 +08:00
OoO
9dd5986077 修復 AI 自動化 Prometheus scrape
All checks were successful
CD Pipeline / deploy (push) Successful in 1m26s
2026-04-30 00:24:40 +08:00
OoO
5a61c020e3 新增 AI 自動化 Grafana 儀表板
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-04-30 00:06:24 +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
d58e4d0d11 同步四 Agent AI 自動化治理紀錄
All checks were successful
CD Pipeline / deploy (push) Successful in 1m10s
2026-04-29 23:36:23 +08:00
OoO
880511032a docs(governance): 建立 Codex 專案入口與記憶索引 2026-04-29 22:11:23 +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
8be332728e docs: ADR-016 daily_sales cache fingerprint + 4/28-29 history log + CLAUDE.md ADR 索引補 015/016
- 新增 docs/adr/ADR-016:daily_sales cache TTL → TTL+DB fingerprint,棄用
  N-POST broadcast hack(命中率 9.4%),引述 debugger/web-researcher/migration-engineer
  三方共識;殘留 HIGH-2(app.py 43 處 _SALES_PROCESSED_CACHE)列管
- docs/memory/history_logs.md 新增 4/28-29 條目:app.py -10.8%、4 個改進版死碼揭發、
  cache 機制重構、hook 9 PoC 強化、12 Agent 並行作戰實踐
- CLAUDE.md 補上 ADR-015/016 索引項

Memory(個人 auto-memory,未入 repo)同步:
- feedback_flask_blueprint_shadow.md(first-registered wins)
- feedback_cache_invalidation_pattern.md(DB fingerprint vs N-POST)
- feedback_agent_dispatch_order.md(critic 必須先於 fullstack)
- feedback_cloud_vs_local_automation.md(LAN 專案禁雲端 routine)
- project_phase3e_refactor_progress.md(11 commits 戰果)
2026-04-29 19:56:48 +08:00
OoO
832030b6de fix(cd): sync 模式改用 compose up -d 取代 restart,根除 502 復發
All checks were successful
CD Pipeline / deploy (push) Successful in 1m13s
根因:cd.yaml sync 模式用 `docker compose restart`,對「不存在的容器」
直接報錯 → 任何外力(人工 docker rm、orphan 清理、別專案連動)清掉容器後,
下次 sync 部署 100% 失敗 → 健康檢查 5 連 502。

修法:
- sync 模式改 `docker compose up -d --no-deps`:image 未變時對既存容器
  no-op(觸發熱掛載),對不存在則自動 create
- 緊急回滾 step 同步從 `docker restart momo-pro-system ...` 改 `compose up -d`,
  否則容器不存在時連回滾都救不回

驗證:2026-04-28 15:33 跑 P0 救急已成功讓 4/4 容器 healthy + HTTP 200。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 15:34:30 +08:00
OoO
7bb97ed252 fix: remove hardcoded Telegram Bot token to resolve AiderHeal security warning
All checks were successful
CD Pipeline / deploy (push) Successful in 1m21s
2026-04-28 12:34:29 +08:00
ogt
a96306fba2 Fix Telegram bot natural language communication issue
- Install python-telegram-bot dependency
- Start Telegram bot service successfully
- Confirm correct group ID (MOMO PRO - small shrimp group)
- Bot now running with all commands and button interface functional
- Natural language processing restored with keyword matching

Fixes issue where Telegram group could not communicate using natural language.
2026-04-22 14:27:50 +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
4ee4ec097e docs(adr): ADR-013 補充部署後記(踩坑清單 + SSH 設定 + 實測結果)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 16:47:58 +08:00
ogt
77d3a1da48 feat(ai-ops): ADR-013 AIOps 自動修復閉環完整實作
Some checks failed
CD Pipeline / deploy (push) Failing after 3m24s
架構(Exception → Incident → PlayBook → Heal → KM → Telegram):

新增元件:
- database/autoheal_models.py: Incident/Playbook/HealLog 三張表 + 7 條種子 PlayBook
- migrations/013_autoheal.sql: 建表 DDL + 種子資料(冪等 INSERT)
- services/auto_heal_service.py: 核心引擎 7 步閉環
  - _classify_error: 8 類錯誤自動分類 (DNS_FAIL/DB_UNREACHABLE/OOM/...)
  - _match_playbook: error_type + keyword + 冷卻 + max_retries 保護
  - _execute_playbook: DOCKER_RESTART/SSH_CMD/ALERT_ONLY/WAIT_RETRY
  - _sink_to_km: 修復知識寫入 ai_insights (auto_heal_playbook)
  - SSH 白名單:僅允許 docker restart / compose restart / docker start

修改元件:
- database/manager.py: _init_autoheal_tables() 啟動時建表+種子 PlayBook
- scheduler.py: 3 個核心任務植入 handle_exception
  (run_auto_import_task / run_icaim_analysis_task / run_weekly_strategy_task)
- requirements.txt: paramiko(SSH 跳板;不可用時降級 subprocess+CLI ssh)

安全設計: CMD 白名單 + cooldown + max_retries escalation + DB 冪等 migration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 16:03:49 +08:00
ogt
0b4f80ee8a feat(ai-ops): Agent Action Ladder 骨幹(ADR-012 Phase 1)+ 週報套模板
All checks were successful
CD Pipeline / deploy (push) Successful in 1m14s
ADR-012 核心設計:
- 4 級信任邊界:L0 直出 / L1 Hermes 觀察 / L2 NemoTron 診斷執行 / L3 OpenClaw HITL
- 通知鏈絕不中斷:每級失敗立即降級,保底 L0 模板 + 🟡 標記
- Audit Trail:每次 dispatch 自動寫 ai_insights (insight_type=agent_action)
- 安全白名單:L2 可呼叫 6 個安全 action(retry/query_km/silence + 3 個既有 NemoTron tool)

新增檔案:
- services/event_router.py — 事件分流入口,按 severity × event_type 分 Tier
- services/agent_actions.py — 安全 action 白名單(Phase 1 stub + 完整介面)
- docs/adr/ADR-012-agent-action-ladder.md — 完整設計 + 分階段計畫

Phase 1 狀態:
- L0 直出完整可用 
- L1 Hermes / L2 NemoTron 為 stub(Phase 2/3 填實作)
- Fallback 降級鏈已完整 
- 靜音檢查(is_silenced)+ Audit Trail 已就緒 

處理既有 TODO:
- services/openclaw_strategist_service.py::_notify_telegram_group()
  改用 telegram_templates.report() 統一週報格式

全景盤點(新 memory):
- reference_telegram_endpoints_map.md — 21 個 Telegram 發送點
- feedback_agent_action_ladder.md — 操作規範
  (+ 既有 ADR-011 跨專案隔離規範一併生效)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 12:46:51 +08:00
ogt
8d0b79cd00 feat(ops): restore Telegram chain + P2/P3 price decisions + ADR-011
All checks were successful
CD Pipeline / deploy (push) Successful in 1m19s
P2 (Inline Keyboard 降價決策):
- routes/bot_api_routes.py: POST /bot/api/price-decision/notify
- services/telegram_bot_service.py: pa:/pr: callback handlers

P3 (OpenClaw 自動觸發):
- services/openclaw_strategist_service.py: Gemini 週報末尾輸出
  PRICE_DECISIONS_JSON,解析後自動推送 inline keyboard 給 admin

Ops 修復(跨專案隔離與容器斷訊根因):
- ADR-011 全面規範多專案共存邊界、禁用 --remove-orphans
- .gitea/workflows/cd.yaml: sync 模式一次重啟三容器
  (原本僅 momo-pro-system,scheduler/telegram-bot 靜默落伍)
- run_telegram_bot.py: 從 scripts/tools/ 複製到根目錄
  (消滅 docker-compose mount 建空目錄的陷阱)
- CLAUDE.md: 補核心容器表、診斷黃金三句、緊急指令

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 12:25:04 +08:00
ogt
62d8504d8f docs: 新增 ADR-010 Gitea CI/CD Pipeline,更新 CLAUDE.md
- ADR-010:記錄 ewoooc Gitea repo 建立、cd.yaml 設計、runner user-level 踩坑、rsync 缺失修復
- CLAUDE.md:新增 CI/CD 表格(repo URL、pipeline 模式、runner、Telegram 通知)
- docs/adr/README.md:加入 ADR-010 索引

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 11:21:53 +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