From b389a50e07e95bf2b9ff687aa7f2490e4d25704f Mon Sep 17 00:00:00 2001 From: OoO Date: Sun, 24 May 2026 16:11:42 +0800 Subject: [PATCH] V10.429 complete runtime governance docs --- .env.example | 51 +++++++++++++++++++ config.py | 2 +- docs/AI_INTELLIGENCE_MODULE_SOT.md | 2 +- .../code_modularization_inventory_20260430.md | 9 ++-- docs/memory/history_logs.md | 1 + 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index e20e09d..d1b6796 100644 --- a/.env.example +++ b/.env.example @@ -97,6 +97,8 @@ GUNICORN_WORKER_CLASS=gthread GUNICORN_THREADS=4 # [預設 300] 長查詢 / 報表匯出 timeout 秒數 GUNICORN_TIMEOUT=300 +# [預設 false] worker 啟動時預熱 Dashboard 快取;正式環境通常維持 false +DASHBOARD_PREWARM_ON_WORKER_INIT=false # ========================================== # Database Settings @@ -108,12 +110,24 @@ POSTGRES_USER=momo POSTGRES_PASSWORD=your_secure_postgres_password_here POSTGRES_DB=momo_analytics +# Generic database URL / discrete keys used by tools and deployment scripts +DATABASE_URL=postgresql://momo:your_secure_postgres_password_here@momo-postgres:5432/momo_analytics +DATABASE_HOST=momo-postgres +DATABASE_PORT=5432 +DATABASE_USER=momo +DATABASE_PASSWORD=your_secure_postgres_password_here +DATABASE_DB=momo_analytics + # SQLite Configuration (Development/Backup) SQLITE_PATH=data/momo_database.db # Database Type Selection (postgresql or sqlite) USE_POSTGRESQL=true +# Redis cache / queue optional endpoint +REDIS_HOST=redis +REDIS_PORT=6379 + # ========================================== # Google Drive 自動匯入設定 # ========================================== @@ -146,6 +160,27 @@ OLLAMA_EMBED_MAX_TIMEOUT=15 OLLAMA_EMBED_KEEP_ALIVE=1m OLLAMA_EMBED_MAX_CHARS=4000 +# 111 Mac final fallback guardrail and allowlist proxy +OLLAMA_111_CIRCUIT_BREAKER_ENABLED=true +OLLAMA_111_CIRCUIT_CACHE_SEC=60 +OLLAMA_111_CIRCUIT_WINDOW_MINUTES=60 +OLLAMA_111_CIRCUIT_PCT=5 +OLLAMA_111_CIRCUIT_MIN_TOTAL=20 +OLLAMA_111_CIRCUIT_MIN_111=5 +OLLAMA_111_USAGE_ALERT_ENABLED=true +OLLAMA_111_USAGE_ALERT_WINDOW_MINUTES=60 +OLLAMA_111_USAGE_ALERT_PCT=5 +OLLAMA_111_USAGE_ALERT_MIN_TOTAL=20 +OLLAMA_111_USAGE_ALERT_MIN_111=3 +OLLAMA_111_USAGE_ALERT_DEDUP_SEC=3600 +OLLAMA111_PROXY_ALLOWED_CIDRS=127.0.0.1/32,192.168.0.111/32,192.168.0.188/32 +OLLAMA111_PROXY_LISTEN_HOST=192.168.0.111 +OLLAMA111_PROXY_LISTEN_PORT=11434 +OLLAMA111_PROXY_TARGET_HOST=127.0.0.1 +OLLAMA111_PROXY_TARGET_PORT=11434 +OLLAMA111_PROXY_LOG_LEVEL=INFO +OLLAMA111_PROXY_REJECT_LOG_DEDUP_SEC=60 + # ========================================== # Elephant Alpha AI Agent Super Orchestrator Settings # ========================================== @@ -481,6 +516,22 @@ GRIST_ADMIN_EMAIL=admin@wooo.work GRAFANA_PASSWORD=change-me PGADMIN_EMAIL=admin@wooo.work PGADMIN_PASSWORD=change-me +SUPERSET_SECRET_KEY=change-me + +# ────────────────────────────────────────────────────────────────────────── +# 部署 / CI / smoke test 輔助變數 +# ────────────────────────────────────────────────────────────────────────── + +PROD_BASE_URL=https://mo.wooo.work +SSH_JUMP_HOST=192.168.0.110 +SSH_JUMP_USER=wooo +SSH_TARGET_HOST=192.168.0.188 +SSH_TARGET_USER=ollama +GITHUB_OUTPUT= +SKIP_FEEDER=false +SKIP_HERMES=false +SKIP_NIM=false +SKIP_TELEGRAM=false # ────────────────────────────────────────────────────────────────────────── # n8n Workflow Automation(monitoring profile) diff --git a/config.py b/config.py index 781cd7a..131e03a 100644 --- a/config.py +++ b/config.py @@ -325,7 +325,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.428" +SYSTEM_VERSION = "V10.429" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/docs/AI_INTELLIGENCE_MODULE_SOT.md b/docs/AI_INTELLIGENCE_MODULE_SOT.md index caaa7ad..29011c9 100644 --- a/docs/AI_INTELLIGENCE_MODULE_SOT.md +++ b/docs/AI_INTELLIGENCE_MODULE_SOT.md @@ -2,7 +2,7 @@ > **最後更新**: 2026-05-24 (台北時間) > **狀態**: 🟢 四 AI Agent 自動化閉環已落地;LLM 路由紅線升級為 Ollama-first 三主機級聯,Gemini 備援預設關閉 -> **適用版本**: V10.428 +> **適用版本**: V10.429 --- diff --git a/docs/memory/code_modularization_inventory_20260430.md b/docs/memory/code_modularization_inventory_20260430.md index 59cee9b..777def0 100644 --- a/docs/memory/code_modularization_inventory_20260430.md +++ b/docs/memory/code_modularization_inventory_20260430.md @@ -49,6 +49,7 @@ - 2026-05-21 追記:同步 Recipe Box 多效提亮防曬霜同款漂移比對補強後的 `services/marketplace_product_matcher.py` 行數;此處只更新 inventory,不變更模組化決策。 - 2026-05-21 追記:同步 browse.sh 診斷計畫寫入 `competitor_match_attempts` 後的 `services/competitor_price_feeder.py` 行數;此處只更新 inventory,不變更模組化決策。 - 2026-05-24 追記:同步背景 PChome 近門檻身份回收與 focused identity 系列更新後的 `services/marketplace_product_matcher.py` 行數;此處只更新 inventory,不變更商品比對行為。 +- 2026-05-24 追記:同步 111 fallback circuit breaker、NemoTron 決策信封與 Telegram template governance 後的 `run_scheduler.py`、`services/ollama_service.py`、`services/nemoton_dispatcher_service.py`、`services/telegram_templates.py` 行數;此處只更新 inventory,不變更模組化決策。 ## 達到或超過 800 行檔案清單 @@ -61,23 +62,23 @@ | 2731 | `services/openclaw_strategist_service.py` | P0 OpenClaw service | prompt builders / report composer / strategy rules | | 3681 | `routes/admin_observability_routes.py` | P0 觀測台巨型 Blueprint | `services/observability_query_service.py` / `services/observability_action_service.py` / route glue | | 1796 | `routes/ai_routes.py` | P1 AI Blueprint | route glue / AI orchestration service / prompt builders | -| 1936 | `services/nemoton_dispatcher_service.py` | P1 NemoTron service | NIM client / tool-call parser / action dispatcher | +| 2154 | `services/nemoton_dispatcher_service.py` | P1 NemoTron service | NIM client / tool-call parser / action dispatcher | | 2026 | `routes/dashboard_routes.py` | P1 Dashboard Blueprint | competitor decision overview / dashboard query service;首頁資料整併需抽 service | | 1485 | `routes/vendor_routes.py` | P1 Vendor Blueprint | route glue / stockout mutation/email;V2 page query、stockout list/batches API query、vendor list/detail query 已抽到 `services/vendor_stockout_query_service.py` | | 1390 | `services/telegram_bot_service.py` | P1 Telegram service | command handlers / message formatters / bot client | | 1237 | `app.py` | P1 bootstrap | 保持只做 app setup;繼續往 app_factory / extension setup 抽;Phase 42 只做 metadata table name 對齊 | | 1800 | `services/elephant_alpha_autonomous_engine.py` | P1 ElephantAlpha engine | HITL / executor / planning policy | | 970 | `routes/cicd_routes.py` | P2 CI/CD Blueprint | route glue / CI query service / deployment action service | -| 1124 | `run_scheduler.py` | P2 scheduler entrypoint | observability jobs / token report jobs / task registration 分離 | +| 1250 | `run_scheduler.py` | P2 scheduler entrypoint | observability jobs / token report jobs / task registration 分離 | | 916 | `services/ppt_auto_generation_service.py` | P2 PPT 自動產線 service | schedule resolver / generation queue / missing report planner | | 966 | `services/trend_crawler.py` | P2 crawler service | source adapters / parser / persistence | | 942 | `services/learning_pipeline.py` | P2 RAG learning pipeline | distiller / promotion gate / persistence / telemetry | | 940 | `services/import_service.py` | P2 import service | validators / import writers / report builders | -| 933 | `services/telegram_templates.py` | P2 Telegram templates | alert template groups / channel-specific formatting / reusable render helpers | +| 1071 | `services/telegram_templates.py` | P2 Telegram templates | alert template groups / channel-specific formatting / reusable render helpers | | 867 | `services/token_report_service.py` | P2 token report service | query / aggregation / chart payload / notification formatting | | 3393 | `services/marketplace_product_matcher.py` | P2 marketplace matcher | identity parsing / unit-comparable scoring / search term quality / persistence normalization | | 865 | `routes/daily_sales_routes.py` | P2 Daily Sales Blueprint | route glue / export helpers / daily query and formatting service | -| 961 | `services/ollama_service.py` | P2 Ollama client | host health / request client / fallback policy / response parsing | +| 1117 | `services/ollama_service.py` | P2 Ollama client | host health / request client / fallback policy / response parsing | | 849 | `services/pchome_crawler.py` | P2 PChome crawler | search fetch / parsing / fallback source handling / rate limit policy | | 1100 | `services/code_review_pipeline_service.py` | P2 Code review pipeline service | scan orchestration / finding normalization / persistence adapter | | 953 | `routes/export_routes.py` | P2 Export flow | export command/router glue / file path / download orchestration | diff --git a/docs/memory/history_logs.md b/docs/memory/history_logs.md index fb209ed..3f918b9 100644 --- a/docs/memory/history_logs.md +++ b/docs/memory/history_logs.md @@ -13,6 +13,7 @@ ## 📅 詳細更新日誌 (考古存檔) ### 2026-05-24:PChome 近門檻身份回收第二輪 +- **V10.429 111 / NemoTron 治理回歸補齊**: 補齊 `.env.example` 中 111 circuit breaker、111 allowlist proxy、部署 smoke、資料庫與 Redis runtime keys,並同步大檔 inventory 行數,讓完整測試可覆蓋最新 `V10.425`–`V10.428` 變更;此版不放寬商品比對門檻、不修改 `competitor_prices` 寫入規則。 - **V10.428 NemoTron 價格決策信封落地**: `NemoTronDispatcher` 的 `price_alert` 與 `human_review` 事件現在會產生 12 Agent 共用 `decision_envelope`,把同款證據、價差、七日銷量變化、營收流失、建議行動、HITL guardrails、資料品質與 trace 同步寫入 EventRouter event 與 KM metadata;這讓 Telegram、AI 觀測台、PPT QA 與後續 Agent 協作能讀同一份可稽核證據,而不是各自解析告警文字。 - **V10.427 111 fallback circuit breaker**: `OllamaService` 在選到 111 final fallback 前先讀 `ai_calls` 近 60 分鐘比例;若 Ollama 呼叫 >=20、111 >=5 且占比 >=5%,會短暫跳過 111 並清除 resolved host cache,避免 111 在已偏高時繼續承接長任務。DB 觀測失敗採 fail-open,避免觀測層故障反向中斷 GCP-A/GCP-B 正常路由。 - **V10.426 111 proxy 拒絕日誌去重**: `ollama111_allow_proxy.py` 對同一來源 IP 的 reject log 預設 60 秒去重,保留 110 / 121 被擋的可觀測性,同時避免旁路 VM 持續探測時把 111 的 proxy log 與磁碟 I/O 刷高。