tla-ts 0.0.10-dev.28c823e4b → 0.0.10-dev.63a6693bd
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/compile.cjs +6 -6
- package/dist/compile.js +10 -10
- package/dist/deciders.cjs +29 -29
- package/dist/deciders.js +40 -40
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +54 -54
- package/dist/prove.js +52 -52
- package/dist/run.cjs +42 -42
- package/dist/run.js +44 -44
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +39 -39
- package/dist/transfer.js +41 -41
- package/dist/worker.cjs +4 -4
- package/dist/worker.js +4 -4
- package/package.json +1 -1
- package/src/ast.ts +44 -39
- package/src/builtins.ts +4 -13
- package/src/check-failure.ts +116 -0
- package/src/check-trace.ts +282 -0
- package/src/check.ts +152 -518
- package/src/cli/options.ts +6 -31
- package/src/cli/shared.ts +1 -1
- package/src/cli/tlapm.ts +14 -13
- package/src/cli/tlc-arguments.ts +222 -210
- package/src/cli/tlc-output.ts +687 -0
- package/src/cli/tlc-usage.ts +1 -1
- package/src/cli/tlc.ts +34 -701
- package/src/cli/xml-exporter.ts +23 -33
- package/src/codegen.ts +5 -10
- package/src/coverage.ts +3 -10
- package/src/dependencies.ts +8 -13
- package/src/dfid.ts +16 -16
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +45 -333
- package/src/errors.ts +3 -2
- package/src/evaluate.ts +5 -4
- package/src/fingerprints.ts +65 -1
- package/src/instances.ts +47 -10
- package/src/java-hash.ts +7 -0
- package/src/json.ts +4 -7
- package/src/levels.ts +39 -42
- package/src/liveness-checker.ts +24 -37
- package/src/liveness.ts +47 -54
- package/src/obligations/action.ts +4 -11
- package/src/obligations/anonymize.ts +4 -2
- package/src/obligations/expression.ts +18 -2
- package/src/obligations/generate.ts +45 -38
- package/src/obligations/index.ts +2 -2
- package/src/obligations/module.ts +27 -38
- package/src/obligations/normalize.ts +2 -1
- package/src/obligations/simplify.ts +39 -44
- package/src/obligations/source.ts +47 -57
- package/src/obligations/temporal.ts +5 -5
- package/src/parallel-worker.ts +10 -30
- package/src/parallel.ts +22 -45
- package/src/parser.ts +19 -34
- package/src/prover/decide-pool.ts +3 -3
- package/src/prover/deciders.ts +3 -3
- package/src/prover/isabelle/encode.ts +1 -1
- package/src/prover/isabelle/isar/inner-syntax.ts +9 -4
- package/src/prover/isabelle/isar/method.ts +14 -25
- package/src/prover/isabelle/isar/theory.ts +11 -10
- package/src/prover/isabelle/isar/type-check.ts +6 -6
- package/src/prover/isabelle/provers/blast/blast.ts +7 -63
- package/src/prover/isabelle/provers/hypsubst.ts +17 -26
- package/src/prover/isabelle/pure/bicompose.ts +9 -25
- package/src/prover/isabelle/pure/conv.ts +2 -8
- package/src/prover/isabelle/pure/drule.ts +9 -2
- package/src/prover/isabelle/pure/logic.ts +1 -1
- package/src/prover/isabelle/pure/raw-simplifier.ts +4 -13
- package/src/prover/isabelle/pure/rewriter.ts +5 -9
- package/src/prover/isabelle/pure/table.ts +2 -1
- package/src/prover/isabelle/pure/tactical.ts +42 -35
- package/src/prover/isabelle/pure/thm.ts +14 -11
- package/src/prover/isabelle/tla/classical-setup.ts +17 -14
- package/src/prover/isabelle/tla/context.ts +7 -2
- package/src/prover/isabelle/tla/logic.ts +10 -21
- package/src/prover/isabelle/tla/simpdata.ts +1 -10
- package/src/prover/prep/action.ts +11 -19
- package/src/prover/prep/fingerprint.ts +2 -5
- package/src/prover/prep/methods.ts +24 -3
- package/src/prover/prove.ts +87 -64
- package/src/prover/smt/context.ts +1 -2
- package/src/prover/smt/data.ts +418 -406
- package/src/prover/smt/encode.ts +30 -18
- package/src/prover/smt/rewrite.ts +657 -626
- package/src/prover/smt/solver/ast.ts +0 -22
- package/src/prover/smt/solver/auf-solver.ts +2 -5
- package/src/prover/smt/solver/context.ts +3 -3
- package/src/prover/smt/solver/e-matching.ts +1 -1
- package/src/prover/smt/solver/expr-safe-replace.ts +1 -1
- package/src/prover/smt/solver/internalizer.ts +1 -2
- package/src/prover/smt/solver/lp/dioph-eq.ts +1 -8
- package/src/prover/smt/solver/lp/hnf-cutter.ts +1 -1
- package/src/prover/smt/solver/lp/nla-core.ts +2 -6
- package/src/prover/smt/solver/mam-compiler.ts +4 -2
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/model-finder.ts +12 -17
- package/src/prover/smt/solver/model-macro-solver.ts +11 -19
- package/src/prover/smt/solver/nlsat/algebraic.ts +9 -9
- package/src/prover/smt/solver/nlsat/atoms.ts +20 -4
- package/src/prover/smt/solver/nlsat/explain.ts +7 -22
- package/src/prover/smt/solver/nlsat/levelwise.ts +1 -6
- package/src/prover/smt/solver/nlsat/polynomial.ts +12 -3
- package/src/prover/smt/solver/nlsat/solver.ts +12 -24
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -1
- package/src/prover/smt/solver/proto-model.ts +0 -4
- package/src/prover/smt/solver/quantifier-analyzer.ts +10 -10
- package/src/prover/smt/solver/quantifier-manager.ts +1 -5
- package/src/prover/smt/solver/smtlib-parser.ts +78 -94
- package/src/prover/smt/solver/theory-lra-bounds.ts +1 -2
- package/src/prover/smt/solver/theory-lra-internalize.ts +5 -16
- package/src/prover/tlapm/cache.ts +28 -18
- package/src/prover/tlapm/tlapm.ts +15 -9
- package/src/prover/verdict.ts +7 -0
- package/src/prover/zenon/check/check.ts +1 -2
- package/src/prover/zenon/check/records.ts +1 -1
- package/src/prover/zenon/check/relations.ts +2 -1
- package/src/prover/zenon/check/rewrites.ts +2 -15
- package/src/prover/zenon/check/sets.ts +40 -58
- package/src/prover/zenon/check/terms.ts +1 -2
- package/src/prover/zenon/eqrel.ts +2 -0
- package/src/prover/zenon/expr.ts +7 -0
- package/src/prover/zenon/index-table.ts +9 -19
- package/src/prover/zenon/isar.ts +35 -35
- package/src/prover/zenon/llproof.ts +2 -11
- package/src/prover/zenon/mltoll.ts +12 -28
- package/src/prover/zenon/parse.ts +3 -6
- package/src/prover/zenon/search.ts +4 -14
- package/src/prover/zenon/tla/functions.ts +2 -2
- package/src/prover/zenon/tla/llproof.ts +9 -11
- package/src/prover/zenon/tla/records.ts +1 -6
- package/src/prover/zenon/tla/sets.ts +15 -14
- package/src/prover/zenon/tla/tla.ts +7 -6
- package/src/resolve.ts +55 -72
- package/src/sany/generation.ts +394 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +686 -0
- package/src/sany/generator-expressions.ts +1100 -0
- package/src/sany/generator-proofs.ts +662 -0
- package/src/sany/generator.ts +155 -2625
- package/src/sany/lexer.ts +17 -16
- package/src/sany/nodes.ts +6 -13
- package/src/sany/report.ts +3 -6
- package/src/sany/selectors.ts +35 -38
- package/src/sany/xml.ts +23 -55
- package/src/search.ts +65 -27
- package/src/simulate.ts +157 -133
- package/src/spec-description.ts +33 -48
- package/src/standard-modules.ts +16 -32
- package/src/state-graph.ts +2 -7
- package/src/substitution-levels.ts +5 -4
- package/src/successors.ts +5 -7
- package/src/tlc/messages.ts +20 -15
- package/src/tlc/order.ts +2 -9
- package/src/tlc/random.ts +4 -4
- package/src/tlc/replay.ts +8 -15
- package/src/tlc/tlc-operators.ts +2 -3
- package/src/tlc/trace-spec.ts +25 -45
- package/src/typescript/actions.ts +2 -4
- package/src/typescript/collections.ts +34 -20
- package/src/typescript/compile.ts +1 -3
- package/src/typescript/formula.ts +5 -3
- package/src/typescript/model.ts +4 -5
- package/src/typescript/steps.ts +20 -18
- package/src/values.ts +63 -158
package/src/check.ts
CHANGED
|
@@ -9,10 +9,8 @@ import {
|
|
|
9
9
|
getCoverageReport,
|
|
10
10
|
type CoverageReport,
|
|
11
11
|
} from "./coverage";
|
|
12
|
-
import { createEnvironment } from "./environment";
|
|
13
12
|
import {
|
|
14
13
|
createStackOverflowError,
|
|
15
|
-
getErrorExitCode,
|
|
16
14
|
isStackOverflow,
|
|
17
15
|
TlaEvaluationError,
|
|
18
16
|
TlaIllegalStateError,
|
|
@@ -24,21 +22,32 @@ import {
|
|
|
24
22
|
formatRange,
|
|
25
23
|
} from "./errors";
|
|
26
24
|
import {
|
|
27
|
-
createTracingEnvironment,
|
|
28
25
|
describeRange,
|
|
29
26
|
getDefinition,
|
|
30
|
-
isImpure,
|
|
31
27
|
type CallStack,
|
|
32
28
|
type Environment,
|
|
33
29
|
type FingerprintFailure,
|
|
34
30
|
} from "./evaluate";
|
|
31
|
+
import { EXIT_STATUS, setExitCode, withLivenessExitCode } from "./exit-codes";
|
|
35
32
|
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
fingerprintReplayed,
|
|
34
|
+
getFailureExitCode,
|
|
35
|
+
getReplayFailure,
|
|
36
|
+
type FailureOptions,
|
|
37
|
+
} from "./check-failure";
|
|
38
|
+
import {
|
|
39
|
+
createTraceBuilder,
|
|
40
|
+
type Behavior,
|
|
41
|
+
type SearchPosition,
|
|
42
|
+
type TracedStep,
|
|
43
|
+
} from "./check-trace";
|
|
44
|
+
import {
|
|
45
|
+
createStateTable,
|
|
46
|
+
findStateIndex,
|
|
47
|
+
getStateHash,
|
|
48
|
+
isSameState,
|
|
49
|
+
markSeenState,
|
|
50
|
+
} from "./fingerprints";
|
|
42
51
|
import type { JavaOverride } from "./java-overrides";
|
|
43
52
|
import {
|
|
44
53
|
createLivenessChecker,
|
|
@@ -47,6 +56,7 @@ import {
|
|
|
47
56
|
type LiveSuccessor,
|
|
48
57
|
} from "./liveness-checker";
|
|
49
58
|
import {
|
|
59
|
+
createCheckEnvironment,
|
|
50
60
|
createMissingOperatorError,
|
|
51
61
|
createSearch,
|
|
52
62
|
getIncompleteSuccessorMessage,
|
|
@@ -58,11 +68,11 @@ import {
|
|
|
58
68
|
import {
|
|
59
69
|
getActionLabel,
|
|
60
70
|
getActionSignature,
|
|
61
|
-
|
|
62
|
-
getNextActions,
|
|
71
|
+
getSpecDescription,
|
|
63
72
|
getSpecificationValue,
|
|
64
73
|
toActionValue,
|
|
65
74
|
type SpecAction,
|
|
75
|
+
type SpecDescription,
|
|
66
76
|
} from "./spec-description";
|
|
67
77
|
import {
|
|
68
78
|
createStateWriter,
|
|
@@ -79,7 +89,6 @@ import {
|
|
|
79
89
|
type Successor,
|
|
80
90
|
} from "./successors";
|
|
81
91
|
import {
|
|
82
|
-
getCodedMessage,
|
|
83
92
|
getFailureMessage,
|
|
84
93
|
getWrappedException,
|
|
85
94
|
isEvalException,
|
|
@@ -90,9 +99,7 @@ import {
|
|
|
90
99
|
} from "./tlc/messages";
|
|
91
100
|
import { createTautologyError } from "./liveness";
|
|
92
101
|
import { KEY_SEPARATOR } from "./resolve";
|
|
93
|
-
import { setFingerprintPolynomial } from "./tlc/fingerprint";
|
|
94
102
|
import { writeTraceSpec } from "./tlc/trace-spec";
|
|
95
|
-
import { createTlcOrder } from "./tlc/order";
|
|
96
103
|
import {
|
|
97
104
|
getPrimedRanges,
|
|
98
105
|
replayInitialStates,
|
|
@@ -103,18 +110,13 @@ import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc/summary";
|
|
|
103
110
|
import { createActionRecord, createCounterExample } from "./tlc/tlcext-operators";
|
|
104
111
|
import type { TlcVersion } from "./tlc/version";
|
|
105
112
|
import {
|
|
106
|
-
combineHash,
|
|
107
113
|
createCanonicalizer,
|
|
108
114
|
createModelValue,
|
|
109
115
|
formatState,
|
|
110
116
|
getFingerprintError,
|
|
111
|
-
getHeldValues,
|
|
112
117
|
getModelValues,
|
|
113
|
-
getValueHash,
|
|
114
118
|
isSameValue,
|
|
115
119
|
markFingerprinted,
|
|
116
|
-
setStringOrder,
|
|
117
|
-
setValueOptions,
|
|
118
120
|
type Value,
|
|
119
121
|
} from "./values";
|
|
120
122
|
|
|
@@ -284,12 +286,6 @@ export interface EvaluationFailure {
|
|
|
284
286
|
isWithoutStatistics?: boolean;
|
|
285
287
|
}
|
|
286
288
|
|
|
287
|
-
interface ReplayFailure {
|
|
288
|
-
callStack: Expression[];
|
|
289
|
-
fingerprint: FingerprintFailure | undefined;
|
|
290
|
-
replayError?: TlaEvaluationError;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
289
|
export interface InitialStates {
|
|
294
290
|
generated: number;
|
|
295
291
|
distinct: number;
|
|
@@ -323,73 +319,18 @@ interface CoveredAction extends SpecAction {
|
|
|
323
319
|
node: number;
|
|
324
320
|
}
|
|
325
321
|
|
|
326
|
-
interface Behavior {
|
|
327
|
-
trace: TraceStep[];
|
|
328
|
-
traceOutput?: OutputLine[];
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
interface TraceOptions {
|
|
332
|
-
loopStart?: number;
|
|
333
|
-
known?: number;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
322
|
interface ReportedViolation extends Omit<Violation, "loopStart"> {
|
|
337
323
|
loopStart?: number;
|
|
338
324
|
}
|
|
339
325
|
|
|
340
|
-
interface RebuiltState {
|
|
341
|
-
state: Value[];
|
|
342
|
-
level: number;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
interface SearchPosition {
|
|
346
|
-
index: number;
|
|
347
|
-
isExpanding: boolean;
|
|
348
|
-
candidate: Value[] | undefined;
|
|
349
|
-
candidateLevel: number;
|
|
350
|
-
livenessSource: number;
|
|
351
|
-
rebuilt: RebuiltState | undefined;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
interface FailureOptions {
|
|
355
|
-
initialState?: Value[];
|
|
356
|
-
isInitial?: boolean;
|
|
357
|
-
outDegrees?: number[];
|
|
358
|
-
callStack?: Expression[];
|
|
359
|
-
fingerprint?: FingerprintFailure;
|
|
360
|
-
replayError?: TlaEvaluationError;
|
|
361
|
-
isNextState?: boolean;
|
|
362
|
-
isCallStackFirst?: boolean;
|
|
363
|
-
traceFailure?: FailureMessage;
|
|
364
|
-
isLiveCallStack?: boolean;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
326
|
const appendTraceOutput = <Traced extends Behavior>(behavior: Traced, lines: OutputLine[]) => ({
|
|
368
327
|
...behavior,
|
|
369
328
|
traceOutput: [...(behavior.traceOutput ?? []), ...lines],
|
|
370
329
|
});
|
|
371
330
|
|
|
372
|
-
const INITIAL_RECOVERY_FAILURE = "Failed to recover the initial state from its fingerprint.";
|
|
373
|
-
const NEXT_RECOVERY_FAILURE = "Failed to recover the next state from its fingerprint.";
|
|
374
|
-
|
|
375
331
|
const STOP_REPLAY = new Error("The replay stopped");
|
|
376
332
|
const STOP_WALK = new Error("The walk stopped");
|
|
377
333
|
|
|
378
|
-
const getInitialExitCode = (error: TlaEvaluationError) => {
|
|
379
|
-
const coded = getCodedMessage(error.message);
|
|
380
|
-
return coded &&
|
|
381
|
-
!coded.isEvalException &&
|
|
382
|
-
getMessageExitStatus(coded.code) === EXIT_STATUS.configParseError
|
|
383
|
-
? EXIT_STATUS.configParseError
|
|
384
|
-
: getErrorExitCode(error);
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
const getReplayExitCode = (error: TlaEvaluationError): number => {
|
|
388
|
-
const inner = error.cause;
|
|
389
|
-
if (inner instanceof TlaEvaluationError) return getReplayExitCode(inner);
|
|
390
|
-
return error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.specEvaluationFailure;
|
|
391
|
-
};
|
|
392
|
-
|
|
393
334
|
export const checkSequentially = (options: CheckOptions): CheckResult => {
|
|
394
335
|
const stateWriter =
|
|
395
336
|
options.dump && createStateWriter(options.dump, options.writeFile, options.version);
|
|
@@ -428,29 +369,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
428
369
|
capturedLines = outer;
|
|
429
370
|
}
|
|
430
371
|
};
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
setValueOptions(options);
|
|
434
|
-
setFingerprintPolynomial(options.fingerprintPolynomial ?? 0);
|
|
435
|
-
const specification = createEnvironment(config, {
|
|
436
|
-
source: options.source,
|
|
437
|
-
loadModule: options.loadModule,
|
|
438
|
-
order,
|
|
439
|
-
loadClass: options.loadClass,
|
|
440
|
-
print,
|
|
441
|
-
files: {
|
|
442
|
-
readFile: options.readFile,
|
|
443
|
-
writeFile: options.writeFile,
|
|
444
|
-
makeDirectory: options.makeDirectory,
|
|
445
|
-
},
|
|
446
|
-
seed: options.seed,
|
|
447
|
-
isTool: options.isTool,
|
|
448
|
-
traceFile: options.traceSpec?.traceFile,
|
|
449
|
-
isSanyReported: options.isSanyReported,
|
|
450
|
-
isWarningEnabled: options.isWarningEnabled,
|
|
451
|
-
version: options.version,
|
|
452
|
-
moduleOperators: options.moduleOperators,
|
|
453
|
-
});
|
|
372
|
+
const created = createCheckEnvironment(config, options, print);
|
|
373
|
+
const specification = created.specification;
|
|
454
374
|
reportStartup(specification, config, options.onProgress);
|
|
455
375
|
const coverage =
|
|
456
376
|
options.coverage === undefined
|
|
@@ -468,13 +388,11 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
468
388
|
const runtime = environment.runtime;
|
|
469
389
|
const is174 = runtime.version === "1.7.4";
|
|
470
390
|
runtime.pause = options.onPause ?? (() => {});
|
|
391
|
+
let description: SpecDescription | undefined;
|
|
392
|
+
const getDescription = () =>
|
|
393
|
+
(description ??= getSpecDescription(config, environment, specification.instanceActions));
|
|
471
394
|
runtime.getSpecification = () =>
|
|
472
|
-
getSpecificationValue(
|
|
473
|
-
config,
|
|
474
|
-
environment,
|
|
475
|
-
specification.variableLocations,
|
|
476
|
-
specification.instanceActions,
|
|
477
|
-
);
|
|
395
|
+
getSpecificationValue(getDescription(), config, environment, specification.variableLocations);
|
|
478
396
|
let searchDepth = 0;
|
|
479
397
|
let computedInitialStates: InitialStates | undefined;
|
|
480
398
|
const getTraceSpec = (trace: TraceStep[], loopStart: number | undefined) =>
|
|
@@ -553,7 +471,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
553
471
|
config,
|
|
554
472
|
environment,
|
|
555
473
|
specification.variableLocations,
|
|
556
|
-
() => order.getDeclarationOrder("variable"),
|
|
474
|
+
() => created.order.getDeclarationOrder("variable"),
|
|
557
475
|
options.onProgress,
|
|
558
476
|
specification.moduleOperators,
|
|
559
477
|
);
|
|
@@ -575,13 +493,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
575
493
|
config.postconditions.length > 0 ||
|
|
576
494
|
config.possible.length > 0 ||
|
|
577
495
|
specification.moduleOperators.some((operator) => operator.kind === "postcondition");
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
{ state: Record<string, Value>; action: SpecAction | undefined }
|
|
581
|
-
>();
|
|
582
|
-
const getStepState = (step: TraceStep) => traceSteps.get(step)?.state ?? step.state;
|
|
496
|
+
const tracedSteps = new WeakMap<TraceStep, TracedStep>();
|
|
497
|
+
const getStepState = (step: TraceStep) => tracedSteps.get(step)?.state ?? step.state;
|
|
583
498
|
const getStepAction = (step: TraceStep) => {
|
|
584
|
-
const action =
|
|
499
|
+
const action = tracedSteps.get(step)?.action;
|
|
585
500
|
return action ? toActionValue(action) : createActionRecord(step.action);
|
|
586
501
|
};
|
|
587
502
|
const checkTracePostconditions = (
|
|
@@ -633,13 +548,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
633
548
|
};
|
|
634
549
|
const spec = search.spec;
|
|
635
550
|
const getFingerprintState = search.getFingerprintState;
|
|
636
|
-
let specNextActions: SpecAction[] | undefined;
|
|
637
|
-
const getSpecNextActions = () =>
|
|
638
|
-
(specNextActions ??= getNextActions(config, environment, specification.instanceActions));
|
|
639
551
|
// Tool's constructor splits the next-state relation into actions before TLC checks anything.
|
|
640
|
-
|
|
552
|
+
const nextActions = getDescription().actions;
|
|
641
553
|
runtime.getSuccessorAction = (state, next) =>
|
|
642
|
-
|
|
554
|
+
nextActions.find((action) =>
|
|
643
555
|
getSuccessors(action.expression, state, environment, action.scope).some((successor) =>
|
|
644
556
|
successor.state.every((value, index) => isSameValue(value, next[index])),
|
|
645
557
|
),
|
|
@@ -657,11 +569,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
657
569
|
)
|
|
658
570
|
: -1,
|
|
659
571
|
}));
|
|
660
|
-
const coverageInits = addCoverageRelations(
|
|
661
|
-
|
|
662
|
-
coverage ? getInitActions(config, environment, specification.instanceActions) : [],
|
|
663
|
-
);
|
|
664
|
-
const coverageActions = addCoverageRelations("next", coverage ? getSpecNextActions() : []);
|
|
572
|
+
const coverageInits = addCoverageRelations("init", coverage ? getDescription().inits : []);
|
|
573
|
+
const coverageActions = addCoverageRelations("next", coverage ? nextActions : []);
|
|
665
574
|
if (coverage) buildCoverage(coverage, environment, getPrimedRanges(coverageActions, environment));
|
|
666
575
|
const walkCoveredSuccessors = (
|
|
667
576
|
action: CoveredAction,
|
|
@@ -696,64 +605,26 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
696
605
|
);
|
|
697
606
|
return successors;
|
|
698
607
|
};
|
|
608
|
+
const rejectIncompleteInitialState = (partial: (Value | undefined)[]) => {
|
|
609
|
+
throw setExitCode(new TlaIllegalStateError([...partial]), EXIT_STATUS.error);
|
|
610
|
+
};
|
|
699
611
|
const getCoveredInitialStates = () => {
|
|
700
612
|
const initialStates: Value[][] = [];
|
|
701
613
|
replayInitialStates(
|
|
702
614
|
coverageInits,
|
|
703
615
|
environment,
|
|
704
616
|
(state) => initialStates.push(state),
|
|
705
|
-
|
|
706
|
-
throw setExitCode(new TlaIllegalStateError([...partial]), EXIT_STATUS.error);
|
|
707
|
-
},
|
|
617
|
+
rejectIncompleteInitialState,
|
|
708
618
|
);
|
|
709
619
|
return initialStates;
|
|
710
620
|
};
|
|
711
|
-
const getReplayFailure = (replay: (tracing: Environment) => void): ReplayFailure | undefined => {
|
|
712
|
-
const tracing = createTracingEnvironment(environment);
|
|
713
|
-
const callStack = tracing.callStack;
|
|
714
|
-
try {
|
|
715
|
-
replay(tracing);
|
|
716
|
-
return undefined;
|
|
717
|
-
} catch (error) {
|
|
718
|
-
if (isStackOverflow(error)) return { callStack: [], fingerprint: undefined };
|
|
719
|
-
if (!(error instanceof TlaEvaluationError) || !callStack) return undefined;
|
|
720
|
-
return {
|
|
721
|
-
callStack: callStack.expressions,
|
|
722
|
-
fingerprint: callStack.fingerprint,
|
|
723
|
-
replayError: error,
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
const findFailedSources = (value: Value, sources: CallStack["sources"]): Expression[] => {
|
|
728
|
-
if (typeof value !== "object") return [];
|
|
729
|
-
const source = sources.get(value);
|
|
730
|
-
const failed = getHeldValues(value).find((held) => getFingerprintError(held) !== undefined);
|
|
731
|
-
return [
|
|
732
|
-
...(source ? [source] : []),
|
|
733
|
-
...(failed === undefined ? [] : findFailedSources(failed, sources)),
|
|
734
|
-
];
|
|
735
|
-
};
|
|
736
|
-
const fingerprintReplayed = (state: Value[], callStack: CallStack | undefined) => {
|
|
737
|
-
for (const value of getFingerprintState(state)) {
|
|
738
|
-
const error = getFingerprintError(value);
|
|
739
|
-
if (!error) continue;
|
|
740
|
-
const sources = callStack ? findFailedSources(value, callStack.sources) : [];
|
|
741
|
-
if (callStack && sources.length > 0) {
|
|
742
|
-
callStack.expressions.length = 0;
|
|
743
|
-
callStack.isFrozen = true;
|
|
744
|
-
callStack.fingerprint = { sources, reason: error.message };
|
|
745
|
-
}
|
|
746
|
-
throw error;
|
|
747
|
-
}
|
|
748
|
-
state.forEach(markFingerprinted);
|
|
749
|
-
};
|
|
750
621
|
const createReplayedStates = () => {
|
|
751
622
|
const replayed = unstoredFingerprint ? [unstoredFingerprint] : [];
|
|
752
623
|
return (state: Value[], callStack: CallStack | undefined) => {
|
|
753
|
-
fingerprintReplayed(state, callStack);
|
|
624
|
+
fingerprintReplayed(state, getFingerprintState(state), callStack);
|
|
754
625
|
const fingerprintState = getFingerprintState(state);
|
|
755
626
|
const isSeen =
|
|
756
|
-
findStateIndex(getStateHash(fingerprintState), fingerprintState) !== -1 ||
|
|
627
|
+
findStateIndex(seenStates, getStateHash(fingerprintState), fingerprintState) !== -1 ||
|
|
757
628
|
replayed.some((seen) => isSameState(seen, fingerprintState));
|
|
758
629
|
if (isSeen) return false;
|
|
759
630
|
replayed.push(fingerprintState);
|
|
@@ -765,48 +636,44 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
765
636
|
let replayedCount = 0;
|
|
766
637
|
const deferred: unknown[] = [];
|
|
767
638
|
const addReplayed = createReplayedStates();
|
|
768
|
-
return getReplayFailure((tracing) => {
|
|
769
|
-
replayInitialStates(
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
state: traced,
|
|
790
|
-
});
|
|
791
|
-
throw STOP_REPLAY;
|
|
792
|
-
}
|
|
793
|
-
} catch (error) {
|
|
794
|
-
const isFingerprintFailure =
|
|
795
|
-
error instanceof TlaEvaluationError && tracing.callStack?.fingerprint !== undefined;
|
|
796
|
-
if (!isFingerprintFailure && !isStackOverflow(error)) throw error;
|
|
797
|
-
deferred.push(error);
|
|
639
|
+
return getReplayFailure(environment, (tracing) => {
|
|
640
|
+
replayInitialStates(getDescription().inits, tracing, (state) => {
|
|
641
|
+
reportInitialStatesProgress(replayedCount, (progress) => capturedLines?.push(progress));
|
|
642
|
+
replayedCount++;
|
|
643
|
+
runtime.generatedStates = replayedCount;
|
|
644
|
+
if (deferred.length > 0) return;
|
|
645
|
+
try {
|
|
646
|
+
const addFingerprint = () => {
|
|
647
|
+
if (!addReplayed(state, tracing.callStack)) return;
|
|
648
|
+
runtime.queueSize++;
|
|
649
|
+
liveness?.addInitialState(states.length, state, tracing);
|
|
650
|
+
};
|
|
651
|
+
const violation = search.checkReplayedInitialState(state, tracing, addFingerprint);
|
|
652
|
+
if (violation) {
|
|
653
|
+
const traced = traces.toTrace([{ action: undefined, state }], []).trace[0].state;
|
|
654
|
+
capturedLines?.push({
|
|
655
|
+
kind: "initial-state-violation",
|
|
656
|
+
...violation,
|
|
657
|
+
state: traced,
|
|
658
|
+
});
|
|
659
|
+
throw STOP_REPLAY;
|
|
798
660
|
}
|
|
799
|
-
}
|
|
800
|
-
|
|
661
|
+
} catch (error) {
|
|
662
|
+
const isFingerprintFailure =
|
|
663
|
+
error instanceof TlaEvaluationError && tracing.callStack?.fingerprint !== undefined;
|
|
664
|
+
if (!isFingerprintFailure && !isStackOverflow(error)) throw error;
|
|
665
|
+
deferred.push(error);
|
|
666
|
+
}
|
|
667
|
+
});
|
|
801
668
|
if (deferred.length > 0) throw deferred[0];
|
|
802
669
|
});
|
|
803
670
|
};
|
|
804
671
|
const replayNext = (index: number) =>
|
|
805
|
-
getReplayFailure((tracing) => {
|
|
672
|
+
getReplayFailure(environment, (tracing) => {
|
|
806
673
|
const state = states[index];
|
|
807
674
|
const source = stateWriter && getGraphState(state, depths[index]);
|
|
808
675
|
const addReplayed = createReplayedStates();
|
|
809
|
-
replaySuccessors(
|
|
676
|
+
replaySuccessors(nextActions, state, tracing, (next, action) => {
|
|
810
677
|
const addFingerprint = () => {
|
|
811
678
|
const isUnseen = addReplayed(next, tracing.callStack);
|
|
812
679
|
if (source) {
|
|
@@ -824,7 +691,6 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
824
691
|
}
|
|
825
692
|
});
|
|
826
693
|
});
|
|
827
|
-
const isReducing = config.view !== undefined || config.symmetry !== undefined;
|
|
828
694
|
const tlcFingerprints: number[] = [];
|
|
829
695
|
if (search.properties.liveness.length > 0) {
|
|
830
696
|
options.onProgress?.({
|
|
@@ -857,7 +723,11 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
857
723
|
search.satisfiesActionConstraints(state, successor.state);
|
|
858
724
|
if (!isInModel) return false;
|
|
859
725
|
const fingerprintState = getFingerprintState(successor.state);
|
|
860
|
-
const index = findStateIndex(
|
|
726
|
+
const index = findStateIndex(
|
|
727
|
+
seenStates,
|
|
728
|
+
getStateHash(fingerprintState),
|
|
729
|
+
fingerprintState,
|
|
730
|
+
);
|
|
861
731
|
successors.push({ index, state: successor.state });
|
|
862
732
|
return false;
|
|
863
733
|
},
|
|
@@ -880,202 +750,14 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
880
750
|
const parents: number[] = [];
|
|
881
751
|
const actions: (string | undefined)[] = [];
|
|
882
752
|
const depths: number[] = [];
|
|
883
|
-
|
|
884
|
-
const seenStates = { slots: new Int32Array(1 << 17), size: 0, shift: 16 };
|
|
753
|
+
const seenStates = createStateTable(fingerprintStates);
|
|
885
754
|
const canonicalizeState = createCanonicalizer();
|
|
886
755
|
|
|
887
756
|
const toRecord = search.toRecord;
|
|
888
|
-
const getAliasState = (
|
|
889
|
-
alias: string,
|
|
890
|
-
steps: Successor[],
|
|
891
|
-
position: number,
|
|
892
|
-
loopStart: number | undefined,
|
|
893
|
-
) => {
|
|
894
|
-
const searchLevel = runtime.getLevel;
|
|
895
|
-
const searchBehavior = runtime.getBehavior;
|
|
896
|
-
runtime.getLevel = () => position + 1;
|
|
897
|
-
runtime.getBehavior = () => steps.slice(0, position + 1).map((step) => step.state);
|
|
898
|
-
try {
|
|
899
|
-
return evaluateAlias(
|
|
900
|
-
alias,
|
|
901
|
-
steps[position].state,
|
|
902
|
-
(steps[position + 1] ?? steps[loopStart ?? position]).state,
|
|
903
|
-
);
|
|
904
|
-
} finally {
|
|
905
|
-
runtime.getLevel = searchLevel;
|
|
906
|
-
runtime.getBehavior = searchBehavior;
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
const evaluateAlias = (alias: string, state: Value[], next: Value[] | undefined) =>
|
|
910
|
-
search.evaluateAlias(alias, state, next, options.isTool ?? false);
|
|
911
|
-
const findStepAction = (index: number, previous: Value[], state: Value[], isHeld: boolean) => {
|
|
912
|
-
const actions = getSpecNextActions();
|
|
913
|
-
const expanding = { ...current };
|
|
914
|
-
Object.assign(current, {
|
|
915
|
-
index,
|
|
916
|
-
isExpanding: true,
|
|
917
|
-
candidate: undefined,
|
|
918
|
-
rebuilt: { state: previous, level: depths[index] },
|
|
919
|
-
});
|
|
920
|
-
const getKey = isHeld ? (values: Value[]) => values : getFingerprintState;
|
|
921
|
-
const key = getKey(state);
|
|
922
|
-
try {
|
|
923
|
-
return coverage
|
|
924
|
-
? coverageActions.find((item) =>
|
|
925
|
-
getCoveredSuccessors(item, previous).some((successor) =>
|
|
926
|
-
isSameState(getKey(successor.state), key),
|
|
927
|
-
),
|
|
928
|
-
)
|
|
929
|
-
: actions.find((item) =>
|
|
930
|
-
getSuccessors(item.expression, previous, environment, item.scope).some((successor) =>
|
|
931
|
-
isSameState(getKey(successor.state), key),
|
|
932
|
-
),
|
|
933
|
-
);
|
|
934
|
-
} finally {
|
|
935
|
-
Object.assign(current, expanding);
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
const toTrace = (
|
|
939
|
-
steps: Successor[],
|
|
940
|
-
path: number[],
|
|
941
|
-
traceOptions: TraceOptions = {},
|
|
942
|
-
): Behavior => {
|
|
943
|
-
const alias = config.alias;
|
|
944
|
-
const known = traceOptions.known ?? 1;
|
|
945
|
-
const initialOutput = steps.length > 1 ? captureOutput(getSpecInitialStates).lines : [];
|
|
946
|
-
const stepActions = steps.map((step, position) =>
|
|
947
|
-
position === 0 || step.action === "Stuttering"
|
|
948
|
-
? { result: undefined, lines: [] }
|
|
949
|
-
: captureOutput(() =>
|
|
950
|
-
findStepAction(
|
|
951
|
-
path[position - 1],
|
|
952
|
-
steps[position - 1].state,
|
|
953
|
-
step.state,
|
|
954
|
-
known === 2 && position === steps.length - 1,
|
|
955
|
-
),
|
|
956
|
-
),
|
|
957
|
-
);
|
|
958
|
-
const outputs = stepActions.map((step) => step.lines);
|
|
959
|
-
const loopStart = traceOptions.loopStart;
|
|
960
|
-
const rebuilt = is174 && loopStart !== undefined ? loopStart + 1 : steps.length - known;
|
|
961
|
-
if (coverage && steps.length > 1) {
|
|
962
|
-
const isRebuiltAgain = known > 0 && !is174;
|
|
963
|
-
if (rebuilt > 0 && isRebuiltAgain) captureOutput(getSpecInitialStates);
|
|
964
|
-
if (isRebuiltAgain) {
|
|
965
|
-
steps.slice(1).forEach((step, position) => {
|
|
966
|
-
if (step.action === "Stuttering") return;
|
|
967
|
-
captureOutput(() =>
|
|
968
|
-
findStepAction(
|
|
969
|
-
path[position],
|
|
970
|
-
steps[position].state,
|
|
971
|
-
step.state,
|
|
972
|
-
known === 2 && position === steps.length - 2,
|
|
973
|
-
),
|
|
974
|
-
);
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
const prefixOutput = rebuilt > 0 ? [initialOutput, ...outputs.slice(1, rebuilt)].flat() : [];
|
|
979
|
-
return {
|
|
980
|
-
trace: steps.map((step, position) => {
|
|
981
|
-
const action = stepActions[position].result;
|
|
982
|
-
const traceStep: TraceStep = {
|
|
983
|
-
action: step.action,
|
|
984
|
-
label: action && getActionLabel(action, options.version),
|
|
985
|
-
state:
|
|
986
|
-
alias === undefined
|
|
987
|
-
? toRecord(step.state)
|
|
988
|
-
: getAliasState(alias, steps, position, loopStart),
|
|
989
|
-
output: position === 0 ? prefixOutput : position < rebuilt ? [] : outputs[position],
|
|
990
|
-
};
|
|
991
|
-
if (alias !== undefined || action) {
|
|
992
|
-
traceSteps.set(traceStep, { state: toRecord(step.state), action });
|
|
993
|
-
}
|
|
994
|
-
return traceStep;
|
|
995
|
-
}),
|
|
996
|
-
traceOutput: known > 0 && !is174 ? [initialOutput, ...outputs].flat() : [],
|
|
997
|
-
};
|
|
998
|
-
};
|
|
999
757
|
const getSpecInitialStates = () => {
|
|
1000
758
|
if (coverage) return getCoveredInitialStates();
|
|
1001
759
|
return spec.init === undefined ? [] : getInitialStates(spec.init, environment, spec.scope);
|
|
1002
760
|
};
|
|
1003
|
-
const findTraceSuccessor = (state: Value[], isMatch: (successor: Successor) => boolean) =>
|
|
1004
|
-
captureOutput(() => {
|
|
1005
|
-
for (const action of getSpecNextActions()) {
|
|
1006
|
-
const successor = getSuccessors(action.expression, state, environment, action.scope).find(
|
|
1007
|
-
isMatch,
|
|
1008
|
-
);
|
|
1009
|
-
if (successor) return { ...successor, action: successor.action ?? action.name };
|
|
1010
|
-
}
|
|
1011
|
-
return undefined;
|
|
1012
|
-
}).result;
|
|
1013
|
-
const hasFingerprint = (state: Value[], index: number) =>
|
|
1014
|
-
isSameState(getFingerprintState(state), fingerprintStates[index]);
|
|
1015
|
-
const findSuccessorWithFingerprint = (state: Value[], index: number) =>
|
|
1016
|
-
findTraceSuccessor(state, (successor) => hasFingerprint(successor.state, index));
|
|
1017
|
-
const getPathStates = (path: number[], nextFailure: string) => {
|
|
1018
|
-
const initial = captureOutput(() =>
|
|
1019
|
-
isReducing || isImpure(environment)
|
|
1020
|
-
? getSpecInitialStates().find((state) => hasFingerprint(state, path[0]))
|
|
1021
|
-
: states[path[0]],
|
|
1022
|
-
).result;
|
|
1023
|
-
if (!initial) throw new TlaEvaluationError(INITIAL_RECOVERY_FAILURE);
|
|
1024
|
-
const steps: Successor[] = [{ state: initial, action: undefined }];
|
|
1025
|
-
for (let position = 1; position < path.length; position++) {
|
|
1026
|
-
const previous = steps[position - 1].state;
|
|
1027
|
-
if (path[position - 1] === path[position]) {
|
|
1028
|
-
steps.push({ state: previous, action: "Stuttering" });
|
|
1029
|
-
continue;
|
|
1030
|
-
}
|
|
1031
|
-
const rebuilt = current.rebuilt;
|
|
1032
|
-
current.rebuilt = { state: previous, level: depths[path[position - 1]] };
|
|
1033
|
-
const successor = findSuccessorWithFingerprint(previous, path[position]);
|
|
1034
|
-
current.rebuilt = rebuilt;
|
|
1035
|
-
if (!successor) throw new TlaEvaluationError(nextFailure);
|
|
1036
|
-
steps.push(successor);
|
|
1037
|
-
}
|
|
1038
|
-
return steps;
|
|
1039
|
-
};
|
|
1040
|
-
const getTrace = (index: number, lastSuccessor?: Successor) => {
|
|
1041
|
-
const path: number[] = [];
|
|
1042
|
-
for (let position = index; position !== -1; position = parents[position]) {
|
|
1043
|
-
path.unshift(position);
|
|
1044
|
-
}
|
|
1045
|
-
const steps =
|
|
1046
|
-
isReducing && path.length > 1
|
|
1047
|
-
? getPathStates(path, INITIAL_RECOVERY_FAILURE)
|
|
1048
|
-
: path.map((position) => ({ state: states[position], action: actions[position] }));
|
|
1049
|
-
if (!lastSuccessor) return toTrace(steps, path);
|
|
1050
|
-
const action = isReducing
|
|
1051
|
-
? findTraceSuccessor(states[index], (successor) =>
|
|
1052
|
-
isSameState(successor.state, lastSuccessor.state),
|
|
1053
|
-
)?.action
|
|
1054
|
-
: lastSuccessor.action;
|
|
1055
|
-
return toTrace([...steps, { state: lastSuccessor.state, action }], path, { known: 2 });
|
|
1056
|
-
};
|
|
1057
|
-
// Deviation from TLC: TLCTrace#printTrace prints a lone initial state without the alias.
|
|
1058
|
-
const getStateTrace = (index: number): Behavior =>
|
|
1059
|
-
parents[index] === -1
|
|
1060
|
-
? {
|
|
1061
|
-
trace: [
|
|
1062
|
-
{
|
|
1063
|
-
action: undefined,
|
|
1064
|
-
label: undefined,
|
|
1065
|
-
state:
|
|
1066
|
-
config.alias === undefined
|
|
1067
|
-
? toRecord(states[index])
|
|
1068
|
-
: getAliasState(
|
|
1069
|
-
config.alias,
|
|
1070
|
-
[{ state: states[index], action: undefined }],
|
|
1071
|
-
0,
|
|
1072
|
-
undefined,
|
|
1073
|
-
),
|
|
1074
|
-
},
|
|
1075
|
-
],
|
|
1076
|
-
traceOutput: is174 ? [] : captureOutput(getSpecInitialStates).lines,
|
|
1077
|
-
}
|
|
1078
|
-
: getTrace(index);
|
|
1079
761
|
const isUnfingerprintable = (state: Value[]) => {
|
|
1080
762
|
try {
|
|
1081
763
|
return getFingerprintState(state).some((value) => getFingerprintError(value) !== undefined);
|
|
@@ -1084,31 +766,6 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1084
766
|
return true;
|
|
1085
767
|
}
|
|
1086
768
|
};
|
|
1087
|
-
const getFailedTrace = (index: number, successor: Successor): Behavior => ({
|
|
1088
|
-
trace: getTrace(index, successor).trace,
|
|
1089
|
-
});
|
|
1090
|
-
const getFailureExitCode = (error: TlaEvaluationError, failureOptions: FailureOptions) => {
|
|
1091
|
-
if (
|
|
1092
|
-
failureOptions.isInitial &&
|
|
1093
|
-
!failureOptions.callStack &&
|
|
1094
|
-
!failureOptions.fingerprint &&
|
|
1095
|
-
is174
|
|
1096
|
-
) {
|
|
1097
|
-
return EXIT_STATUS.success;
|
|
1098
|
-
}
|
|
1099
|
-
if (!failureOptions.callStack) {
|
|
1100
|
-
return failureOptions.isInitial ? getInitialExitCode(error) : getErrorExitCode(error);
|
|
1101
|
-
}
|
|
1102
|
-
if (failureOptions.isCallStackFirst) return getErrorExitCode(error);
|
|
1103
|
-
if (failureOptions.isLiveCallStack) {
|
|
1104
|
-
return (
|
|
1105
|
-
getExitCode(error) ?? (error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.error)
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
return failureOptions.isInitial || failureOptions.fingerprint
|
|
1109
|
-
? EXIT_STATUS.specEvaluationFailure
|
|
1110
|
-
: getReplayExitCode(failureOptions.replayError ?? error);
|
|
1111
|
-
};
|
|
1112
769
|
const createFailureResult = (
|
|
1113
770
|
failed: unknown,
|
|
1114
771
|
behavior: Behavior,
|
|
@@ -1124,7 +781,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1124
781
|
const traceOutput = [...(behavior.traceOutput ?? []), ...(checked?.lines ?? [])];
|
|
1125
782
|
return {
|
|
1126
783
|
...createResult("error", undefined, {
|
|
1127
|
-
...getFailureMessage(
|
|
784
|
+
...getFailureMessage(
|
|
785
|
+
error,
|
|
786
|
+
failureOptions.phase !== undefined && failureOptions.phase !== "initial",
|
|
787
|
+
),
|
|
1128
788
|
...behavior,
|
|
1129
789
|
...(traceOutput.length > 0 && { traceOutput }),
|
|
1130
790
|
...(postcondition && { postcondition }),
|
|
@@ -1132,9 +792,9 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1132
792
|
failureOptions.initialState && !(error instanceof TlaModuleError)
|
|
1133
793
|
? toRecord(failureOptions.initialState)
|
|
1134
794
|
: undefined,
|
|
1135
|
-
exitCode: getFailureExitCode(error, failureOptions),
|
|
795
|
+
exitCode: getFailureExitCode(error, failureOptions, is174),
|
|
1136
796
|
callStack: failureOptions.callStack,
|
|
1137
|
-
...(failureOptions.
|
|
797
|
+
...(failureOptions.phase === "liveness" && { isCallStackFirst: true }),
|
|
1138
798
|
...(failureOptions.fingerprint && { fingerprint: failureOptions.fingerprint }),
|
|
1139
799
|
...(failureOptions.traceFailure && { traceFailure: failureOptions.traceFailure }),
|
|
1140
800
|
}),
|
|
@@ -1143,9 +803,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1143
803
|
};
|
|
1144
804
|
const reportIncompleteSuccessor = (index: number, error: TlaIncompleteSuccessorError) => {
|
|
1145
805
|
runtime.generatedStates++;
|
|
1146
|
-
const actions = getSpecNextActions();
|
|
1147
806
|
const named =
|
|
1148
|
-
|
|
807
|
+
nextActions.length === 1
|
|
808
|
+
? nextActions
|
|
809
|
+
: nextActions.filter((item) => item.name === error.action);
|
|
1149
810
|
const action =
|
|
1150
811
|
named.length === 1
|
|
1151
812
|
? named[0]
|
|
@@ -1157,12 +818,12 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1157
818
|
const message = getIncompleteSuccessorMessage(
|
|
1158
819
|
error.variables,
|
|
1159
820
|
error.action,
|
|
1160
|
-
|
|
821
|
+
nextActions.length,
|
|
1161
822
|
options.version,
|
|
1162
823
|
);
|
|
1163
824
|
const undefinedValue = createModelValue("null");
|
|
1164
825
|
const partial = error.state.map((value) => value ?? undefinedValue);
|
|
1165
|
-
const failure = createFailureResult(error, getStateTrace(index));
|
|
826
|
+
const failure = createFailureResult(error, traces.getStateTrace(index));
|
|
1166
827
|
return withOutDegrees({
|
|
1167
828
|
...failure,
|
|
1168
829
|
failure: failure.failure && {
|
|
@@ -1182,65 +843,12 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1182
843
|
},
|
|
1183
844
|
});
|
|
1184
845
|
};
|
|
1185
|
-
const getPathSteps = (path: number[], loopStart?: number) => {
|
|
1186
|
-
const steps = getPathStates(path, NEXT_RECOVERY_FAILURE);
|
|
1187
|
-
const lastState = steps[steps.length - 1].state;
|
|
1188
|
-
const isClosed =
|
|
1189
|
-
!isReducing ||
|
|
1190
|
-
loopStart === undefined ||
|
|
1191
|
-
loopStart === path.length - 1 ||
|
|
1192
|
-
findSuccessorWithFingerprint(lastState, path[loopStart]) !== undefined;
|
|
1193
|
-
if (!isClosed) throw new TlaEvaluationError(NEXT_RECOVERY_FAILURE);
|
|
1194
|
-
return steps;
|
|
1195
|
-
};
|
|
1196
|
-
const getStateHash = (state: Value[]) => {
|
|
1197
|
-
let hash = 0x811c9dc5;
|
|
1198
|
-
for (let index = 0; index < state.length; index++)
|
|
1199
|
-
hash = combineHash(hash, getValueHash(state[index]));
|
|
1200
|
-
return hash & 0x3fffffff;
|
|
1201
|
-
};
|
|
1202
846
|
const fingerprintModelState = (state: Value[]) => {
|
|
1203
847
|
for (const value of state) {
|
|
1204
848
|
const error = getFingerprintError(value);
|
|
1205
849
|
if (error) throw error;
|
|
1206
850
|
}
|
|
1207
851
|
};
|
|
1208
|
-
const isSameState = (stored: Value[], state: Value[]) => {
|
|
1209
|
-
for (let position = 0; position < state.length; position++) {
|
|
1210
|
-
if (!isSameValue(stored[position], state[position])) return false;
|
|
1211
|
-
}
|
|
1212
|
-
return true;
|
|
1213
|
-
};
|
|
1214
|
-
const getSlot = (hash: number) => (Math.imul(hash, 0x9e3779b1) >>> seenStates.shift) << 1;
|
|
1215
|
-
const findStateIndex = (hash: number, state: Value[]) => {
|
|
1216
|
-
const mask = seenStates.slots.length - 1;
|
|
1217
|
-
for (let slot = getSlot(hash); ; slot = (slot + 2) & mask) {
|
|
1218
|
-
const entry = seenStates.slots[slot + 1];
|
|
1219
|
-
if (entry === 0) return -1;
|
|
1220
|
-
if (seenStates.slots[slot] === hash && isSameState(fingerprintStates[entry - 1], state)) {
|
|
1221
|
-
return entry - 1;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
};
|
|
1225
|
-
const insertSeen = (hash: number, entry: number) => {
|
|
1226
|
-
const mask = seenStates.slots.length - 1;
|
|
1227
|
-
let slot = getSlot(hash);
|
|
1228
|
-
while (seenStates.slots[slot + 1] !== 0) slot = (slot + 2) & mask;
|
|
1229
|
-
seenStates.slots[slot] = hash;
|
|
1230
|
-
seenStates.slots[slot + 1] = entry;
|
|
1231
|
-
};
|
|
1232
|
-
const markSeen = (hash: number, index: number) => {
|
|
1233
|
-
seenStates.size++;
|
|
1234
|
-
if (seenStates.size * 4 > seenStates.slots.length) {
|
|
1235
|
-
const slots = seenStates.slots;
|
|
1236
|
-
seenStates.slots = new Int32Array(slots.length * 2);
|
|
1237
|
-
seenStates.shift--;
|
|
1238
|
-
for (let slot = 0; slot < slots.length; slot += 2) {
|
|
1239
|
-
if (slots[slot + 1] !== 0) insertSeen(slots[slot], slots[slot + 1]);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
insertSeen(hash, index + 1);
|
|
1243
|
-
};
|
|
1244
852
|
let unstoredFingerprint: Value[] | undefined;
|
|
1245
853
|
const countDistinctState = (depth: number) => {
|
|
1246
854
|
runtime.distinctStates = states.length + 1;
|
|
@@ -1269,11 +877,33 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1269
877
|
livenessSource: -1,
|
|
1270
878
|
rebuilt: undefined,
|
|
1271
879
|
};
|
|
880
|
+
const traces = createTraceBuilder({
|
|
881
|
+
config,
|
|
882
|
+
options,
|
|
883
|
+
environment,
|
|
884
|
+
search,
|
|
885
|
+
nextActions,
|
|
886
|
+
current,
|
|
887
|
+
states,
|
|
888
|
+
fingerprintStates,
|
|
889
|
+
parents,
|
|
890
|
+
actions,
|
|
891
|
+
depths,
|
|
892
|
+
tracedSteps,
|
|
893
|
+
captureOutput,
|
|
894
|
+
getInitialStates: getSpecInitialStates,
|
|
895
|
+
findSuccessorAction: (state, isMatch) =>
|
|
896
|
+
coverage
|
|
897
|
+
? coverageActions.find((item) => getCoveredSuccessors(item, state).some(isMatch))
|
|
898
|
+
: nextActions.find((item) =>
|
|
899
|
+
getSuccessors(item.expression, state, environment, item.scope).some(isMatch),
|
|
900
|
+
),
|
|
901
|
+
});
|
|
1272
902
|
const getPath = (index: number): Value[][] =>
|
|
1273
903
|
index === -1 ? [] : [...getPath(parents[index]), states[index]];
|
|
1274
904
|
runtime.isSeen = (state) => {
|
|
1275
905
|
const fingerprintState = getFingerprintState(state);
|
|
1276
|
-
return findStateIndex(getStateHash(fingerprintState), fingerprintState) !== -1;
|
|
906
|
+
return findStateIndex(seenStates, getStateHash(fingerprintState), fingerprintState) !== -1;
|
|
1277
907
|
};
|
|
1278
908
|
runtime.getBehavior = (state) => {
|
|
1279
909
|
const index = state === current.candidate ? -1 : states.indexOf(state);
|
|
@@ -1309,7 +939,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1309
939
|
formatState(
|
|
1310
940
|
config.alias === undefined
|
|
1311
941
|
? toRecord(state)
|
|
1312
|
-
: evaluateAlias(config.alias, state, undefined),
|
|
942
|
+
: search.evaluateAlias(config.alias, state, undefined, options.isTool ?? false),
|
|
1313
943
|
),
|
|
1314
944
|
getText: () => formatState(toRecord(state)),
|
|
1315
945
|
});
|
|
@@ -1328,7 +958,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1328
958
|
fingerprintModelState(fingerprintState);
|
|
1329
959
|
state.forEach(markFingerprinted);
|
|
1330
960
|
}
|
|
1331
|
-
const isSeen = isInModel && findStateIndex(hash, fingerprintState) !== -1;
|
|
961
|
+
const isSeen = isInModel && findStateIndex(seenStates, hash, fingerprintState) !== -1;
|
|
1332
962
|
if (isSeen) return undefined;
|
|
1333
963
|
unstoredFingerprint = isInModel ? fingerprintState : undefined;
|
|
1334
964
|
if (isInModel) {
|
|
@@ -1341,7 +971,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1341
971
|
search.getViolatedInvariants(state).forEach((invariant) =>
|
|
1342
972
|
reportContinuedViolation("invariant-violation", {
|
|
1343
973
|
name: invariant.name,
|
|
1344
|
-
...toTrace([{ action: undefined, state }], []),
|
|
974
|
+
...traces.toTrace([{ action: undefined, state }], []),
|
|
1345
975
|
}),
|
|
1346
976
|
);
|
|
1347
977
|
}
|
|
@@ -1349,18 +979,18 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1349
979
|
if (violated) {
|
|
1350
980
|
return reportViolation("invariant-violation", {
|
|
1351
981
|
name: violated.name,
|
|
1352
|
-
...toTrace([{ action: undefined, state }], []),
|
|
982
|
+
...traces.toTrace([{ action: undefined, state }], []),
|
|
1353
983
|
});
|
|
1354
984
|
}
|
|
1355
985
|
const failedPredicate = search.findFailedInitialPredicate(state);
|
|
1356
986
|
if (failedPredicate) {
|
|
1357
987
|
return reportViolation("liveness-violation", {
|
|
1358
988
|
name: failedPredicate.name,
|
|
1359
|
-
...toTrace([{ action: undefined, state }], []),
|
|
989
|
+
...traces.toTrace([{ action: undefined, state }], []),
|
|
1360
990
|
});
|
|
1361
991
|
}
|
|
1362
992
|
if (!isInModel) return undefined;
|
|
1363
|
-
|
|
993
|
+
markSeenState(seenStates, hash, states.length);
|
|
1364
994
|
addState(state, fingerprintState, -1, undefined);
|
|
1365
995
|
return undefined;
|
|
1366
996
|
};
|
|
@@ -1378,7 +1008,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1378
1008
|
if (isCanonicalizedFirst) canonicalizeState(successor.state);
|
|
1379
1009
|
const fingerprintState = getFingerprintState(successor.state);
|
|
1380
1010
|
const hash = getStateHash(fingerprintState);
|
|
1381
|
-
const foundIndex = findStateIndex(hash, fingerprintState);
|
|
1011
|
+
const foundIndex = findStateIndex(seenStates, hash, fingerprintState);
|
|
1382
1012
|
const isStateInModel = search.satisfiesConstraints(successor.state, state);
|
|
1383
1013
|
if (isStateInModel) search.trackStatePossible(successor.state);
|
|
1384
1014
|
const isInModel = isStateInModel && search.satisfiesActionConstraints(state, successor.state);
|
|
@@ -1425,7 +1055,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1425
1055
|
if (existing === -1) {
|
|
1426
1056
|
try {
|
|
1427
1057
|
const violated = search.findViolatedInvariant(successor.state, state);
|
|
1428
|
-
const violation = violated && { name: violated.name, ...getTrace(index, successor) };
|
|
1058
|
+
const violation = violated && { name: violated.name, ...traces.getTrace(index, successor) };
|
|
1429
1059
|
if (violation && !options.isContinued) {
|
|
1430
1060
|
return withOutDegrees(reportViolation("invariant-violation", violation));
|
|
1431
1061
|
}
|
|
@@ -1435,7 +1065,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1435
1065
|
const replay = captureOutput(() => replayNext(index));
|
|
1436
1066
|
return createFailureResult(
|
|
1437
1067
|
error,
|
|
1438
|
-
appendTraceOutput(getFailedTrace(index, successor), replay.lines),
|
|
1068
|
+
appendTraceOutput(traces.getFailedTrace(index, successor), replay.lines),
|
|
1439
1069
|
replay.result ?? { outDegrees: getFailureOutDegrees() },
|
|
1440
1070
|
);
|
|
1441
1071
|
}
|
|
@@ -1443,7 +1073,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1443
1073
|
const violatedProperty = search.findViolatedActionProperty(state, successor.state);
|
|
1444
1074
|
const propertyViolation = violatedProperty && {
|
|
1445
1075
|
name: violatedProperty.name,
|
|
1446
|
-
...getTrace(index, successor),
|
|
1076
|
+
...traces.getTrace(index, successor),
|
|
1447
1077
|
};
|
|
1448
1078
|
if (propertyViolation && !options.isContinued) {
|
|
1449
1079
|
return withOutDegrees(reportViolation("liveness-violation", propertyViolation));
|
|
@@ -1452,7 +1082,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1452
1082
|
if (!isNew) return undefined;
|
|
1453
1083
|
if (coverage) countCoverageVariables(coverage, successor.state);
|
|
1454
1084
|
if (!isCanonicalizedFirst) canonicalizeState(successor.state);
|
|
1455
|
-
|
|
1085
|
+
markSeenState(seenStates, hash, states.length);
|
|
1456
1086
|
addState(successor.state, fingerprintState, index, successor.action);
|
|
1457
1087
|
runtime.queueSize++;
|
|
1458
1088
|
return undefined;
|
|
@@ -1473,7 +1103,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1473
1103
|
return createFailureResult(
|
|
1474
1104
|
error,
|
|
1475
1105
|
{ trace: [], traceOutput: replay.lines },
|
|
1476
|
-
{ initialState: state, ...replay.result,
|
|
1106
|
+
{ initialState: state, ...replay.result, phase: "initial" },
|
|
1477
1107
|
);
|
|
1478
1108
|
};
|
|
1479
1109
|
try {
|
|
@@ -1500,9 +1130,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1500
1130
|
(state) => {
|
|
1501
1131
|
if (onInitialState(state)) throw STOP_WALK;
|
|
1502
1132
|
},
|
|
1503
|
-
|
|
1504
|
-
throw setExitCode(new TlaIllegalStateError([...partial]), EXIT_STATUS.error);
|
|
1505
|
-
},
|
|
1133
|
+
rejectIncompleteInitialState,
|
|
1506
1134
|
);
|
|
1507
1135
|
} catch (error) {
|
|
1508
1136
|
if (error !== STOP_WALK) throw error;
|
|
@@ -1529,7 +1157,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1529
1157
|
return createFailureResult(
|
|
1530
1158
|
error,
|
|
1531
1159
|
{ trace: [], traceOutput: replay.lines },
|
|
1532
|
-
{ ...replay.result,
|
|
1160
|
+
{ ...replay.result, phase: "initial" },
|
|
1533
1161
|
);
|
|
1534
1162
|
}
|
|
1535
1163
|
}
|
|
@@ -1589,7 +1217,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1589
1217
|
);
|
|
1590
1218
|
}
|
|
1591
1219
|
let isStopped = false;
|
|
1592
|
-
return
|
|
1220
|
+
return nextActions.reduce((count, action) => {
|
|
1593
1221
|
if (isStopped) return count;
|
|
1594
1222
|
return (
|
|
1595
1223
|
count +
|
|
@@ -1610,7 +1238,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1610
1238
|
};
|
|
1611
1239
|
const getLiveCallStack = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1612
1240
|
if (!liveness || is174) return undefined;
|
|
1613
|
-
const replay = getReplayFailure((tracing) =>
|
|
1241
|
+
const replay = getReplayFailure(environment, (tracing) =>
|
|
1614
1242
|
liveness.addState(index, states[index], liveSuccessors, tracing),
|
|
1615
1243
|
);
|
|
1616
1244
|
return replay?.callStack.length && !replay.fingerprint ? replay.callStack : undefined;
|
|
@@ -1627,14 +1255,14 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1627
1255
|
const replayFailedNext = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1628
1256
|
const live = captureOutput(() => addFailedLiveState(index, liveSuccessors));
|
|
1629
1257
|
if (live.result) {
|
|
1630
|
-
const result = { callStack: live.result
|
|
1258
|
+
const result: FailureOptions = { phase: "behavior-graph", callStack: live.result };
|
|
1631
1259
|
return { result, lines: live.lines };
|
|
1632
1260
|
}
|
|
1633
1261
|
const replay = captureOutput(() => replayNext(index));
|
|
1634
1262
|
return { result: replay.result, lines: [...live.lines, ...replay.lines] };
|
|
1635
1263
|
};
|
|
1636
1264
|
const reportNextStateOverflow = (index: number) =>
|
|
1637
|
-
createFailureResult(createStackOverflowError(), getStateTrace(index), {
|
|
1265
|
+
createFailureResult(createStackOverflowError(), traces.getStateTrace(index), { phase: "next" });
|
|
1638
1266
|
const reportNextStateFailure = (
|
|
1639
1267
|
error: unknown,
|
|
1640
1268
|
index: number,
|
|
@@ -1644,8 +1272,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1644
1272
|
const replay = replayFailedNext(index, liveSuccessors);
|
|
1645
1273
|
return createFailureResult(
|
|
1646
1274
|
withNextStateExitCode(error),
|
|
1647
|
-
appendTraceOutput(getStateTrace(index), replay.lines),
|
|
1648
|
-
{
|
|
1275
|
+
appendTraceOutput(traces.getStateTrace(index), replay.lines),
|
|
1276
|
+
{ phase: "next", ...replay.result },
|
|
1649
1277
|
);
|
|
1650
1278
|
};
|
|
1651
1279
|
const expandState = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
@@ -1676,7 +1304,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1676
1304
|
outcome = createFailureResult(
|
|
1677
1305
|
new TlaEvaluationError(`${getWrappedException(error)}${error.message}`, error),
|
|
1678
1306
|
appendTraceOutput({ trace: [] }, replay.lines),
|
|
1679
|
-
{
|
|
1307
|
+
{ phase: "next", ...replay.result },
|
|
1680
1308
|
);
|
|
1681
1309
|
return true;
|
|
1682
1310
|
}
|
|
@@ -1693,10 +1321,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1693
1321
|
outcome = createFailureResult(
|
|
1694
1322
|
error,
|
|
1695
1323
|
appendTraceOutput(
|
|
1696
|
-
traceFailure ? getStateTrace(index) : getFailedTrace(index, successor),
|
|
1324
|
+
traceFailure ? traces.getStateTrace(index) : traces.getFailedTrace(index, successor),
|
|
1697
1325
|
replay.lines,
|
|
1698
1326
|
),
|
|
1699
|
-
{
|
|
1327
|
+
{ phase: "next", ...replay.result, traceFailure },
|
|
1700
1328
|
);
|
|
1701
1329
|
}
|
|
1702
1330
|
return outcome !== undefined;
|
|
@@ -1718,7 +1346,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1718
1346
|
}
|
|
1719
1347
|
const accepted = liveness?.addState(index, state, liveSuccessors);
|
|
1720
1348
|
if (!liveness || !accepted) return undefined;
|
|
1721
|
-
const steps = getPathSteps(accepted);
|
|
1349
|
+
const steps = traces.getPathSteps(accepted);
|
|
1722
1350
|
const properties = getViolatedProperties(
|
|
1723
1351
|
liveness,
|
|
1724
1352
|
steps.map((step) => step.state),
|
|
@@ -1727,11 +1355,14 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1727
1355
|
return reportViolation("property-violation", {
|
|
1728
1356
|
name: properties[0],
|
|
1729
1357
|
properties,
|
|
1730
|
-
...toTrace(steps, accepted, { known: 0 }),
|
|
1358
|
+
...traces.toTrace(steps, accepted, { known: 0 }),
|
|
1731
1359
|
});
|
|
1732
1360
|
};
|
|
1733
1361
|
if (successorCount === 0 && config.checkDeadlock) {
|
|
1734
|
-
const deadlock = reportViolation("deadlock", {
|
|
1362
|
+
const deadlock = reportViolation("deadlock", {
|
|
1363
|
+
name: "deadlock",
|
|
1364
|
+
...traces.getStateTrace(index),
|
|
1365
|
+
});
|
|
1735
1366
|
const live = captureOutput(() => {
|
|
1736
1367
|
try {
|
|
1737
1368
|
return { additional: addLiveState()?.violation };
|
|
@@ -1764,14 +1395,13 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1764
1395
|
{ outDegrees: getFailureOutDegrees() },
|
|
1765
1396
|
);
|
|
1766
1397
|
}
|
|
1767
|
-
const replay = getReplayFailure((tracing) =>
|
|
1398
|
+
const replay = getReplayFailure(environment, (tracing) =>
|
|
1768
1399
|
liveness?.addState(index, state, liveSuccessors, tracing),
|
|
1769
1400
|
);
|
|
1770
|
-
return createFailureResult(error, getStateTrace(index), {
|
|
1401
|
+
return createFailureResult(error, traces.getStateTrace(index), {
|
|
1771
1402
|
outDegrees: getFailureOutDegrees(),
|
|
1772
1403
|
callStack: replay?.callStack.length ? replay.callStack : undefined,
|
|
1773
|
-
|
|
1774
|
-
isCallStackFirst: true,
|
|
1404
|
+
phase: "liveness",
|
|
1775
1405
|
});
|
|
1776
1406
|
}
|
|
1777
1407
|
};
|
|
@@ -1795,8 +1425,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1795
1425
|
const reportLasso = (checker: LivenessChecker, lasso: Lasso) => {
|
|
1796
1426
|
const path = [...lasso.prefix, ...lasso.cycle];
|
|
1797
1427
|
const loopStart = lasso.prefix.length;
|
|
1798
|
-
const steps = getPathSteps(path, loopStart);
|
|
1799
|
-
const trace = toTrace(steps, path, { loopStart, known: 0 }).trace;
|
|
1428
|
+
const steps = traces.getPathSteps(path, loopStart);
|
|
1429
|
+
const trace = traces.toTrace(steps, path, { loopStart, known: 0 }).trace;
|
|
1800
1430
|
const properties = getViolatedProperties(
|
|
1801
1431
|
checker,
|
|
1802
1432
|
steps.map((step) => step.state),
|
|
@@ -1808,7 +1438,9 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1808
1438
|
const loop =
|
|
1809
1439
|
cycleStart === cycleEnd
|
|
1810
1440
|
? { result: undefined, lines: [] }
|
|
1811
|
-
: captureOutput(() =>
|
|
1441
|
+
: captureOutput(() =>
|
|
1442
|
+
traces.findStepAction(cycleEnd, lastState, states[cycleStart], false),
|
|
1443
|
+
);
|
|
1812
1444
|
const isStutteringWarned = cycleStart === cycleEnd && lasso.isCycleConstrained;
|
|
1813
1445
|
return reportViolation(
|
|
1814
1446
|
"liveness-violation",
|
|
@@ -1826,7 +1458,9 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1826
1458
|
? getStepAction(trace[trace.length - 1])
|
|
1827
1459
|
: loop.result
|
|
1828
1460
|
? toActionValue(loop.result)
|
|
1829
|
-
: createActionRecord(
|
|
1461
|
+
: createActionRecord(
|
|
1462
|
+
traces.findSuccessorWithFingerprint(lastState, cycleStart)?.action,
|
|
1463
|
+
),
|
|
1830
1464
|
);
|
|
1831
1465
|
};
|
|
1832
1466
|
const isPeriodic = liveness !== undefined && (options.livenessCheck ?? "default") === "default";
|