"""Run and Step enums (build plan Section 5).

Kept dependency-free so ORM models and the runner can both import them.
"""

from __future__ import annotations

from enum import Enum


class RunStatus(str, Enum):
    PENDING = "pending"
    RUNNING = "running"
    WAITING_APPROVAL = "waiting_approval"
    SUCCEEDED = "succeeded"
    FAILED = "failed"
    CANCELLED = "cancelled"


#: Statuses from which a run will not progress further on its own.
TERMINAL_STATUSES: frozenset[RunStatus] = frozenset(
    {RunStatus.SUCCEEDED, RunStatus.FAILED, RunStatus.CANCELLED}
)


class StepType(str, Enum):
    AGENT_REASON = "agent_reason"
    TOOL_CALL = "tool_call"
    CONDITION = "condition"
    TRANSFORM = "transform"
    APPROVAL = "approval"
    TRIGGER = "trigger"


class ApprovalStatus(str, Enum):
    PENDING = "pending"
    APPROVED = "approved"
    REJECTED = "rejected"
    EXPIRED = "expired"


#: Approval statuses that are final.
DECIDED_APPROVAL_STATUSES: frozenset[ApprovalStatus] = frozenset(
    {ApprovalStatus.APPROVED, ApprovalStatus.REJECTED, ApprovalStatus.EXPIRED}
)
