@typeonce/effect-machine 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +207 -1
- 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 +147 -0
- package/package.json +11 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded breadth-first exploration over concrete planner events.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Machine from "../../../Machine.js";
|
|
8
|
+
import type { Exploration, ExplorationCompleteness, ExplorationKey, ExplorationNode, ExplorationPredicate, ExploreOptions, ReachabilityFailure, RunError, RunFailure, RunServices } from "../../../testing/MachineTest.js";
|
|
9
|
+
import type { EnsureExecutable } from "../../machine/readiness.js";
|
|
10
|
+
import { type InvariantError } from "./invariant.js";
|
|
11
|
+
type AnyMachine = Machine.Machine.Any;
|
|
12
|
+
type ReadyMachine<M extends AnyMachine> = M & EnsureExecutable<Machine.Machine.States<M>, Machine.Machine.UnhandledStates<M>, Machine.Machine.OutputStates<M>>;
|
|
13
|
+
export declare const explore: <M extends AnyMachine, Key extends ExplorationKey>(machine: ReadyMachine<M>, options: ExploreOptions<M, Key>) => Effect.Effect<Exploration<M, Key>, RunFailure<RunError<M>, M> | InvariantError<M>, RunServices<M>>;
|
|
14
|
+
declare const ReachabilityError_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 & {
|
|
15
|
+
readonly _tag: "MachineTestReachabilityError";
|
|
16
|
+
} & Readonly<A>;
|
|
17
|
+
export declare class ReachabilityError<M extends AnyMachine = AnyMachine, Key extends ExplorationKey = ExplorationKey> extends ReachabilityError_base<{
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly expectation: "reachable" | "unreachable";
|
|
20
|
+
readonly reason: ReachabilityFailure;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
readonly completeness: ExplorationCompleteness<M, Key>;
|
|
23
|
+
readonly witness?: ExplorationNode<M, Key>;
|
|
24
|
+
}> {
|
|
25
|
+
}
|
|
26
|
+
export declare const findShortest: <M extends AnyMachine, Key extends ExplorationKey>(exploration: Exploration<M, Key>, predicate: ExplorationPredicate<M, Key>) => ExplorationNode<M, Key> | undefined;
|
|
27
|
+
export declare const assertReachable: <M extends AnyMachine, Key extends ExplorationKey>(exploration: Exploration<M, Key>, name: string, predicate: ExplorationPredicate<M, Key>) => Effect.Effect<ExplorationNode<M, Key>, ReachabilityError<M, Key>>;
|
|
28
|
+
export declare const assertUnreachable: <M extends AnyMachine, Key extends ExplorationKey>(exploration: Exploration<M, Key>, name: string, predicate: ExplorationPredicate<M, Key>) => Effect.Effect<void, ReachabilityError<M, Key>>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=exploration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exploration.d.ts","sourceRoot":"","sources":["../../../../src/internal/testing/machine/exploration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EAGvB,cAAc,EACd,eAAe,EACf,oBAAoB,EAEpB,cAAc,EACd,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AA;IACtD,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;CAC3C,CAAC;CAAG;AAQL,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,UAAU,EAAE,GAAG,SAAS,cAAc,EAC3E,aAAa,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,EAChC,WAAW,oBAAoB,CAAC,CAAC,EAAE,GAAG,CAAC,KACtC,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,SAA8C,CAAA;AAE3E,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,UAAU,EAAE,GAAG,SAAS,cAAc,EAC9E,aAAa,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,EAChC,MAAM,MAAM,EACZ,WAAW,oBAAoB,CAAC,CAAC,EAAE,GAAG,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,GAAG,CAAC,CAkBlE,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,UAAU,EAAE,GAAG,SAAS,cAAc,EAChF,aAAa,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,EAChC,MAAM,MAAM,EACZ,WAAW,oBAAoB,CAAC,CAAC,EAAE,GAAG,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,EAAE,GAAG,CAAC,CA6B/C,CAAA"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded breadth-first exploration over concrete planner events.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Data from "effect/Data";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Graph from "effect/Graph";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
import * as Machine from "../../../Machine.js";
|
|
11
|
+
import { assertInvariants } from "./invariant.js";
|
|
12
|
+
import { appendTrace, run } from "./trace.js";
|
|
13
|
+
const defaultLimits = {
|
|
14
|
+
maxDepth: 20,
|
|
15
|
+
maxStates: 1_000,
|
|
16
|
+
maxTransitions: 10_000
|
|
17
|
+
};
|
|
18
|
+
const validateLimit = (name, value, minimum) => {
|
|
19
|
+
if (!Number.isSafeInteger(value) || value < minimum) {
|
|
20
|
+
throw new Error(`MachineTest.explore expected ${name} to be a safe integer greater than or equal to ${minimum}`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const resolveLimits = (limits) => {
|
|
24
|
+
const resolved = {
|
|
25
|
+
maxDepth: limits?.maxDepth ?? defaultLimits.maxDepth,
|
|
26
|
+
maxStates: limits?.maxStates ?? defaultLimits.maxStates,
|
|
27
|
+
maxTransitions: limits?.maxTransitions ?? defaultLimits.maxTransitions
|
|
28
|
+
};
|
|
29
|
+
validateLimit("maxDepth", resolved.maxDepth, 0);
|
|
30
|
+
validateLimit("maxStates", resolved.maxStates, 1);
|
|
31
|
+
validateLimit("maxTransitions", resolved.maxTransitions, 0);
|
|
32
|
+
return resolved;
|
|
33
|
+
};
|
|
34
|
+
const validateKey = (key) => {
|
|
35
|
+
if (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol") {
|
|
36
|
+
throw new Error("MachineTest.explore expected stateKey to return a string, number, or symbol");
|
|
37
|
+
}
|
|
38
|
+
return key;
|
|
39
|
+
};
|
|
40
|
+
const stateContext = (machine, trace) => ({
|
|
41
|
+
machine,
|
|
42
|
+
snapshot: trace.final,
|
|
43
|
+
configuration: trace.finalConfiguration,
|
|
44
|
+
depth: trace.steps.length,
|
|
45
|
+
trace
|
|
46
|
+
});
|
|
47
|
+
const scenarioWithEvent = (trace, event) => ({
|
|
48
|
+
...trace.scenario,
|
|
49
|
+
events: [...trace.scenario.events, event]
|
|
50
|
+
});
|
|
51
|
+
export const explore = (machine, options) => {
|
|
52
|
+
const limits = resolveLimits(options.limits);
|
|
53
|
+
const initialScenario = (machine.input === undefined || machine.input === Schema.Void
|
|
54
|
+
? { events: [] }
|
|
55
|
+
: { input: options.input, events: [] });
|
|
56
|
+
return Effect.gen(function* () {
|
|
57
|
+
const initialTrace = yield* run(machine, initialScenario);
|
|
58
|
+
const invariants = options.invariants ?? [];
|
|
59
|
+
if (invariants.length > 0) {
|
|
60
|
+
yield* assertInvariants(machine, initialTrace, invariants);
|
|
61
|
+
}
|
|
62
|
+
const initialContext = stateContext(machine, initialTrace);
|
|
63
|
+
const initialKey = validateKey(options.stateKey(initialContext));
|
|
64
|
+
const nodes = [{ ...initialContext, key: initialKey }];
|
|
65
|
+
const nodeDraftsByKey = new Map([[initialKey, 0]]);
|
|
66
|
+
const edges = [];
|
|
67
|
+
const frontier = [];
|
|
68
|
+
const reasons = new Set();
|
|
69
|
+
let plannedTransitions = 0;
|
|
70
|
+
let cursor = 0;
|
|
71
|
+
let halted = false;
|
|
72
|
+
while (cursor < nodes.length && !halted) {
|
|
73
|
+
const sourceIndex = cursor;
|
|
74
|
+
const source = nodes[cursor++];
|
|
75
|
+
const candidates = options.events(source);
|
|
76
|
+
if (!Array.isArray(candidates)) {
|
|
77
|
+
throw new Error("MachineTest.explore expected events to return a readonly array");
|
|
78
|
+
}
|
|
79
|
+
if (source.depth >= limits.maxDepth) {
|
|
80
|
+
if (candidates.length > 0)
|
|
81
|
+
reasons.add("depth");
|
|
82
|
+
for (const event of candidates) {
|
|
83
|
+
frontier.push({
|
|
84
|
+
_tag: "DepthLimit",
|
|
85
|
+
source: source.key,
|
|
86
|
+
trace: source.trace,
|
|
87
|
+
event
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
for (const event of candidates) {
|
|
93
|
+
if (plannedTransitions >= limits.maxTransitions) {
|
|
94
|
+
reasons.add("transitions");
|
|
95
|
+
frontier.push({
|
|
96
|
+
_tag: "TransitionLimit",
|
|
97
|
+
source: source.key,
|
|
98
|
+
trace: source.trace,
|
|
99
|
+
event
|
|
100
|
+
});
|
|
101
|
+
halted = true;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
const scenario = scenarioWithEvent(source.trace, event);
|
|
105
|
+
const targetTrace = yield* appendTrace(machine, source.trace, event, scenario);
|
|
106
|
+
plannedTransitions += 1;
|
|
107
|
+
if (invariants.length > 0) {
|
|
108
|
+
yield* assertInvariants(machine, targetTrace, invariants);
|
|
109
|
+
}
|
|
110
|
+
const targetContext = stateContext(machine, targetTrace);
|
|
111
|
+
const targetKey = validateKey(options.stateKey(targetContext));
|
|
112
|
+
const existing = nodeDraftsByKey.get(targetKey);
|
|
113
|
+
if (existing !== undefined) {
|
|
114
|
+
edges.push({
|
|
115
|
+
source: sourceIndex,
|
|
116
|
+
target: existing,
|
|
117
|
+
edge: {
|
|
118
|
+
event,
|
|
119
|
+
step: targetTrace.steps[targetTrace.steps.length - 1],
|
|
120
|
+
discovered: false
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (nodes.length >= limits.maxStates) {
|
|
126
|
+
reasons.add("states");
|
|
127
|
+
frontier.push({
|
|
128
|
+
_tag: "StateLimit",
|
|
129
|
+
source: source.key,
|
|
130
|
+
trace: source.trace,
|
|
131
|
+
event,
|
|
132
|
+
target: targetKey,
|
|
133
|
+
targetTrace
|
|
134
|
+
});
|
|
135
|
+
halted = true;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
const targetIndex = nodes.length;
|
|
139
|
+
nodeDraftsByKey.set(targetKey, targetIndex);
|
|
140
|
+
nodes.push({ ...targetContext, key: targetKey });
|
|
141
|
+
edges.push({
|
|
142
|
+
source: sourceIndex,
|
|
143
|
+
target: targetIndex,
|
|
144
|
+
edge: {
|
|
145
|
+
event,
|
|
146
|
+
step: targetTrace.steps[targetTrace.steps.length - 1],
|
|
147
|
+
discovered: true
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const nodeIndexes = [];
|
|
153
|
+
const graph = Graph.directed((mutable) => {
|
|
154
|
+
for (const node of nodes)
|
|
155
|
+
nodeIndexes.push(Graph.addNode(mutable, node));
|
|
156
|
+
for (const edge of edges) {
|
|
157
|
+
Graph.addEdge(mutable, nodeIndexes[edge.source], nodeIndexes[edge.target], edge.edge);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const nodesByKey = new Map();
|
|
161
|
+
nodes.forEach((node, index) => nodesByKey.set(node.key, nodeIndexes[index]));
|
|
162
|
+
const completeness = reasons.size === 0
|
|
163
|
+
? { _tag: "Complete" }
|
|
164
|
+
: {
|
|
165
|
+
_tag: "Truncated",
|
|
166
|
+
reasons: ["depth", "states", "transitions"].filter((reason) => reasons.has(reason)),
|
|
167
|
+
frontier
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
graph,
|
|
171
|
+
nodes,
|
|
172
|
+
nodesByKey,
|
|
173
|
+
start: nodeIndexes[0],
|
|
174
|
+
limits,
|
|
175
|
+
stats: {
|
|
176
|
+
states: nodes.length,
|
|
177
|
+
plannedTransitions,
|
|
178
|
+
retainedEdges: edges.length,
|
|
179
|
+
maxDepth: nodes.reduce((maximum, node) => Math.max(maximum, node.depth), 0)
|
|
180
|
+
},
|
|
181
|
+
completeness
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
export class ReachabilityError extends Data.TaggedError("MachineTestReachabilityError") {
|
|
186
|
+
}
|
|
187
|
+
const validateAssertionName = (name) => {
|
|
188
|
+
if (name.trim().length === 0) {
|
|
189
|
+
throw new Error("MachineTest reachability assertions expected name to be a non-empty string");
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
export const findShortest = (exploration, predicate) => exploration.nodes.find(predicate);
|
|
193
|
+
export const assertReachable = (exploration, name, predicate) => {
|
|
194
|
+
validateAssertionName(name);
|
|
195
|
+
return Effect.suspend(() => {
|
|
196
|
+
const witness = findShortest(exploration, predicate);
|
|
197
|
+
if (witness !== undefined)
|
|
198
|
+
return Effect.succeed(witness);
|
|
199
|
+
const inconclusive = exploration.completeness._tag === "Truncated";
|
|
200
|
+
return Effect.fail(new ReachabilityError({
|
|
201
|
+
name,
|
|
202
|
+
expectation: "reachable",
|
|
203
|
+
reason: inconclusive ? "Inconclusive" : "NotFound",
|
|
204
|
+
message: inconclusive
|
|
205
|
+
? `Reachability of ${name} is inconclusive because exploration was truncated`
|
|
206
|
+
: `Expected ${name} to be reachable`,
|
|
207
|
+
completeness: exploration.completeness
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
export const assertUnreachable = (exploration, name, predicate) => {
|
|
212
|
+
validateAssertionName(name);
|
|
213
|
+
return Effect.suspend(() => {
|
|
214
|
+
const witness = findShortest(exploration, predicate);
|
|
215
|
+
if (witness !== undefined) {
|
|
216
|
+
return Effect.fail(new ReachabilityError({
|
|
217
|
+
name,
|
|
218
|
+
expectation: "unreachable",
|
|
219
|
+
reason: "UnexpectedMatch",
|
|
220
|
+
message: `Expected ${name} to be unreachable but found a witness at depth ${witness.depth}`,
|
|
221
|
+
completeness: exploration.completeness,
|
|
222
|
+
witness
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
if (exploration.completeness._tag === "Truncated") {
|
|
226
|
+
return Effect.fail(new ReachabilityError({
|
|
227
|
+
name,
|
|
228
|
+
expectation: "unreachable",
|
|
229
|
+
reason: "Inconclusive",
|
|
230
|
+
message: `Unreachability of ${name} is inconclusive because exploration was truncated`,
|
|
231
|
+
completeness: exploration.completeness
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
return Effect.void;
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
//# sourceMappingURL=exploration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exploration.js","sourceRoot":"","sources":["../../../../src/internal/testing/machine/exploration.ts"],"names":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import * as Machine from "../../../Machine.js";
|
|
|
14
14
|
* An atomic state in a finite generated model.
|
|
15
15
|
*
|
|
16
16
|
* @category models
|
|
17
|
-
* @since 4.0
|
|
17
|
+
* @since 0.4.0
|
|
18
18
|
*/
|
|
19
19
|
export interface FiniteAtomicState {
|
|
20
20
|
readonly _tag: "Atomic";
|
|
@@ -26,7 +26,7 @@ export interface FiniteAtomicState {
|
|
|
26
26
|
* A final state in a finite generated model.
|
|
27
27
|
*
|
|
28
28
|
* @category models
|
|
29
|
-
* @since 4.0
|
|
29
|
+
* @since 0.4.0
|
|
30
30
|
*/
|
|
31
31
|
export interface FiniteFinalState {
|
|
32
32
|
readonly _tag: "Final";
|
|
@@ -40,7 +40,7 @@ export interface FiniteFinalState {
|
|
|
40
40
|
* A compound state in a finite generated model.
|
|
41
41
|
*
|
|
42
42
|
* @category models
|
|
43
|
-
* @since 4.0
|
|
43
|
+
* @since 0.4.0
|
|
44
44
|
*/
|
|
45
45
|
export interface FiniteCompoundState {
|
|
46
46
|
readonly _tag: "Compound";
|
|
@@ -59,7 +59,7 @@ export interface FiniteCompoundState {
|
|
|
59
59
|
* compared without sharing executable callbacks with the reference model.
|
|
60
60
|
*
|
|
61
61
|
* @category models
|
|
62
|
-
* @since 4.0
|
|
62
|
+
* @since 0.4.0
|
|
63
63
|
*/
|
|
64
64
|
export interface FiniteParallelState {
|
|
65
65
|
readonly _tag: "Parallel";
|
|
@@ -79,7 +79,7 @@ export interface FiniteParallelState {
|
|
|
79
79
|
* parallel owner and is used only before that history register is captured.
|
|
80
80
|
*
|
|
81
81
|
* @category models
|
|
82
|
-
* @since 4.0
|
|
82
|
+
* @since 0.4.0
|
|
83
83
|
*/
|
|
84
84
|
export interface FiniteHistoryState {
|
|
85
85
|
readonly _tag: "History";
|
|
@@ -98,7 +98,7 @@ export interface FiniteChoiceState {
|
|
|
98
98
|
* A finite model state.
|
|
99
99
|
*
|
|
100
100
|
* @category models
|
|
101
|
-
* @since 4.0
|
|
101
|
+
* @since 0.4.0
|
|
102
102
|
*/
|
|
103
103
|
export type FiniteState = FiniteAtomicState | FiniteFinalState | FiniteCompoundState | FiniteParallelState | FiniteHistoryState | FiniteChoiceState;
|
|
104
104
|
/**
|
|
@@ -107,7 +107,7 @@ export type FiniteState = FiniteAtomicState | FiniteFinalState | FiniteCompoundS
|
|
|
107
107
|
* same validation, compilation, and reference interpretation path.
|
|
108
108
|
*
|
|
109
109
|
* @category models
|
|
110
|
-
* @since 4.0
|
|
110
|
+
* @since 0.4.0
|
|
111
111
|
*/
|
|
112
112
|
export type FiniteTransitionTrigger = {
|
|
113
113
|
readonly type: "event";
|
|
@@ -121,7 +121,7 @@ export type FiniteTransitionTrigger = {
|
|
|
121
121
|
* One deterministic transition in a finite generated model.
|
|
122
122
|
*
|
|
123
123
|
* @category models
|
|
124
|
-
* @since 4.0
|
|
124
|
+
* @since 0.4.0
|
|
125
125
|
*/
|
|
126
126
|
interface FiniteTransitionBase {
|
|
127
127
|
readonly source: string;
|
|
@@ -134,7 +134,7 @@ interface FiniteTransitionBase {
|
|
|
134
134
|
* A public event transition may explicitly request source reentry.
|
|
135
135
|
*
|
|
136
136
|
* @category models
|
|
137
|
-
* @since 4.0
|
|
137
|
+
* @since 0.4.0
|
|
138
138
|
*/
|
|
139
139
|
export type FiniteEventTransition = FiniteTransitionBase & {
|
|
140
140
|
readonly trigger: Extract<FiniteTransitionTrigger, {
|
|
@@ -147,7 +147,7 @@ export type FiniteEventTransition = FiniteTransitionBase & {
|
|
|
147
147
|
* the event-only reentry option.
|
|
148
148
|
*
|
|
149
149
|
* @category models
|
|
150
|
-
* @since 4.0
|
|
150
|
+
* @since 0.4.0
|
|
151
151
|
*/
|
|
152
152
|
export type FiniteAutomaticTransition = FiniteTransitionBase & {
|
|
153
153
|
readonly trigger: Exclude<FiniteTransitionTrigger, {
|
|
@@ -158,7 +158,7 @@ export type FiniteAutomaticTransition = FiniteTransitionBase & {
|
|
|
158
158
|
* One deterministic event or automatic transition in a finite model.
|
|
159
159
|
*
|
|
160
160
|
* @category models
|
|
161
|
-
* @since 4.0
|
|
161
|
+
* @since 0.4.0
|
|
162
162
|
*/
|
|
163
163
|
export type FiniteTransition = FiniteEventTransition | FiniteAutomaticTransition;
|
|
164
164
|
/**
|
|
@@ -168,7 +168,7 @@ export type FiniteTransition = FiniteEventTransition | FiniteAutomaticTransition
|
|
|
168
168
|
* from that state's generated default value.
|
|
169
169
|
*
|
|
170
170
|
* @category models
|
|
171
|
-
* @since 4.0
|
|
171
|
+
* @since 0.4.0
|
|
172
172
|
*/
|
|
173
173
|
export interface FiniteHistoryMutation {
|
|
174
174
|
readonly source: string;
|
|
@@ -180,7 +180,7 @@ export interface FiniteHistoryMutation {
|
|
|
180
180
|
* One exact transition in a generated history witness.
|
|
181
181
|
*
|
|
182
182
|
* @category models
|
|
183
|
-
* @since 4.0
|
|
183
|
+
* @since 0.4.0
|
|
184
184
|
*/
|
|
185
185
|
export interface FiniteHistoryTransfer {
|
|
186
186
|
readonly source: string;
|
|
@@ -196,7 +196,7 @@ export interface FiniteHistoryTransfer {
|
|
|
196
196
|
* root, and restores the remembered non-default value through `history`.
|
|
197
197
|
*
|
|
198
198
|
* @category models
|
|
199
|
-
* @since 4.0
|
|
199
|
+
* @since 0.4.0
|
|
200
200
|
*/
|
|
201
201
|
export interface FiniteHistoryScenario {
|
|
202
202
|
readonly history: string;
|
|
@@ -215,7 +215,7 @@ export interface FiniteHistoryScenario {
|
|
|
215
215
|
* or a different root as a complete configuration.
|
|
216
216
|
*
|
|
217
217
|
* @category models
|
|
218
|
-
* @since 4.0
|
|
218
|
+
* @since 0.4.0
|
|
219
219
|
*/
|
|
220
220
|
export interface FiniteModel {
|
|
221
221
|
readonly roots: ReadonlyArray<FiniteState>;
|
|
@@ -230,7 +230,7 @@ export interface FiniteModel {
|
|
|
230
230
|
* Limits controlling finite model generation.
|
|
231
231
|
*
|
|
232
232
|
* @category models
|
|
233
|
-
* @since 4.0
|
|
233
|
+
* @since 0.4.0
|
|
234
234
|
*/
|
|
235
235
|
export interface FiniteModelOptions {
|
|
236
236
|
/** Maximum number of root states. Always between one and three. */
|
|
@@ -254,7 +254,7 @@ export interface FiniteModelOptions {
|
|
|
254
254
|
* Resolved limits and structural guarantees for a finite model arbitrary.
|
|
255
255
|
*
|
|
256
256
|
* @category models
|
|
257
|
-
* @since 4.0
|
|
257
|
+
* @since 0.4.0
|
|
258
258
|
*/
|
|
259
259
|
export interface FiniteModelDiagnostics {
|
|
260
260
|
readonly limits: {
|
|
@@ -285,7 +285,7 @@ export interface FiniteModelDiagnostics {
|
|
|
285
285
|
* A finite model arbitrary and the exact limits used to construct it.
|
|
286
286
|
*
|
|
287
287
|
* @category models
|
|
288
|
-
* @since 4.0
|
|
288
|
+
* @since 0.4.0
|
|
289
289
|
*/
|
|
290
290
|
export interface FiniteModels {
|
|
291
291
|
readonly arbitrary: FastCheck.Arbitrary<FiniteModel>;
|
|
@@ -303,7 +303,7 @@ export interface FiniteModels {
|
|
|
303
303
|
* or parallel sources. Separate focused witnesses cover cyclic stabilization.
|
|
304
304
|
*
|
|
305
305
|
* @category constructors
|
|
306
|
-
* @since 4.0
|
|
306
|
+
* @since 0.4.0
|
|
307
307
|
*/
|
|
308
308
|
export declare const finiteModels: (options?: FiniteModelOptions) => FiniteModels;
|
|
309
309
|
/**
|
|
@@ -315,7 +315,7 @@ export declare const finiteModels: (options?: FiniteModelOptions) => FiniteModel
|
|
|
315
315
|
* conformance stages.
|
|
316
316
|
*
|
|
317
317
|
* @category constructors
|
|
318
|
-
* @since 4.0
|
|
318
|
+
* @since 0.4.0
|
|
319
319
|
*/
|
|
320
320
|
export declare const compileModel: (model: FiniteModel) => Machine.Machine.Any;
|
|
321
321
|
export {};
|
|
@@ -430,7 +430,7 @@ const makeTransitionArbitrary = (roots, initial, events, maxTransitions, history
|
|
|
430
430
|
* or parallel sources. Separate focused witnesses cover cyclic stabilization.
|
|
431
431
|
*
|
|
432
432
|
* @category constructors
|
|
433
|
-
* @since 4.0
|
|
433
|
+
* @since 0.4.0
|
|
434
434
|
*/
|
|
435
435
|
export const finiteModels = (options = {}) => {
|
|
436
436
|
const limits = resolveOptions(options);
|
|
@@ -953,7 +953,7 @@ const makeHandlers = (states, parent, byPath, transitions) => {
|
|
|
953
953
|
* conformance stages.
|
|
954
954
|
*
|
|
955
955
|
* @category constructors
|
|
956
|
-
* @since 4.0
|
|
956
|
+
* @since 0.4.0
|
|
957
957
|
*/
|
|
958
958
|
export const compileModel = (model) => {
|
|
959
959
|
const flattened = validateModel(model);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-defined semantic invariants over planner traces.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Machine from "../../../Machine.js";
|
|
8
|
+
import type { Invariant as MachineInvariant, InvariantBuilder, InvariantOptions, InvariantOutcome, InvariantReport, InvariantViolation, StateInvariant, StateInvariantContext, StateInvariantOptions, StepInvariant, StepInvariantContext, Trace, TraceInvariant, TraceInvariantContext } from "../../../testing/MachineTest.js";
|
|
9
|
+
type AnyMachine = Machine.Machine.Any;
|
|
10
|
+
export declare const stateInvariant: <M extends AnyMachine>(name: string, check: (context: StateInvariantContext<M>) => InvariantOutcome, options?: StateInvariantOptions<M>) => StateInvariant<M>;
|
|
11
|
+
export declare const stepInvariant: <M extends AnyMachine>(name: string, check: (context: StepInvariantContext<M>) => InvariantOutcome, options?: InvariantOptions<StepInvariantContext<M>>) => StepInvariant<M>;
|
|
12
|
+
export declare const traceInvariant: <M extends AnyMachine>(name: string, check: (context: TraceInvariantContext<M>) => InvariantOutcome, options?: InvariantOptions<TraceInvariantContext<M>>) => TraceInvariant<M>;
|
|
13
|
+
export declare const Invariant: Readonly<{
|
|
14
|
+
state: <M extends AnyMachine>(name: string, check: (context: StateInvariantContext<M>) => InvariantOutcome, options?: StateInvariantOptions<M>) => StateInvariant<M>;
|
|
15
|
+
step: <M extends AnyMachine>(name: string, check: (context: StepInvariantContext<M>) => InvariantOutcome, options?: InvariantOptions<StepInvariantContext<M>>) => StepInvariant<M>;
|
|
16
|
+
trace: <M extends AnyMachine>(name: string, check: (context: TraceInvariantContext<M>) => InvariantOutcome, options?: InvariantOptions<TraceInvariantContext<M>>) => TraceInvariant<M>;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const invariants: <M extends AnyMachine>(_machine: M) => InvariantBuilder<M>;
|
|
19
|
+
declare const InvariantError_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 & {
|
|
20
|
+
readonly _tag: "MachineTestInvariantError";
|
|
21
|
+
} & Readonly<A>;
|
|
22
|
+
export declare class InvariantError<M extends AnyMachine = AnyMachine> extends InvariantError_base<{
|
|
23
|
+
readonly trace: Trace<M>;
|
|
24
|
+
readonly violations: ReadonlyArray<InvariantViolation<M>>;
|
|
25
|
+
readonly report: InvariantReport;
|
|
26
|
+
}> {
|
|
27
|
+
}
|
|
28
|
+
export declare const checkInvariants: <M extends AnyMachine>(machine: M, trace: Trace<M>, invariants: ReadonlyArray<MachineInvariant<M>>) => Effect.Effect<InvariantReport, InvariantError<M>>;
|
|
29
|
+
export declare const assertInvariants: <M extends AnyMachine>(machine: M, trace: Trace<M>, invariants: ReadonlyArray<MachineInvariant<M>>) => Effect.Effect<void, InvariantError<M>>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../../../src/internal/testing/machine/invariant.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EACV,SAAS,I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