Zigflow
website·Indexed 31 days ago
https://zigflow.devA declarative workflow orchestration layer for Temporal that allows users to define workflows using YAML or JSON.
What's inside Zigflow
- Zigflow is a declarative workflow orchestration layer for Temporal. It allows developers to define workflows using YAML or JSON, which are then compiled into production-grade Temporal workflows with built-in reliability, retries, and state management. It is a compilation layer and DSL, not a replacement for Temporal or a standalone workflow engine.
Manage data flow using $output and $context
Zigflow uses two separate channels for data movement. Confusing them is a common authoring error:
$output: Holds the result of the most recent task only. It is overwritten by every task and is the value the workflow returns. Use a task'soutput.asto shape this value.$context: Shared data that persists across tasks. Use a task'sexport.asto write to it and reference$contextto read it later.
Order of Operations per Task:
- Task produces a raw result (referenced as
.in expressions). output.asis evaluated against the raw result and stored as$output.export.asis evaluated against the raw result and replaces$context.
Key Rules:
exportreplaces$contextentirely. To accumulate data, merge explicitly:export: { as: '${ $context + { key: . } }' }.- To pass a value to a task that is not the immediate next one, use
exportinto$context. - The workflow returns the output of its final task; use
output.ason that task to shape the final return value.
Ensure determinism in workflows
Non-deterministic functions—includinguuid,timestamp,timestamp_iso8601, and jq'snow—must only be used inside asettask. This ensures they are evaluated within a Temporal side effect so the result survives replay. Using these functions in acallbody, argument, or any other task position will be rejected during validation. Generate the value in asettask first, then reference it in later tasks.Authoring rules for Zigflow workflows
When authoring Zigflow workflows, the following constraints are mandatory:
- Top-level Keys: A workflow must have exactly two required top-level keys:
documentanddo. - Step Structure: The
dokey must be an array of single-key maps:do: [ { stepName: { task } } ]. - Expressions: Runtime expressions use jq (gojq) syntax wrapped in
${ ... }. Strings without this wrapper are treated as literals. - Durations: Must be objects with plural integer keys (e.g.,
{ minutes: 1, seconds: 30 }). ISO 8601 strings (likePT1M) are not supported. - Versioning:
document.dslanddocument.versionmust be semantic versions (e.g.,1.0.0). - Naming:
document.taskQueueanddocument.workflowTypemust be RFC 1123 DNS labels (letters, digits, and hyphens; must start/end with a letter or digit; no dots, underscores, or spaces). - Strict Schema: The
documentobject is closed; unknown fields are rejected.
- Top-level Keys: A workflow must have exactly two required top-level keys:
Configure workflow document structure
The workflow definition consists of top-level properties and a specific
documentmetadata object.Top-level Properties:
document(Required): Workflow metadata.do(Required): Array of single-key step maps.input(Optional): Input configuration and schema.output(Optional): Output configuration and shaping.schedule(Optional): Cron string oreveryduration. Requiresdocument.metadata.scheduleWorkflowNameif used.timeout(Deprecated): Usemetadata.activityOptionsinstead.
documentFields:dsl(Required): Semantic version of the DSL (e.g.,1.0.0).taskQueue(Required): Temporal task queue name (RFC 1123 DNS label).workflowType(Required): Temporal workflow type name (RFC 1123 DNS label).version(Required): Workflow semantic version (e.g.,0.0.1).title(Optional): Human-readable title.summary(Optional): Markdown summary.tags(Optional): Key/value string map.metadata(Optional): Open object for additional config likeactivityOptions.
Configure durations in Zigflow
Durations must be defined as an object with one or more plural integer keys. ISO 8601 strings (e.g.,
PT1M) and singular keys (e.g.,minute) are not supported.Supported Keys:
dayshoursminutessecondsmilliseconds
Activity timeouts and retry policies are configured under
metadata.activityOptions.# Correct duration format metadata: activityOptions: timeout: { minutes: 1, seconds: 30 }Use runtime variables in expressions
Zigflow provides six specific workflow-state variables available within
${ ... }expressions. Referencing any other variable will cause a compilation failure:$context: Data exported by earlier tasks via theexportproperty.$data: Internal workflow and execution state (metadata).$env: Environment variables. Only variables starting with the configured prefix (defaultZIGGY_) are exposed, with the prefix stripped (e.g.,ZIGGY_API_URLbecomes$env.API_URL). The prefix is configurable via--env-prefix.$input: The original input provided by the caller (immutable).$output: The current output value.$propagated: Read-only values received via Temporal context propagation (from thezigflow.propagatedheader).
Define a minimal valid Zigflow workflow
A minimal valid workflow requires thedocumentmetadata and adolist of tasks. Thedocumentobject must includedsl,taskQueue,workflowType, andversion.document: dsl: 1.0.0 taskQueue: zigflow workflowType: hello-world version: 0.0.1 title: Hello World summary: Hello world with Zigflow do: - hello: output: as: data: ${ . } set: message: Hello from ZiggyIntegrate Zigflow with AI via MCP Server
Zigflow provides a read-only Model Context Protocol (MCP) server at
https://mcp.zigflow.devfor AI assistants. Available tools include:get_schema: Retrieves the JSON or YAML schema. Usedefto get a specific definition (e.g.,{ "def": "taskList" }).list_examples: Lists bundled example workflows.get_example: Retrieves a specific example workflow by name.validate_workflow: Validates a YAML string and returns structured errors and warnings.
Perform HTTP calls in Zigflow
To make an HTTP request, use thecalltask with the valuehttp. You must specify the method and the endpoint within thewithblock. Theoutputformat defaults tocontentbut can be set toraworresponse.do: - getUser: call: http with: method: get endpoint: https://jsonplaceholder.typicode.com/users/3Implement tasks using Zigflow task types
Zigflow supports exactly 11 task types. Each step in the
dolist must contain exactly one of these keys:Task Key Purpose callInvoke an activity, gRPC service, or HTTP endpoint. doRun a nested sequence of sub-tasks. forIterate over a collection. forkRun multiple branches concurrently. listenWait for and react to an event (e.g., signal). raiseRaise a workflow error. runRun a script, shell command, container, or child workflow. setSet data on the workflow state. switchBranch based on data conditions. tryRun sub-tasks with a catchblock.waitPause for a duration or until a timestamp. Common Task Properties: Every task can optionally include:
if(condition),input,output,export,then, andmetadata. Note: There is no task-leveltimeoutfield.Control workflow flow with the then directive
A task's
thenproperty determines the next step in the workflow. Valid values include:continue: The default behavior.exit: Exits the workflow.end: Ends the workflow.[taskName]: Jumps to another task in the same scope.
Tokens such as
goto,next,stop,fail, orreturnare invalid.