feat(adr-081): Phase 1 感官縱深 — 8D 情報蒐集 + 執行後驗證

成品:
- IncidentEvidence DB model(8D 感官 + pre/post 執行狀態)
- EvidenceSnapshot dataclass(build_summary → LLM 上下文)
- SanitizationService(Prompt Injection 0-tolerance,12 pattern)
- MCPToolRegistry(動態工具登記,suggest_tools 不寫死告警類型)
- PreDecisionInvestigator(8D 並行感官,P99 < 8s,Redis 30s 快取)
- PostExecutionVerifier(warmup 10s → 後狀態評估 success/degraded/failed)
- decision_manager + approval_execution 接線(feature flag 守衛)

Gate 1 修復:D4/D5/D7/D8 補 sanitize_dict_values;移除裸 "error" failure
signal 防 error_rate key 誤判;evidence_snapshot rowcount 零行警告。

測試:130 passed(+111 新增)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-15 13:08:38 +08:00
parent db9e304a14
commit f1cbf6db7d
14 changed files with 2936 additions and 3 deletions

View File

@@ -38,6 +38,44 @@
---
## 📍 2026-04-15 — AI 自主化飛輪 Phase 1 感官縱深建立
### 成品ADR-081
| 成品 | 路徑 | 說明 |
|------|------|------|
| DB Model | `apps/api/src/db/models.py` | IncidentEvidence 表8D 感官 + 執行前後狀態 + 驗證結果) |
| EvidenceSnapshot | `apps/api/src/services/evidence_snapshot.py` | 不可變快照build_summary() 組裝 LLM 上下文 |
| SanitizationService | `apps/api/src/services/sanitization_service.py` | Prompt Injection 0-tolerance12 pattern+ 敏感詞遮罩 |
| MCPToolRegistry | `apps/api/src/services/mcp_tool_registry.py` | 動態工具登記冊suggest_tools() 不寫死告警類型 |
| PreDecisionInvestigator | `apps/api/src/services/pre_decision_investigator.py` | 8D 並行感官蒐集P99 < 8sRedis 30s 快取 |
| PostExecutionVerifier | `apps/api/src/services/post_execution_verifier.py` | 執行後 K8s 收斂等待 + 三態評估success/degraded/failed |
| decision_manager 接線 | `apps/api/src/services/decision_manager.py` | AIOPS_P1_PRE_DECISION_INVESTIGATOR flag 守衛 |
| approval_execution 接線 | `apps/api/src/services/approval_execution.py` | AIOPS_P1_POST_EXECUTION_VERIFIER fire-and-forget |
### 測試覆蓋
| 測試檔 | 數量 |
|--------|------|
| test_sanitization_service.py | 28 |
| test_mcp_tool_registry.py | 33 |
| test_pre_decision_investigator.py | 28 |
| test_post_execution_verifier.py | 22 |
| **總計** | **111 新增Phase 1130 全數通過** |
### Gate 1 修復4 項)
1. `evidence_snapshot.py`: rowcount < 1 → warning log靜默零行更新
2. `post_execution_verifier.py`: 移除裸 `"error"` failure signal防 error_rate key 誤判)
3. `pre_decision_investigator.py`: D4/D5/D7/D8 補 sanitize_dict_valuesPrompt Injection 0-tolerance
4. `feature_flags.py`: 補充 Pod 重啟才能 hot-reload flags 說明
### 下一步
- Phase 2: 5 Agent 骨架 + Orchestrator + AgentSession DB
---
## 📍 2026-04-14 午夜 — Phase 5 分類按鈕完整化全數上線
**Sprint 5.0 → 5.4 全數完成**26 個 commits 推版: