Open Workflow DSL in Lemline
Open Workflow is a declarative language for composing named tasks in YAML or JSON. A workflow defines metadata, data contracts, and the tasks that act on the data. Lemline implements the subset described in Supported Features.
Definitions and execution
A definition has a stable identity under document. Each execution carries its own input and state. A workflow instance runs the tasks under do in order unless a task provides a different flow directive.
document:
dsl: '1.0.3'
namespace: examples
name: validate-and-route-order
version: '1.0.0'
input:
schema:
format: json
document:
type: object
required: [orderId, total]
properties:
orderId:
type: string
total:
type: number
minimum: 0
do:
- routeOrder:
switch:
- largeOrder:
when: ${ .total >= 1000 }
then: requestReview
- automatic:
then: acceptOrder
- requestReview:
set:
status: needs-review
then: exit
- acceptOrder:
set:
status: accepted
output:
as: '${ { orderId: $workflow.input.orderId, status: .status } }'
Data and expressions
A task receives input as .. Use ${ ... } to evaluate a jq expression. The original input is available as $workflow.input. Tasks can share values through $context by exporting them with export.as.
document:
dsl: '1.0.3'
namespace: examples
name: transform-workflow-data
version: '1.0.0'
input:
from: '${ { customer: .user, items: .payload.items } }'
do:
- summarize:
set:
customerId: ${ .customer.id }
itemCount: ${ .items | length }
output:
as: '${ { customerId, itemCount } }'
Resource declarations
The use section defines shared resources. For example, a named retry policy can be referenced from any compatible catch block.
document:
dsl: '1.0.3'
namespace: examples
name: retry-and-fallback
version: '1.0.0'
use:
retries:
transient:
delay: PT2S
backoff:
exponential: {}
limit:
attempt:
count: 3
do:
- fetchInventory:
try:
- requestInventory:
call: http
with:
method: get
endpoint: http://127.0.0.1:8787/stock
query:
fail: '503'
failTimes: ${ .failures // 0 | tostring }
key: ${ $workflow.id }
catch:
errors:
with:
type: https://open-workflow-specification.org/spec/1.0.0/errors/communication
status: 503
retry: transient
do:
- useCachedInventory:
set:
inventory: []
stale: true
See How to Define a Workflow for authoring steps.
Run the Examples
Every example on this page is a complete workflow. Complete the SQLite setup, save each example under the file name used below, and run the commands from the setup directory. With the JAR, substitute java -jar lemline.jar for bin/lemline.
Start the tutorial shop from the root of the Lemline source checkout:
docker compose -f examples/tutorial-services/compose.yaml up -d
Keep the setup worker running and use a second terminal in the setup directory.
bin/lemline definition post -f validate-and-route-order.yaml
bin/lemline instance start examples validate-and-route-order --input '{"orderId":"ORD-301","total":250}'
bin/lemline definition post -f transform-workflow-data.yaml
bin/lemline instance start examples transform-workflow-data --input '{"user":{"id":"C-100"},"payload":{"items":[{"id":"SKU-1"}]}}'
bin/lemline definition post -f retry-and-fallback.yaml
bin/lemline instance start examples retry-and-fallback --input '{"failures":5}'
Example | Expected result |
|---|
validate-and-route-order
| {"orderId":"ORD-301","status":"accepted"}
|
transform-workflow-data
| {"customerId":"C-100","itemCount":1}
|
retry-and-fallback
| {"inventory":[],"stale":true} after four failed calls; allow about a minute
|
Stop the shop when you are done:
docker compose -f examples/tutorial-services/compose.yaml down
25 November 2026