Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 1m32s
統帥指令: 所有自動修復操作(成功/失敗)必須持久化 變更: - migrations/phase10_auto_repair_executions.sql: 新增表 + 4 個索引 - db/models.py: 新增 AutoRepairExecution SQLAlchemy model - repositories/audit_log_repository.py: 新增 AutoRepairExecutionRepository (create/list_by_incident/get_stats) - auto_repair_service.py: execute_auto_repair 成功/失敗分支都寫入 DB - 新增 similarity_score 參數傳遞 - AutoRepairDecision 新增 similarity_score 欄位 - webhooks.py: 傳入 similarity_score 到 execute_auto_repair 已執行 migration: awoooi_prod@192.168.0.188:5432 ✅ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.6 KiB
SQL
39 lines
1.6 KiB
SQL
-- Phase 10: Auto Repair Executions 操作記錄表
|
||
-- 建立時間: 2026-04-08 (台北時區)
|
||
-- 建立者: Claude Code — 統帥指令「所有操作都必須被記錄,寫入資料庫」
|
||
--
|
||
-- 設計說明:
|
||
-- 自動修復每次執行(成功或失敗)都寫入此表
|
||
-- 不依賴 approval_id(自動修復不需要人工批准)
|
||
-- 支援查詢: 按 incident / playbook / 時間範圍 / 成功率
|
||
|
||
CREATE TABLE IF NOT EXISTS auto_repair_executions (
|
||
-- 主鍵
|
||
id VARCHAR(36) PRIMARY KEY DEFAULT gen_random_uuid()::text,
|
||
|
||
-- 關聯
|
||
incident_id VARCHAR(30) NOT NULL,
|
||
playbook_id VARCHAR(36) NOT NULL,
|
||
playbook_name VARCHAR(200) NOT NULL,
|
||
|
||
-- 執行結果
|
||
success BOOLEAN NOT NULL DEFAULT FALSE,
|
||
executed_steps JSONB NOT NULL DEFAULT '[]', -- list of step result strings
|
||
error_message TEXT,
|
||
|
||
-- 執行上下文
|
||
triggered_by VARCHAR(50) NOT NULL DEFAULT 'auto_repair', -- auto_repair / cold_start_trust
|
||
similarity_score NUMERIC(5,4), -- 匹配相似度
|
||
risk_level VARCHAR(20), -- LOW / MEDIUM / HIGH
|
||
execution_time_ms INTEGER,
|
||
|
||
-- 時間戳 (台北時區)
|
||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||
);
|
||
|
||
-- 索引
|
||
CREATE INDEX IF NOT EXISTS ix_are_incident_id ON auto_repair_executions (incident_id);
|
||
CREATE INDEX IF NOT EXISTS ix_are_playbook_id ON auto_repair_executions (playbook_id);
|
||
CREATE INDEX IF NOT EXISTS ix_are_created_at ON auto_repair_executions (created_at DESC);
|
||
CREATE INDEX IF NOT EXISTS ix_are_success ON auto_repair_executions (success);
|