From d6a6519594c811b49447651822f9c74456464650 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 31 May 2026 13:22:07 +0800 Subject: [PATCH] chore(types): sync approval response types --- docs/LOGBOOK.md | 2 + ...-04-15-MASTER-ai-autonomous-flywheel-v2.md | 2 +- packages/shared-types/schemas/api-types.json | 74 +++++++++++++++++++ packages/shared-types/src/api-types.ts | 26 ++++++- 4 files changed, 99 insertions(+), 5 deletions(-) diff --git a/docs/LOGBOOK.md b/docs/LOGBOOK.md index 4b6b711c..49d4c98f 100644 --- a/docs/LOGBOOK.md +++ b/docs/LOGBOOK.md @@ -25,6 +25,8 @@ python3 -m py_compile apps/api/src/models/approval.py apps/api/src/services/appr -> pass /Users/ogt/.pyenv/shims/ruff check apps/api/tests/test_approval_pending_visibility.py -> pass +pnpm --filter @awoooi/shared-types generate + -> pass; packages/shared-types schema / TS types updated for new approval fields DATABASE_URL='postgresql+asyncpg://test:test@localhost/test' /Users/ogt/.pyenv/shims/pytest apps/api/tests/test_approval_pending_visibility.py -q -> 4 passed DATABASE_URL='postgresql+asyncpg://test:test@localhost/test' /Users/ogt/.pyenv/shims/pytest apps/api/tests/test_heartbeat_ollama_endpoints.py apps/api/tests/test_heartbeat_pod_state_machine.py -q diff --git a/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md b/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md index 21a49b7c..09e9af0a 100644 --- a/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md +++ b/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md @@ -2668,7 +2668,7 @@ Phase 6 完成後 **T153 Legacy HITL pending visibility + warning split(2026-05-31 台北)**: - 觸發:production `/api/v1/approvals/pending` 有 legacy HITL backlog `count=21`,但 `/api/v1/platform/approvals` 回 `total=0`,operator 會以為前台沒有人工待辦;同時 heartbeat 用 raw PENDING 數量觸發「PENDING 積壓,需人工處理」,把 OBSERVE / NO_ACTION 觀察卡與真正可執行審批混在一起。 - 修正:`ApprovalRequest` / `ApprovalRequestResponse` 外露 `incident_id`、`matched_playbook_id`、`telegram_message_id`、`telegram_chat_id`;DB / repository converter 保留 legacy approval record 的 incident / playbook / Telegram delivery 欄位。`HeartbeatReportService` 將 24h pending 拆成 actionable、observe-only、without-TG;warning 只看 actionable backlog,並在訊息指向 `/awooop/approvals`,Telegram heartbeat 顯示「待審拆分」。 -- Verification:API py_compile pass;targeted ruff for new test pass;`test_approval_pending_visibility.py` 4 passed;`test_heartbeat_ollama_endpoints.py` + `test_heartbeat_pod_state_machine.py` 15 passed;`git diff --check` pass。 +- Verification:API py_compile pass;targeted ruff for new test pass;`pnpm --filter @awoooi/shared-types generate` pass;`test_approval_pending_visibility.py` 4 passed;`test_heartbeat_ollama_endpoints.py` + `test_heartbeat_pod_state_machine.py` 15 passed;`git diff --check` pass。 - 判讀:T153 不批次 approve/reject 生產 PENDING,也不把觀察卡刪掉;它把「前台看得到 legacy HITL 事實」與「告警只針對真正人工 actionable backlog」補齊。舊 fallback kubectl / SSH action 仍需 operator 在 `/awooop/approvals` 逐筆決策;OBSERVE / NO_ACTION 類不再偽裝成 emergency manual backlog。下一段可追 LLM failure fallback 為何大量產生 `OBSERVE / medium` 卡片,但需避免破壞 agent 後續把 PENDING 更新成可執行 action 的路徑。 **T152 Ansible runtime readiness surfaced(2026-05-24 台北)**: diff --git a/packages/shared-types/schemas/api-types.json b/packages/shared-types/schemas/api-types.json index c0de214a..1578c75d 100644 --- a/packages/shared-types/schemas/api-types.json +++ b/packages/shared-types/schemas/api-types.json @@ -350,6 +350,32 @@ "format": "date-time", "title": "Last Seen At", "type": "string" + }, + "telegram_message_id": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Telegram approval card message ID", + "title": "Telegram Message Id" + }, + "telegram_chat_id": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Telegram chat ID for the approval card", + "title": "Telegram Chat Id" } }, "required": [ @@ -567,6 +593,54 @@ "default": null, "title": "Last Seen At" }, + "incident_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Incident Id" + }, + "matched_playbook_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Matched Playbook Id" + }, + "telegram_message_id": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Telegram Message Id" + }, + "telegram_chat_id": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Telegram Chat Id" + }, "metadata": { "anyOf": [ { diff --git a/packages/shared-types/src/api-types.ts b/packages/shared-types/src/api-types.ts index 53d7eb64..7953d459 100644 --- a/packages/shared-types/src/api-types.ts +++ b/packages/shared-types/src/api-types.ts @@ -151,6 +151,14 @@ export type HitCount = number; * 最後觸發時間 */ export type LastSeenAt = string; +/** + * Telegram approval card message ID + */ +export type TelegramMessageId1 = number | null; +/** + * Telegram chat ID for the approval card + */ +export type TelegramChatId = number | null; /** * 執行動作描述 */ @@ -200,6 +208,10 @@ export type ResolvedAt1 = string | null; export type Fingerprint1 = string | null; export type HitCount1 = number; export type LastSeenAt1 = string | null; +export type IncidentId2 = string | null; +export type MatchedPlaybookId2 = string | null; +export type TelegramMessageId2 = number | null; +export type TelegramChatId1 = number | null; export type Metadata2 = { [k: string]: unknown; } | null; @@ -416,7 +428,7 @@ export type Fingerprint2 = string | null; /** * 事件唯一識別碼 (如 INC-20260322-A1B2C3) */ -export type IncidentId2 = string; +export type IncidentId3 = string; /** * 事件狀態 */ @@ -507,7 +519,7 @@ export type ManualFixSteps = string | null; export type ManualFixBy = string | null; export type Signals1 = Signal[]; export type AffectedServices1 = string[]; -export type IncidentId3 = string; +export type IncidentId4 = string; export type Signals2 = Signal[]; export type AffectedServices2 = string[]; export type ProposalIds1 = string[]; @@ -937,6 +949,8 @@ export interface ApprovalRequest { fingerprint?: Fingerprint; hit_count?: HitCount; last_seen_at?: LastSeenAt; + telegram_message_id?: TelegramMessageId1; + telegram_chat_id?: TelegramChatId; [k: string]: unknown; } /** @@ -982,6 +996,10 @@ export interface ApprovalRequestResponse { fingerprint?: Fingerprint1; hit_count?: HitCount1; last_seen_at?: LastSeenAt1; + incident_id?: IncidentId2; + matched_playbook_id?: MatchedPlaybookId2; + telegram_message_id?: TelegramMessageId2; + telegram_chat_id?: TelegramChatId1; metadata?: Metadata2; [k: string]: unknown; } @@ -1190,7 +1208,7 @@ export interface Annotations { * via the `definition` "Incident". */ export interface Incident { - incident_id?: IncidentId2; + incident_id?: IncidentId3; status?: IncidentStatus1; severity: Severity2; signals?: Signals; @@ -1244,7 +1262,7 @@ export interface IncidentCreate { * via the `definition` "IncidentResponse". */ export interface IncidentResponse { - incident_id: IncidentId3; + incident_id: IncidentId4; status: IncidentStatus; severity: Severity; signals: Signals2;