exlab_wizard.controller.state_machine#
Creation-session state machine. Backend Spec §4.7, §4.7.1.
Defines two enums and the mapping/transition tables that govern a
CreationController session’s lifecycle:
SessionState– the internal state the controller drives (Backend Spec §4.7). Includes terminal-error states (FAILED,ABORTED) and the holding stateINPUT_REQUIREDthat emit nophaseWebSocket frame on entry.Phase– the externally-emittedphaseenum (Backend Spec §4.6.2). Sent over theWS /api/v1/sessions/{id}/eventschannel on every state transition that has a corresponding phase event.state_to_phase()– the §4.7.1 mapping table verbatim. ReturnsNonefor transitional / terminal-error states; returnsPhase.INPUT_REQUIREDforINPUT_REQUIRED(the API surface encodes this as akind: "input_required"envelope rather than aphaseframe – the helper still emits the phase value so a single switch onstate_to_phasecan drive both code paths).VALID_TRANSITIONS– the per-state outbound transition table per the §4.7 diagram.FAILEDandABORTEDare reachable from any non-terminal state (cancel/fail can fire mid-pipeline); the table is hand-written rather than generated to keep the spec ↔ code mapping auditable.assert_transition()– guard used bySessionStoreandCreationControllerto reject invalid state transitions (caught by the type system at the API surface; the runtime raise is defensive against logic bugs in the controller’s pipeline).
Functions
|
Raise |
|
Return the |
Classes
|
Externally-emitted |
|
Internal creation-session state. |
- class exlab_wizard.controller.state_machine.Phase(*values)[source]#
Bases:
StrEnumExternally-emitted
phaseevent. Backend Spec §4.6.2.Sent over the
WS /api/v1/sessions/{id}/eventschannel on every state transition that has a corresponding phase event. The enum values match the spec’s wire-format strings verbatim.- DONE = 'done'#
- INPUT_REQUIRED = 'input_required'#
- QUEUEING_NAS_SYNC = 'queueing_nas_sync'#
- RENDERING_TEMPLATE = 'rendering_template'#
- RUNNING_PLUGINS = 'running_plugins'#
- VALIDATING_INPUTS = 'validating_inputs'#
- VALIDATING_POST_CREATION = 'validating_post_creation'#
- WRITING_CACHE = 'writing_cache'#
- class exlab_wizard.controller.state_machine.SessionState(*values)[source]#
Bases:
StrEnumInternal creation-session state. Backend Spec §4.7.
Values mirror the §4.7 state-machine diagram. Lower-case strings so JSON encoding is direct (
StrEnummakesSessionState.PENDINGrender as"pending").- ABORTED = 'aborted'#
- CACHE_WRITE = 'cache_write'#
- DONE = 'done'#
- FAILED = 'failed'#
- INPUT_REQUIRED = 'input_required'#
- PENDING = 'pending'#
- PLUGIN_PASS = 'plugin_pass'#
- POST_VALIDATE = 'post_validate'#
- RENDERING = 'rendering'#
- SYNC_QUEUED = 'sync_queued'#
- VALIDATING = 'validating'#
- exlab_wizard.controller.state_machine.assert_transition(current, new_state)[source]#
Raise
ValueErrorifcurrent -> new_stateis illegal.Defensive guard used by
SessionStore.transitionand the controller’s pipeline. Backend Spec §4.7 / §4.7.1 are the source of truth for the legal edges; this function consultsVALID_TRANSITIONSvia the sharedexlab_wizard.utils.state.assert_forward_transition()helper.- Parameters:
current (
SessionState)new_state (
SessionState)
- Return type:
- exlab_wizard.controller.state_machine.state_to_phase(state)[source]#
Return the
Phaseevent corresponding tostate.Backend Spec §4.7.1 mapping table.
PENDING,FAILED, andABORTEDreturnNone(no phase event).INPUT_REQUIREDreturnsPhase.INPUT_REQUIRED; the API surface encodes that as akind: "input_required"envelope rather than aphaseframe, but the mapping is preserved so a single dispatch knows the relationship.- Parameters:
state (
SessionState)- Return type: