Files
awoooi/apps/api/requirements.txt
OG T bf45b80bd2
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
feat(Phase 3.5 + Phase 4): AI 學習成果持久化到 PostgreSQL — 修正「AI 失憶」架構缺陷
ADR-085: AI 學習成果不可存在 Cache

架構鐵律確立:
- PostgreSQL = System of Record(AI 的永久記憶)
- Redis = Warm Cache(加速讀取,TTL 到期從 PG 復原)

核心變更:
1. models.py: 新增 PlaybookRecord / DynamicBaselineRecord / LogClusterRecord ORM
2. base.py: ALTER TABLE playbooks 補加 trust_score / requires_approval_level 等欄位
3. playbook_repository.py: 完整雙寫實作(PG upsert + Redis cache)
4. dynamic_baseline_service.py: Holt-Winters 訓練結果寫入 PG,Redis 只作 24h warm cache
5. log_anomaly_detector.py: Drain3 cluster template 寫入 PG(UPSERT on cluster_id)
6. main.py: 啟動時執行 backfill_redis_to_pg()(Redis → PG 冪等補救)

修正的問題:
- Playbook 7天 Redis TTL 到期 → AI 失去所有修復知識
- trust_score EWMA 隨 Redis TTL 歸零 → AI 重新回到初始信任度 0.3
- Holt-Winters 基線 24h TTL → AI 每天重新學習「正常」的定義
- Drain3 cluster 沒有持久化 → AI 把已知 log pattern 反覆當新 pattern

Phase 4 新服務(requirements.txt 已加入 statsmodels + drain3 + numpy)

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

61 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AWOOOI API Dependencies
# =======================
# CTO-101: BFF Gateway 骨架
# 版本: 2026-03-20
# Core Framework
fastapi>=0.109.0
uvicorn[standard]>=0.27.0
starlette>=0.35.0
# Configuration & Validation
pydantic>=2.5.0
pydantic-settings>=2.1.0
# Async HTTP Client
httpx>=0.26.0
# Database
asyncpg>=0.29.0
redis>=5.0.0
# Logging
structlog>=24.1.0
# SSE Support
sse-starlette>=1.8.0
# ==========================================================================
# OpenTelemetry (SigNoz Integration)
# P0 基礎設施: 可觀測性鐵律
# ==========================================================================
opentelemetry-api>=1.20.0
opentelemetry-sdk>=1.20.0
opentelemetry-exporter-otlp>=1.20.0
opentelemetry-instrumentation-fastapi>=0.41b0
opentelemetry-instrumentation-httpx>=0.41b0
opentelemetry-instrumentation-logging>=0.41b0
# ==========================================================================
# Langfuse (LLMOps Observability)
# Phase 15.1: LLM 呼叫追蹤、成本監控、Prompt 版本管理
# ==========================================================================
# 2026-04-02 Claude Code: 鎖定 v2.60.x — v3.x/v4.x 移除 client.trace() API與 langfuse_client.py 不相容
langfuse>=2.0.0,<3.0.0
# ==========================================================================
# Phase 4: 動態異常偵測 (ADR-084)
# ==========================================================================
# Holt-Winters 指數平滑(動態基線)
statsmodels>=0.14.0
# Log clusteringDrain3 演算法)
drain3>=0.9.11
# numpy 已為 statsmodels 依賴,顯式列出確保可用(線性趨勢預測)
numpy>=1.24.0
# Development
pytest>=7.4.0
pytest-asyncio>=0.23.0
ruff>=0.1.0
sentry-sdk[fastapi]>=2.0.0