Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:173TECH Sayn Task Execution Lifecycle

From Leeroopedia
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:

  1. Phase Separation: Each phase has a distinct purpose and failure in one phase prevents the next
  2. Status Machine: A TaskStatus enum tracks the current state, enabling skip logic
  3. 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_fail is not no_skip), the child is SKIPPED
  • If a parent is SKIPPED, the child is SKIPPED
  • fail_fast mode: 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 → run
  • sayn 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.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment