@typeonce/effect-machine 0.12.0 → 0.13.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.
- package/README.md +56 -4
- package/dist/Machine.d.ts +353 -84
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +12 -10
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +1 -0
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +23 -0
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -1
- package/dist/internal/machine/commandRuntime.js +2 -5
- package/dist/internal/machine/commandRuntime.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts +5 -0
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +6 -2
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts +1 -0
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +43 -18
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/initialization.d.ts +5 -0
- package/dist/internal/machine/initialization.d.ts.map +1 -0
- package/dist/internal/machine/initialization.js +61 -0
- package/dist/internal/machine/initialization.js.map +1 -0
- package/dist/internal/machine/inspectionRuntime.d.ts +25 -0
- package/dist/internal/machine/inspectionRuntime.d.ts.map +1 -0
- package/dist/internal/machine/inspectionRuntime.js +79 -0
- package/dist/internal/machine/inspectionRuntime.js.map +1 -0
- package/dist/internal/machine/invocation.d.ts +2 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +17 -10
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +1 -2
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +21 -6
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +15 -0
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +117 -44
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +4 -2
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +27 -3
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +440 -64
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/symbols.d.ts +2 -0
- package/dist/internal/machine/symbols.d.ts.map +1 -1
- package/dist/internal/machine/symbols.js +2 -0
- package/dist/internal/machine/symbols.js.map +1 -1
- package/dist/internal/machine/topology.d.ts +13 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +9 -0
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +3 -3
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +9 -0
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +9 -0
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +102 -9
- package/package.json +5 -5
- package/src/Machine.ts +505 -174
- package/src/internal/machine/atom.ts +26 -0
- package/src/internal/machine/commandRuntime.ts +2 -9
- package/src/internal/machine/configuration.ts +28 -3
- package/src/internal/machine/executionPlan.ts +50 -17
- package/src/internal/machine/initialization.ts +73 -0
- package/src/internal/machine/inspectionRuntime.ts +102 -0
- package/src/internal/machine/invocation.ts +37 -12
- package/src/internal/machine/machine.ts +31 -6
- package/src/internal/machine/planner.ts +136 -42
- package/src/internal/machine/process.ts +4 -2
- package/src/internal/machine/runtime.ts +661 -89
- package/src/internal/machine/symbols.ts +3 -0
- package/src/internal/machine/topology.ts +27 -0
- package/src/internal/testing/machine/finiteModel.ts +8 -7
- package/src/unstable/reactivity/AtomMachine.ts +12 -0
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Cluster and are exposed only through explicit integration boundaries.
|
|
|
34
34
|
## Install
|
|
35
35
|
|
|
36
36
|
```sh
|
|
37
|
-
pnpm add @typeonce/effect-machine effect@4.0.0-rc.
|
|
37
|
+
pnpm add @typeonce/effect-machine effect@4.0.0-rc.109
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
`effect` is an exact peer dependency. Install the version above and upgrade it
|
|
@@ -227,6 +227,56 @@ const ref = yield * prepared.start
|
|
|
227
227
|
not observe startup emissions. Preparation does not retain or replay an
|
|
228
228
|
emission: the observer is simply subscribed before initialization begins.
|
|
229
229
|
|
|
230
|
+
### Inspect a live machine tree
|
|
231
|
+
|
|
232
|
+
`Machine.prepare(machine).inspection` is the operational counterpart to the
|
|
233
|
+
domain-facing `changes` and `emissions` streams. It observes the prepared root
|
|
234
|
+
and every locally owned child, `Logic` process, Effect, and timer in one total
|
|
235
|
+
publication order:
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
const prepared = yield * Machine.prepare(checkout)
|
|
239
|
+
|
|
240
|
+
yield * prepared.inspection.pipe(
|
|
241
|
+
Stream.runForEach((record) => Console.log(record.sequence, record.subject.id, record._tag)),
|
|
242
|
+
Effect.forkScoped({ startImmediately: true })
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
const checkoutRef = yield * prepared.start
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
For a handled input, the stream may expose values such as:
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
{ _tag: "EventSent", sequence: 2, deliveryId: 0,
|
|
252
|
+
subject: { id: "checkout", sessionId: "machine:0", kind: "Machine" },
|
|
253
|
+
source: undefined, target: { id: "checkout", sessionId: "machine:0" },
|
|
254
|
+
event: CheckoutEvents.Submit(), causedBy: undefined }
|
|
255
|
+
|
|
256
|
+
{ _tag: "EventProcessed", sequence: 4, macrostepId: 0,
|
|
257
|
+
deliveryId: 0, handled: true, configurationChanged: true,
|
|
258
|
+
before: { status: "active", state: /* ... */ },
|
|
259
|
+
after: { status: "active", state: /* ... */ }, microsteps: [/* ... */] }
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The closed `Machine.Inspection.Event` union also reports creation,
|
|
263
|
+
initialization and startup failure, direct `Logic` state updates, outward
|
|
264
|
+
emissions, Effect/timer activity lifecycles, and termination. Records erase
|
|
265
|
+
unrelated child protocols to `unknown`; application-level observation remains
|
|
266
|
+
typed through each reference's `changes` and `emissions`.
|
|
267
|
+
|
|
268
|
+
The stream is hot, non-replayed, never fails, and completes after the root
|
|
269
|
+
terminates. Subscribe before `prepared.start` to capture initialization. Local
|
|
270
|
+
session ids are unique only inside that prepared ownership tree: `machine:0`
|
|
271
|
+
is the root and later ids identify its descendants. They are intentionally not
|
|
272
|
+
distributed identities. Cluster placement, routing, and correlation continue
|
|
273
|
+
to use Cluster entity, runner, and request identities at the integration
|
|
274
|
+
boundary.
|
|
275
|
+
|
|
276
|
+
`AtomMachine.inspection(machineAtom)` provides the same root-scoped stream and
|
|
277
|
+
starts a fresh atom-backed machine only after its inspection subscription is
|
|
278
|
+
installed.
|
|
279
|
+
|
|
230
280
|
Invalid event and emission constructions fail the machine with a typed
|
|
231
281
|
`MachineSchemaDecodeError`; they do not throw from the constructor call.
|
|
232
282
|
|
|
@@ -326,7 +376,7 @@ State-scoped work starts on entry and is interrupted on exit:
|
|
|
326
376
|
Loading: {
|
|
327
377
|
invoke: Machine.invoke({
|
|
328
378
|
id: "save-document",
|
|
329
|
-
effect: saveDocument,
|
|
379
|
+
effect: () => saveDocument,
|
|
330
380
|
onDone: ({ output, target }) => target.full.Saved({ id: output.id }),
|
|
331
381
|
onFailure: ({ error, target }) => target.full.Failed({ message: String(error) })
|
|
332
382
|
})
|
|
@@ -393,8 +443,10 @@ lookup.
|
|
|
393
443
|
`onDone` is required for a non-`never` output, and `onFailure` is required for a
|
|
394
444
|
non-`never` typed error; each handler is omitted when its channel is `never`.
|
|
395
445
|
Defects, interruption, and source-construction failures terminate the owning
|
|
396
|
-
runtime.
|
|
397
|
-
|
|
446
|
+
runtime. Effect sources are always factories evaluated when their state is
|
|
447
|
+
entered. Use `effect: () => Effect.sleep(...)` for a generic Effect, while
|
|
448
|
+
`after` keeps timers explicit and makes static durations visible through
|
|
449
|
+
activity inspection.
|
|
398
450
|
|
|
399
451
|
## Reactivity
|
|
400
452
|
|