Let a workflow definition declare the instance variables its runs start with, so a run does not depend on whichever code starts it

A run started with exactly the variables its caller passed to WorkflowEngine::start(), so a workflow that needed an input depended on whichever code started it. Two of the shipped starters pass none at all (OrchestraUiController::start() and ECA's StartProcess), and a workflow exported as configuration arrived with nothing to run on.

A definition may now declare the instance variables its runs start with.

# orchestra.orchestra_workflow.shop_order.yml
variables:
  - name: channel
    value: web
  - name: deposit_due
    value: 1
  • Seeded at start, at instance scope, before the first step.
  • A caller wins on a name they both set, including a value passed explicitly as NULL: the caller knows the facts of the particular run, the definition knows only its own defaults. A subprocess child is a caller like any other, so its parent's mapped input wins and the child's own declarations fill in the rest.
  • Read off the pinned version, and part of the executable shape, so editing the declarations cuts a new version and a running instance keeps what it started with.
  • A declared name starts with a letter, which keeps it out of the engine's reserved __ namespace. A pre-seeded timeout anchor would start a run with a deadline the engine never set, invisible in the variable view and in the audit trail. LocalOrchestraClient::startProcess() already refused those from a remote caller; a Regex constraint refuses them in configuration, and the entity drops them on the storage path an import bypasses that constraint on.

Edited at Workflows > (a workflow) > Variables, a name and a value per row, alongside the existing Retention, Execution and Reading tabs. The form writes text, which is what a routing condition compares against; a non-scalar value carried in by imported configuration is shown and left alone rather than flattened.

Also on this branch

Sixteen Choice constraints across four schema files listed their choices directly under the constraint, the shape symfony/validator 7.4 deprecated in favour of a choices key. Nothing had noticed because nothing validated configuration until the test here did. Spelling only, and each file was diffed structurally to prove the choices are unchanged.

Testing

InitialVariablesTest covers the seeding, the precedence rule (including the explicit NULL), the started event's payload, the subprocess child, the reserved namespace on the storage path, the constraint on the stored name, and the new version an edit cuts. Nine tests, 91 assertions, green on SQLite and on MySQL; six of the nine fail against the unfixed engine.

WorkflowVariablesUiTest drives the form: declaring a pair, a refused name, a duplicate, a value with no name, and clearing a name to stop declaring it. That one is left to CI to run.

Documentation and the French translation are in the same commit as the code.

Edited by Frank Mably

Merge request reports

Loading
Loading