tla-ts 0.0.3-dev.4cf9a33 → 0.0.3-dev.4fdd845
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/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +164 -40
- package/dist/index.d.ts +164 -40
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +1351 -22
- package/dist/run-cli.js +1351 -22
- package/dist/transfer.cjs +83 -34
- package/dist/transfer.js +83 -34
- package/package.json +5 -1
- package/src/ast.ts +49 -6
- package/src/bags.ts +4 -7
- package/src/builtins.ts +29 -11
- package/src/bundled-modules.ts +3 -3
- package/src/canonical.ts +4 -3
- package/src/check.ts +1331 -367
- package/src/cli.ts +8 -1
- package/src/codegen.ts +68 -21
- package/src/config.ts +225 -206
- package/src/environment.ts +417 -124
- package/src/errors.ts +168 -9
- package/src/evaluate.ts +720 -177
- package/src/exit-codes.ts +6 -24
- package/src/index.ts +1 -0
- package/src/instances.ts +3 -1
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +149 -31
- package/src/lexer.ts +32 -4
- package/src/live-check.ts +204 -148
- package/src/liveness.ts +191 -122
- package/src/obligation-expression.ts +2 -2
- package/src/obligation-source.ts +2 -0
- package/src/parallel-worker.ts +6 -1
- package/src/parallel.ts +57 -6
- package/src/parser.ts +419 -122
- package/src/pcal-ast.ts +770 -0
- package/src/pcal-parse.ts +1523 -0
- package/src/pcal-tokenize.ts +516 -0
- package/src/pcal-translate.ts +1230 -0
- package/src/pcal-validate.ts +454 -0
- package/src/randomization.ts +24 -7
- package/src/resolve.ts +1334 -452
- package/src/run-cli.ts +1166 -181
- package/src/runtime.ts +16 -0
- package/src/sany-builtins.ts +147 -0
- package/src/sany-generator.ts +3112 -0
- package/src/sany-levels.ts +1208 -0
- package/src/sany-lexer.ts +545 -0
- package/src/sany-linter.ts +122 -0
- package/src/sany-modules.ts +1398 -0
- package/src/sany-nodes.ts +463 -0
- package/src/sany-parse-error.ts +2161 -0
- package/src/sany-report.ts +354 -0
- package/src/sany-selectors.ts +738 -0
- package/src/sany-source.ts +248 -0
- package/src/sany-xml.ts +1017 -0
- package/src/spec-description.ts +25 -5
- package/src/standard-modules.ts +203 -146
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +29 -6
- package/src/subexpressions.ts +221 -161
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +161 -167
- package/src/symmetry.ts +168 -50
- package/src/tableau.ts +3 -1
- package/src/tlc-ext.ts +13 -17
- package/src/tlc-messages.ts +329 -0
- package/src/tlc-module.ts +49 -21
- package/src/tlc-modules.ts +0 -4
- package/src/tlc-order.ts +55 -9
- package/src/tlc-random.ts +28 -3
- package/src/tlc-replay.ts +655 -0
- package/src/tlc-version.ts +18 -0
- package/src/transfer.ts +15 -3
- package/src/value-sources.ts +29 -0
- package/src/values.ts +683 -256
package/src/parallel.ts
CHANGED
|
@@ -4,8 +4,12 @@ import {
|
|
|
4
4
|
checkSequentially,
|
|
5
5
|
createSearch,
|
|
6
6
|
findAssumptionViolation,
|
|
7
|
+
reportInitialStatesProgress,
|
|
8
|
+
reportStartup,
|
|
7
9
|
type CheckOptions,
|
|
10
|
+
type CheckProgress,
|
|
8
11
|
type CheckResult,
|
|
12
|
+
type InitialStates,
|
|
9
13
|
} from "./check";
|
|
10
14
|
import { parseConfig, type ModelConfig } from "./config";
|
|
11
15
|
import { createEnvironment } from "./environment";
|
|
@@ -20,10 +24,11 @@ import {
|
|
|
20
24
|
type SharedFingerprints,
|
|
21
25
|
} from "./fingerprints";
|
|
22
26
|
import { getInitialStates } from "./successors";
|
|
23
|
-
import { getTlcStringOrder,
|
|
27
|
+
import { getTlcStringOrder, getTlcVariableOrder } from "./tlc-order";
|
|
24
28
|
import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc-summary";
|
|
25
29
|
import { createStateEncoder, type EncodedStates } from "./transfer";
|
|
26
|
-
import {
|
|
30
|
+
import type { TlcVersion } from "./tlc-version";
|
|
31
|
+
import { getRankedStringCount, setStringOrder, setValueVersion, type Value } from "./values";
|
|
27
32
|
|
|
28
33
|
const WORKER_THREADS_MODULE = "node:worker_threads";
|
|
29
34
|
|
|
@@ -43,6 +48,10 @@ export interface StartMessage {
|
|
|
43
48
|
index: number;
|
|
44
49
|
ports: (Port | undefined)[];
|
|
45
50
|
seed: EncodedStates;
|
|
51
|
+
isTool: boolean | undefined;
|
|
52
|
+
isTraceRecorded: boolean | undefined;
|
|
53
|
+
isWarningEnabled: boolean | undefined;
|
|
54
|
+
version: TlcVersion | undefined;
|
|
46
55
|
fingerprints: SharedFingerprints;
|
|
47
56
|
requests: Int32Array;
|
|
48
57
|
remaining: Int32Array;
|
|
@@ -101,16 +110,36 @@ const spawnWorker = async (onMessage: (message: WorkerMessage) => void): Promise
|
|
|
101
110
|
};
|
|
102
111
|
|
|
103
112
|
export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
104
|
-
const config =
|
|
113
|
+
const config =
|
|
114
|
+
typeof options.config === "string"
|
|
115
|
+
? parseConfig(options.config, options.version)
|
|
116
|
+
: options.config;
|
|
105
117
|
const print = options.onPrint ?? console.log;
|
|
106
118
|
const printed = { count: 0 };
|
|
107
|
-
//
|
|
119
|
+
// What each point the search reports is about, such as the invariant TLC warns about.
|
|
120
|
+
const getKey = (progress: CheckProgress) =>
|
|
121
|
+
[
|
|
122
|
+
progress.kind,
|
|
123
|
+
"name" in progress ? progress.name : "",
|
|
124
|
+
"count" in progress ? progress.count : "",
|
|
125
|
+
"text" in progress ? progress.text : "",
|
|
126
|
+
].join(" ");
|
|
127
|
+
const reported = new Set<string>();
|
|
128
|
+
const report = (progress: CheckProgress) => {
|
|
129
|
+
reported.add(getKey(progress));
|
|
130
|
+
options.onProgress?.(progress);
|
|
131
|
+
};
|
|
132
|
+
// The search on the calling thread prints and reports what this one did while it started, so it
|
|
133
|
+
// skips that.
|
|
108
134
|
const fallBack = () => {
|
|
109
135
|
const skipped = { count: printed.count };
|
|
110
136
|
return checkSequentially({
|
|
111
137
|
...options,
|
|
112
138
|
config,
|
|
113
139
|
onPrint: (text) => (skipped.count-- > 0 ? undefined : print(text)),
|
|
140
|
+
onProgress: (progress) => {
|
|
141
|
+
if (!reported.has(getKey(progress))) options.onProgress?.(progress);
|
|
142
|
+
},
|
|
114
143
|
});
|
|
115
144
|
};
|
|
116
145
|
const count = options.workers ?? 1;
|
|
@@ -137,6 +166,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
137
166
|
return bytes;
|
|
138
167
|
};
|
|
139
168
|
setStringOrder(getTlcStringOrder(options.source, config, loadModule));
|
|
169
|
+
setValueVersion(options.version);
|
|
140
170
|
const startupStrings = getRankedStringCount();
|
|
141
171
|
const specification = createEnvironment(config, {
|
|
142
172
|
source: options.source,
|
|
@@ -147,10 +177,19 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
147
177
|
print(text);
|
|
148
178
|
},
|
|
149
179
|
files: { readFile: options.readFile, writeFile: options.writeFile },
|
|
180
|
+
isTool: options.isTool,
|
|
181
|
+
isTraceRecorded: options.isTraceRecorded,
|
|
182
|
+
isSanyReported: options.isSanyReported,
|
|
183
|
+
isWarningEnabled: options.isWarningEnabled,
|
|
184
|
+
version: options.version,
|
|
150
185
|
});
|
|
186
|
+
reportStartup(specification, config, report);
|
|
151
187
|
const environment = specification.environment;
|
|
152
|
-
const search = createSearch(
|
|
153
|
-
|
|
188
|
+
const search = createSearch(
|
|
189
|
+
config,
|
|
190
|
+
environment,
|
|
191
|
+
() => getTlcVariableOrder(options.source, loadModule),
|
|
192
|
+
report,
|
|
154
193
|
);
|
|
155
194
|
if (findAssumptionViolation(specification.assumptions, environment)) return fallBack();
|
|
156
195
|
if (
|
|
@@ -172,6 +211,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
172
211
|
distinctStates: 0,
|
|
173
212
|
queuedStates: 0,
|
|
174
213
|
depth: 0,
|
|
214
|
+
initialStates: undefined as InitialStates | undefined,
|
|
175
215
|
outDegrees: Array.from({ length: OUT_DEGREE_BUCKETS }, () => 0),
|
|
176
216
|
};
|
|
177
217
|
const tlcFingerprints: BigInt64Array[] = [];
|
|
@@ -196,6 +236,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
196
236
|
const seedInitialStates = (init: Expression) => {
|
|
197
237
|
const seeded: Value[][] = [];
|
|
198
238
|
for (const state of getInitialStates(init, environment, search.spec.scope)) {
|
|
239
|
+
reportInitialStatesProgress(statistics.generatedStates, report);
|
|
199
240
|
canonicalize(state);
|
|
200
241
|
statistics.generatedStates++;
|
|
201
242
|
writeStateFingerprint(search.getFingerprintState(state), fingerprint);
|
|
@@ -217,6 +258,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
217
258
|
return true;
|
|
218
259
|
};
|
|
219
260
|
// The sequential search reports a violation or a failed evaluation in the initial states.
|
|
261
|
+
report({ kind: "initial-states-started" });
|
|
220
262
|
try {
|
|
221
263
|
if (!seedInitialStates(search.spec.init)) return fallBack();
|
|
222
264
|
} catch (error) {
|
|
@@ -225,6 +267,11 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
225
267
|
}
|
|
226
268
|
if (getRankedStringCount() !== startupStrings) return fallBack();
|
|
227
269
|
statistics.depth = statistics.generatedStates === 0 ? 0 : 1;
|
|
270
|
+
statistics.initialStates = {
|
|
271
|
+
generated: statistics.generatedStates,
|
|
272
|
+
distinct: statistics.distinctStates,
|
|
273
|
+
};
|
|
274
|
+
report({ kind: "initial-states-computed", initialStates: statistics.initialStates });
|
|
228
275
|
if (statistics.distinctStates === 0) return createSuccess();
|
|
229
276
|
|
|
230
277
|
const reports: WorkerMessage[] = [];
|
|
@@ -266,6 +313,10 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
266
313
|
index,
|
|
267
314
|
ports,
|
|
268
315
|
seed,
|
|
316
|
+
isTool: options.isTool,
|
|
317
|
+
isTraceRecorded: options.isTraceRecorded,
|
|
318
|
+
isWarningEnabled: options.isWarningEnabled,
|
|
319
|
+
version: options.version,
|
|
269
320
|
fingerprints: shared.fingerprints,
|
|
270
321
|
requests,
|
|
271
322
|
remaining,
|