Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/38838-fanout-pause-refusal.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
'@objectstack/spec': minor
---
Expand All @@ -13,7 +13,7 @@

What is refused: two branches that each reach a pausing node, through any path, `condition`s, `decision`s and back-edges included (the parse cannot tell which conditions can hold together), and two branches merging into one pausing node, which the engine runs once per arriving branch. On an `approval` / `approval_revise` node, and on a `decision` that declares `config.conditions`, only out-edges sharing one `label` run together, so two edges labelled `approve` to two steps are refused and `approve` / `reject` edges to two steps are not. A `decision` that declares `config.conditions` but no fallback edge (none labelled `default`, none `isDefault: true`) is refused when two of its branches reach a pausing node: a run matching no condition picks the `default` branch, no edge claims it, and the engine runs every out-edge together. The fix there: mark the fallback edge `isDefault: true` (or label it `default`); marking one existing branch edge `isDefault: true` is enough. A decision one of whose conditions is the literal `true` (`expression: 'true'`) always matches, so it is exhaustive and is not refused; any other always-true expression, or conditions that together cover every record, is refused all the same, because the parse does not check coverage.

Still accepted: one pausing branch beside branches that never pause, an approval after a `parallel` region, an approval's `approve` / `reject` edges each to its own step, the branches of a `decision` that has a fallback edge, each to its own step, and conditioned out-edges of one node, which run one after another. Not judged: a `subflow` or `map` on a concurrent branch (whether it pauses is decided by the child flow it names) and a pausing node type a plugin registers.
Still accepted: one pausing branch beside branches that never pause, an approval after a `parallel` region, an approval's `approve` / `reject` edges each to its own step, and the branches of a `decision` that has a fallback edge, each to its own step. Conditioned out-edges of one node run one after another, so they never pause together; a branch among them that parks before another is refused by its sibling rule, `flow-sequential-branch-durable-pause-refused`. Not judged: a `subflow` or `map` on a concurrent branch (whether it pauses is decided by the child flow it names) and a pausing node type a plugin registers.

A stored flow carrying the shape no longer registers until it is rewritten. No conversion rewrites it (which shape the author meant is not recorded); the ADR-0087 semantic entry `flow-concurrent-branch-durable-pause-refused` carries the rewrite to the upgrade guide.

Expand Down
20 changes: 20 additions & 0 deletions .changeset/38875-conditioned-edge-pause-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@objectstack/spec': minor
---

fix(spec)!: a flow whose node takes a branch that parks the run before another out-edge is refused at authoring

Clause-②: no (narrowing)
Metadata-protocol: narrowed

**BREAKING** for a flow author: FROM a flow registering and running in which one node takes an out-edge whose branch reaches, along any path, an `approval`, `approval_revise`, `screen` or `wait` node before another out-edge of the same traversal, TO that flow refused by the flow schema, at every door (`objectstack validate`, the metadata save, draft or active, and publish with `422 INVALID_METADATA`, and `registerFlow`), with one message naming the node, the edge whose branch parks the run, and the edges it leaves untaken. The one-line fix: make the branch that parks the last one the node takes (declare its edge after its conditioned siblings, with no unconditional sibling beside it), or chain the steps onto one branch; where only one branch should run, route them through a `decision` (exclusive by default), or delete `mode: 'inclusive'` from the `decision` that carries it; on a `decision` that already takes only the first true edge, mark the unconditional otherwise-branch `isDefault: true` and keep one `isDefault` edge per node.

Why. The engine takes a node's out-edges in a fixed order, each awaited before the next: its conditioned edges in declaration order (every one whose condition holds, except on a `decision` without `mode: 'inclusive'`, which takes only the first), then its `isDefault` edges when no condition held, then its unconditional edges together. A run parks at one place, and on resume it continues from the node that parked, never back at the node it was traversing. So when an earlier branch parks, the later edges are never taken: a node with two conditioned out-edges, both true, to two approval steps ran the first, parked, and after its decision completed the run with the second step never opened and no error anywhere. No approval request is orphaned; a branch whose condition holds is silently dropped.

What is refused, each measured on the real engine before the rule: two conditioned edges, the earlier one reaching a pausing node (the later one pausing or not), on any node but an exclusive `decision`, an inclusive `decision` included; a conditioned or `isDefault` edge reaching a pausing node beside an unconditional sibling, whichever is declared first, on any node, an exclusive `decision` included; an `isDefault` edge reaching a pausing node before a later `isDefault` edge of the same node; and, on a `decision` that declares `config.conditions`, the run matching none of them: with no edge labelled `default` every `isDefault` edge is claimed whatever its label and taken in turn, and with no claimant at all every out-edge is taken in the order above. Conditions are judged as if they may all hold, as the fan-out rule judges them, because the parse cannot tell which conditions can hold together: two conditioned edges whose conditions exclude each other are refused too, and the prescription names the `decision` that makes the choice explicit.

Still accepted: the last conditioned branch reaching a pausing node (the earlier ones have run), an exclusive `decision`'s conditioned branches, an `isDefault` edge beside conditioned ones (it runs only when none held), a `fault` edge, and an approval's `approve` / `reject` edges, judged per label. Not judged: a `subflow` or `map` whose child pauses (whether it pauses is decided by the child flow it names; it drops the later edges at run time all the same) and a pausing node type a plugin registers.

A stored flow carrying the shape no longer registers until it is rewritten. No conversion rewrites it (which shape the author meant is not recorded); the ADR-0087 semantic entry `flow-sequential-branch-durable-pause-refused` carries the rewrite to the upgrade guide.

<!-- adr-0087: registered flow-sequential-branch-durable-pause-refused -->
56 changes: 50 additions & 6 deletions content/docs/automation/flows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1742,11 +1742,51 @@ for that. Write instead:

A `parallel` region is no way out: a region body may not hold a pausing step at
all. Still accepted: one pausing branch beside branches that run without
pausing, an approval after a `parallel` region, an approval's `approve` /
`reject` edges each to its own step, and conditioned edges out of one node,
which run one after another. Not judged here: a `subflow` or `map` on a
pausing, an approval after a `parallel` region, and an approval's `approve` /
`reject` edges each to its own step. Not judged here: a `subflow` or `map` on a
concurrent branch, whose pause is decided by the child flow it names.

**A branch that parks the run, taken before another out-edge, is refused.**
A node takes its out-edges in a fixed order, each one finished before the
next: its conditioned edges in the order they are declared (every one whose
condition holds, except on a `decision` without `mode: 'inclusive'`, which
takes only the first), then its `isDefault` edge when no condition held, then
its unconditional edges together. A run that parks inside an earlier branch
resumes from the step it parked at and never comes back to the node, so the
edges it had not taken yet are never taken, and nothing reports it. The flow
schema refuses that shape at the same doors, naming the node, the edge whose
branch parks the run and the edges it would leave untaken:

- two conditioned edges out of one node, the earlier one reaching a pausing
step, on any node but an exclusive `decision` (an inclusive one included);
- a conditioned or `isDefault` edge reaching a pausing step beside an
unconditional sibling, whichever is declared first;
- an `isDefault` edge reaching a pausing step before a later `isDefault` edge
of the same node;
- on a `decision` that declares `config.conditions`, the run that matches none
of them: with no edge labelled `default`, every `isDefault` edge is claimed,
whatever its label, and taken in turn; with no claimant at all, every
out-edge is taken in the order above.

Conditions are judged as if they may all hold, so two conditioned edges whose
conditions exclude each other are refused too. Write instead:

- the branch that parks as the **last** one the node takes: its edge declared
after its conditioned siblings, with no unconditional sibling beside it;
- the steps **chained** onto one branch, so the work after the pause runs when
the run resumes;
- a `decision` in front of the branches when only **one** of them should run
(it takes only the first edge whose condition holds), or `mode: 'inclusive'`
deleted from the `decision` that carries it.

Two branches that each park the run cannot both be taken from one node in any
order: chain them. On a `decision` that already takes only the first true edge,
an unconditional sibling meant as the otherwise-branch is marked
`isDefault: true` instead; keep one `isDefault` edge per node. Still accepted:
the last conditioned branch reaching a pausing step, an exclusive `decision`'s
branches, an `isDefault` edge beside conditioned ones, and a `fault` edge. A `subflow` or `map` whose child pauses
drops the later edges all the same, and is not judged here either.

### Batch approval — a `map` node, one item at a time

"Sign off **every** task in the release, in turn" is a **`map` node**: it runs a
Expand Down Expand Up @@ -2094,9 +2134,13 @@ edges: [
```

`e_no` runs **only** when `e_yes`'s condition was false. Drop `isDefault` and
`e_no` becomes an ordinary unconditional out-edge that runs on **every** pass —
in parallel with `abort` — so an already-converted lead sees the abort screen
*and* walks into the wizard behind it. Writing the negation of every sibling
`e_no` becomes an ordinary unconditional out-edge, taken on **every** pass
after the conditioned edges are done: with a synchronous `abort` step an
already-converted lead gets the abort step *and* then walks into the wizard
behind it; with `abort` a `screen`, the run parks there and `e_no` is never
taken, so the flow schema refuses that spelling outright (a branch that parks
the run before an unconditional sibling, see *Parallel approvals* under
*Durable pause & resume*). Writing the negation of every sibling
condition by hand is the only other correct spelling; `isDefault` is the one
that stays correct when a third branch is added.

Expand Down
Loading
Loading