Drive the worker generation state machine¶
Topics: backends, dispatch, generation, workers
Construct the appropriate HordeWorkerJob and HordeSingleGeneration subtype after a successful pop. The generation
object owns one unit of backend work; the job coordinates one or more generations for the popped request.
- Validate and normalize pop data before creating the generation. Verify the dispatch converter returns backend-ready parameters without mutating the API response model.
- Start generation through the job/executor boundary. Observe its state transition and persist the Horde job ID.
- Record progress only in states that permit it. Treat backend cancellation and exceptions as explicit terminal paths.
- Submit the typed result, then mark the generation terminal only after the submit response succeeds.
- Release backend resources in
finally, including partial-output and cancellation paths.
Tests should assert the exact transition sequence and reject an illegal transition. A submitted generation cannot be retracted; report a later failure as a new worker event. See worker transitions for the state contract and the worker model for ownership boundaries.