@typeonce/effect-machine 0.46.0 → 0.47.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/AGENTS.md +1823 -0
- package/CLAUDE.md +1823 -0
- package/README.md +100 -77
- package/ai-docs/README.md +18 -0
- package/ai-docs/src/10_modeling/01_create-a-machine.ts +51 -0
- package/ai-docs/src/10_modeling/02_branch-on-an-event.ts +55 -0
- package/ai-docs/src/10_modeling/03_update-retained-state.ts +58 -0
- package/ai-docs/src/10_modeling/04_verify-after-changing.ts +29 -0
- package/{docs/agent-guide.md → ai-docs/src/10_modeling/index.md} +234 -155
- package/{docs/root-api.md → ai-docs/src/20_root-api/index.md} +29 -57
- package/{docs/effect-atom-react.md → ai-docs/src/30_react/index.md} +42 -49
- package/{docs/machine-review.md → ai-docs/src/40_review/index.md} +42 -40
- package/ai-docs/src/index.md +7 -0
- package/ai-docs/tsconfig.json +22 -0
- package/dist/Machine.d.ts +1195 -1474
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +366 -214
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/command.d.ts +8 -0
- package/dist/internal/machine/command.d.ts.map +1 -1
- package/dist/internal/machine/command.js +2 -2
- package/dist/internal/machine/command.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts +21 -5
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +1 -0
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/construction.js.map +1 -1
- package/dist/internal/machine/declaration.d.ts +2 -1
- package/dist/internal/machine/declaration.d.ts.map +1 -1
- package/dist/internal/machine/declaration.js +28 -46
- package/dist/internal/machine/declaration.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +23 -16
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/implementation.d.ts +2 -0
- package/dist/internal/machine/implementation.d.ts.map +1 -1
- package/dist/internal/machine/implementation.js.map +1 -1
- package/dist/internal/machine/initialDeclaration.d.ts +2 -0
- package/dist/internal/machine/initialDeclaration.d.ts.map +1 -1
- package/dist/internal/machine/initialDeclaration.js +15 -0
- package/dist/internal/machine/initialDeclaration.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +25 -19
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationEvent.d.ts +34 -17
- package/dist/internal/machine/invocationEvent.d.ts.map +1 -1
- package/dist/internal/machine/invocationEvent.js +16 -4
- package/dist/internal/machine/invocationEvent.js.map +1 -1
- package/dist/internal/machine/machine.d.ts +5 -22
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +157 -119
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +15 -4
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +18 -21
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts +2 -0
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +2 -0
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/protocol.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/runtimeCompiled.js.map +1 -1
- package/dist/internal/machine/runtimeGeneric.d.ts.map +1 -1
- package/dist/internal/machine/runtimeGeneric.js.map +1 -1
- package/dist/internal/machine/runtimeProtocol.d.ts +26 -0
- package/dist/internal/machine/runtimeProtocol.d.ts.map +1 -1
- package/dist/internal/machine/runtimeProtocol.js +71 -0
- package/dist/internal/machine/runtimeProtocol.js.map +1 -1
- package/dist/internal/machine/stateDefinition.d.ts.map +1 -1
- package/dist/internal/machine/stateDefinition.js +0 -14
- package/dist/internal/machine/stateDefinition.js.map +1 -1
- package/dist/internal/machine/symbols.d.ts +9 -0
- package/dist/internal/machine/symbols.d.ts.map +1 -1
- package/dist/internal/machine/symbols.js.map +1 -1
- package/dist/internal/machine/topology.d.ts +18 -9
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +16 -1
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/testing/machine/arbitrary.d.ts.map +1 -1
- package/dist/internal/testing/machine/arbitrary.js +2 -0
- package/dist/internal/testing/machine/arbitrary.js.map +1 -1
- package/dist/internal/testing/machine/check.d.ts +17 -0
- package/dist/internal/testing/machine/check.d.ts.map +1 -0
- package/dist/internal/testing/machine/check.js +371 -0
- package/dist/internal/testing/machine/check.js.map +1 -0
- package/dist/internal/testing/machine/exploration.d.ts.map +1 -1
- package/dist/internal/testing/machine/exploration.js.map +1 -1
- package/dist/internal/testing/machine/finiteModel.d.ts +14 -13
- package/dist/internal/testing/machine/finiteModel.d.ts.map +1 -1
- package/dist/internal/testing/machine/finiteModel.js +21 -23
- package/dist/internal/testing/machine/finiteModel.js.map +1 -1
- package/dist/internal/testing/machine/runtime.d.ts +19 -88
- package/dist/internal/testing/machine/runtime.d.ts.map +1 -1
- package/dist/internal/testing/machine/runtime.js +0 -19
- package/dist/internal/testing/machine/runtime.js.map +1 -1
- package/dist/internal/testing/machine/runtimeInvariant.js.map +1 -1
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +349 -139
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +201 -136
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +9 -14
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +9 -14
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +169 -80
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +165 -76
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/package.json +11 -9
- package/src/Machine.ts +1139 -2130
- package/src/internal/machine/atom.ts +3 -3
- package/src/internal/machine/cluster.ts +2 -2
- package/src/internal/machine/command.ts +10 -4
- package/src/internal/machine/configuration.ts +16 -17
- package/src/internal/machine/construction.ts +1 -1
- package/src/internal/machine/declaration.ts +25 -50
- package/src/internal/machine/executionPlan.ts +90 -56
- package/src/internal/machine/implementation.ts +3 -1
- package/src/internal/machine/initialDeclaration.ts +16 -0
- package/src/internal/machine/invocation.ts +38 -44
- package/src/internal/machine/invocationEvent.ts +46 -20
- package/src/internal/machine/machine.ts +217 -243
- package/src/internal/machine/planner.ts +72 -106
- package/src/internal/machine/process.ts +12 -0
- package/src/internal/machine/protocol.ts +6 -6
- package/src/internal/machine/runtime.ts +1 -5
- package/src/internal/machine/runtimeCompiled.ts +2 -2
- package/src/internal/machine/runtimeGeneric.ts +2 -4
- package/src/internal/machine/runtimeProtocol.ts +80 -4
- package/src/internal/machine/stateDefinition.ts +0 -39
- package/src/internal/machine/symbols.ts +11 -0
- package/src/internal/machine/topology.ts +40 -18
- package/src/internal/testing/machine/arbitrary.ts +2 -0
- package/src/internal/testing/machine/check.ts +460 -0
- package/src/internal/testing/machine/exploration.ts +4 -5
- package/src/internal/testing/machine/finiteModel.ts +40 -42
- package/src/internal/testing/machine/runtime.ts +31 -170
- package/src/internal/testing/machine/runtimeInvariant.ts +3 -3
- package/src/internal/testing/machine/verification.ts +14 -14
- package/src/testing/MachineTest.ts +366 -145
- package/src/unstable/cluster/ClusterMachine.ts +9 -14
- package/src/unstable/reactivity/AtomMachine.ts +167 -78
|
@@ -138,32 +138,17 @@ export const RuntimeSynchronization = {
|
|
|
138
138
|
} as const
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
|
-
* The pure/reference-model result for one runtime command.
|
|
141
|
+
* The pure/reference-model result for one enqueued runtime command.
|
|
142
142
|
*
|
|
143
143
|
* @category models
|
|
144
144
|
* @since 0.4.0
|
|
145
145
|
*/
|
|
146
|
-
export interface
|
|
146
|
+
export interface EnqueuedRuntimeModelStep<Model, Expected, State, Error, Output> {
|
|
147
147
|
readonly model: Model
|
|
148
148
|
readonly expected: Expected
|
|
149
149
|
readonly synchronize: RuntimeSynchronization<State, Error, Output>
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
/**
|
|
153
|
-
* Explicit name for the model step used by the enqueue-oriented command
|
|
154
|
-
* runner. The `RuntimeModelStep` name remains as a compatibility alias.
|
|
155
|
-
*
|
|
156
|
-
* @category models
|
|
157
|
-
* @since 0.4.0
|
|
158
|
-
*/
|
|
159
|
-
export type EnqueuedRuntimeModelStep<Model, Expected, State, Error, Output> = RuntimeModelStep<
|
|
160
|
-
Model,
|
|
161
|
-
Expected,
|
|
162
|
-
State,
|
|
163
|
-
Error,
|
|
164
|
-
Output
|
|
165
|
-
>
|
|
166
|
-
|
|
167
152
|
/**
|
|
168
153
|
* Additional asynchronous observation requested after a causal command has
|
|
169
154
|
* completed. `None` never guesses that later invoke, timer, or child work is
|
|
@@ -355,7 +340,7 @@ export interface CausalVerificationTranscript<M extends AnyMachine, Error, Outpu
|
|
|
355
340
|
* @category models
|
|
356
341
|
* @since 0.4.0
|
|
357
342
|
*/
|
|
358
|
-
export interface
|
|
343
|
+
export interface EnqueuedRuntimeCommandActual<State, Error, Output, Observed> {
|
|
359
344
|
readonly result: RuntimeCommandResult
|
|
360
345
|
readonly snapshot: Machine.RuntimeSnapshot<State, Error, Output> | undefined
|
|
361
346
|
readonly published: ReadonlyArray<Machine.RuntimeSnapshot<State, Error, Output>>
|
|
@@ -368,7 +353,7 @@ export interface RuntimeCommandActual<State, Error, Output, Observed> {
|
|
|
368
353
|
* @category models
|
|
369
354
|
* @since 0.4.0
|
|
370
355
|
*/
|
|
371
|
-
export interface
|
|
356
|
+
export interface EnqueuedRuntimeInspectionContext<State, Event, Error, Output> {
|
|
372
357
|
readonly index: number
|
|
373
358
|
readonly command: RuntimeCommand<Event>
|
|
374
359
|
readonly result: RuntimeCommandResult
|
|
@@ -383,12 +368,12 @@ export interface RuntimeInspectionContext<State, Event, Error, Output> {
|
|
|
383
368
|
* @category models
|
|
384
369
|
* @since 0.4.0
|
|
385
370
|
*/
|
|
386
|
-
export interface
|
|
387
|
-
extends
|
|
371
|
+
export interface EnqueuedRuntimeAssertionContext<Model, Expected, State, Event, Error, Output, Observed>
|
|
372
|
+
extends EnqueuedRuntimeInspectionContext<State, Event, Error, Output>
|
|
388
373
|
{
|
|
389
374
|
readonly model: Model
|
|
390
375
|
readonly expected: Expected
|
|
391
|
-
readonly actual:
|
|
376
|
+
readonly actual: EnqueuedRuntimeCommandActual<State, Error, Output, Observed>
|
|
392
377
|
}
|
|
393
378
|
|
|
394
379
|
/**
|
|
@@ -397,7 +382,7 @@ export interface RuntimeAssertionContext<Model, Expected, State, Event, Error, O
|
|
|
397
382
|
* @category models
|
|
398
383
|
* @since 0.4.0
|
|
399
384
|
*/
|
|
400
|
-
export interface
|
|
385
|
+
export interface EnqueuedRuntimeModelOptions<
|
|
401
386
|
Model,
|
|
402
387
|
Expected,
|
|
403
388
|
State,
|
|
@@ -423,15 +408,15 @@ export interface RuntimeModelOptions<
|
|
|
423
408
|
command: RuntimeCommand<Event>,
|
|
424
409
|
index: number
|
|
425
410
|
) => Effect.Effect<
|
|
426
|
-
|
|
411
|
+
EnqueuedRuntimeModelStep<Model, Expected, State, Error, Output>,
|
|
427
412
|
ModelError,
|
|
428
413
|
ModelServices
|
|
429
414
|
>
|
|
430
415
|
readonly inspect?: (
|
|
431
|
-
context:
|
|
416
|
+
context: EnqueuedRuntimeInspectionContext<State, Event, Error, Output>
|
|
432
417
|
) => Effect.Effect<Observed, InspectionError, InspectionServices>
|
|
433
418
|
readonly assert: (
|
|
434
|
-
context:
|
|
419
|
+
context: EnqueuedRuntimeAssertionContext<Model, Expected, State, Event, Error, Output, Observed>
|
|
435
420
|
) => Effect.Effect<void, AssertionError, AssertionServices>
|
|
436
421
|
}
|
|
437
422
|
|
|
@@ -441,12 +426,12 @@ export interface RuntimeModelOptions<
|
|
|
441
426
|
* @category models
|
|
442
427
|
* @since 0.4.0
|
|
443
428
|
*/
|
|
444
|
-
export interface
|
|
429
|
+
export interface EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed> {
|
|
445
430
|
readonly index: number
|
|
446
431
|
readonly command: RuntimeCommand<Event>
|
|
447
432
|
readonly model: Model
|
|
448
433
|
readonly expected: Expected
|
|
449
|
-
readonly actual:
|
|
434
|
+
readonly actual: EnqueuedRuntimeCommandActual<State, Error, Output, Observed>
|
|
450
435
|
}
|
|
451
436
|
|
|
452
437
|
/**
|
|
@@ -455,10 +440,10 @@ export interface RuntimeCommandRecord<Model, Expected, State, Event, Error, Outp
|
|
|
455
440
|
* @category models
|
|
456
441
|
* @since 0.4.0
|
|
457
442
|
*/
|
|
458
|
-
export interface
|
|
443
|
+
export interface EnqueuedRuntimeTranscript<Model, Expected, State, Event, Error, Output, Observed> {
|
|
459
444
|
readonly commands: ReadonlyArray<RuntimeCommand<Event>>
|
|
460
445
|
readonly initial: Machine.RuntimeSnapshot<State, Error, Output>
|
|
461
|
-
readonly records: ReadonlyArray<
|
|
446
|
+
readonly records: ReadonlyArray<EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed>>
|
|
462
447
|
readonly finalModel: Model
|
|
463
448
|
/** The last explicitly synchronized snapshot, never a racy trailing sample. */
|
|
464
449
|
readonly final: Machine.RuntimeSnapshot<State, Error, Output>
|
|
@@ -469,109 +454,6 @@ export interface RuntimeTranscript<Model, Expected, State, Event, Error, Output,
|
|
|
469
454
|
readonly synchronized: boolean
|
|
470
455
|
}
|
|
471
456
|
|
|
472
|
-
/**
|
|
473
|
-
* Enqueue-oriented name for actual runtime command evidence.
|
|
474
|
-
*
|
|
475
|
-
* @category models
|
|
476
|
-
* @since 0.4.0
|
|
477
|
-
*/
|
|
478
|
-
export type EnqueuedRuntimeCommandActual<State, Error, Output, Observed> = RuntimeCommandActual<
|
|
479
|
-
State,
|
|
480
|
-
Error,
|
|
481
|
-
Output,
|
|
482
|
-
Observed
|
|
483
|
-
>
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Enqueue-oriented name for runtime inspection context.
|
|
487
|
-
*
|
|
488
|
-
* @category models
|
|
489
|
-
* @since 0.4.0
|
|
490
|
-
*/
|
|
491
|
-
export type EnqueuedRuntimeInspectionContext<State, Event, Error, Output> = RuntimeInspectionContext<
|
|
492
|
-
State,
|
|
493
|
-
Event,
|
|
494
|
-
Error,
|
|
495
|
-
Output
|
|
496
|
-
>
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Enqueue-oriented name for runtime assertion context.
|
|
500
|
-
*
|
|
501
|
-
* @category models
|
|
502
|
-
* @since 0.4.0
|
|
503
|
-
*/
|
|
504
|
-
export type EnqueuedRuntimeAssertionContext<Model, Expected, State, Event, Error, Output, Observed> =
|
|
505
|
-
RuntimeAssertionContext<Model, Expected, State, Event, Error, Output, Observed>
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Enqueue-oriented options for a runtime reference model.
|
|
509
|
-
*
|
|
510
|
-
* @category models
|
|
511
|
-
* @since 0.4.0
|
|
512
|
-
*/
|
|
513
|
-
export type EnqueuedRuntimeModelOptions<
|
|
514
|
-
Model,
|
|
515
|
-
Expected,
|
|
516
|
-
State,
|
|
517
|
-
Event,
|
|
518
|
-
Error,
|
|
519
|
-
Output,
|
|
520
|
-
Observed = never,
|
|
521
|
-
ModelError = never,
|
|
522
|
-
ModelServices = never,
|
|
523
|
-
InspectionError = never,
|
|
524
|
-
InspectionServices = never,
|
|
525
|
-
AssertionError = never,
|
|
526
|
-
AssertionServices = never
|
|
527
|
-
> = RuntimeModelOptions<
|
|
528
|
-
Model,
|
|
529
|
-
Expected,
|
|
530
|
-
State,
|
|
531
|
-
Event,
|
|
532
|
-
Error,
|
|
533
|
-
Output,
|
|
534
|
-
Observed,
|
|
535
|
-
ModelError,
|
|
536
|
-
ModelServices,
|
|
537
|
-
InspectionError,
|
|
538
|
-
InspectionServices,
|
|
539
|
-
AssertionError,
|
|
540
|
-
AssertionServices
|
|
541
|
-
>
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* Enqueue-oriented name for a checked runtime command record.
|
|
545
|
-
*
|
|
546
|
-
* @category models
|
|
547
|
-
* @since 0.4.0
|
|
548
|
-
*/
|
|
549
|
-
export type EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed> = RuntimeCommandRecord<
|
|
550
|
-
Model,
|
|
551
|
-
Expected,
|
|
552
|
-
State,
|
|
553
|
-
Event,
|
|
554
|
-
Error,
|
|
555
|
-
Output,
|
|
556
|
-
Observed
|
|
557
|
-
>
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Enqueue-oriented name for a complete runtime transcript.
|
|
561
|
-
*
|
|
562
|
-
* @category models
|
|
563
|
-
* @since 0.4.0
|
|
564
|
-
*/
|
|
565
|
-
export type EnqueuedRuntimeTranscript<Model, Expected, State, Event, Error, Output, Observed> = RuntimeTranscript<
|
|
566
|
-
Model,
|
|
567
|
-
Expected,
|
|
568
|
-
State,
|
|
569
|
-
Event,
|
|
570
|
-
Error,
|
|
571
|
-
Output,
|
|
572
|
-
Observed
|
|
573
|
-
>
|
|
574
|
-
|
|
575
457
|
/**
|
|
576
458
|
* One successfully checked causal command.
|
|
577
459
|
*
|
|
@@ -623,7 +505,7 @@ export interface CausalRuntimeTranscript<
|
|
|
623
505
|
* begun but before a complete checked record exists.
|
|
624
506
|
*
|
|
625
507
|
* @category models
|
|
626
|
-
* @since 0.
|
|
508
|
+
* @since 0.47.0
|
|
627
509
|
*/
|
|
628
510
|
export interface CausalRuntimeCommandAttempt<
|
|
629
511
|
M extends AnyMachine,
|
|
@@ -680,8 +562,8 @@ export class RuntimeCommandFailure<
|
|
|
680
562
|
readonly index: number
|
|
681
563
|
readonly command: RuntimeCommand<Event>
|
|
682
564
|
readonly cause: Cause.Cause<Failure>
|
|
683
|
-
readonly prefix: ReadonlyArray<
|
|
684
|
-
readonly attempted:
|
|
565
|
+
readonly prefix: ReadonlyArray<EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed>>
|
|
566
|
+
readonly attempted: EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed> | undefined
|
|
685
567
|
}> {}
|
|
686
568
|
|
|
687
569
|
/**
|
|
@@ -717,8 +599,8 @@ const makeFailure = <Failure, Model, Expected, State, Event, Error, Output, Obse
|
|
|
717
599
|
readonly index: number
|
|
718
600
|
readonly command: RuntimeCommand<Event>
|
|
719
601
|
readonly cause: Cause.Cause<Failure>
|
|
720
|
-
readonly prefix: ReadonlyArray<
|
|
721
|
-
readonly attempted?:
|
|
602
|
+
readonly prefix: ReadonlyArray<EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed>>
|
|
603
|
+
readonly attempted?: EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed>
|
|
722
604
|
}): RuntimeCommandFailure<Failure, Model, Expected, State, Event, Error, Output, Observed> =>
|
|
723
605
|
new RuntimeCommandFailure({
|
|
724
606
|
...options,
|
|
@@ -941,7 +823,7 @@ export const runEnqueuedCommands = <
|
|
|
941
823
|
>(
|
|
942
824
|
ref: Machine.MachineRef<State, Event, Error, Output>,
|
|
943
825
|
commands: Iterable<RuntimeCommand<Event>>,
|
|
944
|
-
options:
|
|
826
|
+
options: EnqueuedRuntimeModelOptions<
|
|
945
827
|
Model,
|
|
946
828
|
Expected,
|
|
947
829
|
State,
|
|
@@ -957,7 +839,7 @@ export const runEnqueuedCommands = <
|
|
|
957
839
|
AssertionServices
|
|
958
840
|
>
|
|
959
841
|
): Effect.Effect<
|
|
960
|
-
|
|
842
|
+
EnqueuedRuntimeTranscript<Model, Expected, State, Event, Error, Output, Observed>,
|
|
961
843
|
RuntimeCommandFailure<
|
|
962
844
|
ModelError | InspectionError | AssertionError | RuntimeObservationError,
|
|
963
845
|
Model,
|
|
@@ -1000,7 +882,7 @@ export const runEnqueuedCommands = <
|
|
|
1000
882
|
yield* Deferred.await(ready)
|
|
1001
883
|
const initialEntry = yield* Queue.take(changes)
|
|
1002
884
|
const initial = initialEntry._tag === "Snapshot" ? initialEntry.snapshot : yield* ref.snapshot
|
|
1003
|
-
const records: Array<
|
|
885
|
+
const records: Array<EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed>> = []
|
|
1004
886
|
let model = options.initialModel
|
|
1005
887
|
let lastSynchronized = initial
|
|
1006
888
|
let outstandingWorkUnknown = false
|
|
@@ -1010,7 +892,7 @@ export const runEnqueuedCommands = <
|
|
|
1010
892
|
readonly index: number
|
|
1011
893
|
readonly command: RuntimeCommand<Event>
|
|
1012
894
|
readonly effect: () => Effect.Effect<A, Failure, R>
|
|
1013
|
-
readonly attempted?:
|
|
895
|
+
readonly attempted?: EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed>
|
|
1014
896
|
}): Effect.Effect<
|
|
1015
897
|
A,
|
|
1016
898
|
RuntimeCommandFailure<Failure, Model, Expected, State, Event, Error, Output, Observed>,
|
|
@@ -1045,7 +927,7 @@ export const runEnqueuedCommands = <
|
|
|
1045
927
|
command,
|
|
1046
928
|
effect: () => executeCommand(ref, command)
|
|
1047
929
|
})
|
|
1048
|
-
const attemptedBeforeObservation:
|
|
930
|
+
const attemptedBeforeObservation: EnqueuedRuntimeCommandRecord<
|
|
1049
931
|
Model,
|
|
1050
932
|
Expected,
|
|
1051
933
|
State,
|
|
@@ -1097,7 +979,7 @@ export const runEnqueuedCommands = <
|
|
|
1097
979
|
if (!outstandingWorkUnknown && synchronized.snapshot !== undefined) lastSynchronized = synchronized.snapshot
|
|
1098
980
|
break
|
|
1099
981
|
}
|
|
1100
|
-
const inspectionContext:
|
|
982
|
+
const inspectionContext: EnqueuedRuntimeInspectionContext<State, Event, Error, Output> = {
|
|
1101
983
|
index,
|
|
1102
984
|
command,
|
|
1103
985
|
result,
|
|
@@ -1105,7 +987,7 @@ export const runEnqueuedCommands = <
|
|
|
1105
987
|
snapshot: synchronized.snapshot,
|
|
1106
988
|
published: synchronized.published
|
|
1107
989
|
}
|
|
1108
|
-
const attemptedBeforeInspection:
|
|
990
|
+
const attemptedBeforeInspection: EnqueuedRuntimeCommandRecord<
|
|
1109
991
|
Model,
|
|
1110
992
|
Expected,
|
|
1111
993
|
State,
|
|
@@ -1131,13 +1013,13 @@ export const runEnqueuedCommands = <
|
|
|
1131
1013
|
effect: () => options.inspect!(inspectionContext),
|
|
1132
1014
|
attempted: attemptedBeforeInspection
|
|
1133
1015
|
})
|
|
1134
|
-
const actual:
|
|
1016
|
+
const actual: EnqueuedRuntimeCommandActual<State, Error, Output, Observed> = {
|
|
1135
1017
|
result,
|
|
1136
1018
|
snapshot: synchronized.snapshot,
|
|
1137
1019
|
published: synchronized.published,
|
|
1138
1020
|
inspected
|
|
1139
1021
|
}
|
|
1140
|
-
const record:
|
|
1022
|
+
const record: EnqueuedRuntimeCommandRecord<Model, Expected, State, Event, Error, Output, Observed> = {
|
|
1141
1023
|
index,
|
|
1142
1024
|
command,
|
|
1143
1025
|
model,
|
|
@@ -1171,17 +1053,6 @@ export const runEnqueuedCommands = <
|
|
|
1171
1053
|
})
|
|
1172
1054
|
)
|
|
1173
1055
|
|
|
1174
|
-
/**
|
|
1175
|
-
* Compatibility alias for enqueue-oriented runtime command execution.
|
|
1176
|
-
*
|
|
1177
|
-
* @deprecated Use `runEnqueuedCommands`. This compatibility name does not
|
|
1178
|
-
* expose whether sends are merely enqueued or causally processed.
|
|
1179
|
-
*
|
|
1180
|
-
* @category constructors
|
|
1181
|
-
* @since 0.4.0
|
|
1182
|
-
*/
|
|
1183
|
-
export const runRuntimeCommands: typeof runEnqueuedCommands = runEnqueuedCommands
|
|
1184
|
-
|
|
1185
1056
|
/**
|
|
1186
1057
|
* Runs typed commands against a probe and checks them against an Effect-native
|
|
1187
1058
|
* reference model.
|
|
@@ -1528,7 +1399,7 @@ export const runtimeCommands = <M extends AnyMachine>(
|
|
|
1528
1399
|
? Protocol.inputEventSchemas(machine).map((schema) => {
|
|
1529
1400
|
const derived = toArbitraryWithReport(schema)
|
|
1530
1401
|
reports.push(derived.report)
|
|
1531
|
-
return derived.value
|
|
1402
|
+
return derived.value
|
|
1532
1403
|
})
|
|
1533
1404
|
: []
|
|
1534
1405
|
const eventArbitrary = options.eventArbitrary ?? (eventArbitraries.length === 0
|
|
@@ -1589,7 +1460,7 @@ export const runtimeCommands = <M extends AnyMachine>(
|
|
|
1589
1460
|
*/
|
|
1590
1461
|
export const formatEnqueuedTranscript = (
|
|
1591
1462
|
value:
|
|
1592
|
-
|
|
|
1463
|
+
| EnqueuedRuntimeTranscript<any, any, any, any, any, any, any>
|
|
1593
1464
|
| RuntimeCommandFailure<any, any, any, any, any, any, any, any>
|
|
1594
1465
|
): string => {
|
|
1595
1466
|
const failure = value instanceof RuntimeCommandFailure
|
|
@@ -1642,16 +1513,6 @@ export const formatEnqueuedTranscript = (
|
|
|
1642
1513
|
return lines.join("\n")
|
|
1643
1514
|
}
|
|
1644
1515
|
|
|
1645
|
-
/**
|
|
1646
|
-
* Compatibility alias for enqueue-oriented transcript formatting.
|
|
1647
|
-
*
|
|
1648
|
-
* @deprecated Use `formatEnqueuedTranscript`.
|
|
1649
|
-
*
|
|
1650
|
-
* @category formatting
|
|
1651
|
-
* @since 0.4.0
|
|
1652
|
-
*/
|
|
1653
|
-
export const formatRuntimeTranscript: typeof formatEnqueuedTranscript = formatEnqueuedTranscript
|
|
1654
|
-
|
|
1655
1516
|
/**
|
|
1656
1517
|
* Formats a causal runtime transcript or failure as replayable line-oriented
|
|
1657
1518
|
* evidence, including exact probe steps and explicit asynchronous observations.
|
|
@@ -114,7 +114,7 @@ const normalizeTranscript = <M extends AnyMachine, Error, Output>(
|
|
|
114
114
|
transcript: CausalRuntimeEvidence<M, Error, Output>
|
|
115
115
|
): RuntimeInvariantTranscript<M> => ({
|
|
116
116
|
commands: transcript.commands,
|
|
117
|
-
initial: transcript.initial
|
|
117
|
+
initial: transcript.initial,
|
|
118
118
|
records: transcript.records.map(({ actual, command, index }) => ({
|
|
119
119
|
index,
|
|
120
120
|
command,
|
|
@@ -122,7 +122,7 @@ const normalizeTranscript = <M extends AnyMachine, Error, Output>(
|
|
|
122
122
|
snapshot: actual.snapshot as RuntimeInvariantRecord<M>["snapshot"],
|
|
123
123
|
awaited: actual.awaited as RuntimeInvariantRecord<M>["awaited"]
|
|
124
124
|
})),
|
|
125
|
-
final: transcript.final
|
|
125
|
+
final: transcript.final
|
|
126
126
|
})
|
|
127
127
|
|
|
128
128
|
interface Observation<M extends AnyMachine, Context> {
|
|
@@ -479,7 +479,7 @@ export const assertPlannerRuntimeAgreement = <M extends AnyMachine, Error, Outpu
|
|
|
479
479
|
|
|
480
480
|
if (violations.length > 0) {
|
|
481
481
|
return yield* new PlannerRuntimeAgreementError({
|
|
482
|
-
evidence: evidence
|
|
482
|
+
evidence: evidence,
|
|
483
483
|
violations
|
|
484
484
|
})
|
|
485
485
|
}
|
|
@@ -55,7 +55,7 @@ const validateLength = (name: "minEvents" | "maxEvents", value: number): void =>
|
|
|
55
55
|
|
|
56
56
|
export const scenarios = <M extends AnyMachine>(
|
|
57
57
|
machine: M,
|
|
58
|
-
options: ScenarioOptions<M> = {}
|
|
58
|
+
options: ScenarioOptions<M> = {}
|
|
59
59
|
): Scenarios<M> => {
|
|
60
60
|
const eventSchemas = Protocol.inputEventSchemas(machine)
|
|
61
61
|
const minEvents = options.minEvents ?? 0
|
|
@@ -82,7 +82,7 @@ export const scenarios = <M extends AnyMachine>(
|
|
|
82
82
|
index,
|
|
83
83
|
report: derived.report
|
|
84
84
|
})
|
|
85
|
-
return derived.value
|
|
85
|
+
return derived.value
|
|
86
86
|
})
|
|
87
87
|
: []
|
|
88
88
|
|
|
@@ -542,7 +542,7 @@ export const coverage = <M extends AnyMachine>(
|
|
|
542
542
|
missing: undefined,
|
|
543
543
|
hits: undefined,
|
|
544
544
|
misses: undefined,
|
|
545
|
-
observed: Array.from(eventCounts, ([tag, count]) => ({ tag, count }))
|
|
545
|
+
observed: Array.from(eventCounts, ([tag, count]) => ({ tag, count })),
|
|
546
546
|
diagnostics: declaredEvents.diagnostics
|
|
547
547
|
},
|
|
548
548
|
scenarios: {
|
|
@@ -585,7 +585,7 @@ export const coverage = <M extends AnyMachine>(
|
|
|
585
585
|
targets: historyTargets,
|
|
586
586
|
resolvedTargets: resolvedHistoryTargets
|
|
587
587
|
}
|
|
588
|
-
}
|
|
588
|
+
}
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
type SnapshotObservationRole = "startup" | "event" | "microstep"
|
|
@@ -731,7 +731,7 @@ export const observedGraph: <M extends AnyMachine>(
|
|
|
731
731
|
id,
|
|
732
732
|
snapshot: group.snapshot,
|
|
733
733
|
...(group.encoded === undefined ? {} : { encoded: group.encoded }),
|
|
734
|
-
configuration: rawConfigurationPaths(machine, group.snapshot)
|
|
734
|
+
configuration: rawConfigurationPaths(machine, group.snapshot),
|
|
735
735
|
observations: {
|
|
736
736
|
total: group.startup + group.event + group.microstep,
|
|
737
737
|
startup: group.startup,
|
|
@@ -756,7 +756,7 @@ export const observedGraph: <M extends AnyMachine>(
|
|
|
756
756
|
entryPaths: microstep.entryPaths as ReadonlyArray<StatePath<M>>,
|
|
757
757
|
changed: microstep.changed
|
|
758
758
|
}))
|
|
759
|
-
}
|
|
759
|
+
})
|
|
760
760
|
}
|
|
761
761
|
})
|
|
762
762
|
return {
|
|
@@ -767,7 +767,7 @@ export const observedGraph: <M extends AnyMachine>(
|
|
|
767
767
|
new Set(startupSourceOccurrences.map((index) => nodesById.get(occurrenceIds[index]!)!))
|
|
768
768
|
)
|
|
769
769
|
}
|
|
770
|
-
})
|
|
770
|
+
})
|
|
771
771
|
|
|
772
772
|
export class VerificationError extends Data.TaggedError("MachineTestVerificationError")<{
|
|
773
773
|
readonly violations: ReadonlyArray<VerificationViolation>
|
|
@@ -1774,7 +1774,7 @@ export const verify = <M extends AnyMachine>(
|
|
|
1774
1774
|
validateSnapshotMetadata(starting, initialLocation, "initial starting state")
|
|
1775
1775
|
validateTraceConfiguration(
|
|
1776
1776
|
starting,
|
|
1777
|
-
trace.initial.startingConfiguration
|
|
1777
|
+
trace.initial.startingConfiguration,
|
|
1778
1778
|
initialLocation,
|
|
1779
1779
|
"initial starting"
|
|
1780
1780
|
)
|
|
@@ -1782,7 +1782,7 @@ export const verify = <M extends AnyMachine>(
|
|
|
1782
1782
|
if (new Set(trace.initial.initialEntryPaths).size !== trace.initial.initialEntryPaths.length) {
|
|
1783
1783
|
add("microsteps.unique", initialLocation, "initial entry paths contain duplicates")
|
|
1784
1784
|
}
|
|
1785
|
-
if (!samePaths(trace.initial.initialEntryPaths
|
|
1785
|
+
if (!samePaths(trace.initial.initialEntryPaths, starting.paths)) {
|
|
1786
1786
|
add(
|
|
1787
1787
|
"microsteps.order",
|
|
1788
1788
|
initialLocation,
|
|
@@ -1808,7 +1808,7 @@ export const verify = <M extends AnyMachine>(
|
|
|
1808
1808
|
validatePlanCompletion(trace.initial.plan, initialState, initialCompletions, initialLocation, "initial plan")
|
|
1809
1809
|
validateTraceConfiguration(
|
|
1810
1810
|
initialState,
|
|
1811
|
-
trace.initial.configuration
|
|
1811
|
+
trace.initial.configuration,
|
|
1812
1812
|
initialLocation,
|
|
1813
1813
|
"initial"
|
|
1814
1814
|
)
|
|
@@ -1817,7 +1817,7 @@ export const verify = <M extends AnyMachine>(
|
|
|
1817
1817
|
}
|
|
1818
1818
|
if (
|
|
1819
1819
|
selected.has("microsteps") &&
|
|
1820
|
-
!samePaths(trace.initial.initialEntryPaths
|
|
1820
|
+
!samePaths(trace.initial.initialEntryPaths, trace.initial.plan.initialEntryPaths)
|
|
1821
1821
|
) {
|
|
1822
1822
|
add("microsteps.continuity", initialLocation, "initial trace entry paths differ from its plan")
|
|
1823
1823
|
}
|
|
@@ -1830,7 +1830,7 @@ export const verify = <M extends AnyMachine>(
|
|
|
1830
1830
|
validateSnapshotMetadata(before, location, `event ${eventIndex} before state`, true)
|
|
1831
1831
|
validateTraceConfiguration(
|
|
1832
1832
|
before,
|
|
1833
|
-
step.beforeConfiguration
|
|
1833
|
+
step.beforeConfiguration,
|
|
1834
1834
|
location,
|
|
1835
1835
|
`event ${eventIndex} before`
|
|
1836
1836
|
)
|
|
@@ -1875,7 +1875,7 @@ export const verify = <M extends AnyMachine>(
|
|
|
1875
1875
|
validateSnapshotMetadata(after, location, `event ${eventIndex} after state`, true)
|
|
1876
1876
|
validateTraceConfiguration(
|
|
1877
1877
|
after,
|
|
1878
|
-
step.afterConfiguration
|
|
1878
|
+
step.afterConfiguration,
|
|
1879
1879
|
location,
|
|
1880
1880
|
`event ${eventIndex} after`
|
|
1881
1881
|
)
|
|
@@ -1889,7 +1889,7 @@ export const verify = <M extends AnyMachine>(
|
|
|
1889
1889
|
const finalLocation: VerificationLocation = { eventIndex: finalEventIndex }
|
|
1890
1890
|
const final = inspectSnapshot(trace.final, finalLocation, "trace final state")
|
|
1891
1891
|
validateSnapshotMetadata(final, finalLocation, "trace final state", true)
|
|
1892
|
-
validateTraceConfiguration(final, trace.finalConfiguration
|
|
1892
|
+
validateTraceConfiguration(final, trace.finalConfiguration, finalLocation, "final")
|
|
1893
1893
|
if (selected.has("microsteps") && !sameValue(previous.root, final.root)) {
|
|
1894
1894
|
add("microsteps.continuity", finalLocation, "trace final state differs from its final planned state")
|
|
1895
1895
|
}
|