Workflows
Workflows are the core execution mechanism of the Demiton platform. A workflow defines a deterministic sequence of steps that performs a specific operational task — retrieving labour records, transforming them into canonical structures, posting project costs to an ERP ledger.
Execution model
When a workflow is triggered:
- A
WorkflowRunrecord is created TaskRunrecords are created for each step- The run is persisted to the database (pre-flight commit)
- Execution is delegated to the ARQ worker
Execution always occurs asynchronously. No workflow logic runs inside the HTTP control plane.
Step lifecycle
Each step transitions through a defined lifecycle:
| State | Meaning |
|---|---|
PENDING | Created, not yet started |
RUNNING | Currently executing |
SUCCEEDED | Completed successfully |
FAILED | Encountered an error; workflow stops |
SUSPENDED | Awaiting governance approval |
SKIPPED | Bypassed by a LOGIC_GATE |
All state transitions are recorded in the platform database.
Workflow verbs
Each step executes exactly one verb. See the Workflow Verbs reference for the complete list.
External verbs (interact with adapters):
FETCH— retrieve records from an external systemLOOKUP— retrieve a single entityPUSH— write records into an external systemEXECUTE— perform operational commands
Internal verbs (operate in memory only):
TRANSFORM— normalize and map recordsGOVERN— evaluate governance policiesLOGIC_GATE— control workflow branching
Pipeline context
During execution, workflows maintain a PipelineContext — an in-memory structure that stores step outputs. It is:
- scoped to a single workflow run
- cleared after execution completes
- never shared across runs
This prevents cross-run data contamination. Sensitive data (credentials, PII) lives in RAM only and is never persisted to the workflow state.
Suspension and approval
Workflows may suspend when a governance check requires manual approval.
When a step returns a suspension signal:
- The workflow pauses at that step
- Current state is persisted to the database
- An approval request is created
- Execution resumes only after an authorized user approves
This enables approval flows for financial postings, vendor creation, and other sensitive operations.
Triggers
Workflows can be triggered:
- Manually — user action from the platform UI or API
- Scheduled — cron expression evaluated by the workflow scheduler
- Programmatic — via the API (
POST /workflows/{id}/runs)
See Scheduled Pipelines for cron configuration.
Fan-out execution
Workflows that need to process a list of records in parallel use ChunkedDispatch. The runtime spawns one ChunkRun per generator record, allowing large datasets to be processed concurrently while each chunk maintains its own isolated execution context.