@typeonce/effect-machine 0.47.0 → 0.48.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 +374 -22
- package/CLAUDE.md +374 -22
- package/README.md +56 -7
- package/ai-docs/src/10_modeling/01_create-a-machine.ts +3 -3
- package/ai-docs/src/10_modeling/index.md +64 -17
- package/ai-docs/src/20_root-api/index.md +2 -2
- package/ai-docs/src/35_cluster/index.md +213 -0
- package/ai-docs/src/37_new-host/index.md +90 -0
- package/dist/LocalMachine.d.ts +417 -0
- package/dist/LocalMachine.d.ts.map +1 -0
- package/dist/LocalMachine.js +193 -0
- package/dist/LocalMachine.js.map +1 -0
- package/dist/Machine.d.ts +1122 -814
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +195 -186
- package/dist/Machine.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/machine/atom.d.ts +8 -10
- package/dist/internal/machine/atom.d.ts.map +1 -1
- package/dist/internal/machine/atom.js +7 -6
- package/dist/internal/machine/atom.js.map +1 -1
- package/dist/internal/machine/capability.d.ts +101 -0
- package/dist/internal/machine/capability.d.ts.map +1 -0
- package/dist/internal/machine/capability.js +70 -0
- package/dist/internal/machine/capability.js.map +1 -0
- package/dist/internal/machine/{invocationDefinition.d.ts → capturedInvocation.d.ts} +11 -11
- package/dist/internal/machine/capturedInvocation.d.ts.map +1 -0
- package/dist/internal/machine/{invocationDefinition.js → capturedInvocation.js} +2 -2
- package/dist/internal/machine/capturedInvocation.js.map +1 -0
- package/dist/internal/machine/child.d.ts +14 -0
- package/dist/internal/machine/child.d.ts.map +1 -0
- package/dist/internal/machine/child.js +19 -0
- package/dist/internal/machine/child.js.map +1 -0
- package/dist/internal/machine/childRegistry.d.ts +0 -2
- package/dist/internal/machine/childRegistry.d.ts.map +1 -1
- package/dist/internal/machine/childRegistry.js +2 -2
- package/dist/internal/machine/childRegistry.js.map +1 -1
- package/dist/internal/machine/cluster.d.ts +19 -4
- package/dist/internal/machine/cluster.d.ts.map +1 -1
- package/dist/internal/machine/cluster.js +263 -110
- package/dist/internal/machine/cluster.js.map +1 -1
- package/dist/internal/machine/clusterChild.d.ts +66 -0
- package/dist/internal/machine/clusterChild.d.ts.map +1 -0
- package/dist/internal/machine/clusterChild.js +105 -0
- package/dist/internal/machine/clusterChild.js.map +1 -0
- package/dist/internal/machine/clusterFailure.d.ts +14 -0
- package/dist/internal/machine/clusterFailure.d.ts.map +1 -0
- package/dist/internal/machine/clusterFailure.js +44 -0
- package/dist/internal/machine/clusterFailure.js.map +1 -0
- package/dist/internal/machine/clusterInstance.d.ts +194 -0
- package/dist/internal/machine/clusterInstance.d.ts.map +1 -0
- package/dist/internal/machine/clusterInstance.js +1076 -0
- package/dist/internal/machine/clusterInstance.js.map +1 -0
- package/dist/internal/machine/clusterKeepAlive.d.ts +47 -0
- package/dist/internal/machine/clusterKeepAlive.d.ts.map +1 -0
- package/dist/internal/machine/clusterKeepAlive.js +72 -0
- package/dist/internal/machine/clusterKeepAlive.js.map +1 -0
- package/dist/internal/machine/clusterProgress.d.ts +73 -0
- package/dist/internal/machine/clusterProgress.d.ts.map +1 -0
- package/dist/internal/machine/clusterProgress.js +116 -0
- package/dist/internal/machine/clusterProgress.js.map +1 -0
- package/dist/internal/machine/clusterProtocol.d.ts +37 -4
- package/dist/internal/machine/clusterProtocol.d.ts.map +1 -1
- package/dist/internal/machine/clusterProtocol.js +18 -4
- package/dist/internal/machine/clusterProtocol.js.map +1 -1
- package/dist/internal/machine/clusterProxy.d.ts +46 -0
- package/dist/internal/machine/clusterProxy.d.ts.map +1 -0
- package/dist/internal/machine/clusterProxy.js +150 -0
- package/dist/internal/machine/clusterProxy.js.map +1 -0
- package/dist/internal/machine/clusterRead.d.ts +61 -0
- package/dist/internal/machine/clusterRead.d.ts.map +1 -0
- package/dist/internal/machine/clusterRead.js +108 -0
- package/dist/internal/machine/clusterRead.js.map +1 -0
- package/dist/internal/machine/clusterSqlStorage.d.ts +16 -0
- package/dist/internal/machine/clusterSqlStorage.d.ts.map +1 -0
- package/dist/internal/machine/clusterSqlStorage.js +138 -0
- package/dist/internal/machine/clusterSqlStorage.js.map +1 -0
- package/dist/internal/machine/clusterStorageCheck.d.ts +19 -0
- package/dist/internal/machine/clusterStorageCheck.d.ts.map +1 -0
- package/dist/internal/machine/clusterStorageCheck.js +186 -0
- package/dist/internal/machine/clusterStorageCheck.js.map +1 -0
- package/dist/internal/machine/clusterTarget.d.ts +74 -0
- package/dist/internal/machine/clusterTarget.d.ts.map +1 -0
- package/dist/internal/machine/clusterTarget.js +81 -0
- package/dist/internal/machine/clusterTarget.js.map +1 -0
- package/dist/internal/machine/clusterTimer.d.ts +21 -0
- package/dist/internal/machine/clusterTimer.d.ts.map +1 -0
- package/dist/internal/machine/clusterTimer.js +50 -0
- package/dist/internal/machine/clusterTimer.js.map +1 -0
- package/dist/internal/machine/clusterWake.d.ts +61 -0
- package/dist/internal/machine/clusterWake.d.ts.map +1 -0
- package/dist/internal/machine/clusterWake.js +81 -0
- package/dist/internal/machine/clusterWake.js.map +1 -0
- package/dist/internal/machine/clusterWork.d.ts +130 -0
- package/dist/internal/machine/clusterWork.d.ts.map +1 -0
- package/dist/internal/machine/clusterWork.js +191 -0
- package/dist/internal/machine/clusterWork.js.map +1 -0
- package/dist/internal/machine/command.d.ts +4 -4
- package/dist/internal/machine/command.d.ts.map +1 -1
- package/dist/internal/machine/commandRuntime.d.ts +8 -6
- package/dist/internal/machine/commandRuntime.d.ts.map +1 -1
- package/dist/internal/machine/commandRuntime.js +1 -5
- package/dist/internal/machine/commandRuntime.js.map +1 -1
- package/dist/internal/machine/configuration.d.ts +0 -13
- package/dist/internal/machine/configuration.d.ts.map +1 -1
- package/dist/internal/machine/configuration.js +0 -151
- package/dist/internal/machine/configuration.js.map +1 -1
- package/dist/internal/machine/errors.d.ts +11 -2
- package/dist/internal/machine/errors.d.ts.map +1 -1
- package/dist/internal/machine/errors.js +11 -2
- package/dist/internal/machine/errors.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts +45 -3
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +328 -191
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/implementation.d.ts +6 -6
- package/dist/internal/machine/implementation.d.ts.map +1 -1
- package/dist/internal/machine/inspectionRuntime.d.ts +1 -1
- package/dist/internal/machine/inspectionRuntime.d.ts.map +1 -1
- package/dist/internal/machine/invocationChanges.d.ts +60 -0
- package/dist/internal/machine/invocationChanges.d.ts.map +1 -0
- package/dist/internal/machine/invocationChanges.js +54 -0
- package/dist/internal/machine/invocationChanges.js.map +1 -0
- package/dist/internal/machine/{activities.d.ts → invocationDefinitions.d.ts} +8 -8
- package/dist/internal/machine/invocationDefinitions.d.ts.map +1 -0
- package/dist/internal/machine/{activities.js → invocationDefinitions.js} +5 -5
- package/dist/internal/machine/invocationDefinitions.js.map +1 -0
- package/dist/internal/machine/invocationEvent.d.ts +16 -7
- package/dist/internal/machine/invocationEvent.d.ts.map +1 -1
- package/dist/internal/machine/invocationEvent.js +26 -12
- package/dist/internal/machine/invocationEvent.js.map +1 -1
- package/dist/internal/machine/invocationOutcome.d.ts +89 -0
- package/dist/internal/machine/invocationOutcome.d.ts.map +1 -0
- package/dist/internal/machine/invocationOutcome.js +76 -0
- package/dist/internal/machine/invocationOutcome.js.map +1 -0
- package/dist/internal/machine/invocationResolution.d.ts +137 -0
- package/dist/internal/machine/invocationResolution.d.ts.map +1 -0
- package/dist/internal/machine/invocationResolution.js +150 -0
- package/dist/internal/machine/invocationResolution.js.map +1 -0
- package/dist/internal/machine/logicScope.d.ts +24 -0
- package/dist/internal/machine/logicScope.d.ts.map +1 -0
- package/dist/internal/machine/logicScope.js +33 -0
- package/dist/internal/machine/logicScope.js.map +1 -0
- package/dist/internal/machine/machine.d.ts +17 -23
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +24 -40
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/observation.d.ts +3 -0
- package/dist/internal/machine/observation.d.ts.map +1 -1
- package/dist/internal/machine/observation.js +56 -2
- package/dist/internal/machine/observation.js.map +1 -1
- package/dist/internal/machine/plannedSnapshot.d.ts.map +1 -1
- package/dist/internal/machine/plannedSnapshot.js +11 -20
- package/dist/internal/machine/plannedSnapshot.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +36 -23
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +15 -8
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/process.d.ts +17 -9
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +43 -503
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/protocol.d.ts +1 -1
- package/dist/internal/machine/protocol.d.ts.map +1 -1
- package/dist/internal/machine/protocol.js +48 -10
- package/dist/internal/machine/protocol.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +20 -16
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +93 -88
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/runtimeCompiled.d.ts.map +1 -1
- package/dist/internal/machine/runtimeCompiled.js +359 -120
- package/dist/internal/machine/runtimeCompiled.js.map +1 -1
- package/dist/internal/machine/runtimeProtocol.d.ts +151 -82
- package/dist/internal/machine/runtimeProtocol.d.ts.map +1 -1
- package/dist/internal/machine/runtimeProtocol.js +236 -219
- package/dist/internal/machine/runtimeProtocol.js.map +1 -1
- package/dist/internal/machine/stateDefinition.d.ts +0 -1
- package/dist/internal/machine/stateDefinition.d.ts.map +1 -1
- package/dist/internal/machine/stateDefinition.js +0 -1
- package/dist/internal/machine/stateDefinition.js.map +1 -1
- package/dist/internal/machine/step.d.ts +486 -0
- package/dist/internal/machine/step.d.ts.map +1 -0
- package/dist/internal/machine/step.js +957 -0
- package/dist/internal/machine/step.js.map +1 -0
- package/dist/internal/machine/stepHost.d.ts +33 -0
- package/dist/internal/machine/stepHost.d.ts.map +1 -0
- package/dist/internal/machine/stepHost.js +501 -0
- package/dist/internal/machine/stepHost.js.map +1 -0
- package/dist/internal/machine/symbols.d.ts +2 -11
- package/dist/internal/machine/symbols.d.ts.map +1 -1
- package/dist/internal/machine/symbols.js +2 -2
- package/dist/internal/machine/symbols.js.map +1 -1
- package/dist/internal/machine/transition.d.ts +7 -7
- package/dist/internal/machine/transition.d.ts.map +1 -1
- package/dist/internal/testing/machine/check.d.ts.map +1 -1
- package/dist/internal/testing/machine/check.js +217 -25
- package/dist/internal/testing/machine/check.js.map +1 -1
- package/dist/internal/testing/machine/exploration.d.ts +19 -2
- package/dist/internal/testing/machine/exploration.d.ts.map +1 -1
- package/dist/internal/testing/machine/exploration.js +14 -3
- package/dist/internal/testing/machine/exploration.js.map +1 -1
- package/dist/internal/testing/machine/format.js.map +1 -1
- package/dist/internal/testing/machine/probe.d.ts.map +1 -1
- package/dist/internal/testing/machine/probe.js +1 -1
- package/dist/internal/testing/machine/probe.js.map +1 -1
- package/dist/internal/testing/machine/runtime.d.ts +2 -2
- package/dist/internal/testing/machine/runtime.d.ts.map +1 -1
- package/dist/internal/testing/machine/runtime.js +10 -3
- package/dist/internal/testing/machine/runtime.js.map +1 -1
- package/dist/internal/testing/machine/trace.d.ts +38 -3
- package/dist/internal/testing/machine/trace.d.ts.map +1 -1
- package/dist/internal/testing/machine/trace.js +180 -33
- package/dist/internal/testing/machine/trace.js.map +1 -1
- package/dist/internal/testing/machine/transitionCoverage.d.ts +1 -1
- package/dist/internal/testing/machine/transitionCoverage.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +9 -1
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/internal/testing/machine/work.d.ts +47 -0
- package/dist/internal/testing/machine/work.d.ts.map +1 -0
- package/dist/internal/testing/machine/work.js +74 -0
- package/dist/internal/testing/machine/work.js.map +1 -0
- package/dist/testing/MachineTest.d.ts +253 -37
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +81 -9
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +1071 -41
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +441 -12
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/cluster/ClusterMachineProxy.d.ts +257 -0
- package/dist/unstable/cluster/ClusterMachineProxy.d.ts.map +1 -0
- package/dist/unstable/cluster/ClusterMachineProxy.js +73 -0
- package/dist/unstable/cluster/ClusterMachineProxy.js.map +1 -0
- package/dist/unstable/cluster/SqlMachineStorage.d.ts +125 -0
- package/dist/unstable/cluster/SqlMachineStorage.d.ts.map +1 -0
- package/dist/unstable/cluster/SqlMachineStorage.js +62 -0
- package/dist/unstable/cluster/SqlMachineStorage.js.map +1 -0
- package/dist/unstable/cluster/index.d.ts +13 -0
- package/dist/unstable/cluster/index.d.ts.map +1 -1
- package/dist/unstable/cluster/index.js +13 -0
- package/dist/unstable/cluster/index.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +21 -26
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/package.json +5 -3
- package/src/LocalMachine.ts +611 -0
- package/src/Machine.ts +1383 -1336
- package/src/index.ts +1 -0
- package/src/internal/machine/atom.ts +20 -49
- package/src/internal/machine/capability.ts +123 -0
- package/src/internal/machine/{invocationDefinition.ts → capturedInvocation.ts} +13 -13
- package/src/internal/machine/child.ts +25 -0
- package/src/internal/machine/childRegistry.ts +1 -4
- package/src/internal/machine/cluster.ts +420 -205
- package/src/internal/machine/clusterChild.ts +117 -0
- package/src/internal/machine/clusterFailure.ts +53 -0
- package/src/internal/machine/clusterInstance.ts +1779 -0
- package/src/internal/machine/clusterKeepAlive.ts +93 -0
- package/src/internal/machine/clusterProgress.ts +159 -0
- package/src/internal/machine/clusterProtocol.ts +46 -4
- package/src/internal/machine/clusterProxy.ts +233 -0
- package/src/internal/machine/clusterRead.ts +207 -0
- package/src/internal/machine/clusterSqlStorage.ts +181 -0
- package/src/internal/machine/clusterStorageCheck.ts +274 -0
- package/src/internal/machine/clusterTarget.ts +154 -0
- package/src/internal/machine/clusterTimer.ts +58 -0
- package/src/internal/machine/clusterWake.ts +100 -0
- package/src/internal/machine/clusterWork.ts +269 -0
- package/src/internal/machine/command.ts +4 -4
- package/src/internal/machine/commandRuntime.ts +12 -24
- package/src/internal/machine/configuration.ts +0 -181
- package/src/internal/machine/errors.ts +11 -2
- package/src/internal/machine/executionPlan.ts +493 -263
- package/src/internal/machine/implementation.ts +6 -6
- package/src/internal/machine/inspectionRuntime.ts +1 -1
- package/src/internal/machine/invocationChanges.ts +89 -0
- package/src/internal/machine/{activities.ts → invocationDefinitions.ts} +10 -10
- package/src/internal/machine/invocationEvent.ts +35 -12
- package/src/internal/machine/invocationOutcome.ts +145 -0
- package/src/internal/machine/invocationResolution.ts +307 -0
- package/src/internal/machine/logicScope.ts +47 -0
- package/src/internal/machine/machine.ts +35 -100
- package/src/internal/machine/observation.ts +67 -2
- package/src/internal/machine/plannedSnapshot.ts +17 -20
- package/src/internal/machine/planner.ts +75 -99
- package/src/internal/machine/process.ts +78 -722
- package/src/internal/machine/protocol.ts +70 -26
- package/src/internal/machine/runtime.ts +198 -195
- package/src/internal/machine/runtimeCompiled.ts +496 -171
- package/src/internal/machine/runtimeProtocol.ts +416 -305
- package/src/internal/machine/stateDefinition.ts +0 -5
- package/src/internal/machine/step.ts +1518 -0
- package/src/internal/machine/stepHost.ts +634 -0
- package/src/internal/machine/symbols.ts +3 -14
- package/src/internal/machine/transition.ts +11 -11
- package/src/internal/testing/machine/check.ts +240 -36
- package/src/internal/testing/machine/exploration.ts +42 -3
- package/src/internal/testing/machine/format.ts +1 -1
- package/src/internal/testing/machine/probe.ts +2 -1
- package/src/internal/testing/machine/runtime.ts +15 -5
- package/src/internal/testing/machine/trace.ts +261 -41
- package/src/internal/testing/machine/transitionCoverage.ts +1 -1
- package/src/internal/testing/machine/verification.ts +11 -5
- package/src/internal/testing/machine/work.ts +101 -0
- package/src/testing/MachineTest.ts +268 -44
- package/src/unstable/cluster/ClusterMachine.ts +1183 -59
- package/src/unstable/cluster/ClusterMachineProxy.ts +372 -0
- package/src/unstable/cluster/SqlMachineStorage.ts +136 -0
- package/src/unstable/cluster/index.ts +15 -0
- package/src/unstable/reactivity/AtomMachine.ts +27 -88
- package/dist/internal/machine/activities.d.ts.map +0 -1
- package/dist/internal/machine/activities.js.map +0 -1
- package/dist/internal/machine/invocation.d.ts +0 -33
- package/dist/internal/machine/invocation.d.ts.map +0 -1
- package/dist/internal/machine/invocation.js +0 -220
- package/dist/internal/machine/invocation.js.map +0 -1
- package/dist/internal/machine/invocationDefinition.d.ts.map +0 -1
- package/dist/internal/machine/invocationDefinition.js.map +0 -1
- package/dist/internal/machine/requirements.d.ts +0 -4
- package/dist/internal/machine/requirements.d.ts.map +0 -1
- package/dist/internal/machine/requirements.js +0 -2
- package/dist/internal/machine/requirements.js.map +0 -1
- package/dist/internal/machine/runtimeGeneric.d.ts +0 -3
- package/dist/internal/machine/runtimeGeneric.d.ts.map +0 -1
- package/dist/internal/machine/runtimeGeneric.js +0 -465
- package/dist/internal/machine/runtimeGeneric.js.map +0 -1
- package/src/internal/machine/invocation.ts +0 -376
- package/src/internal/machine/requirements.ts +0 -11
- package/src/internal/machine/runtimeGeneric.ts +0 -797
|
@@ -16,6 +16,7 @@ import * as ProbeTest from "../internal/testing/machine/probe.js";
|
|
|
16
16
|
import * as ReferenceModel from "../internal/testing/machine/referenceModel.js";
|
|
17
17
|
import type * as RuntimeTest from "../internal/testing/machine/runtime.js";
|
|
18
18
|
import * as RuntimeInvariantTest from "../internal/testing/machine/runtimeInvariant.js";
|
|
19
|
+
import { WorkOutcomeTypeId } from "../internal/testing/machine/trace.js";
|
|
19
20
|
import type { VerificationError } from "../internal/testing/machine/verification.js";
|
|
20
21
|
import type * as Machine from "../Machine.js";
|
|
21
22
|
export { advanceCommand, type CausalRuntimeAssertionContext, type CausalRuntimeCommandActual, type CausalRuntimeCommandAttempt, CausalRuntimeCommandFailure, type CausalRuntimeCommandRecord, type CausalRuntimeCommandResult, type CausalRuntimeInspectionContext, type CausalRuntimeModelOptions, type CausalRuntimeModelStep, type CausalRuntimeTranscript, type CausalVerificationAwaitContext, type CausalVerificationOptions, type CausalVerificationTranscript, checkpointCommand, type EnqueuedRuntimeAssertionContext, type EnqueuedRuntimeCommandActual, type EnqueuedRuntimeCommandRecord, type EnqueuedRuntimeInspectionContext, type EnqueuedRuntimeModelOptions, type EnqueuedRuntimeModelStep, type EnqueuedRuntimeTranscript, formatCausalTranscript, formatEnqueuedTranscript, runCausalCommands, runEnqueuedCommands, type RuntimeAwait, type RuntimeCommand, RuntimeCommandFailure, type RuntimeCommandResult, type RuntimeCommands, runtimeCommands, type RuntimeCommandsDiagnostics, type RuntimeCommandsOptions, RuntimeObservationError, RuntimeSynchronization, sendCommand, stopCommand, verifyCausalCommands } from "../internal/testing/machine/runtime.js";
|
|
@@ -37,20 +38,102 @@ type StateNodePath<M extends AnyMachine> = Machine.Machine.StateNodeIdentifier<M
|
|
|
37
38
|
type IsAny<A> = 0 extends (1 & A) ? true : false;
|
|
38
39
|
type ReadyMachine<M extends AnyMachine> = M & EnsureExecutable<Machine.Machine.States<M>, Machine.Machine.UnhandledStates<M>, Machine.Machine.OutputStates<M>>;
|
|
39
40
|
type RootReadyMachine<M extends AnyMachine> = ReadyMachine<M> & Machine.Machine.RootCompatible<Machine.Machine.ParentEvents<M>>;
|
|
41
|
+
/**
|
|
42
|
+
* Type identifier of a {@link WorkOutcome}.
|
|
43
|
+
*
|
|
44
|
+
* @category type IDs
|
|
45
|
+
* @since 0.48.0
|
|
46
|
+
*/
|
|
47
|
+
export { WorkOutcomeTypeId };
|
|
48
|
+
/**
|
|
49
|
+
* A result reported by work that a state invoked: the output or typed failure
|
|
50
|
+
* of an Effect, or a timer whose duration elapsed.
|
|
51
|
+
*
|
|
52
|
+
* **Details**
|
|
53
|
+
*
|
|
54
|
+
* A scenario lists what a machine receives in order, so an outcome is an entry
|
|
55
|
+
* of `events` beside the public events. `path` and `id` name the state that
|
|
56
|
+
* invoked the work and the invocation, as `Machine.InvocationEvent` does.
|
|
57
|
+
* Planning applies an outcome only while its work runs: work starts when its
|
|
58
|
+
* state is entered and ends once per entry, so an outcome for work that is not
|
|
59
|
+
* running is ignored and plans an unchanged step, as every host ignores a late
|
|
60
|
+
* result.
|
|
61
|
+
*
|
|
62
|
+
* `_tag` is {@link WorkOutcomeTypeId}, which no event tag can equal. Use
|
|
63
|
+
* {@link isWorkOutcome} to tell an outcome from an event.
|
|
64
|
+
*
|
|
65
|
+
* **Gotchas**
|
|
66
|
+
*
|
|
67
|
+
* A failure reported to work with no `onFailure` fails the machine, and so
|
|
68
|
+
* does an output reported to work with no `onDone`. {@link run} returns that
|
|
69
|
+
* failure as a `RunFailure`.
|
|
70
|
+
*
|
|
71
|
+
* @category models
|
|
72
|
+
* @since 0.48.0
|
|
73
|
+
*/
|
|
74
|
+
export type WorkOutcome = {
|
|
75
|
+
readonly _tag: typeof WorkOutcomeTypeId;
|
|
76
|
+
readonly kind: "Done";
|
|
77
|
+
readonly path: string;
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly output: unknown;
|
|
80
|
+
} | {
|
|
81
|
+
readonly _tag: typeof WorkOutcomeTypeId;
|
|
82
|
+
readonly kind: "Failure";
|
|
83
|
+
readonly path: string;
|
|
84
|
+
readonly id: string;
|
|
85
|
+
readonly error: unknown;
|
|
86
|
+
} | {
|
|
87
|
+
readonly _tag: typeof WorkOutcomeTypeId;
|
|
88
|
+
readonly kind: "Elapsed";
|
|
89
|
+
readonly path: string;
|
|
90
|
+
readonly id: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Returns `true` if a scenario entry or trace step event is a {@link WorkOutcome}.
|
|
94
|
+
*
|
|
95
|
+
* @category guards
|
|
96
|
+
* @since 0.48.0
|
|
97
|
+
*/
|
|
98
|
+
export declare const isWorkOutcome: (value: unknown) => value is WorkOutcome;
|
|
99
|
+
/**
|
|
100
|
+
* Work that runs in a planner trace: invoked by an active state that was
|
|
101
|
+
* entered, and not yet ended.
|
|
102
|
+
*
|
|
103
|
+
* @category models
|
|
104
|
+
* @since 0.48.0
|
|
105
|
+
*/
|
|
106
|
+
export interface RunningWork {
|
|
107
|
+
/** Path of the state that invoked the work. */
|
|
108
|
+
readonly path: string;
|
|
109
|
+
/** Id of the invocation within that state. */
|
|
110
|
+
readonly id: string;
|
|
111
|
+
/** Registered source name, or `undefined` for a child machine. */
|
|
112
|
+
readonly source: string | undefined;
|
|
113
|
+
readonly kind: "Effect" | "Timer" | "Stream" | "Logic" | "Child";
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* One entry of a scenario: a public event, or a result of invoked work.
|
|
117
|
+
*
|
|
118
|
+
* @category models
|
|
119
|
+
* @since 0.48.0
|
|
120
|
+
*/
|
|
121
|
+
export type ScenarioEvent<M extends AnyMachine> = Machine.Machine.EventInput<Machine.Machine.InputEvent<M>> | WorkOutcome;
|
|
40
122
|
/**
|
|
41
123
|
* A generated public-input scenario for a machine.
|
|
42
124
|
*
|
|
43
125
|
* Machines without an input schema omit `input`; machines with one retain its
|
|
44
|
-
* exact decoded type. Events use only the public input protocol
|
|
126
|
+
* exact decoded type. Events use only the public input protocol, and may be
|
|
127
|
+
* interleaved with the {@link WorkOutcome} results of invoked work.
|
|
45
128
|
*
|
|
46
129
|
* @category models
|
|
47
130
|
* @since 0.4.0
|
|
48
131
|
*/
|
|
49
132
|
export type Scenario<M extends AnyMachine> = Machine.Machine.InputSchema<M> extends typeof Schema.Void ? {
|
|
50
|
-
readonly events: ReadonlyArray<
|
|
133
|
+
readonly events: ReadonlyArray<ScenarioEvent<M>>;
|
|
51
134
|
} : {
|
|
52
135
|
readonly input: InputValue<M>;
|
|
53
|
-
readonly events: ReadonlyArray<
|
|
136
|
+
readonly events: ReadonlyArray<ScenarioEvent<M>>;
|
|
54
137
|
};
|
|
55
138
|
/**
|
|
56
139
|
* Options for schema-derived scenario generation.
|
|
@@ -158,9 +241,9 @@ export type PlanCompletion<M extends AnyMachine> = {
|
|
|
158
241
|
* @category models
|
|
159
242
|
* @since 0.4.0
|
|
160
243
|
*/
|
|
161
|
-
export interface Microstep<M extends AnyMachine
|
|
244
|
+
export interface Microstep<M extends AnyMachine> {
|
|
162
245
|
readonly next: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
163
|
-
readonly event: Machine.Machine.Event<M> | Machine.InitialEvent;
|
|
246
|
+
readonly event: Machine.Machine.Event<M> | Machine.InitialEvent | Machine.InvocationEvent;
|
|
164
247
|
readonly transitions: ReadonlyArray<Machine.Machine.RetainedTransition<StatePath<M>, Machine.Machine.TagOf<Machine.Machine.Events<M>[number]>, StateNodePath<M>>>;
|
|
165
248
|
readonly commands: ReadonlyArray<Machine.Command>;
|
|
166
249
|
readonly raisedEvents: ReadonlyArray<Machine.Machine.Event<M>>;
|
|
@@ -181,16 +264,17 @@ export type InitialPlan<M extends AnyMachine> = {
|
|
|
181
264
|
readonly state: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
182
265
|
readonly commands: ReadonlyArray<Machine.Command>;
|
|
183
266
|
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
184
|
-
readonly microsteps: ReadonlyArray<Microstep<M
|
|
267
|
+
readonly microsteps: ReadonlyArray<Microstep<M>>;
|
|
185
268
|
} & PlanCompletion<M>;
|
|
186
269
|
/**
|
|
187
|
-
* The complete data returned while planning one public event
|
|
270
|
+
* The complete data returned while planning one public event, or one result of
|
|
271
|
+
* invoked work, whose `event` is its `Machine.InvocationEvent`.
|
|
188
272
|
*
|
|
189
273
|
* @category models
|
|
190
274
|
* @since 0.4.0
|
|
191
275
|
*/
|
|
192
276
|
export type EventPlan<M extends AnyMachine> = {
|
|
193
|
-
readonly event: Machine.Machine.InputEvent<M
|
|
277
|
+
readonly event: Machine.Machine.InputEvent<M> | Machine.InvocationEvent;
|
|
194
278
|
readonly next: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
195
279
|
readonly commands: ReadonlyArray<Machine.Command>;
|
|
196
280
|
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
@@ -212,6 +296,9 @@ export interface InitialTrace<M extends AnyMachine> {
|
|
|
212
296
|
/**
|
|
213
297
|
* One event portion of an executable planner trace.
|
|
214
298
|
*
|
|
299
|
+
* `event` is the decoded public event, or the {@link WorkOutcome} of a step
|
|
300
|
+
* caused by invoked work.
|
|
301
|
+
*
|
|
215
302
|
* @category models
|
|
216
303
|
* @since 0.4.0
|
|
217
304
|
*/
|
|
@@ -219,7 +306,7 @@ export interface TraceStep<M extends AnyMachine> {
|
|
|
219
306
|
readonly index: number;
|
|
220
307
|
readonly before: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
221
308
|
readonly beforeConfiguration: ReadonlyArray<StatePath<M>>;
|
|
222
|
-
readonly event: Machine.Machine.InputEvent<M
|
|
309
|
+
readonly event: Machine.Machine.InputEvent<M> | WorkOutcome;
|
|
223
310
|
readonly plan: EventPlan<M>;
|
|
224
311
|
readonly after: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
225
312
|
readonly afterConfiguration: ReadonlyArray<StatePath<M>>;
|
|
@@ -236,6 +323,8 @@ export interface Trace<M extends AnyMachine> {
|
|
|
236
323
|
readonly steps: ReadonlyArray<TraceStep<M>>;
|
|
237
324
|
readonly final: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
238
325
|
readonly finalConfiguration: ReadonlyArray<StatePath<M>>;
|
|
326
|
+
/** The work that runs in `final`, in start order. A completed machine runs none. */
|
|
327
|
+
readonly work: ReadonlyArray<RunningWork>;
|
|
239
328
|
}
|
|
240
329
|
/**
|
|
241
330
|
* One runtime microstep retained by the execution strategy used by a probe.
|
|
@@ -319,7 +408,7 @@ export { ProbeUnavailableError } from "../internal/testing/machine/probe.js";
|
|
|
319
408
|
* **Example** (Acknowledging commands at runtime)
|
|
320
409
|
*
|
|
321
410
|
* ```ts import.meta.vitest
|
|
322
|
-
* import { Machine } from "@typeonce/effect-machine"
|
|
411
|
+
* import { LocalMachine, Machine } from "@typeonce/effect-machine"
|
|
323
412
|
* import { MachineTest } from "@typeonce/effect-machine/testing"
|
|
324
413
|
* import { Effect } from "effect"
|
|
325
414
|
*
|
|
@@ -329,7 +418,7 @@ export { ProbeUnavailableError } from "../internal/testing/machine/probe.js";
|
|
|
329
418
|
* })
|
|
330
419
|
*
|
|
331
420
|
* const probed = Effect.scoped(Effect.gen(function*() {
|
|
332
|
-
* const ref = yield*
|
|
421
|
+
* const ref = yield* LocalMachine.start(machine)
|
|
333
422
|
* const probe = yield* MachineTest.probe(machine, ref)
|
|
334
423
|
* return typeof probe
|
|
335
424
|
* }))
|
|
@@ -347,7 +436,7 @@ export declare const probe: <M extends AnyMachine, Error, Output>(machine: Ready
|
|
|
347
436
|
* @category utility types
|
|
348
437
|
* @since 0.4.0
|
|
349
438
|
*/
|
|
350
|
-
export type RuntimeInvariantErrorChannel<M extends AnyMachine> = Machine.Machine.Error<M> | Machine.
|
|
439
|
+
export type RuntimeInvariantErrorChannel<M extends AnyMachine> = Machine.Machine.Error<M> | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StoppedError;
|
|
351
440
|
/**
|
|
352
441
|
* A causal command record projected independently of a reference model.
|
|
353
442
|
*
|
|
@@ -659,10 +748,11 @@ export interface StateInvariantContext<M extends AnyMachine> {
|
|
|
659
748
|
readonly phase: StateObservation;
|
|
660
749
|
readonly eventIndex: number | undefined;
|
|
661
750
|
readonly microstepIndex: number | undefined;
|
|
662
|
-
readonly event: Machine.Machine.Event<M> | Machine.InitialEvent | undefined;
|
|
751
|
+
readonly event: Machine.Machine.Event<M> | Machine.InitialEvent | Machine.InvocationEvent | WorkOutcome | undefined;
|
|
663
752
|
}
|
|
664
753
|
/**
|
|
665
|
-
* Evidence passed to an invariant for one public event
|
|
754
|
+
* Evidence passed to an invariant for one step: a public event, or a result of
|
|
755
|
+
* invoked work.
|
|
666
756
|
*
|
|
667
757
|
* @category invariants
|
|
668
758
|
* @since 0.4.0
|
|
@@ -674,7 +764,7 @@ export interface StepInvariantContext<M extends AnyMachine> {
|
|
|
674
764
|
readonly index: number;
|
|
675
765
|
readonly before: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
676
766
|
readonly beforeConfiguration: ReadonlyArray<StatePath<M>>;
|
|
677
|
-
readonly event: Machine.Machine.InputEvent<M
|
|
767
|
+
readonly event: Machine.Machine.InputEvent<M> | WorkOutcome;
|
|
678
768
|
readonly plan: EventPlan<M>;
|
|
679
769
|
readonly after: Machine.Machine.Snapshot<Machine.Machine.States<M>>;
|
|
680
770
|
readonly afterConfiguration: ReadonlyArray<StatePath<M>>;
|
|
@@ -962,7 +1052,7 @@ export interface ExplorationNode<M extends AnyMachine, Key extends ExplorationKe
|
|
|
962
1052
|
* @since 0.4.0
|
|
963
1053
|
*/
|
|
964
1054
|
export interface ExplorationEdge<M extends AnyMachine> {
|
|
965
|
-
readonly event:
|
|
1055
|
+
readonly event: ScenarioEvent<M>;
|
|
966
1056
|
readonly step: TraceStep<M>;
|
|
967
1057
|
readonly discovered: boolean;
|
|
968
1058
|
}
|
|
@@ -976,19 +1066,19 @@ export type ExplorationFrontier<M extends AnyMachine, Key extends ExplorationKey
|
|
|
976
1066
|
readonly _tag: "DepthLimit";
|
|
977
1067
|
readonly source: Key;
|
|
978
1068
|
readonly trace: Trace<M>;
|
|
979
|
-
readonly event:
|
|
1069
|
+
readonly event: ScenarioEvent<M>;
|
|
980
1070
|
} | {
|
|
981
1071
|
readonly _tag: "StateLimit";
|
|
982
1072
|
readonly source: Key;
|
|
983
1073
|
readonly trace: Trace<M>;
|
|
984
|
-
readonly event:
|
|
1074
|
+
readonly event: ScenarioEvent<M>;
|
|
985
1075
|
readonly target: Key;
|
|
986
1076
|
readonly targetTrace: Trace<M>;
|
|
987
1077
|
} | {
|
|
988
1078
|
readonly _tag: "TransitionLimit";
|
|
989
1079
|
readonly source: Key;
|
|
990
1080
|
readonly trace: Trace<M>;
|
|
991
|
-
readonly event:
|
|
1081
|
+
readonly event: ScenarioEvent<M>;
|
|
992
1082
|
};
|
|
993
1083
|
/**
|
|
994
1084
|
* Honest completeness status for the supplied event representatives and state
|
|
@@ -1039,7 +1129,7 @@ export interface Exploration<M extends AnyMachine, Key extends ExplorationKey =
|
|
|
1039
1129
|
readonly completeness: ExplorationCompleteness<M, Key>;
|
|
1040
1130
|
}
|
|
1041
1131
|
type ExploreOptionsBase<M extends AnyMachine, Key extends ExplorationKey> = {
|
|
1042
|
-
readonly events: (context: ExplorationStateContext<M>) => ReadonlyArray<
|
|
1132
|
+
readonly events: (context: ExplorationStateContext<M>) => ReadonlyArray<ScenarioEvent<M>>;
|
|
1043
1133
|
readonly stateKey: (context: ExplorationStateContext<M>) => Key;
|
|
1044
1134
|
readonly limits?: ExplorationLimits;
|
|
1045
1135
|
readonly invariants?: ReadonlyArray<Invariant<M>>;
|
|
@@ -1063,8 +1153,11 @@ export type ExploreOptions<M extends AnyMachine, Key extends ExplorationKey = Ex
|
|
|
1063
1153
|
* Explores the bounded logical state graph in breadth-first order.
|
|
1064
1154
|
*
|
|
1065
1155
|
* Invariants are checked against startup and every concretely planned edge,
|
|
1066
|
-
* so a failure retains a shortest discovered counterexample.
|
|
1067
|
-
* and
|
|
1156
|
+
* so a failure retains a shortest discovered counterexample. Planned commands
|
|
1157
|
+
* and invocations are not executed. `events` may return {@link WorkOutcome}
|
|
1158
|
+
* results for the work in `trace.work`; nodes are identified by `stateKey`
|
|
1159
|
+
* alone, so include `trace.work` in the key when the same state can run
|
|
1160
|
+
* different work. `transitionCoverage` includes
|
|
1068
1161
|
* startup and every event plan that was actually computed, including a plan
|
|
1069
1162
|
* retained at a state-limit frontier. Depth- and transition-limit frontiers
|
|
1070
1163
|
* have no plan and therefore contribute no transition hits.
|
|
@@ -1187,7 +1280,7 @@ export type RunFailure<Cause, M extends AnyMachine = AnyMachine> = {
|
|
|
1187
1280
|
readonly scenario: Scenario<M>;
|
|
1188
1281
|
readonly phase: "event";
|
|
1189
1282
|
readonly eventIndex: number;
|
|
1190
|
-
readonly event:
|
|
1283
|
+
readonly event: ScenarioEvent<M>;
|
|
1191
1284
|
readonly initial: InitialTrace<M>;
|
|
1192
1285
|
readonly steps: ReadonlyArray<TraceStep<M>>;
|
|
1193
1286
|
readonly cause: Cause;
|
|
@@ -1198,26 +1291,35 @@ export type RunFailure<Cause, M extends AnyMachine = AnyMachine> = {
|
|
|
1198
1291
|
* @category errors
|
|
1199
1292
|
* @since 0.4.0
|
|
1200
1293
|
*/
|
|
1201
|
-
export type RunError<M extends AnyMachine> = Machine.Machine.
|
|
1294
|
+
export type RunError<M extends AnyMachine> = Machine.Machine.Error<M> | Machine.InfiniteTransitionError | Machine.MachineSchemaDecodeError | Machine.StartupError;
|
|
1202
1295
|
/**
|
|
1203
1296
|
* Services required while planning a complete scenario.
|
|
1204
1297
|
*
|
|
1205
1298
|
* Scenario execution delegates exclusively to the service-free `planInitial`
|
|
1206
|
-
* and `
|
|
1207
|
-
* later execution, not synchronous planning.
|
|
1299
|
+
* and `toStep` APIs, so it requires no services. Invoke services belong to
|
|
1300
|
+
* later execution, not synchronous planning. A machine whose services are erased to
|
|
1301
|
+
* `any` keeps `any`.
|
|
1208
1302
|
*
|
|
1209
1303
|
* @category models
|
|
1210
1304
|
* @since 0.4.0
|
|
1211
1305
|
*/
|
|
1212
|
-
export type RunServices<M extends AnyMachine> = IsAny<Machine.
|
|
1306
|
+
export type RunServices<M extends AnyMachine> = IsAny<Machine.Machine.Services<M>> extends true ? any : never;
|
|
1213
1307
|
/**
|
|
1214
|
-
* Executes a generated scenario exclusively through `planInitial` and
|
|
1308
|
+
* Executes a generated scenario exclusively through `planInitial` and the
|
|
1309
|
+
* step of `Machine.toStep`, whose plans are the ones `plan` returns.
|
|
1215
1310
|
*
|
|
1216
|
-
*
|
|
1311
|
+
* Commands are retained in each plan but are never executed. Every event
|
|
1217
1312
|
* is planned, including events that occur after a terminal configuration.
|
|
1218
1313
|
* Typed planning errors retain the scenario and successfully completed prefix
|
|
1219
1314
|
* in a `RunFailure`.
|
|
1220
1315
|
*
|
|
1316
|
+
* Work is never run, but the trace follows which work runs, in `work`, as the
|
|
1317
|
+
* step decides it for every host: work also ends when a transition stops the
|
|
1318
|
+
* child that it runs. A {@link WorkOutcome} in the scenario is planned for the
|
|
1319
|
+
* work it names while that work runs, and ignored once it no longer does. An
|
|
1320
|
+
* outcome that fails the machine is a `RunFailure` whose cause is the typed
|
|
1321
|
+
* failure, so the replay of a {@link check} finding reproduces it.
|
|
1322
|
+
*
|
|
1221
1323
|
* **Example** (Running a pure trace)
|
|
1222
1324
|
*
|
|
1223
1325
|
* ```ts import.meta.vitest
|
|
@@ -1394,6 +1496,8 @@ export interface MicrostepCoverageEvidence {
|
|
|
1394
1496
|
readonly alwaysTriggered: number;
|
|
1395
1497
|
readonly doneTriggered: number;
|
|
1396
1498
|
readonly choiceTriggered: number;
|
|
1499
|
+
/** Transitions taken for a result of invoked work. */
|
|
1500
|
+
readonly invokeTriggered: number;
|
|
1397
1501
|
}
|
|
1398
1502
|
/**
|
|
1399
1503
|
* Directly observed completion evidence.
|
|
@@ -1504,7 +1608,7 @@ export interface ObservedGraphNode<M extends AnyMachine> {
|
|
|
1504
1608
|
export interface ObservedGraphMicrostep<M extends AnyMachine> {
|
|
1505
1609
|
readonly next: string;
|
|
1506
1610
|
readonly event: Machine.Machine.Event<M> | Machine.InitialEvent;
|
|
1507
|
-
readonly transitions: Microstep<M
|
|
1611
|
+
readonly transitions: Microstep<M>["transitions"];
|
|
1508
1612
|
readonly raisedEvents: ReadonlyArray<Machine.Machine.Event<M>>;
|
|
1509
1613
|
readonly emittedEvents: ReadonlyArray<Machine.Machine.EmittedEvent<M>>;
|
|
1510
1614
|
readonly exitPaths: ReadonlyArray<StatePath<M>>;
|
|
@@ -1526,7 +1630,7 @@ export type ObservedGraphEdge<M extends AnyMachine> = {
|
|
|
1526
1630
|
readonly _tag: "Event";
|
|
1527
1631
|
readonly traceIndex: number;
|
|
1528
1632
|
readonly eventIndex: number;
|
|
1529
|
-
readonly event: Machine.Machine.InputEvent<M
|
|
1633
|
+
readonly event: Machine.Machine.InputEvent<M> | WorkOutcome;
|
|
1530
1634
|
readonly microsteps: ReadonlyArray<ObservedGraphMicrostep<M>>;
|
|
1531
1635
|
readonly completion: PlanCompletion<M>;
|
|
1532
1636
|
};
|
|
@@ -1694,7 +1798,13 @@ export type AnalysisFinding = {
|
|
|
1694
1798
|
*/
|
|
1695
1799
|
export declare const analyze: <M extends AnyMachine>(machine: M) => ReadonlyArray<AnalysisFinding>;
|
|
1696
1800
|
/**
|
|
1697
|
-
* The
|
|
1801
|
+
* The input and the steps that reproduce a finding from startup, in order.
|
|
1802
|
+
*
|
|
1803
|
+
* **Details**
|
|
1804
|
+
*
|
|
1805
|
+
* `events` is a scenario: its entries are public events and the
|
|
1806
|
+
* {@link WorkOutcome} results of invoked work, such as an elapsed timer or a
|
|
1807
|
+
* supplied Effect output. Pass the replay to {@link run} to plan it again.
|
|
1698
1808
|
*
|
|
1699
1809
|
* @category models
|
|
1700
1810
|
* @since 0.47.0
|
|
@@ -1719,10 +1829,18 @@ export type CheckExplorationLimit =
|
|
|
1719
1829
|
| "sampledInput"
|
|
1720
1830
|
/** Exploration used caller-supplied events. */
|
|
1721
1831
|
| "customEvents"
|
|
1832
|
+
/** Exploration used caller-supplied results of invoked Effects. */
|
|
1833
|
+
| "customOutcomes"
|
|
1722
1834
|
/** A caller-supplied state key may merge distinct snapshots. */
|
|
1723
1835
|
| "customStateKey"
|
|
1724
|
-
/**
|
|
1725
|
-
| "
|
|
1836
|
+
/** An Effect ran whose results were not supplied, so none of them was explored. */
|
|
1837
|
+
| "effectsWithoutOutcomes"
|
|
1838
|
+
/** A Stream ran. Its elements and its end were not explored. */
|
|
1839
|
+
| "streams"
|
|
1840
|
+
/** Logic ran. Its snapshots and its end were not explored. */
|
|
1841
|
+
| "logic"
|
|
1842
|
+
/** A child machine ran. Its snapshots and its end were not explored. */
|
|
1843
|
+
| "children";
|
|
1726
1844
|
/**
|
|
1727
1845
|
* A problem found by {@link check}. An `"error"` finding fails the report and a
|
|
1728
1846
|
* `"warning"` does not.
|
|
@@ -1758,6 +1876,24 @@ export type CheckFinding = AnalysisFinding | {
|
|
|
1758
1876
|
readonly invariant: string;
|
|
1759
1877
|
readonly replay: CheckReplay;
|
|
1760
1878
|
readonly message: string;
|
|
1879
|
+
} | {
|
|
1880
|
+
readonly law: "outcomes.invalid";
|
|
1881
|
+
readonly severity: "error";
|
|
1882
|
+
/** The name the outcomes were supplied under. */
|
|
1883
|
+
readonly source: string;
|
|
1884
|
+
readonly message: string;
|
|
1885
|
+
} | {
|
|
1886
|
+
/**
|
|
1887
|
+
* A supplied result fails the machine. The compiler requires `onFailure`
|
|
1888
|
+
* for a typed failure and `onDone` for a result, so this happens only when
|
|
1889
|
+
* the machine's types were erased.
|
|
1890
|
+
*/
|
|
1891
|
+
readonly law: "outcome.failsMachine";
|
|
1892
|
+
readonly severity: "error";
|
|
1893
|
+
/** The registered name of the source whose result fails the machine. */
|
|
1894
|
+
readonly source: string | undefined;
|
|
1895
|
+
readonly replay: CheckReplay;
|
|
1896
|
+
readonly message: string;
|
|
1761
1897
|
} | {
|
|
1762
1898
|
readonly law: "transition.notCovered";
|
|
1763
1899
|
readonly severity: "warning";
|
|
@@ -1797,6 +1933,35 @@ export interface CheckReport {
|
|
|
1797
1933
|
};
|
|
1798
1934
|
readonly findings: ReadonlyArray<CheckFinding>;
|
|
1799
1935
|
}
|
|
1936
|
+
/**
|
|
1937
|
+
* The results to try for one Effect source: each value is one branch of
|
|
1938
|
+
* exploration, taken wherever the source runs.
|
|
1939
|
+
*
|
|
1940
|
+
* `failure` is accepted only when the Effect has a typed failure.
|
|
1941
|
+
*
|
|
1942
|
+
* @category models
|
|
1943
|
+
* @since 0.48.0
|
|
1944
|
+
*/
|
|
1945
|
+
export type CheckOutcome<Result extends Machine.Machine.EffectResult<any, any>> = {
|
|
1946
|
+
readonly done?: ReadonlyArray<Result["done"]>;
|
|
1947
|
+
} & ([Result["failure"]] extends [never] ? {
|
|
1948
|
+
readonly failure?: never;
|
|
1949
|
+
} : {
|
|
1950
|
+
readonly failure?: ReadonlyArray<Result["failure"]>;
|
|
1951
|
+
});
|
|
1952
|
+
/**
|
|
1953
|
+
* The results to try for the Effect sources of a machine, keyed by registered
|
|
1954
|
+
* source name and typed from each source's Effect.
|
|
1955
|
+
*
|
|
1956
|
+
* A machine whose type no longer carries the result types of its sources,
|
|
1957
|
+
* because it was widened by an annotation, accepts no outcomes.
|
|
1958
|
+
*
|
|
1959
|
+
* @category models
|
|
1960
|
+
* @since 0.48.0
|
|
1961
|
+
*/
|
|
1962
|
+
export type CheckOutcomes<M extends AnyMachine> = [Machine.Machine.EffectResults<M>] extends [never] ? never : {
|
|
1963
|
+
readonly [K in keyof Machine.Machine.EffectResults<M>]?: CheckOutcome<Machine.Machine.EffectResults<M>[K]>;
|
|
1964
|
+
};
|
|
1800
1965
|
/**
|
|
1801
1966
|
* Options for {@link check}. Every option has a default derived from the machine.
|
|
1802
1967
|
*
|
|
@@ -1808,6 +1973,11 @@ export interface CheckOptions<M extends AnyMachine> {
|
|
|
1808
1973
|
readonly input?: InputValue<M>;
|
|
1809
1974
|
/** Events to try in every state. Defaults to samples derived from the event schemas. */
|
|
1810
1975
|
readonly events?: ReadonlyArray<Machine.Machine.EventInput<Machine.Machine.InputEvent<M>>>;
|
|
1976
|
+
/**
|
|
1977
|
+
* Results to try for invoked Effects, keyed by source name. Without an entry,
|
|
1978
|
+
* an Effect's results are not explored.
|
|
1979
|
+
*/
|
|
1980
|
+
readonly outcomes?: CheckOutcomes<M>;
|
|
1811
1981
|
/** Distinct values to sample for each event tag. Defaults to 3. */
|
|
1812
1982
|
readonly eventSamples?: number;
|
|
1813
1983
|
/** Seed for sampled input and events. Defaults to 0, so reports are reproducible. */
|
|
@@ -1835,15 +2005,26 @@ export interface CheckOptions<M extends AnyMachine> {
|
|
|
1835
2005
|
* transition a second time, so nondeterminism is found even when hidden behind a
|
|
1836
2006
|
* helper. Declared branches that were never taken are reported as warnings.
|
|
1837
2007
|
*
|
|
2008
|
+
* Work never runs, but exploration takes its results as further branches while
|
|
2009
|
+
* the work runs: a running timer elapses, and a running Effect reports each
|
|
2010
|
+
* value supplied for its source in `outcomes`. A result is offered once per
|
|
2011
|
+
* entry of the state that invoked the work, so a node is a state together with
|
|
2012
|
+
* the work still running in it. Each result is planned and checked like an
|
|
2013
|
+
* event. A supplied result that fails the machine, because its work has no
|
|
2014
|
+
* `onFailure` or no `onDone`, is an `"outcome.failsMachine"` error. The compiler
|
|
2015
|
+
* requires both handlers, so this happens only when the machine's types were
|
|
2016
|
+
* erased.
|
|
2017
|
+
*
|
|
1838
2018
|
* Findings are returned rather than failed, so the Effect only fails on
|
|
1839
2019
|
* interruption. Each finding that came from running the machine includes the
|
|
1840
|
-
* events that reproduce it.
|
|
2020
|
+
* events and results that reproduce it, which {@link run} plans again.
|
|
1841
2021
|
*
|
|
1842
2022
|
* **Gotchas**
|
|
1843
2023
|
*
|
|
1844
2024
|
* A passing `"bounded"` report means nothing was found in what was explored. It
|
|
1845
|
-
* is not a proof.
|
|
1846
|
-
*
|
|
2025
|
+
* is not a proof. The results of an Effect without `outcomes`, and of Streams,
|
|
2026
|
+
* logic, and child machines, are not explored, and `limits` names each one that
|
|
2027
|
+
* ran. Test those with {@link probe} on a started machine.
|
|
1847
2028
|
*
|
|
1848
2029
|
* **Example** (Finding nondeterministic planning)
|
|
1849
2030
|
*
|
|
@@ -1871,6 +2052,41 @@ export interface CheckOptions<M extends AnyMachine> {
|
|
|
1871
2052
|
* report.findings.map((finding) => finding.law) // => ["planning.deterministic"]
|
|
1872
2053
|
* ```
|
|
1873
2054
|
*
|
|
2055
|
+
* **Example** (Visiting the states behind invoked work)
|
|
2056
|
+
*
|
|
2057
|
+
* ```ts import.meta.vitest
|
|
2058
|
+
* import { Machine } from "@typeonce/effect-machine"
|
|
2059
|
+
* import { MachineTest } from "@typeonce/effect-machine/testing"
|
|
2060
|
+
* import { Data, Effect } from "effect"
|
|
2061
|
+
*
|
|
2062
|
+
* class LoadError extends Data.TaggedError("LoadError")<{}> {}
|
|
2063
|
+
* const loadDocument: Effect.Effect<string, LoadError> = Effect.succeed("# Title")
|
|
2064
|
+
*
|
|
2065
|
+
* const machine = Machine.make({
|
|
2066
|
+
* root: Machine.state({ states: { Loading: {}, Ready: {}, Failed: {}, TimedOut: {} } }),
|
|
2067
|
+
* events: Machine.events({}),
|
|
2068
|
+
* effects: { loadDocument },
|
|
2069
|
+
* timers: { timeout: "5 seconds" }
|
|
2070
|
+
* }).handle({
|
|
2071
|
+
* initial: { target: "Loading" },
|
|
2072
|
+
* states: {
|
|
2073
|
+
* Loading: {
|
|
2074
|
+
* invoke: [
|
|
2075
|
+
* { src: "loadDocument", onDone: { target: "Ready" }, onFailure: { target: "Failed" } },
|
|
2076
|
+
* { src: "timeout", onDone: { target: "TimedOut" } }
|
|
2077
|
+
* ]
|
|
2078
|
+
* }
|
|
2079
|
+
* }
|
|
2080
|
+
* })
|
|
2081
|
+
*
|
|
2082
|
+
* const report = await Effect.runPromise(MachineTest.check(machine, {
|
|
2083
|
+
* outcomes: { loadDocument: { done: ["# Title"], failure: [new LoadError()] } }
|
|
2084
|
+
* }))
|
|
2085
|
+
*
|
|
2086
|
+
* report.stats.states // => 4
|
|
2087
|
+
* report.limits // => ["customOutcomes"]
|
|
2088
|
+
* ```
|
|
2089
|
+
*
|
|
1874
2090
|
* @category verification
|
|
1875
2091
|
* @since 0.47.0
|
|
1876
2092
|
*/
|