@typeonce/effect-machine 0.4.0 → 0.5.1
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 +166 -588
- package/dist/Machine.d.ts +426 -240
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +219 -43
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/activities.d.ts +1 -1
- package/dist/internal/machine/activities.js +1 -1
- package/dist/internal/machine/atom.d.ts +1 -1
- package/dist/internal/machine/atom.js +1 -1
- package/dist/internal/machine/cluster.d.ts +2 -2
- package/dist/internal/machine/cluster.js +1 -1
- package/dist/internal/machine/command.d.ts +1 -1
- package/dist/internal/machine/command.js +1 -1
- package/dist/internal/machine/commandRuntime.d.ts +1 -1
- package/dist/internal/machine/commandRuntime.js +1 -1
- package/dist/internal/machine/configuration.d.ts +1 -1
- package/dist/internal/machine/configuration.js +1 -1
- package/dist/internal/machine/errors.d.ts +7 -7
- package/dist/internal/machine/errors.js +7 -7
- package/dist/internal/machine/executionPlan.d.ts +2 -2
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +17 -8
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts +1 -1
- package/dist/internal/machine/invocation.js +1 -1
- package/dist/internal/machine/planner.d.ts +1 -1
- package/dist/internal/machine/planner.js +1 -1
- package/dist/internal/machine/process.d.ts +1 -1
- package/dist/internal/machine/process.d.ts.map +1 -1
- package/dist/internal/machine/process.js +76 -24
- package/dist/internal/machine/process.js.map +1 -1
- package/dist/internal/machine/protocol.d.ts +1 -1
- package/dist/internal/machine/protocol.js +1 -1
- package/dist/internal/machine/runtime.d.ts +32 -4
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +120 -12
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/serialization.d.ts +1 -1
- package/dist/internal/machine/serialization.js +1 -1
- package/dist/internal/machine/topology.d.ts +1 -1
- package/dist/internal/machine/topology.js +1 -1
- package/dist/internal/testing/machine/arbitrary.d.ts +3 -3
- package/dist/internal/testing/machine/exploration.d.ts +30 -0
- package/dist/internal/testing/machine/exploration.d.ts.map +1 -0
- package/dist/internal/testing/machine/exploration.js +237 -0
- package/dist/internal/testing/machine/exploration.js.map +1 -0
- package/dist/internal/testing/machine/finiteModel.d.ts +20 -20
- package/dist/internal/testing/machine/finiteModel.js +2 -2
- package/dist/internal/testing/machine/invariant.d.ts +31 -0
- package/dist/internal/testing/machine/invariant.d.ts.map +1 -0
- package/dist/internal/testing/machine/invariant.js +214 -0
- package/dist/internal/testing/machine/invariant.js.map +1 -0
- package/dist/internal/testing/machine/probe.d.ts +26 -0
- package/dist/internal/testing/machine/probe.d.ts.map +1 -0
- package/dist/internal/testing/machine/probe.js +45 -0
- package/dist/internal/testing/machine/probe.js.map +1 -0
- package/dist/internal/testing/machine/referenceModel.d.ts +14 -14
- package/dist/internal/testing/machine/referenceModel.js +2 -2
- package/dist/internal/testing/machine/runtime.d.ts +329 -26
- package/dist/internal/testing/machine/runtime.d.ts.map +1 -1
- package/dist/internal/testing/machine/runtime.js +303 -14
- package/dist/internal/testing/machine/runtime.js.map +1 -1
- package/dist/internal/testing/machine/runtimeInvariant.d.ts +32 -0
- package/dist/internal/testing/machine/runtimeInvariant.d.ts.map +1 -0
- package/dist/internal/testing/machine/runtimeInvariant.js +334 -0
- package/dist/internal/testing/machine/runtimeInvariant.js.map +1 -0
- package/dist/internal/testing/machine/trace.d.ts +17 -0
- package/dist/internal/testing/machine/trace.d.ts.map +1 -0
- package/dist/internal/testing/machine/trace.js +94 -0
- package/dist/internal/testing/machine/trace.js.map +1 -0
- package/dist/internal/testing/machine/verification.d.ts +9 -6
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +8 -79
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +1029 -47
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js +315 -11
- package/dist/testing/MachineTest.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/unstable/cluster/ClusterMachine.d.ts +38 -19
- package/dist/unstable/cluster/ClusterMachine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterMachine.js +27 -9
- package/dist/unstable/cluster/ClusterMachine.js.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.d.ts +82 -31
- package/dist/unstable/reactivity/AtomMachine.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomMachine.js +63 -12
- package/dist/unstable/reactivity/AtomMachine.js.map +1 -1
- package/docs/agent-guide.md +160 -18
- package/package.json +11 -2
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-defined semantic invariants over planner traces.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Data from "effect/Data";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Machine from "../../../Machine.js";
|
|
9
|
+
const validateName = (name) => {
|
|
10
|
+
if (name.trim().length === 0) {
|
|
11
|
+
throw new Error("MachineTest.Invariant expected name to be a non-empty string");
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const validateRequirement = (options) => {
|
|
15
|
+
const minimum = options.require?.minObservations;
|
|
16
|
+
if (minimum !== undefined && (!Number.isSafeInteger(minimum) || minimum < 0)) {
|
|
17
|
+
throw new Error("MachineTest.Invariant expected minObservations to be a non-negative safe integer");
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const stateInvariant = (name, check, options = {}) => {
|
|
21
|
+
validateName(name);
|
|
22
|
+
validateRequirement(options);
|
|
23
|
+
return Object.freeze({
|
|
24
|
+
_tag: "StateInvariant",
|
|
25
|
+
name,
|
|
26
|
+
observe: options.observe ?? "settled",
|
|
27
|
+
check,
|
|
28
|
+
...(options.when === undefined ? {} : { when: options.when }),
|
|
29
|
+
...(options.require === undefined ? {} : { require: Object.freeze({ ...options.require }) })
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export const stepInvariant = (name, check, options = {}) => {
|
|
33
|
+
validateName(name);
|
|
34
|
+
validateRequirement(options);
|
|
35
|
+
return Object.freeze({
|
|
36
|
+
_tag: "StepInvariant",
|
|
37
|
+
name,
|
|
38
|
+
check,
|
|
39
|
+
...(options.when === undefined ? {} : { when: options.when }),
|
|
40
|
+
...(options.require === undefined ? {} : { require: Object.freeze({ ...options.require }) })
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export const traceInvariant = (name, check, options = {}) => {
|
|
44
|
+
validateName(name);
|
|
45
|
+
validateRequirement(options);
|
|
46
|
+
return Object.freeze({
|
|
47
|
+
_tag: "TraceInvariant",
|
|
48
|
+
name,
|
|
49
|
+
check,
|
|
50
|
+
...(options.when === undefined ? {} : { when: options.when }),
|
|
51
|
+
...(options.require === undefined ? {} : { require: Object.freeze({ ...options.require }) })
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
export const Invariant = Object.freeze({
|
|
55
|
+
state: stateInvariant,
|
|
56
|
+
step: stepInvariant,
|
|
57
|
+
trace: traceInvariant
|
|
58
|
+
});
|
|
59
|
+
export const invariants = (_machine) => Object.freeze({
|
|
60
|
+
state: (name, check, options) => stateInvariant(name, check, options),
|
|
61
|
+
step: (name, check, options) => stepInvariant(name, check, options),
|
|
62
|
+
trace: (name, check, options) => traceInvariant(name, check, options)
|
|
63
|
+
});
|
|
64
|
+
export class InvariantError extends Data.TaggedError("MachineTestInvariantError") {
|
|
65
|
+
}
|
|
66
|
+
const configuration = (machine, snapshot) => Machine.configuration(machine, snapshot).map(({ path }) => path);
|
|
67
|
+
const stateObservations = (machine, trace, observe) => {
|
|
68
|
+
const observations = [];
|
|
69
|
+
let observationIndex = 0;
|
|
70
|
+
const add = (snapshot, paths, phase, eventIndex, microstepIndex, event) => {
|
|
71
|
+
const context = {
|
|
72
|
+
machine,
|
|
73
|
+
trace,
|
|
74
|
+
snapshot,
|
|
75
|
+
configuration: paths,
|
|
76
|
+
observationIndex,
|
|
77
|
+
phase,
|
|
78
|
+
eventIndex,
|
|
79
|
+
microstepIndex,
|
|
80
|
+
event
|
|
81
|
+
};
|
|
82
|
+
observations.push({
|
|
83
|
+
context,
|
|
84
|
+
observationIndex,
|
|
85
|
+
eventIndex,
|
|
86
|
+
...(microstepIndex === undefined ? {} : { microstepIndex }),
|
|
87
|
+
phase,
|
|
88
|
+
configuration: paths,
|
|
89
|
+
...(event === undefined ? {} : { event })
|
|
90
|
+
});
|
|
91
|
+
observationIndex += 1;
|
|
92
|
+
};
|
|
93
|
+
if (observe === "final") {
|
|
94
|
+
add(trace.final, trace.finalConfiguration, "final", undefined, undefined, undefined);
|
|
95
|
+
return observations;
|
|
96
|
+
}
|
|
97
|
+
if (observe === "settled" || observe === "all") {
|
|
98
|
+
add(trace.initial.plan.state, trace.initial.configuration, "initial", undefined, undefined, undefined);
|
|
99
|
+
}
|
|
100
|
+
if (observe === "microsteps" || observe === "all") {
|
|
101
|
+
trace.initial.plan.microsteps.forEach((microstep, microstepIndex) => {
|
|
102
|
+
add(microstep.next, configuration(machine, microstep.next), "microstep", undefined, microstepIndex, microstep.event);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
for (const step of trace.steps) {
|
|
106
|
+
if (observe === "microsteps" || observe === "all") {
|
|
107
|
+
step.plan.microsteps.forEach((microstep, microstepIndex) => {
|
|
108
|
+
add(microstep.next, configuration(machine, microstep.next), "microstep", step.index, microstepIndex, microstep.event);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (observe === "settled" || observe === "all") {
|
|
112
|
+
add(step.after, step.afterConfiguration, "event", step.index, undefined, step.event);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return observations;
|
|
116
|
+
};
|
|
117
|
+
const stepObservations = (machine, trace) => trace.steps.map((step) => ({
|
|
118
|
+
context: {
|
|
119
|
+
machine,
|
|
120
|
+
trace,
|
|
121
|
+
step,
|
|
122
|
+
index: step.index,
|
|
123
|
+
before: step.before,
|
|
124
|
+
beforeConfiguration: step.beforeConfiguration,
|
|
125
|
+
event: step.event,
|
|
126
|
+
plan: step.plan,
|
|
127
|
+
after: step.after,
|
|
128
|
+
afterConfiguration: step.afterConfiguration
|
|
129
|
+
},
|
|
130
|
+
eventIndex: step.index,
|
|
131
|
+
event: step.event
|
|
132
|
+
}));
|
|
133
|
+
const traceObservations = (machine, trace) => [{
|
|
134
|
+
context: { machine, trace },
|
|
135
|
+
eventIndex: undefined
|
|
136
|
+
}];
|
|
137
|
+
const scopeOf = (invariant) => {
|
|
138
|
+
switch (invariant._tag) {
|
|
139
|
+
case "StateInvariant":
|
|
140
|
+
return "state";
|
|
141
|
+
case "StepInvariant":
|
|
142
|
+
return "step";
|
|
143
|
+
case "TraceInvariant":
|
|
144
|
+
return "trace";
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const messageOf = (outcome) => outcome === true ? undefined : typeof outcome === "string" ? outcome : "Invariant predicate returned false";
|
|
148
|
+
const evaluateInvariant = (invariant, scope, observations) => {
|
|
149
|
+
let observed = 0;
|
|
150
|
+
let failures = 0;
|
|
151
|
+
const violations = [];
|
|
152
|
+
for (const observation of observations) {
|
|
153
|
+
if (invariant.when !== undefined && !invariant.when(observation.context))
|
|
154
|
+
continue;
|
|
155
|
+
observed += 1;
|
|
156
|
+
const message = messageOf(invariant.check(observation.context));
|
|
157
|
+
if (message === undefined)
|
|
158
|
+
continue;
|
|
159
|
+
failures += 1;
|
|
160
|
+
violations.push({
|
|
161
|
+
invariant: invariant.name,
|
|
162
|
+
scope,
|
|
163
|
+
kind: "predicate",
|
|
164
|
+
...(observation.observationIndex === undefined ? {} : { observationIndex: observation.observationIndex }),
|
|
165
|
+
eventIndex: observation.eventIndex,
|
|
166
|
+
...(observation.microstepIndex === undefined ? {} : { microstepIndex: observation.microstepIndex }),
|
|
167
|
+
...(observation.phase === undefined ? {} : { phase: observation.phase }),
|
|
168
|
+
...(observation.configuration === undefined ? {} : { configuration: observation.configuration }),
|
|
169
|
+
...(observation.event === undefined ? {} : { event: observation.event }),
|
|
170
|
+
message
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const minimum = invariant.require?.minObservations ?? 0;
|
|
174
|
+
const insufficient = observed < minimum;
|
|
175
|
+
if (insufficient) {
|
|
176
|
+
violations.push({
|
|
177
|
+
invariant: invariant.name,
|
|
178
|
+
scope,
|
|
179
|
+
kind: "observations",
|
|
180
|
+
eventIndex: undefined,
|
|
181
|
+
message: `Invariant required at least ${minimum} observation${minimum === 1 ? "" : "s"} but observed ${observed}`
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
check: {
|
|
186
|
+
invariant: invariant.name,
|
|
187
|
+
scope,
|
|
188
|
+
status: failures > 0 ? "failed" : insufficient ? "insufficient" : observed === 0 ? "untested" : "passed",
|
|
189
|
+
observations: observed,
|
|
190
|
+
failures
|
|
191
|
+
},
|
|
192
|
+
violations
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
export const checkInvariants = (machine, trace, invariants) => Effect.suspend(() => {
|
|
196
|
+
const checks = [];
|
|
197
|
+
const violations = [];
|
|
198
|
+
for (const invariant of invariants) {
|
|
199
|
+
const scope = scopeOf(invariant);
|
|
200
|
+
const result = invariant._tag === "StateInvariant"
|
|
201
|
+
? evaluateInvariant(invariant, scope, stateObservations(machine, trace, invariant.observe))
|
|
202
|
+
: invariant._tag === "StepInvariant"
|
|
203
|
+
? evaluateInvariant(invariant, scope, stepObservations(machine, trace))
|
|
204
|
+
: evaluateInvariant(invariant, scope, traceObservations(machine, trace));
|
|
205
|
+
checks.push(result.check);
|
|
206
|
+
violations.push(...result.violations);
|
|
207
|
+
}
|
|
208
|
+
const report = { checks };
|
|
209
|
+
return violations.length === 0
|
|
210
|
+
? Effect.succeed(report)
|
|
211
|
+
: Effect.fail(new InvariantError({ trace, violations, report }));
|
|
212
|
+
});
|
|
213
|
+
export const assertInvariants = (machine, trace, invariants) => checkInvariants(machine, trace, invariants).pipe(Effect.asVoid);
|
|
214
|
+
//# sourceMappingURL=invariant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.js","sourceRoot":"","sources":["../../../../src/internal/testing/machine/invariant.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAmC9C,MAAM,YAAY,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC1C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAA;IACjF,CAAC;AACH,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAU,OAAkC,EAAQ,EAAE;IAChF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,eAAe,CAAA;IAChD,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAA;IACrG,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,KAA8D,EAC9D,UAAoC,EAAE,EACnB,EAAE;IACrB,YAAY,CAAC,IAAI,CAAC,CAAA;IAClB,mBAAmB,CAAC,OAAO,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,gBAAyB;QAC/B,IAAI;QACJ,OAAO,EAAE,OAAO,C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AAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;YAC3F,CAAC,CAAC,SAAS,CAAC,IAAI,KAAK,eAAe;gBACpC,CAAC,CAAC,iBAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBACvE,CAAC,CAAC,iBAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;QAC1E,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACzB,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;IACvC,CAAC;IAED,MAAM,MAAM,GAAoB,EAAE,MAAM,EAAE,CAAA;IAC1C,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC;QAC5B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AACpE,CAAC,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAU,EACV,KAAe,EACf,UAA8C,EACN,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Causal testing access to a running statechart.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import type * as Machine from "../../../Machine.js";
|
|
8
|
+
import type { Probe } from "../../../testing/MachineTest.js";
|
|
9
|
+
type AnyMachine = Machine.Machine.Any;
|
|
10
|
+
declare const ProbeUnavailableError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
11
|
+
readonly _tag: "MachineTestProbeUnavailableError";
|
|
12
|
+
} & Readonly<A>;
|
|
13
|
+
/**
|
|
14
|
+
* Raised when a reference was not created by the managed statechart runtime.
|
|
15
|
+
*
|
|
16
|
+
* @category errors
|
|
17
|
+
* @since 0.4.0
|
|
18
|
+
*/
|
|
19
|
+
export declare class ProbeUnavailableError extends ProbeUnavailableError_base<{
|
|
20
|
+
readonly message: string;
|
|
21
|
+
}> {
|
|
22
|
+
}
|
|
23
|
+
/** @internal */
|
|
24
|
+
export declare const probe: <M extends AnyMachine, Error, Output>(machine: M, ref: Machine.MachineRef<Machine.Machine.Snapshot<Machine.Machine.States<M>>, Machine.Machine.InputEvent<M>, Error, Output>) => Effect.Effect<Probe<M, Error, Output>, ProbeUnavailableError>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../../../src/internal/testing/machine/probe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,OAAO,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,iCAAiC,CAAA;AAGvE,KAAK,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAA;;;;AAErC;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,2BAAqD;IAC9F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAC;CAAG;AAEL,gBAAgB;AAChB,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,EACvD,SAAS,CAAC,EACV,KAAK,OAAO,CAAC,UAAU,CACrB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAC7B,KAAK,EACL,MAAM,CACP,KACA,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,qBAAqB,CA6C9D,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Causal testing access to a running statechart.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Data from "effect/Data";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Runtime from "../../machine/runtime.js";
|
|
9
|
+
/**
|
|
10
|
+
* Raised when a reference was not created by the managed statechart runtime.
|
|
11
|
+
*
|
|
12
|
+
* @category errors
|
|
13
|
+
* @since 0.4.0
|
|
14
|
+
*/
|
|
15
|
+
export class ProbeUnavailableError extends Data.TaggedError("MachineTestProbeUnavailableError") {
|
|
16
|
+
}
|
|
17
|
+
/** @internal */
|
|
18
|
+
export const probe = (machine, ref) => {
|
|
19
|
+
const acknowledged = ref[Runtime.acknowledgedSend];
|
|
20
|
+
if (acknowledged === undefined) {
|
|
21
|
+
return Effect.fail(new ProbeUnavailableError({
|
|
22
|
+
message: "MachineTest.probe requires a managed statechart reference created by Machine.start or Machine.resume"
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
return Effect.succeed(Object.freeze({
|
|
26
|
+
machine,
|
|
27
|
+
ref,
|
|
28
|
+
await: Object.freeze({
|
|
29
|
+
none: { _tag: "None" },
|
|
30
|
+
until: (predicate) => ({ _tag: "Until", predicate })
|
|
31
|
+
}),
|
|
32
|
+
sendAndAwait: (event) => acknowledged.call(ref, event).pipe(Effect.map(({ after, before, plan }) => {
|
|
33
|
+
const eventPlan = plan;
|
|
34
|
+
return Object.freeze({
|
|
35
|
+
event,
|
|
36
|
+
before,
|
|
37
|
+
plan: eventPlan,
|
|
38
|
+
after,
|
|
39
|
+
handled: eventPlan.microsteps.length > 0,
|
|
40
|
+
configurationChanged: eventPlan.microsteps.some((microstep) => microstep.changed)
|
|
41
|
+
});
|
|
42
|
+
}))
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../../../../src/internal/testing/machine/probe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AAInD;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,kCAAkC,CAE5F;CAAG;AAEL,gBAAgB;AAChB,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,OAAU,EACV,GAKC,EAC8D,EAAE;IACjE,MAAM,YAAY,GAAI,GAKpB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC5B,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,qBAAqB,CAAC;YACxB,OAAO,EAAE,sGAAsG;SAChH,CAAC,CACH,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAClC,OAAO;QACP,GAAG;QACH,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;YACnB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAW;YAC/B,KAAK,EAAE,CACL,SAMY,EACZ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAY,CAAA;SAC7C,CAAC;QACF,YAAY,EAAE,CAAC,KAAoC,EAAE,EAAE,CACrD,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,IAAI,CAChC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;YACrC,MAAM,SAAS,GAAG,IAAoB,CAAA;YACtC,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,KAAK;gBACL,MAAM;gBACN,IAAI,EAAE,SAAS;gBACf,KAAK;gBACL,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;gBACxC,oBAAoB,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;aAClF,CAAC,CAAA;QACJ,CAAC,CAAC,CACH;KACJ,CAAC,CAAC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -15,7 +15,7 @@ import type { FiniteModel } from "./finiteModel.js";
|
|
|
15
15
|
* The deterministic value assigned to one active finite-model state.
|
|
16
16
|
*
|
|
17
17
|
* @category models
|
|
18
|
-
* @since 4.0
|
|
18
|
+
* @since 0.4.0
|
|
19
19
|
*/
|
|
20
20
|
export interface ReferenceStateValue {
|
|
21
21
|
readonly _tag: string;
|
|
@@ -25,7 +25,7 @@ export interface ReferenceStateValue {
|
|
|
25
25
|
* One output retained for an actively completed state.
|
|
26
26
|
*
|
|
27
27
|
* @category models
|
|
28
|
-
* @since 4.0
|
|
28
|
+
* @since 0.4.0
|
|
29
29
|
*/
|
|
30
30
|
export interface ReferenceCompletion {
|
|
31
31
|
readonly path: string;
|
|
@@ -35,7 +35,7 @@ export interface ReferenceCompletion {
|
|
|
35
35
|
* One independently captured shallow or deep history register.
|
|
36
36
|
*
|
|
37
37
|
* @category models
|
|
38
|
-
* @since 4.0
|
|
38
|
+
* @since 0.4.0
|
|
39
39
|
*/
|
|
40
40
|
export interface ReferenceHistoryRecord {
|
|
41
41
|
readonly mode: "shallow" | "deep";
|
|
@@ -46,7 +46,7 @@ export interface ReferenceHistoryRecord {
|
|
|
46
46
|
* An independently interpreted finite-model configuration.
|
|
47
47
|
*
|
|
48
48
|
* @category models
|
|
49
|
-
* @since 4.0
|
|
49
|
+
* @since 0.4.0
|
|
50
50
|
*/
|
|
51
51
|
export interface ReferenceState {
|
|
52
52
|
/** Active ancestors and leaf in state-definition order. */
|
|
@@ -64,7 +64,7 @@ export interface ReferenceState {
|
|
|
64
64
|
* One transition retained by the independent reference step.
|
|
65
65
|
*
|
|
66
66
|
* @category models
|
|
67
|
-
* @since 4.0
|
|
67
|
+
* @since 0.4.0
|
|
68
68
|
*/
|
|
69
69
|
export interface ReferenceTransition {
|
|
70
70
|
readonly source: string;
|
|
@@ -86,7 +86,7 @@ export interface ReferenceTransition {
|
|
|
86
86
|
* The independently calculated planner microstep for one selected event.
|
|
87
87
|
*
|
|
88
88
|
* @category models
|
|
89
|
-
* @since 4.0
|
|
89
|
+
* @since 0.4.0
|
|
90
90
|
*/
|
|
91
91
|
export interface ReferenceMicrostep {
|
|
92
92
|
readonly next: ReferenceState;
|
|
@@ -100,7 +100,7 @@ export interface ReferenceMicrostep {
|
|
|
100
100
|
* Startup semantics calculated without executing the real machine.
|
|
101
101
|
*
|
|
102
102
|
* @category models
|
|
103
|
-
* @since 4.0
|
|
103
|
+
* @since 0.4.0
|
|
104
104
|
*/
|
|
105
105
|
export interface ReferenceInitialStep {
|
|
106
106
|
readonly startingState: ReferenceState;
|
|
@@ -114,7 +114,7 @@ export interface ReferenceInitialStep {
|
|
|
114
114
|
* One public event interpreted against a reference configuration.
|
|
115
115
|
*
|
|
116
116
|
* @category models
|
|
117
|
-
* @since 4.0
|
|
117
|
+
* @since 0.4.0
|
|
118
118
|
*/
|
|
119
119
|
export interface ReferenceStep {
|
|
120
120
|
readonly index: number;
|
|
@@ -129,7 +129,7 @@ export interface ReferenceStep {
|
|
|
129
129
|
* A complete, pure interpretation of a finite model and event sequence.
|
|
130
130
|
*
|
|
131
131
|
* @category models
|
|
132
|
-
* @since 4.0
|
|
132
|
+
* @since 0.4.0
|
|
133
133
|
*/
|
|
134
134
|
export interface ReferenceTrace {
|
|
135
135
|
readonly events: ReadonlyArray<string>;
|
|
@@ -141,7 +141,7 @@ export interface ReferenceTrace {
|
|
|
141
141
|
* Location of one planner/reference disagreement.
|
|
142
142
|
*
|
|
143
143
|
* @category models
|
|
144
|
-
* @since 4.0
|
|
144
|
+
* @since 0.4.0
|
|
145
145
|
*/
|
|
146
146
|
export interface ModelVerificationLocation {
|
|
147
147
|
readonly phase: "initial" | "event" | "final";
|
|
@@ -153,14 +153,14 @@ type ModelStateField = "initial.startingState" | "initial.plan.startingState" |
|
|
|
153
153
|
* Stable semantic observation compared by the finite-model oracle.
|
|
154
154
|
*
|
|
155
155
|
* @category models
|
|
156
|
-
* @since 4.0
|
|
156
|
+
* @since 0.4.0
|
|
157
157
|
*/
|
|
158
158
|
export type ModelVerificationField = `${ModelStateField}.${"activePaths" | "values" | "completions" | "history"}` | "event.tag" | "initial.startingConfiguration" | "initial.initialEntryPaths" | "initial.plan.initialEntryPaths" | "initial.configuration" | "initial.plan.microsteps" | "initial.plan.done" | "initial.plan.output" | "trace.steps.length" | "step.index" | "step.event" | "step.beforeConfiguration" | "step.plan.microsteps.length" | "microstep.event" | "microstep.transitions" | "microstep.exitPaths" | "microstep.entryPaths" | "microstep.changed" | "step.afterConfiguration" | "step.plan.done" | "step.plan.output" | "trace.finalConfiguration";
|
|
159
159
|
/**
|
|
160
160
|
* One structured semantic disagreement with the independent interpreter.
|
|
161
161
|
*
|
|
162
162
|
* @category models
|
|
163
|
-
* @since 4.0
|
|
163
|
+
* @since 0.4.0
|
|
164
164
|
*/
|
|
165
165
|
export interface ModelVerificationMismatch {
|
|
166
166
|
readonly location: ModelVerificationLocation;
|
|
@@ -177,7 +177,7 @@ declare const ModelVerificationError_base: new <A extends Record<string, any> =
|
|
|
177
177
|
* All semantic disagreements found for one finite-model trace.
|
|
178
178
|
*
|
|
179
179
|
* @category errors
|
|
180
|
-
* @since 4.0
|
|
180
|
+
* @since 0.4.0
|
|
181
181
|
*/
|
|
182
182
|
export declare class ModelVerificationError extends ModelVerificationError_base<{
|
|
183
183
|
readonly mismatches: ReadonlyArray<ModelVerificationMismatch>;
|
|
@@ -188,7 +188,7 @@ export declare class ModelVerificationError extends ModelVerificationError_base<
|
|
|
188
188
|
* executing a `Machine`.
|
|
189
189
|
*
|
|
190
190
|
* @category verification
|
|
191
|
-
* @since 4.0
|
|
191
|
+
* @since 0.4.0
|
|
192
192
|
*/
|
|
193
193
|
export declare const interpretModel: (model: FiniteModel, events: ReadonlyArray<string>) => ReferenceTrace;
|
|
194
194
|
/**
|
|
@@ -15,7 +15,7 @@ import * as Effect from "effect/Effect";
|
|
|
15
15
|
* All semantic disagreements found for one finite-model trace.
|
|
16
16
|
*
|
|
17
17
|
* @category errors
|
|
18
|
-
* @since 4.0
|
|
18
|
+
* @since 0.4.0
|
|
19
19
|
*/
|
|
20
20
|
export class ModelVerificationError extends Data.TaggedError("MachineTestModelVerificationError") {
|
|
21
21
|
}
|
|
@@ -798,7 +798,7 @@ const stepModel = (index, before, event, stepIndex) => {
|
|
|
798
798
|
* executing a `Machine`.
|
|
799
799
|
*
|
|
800
800
|
* @category verification
|
|
801
|
-
* @since 4.0
|
|
801
|
+
* @since 0.4.0
|
|
802
802
|
*/
|
|
803
803
|
export const interpretModel = (model, events) => {
|
|
804
804
|
const index = indexModel(model);
|