fix(ai): suppress sealed slo watchdog meta noise
All checks were successful
CD Pipeline / tests (push) Successful in 1m21s
Code Review / ai-code-review (push) Successful in 17s
CD Pipeline / build-and-deploy (push) Successful in 3m48s
CD Pipeline / post-deploy-checks (push) Successful in 2m6s

This commit is contained in:
Your Name
2026-06-01 18:52:27 +08:00
parent fffc21ccf5
commit 9886df8785
3 changed files with 157 additions and 6 deletions

View File

@@ -118,11 +118,18 @@ async def _check_once() -> None:
report = await AiSloCalculator().calculate()
if report.any_violated:
violated = [m.name for m in report.metrics if m.violated]
w1_line, w1_cause = _format_slo_violation_for_alert(report, violated)
violations.append(w1_line)
if w1_cause:
probable_causes.append(w1_cause)
violation_codes.append(f"W1:slo_violated:{','.join(sorted(violated))}")
if _is_observation_only_slo_violation(report, violated):
logger.info(
"watchdog_w1_slo_observation_only",
violated=violated,
reason="sealed_waiting_rolling_window",
)
else:
w1_line, w1_cause = _format_slo_violation_for_alert(report, violated)
violations.append(w1_line)
if w1_cause:
probable_causes.append(w1_cause)
violation_codes.append(f"W1:slo_violated:{','.join(sorted(violated))}")
except Exception as e:
logger.warning("watchdog_w1_slo_check_failed", error=str(e))
@@ -354,6 +361,23 @@ def _format_slo_violation_for_alert(report, violated: list[str]) -> tuple[str, s
return line, "\n".join(cause_parts)
def _is_observation_only_slo_violation(report, violated: list[str]) -> bool:
"""已封口且只等 rolling window 的 W-1不再升成 Meta System 告警。"""
if set(violated) != {"auto_execute_success_rate"}:
return False
diagnostics = getattr(report, "diagnostics", {}) or {}
diag = diagnostics.get("auto_execute_success_rate") or {}
try:
open_groups = int(diag.get("open_failure_group_count") or 0)
except (TypeError, ValueError):
open_groups = 0
return (
diag.get("status") == "sealed_waiting_window"
and open_groups == 0
)
def _short_taipei_time(value: str | None) -> str | None:
if not value:
return None