Workflow and Context
Workflow, Operation, Work, Event, and Query are the durable contracts. WorkflowExecution<E> is passed to a workflow handler and exposes the complete operation layer directly.
Construction
| API | Creates |
|---|---|
Workflow<I, O, E>(...) | Workflow definition backed by three Schema values |
Operation<I, O, E>(...) | Automated-operation definition backed by three Schema values |
Work<I, R>(...) | Assigned-work request and response contract |
Event<P>(...) | External-event contract |
WorkflowDocument.compileJson(document) | Compiled JSON document |
document.compile() | Compile an existing WorkflowDocument |
Query | Typed read-only query contract |
Schema construction
Schema<T> is the workflow-facing wrapper. Build its jsonSchema with package:json_schema_builder, which owns Draft 2020-12 types, constraints, composition, references, formats, and validation. Use @JsonSerializable(createJsonSchema: true) when the Dart model should generate its codec and structural schema from one declaration.
The wrapper is enforced, not merely published for tooling. Schema.decode validates incoming JSON before constructing a Dart value; Schema.encode validates generated JSON before it can be persisted or returned. The runtime applies this rule to workflows, operations, work, events, queries, expected failures, and child workflows. Failures report the schema key, encode/decode direction, and JSON Schema violations.
Custom Schema<T> declarations must provide jsonSchema; there is no implicit permissive schema. Schema.identity is for JSON-native values and accepts an explicit structural schema. Its omitted-schema form deliberately means unconstrained JSON. Schema.never declares the impossible failure seam of an infallible workflow or operation.
Context Actions
| Action | Meaning |
|---|---|
perform | Automated side effect with retry, timeout, idempotency, and annotations |
request | Request assigned durable work and wait for a response |
waitForEvent | Wait for a named typed external event |
sleep | Durable timer |
parallel / race / quorum | Structured concurrency |
forEach | Keyed durable fan-out |
saga | Reverse-order compensation |
workflow / spawn / join | Child workflows |
query | Publish a typed read-only snapshot |
continueAsNew | Close and create the successor |
continueAsNewSuggested is true once history reaches the soft limit.