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
7 changes: 7 additions & 0 deletions .changeset/calm-machines-enter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@typeonce/effect-machine": patch
---

Allow local and branch targets to enter inactive nested parallel states. These
targets now require a complete selection for every parallel region while
preserving partial updates for parallel states that are already active.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ Transition contexts expose three typed target builders:
| `target.branch` | Anywhere under the source's active top-level root | Replaces the selected branch while keeping omitted active ancestor values and parallel regions |
| `target.full` | Any top-level root | Builds a complete active snapshot for the selected root |

When `target.local` or `target.branch` enters an inactive nested parallel
state, its callback must select every region, just like `initial` and
`target.full`. When that parallel state is already active, `target.branch`
can still update one region directly and preserves the other active regions.

The builder controls how the next configuration is assembled; it does not by
itself decide which invokes restart. The runtime derives exit and entry paths
from the previous and next active paths. Shared active ancestors remain entered,
Expand Down
8 changes: 7 additions & 1 deletion docs/agent-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ const ParallelStates = Machine.defineStates({
```

Every parallel region needs an active state in initial and full snapshot
builders.
builders. The same rule applies when a local or branch target enters an
inactive nested parallel state.

Use `type: "final"` for a terminal leaf in `Machine.defineStates`. A final
child completes its compound parent. Put `onDone` on that completed parent,
Expand Down Expand Up @@ -208,6 +209,11 @@ until every declared output schema has an implementation.
| `target.branch` | The destination is elsewhere under the active top-level root | Omitted current ancestor values and parallel regions |
| `target.full` | The destination may be under any top-level root | Nothing is inferred for a newly selected root; build its complete active snapshot |

Entering an inactive parallel state through `target.local` or `target.branch`
requires a complete callback with one selection per region. A parallel state
that is already active remains partially addressable through `target.branch`;
unmentioned active regions are preserved.

These describe configuration construction, not automatic process restart.
Machine planning compares active paths and derives the actual exit and entry
sets. A `target.full` result with the same active paths can update values without
Expand Down
Loading