refactor(api): Phase 17 P1 Tier 3 紅區服務 Protocol 定義

新增 5 個紅區核心服務的 Protocol 介面:
- IDecisionManager: 決策狀態機
- ITrustScoreManager: 信任評分引擎
- IIncidentEngine: 事件處理引擎
- IMultiSigRedisService: 分散式鎖服務
- ITelegramSecurityInterceptor: 安全攔截器

符合 leWOOOgo 積木化規範:
- 支援依賴注入 (DI)
- 便於測試時 Mock
- 型別約束確保實作一致性

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-26 12:49:30 +08:00
parent 702e9a9634
commit d1f0bbfbcd
5 changed files with 237 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ v1.1 重構內容 (2026-03-22 架構師審查後修正):
import json
from datetime import UTC, datetime
from typing import Any
from typing import Any, Protocol, runtime_checkable
import structlog
@@ -234,6 +234,46 @@ return "AGGREGATED:" .. updated_json
"""
# =============================================================================
# Protocol Interface (Phase 17 P1 - 紅區治理)
# =============================================================================
@runtime_checkable
class IIncidentEngine(Protocol):
"""
IncidentEngine 介面定義
用途:
- 依賴注入 (DI) 時的型別約束
- 測試時 Mock 的型別檢查
- 符合 leWOOOgo 積木化規範
Tier 3 紅區服務: 修改需首席架構師簽核
@see feedback_lewooogo_modular_enforcement.md
@see docs/RED_ZONES.md
"""
async def process_signal(
self,
signal_data: dict[str, Any],
) -> Incident | None:
"""處理 Signal: 原子建立或聚合 Incident"""
...
async def get_incident(self, incident_id: str) -> Incident | None:
"""取得指定 Incident"""
...
async def update_incident_status(
self,
incident_id: str,
status: str,
) -> Incident | None:
"""更新 Incident 狀態"""
...
# =============================================================================
# Incident Engine v1.1
# =============================================================================