From 21dcfbd9919a47162db83652ab5d9aea9f482285 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 14 May 2026 19:37:15 +0800 Subject: [PATCH] fix(governance): collapse km slo fallback series --- apps/api/src/services/governance_agent.py | 2 +- apps/api/tests/test_governance_agent.py | 2 +- docs/adr/ADR-100-ai-autonomous-slo.md | 2 +- ops/monitoring/slo-rules.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/api/src/services/governance_agent.py b/apps/api/src/services/governance_agent.py index 1e7371c95..eeb4375fb 100644 --- a/apps/api/src/services/governance_agent.py +++ b/apps/api/src/services/governance_agent.py @@ -409,7 +409,7 @@ class GovernanceAgent: "autonomy_rate": "sli:autonomy_rate:5m", "decision_accuracy": "sli:decision_accuracy:5m", "confidence_calibration": "sli:confidence_calibration:1h", - "km_growth_rate": "max(knowledge_entries_created_24h) or sli:km_growth_rate:24h", + "km_growth_rate": "max(knowledge_entries_created_24h) or max(sli:km_growth_rate:24h)", } # 硬紅線:低於此值必須告警(非軟性警告) hard_red_lines: dict[str, float] = { diff --git a/apps/api/tests/test_governance_agent.py b/apps/api/tests/test_governance_agent.py index 7d9593a63..39461bc78 100644 --- a/apps/api/tests/test_governance_agent.py +++ b/apps/api/tests/test_governance_agent.py @@ -695,6 +695,6 @@ class TestCheckSloCompliance: with patch("httpx.AsyncClient", return_value=client): result = await agent.check_slo_compliance() - assert "max(knowledge_entries_created_24h) or sli:km_growth_rate:24h" in client.queries + assert "max(knowledge_entries_created_24h) or max(sli:km_growth_rate:24h)" in client.queries assert result["km_growth_rate"]["status"] == "ok" assert result["km_growth_rate"]["value"] == 25 diff --git a/docs/adr/ADR-100-ai-autonomous-slo.md b/docs/adr/ADR-100-ai-autonomous-slo.md index f3453bea6..2a16abca7 100644 --- a/docs/adr/ADR-100-ai-autonomous-slo.md +++ b/docs/adr/ADR-100-ai-autonomous-slo.md @@ -112,7 +112,7 @@ sum(rate(approval_records_high_confidence_total[1h])) ```promql max(knowledge_entries_created_24h) or -increase(knowledge_entries_total[24h]) +max(increase(knowledge_entries_total[24h])) ``` **Recording rule**: `sli:km_growth_rate:24h` diff --git a/ops/monitoring/slo-rules.yml b/ops/monitoring/slo-rules.yml index 115bffbe6..70414c0fe 100644 --- a/ops/monitoring/slo-rules.yml +++ b/ops/monitoring/slo-rules.yml @@ -50,7 +50,7 @@ groups: expr: | max(knowledge_entries_created_24h) or - increase(knowledge_entries_total[24h]) + max(increase(knowledge_entries_total[24h])) # ----------------------------------------------------------------------- # Error Budget Recording Rules(輔助 Grafana 顯示)