server.web.services.task_fsm ============================ .. py:module:: server.web.services.task_fsm .. autoapi-nested-parse:: Centralized Task finite state machine. Classes ------- .. autoapisummary:: server.web.services.task_fsm.TaskFSM Module Contents --------------- .. py:class:: 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. .. py:attribute:: VALID_TRANSITIONS :type: Dict[str, Set[str]] .. py:attribute:: VALID_SOURCES :type: Dict[str, Set[str]] .. py:attribute:: TI_TO_TASK_STATUS :type: Dict[str, str] .. py:method:: is_valid_transition(from_status: str, to_status: str) -> bool :classmethod: Check if a transition is valid per FSM rules. .. py:method:: get_valid_sources(to_status: str) -> Set[str] :classmethod: Get all statuses that can transition TO the given status. .. py:method:: is_terminal(status: str) -> bool :classmethod: Check if a status is terminal (no outgoing transitions). .. py:method:: get_task_status_for_ti(ti_status: str, task_num_attempts: int, task_max_attempts: int) -> Optional[str] :classmethod: Get Task status for a TaskInstance status change. Skips ERROR_RECOVERABLE, returns final state directly. Returns None if no Task transition needed.