Skip to main content

Module model

Module model 

Source
Expand description

The workflow model: a named DAG of steps beginning at start nodes, parsed from a JSON or YAML document and validated for acyclicity, reachability, finish reachability, dependency existence, schema well-formedness, CEL compilation and the caps.

Field checking is strict per kind: a field the kind does not declare is a validation error, not something to ignore. A misspelled key is the failure mode that hurts most here — the workflow parses, runs, and quietly does not do the thing that key was meant to configure — so an unknown field must be refused where someone is still looking at it.

The node catalogue is one table (KINDS); the validator, the executor and --workflow-schema all read it, so a kind cannot be documented without being validated or exposed without being described.

Structs§

Body
A nested sub-DAG: the body of foreach/batch/iterate/subgraph, or one branch of parallel/race. Body steps depend only on siblings; steps with no dependencies are the entry points; steps nothing depends on are the sinks whose outputs form the body’s result (one sink ⇒ its output; many ⇒ an object keyed by step id).
Concurrency
KindInfo
A step kind’s metadata.
Retry
StateDecl
One declared run variable.
Step
One step (the cross-cutting fields typed; kind fields in spec).
Unload
The unload: declaration ({policy, timeout}).
Workflow
A parsed, validated workflow.
WorkflowLimits
WorkflowTool
A workflow’s tool registration.
WorkflowToolGrant

Enums§

ConcurrencyScope
OnError
on_error policy.
OnOverflow
OnReplay
Priority
Contention priority — for workflows and subagent spawns. Ordering matters: higher is more important.
UnloadPolicy
What happens to a workflow’s LIVE runs when its definition goes away — removed from the config, replaced by another version, or workflow.deleted. Whatever the policy, withdrawing a definition always disarms its starts, unsubscribes its MCP resources, stops admitting new runs, and pins the definition each surviving run started against, so a run’s shape never changes underneath it.
WorkflowToolMode

Constants§

COMMON_FIELDS
Cross-cutting fields every step may carry, whatever its kind. Field checking is the union of these and the kind’s own list, so a name that appears in neither is refused.
DEFAULT_FAN_OUT
Lanes a foreach/batch uses when the definition does not say.
DIALECT
The dialect this model speaks.
KINDS
The node catalogue: every step kind, its start-node status, the fields it accepts, the fields it requires, whether this build executes it, and whether it carries a nested sub-DAG. This table is the single source the validator, the schema generator and the executor all consult.
MAX_BATCH_PARALLEL
MAX_ID_LEN
MAX_ITERATIONS
MAX_NESTING
MAX_STEPS
Structural caps, enforced at validation so a pathological document is refused when it is submitted rather than after it has been scheduled.
ONE_SHOT_STARTS
The start kinds that do NOT keep an instance alive. once fires when armed and manual only on an explicit workflow.run; when either finishes there is nothing left waiting, so a job-shaped instance may exit.
RAW_FIELDS
Fields never rendered as templates before execution (expressions the step evaluates itself, and nested definitions).
TOP
The top-level fields a workflow document may carry. The parser and the JSON Schema both read this list, so an editor can never flag a field the loader accepts (or complete one it refuses) — they drifted apart once.

Functions§

canonical
Canonical JSON (sorted keys — serde_json’s Map is a BTreeMap here) for hashing.
duration_ms
A duration field: "30s", "5m", bare seconds, or ms as {"ms": n}.
duration_ms_opt
Some(ms) for a duration field, None when absent/invalid.
implemented_kinds
The kinds implemented by this build’s engine.
is_long_lived_start
Whether a start kind keeps the instance alive.
is_raw_field
kind_info
parse_workflow
Parse + validate a dialect-3 document. Errors name every problem.
pure_data_kind
Step kinds that are PURE data transforms: no external effect, no durable write of their own, fully deterministic over the run’s data. The checkpoint-before-effect rule exists to stop a crash from losing or repeating an effect, and these steps have none — a crash simply replays them from the last checkpoint and reaches the same values. So the scheduler skips the checkpoint for them, and an inline chain batches into its tick’s single checkpoint instead of paying a serialize-and-write per step, which measures at roughly 40% of such a chain’s cycles.
start_kinds
Every start kind, derived from KINDS so it cannot drift from the table the parser uses.
valid_id
[a-zA-Z_][a-zA-Z0-9_-]{0,63}.
workflow_schema
The workflow JSON Schema, as --workflow-schema prints it. Generated from KINDS rather than written by hand, so the schema and the validator can never disagree about which fields a kind accepts.