Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a4b0676
wip(automation): refuse a branch pause that would drop another branch…
claude Dec 2, 2026
c86fa44
test: pin the run-time branch pause refusal on the engine and the app…
claude Dec 2, 2026
5d611a2
fix(automation): a fan-out waits for its other branches only when one…
claude Dec 2, 2026
b7cd09f
docs(automation): flows teach the run-time branch refusal; changeset
claude Dec 2, 2026
ffd5b71
Merge remote-tracking branch 'origin/main' into claude/issue-38876-su…
claude Dec 2, 2026
5c0793a
fix(automation): the engine hands the branch reader over in one forwa…
claude Dec 2, 2026
90d4d51
test: type the request read's query options in the branch-pause pins
claude Dec 2, 2026
db709f5
fix(automation): a branch pause never waits on its siblings; a late s…
claude Dec 2, 2026
ec5911f
test(automation): pin the late branch refusal on the reviewer's shape…
claude Dec 2, 2026
4d41024
test(automation): P1b's child can park and does not
claude Dec 2, 2026
25fe7cd
test(plugin-approvals): the approval rig reads a late refusal, and pi…
claude Dec 2, 2026
b377383
docs(automation): say when the branch refusal fires; correct the step…
claude Dec 2, 2026
81efb0b
Merge remote-tracking branch 'origin/main' into claude/issue-38876-su…
claude Dec 2, 2026
d5c2223
Merge remote-tracking branch 'origin/main' into claude/issue-38876-su…
claude Dec 2, 2026
f7912ec
fix(automation): the late branch failure binds to the pause it watched
claude Dec 2, 2026
1627126
fix(automation): the engine's watch member is one forwarding call aga…
claude Dec 2, 2026
cde1774
Merge remote-tracking branch 'origin/main' into claude/issue-38876-su…
claude Dec 2, 2026
bb04e46
fix(automation): a resume that meets the late watch mid-read waits in…
claude Dec 2, 2026
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
26 changes: 26 additions & 0 deletions .changeset/38876-subflow-branch-pause-refusal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@objectstack/service-automation': patch
---

fix(automation): a branch whose subflow or map child parks, where the run cannot park, fails the run instead of silently dropping work

Clause-②: no
Metadata-protocol: none

A run parks at one place, and a resumed run continues from the step that parked, never back at the node whose out-edges led there. The flow schema already refuses the two shapes that lose work for the steps that always pause (`approval`, `approval_revise`, `screen`, `wait`): two of them on concurrent branches of one node, and a branch that pauses before the node's other out-edges. It cannot see a `subflow` or `map`, whose pause is decided by the child flow it names, so those shapes registered and ran, and lost work without an error:

- **Concurrent.** A node fanning out to an `approval` and to a `subflow` whose child parks on its own approval opened both requests. Decided parent first, the parent completed and the work after the `subflow` never ran. Decided child first, the child's completion consumed the parent's approval pause, the parent completed, and the parent's own request stayed `pending` with a decision answering `RESUME_TARGET_LOST`.
- **Sequential.** A node whose earlier true conditioned edge led into such a `subflow`, beside a later true conditioned edge to another step: the child's request opened and was decided, the run completed, and the later step never ran.

The engine now fails such a run with a named error on the pauses that actually happen, a child flow's pause included whatever step raises it, and cancels every child run a refused `subflow` / `map` started, so nothing is left parked:

- `durable pause on concurrent branches: node '<node>' runs its unconditional out-edges together, and more than one of those branches suspended — …`, naming each step that paused and the child flow it called;
- `durable pause before a later branch: node '<node>' took edge '<edge>', and node '<step>' (sub-flow '<child>') suspended on that branch while the same traversal still had to take edge '<edge>' …`, naming the edges left untaken.

Each message ends with the fix: chain the pausing steps onto one branch, make the branch that pauses the last one the node takes, or republish the child flow without a step that pauses. The error is a guard refusal, so a `fault` edge does not route it. It is the failed run's `error`; no failure step is logged for it (it is raised by the traversal, not by a node), so the run's step log ends where its branches stopped. Inside a `loop`, `parallel` or `try_catch` body the region error is raised instead, as for any pause there.

When it fires. A fan-out still answers at its first rejection, as it always has: when that is a pause, the run parks and the pause is stored at once, with the step log ending at the node it parked on; nothing waits on the other branches, so a branch that never settles holds nothing up. At the first branch that pauses too afterwards, or ends in this error or the region error, the run that had answered `paused` is failed, provided it still waits at the pause it answered with: that pause is withdrawn the way a resume claims it (the same node and correlation, inside the same in-process gate a resume takes), its record turns `failed` with the error (said once at `error` in the log), a parent flow waiting on it as a `subflow` fails with it, even when the parent's own pause is still being stored, and the child runs are cancelled. A run a decision has moved on by then, finished or parked again at another step, is left as it is, its new pause and that pause's child run untouched; the lost branch is logged at `error` and its child run cancelled. A decision that arrives while the engine is reading where the run waits is held until that read is done rather than refused, and goes on when the run has moved on. When the store cannot be read or claimed at that moment the run is not failed, and the `error` line says so and how to cancel it. When the two arrive before the node has answered, the run fails at once and nothing is stored. When a fan-out's first rejection is a failure, the run fails as before, and a branch that pauses after it has its child run cancelled. The after-the-answer check lives in the engine's process memory: an engine restarted between storing the pause and the late branch settling keeps the old behaviour, the run parked and the late branch's work lost without a word.

What still runs as before: a fan-out whose one pausing branch sits beside branches that do not pause; a branch that pauses with nothing left for the node to take after it; a later conditioned edge whose condition does not hold when the earlier branch pauses; a sibling that fails (with any other error) after another branch paused, which is dropped as before.

Not changed: what an author can write, and every door a flow passes before it runs (`objectstack validate`, the metadata save and publish, `registerFlow`, trigger arming). A request an `approval` opened before the run was refused stays `pending`; deciding it answers `409 RESUME_TARGET_LOST`; the approvals' sweep of requests whose run has ended releases it where the deployment schedules that sweep, and an administrator can recall it sooner.
52 changes: 49 additions & 3 deletions content/docs/automation/flows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1743,8 +1743,10 @@ 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, 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.
`reject` edges each to its own step. A `subflow` or `map` on a concurrent
branch is not judged here, because whether it pauses is decided by the child
flow it names; it is met when the run gets there (*A branch whose child flow
parks* below).

**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
Expand Down Expand Up @@ -1785,7 +1787,51 @@ 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.
is not judged here either; it is met when the run gets there (next).

**A branch whose child flow parks, where the run cannot park, fails the run.**
The schema cannot see a `subflow` or `map` pause: it is decided by another
flow. The engine meets the same two shapes on the pauses that actually happen,
a child flow that parks included (whatever its pausing step), and fails the
run with a named error instead of keeping one pause and dropping the rest:

- **`durable pause on concurrent branches`**: two or more of a node's
unconditional branches paused (an approval beside a `subflow` whose child
parks on its own approval, two such calls). The message names the node and
each step that paused, with the child flow it called.
- **`durable pause before a later branch`**: a branch paused while the node
still had an edge to take after it, a later conditioned edge whose condition
holds at that moment, a later `isDefault` edge or an unconditional sibling.
The message names the node, the edge taken, the step that paused and the
edges left untaken. A later edge whose condition does not hold when the
branch pauses is no lost branch: the run parks as before.

A fan-out still answers at the first branch that pauses, and that pause is
stored at once, as before; nothing waits on the other branches. At the first of
them that pauses too afterwards, or meets one of these errors or the region
error, the run that had answered `paused` is failed then, if it still waits at
that same pause: the pause is withdrawn the way a resume takes it, the record
turns `failed` with the error, and a parent flow waiting on it as a `subflow`
fails with it. A run a decision has moved on by then, finished or parked again
at another step, is left as it is, with its new pause and that pause's child
run untouched; the engine logs the lost branch at `error` and cancels the child
run it parked. A decision that arrives while the engine is reading where the
run waits is held until that read is done, and goes on when the run has moved
on. This check runs in the engine's memory, so an engine restarted
between the pause and the late branch leaves the run parked as before.

Each child run a refused `subflow` or `map` started is cancelled, so nothing is
left parked under the failed run. A request an `approval` opened before the run
was refused stays `pending`, and deciding it answers `409 RESUME_TARGET_LOST`;
the approvals' sweep of requests whose run has ended releases it where the
deployment schedules that sweep, and an administrator can recall it sooner. A
fan-out with one branch that pauses, and a branch that pauses with nothing left
to take after it, run as before. Inside a `loop`, `parallel` or `try_catch` body
the region error (`durable pause inside a structured region`) is raised
instead, since a region cannot pause on any branch. The prescriptions are the
ones above: chain the steps onto one branch, make the branch that pauses the
last one the node takes, or republish the child flow without a step that
pauses.

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

Expand Down
Loading
Loading