fix(api): 在人工處置告警顯示資產總帳
All checks were successful
Code Review / ai-code-review (push) Successful in 13s
CD Pipeline / tests (push) Successful in 1m41s
CD Pipeline / build-and-deploy (push) Successful in 4m44s
CD Pipeline / post-deploy-checks (push) Successful in 2m32s

This commit is contained in:
Your Name
2026-06-18 13:02:29 +08:00
parent 14d57270b8
commit 5e2a758fcf
2 changed files with 27 additions and 0 deletions

View File

@@ -263,6 +263,25 @@ def _manual_evidence_hint(resource_name: str, alert_category: str) -> str:
return "來源事件、fingerprint recurrence、metrics、logs、最近變更與相關 run"
def _format_manual_asset_ledger_lines(*, compact: bool = False) -> list[str]:
"""Show the automation assets that must be sedimented before closure."""
if compact:
return [
"🧾 <b>自動化資產總帳</b>",
"└ 需回寫KM / PlayBook / 腳本或 Ansible / 排程或監控規則 / Verifier",
]
return [
"🧾 <b>自動化資產總帳</b>",
"├ KM<code>Knowledge Base</code> 草稿、來源與 owner",
"├ PlayBook<code>Work Items</code> 專屬草案、trust gate 與 rollback",
"├ 腳本/Ansible<code>Runs</code> 安全路由、命令與執行紀錄",
"├ 排程/監控:<code>Observability</code> recurrence、rule 與抑噪狀態",
"├ Verifier<code>事件時間線</code> healthy / degraded / failed 回寫",
"└ 判定:沒有資產 ID、owner、狀態與下一步不可視為自動化完成",
]
def _format_manual_handoff_package_lines(
*,
incident_id: str,
@@ -307,6 +326,7 @@ def _format_manual_handoff_package_lines(
"├ 4. 沉澱資產KM、PlayBook、腳本/Ansible、排程/監控規則、Verifier 結果",
"└ 5. 頁面可查Runs、Work Items、Knowledge Base 要顯示資產 ID、owner、狀態與下一步",
]
lines.extend(_format_manual_asset_ledger_lines(compact=compact))
insert_at = 3
if repair_candidate_blocker_summary:
lines.insert(

View File

@@ -77,6 +77,13 @@ def test_repair_candidate_missing_card_exposes_manual_handoff_package() -> None:
assert "https://awoooi.wooo.work/zh-TW/awooop/work-items?" in body
assert "補證據node_exporter target up" in body
assert "AwoooP 建立修復候選" in body
assert "自動化資產總帳" in body
assert "KM<code>Knowledge Base</code>" in body
assert "PlayBook<code>Work Items</code>" in body
assert "腳本/Ansible<code>Runs</code>" in body
assert "排程/監控:<code>Observability</code>" in body
assert "Verifier<code>事件時間線</code>" in body
assert "不可視為自動化完成" in body
assert "按鈕:<b>處置包</b>" in body
assert "修復候選狀態" in body
assert "等待人工批准" not in body