Skip to content

Workflow Execution Model

Document ID: WF-002 Version: 1.0.0 Status: Draft Owner: Workflow Engine Team Last Updated: 2026-06-26


This document defines the execution semantics of the Wovyr Workflow Engine.

It specifies:

  • Workflow lifecycle
  • Execution state transitions
  • Activity dispatch
  • Scheduling behavior
  • Replay rules
  • Checkpointing
  • Concurrency model
  • Failure handling
  • Worker coordination

This document serves as the implementation contract for the runtime.


The execution model must provide:

  • Durable execution
  • Deterministic behavior
  • Horizontal scalability
  • Replay capability
  • Fault tolerance
  • Observability
  • High throughput

The Workflow Engine executes workflows as:

Durable, event-sourced state machines.

Execution state is reconstructed from events and checkpoints.

Workflow progress is never dependent on process memory alone.


Created
Validated
Scheduled
Running
├────────► Waiting
│ │
│ ▼
│ Resumed
Completed
Failed
Cancelled
Compensated

Every transition is persisted.


Each workflow execution creates a unique instance.

Attributes:

execution_id:
workflow_id:
workflow_version:
tenant_id:
correlation_id:
status:
started_at:
updated_at:
owner_worker:
variables:
metadata:

Instances are immutable except through state transitions.


The execution context contains runtime state.

context:
inputs:
outputs:
variables:
secrets:
metadata:
correlation_id:
retry_counts:
activity_results:

The context is persisted throughout execution.


Workflow progress is represented by events.

Example:

WorkflowCreated
WorkflowScheduled
ActivityStarted
ActivityCompleted
ActivityCompleted
WorkflowCompleted

State can be reconstructed by replaying events.


To avoid replaying entire histories, periodic checkpoints are stored.

Checkpoint contents:

checkpoint:
execution_state:
active_nodes:
variables:
completed_activities:
timestamps:

Checkpoints accelerate recovery and startup.


Activities are the smallest executable units.

Execution flow:

Ready
Dispatched
Running
├────► Retrying
Completed
└────► Failed

Activity execution is isolated from workflow orchestration.


Workflow runtime identifies executable nodes.

Pseudo-flow:

1. Load execution state
2. Identify ready activities
3. Publish work items
4. Workers claim activities
5. Execute activity
6. Persist result
7. Evaluate next transitions

Only activities whose dependencies are satisfied become eligible.


A workflow execution has an owning worker.

Responsibilities:

  • Coordinate state transitions
  • Schedule activities
  • Persist progress

Ownership can transfer during failure recovery.


Workers execute activity tasks.

Responsibilities:

  • Claim task
  • Execute activity
  • Publish result
  • Report failures

Workers remain stateless.


The engine supports:

  • Sequential execution
  • Parallel branches
  • Dynamic fan-out
  • Dynamic fan-in

Example:

Start
┌────┴────┐
▼ ▼
Task A Task B
└────┬────┘
Merge

Branch synchronization occurs at merge points.


Workflow definitions must remain deterministic.

Allowed:

  • Workflow variables
  • Stored activity outputs
  • Persisted events

Disallowed:

  • Current system time
  • Random values
  • External calls directly from orchestration logic

Non-deterministic work must occur inside activities.


Replay rebuilds execution state.

Process:

Load Checkpoint
Load Events After Checkpoint
Reconstruct State
Resume Execution

Replay must produce identical workflow state.


Recovery occurs when:

  • Worker crashes
  • Node fails
  • Deployment restarts
  • Infrastructure disruption occurs

Recovery steps:

  1. Detect abandoned execution
  2. Reassign ownership
  3. Restore checkpoint
  4. Replay events
  5. Resume scheduling

No completed activity should be re-executed unless explicitly configured.


Events may trigger execution changes.

Examples:

  • Human approval received
  • Webhook callback
  • Timer fired
  • File uploaded

Workflow state changes only through validated events.


Execution may pause indefinitely.

Examples:

  • Human approval
  • External event
  • Scheduled resume
  • Long-running process

Waiting executions consume no worker resources.


Eligible activities are determined by:

  • Dependency satisfaction
  • Conditional evaluation
  • Resource availability
  • Policy constraints

Scheduling decisions are deterministic.


Execution policies may define:

limits:
max_parallelism:
max_memory:
timeout:
retries:

Policies are evaluated before dispatch.


Timeout scopes:

  • Activity timeout
  • Workflow timeout
  • Waiting timeout
  • Schedule timeout

Timeouts generate workflow events and trigger configured policies.


Failures are categorized as:

Single activity fails.

Entire workflow cannot proceed.

Runtime or infrastructure issue.

Provider or service unavailable.

Each failure type may trigger different recovery behavior.


Retries are configurable.

Example:

retry:
attempts: 5
strategy: exponential
delay: 30s

Retries apply to activities, not orchestration logic.


Compensation is used when completed work must be reversed.

Example:

Reserve Inventory
Charge Payment
Create Shipment
Failure
Compensate:
Cancel Shipment
Refund Payment
Release Inventory

Compensation activities are explicit workflow steps.


Examples:

WorkflowStarted
ActivityDispatched
ActivityStarted
ActivityCompleted
ActivityFailed
WorkflowPaused
WorkflowResumed
WorkflowCompleted
WorkflowFailed

These events drive observability and recovery.


Persist after:

  • State transition
  • Activity completion
  • Retry increment
  • Event receipt
  • Ownership change

Persistence must occur before acknowledging critical progress.


Supports:

  • Multiple schedulers
  • Distributed workers
  • Queue partitioning
  • Horizontal scaling

Work distribution should avoid centralized bottlenecks.


Track:

  • Workflow duration
  • Activity duration
  • Queue depth
  • Retry count
  • Failure rate
  • Worker utilization

All executions must be traceable via Correlation ID.


Execution runtime must enforce:

  • Tenant isolation
  • Activity permissions
  • Secret access policies
  • Audit logging

Security policies are evaluated before activity execution.


  • Workflow Overview
  • Workflow DSL
  • DAG Engine
  • Scheduler
  • State Machine
  • Checkpointing
  • Retry Engine
  • Compensation
  • Distributed Execution
  • Persistence
  • Rust Crate Design

VersionDateDescription
1.0.02026-06-26Initial Workflow Execution Model