tla-ts 0.0.10-dev.a17d6d9fa → 0.0.10-dev.a4b81b6d0
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +65 -65
- package/dist/prove.js +76 -76
- package/dist/run.cjs +34 -34
- package/dist/run.js +42 -42
- package/dist/transfer.cjs +28 -28
- package/dist/transfer.js +12 -12
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +1 -1
- package/src/check-failure.ts +8 -5
- package/src/check-trace.ts +35 -22
- package/src/check.ts +119 -60
- package/src/cli/tlc-output.ts +1 -0
- package/src/codegen.ts +5 -3
- package/src/dependencies.ts +5 -4
- package/src/evaluate.ts +33 -14
- package/src/exit-codes.ts +26 -13
- package/src/liveness-checker.ts +69 -51
- package/src/search.ts +47 -14
- package/src/simulate.ts +64 -61
- package/src/standard-modules.ts +41 -16
- package/src/successors.ts +3 -1
- package/src/symmetry.ts +1 -0
- package/src/tlc/replay.ts +19 -12
- package/src/typed-tier.ts +6 -2
package/dist/worker.cjs
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>
|
|
9
|
+
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>({branches:e.branches,solutions:e.solutions,addInitialState:(t,n,r)=>o(()=>e.addInitialState(t,n,r)),addState:(t,n,r,i)=>o(()=>e.addState(t,n,r,i)),storeState:e.storeState,getStateCounts:e.getStateCounts,findViolation:()=>o(()=>e.findViolation()),getViolatedProperties:(t,n)=>o(()=>e.getViolatedProperties(t,n))}),ee=e=>{let t=o(e);return t&&s(t)},c=e=>{let t=o(e);return t&&{solutions:t.solutions,createChecker:(e,n)=>s(t.createChecker(e,n))}},l=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,te=l(`java.lang.RuntimeException`),u=l(`tlc2.tool.EvalException`),d=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`||e instanceof SyntaxError&&e.message.endsWith(`: Stack overflow`);var f=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},p=class extends f{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},m=class extends p{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},h=class extends m{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const g=(e,t=!1,n,r=[])=>new p(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
10
|
|
|
11
|
-
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),
|
|
12
|
-
`)}`,
|
|
11
|
+
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),_=(e,t)=>g([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),v=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
+
`)}`,y=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,ne=(e,t)=>g([{location:y(t),message:e}]);var b=class extends f{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},x=class extends f{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const S=`This was a Java StackOverflowError. It was probably the result
|
|
13
13
|
of an incorrect recursive function definition that caused TLC to enter
|
|
14
14
|
an infinite loop when trying to compute the function or its application
|
|
15
|
-
to an element in its putative domain.`;var
|
|
15
|
+
to an element in its putative domain.`;var C=class extends x{constructor(){super(S)}};const w=()=>i(new C,e.error);var T=class extends x{},E=class extends x{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},D=class extends x{variable;constructor(e,t){super(e),this.variable=t}},O=class extends x{exitCode;constructor(t,n=e.error){super(t),this.exitCode=n}},k=class extends x{constructor(t){super(t),i(this,e.error)}},A=class extends T{constructor(){super(`PickSuccessor reached the end of standard input without an answer whether to extend the behavior.`)}},j=class extends x{constructor(t){super(`The directory ${t} holds no checkpoint to recover from.`),i(this,e.error)}},M=class extends x{},N=class extends x{};const P=`Too many possible next states for the last state in the trace.`;var F=class extends x{constructor(){super(P)}},I=class extends x{code;constructor(e,t){super(t),this.code=e}},L=class extends x{state;constructor(e){super(`current state is not a legal state`),this.state=e}},R=class extends f{failure;exception;locus;constructor(e,t={}){super(e),this.locus=t.locus,this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},z=class extends R{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e})}},B=class extends f{constructor(e,t){super(e,t),this.name=`TlaProverError`}},V=class extends B{locus;constructor(e,t){super(e),this.name=`TlaMethodError`,this.locus=t}},H=class extends f{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},U=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}};const W=(e,t)=>e instanceof U&&e.exception===t;var G=class extends f{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},K=class extends f{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},q=class extends f{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},J=class extends f{constructor(e){super(e),this.name=`SmtDefaultError`}},Y=class extends f{constructor(e){super(e),this.name=`SmtInvariantError`}},X=class extends f{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},Z=class extends f{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},re=class extends f{line;column;constructor(e,t){super(e),this.name=`SmtParseError`,this.line=t.line,this.column=t.column}},ie=class extends G{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const ae=t=>a(t)??(t instanceof p?e.specParseError:t instanceof b?e.configParseError:t instanceof x?e.specEvaluationFailure:e.error);var oe=class extends f{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},se=class extends f{constructor(e){super(e),this.name=`PcalRuntimeError`}},Q=class extends f{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}},ce=class extends f{constructor(e,t){let n=t?.getSourceFile(),r=n?.getLineAndCharacterOfPosition(t?.getStart()??0);super(n===void 0||r===void 0?e:`${n.fileName}:${r.line+1}:${r.character+1} ${e}`),this.name=`TlaTypeScriptError`}};const $=`node:worker_threads`,le=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,ue=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
16
|
/* @vite-ignore */
|
|
17
17
|
/* webpackIgnore: true */
|
|
18
|
-
|
|
18
|
+
$))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},de=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
19
19
|
/* @vite-ignore */
|
|
20
20
|
/* webpackIgnore: true */
|
|
21
|
-
|
|
21
|
+
$)).parentPort,fe=()=>{let e=`Bun`in globalThis?import(
|
|
22
22
|
/* @vite-ignore */
|
|
23
23
|
/* webpackIgnore: true */
|
|
24
|
-
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return
|
|
24
|
+
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return D}});
|
package/dist/worker.js
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>
|
|
9
|
+
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>({branches:e.branches,solutions:e.solutions,addInitialState:(t,n,r)=>o(()=>e.addInitialState(t,n,r)),addState:(t,n,r,i)=>o(()=>e.addState(t,n,r,i)),storeState:e.storeState,getStateCounts:e.getStateCounts,findViolation:()=>o(()=>e.findViolation()),getViolatedProperties:(t,n)=>o(()=>e.getViolatedProperties(t,n))}),ee=e=>{let t=o(e);return t&&s(t)},c=e=>{let t=o(e);return t&&{solutions:t.solutions,createChecker:(e,n)=>s(t.createChecker(e,n))}},l=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,te=l(`java.lang.RuntimeException`),u=l(`tlc2.tool.EvalException`),d=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`||e instanceof SyntaxError&&e.message.endsWith(`: Stack overflow`);var f=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},p=class extends f{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},m=class extends p{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},h=class extends m{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const g=(e,t=!1,n,r=[])=>new p(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
10
|
|
|
11
|
-
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),
|
|
12
|
-
`)}`,
|
|
11
|
+
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),_=(e,t)=>g([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),v=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
+
`)}`,y=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,ne=(e,t)=>g([{location:y(t),message:e}]);var b=class extends f{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},x=class extends f{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const S=`This was a Java StackOverflowError. It was probably the result
|
|
13
13
|
of an incorrect recursive function definition that caused TLC to enter
|
|
14
14
|
an infinite loop when trying to compute the function or its application
|
|
15
|
-
to an element in its putative domain.`;var
|
|
15
|
+
to an element in its putative domain.`;var C=class extends x{constructor(){super(S)}};const w=()=>i(new C,e.error);var T=class extends x{},E=class extends x{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},D=class extends x{variable;constructor(e,t){super(e),this.variable=t}},O=class extends x{exitCode;constructor(t,n=e.error){super(t),this.exitCode=n}},k=class extends x{constructor(t){super(t),i(this,e.error)}},A=class extends T{constructor(){super(`PickSuccessor reached the end of standard input without an answer whether to extend the behavior.`)}},j=class extends x{constructor(t){super(`The directory ${t} holds no checkpoint to recover from.`),i(this,e.error)}},M=class extends x{},N=class extends x{};const P=`Too many possible next states for the last state in the trace.`;var F=class extends x{constructor(){super(P)}},I=class extends x{code;constructor(e,t){super(t),this.code=e}},L=class extends x{state;constructor(e){super(`current state is not a legal state`),this.state=e}},R=class extends f{failure;exception;locus;constructor(e,t={}){super(e),this.locus=t.locus,this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},z=class extends R{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e})}},B=class extends f{constructor(e,t){super(e,t),this.name=`TlaProverError`}},V=class extends B{locus;constructor(e,t){super(e),this.name=`TlaMethodError`,this.locus=t}},H=class extends f{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},U=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}};const W=(e,t)=>e instanceof U&&e.exception===t;var G=class extends f{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},K=class extends f{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},q=class extends f{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},J=class extends f{constructor(e){super(e),this.name=`SmtDefaultError`}},Y=class extends f{constructor(e){super(e),this.name=`SmtInvariantError`}},X=class extends f{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},Z=class extends f{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},re=class extends f{line;column;constructor(e,t){super(e),this.name=`SmtParseError`,this.line=t.line,this.column=t.column}},ie=class extends G{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const ae=t=>a(t)??(t instanceof p?e.specParseError:t instanceof b?e.configParseError:t instanceof x?e.specEvaluationFailure:e.error);var oe=class extends f{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},se=class extends f{constructor(e){super(e),this.name=`PcalRuntimeError`}},Q=class extends f{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}},ce=class extends f{constructor(e,t){let n=t?.getSourceFile(),r=n?.getLineAndCharacterOfPosition(t?.getStart()??0);super(n===void 0||r===void 0?e:`${n.fileName}:${r.line+1}:${r.character+1} ${e}`),this.name=`TlaTypeScriptError`}};const $=`node:worker_threads`,le=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,ue=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
16
|
/* @vite-ignore */
|
|
17
17
|
/* webpackIgnore: true */
|
|
18
|
-
|
|
18
|
+
$))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},de=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
19
19
|
/* @vite-ignore */
|
|
20
20
|
/* webpackIgnore: true */
|
|
21
|
-
|
|
21
|
+
$)).parentPort,fe=()=>{let e=`Bun`in globalThis?import(
|
|
22
22
|
/* @vite-ignore */
|
|
23
23
|
/* webpackIgnore: true */
|
|
24
|
-
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};export{
|
|
24
|
+
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};export{ae as $,O as A,T as B,L as C,V as D,ie as E,C as F,u as G,I as H,p as I,g as J,te as K,F as L,B as M,m as N,j as O,N as P,v as Q,ce as R,k as S,U as T,H as U,G as V,z as W,w as X,ne as Y,y as Z,M as _,X as a,n as at,f as b,se as c,ee as ct,q as d,l as et,J as f,P as g,K as h,ue as i,a as it,R as j,h as k,Z as l,re as m,de as n,d as nt,Q as o,i as ot,Y as p,_ as q,le as r,e as rt,oe as s,c as st,fe as t,W as tt,S as u,b as v,E as w,x,A as y,D as z};
|
package/package.json
CHANGED
package/src/check-failure.ts
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
type FingerprintFailure,
|
|
8
8
|
} from "./evaluate";
|
|
9
9
|
import { EXIT_STATUS, getExitCode, getMessageExitStatus } from "./exit-codes";
|
|
10
|
-
import {
|
|
10
|
+
import type { TraceFailure } from "./check";
|
|
11
|
+
import { getCodedMessage } from "./tlc/messages";
|
|
11
12
|
import { getFingerprintError, getHeldValues, markFingerprinted, type Value } from "./values";
|
|
12
13
|
|
|
13
14
|
export interface ReplayFailure {
|
|
@@ -24,7 +25,7 @@ export interface FailureOptions {
|
|
|
24
25
|
callStack?: Expression[];
|
|
25
26
|
fingerprint?: FingerprintFailure;
|
|
26
27
|
replayError?: TlaEvaluationError;
|
|
27
|
-
traceFailure?:
|
|
28
|
+
traceFailure?: TraceFailure;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const getInitialExitCode = (error: TlaEvaluationError) => {
|
|
@@ -42,6 +43,9 @@ const getReplayExitCode = (error: TlaEvaluationError): number => {
|
|
|
42
43
|
return error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.specEvaluationFailure;
|
|
43
44
|
};
|
|
44
45
|
|
|
46
|
+
const getCodeExitCode = (error: TlaEvaluationError) =>
|
|
47
|
+
getExitCode(error) ?? (error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.error);
|
|
48
|
+
|
|
45
49
|
export const getFailureExitCode = (
|
|
46
50
|
error: TlaEvaluationError,
|
|
47
51
|
failureOptions: FailureOptions,
|
|
@@ -53,12 +57,11 @@ export const getFailureExitCode = (
|
|
|
53
57
|
if (isReplayed) return EXIT_STATUS.specEvaluationFailure;
|
|
54
58
|
return is174 ? EXIT_STATUS.success : getInitialExitCode(error);
|
|
55
59
|
case "behavior-graph":
|
|
56
|
-
return (
|
|
57
|
-
getExitCode(error) ?? (error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.error)
|
|
58
|
-
);
|
|
60
|
+
return getCodeExitCode(error);
|
|
59
61
|
case "liveness":
|
|
60
62
|
return error instanceof TlaModuleError ? error.exitCode : getErrorExitCode(error);
|
|
61
63
|
default:
|
|
64
|
+
if (!isReplayed && failureOptions.phase === "next" && !is174) return getCodeExitCode(error);
|
|
62
65
|
if (!isReplayed) return getErrorExitCode(error);
|
|
63
66
|
return failureOptions.fingerprint
|
|
64
67
|
? EXIT_STATUS.specEvaluationFailure
|
package/src/check-trace.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { getStateHash, isSameState } from "./fingerprints";
|
|
|
6
6
|
import type { Search } from "./search";
|
|
7
7
|
import { getActionLabel, type SpecAction } from "./spec-description";
|
|
8
8
|
import { getSuccessors, type Successor } from "./successors";
|
|
9
|
-
import { createModelValue, type Value } from "./values";
|
|
9
|
+
import { createModelValue, getFingerprintError, isSameValue, type Value } from "./values";
|
|
10
10
|
|
|
11
11
|
export interface Behavior {
|
|
12
12
|
trace: TraceStep[];
|
|
@@ -17,6 +17,7 @@ interface TraceOptions {
|
|
|
17
17
|
loopStart?: number;
|
|
18
18
|
known?: number;
|
|
19
19
|
incomplete?: State;
|
|
20
|
+
isFailed?: boolean;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
interface RebuiltState {
|
|
@@ -54,6 +55,7 @@ interface TraceContext {
|
|
|
54
55
|
tracedSteps: WeakMap<TraceStep, TracedStep>;
|
|
55
56
|
captureOutput: <Result>(rebuild: () => Result) => { result: Result; lines: OutputLine[] };
|
|
56
57
|
getInitialStates: () => Value[][];
|
|
58
|
+
getUncoveredInitialStates: () => Value[][];
|
|
57
59
|
findSuccessorAction: (
|
|
58
60
|
state: Value[],
|
|
59
61
|
isMatch: (successor: Successor) => boolean,
|
|
@@ -101,15 +103,23 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
101
103
|
current.rebuilt = { state, level };
|
|
102
104
|
runtime.reseedRandom();
|
|
103
105
|
};
|
|
106
|
+
// TLC's TLCStateMut#equals compares the variables in turn, and a lazy value fails as it reaches it.
|
|
107
|
+
const isEqualState = (state: Value[], successor: Value[]) =>
|
|
108
|
+
state.every((value, position) => {
|
|
109
|
+
const error = getFingerprintError(value);
|
|
110
|
+
if (error) throw error;
|
|
111
|
+
return isSameValue(value, successor[position]);
|
|
112
|
+
});
|
|
104
113
|
const findStepAction = (index: number, previous: Value[], state: Value[], isHeld: boolean) => {
|
|
105
114
|
const expanding = { ...current };
|
|
106
115
|
Object.assign(current, { index, isExpanding: true, candidate: undefined });
|
|
107
116
|
rebuildFrom(previous, depths[index]);
|
|
108
|
-
const
|
|
109
|
-
const key = getKey(state);
|
|
117
|
+
const key = isHeld ? state : getFingerprintState(state);
|
|
110
118
|
try {
|
|
111
119
|
return context.findSuccessorAction(previous, (successor) =>
|
|
112
|
-
|
|
120
|
+
isHeld
|
|
121
|
+
? isEqualState(key, successor.state)
|
|
122
|
+
: isSameState(getFingerprintState(successor.state), key),
|
|
113
123
|
);
|
|
114
124
|
} finally {
|
|
115
125
|
Object.assign(current, expanding);
|
|
@@ -122,7 +132,13 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
122
132
|
): Behavior => {
|
|
123
133
|
const alias = config.alias;
|
|
124
134
|
const known = traceOptions.known ?? 1;
|
|
125
|
-
const
|
|
135
|
+
const loopStart = traceOptions.loopStart;
|
|
136
|
+
const rebuilt = is174 && loopStart !== undefined ? loopStart + 1 : steps.length - known;
|
|
137
|
+
const isRebuiltAgain = known > 0 && !is174 && !traceOptions.isFailed;
|
|
138
|
+
const initialOutput =
|
|
139
|
+
known === 0 || (steps.length > 1 && (rebuilt > 0 || isRebuiltAgain || is174))
|
|
140
|
+
? captureOutput(context.getInitialStates).lines
|
|
141
|
+
: [];
|
|
126
142
|
const stepActions = steps.map((step, position) =>
|
|
127
143
|
position === 0 || step.action === "Stuttering"
|
|
128
144
|
? { result: undefined, lines: [] }
|
|
@@ -136,10 +152,7 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
136
152
|
),
|
|
137
153
|
);
|
|
138
154
|
const outputs = stepActions.map((step) => step.lines);
|
|
139
|
-
const loopStart = traceOptions.loopStart;
|
|
140
|
-
const rebuilt = is174 && loopStart !== undefined ? loopStart + 1 : steps.length - known;
|
|
141
155
|
if (environment.coverage && steps.length > 1) {
|
|
142
|
-
const isRebuiltAgain = known > 0 && !is174;
|
|
143
156
|
if (rebuilt > 0 && isRebuiltAgain) captureOutput(context.getInitialStates);
|
|
144
157
|
if (isRebuiltAgain) {
|
|
145
158
|
steps.slice(1).forEach((step, position) => {
|
|
@@ -181,7 +194,7 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
181
194
|
}
|
|
182
195
|
return traceStep;
|
|
183
196
|
}),
|
|
184
|
-
traceOutput:
|
|
197
|
+
traceOutput: isRebuiltAgain ? [initialOutput, ...outputs].flat() : [],
|
|
185
198
|
};
|
|
186
199
|
};
|
|
187
200
|
const findTraceSuccessor = (state: Value[], isMatch: (successor: Successor) => boolean) =>
|
|
@@ -215,7 +228,7 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
215
228
|
const getPathStates = (path: number[], nextFailure: string) => {
|
|
216
229
|
const initial = captureOutput(() =>
|
|
217
230
|
isReducing || isImpure(environment)
|
|
218
|
-
? context.
|
|
231
|
+
? context.getUncoveredInitialStates().find((state) => hasFingerprint(state, path[0]))
|
|
219
232
|
: states[path[0]],
|
|
220
233
|
).result;
|
|
221
234
|
if (!initial) throw new TlaEvaluationError(INITIAL_RECOVERY_FAILURE);
|
|
@@ -232,7 +245,7 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
232
245
|
}
|
|
233
246
|
return steps;
|
|
234
247
|
};
|
|
235
|
-
const getTrace = (index: number, lastSuccessor?: Successor,
|
|
248
|
+
const getTrace = (index: number, lastSuccessor?: Successor, traceOptions: TraceOptions = {}) => {
|
|
236
249
|
const path: number[] = [];
|
|
237
250
|
for (let position = index; position !== -1; position = context.parents[position]) {
|
|
238
251
|
path.unshift(position);
|
|
@@ -244,22 +257,26 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
244
257
|
state: states[position],
|
|
245
258
|
action: context.actions[position],
|
|
246
259
|
}));
|
|
247
|
-
if (!lastSuccessor) return toTrace(steps, path,
|
|
260
|
+
if (!lastSuccessor) return toTrace(steps, path, traceOptions);
|
|
248
261
|
const action = isReducing
|
|
249
262
|
? findTraceSuccessor(states[index], (successor) =>
|
|
250
263
|
isSameState(successor.state, lastSuccessor.state),
|
|
251
264
|
)?.action
|
|
252
265
|
: lastSuccessor.action;
|
|
253
|
-
return toTrace([...steps, { state: lastSuccessor.state, action }], path, {
|
|
266
|
+
return toTrace([...steps, { state: lastSuccessor.state, action }], path, {
|
|
267
|
+
...traceOptions,
|
|
268
|
+
known: 2,
|
|
269
|
+
});
|
|
254
270
|
};
|
|
255
271
|
// TLCTrace#printTrace applies the alias to every state but an initial one it prints without a successor.
|
|
256
|
-
const getStateTrace = (index: number,
|
|
257
|
-
if (context.parents[index] !== -1) return getTrace(index, undefined,
|
|
258
|
-
const traceOutput =
|
|
272
|
+
const getStateTrace = (index: number, traceOptions: TraceOptions = {}): Behavior => {
|
|
273
|
+
if (context.parents[index] !== -1) return getTrace(index, undefined, traceOptions);
|
|
274
|
+
const traceOutput =
|
|
275
|
+
is174 || traceOptions.isFailed ? [] : captureOutput(context.getInitialStates).lines;
|
|
259
276
|
const state = states[index];
|
|
260
|
-
if (incomplete !== undefined) {
|
|
277
|
+
if (traceOptions.incomplete !== undefined) {
|
|
261
278
|
return {
|
|
262
|
-
trace: toTrace([{ state, action: undefined }], [index],
|
|
279
|
+
trace: toTrace([{ state, action: undefined }], [index], traceOptions).trace,
|
|
263
280
|
traceOutput,
|
|
264
281
|
};
|
|
265
282
|
}
|
|
@@ -290,9 +307,6 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
290
307
|
context.tracedSteps.set(traceStep, { state, action });
|
|
291
308
|
return traceStep;
|
|
292
309
|
};
|
|
293
|
-
const getFailedTrace = (index: number, successor: Successor): Behavior => ({
|
|
294
|
-
trace: getTrace(index, successor).trace,
|
|
295
|
-
});
|
|
296
310
|
const getPathSteps = (path: number[]) => getPathStates(path, NEXT_RECOVERY_FAILURE);
|
|
297
311
|
return {
|
|
298
312
|
toTrace,
|
|
@@ -301,7 +315,6 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
301
315
|
getTrace,
|
|
302
316
|
getStateTrace,
|
|
303
317
|
getIncompleteStep,
|
|
304
|
-
getFailedTrace,
|
|
305
318
|
getPathSteps,
|
|
306
319
|
};
|
|
307
320
|
};
|