diff --git a/apps/api/src/core/config.py b/apps/api/src/core/config.py index 7913ea31..dcd0afbc 100644 --- a/apps/api/src/core/config.py +++ b/apps/api/src/core/config.py @@ -62,6 +62,28 @@ class Settings(BaseSettings): description="Phase 24: True=新 AIRouter 路由, False=舊 openclaw.py fallback chain", ) + # ========================================================================== + # aider-watch v2 integration (2026-04-20 ADR-091) + # 整合 Mac aider CLI 監控進 awoooi 飛輪(events → incident → ai_router feedback) + # 回滾:kubectl set env deployment/awoooi-api USE_AIDER_FEEDBACK=false + # ========================================================================== + AIDER_WEBHOOK_SECRET: str = Field( + default="", + description="HMAC secret for /api/v1/aider/events webhook verification", + ) + AIDER_EVENTS_STREAM_KEY: str = Field( + default="signals:aider:events", + description="Redis stream key for aider event ingestion", + ) + AIDER_PATTERN_EXTRACT_INTERVAL_HOURS: float = Field( + default=24.0, + description="Aider event pattern extraction interval (future use)", + ) + USE_AIDER_FEEDBACK: bool = Field( + default=False, + description="Phase 24 A8: True=ai_router.route() 讀 aider 成功率調權重, False=不讀(預設)", + ) + # Phase 22: OpenClaw + Nemotron 協作 (ADR-044) # 2026-03-31 Claude Code: 統帥批准實作 # diff --git a/apps/api/src/main.py b/apps/api/src/main.py index c4b3f0c5..37f86e1c 100644 --- a/apps/api/src/main.py +++ b/apps/api/src/main.py @@ -34,6 +34,7 @@ from sentry_sdk.integrations.starlette import StarletteIntegration from src.api.v1 import agents as agents_v1 # Phase 9.5: Agent Teams API from src.api.v1 import ai as ai_v1 +from src.api.v1 import aider_events as aider_events_v1 # aider-watch v2 ADR-091 from src.api.v1 import ai_slo as ai_slo_v1 # Phase 6 ADR-087: AI SLO 自我治理 from src.api.v1 import aiops_kpi as aiops_kpi_v1 # ADR-090 § Phase 7 KPI Dashboard from src.api.v1 import approvals as approvals_v1 @@ -411,6 +412,15 @@ async def lifespan(_app: FastAPI) -> AsyncGenerator[None, None]: except Exception as e: logger.warning("compliance_scanner_loop_schedule_failed", error=str(e)) + # aider-watch v2 processor (2026-04-20 ADR-091) + # 消費 signals:aider:events stream → 建 incident + 寫 aider_events 表 + try: + from src.workers.aider_event_processor import run_aider_event_processor_loop + logger.info("aider_event_processor: starting Redis stream consumer") + asyncio.create_task(run_aider_event_processor_loop()) + except Exception as e: + logger.warning("aider_event_processor_schedule_failed", error=str(e)) + # ADR-090 § Coverage Evaluator (2026-04-19 ogt + Claude Opus 4.7 Asia/Taipei) # 每 1h 把 asset_coverage_snapshot 從 'unknown' 升級成 green/yellow/red # 依據: Prometheus targets / alert_rule_catalog labels / knowledge_entries 覆蓋 @@ -692,6 +702,11 @@ app.include_router(timeline_v1.router, prefix="/api/v1", tags=["Timeline"]) app.include_router(audit_logs_v1.router, prefix="/api/v1", tags=["Audit Logs"]) # 2026-04-09 Claude Sonnet 4.6: alert_operation_log 查詢 API (Sprint 5.2) app.include_router(alert_operation_logs_v1.router, prefix="/api/v1", tags=["Alert Operation Logs"]) +app.include_router( + aider_events_v1.router, + prefix="/api/v1", + tags=["Aider Watch"], +) # aider-watch v2 ADR-091 app.include_router( telegram_v1.router, prefix="/api/v1", tags=["Telegram Gateway"] ) # Phase 5.4