tla-ts 0.0.10-dev.b4a856304 → 0.0.10-dev.f16792fed
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/index.cjs +1 -1
- package/dist/index.d.cts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +48 -48
- package/dist/prove.js +29 -29
- package/dist/run.cjs +40 -40
- package/dist/run.js +31 -31
- package/dist/transfer.cjs +36 -36
- package/dist/transfer.js +40 -40
- package/package.json +1 -1
- package/src/ast.ts +0 -5
- package/src/bags.ts +2 -5
- package/src/builtins.ts +1 -8
- package/src/check.ts +128 -193
- package/src/cli/options.ts +1 -1
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +8 -7
- package/src/cli/shared.ts +0 -4
- package/src/cli/tlc-arguments.ts +24 -30
- package/src/cli/tlc-usage.ts +2 -3
- package/src/coverage.ts +3 -8
- package/src/evaluate.ts +26 -102
- package/src/java-hash.ts +7 -0
- package/src/java-overrides.ts +4 -9
- package/src/json-reader.ts +1 -2
- package/src/json.ts +4 -11
- package/src/levels.ts +7 -15
- package/src/lexer.ts +72 -83
- package/src/liveness-checker.ts +77 -106
- package/src/liveness.ts +10 -34
- package/src/parallel.ts +26 -33
- package/src/parser.ts +163 -226
- package/src/pcal/ast.ts +53 -65
- package/src/pcal/parse.ts +144 -191
- package/src/pcal/tokenize.ts +91 -115
- package/src/pcal/translate.ts +83 -98
- package/src/pcal/validate.ts +48 -50
- package/src/pretty-print.ts +6 -6
- package/src/randomization.ts +1 -4
- package/src/resolve.ts +12 -70
- package/src/runtime.ts +11 -18
- package/src/sany/builtins.ts +1 -3
- package/src/sany/generator.ts +74 -127
- package/src/sany/levels.ts +5 -9
- package/src/sany/lexer.ts +40 -44
- package/src/sany/linter.ts +0 -1
- package/src/sany/nodes.ts +4 -10
- package/src/search.ts +1 -1
- package/src/simulate.ts +50 -59
- package/src/spec-description.ts +23 -34
- package/src/standard-definitions.ts +0 -3
- package/src/standard-modules.ts +1 -12
- package/src/state-graph.ts +3 -15
- package/src/subexpressions.ts +38 -47
- package/src/successors.ts +14 -35
- package/src/symmetry.ts +4 -19
- package/src/tlc/fingerprint.ts +15 -21
- package/src/tlc/jar-data.ts +0 -1
- package/src/tlc/messages.ts +2 -21
- package/src/tlc/order.ts +22 -47
- package/src/tlc/random.ts +18 -30
- package/src/tlc/replay.ts +13 -33
- package/src/tlc/summary.ts +36 -45
- package/src/tlc/tlc-operators.ts +4 -14
- package/src/tlc/tlcext-operators.ts +11 -15
- package/src/tlc/trace-spec.ts +4 -9
- package/src/tlc/value-stream.ts +9 -13
- package/src/tlc/version.ts +0 -1
- package/src/values.ts +74 -186
package/src/parallel.ts
CHANGED
|
@@ -85,7 +85,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
85
85
|
? parseConfig(options.config, options.version)
|
|
86
86
|
: options.config;
|
|
87
87
|
const print = options.onPrint ?? console.log;
|
|
88
|
-
|
|
88
|
+
let printedCount = 0;
|
|
89
89
|
const getKey = (progress: CheckProgress) =>
|
|
90
90
|
[
|
|
91
91
|
progress.kind,
|
|
@@ -98,26 +98,21 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
98
98
|
reported.add(getKey(progress));
|
|
99
99
|
options.onProgress?.(progress);
|
|
100
100
|
};
|
|
101
|
-
// The search on the calling thread prints and reports what this one did while it started, so it
|
|
102
|
-
// skips that.
|
|
103
101
|
const fallBack = (createdString?: string) => {
|
|
104
102
|
if (createdString !== undefined) {
|
|
105
103
|
options.onProgress?.({ kind: "sequential-fallback", string: createdString });
|
|
106
104
|
}
|
|
107
|
-
|
|
105
|
+
let skippedCount = printedCount;
|
|
108
106
|
return checkSequentially({
|
|
109
107
|
...options,
|
|
110
108
|
config,
|
|
111
|
-
onPrint: (text) => (
|
|
109
|
+
onPrint: (text) => (skippedCount-- > 0 ? undefined : print(text)),
|
|
112
110
|
onProgress: (progress) => {
|
|
113
111
|
if (!reported.has(getKey(progress))) options.onProgress?.(progress);
|
|
114
112
|
},
|
|
115
113
|
});
|
|
116
114
|
};
|
|
117
115
|
const workerCount = options.workers ?? 1;
|
|
118
|
-
// TLC's workers write the -dump state graph, and print the violations -continue goes on past, in
|
|
119
|
-
// whichever order they find them, so one worker does what a single TLC worker does. The
|
|
120
|
-
// coverage counts live in one worker's evaluators.
|
|
121
116
|
const isSequential =
|
|
122
117
|
workerCount < 2 ||
|
|
123
118
|
typeof SharedArrayBuffer !== "function" ||
|
|
@@ -152,7 +147,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
152
147
|
order,
|
|
153
148
|
loadClass,
|
|
154
149
|
print: (text) => {
|
|
155
|
-
|
|
150
|
+
printedCount++;
|
|
156
151
|
print(text);
|
|
157
152
|
},
|
|
158
153
|
files: {
|
|
@@ -187,7 +182,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
187
182
|
}
|
|
188
183
|
|
|
189
184
|
const canonicalize = createCanonicalizer();
|
|
190
|
-
|
|
185
|
+
let sharedFingerprints = createSharedFingerprints();
|
|
191
186
|
const fingerprint = new Int32Array(2);
|
|
192
187
|
const seeds = Array.from({ length: workerCount }, createStateEncoder);
|
|
193
188
|
const statistics = {
|
|
@@ -224,10 +219,10 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
224
219
|
canonicalize(state);
|
|
225
220
|
statistics.generatedStates++;
|
|
226
221
|
writeStateFingerprint(search.getFingerprintState(state), fingerprint);
|
|
227
|
-
if (isSharedFingerprintsFull(
|
|
228
|
-
|
|
222
|
+
if (isSharedFingerprintsFull(sharedFingerprints)) {
|
|
223
|
+
sharedFingerprints = growSharedFingerprints(sharedFingerprints);
|
|
229
224
|
}
|
|
230
|
-
if (!insertSharedFingerprint(
|
|
225
|
+
if (!insertSharedFingerprint(sharedFingerprints, fingerprint[0], fingerprint[1])) continue;
|
|
231
226
|
if (search.findViolatedInvariant(state) || search.findFailedInitialPredicate(state)) {
|
|
232
227
|
return false;
|
|
233
228
|
}
|
|
@@ -241,7 +236,6 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
241
236
|
);
|
|
242
237
|
return true;
|
|
243
238
|
};
|
|
244
|
-
// The sequential search reports a violation or a failed evaluation in the initial states.
|
|
245
239
|
report({ kind: "initial-states-started" });
|
|
246
240
|
try {
|
|
247
241
|
if (!seedInitialStates(search.spec.init)) return fallBack();
|
|
@@ -260,17 +254,18 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
260
254
|
if (statistics.distinctStates === 0) return createSuccess();
|
|
261
255
|
|
|
262
256
|
const reports: WorkerMessage[] = [];
|
|
263
|
-
|
|
257
|
+
let pendingCount = workerCount;
|
|
258
|
+
let resolvePending = (_reports: WorkerMessage[]) => {};
|
|
264
259
|
const onMessage = (message: WorkerMessage) => {
|
|
265
260
|
reports.push(message);
|
|
266
|
-
if (message.type === "abort" || reports.length ===
|
|
267
|
-
|
|
261
|
+
if (message.type === "abort" || reports.length === pendingCount) {
|
|
262
|
+
resolvePending(reports.splice(0));
|
|
268
263
|
}
|
|
269
264
|
};
|
|
270
265
|
const waitForReports = (expected: number) =>
|
|
271
266
|
new Promise<WorkerMessage[]>((resolve) => {
|
|
272
|
-
|
|
273
|
-
|
|
267
|
+
pendingCount = expected;
|
|
268
|
+
resolvePending = resolve;
|
|
274
269
|
});
|
|
275
270
|
const ready = waitForReports(workerCount);
|
|
276
271
|
const requests = new Int32Array(new SharedArrayBuffer(workerCount * 4));
|
|
@@ -293,7 +288,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
293
288
|
return (from < to ? channel.port1 : channel.port2) as unknown as Port;
|
|
294
289
|
};
|
|
295
290
|
workers.forEach((worker, index) => {
|
|
296
|
-
const ports = Array.from({ length: workerCount }, (
|
|
291
|
+
const ports = Array.from({ length: workerCount }, (_value, peer) =>
|
|
297
292
|
peer === index ? undefined : getPort(index, peer),
|
|
298
293
|
);
|
|
299
294
|
const seed = seeds[index].finish();
|
|
@@ -313,7 +308,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
313
308
|
fingerprintPolynomial: options.fingerprintPolynomial,
|
|
314
309
|
maxSetSize: options.maxSetSize,
|
|
315
310
|
isLazyValueExpanded: options.isLazyValueExpanded,
|
|
316
|
-
fingerprints:
|
|
311
|
+
fingerprints: sharedFingerprints,
|
|
317
312
|
requests,
|
|
318
313
|
remaining,
|
|
319
314
|
};
|
|
@@ -323,26 +318,24 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
323
318
|
messages.some((message) => message.type === "abort");
|
|
324
319
|
const send = (message: CoordinatorMessage) =>
|
|
325
320
|
workers.forEach((worker) => worker.postMessage(message));
|
|
326
|
-
// Workers pause when the shared table needs to grow, and resume once it has.
|
|
327
321
|
const collectLevels = async (messages: WorkerMessage[]): Promise<WorkerMessage[]> => {
|
|
328
|
-
const
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
const resumed = waitForReports(
|
|
332
|
-
send({ type: "resize", fingerprints:
|
|
333
|
-
const
|
|
334
|
-
return [...
|
|
322
|
+
const pausedCount = messages.filter((message) => message.type === "paused").length;
|
|
323
|
+
if (pausedCount === 0 || isAborted(messages)) return messages;
|
|
324
|
+
sharedFingerprints = growSharedFingerprints(sharedFingerprints);
|
|
325
|
+
const resumed = waitForReports(pausedCount);
|
|
326
|
+
send({ type: "resize", fingerprints: sharedFingerprints });
|
|
327
|
+
const unpaused = messages.filter((message) => message.type !== "paused");
|
|
328
|
+
return [...unpaused, ...(await collectLevels(await resumed))];
|
|
335
329
|
};
|
|
336
330
|
if (isAborted(await ready)) {
|
|
337
331
|
terminate();
|
|
338
332
|
return fallBack();
|
|
339
333
|
}
|
|
340
334
|
for (;;) {
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
requests.forEach((_, index) => Atomics.store(requests, index, 0));
|
|
335
|
+
const levelReports = waitForReports(workerCount);
|
|
336
|
+
requests.forEach((_request, index) => Atomics.store(requests, index, 0));
|
|
344
337
|
send({ type: "level" });
|
|
345
|
-
const messages = await collectLevels(await
|
|
338
|
+
const messages = await collectLevels(await levelReports);
|
|
346
339
|
if (isAborted(messages)) {
|
|
347
340
|
terminate();
|
|
348
341
|
const aborted = messages.find(
|