Files
awoooi/apps/api/src/services/approval_action_classifier.py
Your Name 4ada9e6d19
Some checks failed
Code Review / ai-code-review (push) Successful in 22s
CD Pipeline / tests (push) Successful in 1m54s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
Ansible / Reboot Recovery Contract / validate (push) Has been cancelled
fix(api): expose repair draft owner review state
2026-06-25 20:06:10 +08:00

34 lines
1.0 KiB
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 "DRAFT_READY" in upper
or "OWNER_REVIEW_REQUIRED" 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)