fix(governance): normalize knowledge degradation payloads
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 5m55s
CD Pipeline / build-and-deploy (push) Successful in 4m22s
CD Pipeline / post-deploy-checks (push) Successful in 1m39s

This commit is contained in:
Your Name
2026-05-19 15:35:39 +08:00
parent 81ac1f0f55
commit bf8974be03
2 changed files with 121 additions and 4 deletions

View File

@@ -294,6 +294,38 @@ def test_governance_alert_card_formats_knowledge_degradation() -> None:
assert "欄位快覽" not in card
def test_governance_alert_card_accepts_legacy_knowledge_degradation_payload() -> None:
card = format_governance_alert_card(
"knowledge_degradation",
{
"status": "warning",
"stale_count": 1425,
"total": 1856,
"stale_ratio": 0.768,
"threshold": 0.2,
"stale_days": 7,
"remediation": [
"啟動 KM 反查與自動補齊流程",
"關鍵服務告警自動同步到 KM 任務",
],
"next_step": "run_kb_growth_healthcheck",
"automatable_work": [
"每日檢查 ANTI_PATTERN 更新結果",
"安排至少 2 位 owner 對 stale 條目做快速人工審核",
],
},
)
assert "1425 / 1856 筆 KM" in card
assert "陳舊 KM1425" in card
assert "總 KM1856" in card
assert "陳舊比例76\\.8%" in card
assert "▶️ 下一步run\\_kb\\_growth\\_healthcheck" in card
assert "每日檢查 ANTI\\_PATTERN 更新結果" in card
assert "📎 *補充欄位*" not in card
assert "? / ?" not in card
def test_governance_alert_card_limits_fallback_fields() -> None:
card = format_governance_alert_card(
"custom_signal",