feat(awooop): add AI alert card delivery readback
This commit is contained in:
@@ -1,3 +1,28 @@
|
||||
## 2026-06-25|AwoooP AI 事件卡 delivery readback API
|
||||
|
||||
**背景**:上一段已讓 Telegram outbound mirror 保存 `ai_automation_alert_card_mirror_v1` metadata,但尚未有正式 readback API 可查「Wazuh Dashboard/API 讀回退化事件卡是否已送出、是否失敗、是否仍只停在 source-side」。本輪補只讀 API contract,不實發 Telegram、不修改 Wazuh、不寫 incident。
|
||||
|
||||
**完成**:
|
||||
- 新增 `GET /api/v1/platform/runs/ai-alert-cards`,支援 `project_id`、`event_type`、`lane`、`page`、`per_page`、`refresh`。
|
||||
- service 層只查 `awooop_outbound_message.source_envelope ? 'ai_automation_alert_card'`,不新增 DB migration。
|
||||
- 回傳 `awooop_ai_alert_card_delivery_readback_v1` summary:`sent_total`、`failed_total`、`pending_total`、`shadow_total`、`delivery_receipt_required_total`、`runtime_write_gate_open_count`、`production_write_count=0`。
|
||||
- item 只回 metadata、source refs、send status、run ref,不回完整 Telegram text、raw alert、raw Wazuh payload、內網 URL 或主機路徑。
|
||||
- AwoooP 通知模型與 Wazuh agent disappearance readback 文件已同步 API 路徑與禁止解讀。
|
||||
|
||||
**驗證**:
|
||||
- `DATABASE_URL=postgresql://postgres:postgres@localhost:5432/awoooi_test pytest apps/api/tests/test_awooop_operator_timeline_labels.py apps/api/tests/test_telegram_gateway_error_sanitizer.py apps/api/tests/test_telegram_message_templates.py -q`:`144 passed`。
|
||||
- `python3 -m py_compile apps/api/src/services/platform_operator_service.py apps/api/src/api/v1/platform/operator_runs.py apps/api/src/services/telegram_gateway.py`:通過。
|
||||
- `python3 scripts/security/security-mirror-progress-guard.py --root .`:通過。
|
||||
- `git diff --check`:通過。
|
||||
|
||||
**完成度同步**:
|
||||
- AwoooP AI 事件卡 delivery readback API source-side:`100%`。
|
||||
- Wazuh P0-D alert card / delivery readiness:`82% -> 88%` source-side、`0%` production receipt。
|
||||
- SOC / Wazuh no-false-green 納管:`56% -> 60%`。
|
||||
- production deploy、live outbound readback、IwoooS 前台顯示、Wazuh manager registry 驗收、Dashboard stored API 修復:仍維持 `0%`。
|
||||
|
||||
**邊界**:本輪沒有送 Telegram、沒有 DB migration、沒有 runtime deploy、沒有 Wazuh / 112 / host / Nginx / Docker / firewall / secret 寫入,也沒有 active scan。
|
||||
|
||||
## 2026-06-25|AwoooP mirror 事件卡 metadata 讀回基礎
|
||||
|
||||
**背景**:Wazuh Dashboard/API 讀回退化事件卡已能把 raw 429/500 轉成 `ai_automation_alert_card_v1`,但若 AwoooP outbound mirror 只保存一般文字,後續 delivery receipt 與 timeline 仍難以用結構化方式查詢 Wazuh lane / gate。
|
||||
|
||||
@@ -163,6 +163,7 @@ Live 2026-05-12 evidence shows this gate is not yet green:
|
||||
- `append_incident_update()` 對相同的「AI 自動修復失敗 / AI 診斷工具失敗」摘要增加 10 分鐘跨 incident 去重;每個 incident 仍會移除原卡危險按鈕,但 Telegram 不再重複 reply 同一個失敗摘要。
|
||||
- `TelegramGateway._send_request()` 對成功送出的 legacy `sendMessage` 增加 AwoooP `awooop_outbound_message` 鏡像。鏡像失敗只記錄 `telegram_outbound_mirror_failed`,不能影響 Telegram 正常送達。
|
||||
- `ai_automation_alert_card_v1` 送出後,AwoooP mirror envelope 需帶 `ai_automation_alert_card_mirror_v1` metadata,至少包含 `event_type`、`lane`、`target`、`gates`、`runtime_write_gate_count=0` 與 `delivery_receipt_readback_required=true`;不得把 raw alert、完整 Telegram text、token、內網 URL、主機路徑或 raw Wazuh payload 放進 envelope。
|
||||
- `GET /api/v1/platform/runs/ai-alert-cards` 只讀查詢 `ai_automation_alert_card_v1` delivery readback,可用 `project_id`、`event_type`、`lane` 篩選;此路徑只回 metadata、source refs 與 send status,不回完整 Telegram text,也不代表 Telegram 已實發或 Wazuh registry 已驗收。
|
||||
- 成本告警、審批執行結果、自愈 rollback 提案已由 direct Bot API 改走 `TelegramGateway._send_request()`,避免繞過 outbound mirror。
|
||||
- `telegram_gateway.py` 內部歷史直打 `sendMessage` 路徑已收斂;多 Bot `_send_as_bot()` 因需指定 token 保留 direct HTTP,但成功後同樣鏡像到 `awooop_outbound_message`。
|
||||
- 既有 `詳情 / 重診 / 歷史` 按鈕保留,讓 Telegram 保持輕量,細節回到控制台。
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
| P0-A | Wazuh manager agent registry 只讀驗收 | owner 提供脫敏 `agent_total / active / disconnected / last_seen` ref,或經 server-side secret metadata 啟用 IwoooS 只讀 API | `40%` |
|
||||
| P0-B | Dashboard stored API / rate-limit / TLS trust 修復 gate | 查明 `/api/check-stored-api` 429/500 根因;維修前有 owner、rollback、postcheck;維修後 Dashboard 與 API count 一致 | `35%` |
|
||||
| P0-C | IwoooS live metadata route 正式部署 | `/api/iwooos/wazuh` 不再 404,回傳 schema `iwooos_wazuh_readonly_status_v1`,不洩漏 agent identity / internal IP / secret | `55%` source-side、`0%` production |
|
||||
| P0-D | Wazuh agent disappearance alert card | 產出 `ai_automation_alert_card_v1`,包含 agent count delta、Dashboard API status、manager health、next gate、owner;本輪已新增 `wazuh_dashboard_api_readback_degraded` formatter / test / guard | `70%` source-side、`0%` delivery receipt |
|
||||
| P0-D | Wazuh agent disappearance alert card | 產出 `ai_automation_alert_card_v1`,包含 agent count delta、Dashboard API status、manager health、next gate、owner;本輪已新增 `wazuh_dashboard_api_readback_degraded` formatter / test / guard 與 AwoooP `/runs/ai-alert-cards` delivery readback contract | `88%` source-side、`0%` production receipt |
|
||||
| P0-E | 112/Wazuh owner response | 回覆 owner role/team、decision、reason、affected scope、redacted evidence refs、rollback owner、followup owner | `0%` |
|
||||
| P1-A | 110/188 agent receipt heartbeat | 每台 host 定期只讀確認 service active、manager target、1514 established、last evidence ref | `45%` |
|
||||
| P1-B | Dashboard no-false-green | Dashboard 429/500 或 Wazuh API check failure 要進 IwoooS incident,不可顯示綠燈 | `15%` |
|
||||
@@ -84,7 +84,7 @@
|
||||
1. 請 Wazuh/112 owner 補脫敏 agent registry evidence:`agent_total`、`active`、`disconnected`、`never_connected`、`last_seen` 時間窗,不提供密碼或 raw payload。
|
||||
2. 啟用 IwoooS `/api/iwooos/wazuh` 前,先完成 production route readback、server-side env owner、secret source metadata、readonly account scope 與 rollback owner。
|
||||
3. 若 owner 批准維修 Dashboard stored API,必須先做 read-only preflight:rate-limit 現況、stored API 指向、TLS trust、API user scope、Dashboard 與 manager 版本、回滾方式。
|
||||
4. 補 IwoooS AI 事件卡正式 readback:source-side formatter 已能把 Dashboard/API mismatch 分類為 `wazuh_dashboard_api_readback_degraded`;下一步需接 delivery receipt、AwoooP timeline 與 IwoooS 前台 readback。
|
||||
4. 補 IwoooS AI 事件卡正式 readback:source-side formatter 已能把 Dashboard/API mismatch 分類為 `wazuh_dashboard_api_readback_degraded`,AwoooP 已有 `/api/v1/platform/runs/ai-alert-cards` 只讀 delivery readback contract;下一步需 production deploy、live outbound readback、AwoooP timeline 顯示與 IwoooS 前台 readback。
|
||||
|
||||
## 7. 完成度
|
||||
|
||||
@@ -92,5 +92,5 @@
|
||||
- 真正 agent registry 驗收:`0%`。
|
||||
- IwoooS live readback production:`0%`。
|
||||
- Dashboard stored API 修復:`0%`。
|
||||
- SOC / Wazuh no-false-green 納管:`52%`。
|
||||
- SOC / Wazuh no-false-green 納管:`60%`。
|
||||
- active response / host write / auto block:`0%`,保持關閉。
|
||||
|
||||
Reference in New Issue
Block a user