Principle:173TECH Sayn Task Execution Lifecycle
| Knowledge Sources | |
|---|---|
| Domains | Software_Engineering, Data_Engineering |
| Last Updated | 2026-10-17 00:00 GMT |
Overview
Pattern for managing task execution through a structured lifecycle of configuration, setup, and execution phases with status tracking and failure propagation.
Description
Task execution lifecycle is the practice of organizing task processing into discrete phases — config, setup, and execute (run/compile/test) — with explicit status transitions and failure propagation. This solves the problem of unstructured execution where a failure in one task leaves the system in an unknown state, and where dependency failures are not properly handled.
The lifecycle phases:
- Config: Validate task configuration against schema, compile SQL templates (stub pass for source/output collection), validate DDL
- Setup: Recompile templates with final source/output resolution (accounting for from_prod), activate database connections, introspect objects
- Execute: Run the task (run/compile/test), track status as SUCCEEDED/FAILED/SKIPPED, propagate failures to dependent tasks
Status transitions:
UNKNOWN → CONFIGURING → READY_FOR_SETUP → SETTING_UP → READY → EXECUTING → SUCCEEDED/FAILED/SKIPPED
Usage
Use this principle when designing a task execution system where tasks have dependencies and failures must propagate predictably. The lifecycle pattern ensures that setup failures are detected before execution and that parent failures cause child tasks to be skipped.
Theoretical Basis
The lifecycle is governed by three key mechanisms:
- Phase Separation: Each phase has a distinct purpose and failure in one phase prevents the next
- Status Machine: A
TaskStatusenum tracks the current state, enabling skip logic - Failure Propagation: When a parent fails, children are skipped (unless
on_fail: no_skip)
Skip logic:
- If a parent has status FAILED or SETUP_FAILED (and
on_failis notno_skip), the child is SKIPPED - If a parent is SKIPPED, the child is SKIPPED
fail_fastmode: any failure interrupts remaining execution
Pseudo-code:
# Abstract algorithm (NOT real implementation)
for task in tasks_in_topological_order:
if any_parent_failed(task) and task.on_fail == "skip":
task.status = SKIPPED
else:
result = task.run()
task.status = SUCCEEDED if result.is_ok else FAILED
if fail_fast and result.is_err:
break
Practical Guide
The lifecycle maps to SAYN CLI commands:
sayn run— full lifecycle: config → setup → runsayn compile— config → setup → compile (no execution)sayn test— config → setup → test (only tasks with tests)
The with_tests flag runs tests after run for each task.