@typeonce/effect-machine 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +345 -42
  2. package/dist/Machine.d.ts +1273 -347
  3. package/dist/Machine.d.ts.map +1 -1
  4. package/dist/Machine.js +161 -426
  5. package/dist/Machine.js.map +1 -1
  6. package/dist/internal/machine/activities.d.ts +57 -0
  7. package/dist/internal/machine/activities.d.ts.map +1 -0
  8. package/dist/internal/machine/activities.js +49 -0
  9. package/dist/internal/machine/activities.js.map +1 -0
  10. package/dist/internal/machine/atom.d.ts +69 -0
  11. package/dist/internal/machine/atom.d.ts.map +1 -0
  12. package/dist/{AtomMachine.js → internal/machine/atom.js} +19 -94
  13. package/dist/internal/machine/atom.js.map +1 -0
  14. package/dist/internal/machine/cluster.d.ts +63 -0
  15. package/dist/internal/machine/cluster.d.ts.map +1 -0
  16. package/dist/{ClusterMachine.js → internal/machine/cluster.js} +15 -119
  17. package/dist/internal/machine/cluster.js.map +1 -0
  18. package/dist/internal/machine/command.d.ts +16 -0
  19. package/dist/internal/machine/command.d.ts.map +1 -0
  20. package/dist/internal/machine/command.js +45 -0
  21. package/dist/internal/machine/command.js.map +1 -0
  22. package/dist/internal/machine/commandRuntime.d.ts +13 -0
  23. package/dist/internal/machine/commandRuntime.d.ts.map +1 -0
  24. package/dist/internal/machine/commandRuntime.js +16 -0
  25. package/dist/internal/machine/commandRuntime.js.map +1 -0
  26. package/dist/internal/{machineModel.d.ts → machine/configuration.d.ts} +32 -38
  27. package/dist/internal/machine/configuration.d.ts.map +1 -0
  28. package/dist/internal/machine/configuration.js +965 -0
  29. package/dist/internal/machine/configuration.js.map +1 -0
  30. package/dist/internal/{machineErrors.d.ts → machine/errors.d.ts} +3 -3
  31. package/dist/internal/machine/errors.d.ts.map +1 -0
  32. package/dist/internal/{machineErrors.js → machine/errors.js} +1 -1
  33. package/dist/internal/machine/errors.js.map +1 -0
  34. package/dist/internal/machine/executionPlan.d.ts +49 -0
  35. package/dist/internal/machine/executionPlan.d.ts.map +1 -0
  36. package/dist/internal/machine/executionPlan.js +667 -0
  37. package/dist/internal/machine/executionPlan.js.map +1 -0
  38. package/dist/internal/machine/invocation.d.ts +23 -0
  39. package/dist/internal/machine/invocation.d.ts.map +1 -0
  40. package/dist/internal/machine/invocation.js +77 -0
  41. package/dist/internal/machine/invocation.js.map +1 -0
  42. package/dist/internal/machine/machine.d.ts +183 -0
  43. package/dist/internal/machine/machine.d.ts.map +1 -0
  44. package/dist/internal/machine/machine.js +552 -0
  45. package/dist/internal/machine/machine.js.map +1 -0
  46. package/dist/internal/machine/planner.d.ts +182 -0
  47. package/dist/internal/machine/planner.d.ts.map +1 -0
  48. package/dist/internal/machine/planner.js +1082 -0
  49. package/dist/internal/machine/planner.js.map +1 -0
  50. package/dist/internal/{machineProcess.d.ts → machine/process.d.ts} +10 -4
  51. package/dist/internal/machine/process.d.ts.map +1 -0
  52. package/dist/internal/machine/process.js +446 -0
  53. package/dist/internal/machine/process.js.map +1 -0
  54. package/dist/internal/machine/protocol.d.ts +34 -0
  55. package/dist/internal/machine/protocol.d.ts.map +1 -0
  56. package/dist/internal/machine/protocol.js +182 -0
  57. package/dist/internal/machine/protocol.js.map +1 -0
  58. package/dist/internal/machine/readiness.d.ts +4 -0
  59. package/dist/internal/machine/readiness.d.ts.map +1 -0
  60. package/dist/internal/machine/readiness.js +2 -0
  61. package/dist/internal/machine/readiness.js.map +1 -0
  62. package/dist/internal/{machineRuntime.d.ts → machine/runtime.d.ts} +104 -2
  63. package/dist/internal/machine/runtime.d.ts.map +1 -0
  64. package/dist/internal/machine/runtime.js +1381 -0
  65. package/dist/internal/machine/runtime.js.map +1 -0
  66. package/dist/internal/machine/serialization.d.ts +14 -0
  67. package/dist/internal/machine/serialization.d.ts.map +1 -0
  68. package/dist/internal/machine/serialization.js +338 -0
  69. package/dist/internal/machine/serialization.js.map +1 -0
  70. package/dist/internal/machine/stateDefinition.d.ts +15 -0
  71. package/dist/internal/machine/stateDefinition.d.ts.map +1 -0
  72. package/dist/internal/machine/stateDefinition.js +210 -0
  73. package/dist/internal/machine/stateDefinition.js.map +1 -0
  74. package/dist/internal/machine/symbols.d.ts +3 -0
  75. package/dist/internal/machine/symbols.d.ts.map +1 -0
  76. package/dist/internal/machine/symbols.js +3 -0
  77. package/dist/internal/machine/symbols.js.map +1 -0
  78. package/dist/internal/machine/topology.d.ts +98 -0
  79. package/dist/internal/machine/topology.d.ts.map +1 -0
  80. package/dist/internal/machine/topology.js +347 -0
  81. package/dist/internal/machine/topology.js.map +1 -0
  82. package/dist/internal/testing/machine/arbitrary.d.ts +36 -0
  83. package/dist/internal/testing/machine/arbitrary.d.ts.map +1 -0
  84. package/dist/internal/testing/machine/arbitrary.js +68 -0
  85. package/dist/internal/testing/machine/arbitrary.js.map +1 -0
  86. package/dist/internal/testing/machine/finiteModel.d.ts +322 -0
  87. package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -0
  88. package/dist/internal/testing/machine/finiteModel.js +976 -0
  89. package/dist/internal/testing/machine/finiteModel.js.map +1 -0
  90. package/dist/internal/testing/machine/referenceModel.d.ts +203 -0
  91. package/dist/internal/testing/machine/referenceModel.d.ts.map +1 -0
  92. package/dist/internal/testing/machine/referenceModel.js +1012 -0
  93. package/dist/internal/testing/machine/referenceModel.js.map +1 -0
  94. package/dist/internal/testing/machine/runtime.d.ts +328 -0
  95. package/dist/internal/testing/machine/runtime.d.ts.map +1 -0
  96. package/dist/internal/testing/machine/runtime.js +437 -0
  97. package/dist/internal/testing/machine/runtime.js.map +1 -0
  98. package/dist/internal/testing/machine/verification.d.ts +33 -0
  99. package/dist/internal/testing/machine/verification.d.ts.map +1 -0
  100. package/dist/internal/testing/machine/verification.js +1446 -0
  101. package/dist/internal/testing/machine/verification.js.map +1 -0
  102. package/dist/testing/MachineTest.d.ts +606 -0
  103. package/dist/testing/MachineTest.d.ts.map +1 -0
  104. package/dist/testing/MachineTest.js +102 -0
  105. package/dist/testing/MachineTest.js.map +1 -0
  106. package/dist/testing/index.d.ts +7 -0
  107. package/dist/testing/index.d.ts.map +1 -0
  108. package/dist/testing/index.js +7 -0
  109. package/dist/testing/index.js.map +1 -0
  110. package/dist/{ClusterMachine.d.ts → unstable/cluster/ClusterMachine.d.ts} +22 -30
  111. package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -0
  112. package/dist/unstable/cluster/ClusterMachine.js +126 -0
  113. package/dist/unstable/cluster/ClusterMachine.js.map +1 -0
  114. package/dist/{cluster.js → unstable/cluster/index.d.ts} +1 -1
  115. package/dist/unstable/cluster/index.d.ts.map +1 -0
  116. package/dist/{cluster.d.ts → unstable/cluster/index.js} +1 -1
  117. package/dist/unstable/cluster/index.js.map +1 -0
  118. package/dist/{AtomMachine.d.ts → unstable/reactivity/AtomMachine.d.ts} +40 -23
  119. package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -0
  120. package/dist/unstable/reactivity/AtomMachine.js +113 -0
  121. package/dist/unstable/reactivity/AtomMachine.js.map +1 -0
  122. package/dist/{reactivity.js → unstable/reactivity/index.d.ts} +1 -1
  123. package/dist/unstable/reactivity/index.d.ts.map +1 -0
  124. package/dist/{reactivity.d.ts → unstable/reactivity/index.js} +1 -1
  125. package/dist/unstable/reactivity/index.js.map +1 -0
  126. package/docs/agent-guide.md +271 -38
  127. package/package.json +23 -13
  128. package/dist/AtomMachine.d.ts.map +0 -1
  129. package/dist/AtomMachine.js.map +0 -1
  130. package/dist/ClusterMachine.d.ts.map +0 -1
  131. package/dist/ClusterMachine.js.map +0 -1
  132. package/dist/cluster.d.ts.map +0 -1
  133. package/dist/cluster.js.map +0 -1
  134. package/dist/internal/machineErrors.d.ts.map +0 -1
  135. package/dist/internal/machineErrors.js.map +0 -1
  136. package/dist/internal/machineModel.d.ts.map +0 -1
  137. package/dist/internal/machineModel.js +0 -766
  138. package/dist/internal/machineModel.js.map +0 -1
  139. package/dist/internal/machinePlanner.d.ts +0 -74
  140. package/dist/internal/machinePlanner.d.ts.map +0 -1
  141. package/dist/internal/machinePlanner.js +0 -621
  142. package/dist/internal/machinePlanner.js.map +0 -1
  143. package/dist/internal/machineProcess.d.ts.map +0 -1
  144. package/dist/internal/machineProcess.js +0 -181
  145. package/dist/internal/machineProcess.js.map +0 -1
  146. package/dist/internal/machineRuntime.d.ts.map +0 -1
  147. package/dist/internal/machineRuntime.js +0 -365
  148. package/dist/internal/machineRuntime.js.map +0 -1
  149. package/dist/reactivity.d.ts.map +0 -1
  150. package/dist/reactivity.js.map +0 -1
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Atom bridge for running machines.
3
+ *
4
+ * @since 4.0.0
5
+ */
6
+ import * as internal from "../../internal/machine/atom.js";
7
+ /**
8
+ * Error returned when a machine command is issued before startup completes.
9
+ *
10
+ * @category errors
11
+ * @since 4.0.0
12
+ */
13
+ export { NotReadyError } from "../../internal/machine/atom.js";
14
+ /**
15
+ * Error returned when a command targets a child machine that is not active.
16
+ *
17
+ * @category errors
18
+ * @since 4.0.0
19
+ */
20
+ export { ChildNotActiveError } from "../../internal/machine/atom.js";
21
+ const ExternalRequirementsTypeId = "~effect/reactivity/AtomMachine/ExternalRequirements";
22
+ /**
23
+ * Selects the typed value for an active state path.
24
+ *
25
+ * Valid paths and their selected value types are inferred from the bridge.
26
+ * The derived atom suppresses structurally equal updates. Keep the returned
27
+ * atom stable when constructing it inside a component.
28
+ *
29
+ * **Example**
30
+ *
31
+ * ```ts
32
+ * const readyAtom = AtomMachine.select(machineAtom, "Ready")
33
+ * // Atom<AsyncResult<Option<Ready>, StartError | RuntimeError>>
34
+ * ```
35
+ *
36
+ * @category combinators
37
+ * @since 4.0.0
38
+ */
39
+ export const select = internal.select;
40
+ /**
41
+ * Selects the typed value for an active state path in an invoked child.
42
+ *
43
+ * Valid paths and their selected value types are inferred from the child
44
+ * bridge. An inactive child produces `Option.none()`. Keep the returned atom
45
+ * stable when constructing it inside a component.
46
+ *
47
+ * **Example**
48
+ *
49
+ * ```ts
50
+ * const editingAtom = AtomMachine.selectChild(editorAtom, "Editing")
51
+ * // Atom<AsyncResult<Option<Editing>, StartError | ChildRuntimeError>>
52
+ * ```
53
+ *
54
+ * @category combinators
55
+ * @since 4.0.0
56
+ */
57
+ export const selectChild = internal.selectChild;
58
+ /**
59
+ * Returns whether a state path is active.
60
+ *
61
+ * Valid paths are inferred from the bridge snapshot.
62
+ * The derived atom suppresses equal updates. Runtime failures remain in the
63
+ * typed failure channel.
64
+ *
65
+ * @category combinators
66
+ * @since 4.0.0
67
+ */
68
+ export const matches = internal.matches;
69
+ /**
70
+ * Returns whether a state path is active in an invoked child.
71
+ *
72
+ * Valid paths are inferred from the child bridge snapshot.
73
+ * An inactive child produces `false`. Keep the returned atom stable when
74
+ * constructing it inside a component.
75
+ *
76
+ * @category combinators
77
+ * @since 4.0.0
78
+ */
79
+ export const matchesChild = internal.matchesChild;
80
+ const BoundRequirementsTypeId = "~effect/reactivity/AtomMachine/BoundRequirements";
81
+ /**
82
+ * Creates atoms backed by a running machine.
83
+ *
84
+ * Use `bind(runtime).make(machine)` when the machine requires external
85
+ * services.
86
+ *
87
+ * @category constructors
88
+ * @since 4.0.0
89
+ */
90
+ export const make = internal.make;
91
+ /**
92
+ * Creates a lazy atom bridge from a decoded logical snapshot.
93
+ *
94
+ * The bridge owns one freshly resumed runtime per `AtomRegistry`, with the same
95
+ * lazy start and disposal semantics as {@link make}. The machine initial
96
+ * function and its input, errors, and services are not involved.
97
+ *
98
+ * @category constructors
99
+ * @since 4.0.0
100
+ */
101
+ export const resume = internal.resume;
102
+ /**
103
+ * Creates an `AtomMachine` factory that owns a shared Effect runtime.
104
+ *
105
+ * Use this when an application runs many machines from the same service layer.
106
+ * The returned factory keeps runtime provisioning at the composition boundary,
107
+ * while every call to `make` still creates an independent machine bridge.
108
+ *
109
+ * @category constructors
110
+ * @since 4.0.0
111
+ */
112
+ export const bind = internal.bind;
113
+ //# sourceMappingURL=AtomMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AtomMachine.js","sourceRoot":"","sources":["../../../src/unstable/reactivity/AtomMachine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAA;AAK1D;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAE9D;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAMpE,MAAM,0BAA0B,GAAG,qDAAqD,CAAA;AAwQxF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,MAAM,GASf,QAAQ,CAAC,MAAM,CAAA;AAEnB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,WAAW,GASpB,QAAQ,CAAC,WAAW,CAAA;AAExB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAUmD,QAAQ,CAAC,OAAO,CAAA;AAEvF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAMrB,QAAQ,CAAC,YAAY,CAAA;AAEzB,MAAM,uBAAuB,GAAG,kDAAkD,CAAA;AA8GlF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAiDb,QAAQ,CAAC,IAAI,CAAA;AAEjB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAQf,QAAQ,CAAC,MAAM,CAAA;AAEnB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,IAAI,GAEoB,QAAQ,CAAC,IAAI,CAAA"}
@@ -1,2 +1,2 @@
1
1
  export * as AtomMachine from "./AtomMachine.js";
2
- //# sourceMappingURL=reactivity.js.map
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable/reactivity/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA"}
@@ -1,2 +1,2 @@
1
1
  export * as AtomMachine from "./AtomMachine.js";
2
- //# sourceMappingURL=reactivity.d.ts.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/unstable/reactivity/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA"}
@@ -65,8 +65,8 @@ class methods or nominal class identity.
65
65
  transport boundary.
66
66
  - Return snapshots or typed target-builder results from transitions. Do not
67
67
  return raw decoded state values.
68
- - Effects returned by handlers are planning Effects. Wrap external effects in
69
- `Machine.action`.
68
+ - Transition and lifecycle callbacks are synchronous. Put asynchronous work in
69
+ an invoked Effect, actor, or child machine and map its result to an event.
70
70
  - Put data on the narrowest state where it is valid. Put data shared by sibling
71
71
  phases on their compound parent.
72
72
  - Declare finality only in the state definition. Do not put `type: "final"` in
@@ -92,7 +92,8 @@ Choose one helper from the intent, and reach for the lower-level form only when
92
92
  its extra control is required:
93
93
 
94
94
  - Bind a shared Atom runtime once with `AtomMachine.bind(runtime)`, then use the
95
- returned `make`. Use `AtomMachine.make(machine)` for a service-free machine.
95
+ returned `make` or `resume`. Use `AtomMachine.make(machine)` and
96
+ `AtomMachine.resume(machine, snapshot)` for service-free machines.
96
97
  - Use `Machine.invokeEffect` for a typed one-shot Effect and `Machine.after` for
97
98
  a timer. Use `Machine.invoke` with `Machine.effect` only for custom child
98
99
  process behavior or snapshot mapping.
@@ -100,11 +101,10 @@ its extra control is required:
100
101
  `Machine.childAddress<Event>(id)` for a low-level process address. An
101
102
  invocation is addressable only when `Machine.invoke` receives that address
102
103
  explicitly.
103
- - Stage external effects with `Machine.action`; its optional second argument is
104
- the same operation with a returned transition value, not a separate action
105
- API.
104
+ - Use the callback's `enqueue` argument for `raise`, `emit`, `sendTo`, and
105
+ `stop`. These operations record closed actor commands and do not run Effects.
106
106
 
107
- ## Atomic, compound, and parallel states
107
+ ## Atomic, compound, parallel, and history states
108
108
 
109
109
  Use an atomic state when no child phase can be active beneath it.
110
110
 
@@ -170,7 +170,8 @@ const ParallelStates = Machine.defineStates({
170
170
  ```
171
171
 
172
172
  Every parallel region needs an active state in initial and full snapshot
173
- builders.
173
+ builders. The same rule applies when a local or branch target enters an
174
+ inactive nested parallel state.
174
175
 
175
176
  Use `type: "final"` for a terminal leaf in `Machine.defineStates`. A final
176
177
  child completes its compound parent. Put `onDone` on that completed parent,
@@ -200,13 +201,110 @@ const machine = Machine.make({
200
201
  Do not repeat `type: "final"` in `handle`. Execution APIs reject a machine
201
202
  until every declared output schema has an implementation.
202
203
 
204
+ Declare a history pseudo-state below the active parent whose configuration it
205
+ should remember. It has no schema, is excluded from active state identifiers,
206
+ and is addressed only through `target.history`:
207
+
208
+ ```ts
209
+ const States = Machine.defineStates({
210
+ checkout: {
211
+ schema: Checkout,
212
+ initial: "shipping",
213
+ states: {
214
+ shipping: Shipping,
215
+ payment: {
216
+ schema: Payment,
217
+ initial: "cardEntry",
218
+ states: {
219
+ cardEntry: CardEntry,
220
+ verifying: Verifying
221
+ }
222
+ },
223
+ recent: { type: "history" },
224
+ exact: { type: "history", history: "deep" }
225
+ }
226
+ },
227
+ support: Support
228
+ })
229
+ ```
230
+
231
+ Every history node needs a source-independent default for the first use. The
232
+ default is a complete root snapshot containing the history owner:
233
+
234
+ ```ts
235
+ checkout: {
236
+ history: {
237
+ recent: { default: () => initialCheckoutSnapshot },
238
+ exact: { default: () => initialCheckoutSnapshot }
239
+ }
240
+ }
241
+ ```
242
+
243
+ Target it without a value:
244
+
245
+ ```ts
246
+ Resume: ({ target }) => target.history.checkout.exact()
247
+ ```
248
+
249
+ Deep history restores the complete remembered subtree and its decoded values.
250
+ Shallow history restores only parent and direct-child values. If the remembered
251
+ child is compound, its configured initial child needs a freshly constructed
252
+ value, so implement `initial` only on paths required by shallow history:
253
+
254
+ ```ts
255
+ payment: {
256
+ initial: ({ state }) => new CardEntry({ attempt: state.attempt, cardNumber: "" })
257
+ }
258
+ ```
259
+
260
+ A nested default must include every ancestor above its owner and every region
261
+ of any parallel ancestor. The containing branch is checked statically, so an
262
+ unrelated root, a sibling compound branch, a direct-owner-only nested snapshot,
263
+ or an incomplete parallel configuration is rejected. A canonical nested
264
+ default looks like:
265
+
266
+ ```ts
267
+ Workspace: {
268
+ history: {
269
+ resume: {
270
+ default: ({ target }) =>
271
+ target.App(
272
+ State.cases.App.make({ workspaceId: "default" }),
273
+ (app) =>
274
+ app.Workspace(
275
+ State.cases.Workspace.make({}),
276
+ (workspace) =>
277
+ workspace.Editing(State.cases.Editing.make({}))
278
+ )
279
+ )
280
+ }
281
+ }
282
+ }
283
+ ```
284
+
285
+ On first use from an inactive root, this complete configuration is entered. If
286
+ a parallel ancestor is already active, unaffected active regions are retained.
287
+ Once a history record exists, shallow or deep recorded restoration wins over
288
+ the default.
289
+
290
+ The machine's readiness type tracks missing defaults and shallow initializers.
291
+ History is an overwriteable register, not a stack: restoration does not consume
292
+ it, and the next parent exit replaces it. Entry actions and invokes run again;
293
+ prior effects, actors, and timers are not rewound.
294
+
203
295
  ## Choosing a target
204
296
 
205
- | Builder | Use it when | What it preserves |
206
- | --------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
207
- | `target.local` | The destination is inside the nearest compound scope containing the source | The compound value, active ancestors, and unrelated parallel regions |
208
- | `target.branch` | The destination is elsewhere under the active top-level root | Omitted current ancestor values and parallel regions |
209
- | `target.full` | The destination may be under any top-level root | Nothing is inferred for a newly selected root; build its complete active snapshot |
297
+ | Builder | Use it when | What it preserves |
298
+ | ---------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
299
+ | `target.local` | The destination is inside the nearest compound scope containing the source | The compound value, active ancestors, and unrelated parallel regions |
300
+ | `target.branch` | The destination is elsewhere under the active top-level root | Omitted current ancestor values and parallel regions |
301
+ | `target.full` | The destination may be under any top-level root | Nothing is inferred for a newly selected root; build its complete active snapshot |
302
+ | `target.history` | The destination is a declared history pseudo-state | Its parent's remembered configuration, or a source-independent complete default containing that owner before the first capture |
303
+
304
+ Entering an inactive parallel state through `target.local` or `target.branch`
305
+ requires a complete callback with one selection per region. A parallel state
306
+ that is already active remains partially addressable through `target.branch`;
307
+ unmentioned active regions are preserved.
210
308
 
211
309
  These describe configuration construction, not automatic process restart.
212
310
  Machine planning compares active paths and derives the actual exit and entry
@@ -224,6 +322,35 @@ Refresh: {
224
322
  Do not use `target.full` merely because it is easiest to discover. Prefer the
225
323
  narrowest builder that expresses the intended configuration change.
226
324
 
325
+ Every state builder method has two construction forms:
326
+
327
+ ```ts
328
+ target.local.Ready(decodedReady)
329
+ target.local.Ready.from({ value: event.value })
330
+ ```
331
+
332
+ The direct call accepts the schema's decoded `Type`. `.from` accepts its
333
+ `~type.make.in`, so callers do not need to invoke a TaggedUnion case's `make`
334
+ or instantiate a TaggedClass. The machine resolves `.from` with
335
+ `schema.makeEffect` during planning. Constructor defaults and class identity
336
+ are retained; refinement failures use `MachineSchemaDecodeError` at the state
337
+ boundary rather than throwing synchronously. This applies recursively to
338
+ initial, full, local, branch, compound, parallel, final, and `local.with`
339
+ builders.
340
+
341
+ If `{}` satisfies the schema's constructor input, omit it:
342
+
343
+ ```ts
344
+ target.local.Idle.from()
345
+ target.local.Flow.from((flow) => flow.Idle.from())
346
+ ```
347
+
348
+ This shorthand also applies to schemas whose constructor fields are all
349
+ optional or defaulted. It does not make required fields optional. Compound and
350
+ parallel builders still require a callback selecting their active child or
351
+ every active region. Omitted input is normalized to `{}` and still passes
352
+ through `schema.makeEffect`, including refinements.
353
+
227
354
  ## Reading state and parents
228
355
 
229
356
  `Machine.defineStates` returns typed helpers:
@@ -246,6 +373,47 @@ parents["Route.Ready.Editing"]
246
373
 
247
374
  Do not guess short properties such as `parents.Ready`.
248
375
 
376
+ ### Inspecting the full transition configuration
377
+
378
+ Event, `always`, and `onDone` transition contexts include a fully typed
379
+ `snapshot`. It is the complete logical snapshot at the beginning of that
380
+ microstep, before any selected transition is applied:
381
+
382
+ ```ts
383
+ BufferReady: ({ snapshot, target }) =>
384
+ States.matches(snapshot, "Player.Network.Online")
385
+ ? target.local.Playing(new Playing({}))
386
+ : undefined
387
+ ```
388
+
389
+ Use the existing `States.matches`, `States.get`, `States.getWithParents`, and
390
+ `States.getSnapshot` helpers for cross-region reads. Parallel transitions
391
+ selected in one microstep receive the same capture. Synchronous handlers use
392
+ that captured value and cannot consult live runtime state later.
393
+
394
+ Do not expect `snapshot` in entry, exit, invoke, initializer, history-default,
395
+ or choice contexts. Choice is an important soundness boundary: a startup or
396
+ chained choice can run without a complete stable configuration containing the
397
+ pseudo-source, so the API does not fabricate a partial `Machine.Snapshot`.
398
+
399
+ ### State annotations
400
+
401
+ Attach active-state metadata through Effect Schema:
402
+
403
+ ```ts
404
+ const Saving = State.cases.Saving.annotate({
405
+ title: "Saving document",
406
+ description: "Persisting local changes to the server",
407
+ documentation: "https://docs.example.test/saving"
408
+ })
409
+ ```
410
+
411
+ `Machine.stateNodes(machine)` returns the resolved annotation map. Choice and
412
+ history definitions may declare an `annotations` object containing only
413
+ `title`, `description`, and `documentation`. These values are descriptive;
414
+ they cannot change behavior, identity, or targeting. Visualization may show a
415
+ title, while the structural path remains authoritative.
416
+
249
417
  Use `Machine.retag(TargetCase, source, patch?)` when sibling state payloads
250
418
  share fields. It removes the source discriminator, reuses only compatible
251
419
  fields, and requires a patch for every missing or incompatible required field.
@@ -254,30 +422,25 @@ it through every phase.
254
422
 
255
423
  ## Planning, actions, raised events, and emissions
256
424
 
257
- A transition may return a target directly or compute it in an Effect:
425
+ A transition returns a target synchronously:
258
426
 
259
427
  ```ts
260
- Submit: Effect.fn(function* ({ state, target }) {
261
- const service = yield* SaveService
262
- const canSave = yield* service.validate(state.draft)
263
-
264
- return canSave ? target.local.Saving(new Saving({ draft: state.draft })) : undefined
265
- })
428
+ Submit: ({ state, target }) =>
429
+ state.valid ? target.local.Saving(new Saving({ draft: state.draft })) : undefined
266
430
  ```
267
431
 
268
- That Effect runs during planning. External side effects must be staged:
432
+ Closed statechart and actor operations use `enqueue`:
269
433
 
270
434
  ```ts
271
- Submit: ({ target }) => Machine.action(writeAuditLog, target.local.Saving(new Saving({})))
435
+ Submit: ({ target }, enqueue) => {
436
+ enqueue.emit(new SaveRequested({}))
437
+ return target.local.Saving(new Saving({}))
438
+ }
272
439
  ```
273
440
 
274
- `Machine.action(effect)` stages the action and returns `void`.
275
- `Machine.action(effect, next)` stages the same action and returns `next`, which
276
- is convenient when the transition does not otherwise need an Effect generator.
277
-
278
- The managed runtime executes staged actions before publishing the planned
279
- state. If an action fails, it retains the previous state and suppresses planned
280
- emissions.
441
+ For asynchronous validation or persistence, invoke an Effect or child machine
442
+ from the state and handle its typed success or failure event in a later
443
+ transition. This keeps `(state, event) => [nextState, commands]` synchronous.
281
444
 
282
445
  Plans have a discriminated completion result:
283
446
 
@@ -308,10 +471,25 @@ const machine = Machine.make({
308
471
  states: States.states,
309
472
  events: [Event.cases.Save],
310
473
  internalEvents: [InternalEvent.cases.Saved, InternalEvent.cases.SaveFailed],
311
- initial: () => States.initial.Idle(State.cases.Idle.make({}))
474
+ initial: () => States.initial.Idle.from()
312
475
  })
313
476
  ```
314
477
 
478
+ When the same already-constructed event may be delivered repeatedly, construct
479
+ it once through its owning machine protocol:
480
+
481
+ ```ts
482
+ const save = Machine.event(machine, Event.cases.Save)
483
+ yield* ref.send(save)
484
+ ```
485
+
486
+ `Machine.event` runs the configured schema constructor once. That machine and
487
+ definitions derived from it with `handle` then recognize the decoded event as
488
+ trusted and do not decode it again. Tagged-union case schemas are recognized
489
+ when their union is configured. Treat the returned event as immutable. Raw
490
+ objects and values constructed for another machine continue through normal
491
+ runtime validation on every delivery.
492
+
315
493
  Use the exported utility types when another API must preserve the boundary:
316
494
 
317
495
  ```ts
@@ -407,6 +585,25 @@ Use the separate
407
585
  `Machine.childAddress<Event>(id)` constructor only for lower-level process
408
586
  logic that does not have a complete machine descriptor.
409
587
 
588
+ ### Inspecting state-owned activities
589
+
590
+ Use `Machine.activityDefinitions(machine)` to inspect invokes without running
591
+ them. Static `Machine.invoke`, `Machine.invokeEffect`, `Machine.after`, and
592
+ `Machine.invokeMachine` descriptors expose serializable ownership metadata:
593
+
594
+ ```ts
595
+ Machine.activityDefinitions(machine)
596
+ // [{ source: "Loading", id: "load-timeout", type: "timer",
597
+ // duration: "10s", event: "LoadTimedOut" }]
598
+ ```
599
+
600
+ Effect success/failure mappers are closures and therefore appear as dynamic
601
+ outcomes. Child machines expose descriptor identity, never their runtime or
602
+ implementation. A function-valued `invoke` factory is represented as a dynamic
603
+ activity because inspection must not evaluate user code. The existing invoke
604
+ helpers remain the only execution API; this metadata does not add lifecycle
605
+ configuration syntax or affect execution.
606
+
410
607
  ## AtomMachine and React
411
608
 
412
609
  `AtomMachine.make(machine, ...input)` works when the machine has no external
@@ -481,15 +678,51 @@ Use `Machine.encodeSnapshot` and `Machine.decodeSnapshot` for validated logical
481
678
  statechart data. Persist machine identity and an application migration/version
482
679
  next to the encoded snapshot.
483
680
 
681
+ The canonical resumption boundary is explicit:
682
+
683
+ ```ts
684
+ const encoded = yield* Machine.encodeSnapshot(machine, snapshot)
685
+ const decoded = yield* Machine.decodeSnapshot(machine, encoded)
686
+ const ref = yield* Machine.resume(machine, decoded)
687
+ ```
688
+
689
+ Pass only a decoded `Machine.Snapshot` to `resume`; encoded or arbitrary
690
+ transport data belongs at `decodeSnapshot`. Resumption validates and normalizes
691
+ the logical snapshot again, then publishes it as the fresh runtime's first
692
+ state. It does not call the initial function, require machine input, or include
693
+ initial-only failures and services in its Effect type.
694
+
484
695
  Encoding does not preserve:
485
696
 
486
697
  - running invokes or spawned children;
487
- - subscriptions, timers, or services;
698
+ - subscriptions, queued events, fibers, scopes, timers, or services;
488
699
  - the machine definition;
489
700
  - application migration metadata.
490
701
 
491
- Do not treat decoding as resuming the previous process. It reconstructs logical
492
- state only.
702
+ `resume` reconstructs runtime ownership from logical state only:
703
+
704
+ - no historical entry, transition, completion, eventless, raise, or emit work
705
+ is replayed;
706
+ - completion and history records survive but do not retrigger `onDone`;
707
+ - active-state invokes start once in ordinary ancestor/document order with
708
+ `Machine.InitialEvent`;
709
+ - `invokeEffect` restarts, `invokeMachine` creates a fresh child from its normal
710
+ initial state, and `Machine.after` restarts its complete duration;
711
+ - inactive invokes, spawned children, child snapshots, elapsed timer time, and
712
+ prior `RuntimeSnapshot` status/errors are not restored;
713
+ - a final logical snapshot creates an immediately completed ref;
714
+ - `resume` itself does not evaluate `always` or `onDone`, including transitions
715
+ newly enabled by a changed machine definition. Later events use ordinary
716
+ planning semantics.
717
+
718
+ Use `AtomMachine.resume(machine, decoded)` or
719
+ `AtomMachine.bind(runtime).resume(machine, decoded)` for the same contract in a
720
+ lazy atom bridge. Registry disposal stops the fresh invokes and timers exactly
721
+ as it does for `AtomMachine.make`.
722
+
723
+ This is not durable runtime restoration. `ClusterMachine` has a separate
724
+ checkpoint/planning contract and process-local restrictions; do not substitute
725
+ `Machine.resume` for cluster recovery.
493
726
 
494
727
  ## Common compiler errors
495
728
 
@@ -567,19 +800,19 @@ error defaults to `unknown`. Atoms created with an `AtomRuntime<R, E>` include
567
800
  `E` in their startup error type. Use `ChildOf<ParentAtom, Child>` to infer that
568
801
  exact channel from a parent instead of restating it manually.
569
802
 
570
- ### Handler tree is too deeply nested
803
+ ### Handler tree reaches a compiler instantiation limit
571
804
 
572
- Type inference traverses at most eight nested handler objects. Split or flatten
573
- a deeper statechart instead of casting away the diagnostic.
805
+ `effect-machine` does not impose a fixed handler-tree depth. Inference follows
806
+ the nested handler object until TypeScript reaches its normal, shape-dependent
807
+ compiler resource or instantiation limits.
574
808
 
575
809
  ## Unsupported and intentionally imperative features
576
810
 
577
811
  The current API does not include:
578
812
 
579
- - history states;
580
813
  - declarative first-class guards;
581
814
  - a complete inspectable graph for arbitrary transition Effects.
582
815
 
583
816
  Use ordinary TypeScript conditions for guards and `Machine.after` for
584
817
  state-scoped timers. Do not invent undocumented state-node properties such as
585
- `guard` or `history`.
818
+ `guard`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeonce/effect-machine",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Schema-first state machines and statecharts for Effect",
5
5
  "author": "Sandro Maglione",
6
6
  "repository": {
@@ -27,12 +27,16 @@
27
27
  "import": "./dist/index.js"
28
28
  },
29
29
  "./reactivity": {
30
- "types": "./dist/reactivity.d.ts",
31
- "import": "./dist/reactivity.js"
30
+ "types": "./dist/unstable/reactivity/index.d.ts",
31
+ "import": "./dist/unstable/reactivity/index.js"
32
32
  },
33
33
  "./cluster": {
34
- "types": "./dist/cluster.d.ts",
35
- "import": "./dist/cluster.js"
34
+ "types": "./dist/unstable/cluster/index.d.ts",
35
+ "import": "./dist/unstable/cluster/index.js"
36
+ },
37
+ "./testing": {
38
+ "types": "./dist/testing/index.d.ts",
39
+ "import": "./dist/testing/index.js"
36
40
  },
37
41
  "./package.json": "./package.json"
38
42
  },
@@ -41,17 +45,20 @@
41
45
  "provenance": true
42
46
  },
43
47
  "peerDependencies": {
44
- "effect": "4.0.0-beta.102"
48
+ "effect": "4.0.0-beta.107"
45
49
  },
46
50
  "devDependencies": {
47
51
  "@changesets/cli": "2.31.0",
48
- "@effect/vitest": "4.0.0-beta.102",
52
+ "@effect/vitest": "4.0.0-beta.107",
49
53
  "@types/node": "25.7.0",
50
- "effect": "4.0.0-beta.102",
51
- "prettier": "3.8.1",
54
+ "dprint": "0.55.2",
55
+ "effect": "4.0.0-beta.107",
56
+ "tinybench": "2.9.0",
52
57
  "tstyche": "7.2.1",
53
58
  "typescript": "6.0.3",
54
- "vitest": "4.1.10"
59
+ "vitest": "4.1.10",
60
+ "xstate-v5": "npm:xstate@5.32.5",
61
+ "xstate-v6": "npm:xstate@6.0.0-alpha.31"
55
62
  },
56
63
  "engines": {
57
64
  "node": ">=20"
@@ -60,12 +67,15 @@
60
67
  "build": "tsc -p tsconfig.build.json",
61
68
  "test": "vitest run",
62
69
  "test:types": "tstyche",
70
+ "check:architecture": "node --test scripts/check-architecture.test.mjs && node scripts/check-architecture.mjs",
63
71
  "typecheck": "tsc -p tsconfig.json --noEmit",
64
- "format": "prettier --write .",
65
- "format:check": "prettier --check .",
72
+ "perf:types": "pnpm build && node scripts/type-performance.mjs",
73
+ "perf:runtime": "pnpm build && node --expose-gc scripts/runtime-performance.mjs",
74
+ "format": "dprint fmt",
75
+ "format:check": "dprint check",
66
76
  "test:consumer": "node scripts/test-consumer.mjs",
67
77
  "pack:check": "node scripts/pack-check.mjs",
68
- "check": "pnpm format:check && pnpm typecheck && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check",
78
+ "check": "pnpm format:check && pnpm check:architecture && pnpm typecheck && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check",
69
79
  "changeset": "changeset",
70
80
  "version-packages": "changeset version",
71
81
  "release": "pnpm build && changeset publish"
@@ -1 +0,0 @@
1
- {"version":3,"file":"AtomMachine.d.ts","sourceRoot":"","sources":["../src/AtomMachine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACjF,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;;;;AAGvC;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,kBAAiC;CAAG;;;;AAEvE;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,yBAAwC;IAC/E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CACpB,CAAC;CAAG;AAEL,KAAK,yBAAyB,GAAG,KAAK,CAAC,KAAK,GAAG,YAAY,CAAC,YAAY,CAAA;AAExE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