ADL 37 · Part V — Execution, presentation, and integration

0.5.1 baseline + 0.6 edition note

Workflows

ADL 0.6.0 reference · Review draft 1 · November 14, 2026.

Contents · Source map · Evidence

The 0.6 edition note

This chapter retains the detailed language contract and its source-specific observations. Its chapter number and numbered sections remain stable. The 0.6 additions do not by themselves change this subject’s defaults or supply fresh execution evidence for it.

Reverification should cover durable workflow state, system identity, retries, and policy-covered calls. Use the original examples and evidence links below to recover the earlier test context. The new edition’s source map records this chapter as inherited detail; the current draft does not claim those historical tests were rerun.

Retained reference detail

The numbered sections below are carried from 37-workflows.md. Their original baseline and evidence remain attached to the source. Statements about “current” or “checked” behavior in this retained text refer to those original observations unless the edition note explicitly updates them. This is a consolidated draft, not a claim of complete re-verification.

37.1 Scope and edition boundary

A workflow connects actions, decisions, and waits into a named process. This chapter owns that control flow, the data passed between steps, persisted instances, and failure reporting. Resource operations remain owned by ADL 26, transitions by ADL 22, and notification delivery by ADL 35.

The baseline chapter (v0.5.0, retired) and delta §13 supply the edition context. Current execution requires several corrections to inherited examples: trigger.event selects the event; step structure determines step kind; and explicit then links advance the process. Declaration order alone does not execute a list of actions from beginning to end.

A workflow is not a transaction. The checked order-processing failure case commits its first receipt, fails a later required-field validation, records a failed instance, and still returns success for the triggering ticket creation.

When the triggering write is inside a database transaction, ordinary workflow subscriptions are deferred until the outer commit (#1370, #1415). Rollback discards the held events, so those workflows do not start. Commit releases the connection/lock and then delivers events synchronously on the writing thread: workflows see committed data and still run before the request returns. A released savepoint alone does not deliver events. This does not make all of a workflow’s later steps one transaction.

Since ADL 0.102.91 (#1373), features.transactions: true is the default and wraps each generated CRUD write phase. Thus ordinary workflows triggered by those writes start after commit, see the complete committed record, and do not start if a later audit, history, version or derived write forces rollback. They still execute synchronously before the triggering response returns. Rules and the already-constructed response must not rely on later workflow writes. Each workflow step remains a separate action, not part of one workflow-wide transaction.

Explicit features.transactions: false preserves the earlier operation-specific boundaries: an existing narrower transaction still defers events, while a write without one publishes inline. Before-hooks’ explicit calls and internal derived subscribers have separate timing; see ADL 29 §29.7.

37.2 Declaring a process

Place a name-to-definition mapping at domain.workflows. A definition has description, enabled (default true), a trigger, and an array of steps. The first step is the entry point. The following fragment is taken from the complete sequential.yaml example:

workflows:
  process:
    trigger:
      resource: Ticket
      event: create
    steps:
      - name: record
        action: create
        resource: Receipt
        input:
          id: $trigger.record.id
          title: $trigger.record.title
        then: finish
      - name: finish
        action: noop

The two resources are ordinary declarations in the linked complete file. They need not grant the external caller permission to perform every internal step; §37.5 describes the engine’s separate execution identity.

Trigger memberMeaning in the current engine
resourceResource whose event starts the process
event: create, update, deleteCRUD event subscription
event: historyHistory event name supplied through transition or field
event: transitionHistory topic named by transition
conditionAEL prefilter; false or evaluation failure prevents an instance

The last two forms depend on the history event actually published. A transition name is not automatically a matching history event name. A trigger declaring fieldChange is parsed but has no branch in current trigger registration. The legacy trigger.on: [create] example is admitted without producing the required event selector, so no instance starts.

Instance trigger data contains a record and event kind. History subscriptions use the captured payload; CRUD subscriptions use their published record shape. Actor identity is copied only if the event contains an actorId. A workflow should not assume that every trigger carries the complete requesting principal.

37.3 Step grammar and explicit flow

The native parser recognizes step kinds by structure, in this precedence: wait object, decide array, group object, forEach object, otherwise action. A type label does not override that choice.

Step kindDeclaration and execution
Actionaction, resource, optional target, transition, and input
Waitwait: {resource, event, ...}, optional condition, timeout, and alternative destination
Decidedecide: [{condition, then}, {default: true, then}]
Groupgroup: {all, steps: [...]} with inline step definitions
For-eachforEach: {collection, as, step: {...}}

A create step may name a resource of another domain as its resource, written domain.Resource or adl.<suite>.<domain>.<Resource>. It is allowed only where that resource’s allowWriteFrom names this workflow’s domain, or holds "*" and both domains share a suite (ADL 36 §36.5.2). Without the grant the step fails with WRITE_AUTHORITY_DENIED and the instance takes its failure path. The other step actions stay in the workflow’s own domain.

name identifies a step. then names a top-level destination or end. An empty then also completes the instance. The missing-then fixture therefore executes only its first action, although another action is declared immediately after it. A nonexistent destination fails at execution. The parser does not establish a complete graph-validation guarantee for missing names, duplicate names, recursion, or termination.

Action steps support create, update, delete, transition, notify, and noop. Create uses the named resource. Update/delete/transition resolve target as the record ID. Transition additionally requires transition. The engine constructs these resource actions; the action value is not an arbitrary fully qualified bus identifier.

Decide tests nondefault branches in order and selects the first true condition. It remembers a default while checking conditions; evaluation failures count as nonmatches. With no matching branch and no default, the instance fails with a recorded explanation. A selected branch whose then is empty completes.

37.4 Data flow and expression boundaries

NameAvailable value
$triggerPersisted trigger data, including $trigger.record
$steps.<name>.resultA completed action’s returned data
$steps.<waitName>.event.recordRecord from a matching wait event
$workflow.id, $workflow.startedAtCurrent instance identity and start time
$eventSupplied while evaluating the wait condition; not a persistent global record
$itemCurrent for-each item

Input mappings are converted to strings at parse time. The workflow host passes simple strings through, parses JSON-looking scalar/array/object values, and uses AEL when a string contains $, (, ==, +, or -. Failed evaluation falls back to the original expression text. Thus a missing reference, a failed expression, and an intentionally literal string need not produce the same value. The inherited blanket claim that an unexecuted step always reads empty is too broad for this host.

The complete examples compare an ordinary sequence, a failed later action, missing continuation, unmatched decision, and two for-each variants. The current loop binds $item even when a different as name is parsed. The for-each.yaml probe uses $entry and fails its required-field write; for-each-working.yaml uses $item and creates both receipts.

For-each executes its inline step through the action helper, not the general step dispatcher. It does not implement arbitrary nested waits or decisions as an ordinary recursive process. Per-iteration action results are not accumulated under the inline step’s name. A nonarray collection or absent inline step can fall through to completion without performing iterations.

37.5 Execution order, group branches, and authority

The initial process executes synchronously from its bus callback until it finishes, fails, or waits. Persistence does not imply that every step is queued on a worker. Each action response is stored in the instance before advancing.

37.5.1 group, formerly parallel

Ruling R12 (kalos#449). The step kind is named group. parallel is refused by the parser, with an error naming group and the workflow it occurred in.

The keyword was parallel and the branches were never parallel: they ran, and still run, sequentially in declaration order. An author who reached for it to overlap slow steps got none of the benefit and no diagnostic — the document parsed, the workflow ran, and only a stopwatch would have shown the difference.

parallel is rejected rather than accepted as an alias, and rejected rather than ignored. Ignoring it is the dangerous option: an unrecognized step key falls through to the action branch, so a parallel step would parse as an action step with no action and do nothing at all. The body is unchanged — all and steps keep their meanings — so migration is renaming one key.

Concurrency is not withdrawn as an idea, only as a claim. Implementing it needs decisions this ruling does not make: what happens when one branch fails, how side effects order, how it interacts with a transaction. Those belong to a new keyword that means them, not to one that has promised them since v0.3.

37.5.2 Execution and authority

group branches run sequentially in declaration order. With all: true (the default), the engine attempts each inline branch. With all: false, it stops after the first branch that returns without a waiting/failed/cancelled status. A first branch that fails stops the process; this is not a race that tries another branch after failure. The checked examples distinguish two committed receipts from one.

Inline branches share the same instance and top-level step lookup. Their then links can advance that shared process, and an inline wait cannot be assumed to restore like a top-level wait. Use the examples for the evidenced action-branch case; a group key alone supplies neither isolation nor independent branch continuations.

Resource actions run with transport workflow, username workflow:<workflowName>, and the admin role. User ID is a trigger actor ID when present, otherwise system. The engine does not reapply the external caller’s roles as a limit on each step. Resource validation and other handler checks still apply. Workflow authority and actor attribution are distinct.

A notify step publishes a payload containing workflow, instance, step, and resolved data. With resource, the legacy topic is adl.<domain>.<resource>.history.<stepName>; a notification can subscribe to that history-shaped event name. Without a resource, it uses adl.<domain>.workflow.<stepName>. This publishes an event; it does not itself write a history row or certify delivery. The checked notify case reaches a notification log through the production subscriber.

37.6 Waiting, timeout, and restoration

A wait stores status: waiting and its current step, then subscribes for a matching event. wait.resource and wait.event select the source; transition and field-change waits additionally use their corresponding names. The wait’s filter mapping compares event fields against values resolved in the instance context. Without a sufficiently specific filter, an event from another record can satisfy the wait.

On a match, the engine saves the event under the wait step’s name. A true or absent condition follows then; false follows else, or completes if no alternative exists. The later action reads the saved event through $steps.

A wait may declare:

# Step fragment from waiting.yaml.
wait:
  resource: Receipt
  event: create
  filter:
    id: $trigger.record.id
timeout:
  duration: 1h
then: finish

The duration arms timeoutAt. A timeout without timeout.then marks the instance timed_out; one with a destination resumes at that top-level step. Invalid or nonpositive durations leave no deadline. The production registration starts a 60-second timeout sweeper when a top-level wait declares a usable timeout. The examples separately verify deadline calculation, persisted arming, and an explicit sweep after moving a disposable deadline into the past. A second sweep does not repeat the action.

Top-level workflow timeout configuration is parsed but is not a substitute for this wait-step mechanism. Action steps have no general execution deadline. The presence of timeout keys in the model does not prove all such keys run.

On reconstruction, restore_waiting_instances() reloads waiting rows and finds their named top-level wait in the current definition. The example stops the original engine, reconstructs one from the retained model/source, ignores an unrelated receipt, then resumes on the matching receipt. This verifies engine restoration over retained rows, not a killed-process or failed-disk experiment. Changed/missing definitions, nested waits, and interrupted running instances need separate recovery treatment; they are not covered by a blanket durability promise.

37.7 Failure, management API, and source recovery

A failed step marks the instance failed and records an error. Earlier effects remain. The error handler can attempt the declared onError action; failure of that handler is swallowed after the original failure is recorded. The raw onError.notification field is not a delivery implementation. There is no automatic action retry and no transaction around the steps: what an earlier step wrote is undone only where that step declares how (§37.7.1).

37.7.1 Step compensation

An action step can declare compensate:, the action that undoes it. When a later step fails, the engine runs the compensations of the steps that succeeded, newest first, and then runs onError. It is cleanup, not a rollback: each undo is an ordinary action through the same dispatch path, under the workflow’s authority, and its own effects (events, audit rows, rules) happen.

steps:
  - name: holdBudget
    action: create
    resource: BudgetHold
    input: {orderId: $trigger.record.id}
    compensate:
      action: delete
      resource: BudgetHold
      target: $steps.holdBudget.result.id
    then: sendWire
  - name: sendWire
    action: create
    resource: Payment
    compensate: {action: none, reason: "a wire cannot be recalled"}
    then: orderLine
  - name: orderLine
    action: create
    resource: OrderLine
KeyMeaning
actioncreate, update, delete, transition, notify, noop, or none
resourceResource the undo acts on; required for the four resource actions
targetRow id; required for update, delete, transition. May read $steps.<name>.result
transitionTransition name; required for transition
inputData sent with the undo
reasonWhy a step has no undo; read only with none

compensate: none (scalar or action: none) says the step cannot be undone. It is recorded, not run. A step with no compensate: is skipped silently.

The parser refuses compensate: on a step that is not an action step, on an unnamed step, on the inner step of a forEach, with an unknown key or action, or missing the keys its action needs. A step inside a group can carry one.

The instance keeps its failed status and the failing step’s error. The detail route adds two fields:

FieldValues
compensationStatusnone (nothing declared), compensated (every undo ran), partial (a step was declared irreversible), failed (an undo failed)
compensationsOne entry per step, in the order run: step, action, resource, target, status (compensated, irreversible, failed), and error or reason

A failed undo is recorded and the walk continues to the earlier steps; nothing retries it. Compensation runs once per instance, and only on a step failure. A timeout or a cancellation does not run it. Both fields are absent on an instance that did not fail.

Under /api/v1/{domain}/workflows, management routes are:

MethodSuffixResult
GETemptyWorkflow definitions
GET/{name}/instancesBounded instance list; optional status filter
GET/{name}/instances/{id}Detail including trigger and step data
POST/{name}/instances/{id}/cancelCancels a running or waiting instance

They require admin or administrator. Missing IDs produce VALIDATION_ERROR; unknown detail IDs produce NOT_FOUND; cancellation of an absent or terminal instance produces NOT_CANCELLABLE. Detail and cancellation lookup use the instance ID without verifying the path’s workflow name. List totalCount is the returned slice. The implementation also records completed, failed, cancelled, and timed_out states.

Delta §13’s canonical action/event forms coexist with legacy identifiers when the compatibility flag is enabled. The canonical-only fixture starts a workflow from its canonical ticket event, but the step’s internal resource dispatch still uses a legacy action. It records a failed instance with ACTION_NOT_FOUND and creates no receipt. Trigger delivery alone does not repair that dispatch path.

The exporter refuses a model containing workflows as a lossy unsupported projection. Source-backed registry restoration succeeds; forced source-free restoration returns no model in the checked example. Keep the authored/resolved source with the recovery evidence. The verification record separates native execution, modeller observations, fixed-time helpers, and source-inspected limits.