Skip to content
ModuleM4 — The process engines
After this session you canTrace a request through the workflow’s state machine, including a sub-workflow and an external step, and explain what the engine stores at each move.
Time68 min with a facilitator · about 68 min on your own
Before you startM4-S2 (reaction runs and commands) and M2-S3 (definitions and records). Larkspur Lab, Rami Aziz signed in; private windows for Sara Qasim and Omar Haddad; the workbench API window with its address and token set.
Go deeperEngine: Workflow and owner resolution · Workflow model and API reference · Requests and services

◆ Orientation (1 min) — Where a request really is

Section titled “◆ Orientation (1 min) — Where a request really is”

A Purchase Request above 25,000 goes through a technical review before Sara Qasim approves it. You designed routes like this in ACE M3-S3 with a sub-workflow and a condition. The designer shows the route; the engine keeps something else: a stack of open workflow instances inside the record, and a history beside it. In this session you learn to read that stack, predict how each action changes it, and explain the refusals a person sees when the engine says no. M4-S4 then uses the same stack to work out who owns each step and when it is late.

▤ Concept (11 min) — Definitions, the stack and the move

Section titled “▤ Concept (11 min) — Definitions, the stack and the move”
ConcernServiceWhat it keeps
Step moves, owner resolution, sub-workflowsdata serviceThe entry’s workflow state, inside the entry
The HTTP routes people and clients call to actworkflow serviceNothing of its own for a move; it calls the data service
Time limits and workflow-status viewsworkflow serviceTime-limit records (M4-S4)
Working-time arithmeticclock serviceNothing: it computes a due date and forgets

When a person clicks an action, the workflow service receives the call and passes it to the data service directly over internal HTTP, then returns the data service’s answer. There is no bus hop and no reply token on that path: on the 1.10 line the old bridge that sent a command over the bus and waited for an answer is gone. A reaction that moves a workflow (M4-S2) still sends a bus command and parks its saga until the completion event comes back. Both paths end in the same write logic in the data service, so a rule you change there changes both.

The definition of a workflow lives on the entity: an ordered list of steps, each with a type, its actions and their targets, its owner settings and its time limit. The step types matter for prediction:

TypeWhat the engine does with it
EntryThe first step; its owner is always the entry’s creator
IntermediateAn ordinary step
ExitThe last step; it may have no owner; a person cannot move onto it by hand
Ad hocA step inserted at run time, where the step allows it
Sub-workflow stepStarts another workflow of the same entity as a child
External stepWaits for another system to return; a person cannot execute its actions

The state lives inside the entry itself, in fields whose names start with _meta, which the form never shows:

  • _metaCurrentSteps is the stack: one item per open workflow instance, main or sub. Each item holds workflowId, currentStep, an instanceId, the owner, the full eligible set originalOwner, active, and the links between parent and child (isInSubWorkflow, subWorkflowInstanceId, parentWorkflowInstanceId, parentStepId). Exactly one item is active: the one a person acts on now.
  • _metaWorkflowHistory holds one history per instance, each with its stepsHistory: who acted, on which step, when it was received and how long it took.

Because the state is part of the entry, it travels with every read of the entry, it is protected by the same write guards, and a reaction can address a step by its position in the stack.

flowchart TD
  A["A person runs an action"] --> B["Workflow service: HTTP call to the data service"]
  B --> C["Checks: owner, comment, re-verification, external step"]
  C --> D["Next step: thresholds, conditional targets, repeat, default target"]
  D --> E{"What kind of move?"}
  E -->|"into a sub-workflow"| F["Park the parent, push a child instance"]
  E -->|"out of a sub-workflow"| G["Close the child, resume the parent at its merge step"]
  E -->|"normal"| H["Record history, set the next step and owner"]
  F --> I["Write only if the state is unchanged since the checks"]
  G --> I
  H --> I
  I --> J["Publish: action executed, step reached, step exited"]

What to notice: the events are published only after the write succeeds, and the write succeeds only if nobody changed the workflow state in between.

Choosing the next step. The engine first applies a group decision’s threshold (the action’s target may become a failure target), then the action’s conditional targets in order, taking the first whose expression is true (an expression that fails to evaluate is skipped, not raised), then the default target. A step whose owners must all act repeats until each has acted. The owner of the next step is resolved last; that is M4-S4.

The three kinds of move.

  • Entering a sub-workflow. The parent instance stays on the sub-workflow step but becomes inactive (active: false, isInSubWorkflow: true), and a new active instance is pushed on top of the stack. No history is written for the start itself.
  • Leaving it. When the child reaches its exit, the engine records it, closes the child and makes the parent active again at its merge step. If that merge step is itself an exit and the parent is a child too, the completion cascades upwards.
  • A normal move. One history row (one per owner on a parallel step), then the new current step and owner.

Events, and their order. Every move publishes action executed, then step reached, then step exited, the last only if the step actually changed. Reactions, time limits and the request lists you met in ACP all listen to these.

Not every move comes from an action button. Every history row records a change mode, and reading it is the fastest way to know which kind of move happened:

Change modeWhat caused itWhat the engine does
NormalA person or a reaction ran a step’s actionThe move described above
MoveToStepAn administrator or a reaction moved the request forward to a chosen stepOnly steps of workflows already open in the stack are valid targets; a person may never move onto the exit step
ReturnToStepA return to a step already passedA backward move by the system is recorded as a return, so the history shows the true direction
ResetWorkflowA resetThe main workflow goes back to its first step, keeping the same instance id; a reset sub-workflow resumes its parent
EndWorkflowAn endEvery open sub-workflow is closed and the main workflow moves to its exit
AdHocA step inserted at run timeAllowed only where the step permits ad-hoc steps; the inserted step’s definition is kept in the entry

Two details explain surprises. Moving or returning to another workflow’s step closes every sub-workflow that sat above it in the stack, so a reset of the main workflow silently abandons an open technical review. And a reassigned owner is forgotten at the next move unless it was a permanent change, because the engine clears that flag on every transition; M4-S4 shows how a permanent change wins the next owner resolution.

  • Two people act at once. Since 1.10 every workflow write is conditional: the engine snapshots the workflow state before computing the move and writes only if it is unchanged. The second caller gets 409 with the code UPDATE_CONFLICT, and nothing is published for it. Before 1.10, both calls succeeded and every reaction ran twice.
  • A manual action on an external step. The engine refuses it outright. Only a reaction, or the other system’s return call with its token, can complete an external step; the return answers success, alreadyProcessed, invalid or executionFailed, and success means accepted, not finished.
  • An action that needs re-verification. Since 1.10 an action can require its executor to verify their identity again just before it runs. The check sits in the data service, so it applies to every client; reactions, external-step returns and administrative modifications are exempt. The refusal’s code, WORKFLOW_ACTION_STEP_UP_REQUIRED, is the contract; do not rely on its HTTP status.

A service is an entity published to the catalog with a workflow; a request is one entry of it. The portal’s Inbox, My requests and Watching lists do not query workflow state across every entity. They read request rows, a mirror the data service rebuilds from the entry after each change, with the visible step, the owner and the watchers. That mirror explains two things you may see: a list can lag a move by a moment, and a repair migration in 1.10 rebuilt rows whose visible step was wrong. If a request shows the wrong step in the Inbox but the right one on its form, the form (the entry) is the truth.

▶ Guided demo (10 min) — The stack of a request

Section titled “▶ Guided demo (10 min) — The stack of a request”

Starting state. Larkspur Lab as seeded. Purchase request PR-2031 (Spare impellers for P-104, value 8,400) waits at Procurement Review, owned by Sara Qasim.

  1. Open PR-2031 in the portal. The form shows the step Procurement Review and Sara as owner.

  2. In the API window, read the entry’s workflow state:

    Terminal window
    curl -s "$BASE/api/v2/entities/purchase_requests/entries/<PR-2031 id>" \
    -H "x-app-token: $TOKEN" | jq '.result.entry.value._metaCurrentSteps'

    One item: currentStep is the Procurement Review step id, active is true, owner is Sara.

  3. Read the history: jq '.result.entry.value._metaWorkflowHistory[0].stepsHistory | map({step: .stepId, by: .executedBy, at: .executedAt})' on the same answer. One row: the submission at Draft.

  4. In the designer, open Data Entities › Purchase Requests › Workflows and match the step ids to their names.

  5. As Sara, approve PR-2031 at Procurement Review. The value is below 25,000, so it goes to Approval.

  6. Read the stack again. Still one item, now at Approval; the history has a second row with Sara and the action she ran.

Screenshot pending The API answer for PR-2031 showing one item in _metaCurrentSteps with currentStep, active true and the owner What to notice: the stack has one item because no sub-workflow is open; the step’s name is not stored, only its id.

PracticeChoose one answer.

A request’s _metaCurrentSteps has two items. The first has active: false and isInSubWorkflow: true; the second has active: true. Where is the request?

  1. Explanation for A

    ✗ Incorrect

    Not this one: an inactive item with isInSubWorkflow is a parked parent, not a finished workflow. See what one action does.

  2. Explanation for B

    ✓ Correct

    Correct: entering a sub-workflow parks the parent and pushes an active child instance on top of the stack. See what one action does.

  3. Explanation for C

    ✗ Incorrect

    Not this one: exactly one item is active; the other is waiting for the child to finish. See definition and state.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A planner moves a work order and the step does not change, because the step repeats until every owner has acted. Which events are published?

  1. Explanation for A

    ✗ Incorrect

    Not this one: the exit event is published only when the step actually changes. See what one action does.

  2. Explanation for B

    ✓ Correct

    Correct: the order is always executed, reached, exited, and the last is skipped when the step stays the same. See what one action does.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the engine still publishes the step reached event for the repeated step. See what one action does.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

The Inbox shows a request at Procurement Review, but its form shows Approval. What is true?

  1. Explanation for A

    ✓ Correct

    Correct: the lists read request rows rebuilt from the entry, so when they disagree the entry wins. See services, requests and the lists.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the form shows the stored current step, not a prediction. See services, requests and the lists.

  3. Explanation for C

    ✗ Incorrect

    Not this one: this request has no sub-workflow open here; the two views read different stores. See services, requests and the lists.

Check your answer

The correct answer is A. Open the explanation under each option to see why.

⛏ Lab (33 min) — Predict and read a request through its technical review

Section titled “⛏ Lab (33 min) — Predict and read a request through its technical review”

Goal. Submit a purchase request above the threshold, and before every move write down what you expect in the stack, then read it and compare.

Before you start. The demo’s API window. Sara Qasim (Procurement Lead) and Omar Haddad (in the Maintenance Planners group, which owns Engineering Check) in private windows. A table in your notes with four columns: move, predicted stack, actual stack, events.

  1. As yourself, open Services, select Apply on Purchase Request, then New Request. Fill Item “Replacement compressor head, C-220”, Supplier Halcyon Valves, Value 31,500, and submit. Note the request’s number and id.
  2. Predict the stack after submission, then read it with the demo’s command. Expect one active item at Procurement Review.
  3. Predict what Sara’s approval does at 31,500. Write it down: the conditional target sends the request to the Technical Review sub-workflow step; the parent is parked and a child pushed.
  4. As Sara, approve the request at Procurement Review.
  5. Read the stack. Two items: the parent with active: false, isInSubWorkflow: true and currentStep on the sub-workflow step; the child active at Engineering Check, with parentWorkflowInstanceId equal to the parent’s instanceId.

Screenshot pending The API answer showing two stack items, the parked parent and the active child of the Technical Review sub-workflow What to notice: the child’s parentWorkflowInstanceId equals the parent’s instanceId; that link is how the engine finds where to merge back. 6. Read the histories: jq '.result.entry.value._metaWorkflowHistory | map({wf: .workflowId, rows: (.stepsHistory | length)})'. The main history gained Sara’s row; the child’s history has no row yet, because entering a sub-workflow writes none. 7. In the logs window, search for the request’s trace: the data service logged the move once. 8. As Omar, open the Inbox. The request is there, at Engineering Check. 9. Predict what Omar’s Pass does: the child reaches its exit, the child closes, the parent resumes at its merge step Approval. 10. As Omar, run Pass. 11. Read the stack. One item again, the parent, active at Approval, isInSubWorkflow false. 12. Read the histories again. The child’s history has Omar’s row; the main history recorded the return at the merge step. 13. A conflict. Open the request as Sara in two browser tabs. In the first tab, run Approve. In the second tab, without reloading, run Reject. 14. The second tab shows a conflict message. Read the stack: the request is at Approved, and the history has one approval, not a rejection. 15. In Reaction Logs, the reaction Notify requester of decision ran once for this request, not twice. 16. An external step. Open PR-2027 (Annual bearing contract), which waits at Supplier Confirmation, an external step. As Sara, look at its actions. 17. Try to run Confirmed from the form, or with the API window’s execute-action call from the workbench. The engine refuses it. 18. Fill in your table’s last column for every move: the events in order.

Check.

  • Every move in your table has a prediction written before the read.
  • After step 5: two items, parent parked, child active, linked by instance id.
  • After step 11: one item, parent active at Approval.
  • The stale Reject was refused and nothing was published for it.
  • The manual action on the external step was refused.
  • The events column shows executed, reached, exited for every move that changed step.

Pass condition. Your table matches the stored stack at every read, and where a prediction was wrong you have written which rule you missed.

If something goes wrong

What you seeWhat to do
Sara’s approval goes straight to ApprovalThe value is not above 25,000, or the conditional target’s expression reads another field. Check the action’s conditional targets in Workflows.
Omar does not see the requestCheck that he is a member of Maintenance Planners and that the step’s owner is that group. M4-S4 explains owner resolution in detail.
The second tab’s Reject succeededYou reloaded the tab between the two actions; repeat with a fresh request.
The API answer has no _metaCurrentStepsYour token is not a system viewer’s. Use the workbench token, which has system View.
Model answer

After submission the stack has one active item at Procurement Review. Sara’s approval at 31,500 matched the conditional target, so the engine recorded her row in the main history, parked the parent on the Technical Review step (active: false, isInSubWorkflow: true) and pushed the child at Engineering Check, whose owner is inherited from the sub-workflow step’s owner. No history was written for the start. Omar’s Pass took the child to its exit: the engine recorded his row in the child’s history, closed the child and resumed the parent at the merge step Approval. Each move published action executed and step reached, then step exited because the step changed. The stale Reject failed the conditional write with UPDATE_CONFLICT, so it was not recorded and no reaction ran for it. The external step refused the manual action because only a reaction or the other system’s return may complete it.

◇ Worked scenario (2 min) — “The approval vanished”

Section titled “◇ Worked scenario (2 min) — “The approval vanished””

Sara reports that she approved PR-2050 yesterday, the screen said it worked, and today the request is back at Procurement Review. Decide at each step before you read on.

Step 1. What does the history say? You read _metaWorkflowHistory. Sara’s approval is there, at 16:02. A later row at 16:05 shows the change mode ReturnToStep, done by the system user. Someone or something moved the request back.

Step 2. Who returns a request? A person cannot move a request backwards with a forward move; the engine re-routes a backward system move as a return so the history records the true direction. So this was a reaction or an administrator. Reaction Logs for PR-2050 at 16:05 shows a run of Return incomplete requests, which moves a request back to Procurement Review when its Quote attachment is empty.

Step 3. Why did it match? The reaction fires On Entry Updated. Sara’s approval itself did not touch Quote, but the step’s own reaction Stamp approval date updated the entry at 16:05, and Return incomplete requests has no condition on the step: any update of a request with no quote sends it back, including one at Approval.

Step 4. The fix. You add the condition “current step is Approval or later is excluded” to the criteria, or better, move the rule to where it belongs: a mandatory Quote on the Procurement Review step, so an incomplete request can never be approved. The second is the designer’s tool for the job and leaves nothing to race.

The lesson: when a request moves “by itself”, the history’s change mode and actor tell you which engine moved it, and Reaction Logs tells you why.

✓ Practice (6 min) — Moves and refusals

Section titled “✓ Practice (6 min) — Moves and refusals”
PracticeChoose one answer.

A client application retries an Approve call after a timeout. The first call had in fact succeeded. What does the retry get on the 1.10 line?

  1. Explanation for A

    ✗ Incorrect

    Not this one: that was the behaviour before 1.10; now the write is conditional on the state the call validated. See refusals you can now explain.

  2. Explanation for B

    ✓ Correct

    Correct: the step moved, so the state the retry validated against no longer matches, and no events are published for it. See refusals you can now explain.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the engine has no queue of pending actions; a refused action is simply refused. See refusals you can now explain.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A step’s action has two conditional targets. The first expression throws an error for a request with no Value; the second is true. Where does the request go?

  1. Explanation for A

    ✗ Incorrect

    Not this one: errors in conditional targets are swallowed and the engine moves on to the next one. See what one action does.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the default applies only when no condition is true. See what one action does.

  3. Explanation for C

    ✓ Correct

    Correct: the engine walks the conditional targets in order, skips the one that errors and takes the first that evaluates true. See what one action does.

Check your answer

The correct answer is C. Open the explanation under each option to see why.

PracticeChoose one answer.

An outside supplier system completes an external step through its return call and receives success. Thirty seconds later the request is still at the external step. Is something wrong?

  1. Explanation for A

    ✓ Correct

    Correct: the return claims the action and queues it; the move itself follows, and its arrival is seen on the entry. See refusals you can now explain.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the outcome describes the claim of the action, not the finished transition. See refusals you can now explain.

  3. Explanation for C

    ✗ Incorrect

    Not this one: a person cannot execute an external step’s actions at all. See refusals you can now explain.

Check your answer

The correct answer is A. Open the explanation under each option to see why.

PracticeChoose one answer.

A reaction moves purchase requests to the next step. One of those steps requires re-verification of the executor. What happens when the reaction runs?

  1. Explanation for A

    ✗ Incorrect

    Not this one: re-verification is an end-user control, and reactions are exempt from it. See refusals you can now explain.

  2. Explanation for B

    ✓ Correct

    Correct: the check is skipped for automated actions, external-step returns and administrative modifications. See refusals you can now explain.

  3. Explanation for C

    ✗ Incorrect

    Not this one: nothing in the engine waits for a person to re-verify on behalf of a reaction. See refusals you can now explain.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticePut the items in the right order.

Put what happens when a person’s action takes a request into a sub-workflow in the order the engine does it.

  1. Explanation for A

    Belongs in position 5 of 5

    Last: events follow a successful write, so a refused write publishes nothing. See what one action does.

  2. Explanation for B

    Belongs in position 2 of 5

    Second: owner, comment and other checks run, then thresholds and conditional targets choose the target. See what one action does.

  3. Explanation for C

    Belongs in position 3 of 5

    Third: the sub-workflow step parks the parent and pushes an active child. See what one action does.

  4. Explanation for D

    Belongs in position 1 of 5

    First: on the 1.10 line a person’s action reaches the data service directly, without a bus hop. See three services, one state machine.

  5. Explanation for E

    Belongs in position 4 of 5

    Fourth: the conditional write protects the move against a concurrent action. See refusals you can now explain.

Check your answer

The correct order is D → B → C → E → A. Open the explanation under each item to see why it sits where it does.

↺ Recap (1 min) — The stack is the truth

Section titled “↺ Recap (1 min) — The stack is the truth”

You can now read where a request really is from its stack, predict what an action does to it, including a sub-workflow’s park and merge, and explain the engine’s refusals: a stale action, a manual action on an external step, a missing re-verification. Next, M4-S4: who becomes the owner of the step the engine just chose, and when that step becomes late.