server.web.services.task_fsm

Centralized Task finite state machine.

Classes

TaskFSM

Centralized finite state machine for Task status transitions.

Module Contents

class server.web.services.task_fsm.TaskFSM

Centralized finite state machine for Task status transitions.

Extracts and centralizes the FSM logic currently embedded in Task model. Includes direct transitions that skip ERROR_RECOVERABLE intermediate state.

VALID_TRANSITIONS: Dict[str, Set[str]]
VALID_SOURCES: Dict[str, Set[str]]
TI_TO_TASK_STATUS: Dict[str, str]
classmethod is_valid_transition(from_status: str, to_status: str) bool

Check if a transition is valid per FSM rules.

classmethod get_valid_sources(to_status: str) Set[str]

Get all statuses that can transition TO the given status.

classmethod is_terminal(status: str) bool

Check if a status is terminal (no outgoing transitions).

classmethod get_task_status_for_ti(ti_status: str, task_num_attempts: int, task_max_attempts: int) str | None

Get Task status for a TaskInstance status change.

Skips ERROR_RECOVERABLE, returns final state directly. Returns None if no Task transition needed.