When tasks created by a workflow execution complete or fail, the WorkflowExecution should transition to terminal status accordingly.
Currently, activate() creates an execution in RUNNING status and cancel_execution() transitions to CANCELLED, but there is no mechanism to advance an execution to COMPLETED or FAILED based on task outcomes.
What needs to happen
-
COMPLETED transition: When all TASK nodes in the execution have their corresponding tasks completed successfully, the execution should transition to COMPLETED with completed_at set.
-
FAILED transition: When any task fails (or a configurable failure policy is met), the execution should transition to FAILED with error and completed_at set.
-
Event constants: WORKFLOW_EXEC_COMPLETED and WORKFLOW_EXEC_FAILED are already defined in src/synthorg/observability/events/workflow_execution.py but are currently unused -- they should be used when logging these transitions.
Implementation options
- Polling: A periodic check that queries task statuses for running executions
- Event-driven: TaskEngine emits events on task completion/failure, and a listener updates the execution
- Callback: The workflow execution service registers a callback with the TaskEngine at activation time
Context
When tasks created by a workflow execution complete or fail, the
WorkflowExecutionshould transition to terminal status accordingly.Currently,
activate()creates an execution inRUNNINGstatus andcancel_execution()transitions toCANCELLED, but there is no mechanism to advance an execution toCOMPLETEDorFAILEDbased on task outcomes.What needs to happen
COMPLETED transition: When all TASK nodes in the execution have their corresponding tasks completed successfully, the execution should transition to
COMPLETEDwithcompleted_atset.FAILED transition: When any task fails (or a configurable failure policy is met), the execution should transition to
FAILEDwitherrorandcompleted_atset.Event constants:
WORKFLOW_EXEC_COMPLETEDandWORKFLOW_EXEC_FAILEDare already defined insrc/synthorg/observability/events/workflow_execution.pybut are currently unused -- they should be used when logging these transitions.Implementation options
Context
completed_atcross-field validator was added in PR feat: workflow execution -- instantiate tasks from WorkflowDefinition #1040 -- terminal statuses now requirecompleted_atto be set