Files
awoooi/apps/api/src/services/approval_action_classifier.py
Your Name 32e4beca06
All checks were successful
CD Pipeline / tests (push) Successful in 1m27s
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / build-and-deploy (push) Successful in 4m24s
CD Pipeline / post-deploy-checks (push) Successful in 1m29s
fix(api): connect approval execution truth chain
2026-06-11 13:03:54 +08:00

32 lines
995 B
Python

"""
Approval action classifier
==========================
2026-05-31 ogt + Codex: Telegram 告警鏈路一致性修復。
將 OBSERVE / INVESTIGATE / NO_ACTION 這類「純觀察、未執行修復」的
判斷集中,避免 execution、Telegram、統計各自用不同語意。
"""
from __future__ import annotations
def is_no_action_approval_action(action: str | None) -> bool:
"""Return True when an approval action records observation instead of repair."""
text = (action or "").strip()
upper = text.upper()
if not text:
return True
return (
"NO_ACTION" in upper
or "NO-ACTION" in upper
or "NOACTION" in upper
or "(未設)" in text
or upper.startswith("OBSERVE")
or upper.startswith("INVESTIGATE")
)
def is_executable_repair_approval_action(action: str | None) -> bool:
"""Return True when approving the action should schedule a repair executor."""
return not is_no_action_approval_action(action)