Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Workflows and scheduler

Workflows

A workflow is a durable state machine. Each step is a task (or a nested workflow) with an owner, a budget, and a compensation action. The engine persists state transitions, tokens, cost, and attempt markers so a crash does not silently re-execute a completed step.

Key properties:

Pause is a gate. Events that arrive while paused are parked and resumed deliberately; a paused workflow does not execute side effects. Compensation is LIFO and includes the failing step. A failed step’s compensation is sequenced before its predecessors; markers are written before effects so a kill window cannot double-compensate. Budgets auto-stop. Token and time budgets are enforced; exceeding a budget enters a terminal budgetlimited path. Definitions are hashed. A persisted workflow refuses a definition that drifted underneath it. Terminal GC and branch inheritance keep the instance graph bounded and consistent.

Recipes

Recipes are named workflow definitions, validated at load and reloadable at runtime. zerg recipe-list, recipe-show, recipe-run, and recipe-reload are the operator surface.

Authoring

Workflow definitions bind step names to registered task/agent chains. The registry validates that every referenced chain exists at load; an unknown chain refuses the definition loudly. See the API reference for start/cancel/branch/tree/lineage.

Scheduler

The scheduler runs jobs on cron, an interval, or a one-time epoch.

Create-time validation refuses impossible schedules (for example a day-of-month that cannot occur in the selected month). Single-writer claim. A job is claimed atomically in the store; multiple dispatch paths cannot double-run it. Timezone posture. Cron expressions are interpreted as UTC unless the deployment documents otherwise. This is a deliberate, dependency-free choice. Persistence classes. Deletes/disables are immediate; bulk edits are debounced and the bounded residual is documented. Stuck-job recovery resets a stuck job with backoff and raises a CRITICAL after repeated attempts.

Commands

zerg schedule list
zerg schedule add "Run the health summary" --cron "0 */6 * * *" --name health-summary
zerg schedule show <job-id>
zerg schedule pause <job-id>
zerg schedule unpause <job-id>
zerg schedule run <job-id>
zerg schedule delete <job-id>

Exactly one schedule source is used: --every wins over --cron, which wins over --at. --at takes Unix epoch seconds; an ISO 8601 string is silently dropped.

Next

First workflow tutorial Workflow API Scheduler API Events reference