diff --git a/packages/shared-types/schemas/api-types.json b/packages/shared-types/schemas/api-types.json index 034157e4..776f108d 100644 --- a/packages/shared-types/schemas/api-types.json +++ b/packages/shared-types/schemas/api-types.json @@ -243,6 +243,32 @@ "description": "額外元資料", "title": "Metadata" }, + "incident_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "關聯的 Incident ID", + "title": "Incident Id" + }, + "matched_playbook_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "命中的 Playbook ID,供學習服務 EWMA 更新", + "title": "Matched Playbook Id" + }, "id": { "format": "uuid", "title": "Id", @@ -324,19 +350,6 @@ "format": "date-time", "title": "Last Seen At", "type": "string" - }, - "incident_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "關聯的 Incident ID", - "title": "Incident Id" } }, "required": [ @@ -408,6 +421,32 @@ "default": null, "description": "額外元資料", "title": "Metadata" + }, + "incident_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "關聯的 Incident ID", + "title": "Incident Id" + }, + "matched_playbook_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "命中的 Playbook ID,供學習服務 EWMA 更新", + "title": "Matched Playbook Id" } }, "required": [ @@ -1226,6 +1265,114 @@ "description": "是否已向量化到 Vector DB (Semantic Memory)", "title": "Vectorized", "type": "boolean" + }, + "notification_type": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "通知類型 TYPE-1/2/3/4/4D", + "title": "Notification Type" + }, + "alert_category": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "告警類別 k8s_workload/database/host_resource/...", + "title": "Alert Category" + }, + "context_bundle": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "description": "MCP 情報收集快照(執行前)", + "title": "Context Bundle" + }, + "metrics_before": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "description": "指標快照(執行前,Prometheus MCP)", + "title": "Metrics Before" + }, + "metrics_after": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "description": "指標快照(執行後,Prometheus MCP)", + "title": "Metrics After" + }, + "verification_result": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "description": "執行驗證結果(K8s MCP watch_rollout)", + "title": "Verification Result" + }, + "manual_fix_steps": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "手動修復步驟(TYPE-4 使用者輸入)", + "title": "Manual Fix Steps" + }, + "manual_fix_by": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "手動修復執行者", + "title": "Manual Fix By" } }, "required": [ @@ -1883,6 +2030,14 @@ "description": "最後使用時間", "title": "Last Used At" }, + "trust_score": { + "default": 0.3, + "description": "EWMA 動態信任度(Phase 3 新增)", + "maximum": 1.0, + "minimum": 0.0, + "title": "Trust Score", + "type": "number" + }, "approved_by": { "anyOf": [ { diff --git a/packages/shared-types/src/api-types.ts b/packages/shared-types/src/api-types.ts index 5c8150d9..1d40f74d 100644 --- a/packages/shared-types/src/api-types.ts +++ b/packages/shared-types/src/api-types.ts @@ -103,6 +103,14 @@ export type ExpiresAt = string | null; export type Metadata = { [k: string]: unknown; } | null; +/** + * 關聯的 Incident ID + */ +export type IncidentId = string | null; +/** + * 命中的 Playbook ID,供學習服務 EWMA 更新 + */ +export type MatchedPlaybookId = string | null; export type Id1 = string; /** * 授權請求狀態機 @@ -143,10 +151,6 @@ export type HitCount = number; * 最後觸發時間 */ export type LastSeenAt = string; -/** - * 關聯的 Incident ID - */ -export type IncidentId = string | null; /** * 執行動作描述 */ @@ -174,6 +178,14 @@ export type ExpiresAt1 = string | null; export type Metadata1 = { [k: string]: unknown; } | null; +/** + * 關聯的 Incident ID + */ +export type IncidentId1 = string | null; +/** + * 命中的 Playbook ID,供學習服務 EWMA 更新 + */ +export type MatchedPlaybookId1 = string | null; export type Id2 = string; export type Action2 = string; export type Description2 = string; @@ -404,7 +416,7 @@ export type Fingerprint2 = string | null; /** * 事件唯一識別碼 (如 INC-20260322-A1B2C3) */ -export type IncidentId1 = string; +export type IncidentId2 = string; /** * 事件狀態 */ @@ -453,9 +465,49 @@ export type PersistedToPg = boolean; * 是否已向量化到 Vector DB (Semantic Memory) */ export type Vectorized = boolean; +/** + * 通知類型 TYPE-1/2/3/4/4D + */ +export type NotificationType = string | null; +/** + * 告警類別 k8s_workload/database/host_resource/... + */ +export type AlertCategory = string | null; +/** + * MCP 情報收集快照(執行前) + */ +export type ContextBundle = { + [k: string]: unknown; +} | null; +/** + * 指標快照(執行前,Prometheus MCP) + */ +export type MetricsBefore = { + [k: string]: unknown; +} | null; +/** + * 指標快照(執行後,Prometheus MCP) + */ +export type MetricsAfter = { + [k: string]: unknown; +} | null; +/** + * 執行驗證結果(K8s MCP watch_rollout) + */ +export type VerificationResult = { + [k: string]: unknown; +} | null; +/** + * 手動修復步驟(TYPE-4 使用者輸入) + */ +export type ManualFixSteps = string | null; +/** + * 手動修復執行者 + */ +export type ManualFixBy = string | null; export type Signals1 = Signal[]; export type AffectedServices1 = string[]; -export type IncidentId2 = string; +export type IncidentId3 = string; export type Signals2 = Signal[]; export type AffectedServices2 = string[]; export type ProposalIds1 = string[]; @@ -632,6 +684,10 @@ export type FailureCount = number; * 最後使用時間 */ export type LastUsedAt = string | null; +/** + * EWMA 動態信任度(Phase 3 新增) + */ +export type TrustScore = number; /** * 核准者 */ @@ -848,6 +904,8 @@ export interface ApprovalRequest { requested_by: RequestedBy; expires_at?: ExpiresAt; metadata?: Metadata; + incident_id?: IncidentId; + matched_playbook_id?: MatchedPlaybookId; id?: Id1; status?: ApprovalStatus1; required_signatures: RequiredSignatures; @@ -859,7 +917,6 @@ export interface ApprovalRequest { fingerprint?: Fingerprint; hit_count?: HitCount; last_seen_at?: LastSeenAt; - incident_id?: IncidentId; [k: string]: unknown; } /** @@ -877,6 +934,8 @@ export interface ApprovalRequestCreate { requested_by: RequestedBy1; expires_at?: ExpiresAt1; metadata?: Metadata1; + incident_id?: IncidentId1; + matched_playbook_id?: MatchedPlaybookId1; [k: string]: unknown; } /** @@ -1111,7 +1170,7 @@ export interface Annotations { * via the `definition` "Incident". */ export interface Incident { - incident_id?: IncidentId1; + incident_id?: IncidentId2; status?: IncidentStatus1; severity: Severity2; signals?: Signals; @@ -1136,6 +1195,14 @@ export interface Incident { ttl_days?: TtlDays; persisted_to_pg?: PersistedToPg; vectorized?: Vectorized; + notification_type?: NotificationType; + alert_category?: AlertCategory; + context_bundle?: ContextBundle; + metrics_before?: MetricsBefore; + metrics_after?: MetricsAfter; + verification_result?: VerificationResult; + manual_fix_steps?: ManualFixSteps; + manual_fix_by?: ManualFixBy; [k: string]: unknown; } /** @@ -1157,7 +1224,7 @@ export interface IncidentCreate { * via the `definition` "IncidentResponse". */ export interface IncidentResponse { - incident_id: IncidentId2; + incident_id: IncidentId3; status: IncidentStatus; severity: Severity; signals: Signals2; @@ -1357,6 +1424,7 @@ export interface Playbook { success_count?: SuccessCount; failure_count?: FailureCount; last_used_at?: LastUsedAt; + trust_score?: TrustScore; approved_by?: ApprovedBy; approved_at?: ApprovedAt; tags?: Tags;