tslaws 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/check.js +87 -17
- package/dist/cli.js +43 -3
- package/dist/coverage.d.ts +8 -0
- package/dist/coverage.js +18 -1
- package/dist/github.d.ts +123 -0
- package/dist/github.js +276 -0
- package/dist/githubCli.d.ts +53 -0
- package/dist/githubCli.js +535 -0
- package/dist/lock.d.ts +23 -0
- package/dist/lock.js +84 -0
- package/dist/propertyRun.d.ts +11 -0
- package/dist/propertyRun.js +23 -0
- package/dist/reporters.d.ts +3 -0
- package/dist/reporters.js +17 -0
- package/dist/smt.d.ts +16 -0
- package/dist/smt.js +43 -1
- package/dist/solvers.d.ts +31 -0
- package/dist/solvers.js +121 -0
- package/dist/symbolic.js +2 -2
- package/dist/types.d.ts +17 -0
- package/package.json +7 -7
package/dist/propertyRun.js
CHANGED
|
@@ -54,3 +54,26 @@ export function summarise(details, options) {
|
|
|
54
54
|
stack: details.errorInstance instanceof Error ? details.errorInstance.stack : undefined,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
/** Inputs a law has run on, at least, before a proof of it stands. */
|
|
58
|
+
export const crossCheckRuns = 50;
|
|
59
|
+
/**
|
|
60
|
+
* A `proved` verdict is checked against plain JavaScript: the law's property run (generators that stay inside what the
|
|
61
|
+
* proof assumes) already passed in this check, and counts when it ran `crossCheckRuns` inputs. A shorter one (a low
|
|
62
|
+
* `--runs`) is topped up with a run of `crossCheckRuns` from the same seed. Returns the outcome of the top-up when the
|
|
63
|
+
* law fails on it, `'timeout'` when it does not finish, and `undefined` when nothing disagrees with the proof.
|
|
64
|
+
*/
|
|
65
|
+
export async function crossCheck(passed, parameters, rerun) {
|
|
66
|
+
if (parameters === 0 || passed.numRuns >= crossCheckRuns)
|
|
67
|
+
return undefined;
|
|
68
|
+
const again = await rerun(crossCheckRuns);
|
|
69
|
+
if (again === 'timeout')
|
|
70
|
+
return again;
|
|
71
|
+
return again.failed && again.counterexample !== undefined ? again : undefined;
|
|
72
|
+
}
|
|
73
|
+
/** Why a law counts as failed when the prover said `proved` and a JavaScript run disagrees. */
|
|
74
|
+
export function disagreement(outcome) {
|
|
75
|
+
const reason = outcome.message === undefined || outcome.message.startsWith('Property failed by returning false')
|
|
76
|
+
? 'returned false'
|
|
77
|
+
: `threw: ${outcome.message}`;
|
|
78
|
+
return `the prover said proved but a JavaScript run disagrees (${reason}); this is likely a translation bug in the prover, please report it`;
|
|
79
|
+
}
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CheckReport } from './check.ts';
|
|
2
|
+
import type { LawResult } from './types.ts';
|
|
2
3
|
/** The values of `tslaws check --reporter`. `text`, `json` and `ndjson` are rendered by the CLI itself. */
|
|
3
4
|
export declare const reporterNames: readonly ["text", "json", "junit", "github", "ndjson"];
|
|
4
5
|
export type ReporterName = (typeof reporterNames)[number];
|
|
@@ -10,6 +11,8 @@ export declare function escapeAttr(text: string): string;
|
|
|
10
11
|
export declare function escapeGithubData(text: string): string;
|
|
11
12
|
/** Escape a workflow command property value. */
|
|
12
13
|
export declare function escapeGithubProperty(text: string): string;
|
|
14
|
+
/** For a law not yet in the lock: what it would be if accepted, e.g. `if accepted: failed, counterexample [0]`. */
|
|
15
|
+
export declare function proposalText(result: LawResult): string | undefined;
|
|
13
16
|
/** JUnit XML: one `testsuite` per law file, one `testcase` per law. */
|
|
14
17
|
export declare function junit(report: CheckReport): string;
|
|
15
18
|
/** GitHub Actions workflow commands: an annotation per failing result and a notice for bounded or tested ones. */
|
package/dist/reporters.js
CHANGED
|
@@ -45,14 +45,31 @@ function detail(result) {
|
|
|
45
45
|
parts.push(result.message);
|
|
46
46
|
if (result.counterexample !== undefined)
|
|
47
47
|
parts.push(`counterexample ${result.counterexample}`);
|
|
48
|
+
if (result.assumptions !== undefined && result.assumptions.length > 0)
|
|
49
|
+
parts.push(`assuming ${result.assumptions.join('; ')}`);
|
|
48
50
|
if (result.status === 'failed' && result.seed !== undefined)
|
|
49
51
|
parts.push(`seed ${result.seed}`);
|
|
50
52
|
return parts.join('; ');
|
|
51
53
|
}
|
|
54
|
+
/** For a law not yet in the lock: what it would be if accepted, e.g. `if accepted: failed, counterexample [0]`. */
|
|
55
|
+
export function proposalText(result) {
|
|
56
|
+
const p = result.proposal;
|
|
57
|
+
if (p === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
const detail = p.counterexample !== undefined
|
|
60
|
+
? `, counterexample ${p.counterexample}`
|
|
61
|
+
: p.status === 'failed' && p.message !== undefined
|
|
62
|
+
? `, ${p.message.split('\n')[0]}`
|
|
63
|
+
: '';
|
|
64
|
+
return `proposal (${p.reason}); if accepted: ${p.status} [${p.method}]${detail}`;
|
|
65
|
+
}
|
|
52
66
|
function failureText(result) {
|
|
53
67
|
const lines = [`${result.status.toUpperCase()} ${result.name} (${result.file}:${result.line}) [${result.method}]`];
|
|
54
68
|
if (result.message !== undefined)
|
|
55
69
|
lines.push(result.message);
|
|
70
|
+
const proposed = proposalText(result);
|
|
71
|
+
if (proposed !== undefined)
|
|
72
|
+
lines.push(proposed);
|
|
56
73
|
if (result.counterexample !== undefined)
|
|
57
74
|
lines.push(`counterexample: ${result.counterexample}`);
|
|
58
75
|
const hint = hintFor(result);
|
package/dist/smt.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SolverName } from './solvers.ts';
|
|
1
2
|
import type { ManifestLaw } from './types.ts';
|
|
2
3
|
export type Shape = 'number' | 'int' | 'bigint' | 'boolean' | 'string' | {
|
|
3
4
|
array: Shape;
|
|
@@ -6,9 +7,11 @@ export type Shape = 'number' | 'int' | 'bigint' | 'boolean' | 'string' | {
|
|
|
6
7
|
} | undefined;
|
|
7
8
|
export type ProofResult = {
|
|
8
9
|
kind: 'proved';
|
|
10
|
+
assumptions: string[];
|
|
9
11
|
} | {
|
|
10
12
|
kind: 'bounded';
|
|
11
13
|
limits: string[];
|
|
14
|
+
assumptions: string[];
|
|
12
15
|
} | {
|
|
13
16
|
kind: 'refuted';
|
|
14
17
|
model: string;
|
|
@@ -16,6 +19,11 @@ export type ProofResult = {
|
|
|
16
19
|
} | {
|
|
17
20
|
kind: 'unsupported';
|
|
18
21
|
reason: string;
|
|
22
|
+
}
|
|
23
|
+
/** A configured second solver could not run (the cvc5 binary is missing). */
|
|
24
|
+
| {
|
|
25
|
+
kind: 'error';
|
|
26
|
+
message: string;
|
|
19
27
|
};
|
|
20
28
|
export interface ProveInput {
|
|
21
29
|
law: ManifestLaw;
|
|
@@ -28,6 +36,14 @@ export interface ProveInput {
|
|
|
28
36
|
bound: number;
|
|
29
37
|
/** Runs the compiled law on concrete inputs; true when it holds. */
|
|
30
38
|
holds: (inputs: unknown[]) => boolean;
|
|
39
|
+
/** The solvers that must agree on a proof (see solvers.ts); default Z3 alone. */
|
|
40
|
+
solvers?: readonly SolverName[];
|
|
31
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The domain assumptions a proof rests on for parameters of these types, in order of first use and without repeats.
|
|
44
|
+
* Arrays are left out (their length bound is a limit of the proof), as is `int` when `intLimit` narrows it (that range is
|
|
45
|
+
* a limit too). `bigint` and `boolean` take nothing for granted.
|
|
46
|
+
*/
|
|
47
|
+
export declare function assumptionsFor(shapes: Shape[], intLimit?: bigint): string[];
|
|
32
48
|
/** Tries to prove `input.law` for every input within `input.bound`. */
|
|
33
49
|
export declare function proveLaw(input: ProveInput): Promise<ProofResult>;
|
package/dist/smt.js
CHANGED
|
@@ -14,6 +14,7 @@ import { Worker } from 'node:worker_threads';
|
|
|
14
14
|
import { jobs, WorkerPool } from "./pool.js";
|
|
15
15
|
import { dirname, join } from 'node:path';
|
|
16
16
|
import ts from 'typescript';
|
|
17
|
+
import { SolverUnavailable, secondOpinion } from "./solvers.js";
|
|
17
18
|
import { Executor, SpuriousModel, Unsupported, and } from "./symbolic.js";
|
|
18
19
|
const safeRange = (t) => `(and (<= (- 9007199254740991) ${t}) (<= ${t} 9007199254740991))`;
|
|
19
20
|
class Declarations {
|
|
@@ -301,6 +302,38 @@ function containsArray(shape) {
|
|
|
301
302
|
function show(value) {
|
|
302
303
|
return JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? `${v}n` : v));
|
|
303
304
|
}
|
|
305
|
+
/** What a proof silently takes for granted about each kind of parameter; shown with a `proved` or `bounded` result. */
|
|
306
|
+
const numberAssumption = 'number parameters exclude NaN and ±Infinity';
|
|
307
|
+
const intAssumption = 'int parameters stay within ±(2^53 - 1)';
|
|
308
|
+
const stringAssumption = `string parameters use only characters up to U+FFFF (no surrogate pairs) and at most ${maxStringLength} UTF-16 units`;
|
|
309
|
+
/**
|
|
310
|
+
* The domain assumptions a proof rests on for parameters of these types, in order of first use and without repeats.
|
|
311
|
+
* Arrays are left out (their length bound is a limit of the proof), as is `int` when `intLimit` narrows it (that range is
|
|
312
|
+
* a limit too). `bigint` and `boolean` take nothing for granted.
|
|
313
|
+
*/
|
|
314
|
+
export function assumptionsFor(shapes, intLimit) {
|
|
315
|
+
const found = new Set();
|
|
316
|
+
const visit = (shape) => {
|
|
317
|
+
if (shape === 'number')
|
|
318
|
+
found.add(numberAssumption);
|
|
319
|
+
else if (shape === 'int') {
|
|
320
|
+
if (intLimit === undefined)
|
|
321
|
+
found.add(intAssumption);
|
|
322
|
+
}
|
|
323
|
+
else if (shape === 'string')
|
|
324
|
+
found.add(stringAssumption);
|
|
325
|
+
else if (shape === undefined || typeof shape === 'string')
|
|
326
|
+
return;
|
|
327
|
+
else if ('array' in shape)
|
|
328
|
+
visit(shape.array);
|
|
329
|
+
else
|
|
330
|
+
for (const field of Object.values(shape.fields))
|
|
331
|
+
visit(field);
|
|
332
|
+
};
|
|
333
|
+
for (const shape of shapes)
|
|
334
|
+
visit(shape);
|
|
335
|
+
return [...found];
|
|
336
|
+
}
|
|
304
337
|
/** Ints stay within this in the second attempt, where products and sums cannot leave the safe range. */
|
|
305
338
|
const smallInts = 2n ** 26n;
|
|
306
339
|
/** Tries to prove `input.law` for every input within `input.bound`. */
|
|
@@ -320,6 +353,8 @@ export async function proveLaw(input) {
|
|
|
320
353
|
catch (error) {
|
|
321
354
|
if (error instanceof Unsupported)
|
|
322
355
|
return { kind: 'unsupported', reason: error.message };
|
|
356
|
+
if (error instanceof SolverUnavailable)
|
|
357
|
+
return { kind: 'error', message: error.message };
|
|
323
358
|
throw error;
|
|
324
359
|
}
|
|
325
360
|
}
|
|
@@ -371,7 +406,14 @@ async function attempt(input, intLimit) {
|
|
|
371
406
|
const { out, vals } = await solve(query.join('\n'), valueQuery, input.timeoutMs);
|
|
372
407
|
const check = out;
|
|
373
408
|
if (check.startsWith('unsat')) {
|
|
374
|
-
|
|
409
|
+
const assumptions = assumptionsFor(input.shapes, intLimit);
|
|
410
|
+
if (executor.bounded.length > 0)
|
|
411
|
+
return { kind: 'bounded', limits: executor.bounded, assumptions };
|
|
412
|
+
// Only a proof that would stand is sent to the second solver.
|
|
413
|
+
const unconfirmed = await secondOpinion(input.solvers ?? [], query.join('\n'), input.timeoutMs);
|
|
414
|
+
return unconfirmed === undefined
|
|
415
|
+
? { kind: 'proved', assumptions }
|
|
416
|
+
: { kind: 'bounded', limits: [unconfirmed], assumptions };
|
|
375
417
|
}
|
|
376
418
|
if (check.startsWith('unknown'))
|
|
377
419
|
throw new Unsupported(`solver gave up within ${input.timeoutMs} ms`);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type SolverName = 'z3' | 'cvc5';
|
|
2
|
+
export declare const solverNames: readonly SolverName[];
|
|
3
|
+
/** The solvers of a project without a `solvers` key: Z3 alone, with no second opinion. */
|
|
4
|
+
export declare const defaultSolvers: readonly SolverName[];
|
|
5
|
+
/** What is wrong with a `solvers` value from tslaws.json, or undefined when it is valid. */
|
|
6
|
+
export declare function solversProblem(value: unknown): string | undefined;
|
|
7
|
+
/** The cvc5 binary is not there to run. */
|
|
8
|
+
export declare class SolverUnavailable extends Error {
|
|
9
|
+
}
|
|
10
|
+
export type Cvc5Answer = {
|
|
11
|
+
kind: 'unsat' | 'sat' | 'unknown';
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'timeout';
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'error';
|
|
16
|
+
detail: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The text cvc5 reads: Z3's query without the Z3-only timeout option (cvc5 takes `--tlimit`) and without `(get-model)`,
|
|
20
|
+
* with `(set-logic ALL)` first when the query names no logic.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cvc5Text(query: string): string;
|
|
23
|
+
/** Asks cvc5 for the verdict on the query; a binary that cannot be started throws `SolverUnavailable`. */
|
|
24
|
+
export declare function runCvc5(query: string, timeoutMs: number): Promise<Cvc5Answer>;
|
|
25
|
+
/** The reason cvc5 did not agree, or undefined when it also said `unsat`. */
|
|
26
|
+
export declare function disagreementOf(answer: Cvc5Answer, timeoutMs: number): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Runs the second solver on a query Z3 answered `unsat`. Returns what stops the proof from standing, or undefined when
|
|
29
|
+
* the solvers agree or no second solver is configured.
|
|
30
|
+
*/
|
|
31
|
+
export declare function secondOpinion(solvers: readonly SolverName[], query: string, timeoutMs: number): Promise<string | undefined>;
|
package/dist/solvers.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// A second opinion on proofs. Z3 always decides; when `"solvers": ["z3", "cvc5"]` is set in tslaws.json, a law Z3 proves
|
|
2
|
+
// (an `unsat` answer) counts as `proved` only if the cvc5 binary also says `unsat` to the same SMT-LIB query. Any other
|
|
3
|
+
// answer from cvc5 leaves the law `bounded`, with a limit that names what cvc5 said. Refutations are never sent to cvc5:
|
|
4
|
+
// they already replay in JavaScript.
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { extname } from 'node:path';
|
|
7
|
+
export const solverNames = ['z3', 'cvc5'];
|
|
8
|
+
/** The solvers of a project without a `solvers` key: Z3 alone, with no second opinion. */
|
|
9
|
+
export const defaultSolvers = ['z3'];
|
|
10
|
+
/** What is wrong with a `solvers` value from tslaws.json, or undefined when it is valid. */
|
|
11
|
+
export function solversProblem(value) {
|
|
12
|
+
const allowed = solverNames.map((name) => `"${name}"`).join(' and ');
|
|
13
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
14
|
+
return `"solvers" must be an array of solver names (${allowed}), got ${JSON.stringify(value)}`;
|
|
15
|
+
for (const entry of value) {
|
|
16
|
+
if (typeof entry !== 'string' || !solverNames.includes(entry))
|
|
17
|
+
return `"solvers" has an unknown solver ${JSON.stringify(entry)}; the supported solvers are ${allowed}`;
|
|
18
|
+
}
|
|
19
|
+
if (!value.includes('z3'))
|
|
20
|
+
return '"solvers" must include "z3": Z3 decides every proof and cvc5 only confirms it';
|
|
21
|
+
const repeated = value.find((entry, index) => value.indexOf(entry) !== index);
|
|
22
|
+
if (repeated !== undefined)
|
|
23
|
+
return `"solvers" lists "${repeated}" more than once`;
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
/** The cvc5 binary is not there to run. */
|
|
27
|
+
export class SolverUnavailable extends Error {
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The text cvc5 reads: Z3's query without the Z3-only timeout option (cvc5 takes `--tlimit`) and without `(get-model)`,
|
|
31
|
+
* with `(set-logic ALL)` first when the query names no logic.
|
|
32
|
+
*/
|
|
33
|
+
export function cvc5Text(query) {
|
|
34
|
+
const lines = query.split('\n').filter((line) => !/^\s*\(set-option\s+:timeout\s+\d+\)\s*$/.test(line));
|
|
35
|
+
const text = lines
|
|
36
|
+
.filter((line) => line.trim() !== '(get-model)')
|
|
37
|
+
.join('\n')
|
|
38
|
+
.trimEnd();
|
|
39
|
+
const logic = /\(set-logic\s/.test(text) ? '' : '(set-logic ALL)\n';
|
|
40
|
+
return `${logic}${text}\n`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Where the binary is and how to start it: `TSLAWS_CVC5`, else `cvc5` on the PATH. A path ending in .js, .mjs or .cjs is
|
|
44
|
+
* a Node script and runs under the current Node (the tests use one as a fake solver, which a .cmd file could not do on
|
|
45
|
+
* every platform); anything else is run as it is. No shell is involved.
|
|
46
|
+
*/
|
|
47
|
+
function command() {
|
|
48
|
+
const path = process.env.TSLAWS_CVC5 ?? 'cvc5';
|
|
49
|
+
return ['.js', '.mjs', '.cjs'].includes(extname(path))
|
|
50
|
+
? { file: process.execPath, args: [path] }
|
|
51
|
+
: { file: path, args: [] };
|
|
52
|
+
}
|
|
53
|
+
const missing = () => new SolverUnavailable(`"solvers" includes "cvc5", but the cvc5 binary was not found: install cvc5 (https://cvc5.github.io) so that cvc5 is on the PATH, or set TSLAWS_CVC5 to its path`);
|
|
54
|
+
/** Asks cvc5 for the verdict on the query; a binary that cannot be started throws `SolverUnavailable`. */
|
|
55
|
+
export function runCvc5(query, timeoutMs) {
|
|
56
|
+
const { file, args } = command();
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const child = spawn(file, [...args, '--lang', 'smt2', '--tlimit', String(timeoutMs)], {
|
|
59
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
60
|
+
windowsHide: true,
|
|
61
|
+
});
|
|
62
|
+
let stdout = '';
|
|
63
|
+
let stderr = '';
|
|
64
|
+
let finished = false;
|
|
65
|
+
const done = (answer) => {
|
|
66
|
+
if (finished)
|
|
67
|
+
return;
|
|
68
|
+
finished = true;
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
resolve(answer);
|
|
71
|
+
};
|
|
72
|
+
// cvc5 stops itself at --tlimit; the grace period only catches a process that does not.
|
|
73
|
+
const timer = setTimeout(() => {
|
|
74
|
+
child.kill();
|
|
75
|
+
done({ kind: 'timeout' });
|
|
76
|
+
}, timeoutMs + 3000);
|
|
77
|
+
child.stdout.setEncoding('utf8').on('data', (chunk) => (stdout += chunk));
|
|
78
|
+
child.stderr.setEncoding('utf8').on('data', (chunk) => (stderr += chunk));
|
|
79
|
+
child.on('error', (error) => {
|
|
80
|
+
if (finished)
|
|
81
|
+
return;
|
|
82
|
+
if (error.code === 'ENOENT' || error.code === 'EACCES') {
|
|
83
|
+
finished = true;
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
reject(missing());
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
done({ kind: 'error', detail: error.message });
|
|
89
|
+
});
|
|
90
|
+
child.on('close', (code) => {
|
|
91
|
+
const first = stdout.trim().split('\n')[0]?.trim() ?? '';
|
|
92
|
+
if (code === 0 && (first === 'unsat' || first === 'sat' || first === 'unknown'))
|
|
93
|
+
done({ kind: first });
|
|
94
|
+
else {
|
|
95
|
+
const detail = first !== '' ? first : stderr.trim().split('\n')[0]?.trim() || `exited with code ${code}`;
|
|
96
|
+
done({ kind: 'error', detail });
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
child.stdin.on('error', () => undefined);
|
|
100
|
+
child.stdin.end(cvc5Text(query));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** The reason cvc5 did not agree, or undefined when it also said `unsat`. */
|
|
104
|
+
export function disagreementOf(answer, timeoutMs) {
|
|
105
|
+
if (answer.kind === 'unsat')
|
|
106
|
+
return undefined;
|
|
107
|
+
if (answer.kind === 'timeout')
|
|
108
|
+
return `cvc5 did not confirm the proof (no answer within ${timeoutMs} ms)`;
|
|
109
|
+
if (answer.kind === 'error')
|
|
110
|
+
return `cvc5 did not confirm the proof (error: ${answer.detail})`;
|
|
111
|
+
return `cvc5 did not confirm the proof (${answer.kind})`;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Runs the second solver on a query Z3 answered `unsat`. Returns what stops the proof from standing, or undefined when
|
|
115
|
+
* the solvers agree or no second solver is configured.
|
|
116
|
+
*/
|
|
117
|
+
export async function secondOpinion(solvers, query, timeoutMs) {
|
|
118
|
+
if (!solvers.includes('cvc5'))
|
|
119
|
+
return undefined;
|
|
120
|
+
return disagreementOf(await runCvc5(query, timeoutMs), timeoutMs);
|
|
121
|
+
}
|
package/dist/symbolic.js
CHANGED
|
@@ -439,7 +439,7 @@ export class Executor {
|
|
|
439
439
|
block(statements, f, pc) {
|
|
440
440
|
const outer = new Set(f.env.keys());
|
|
441
441
|
this.execList(statements, f, pc);
|
|
442
|
-
for (const name of
|
|
442
|
+
for (const name of f.env.keys())
|
|
443
443
|
if (!outer.has(name))
|
|
444
444
|
f.env.delete(name);
|
|
445
445
|
}
|
|
@@ -493,7 +493,7 @@ export class Executor {
|
|
|
493
493
|
this.ev(node.initializer, f, pc, true);
|
|
494
494
|
}
|
|
495
495
|
this.loop(undefined, node.condition, node.incrementor, node.statement, f, pc);
|
|
496
|
-
for (const name of
|
|
496
|
+
for (const name of f.env.keys())
|
|
497
497
|
if (!outer.has(name))
|
|
498
498
|
f.env.delete(name);
|
|
499
499
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -25,10 +25,27 @@ export interface LawResult {
|
|
|
25
25
|
seed?: number;
|
|
26
26
|
counterexample?: string;
|
|
27
27
|
message?: string;
|
|
28
|
+
/** The domain assumptions a `proved` or `bounded` result rests on, for the parameter types of this law only. */
|
|
29
|
+
assumptions?: string[];
|
|
28
30
|
/** Project-relative path of a screenshot of the page at the counterexample (browser laws). */
|
|
29
31
|
screenshot?: string;
|
|
30
32
|
/** The project functions the law reaches and where they are declared, for an editor to mark on both ends. */
|
|
31
33
|
exercises?: Exercised[];
|
|
34
|
+
/**
|
|
35
|
+
* Set on a `tampered` result whose law is not (or no longer) the one in the lock: what the law would be if a person
|
|
36
|
+
* accepted it. The law still ran, so a reviewer sees whether the proposal holds; the result stays `tampered`, so the
|
|
37
|
+
* check still fails until the lock records the law.
|
|
38
|
+
*/
|
|
39
|
+
proposal?: ProposalOutcome;
|
|
40
|
+
}
|
|
41
|
+
/** Why a law is a proposal, and what it did when it ran. */
|
|
42
|
+
export interface ProposalOutcome {
|
|
43
|
+
reason: 'added' | 'changed' | 'removed' | 'level' | 'exempt';
|
|
44
|
+
/** The status the law would have if accepted; `removed` and `exempt` proposals run nothing and hold trivially. */
|
|
45
|
+
status: Exclude<LawStatus, 'tampered' | 'uncovered'>;
|
|
46
|
+
method: string;
|
|
47
|
+
counterexample?: string;
|
|
48
|
+
message?: string;
|
|
32
49
|
}
|
|
33
50
|
export interface CheckOptions {
|
|
34
51
|
files: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tslaws",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Runs and checks `law` declarations compiled by tsc-laws: property tests, SMT proofs, tamper lock.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tslaws": "bin/tslaws.js"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"check:watch": "node bin/tslaws.js check --watch"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"esbuild": "^0.
|
|
56
|
+
"esbuild": "^0.28.1",
|
|
57
57
|
"fast-check": "^4.0.0",
|
|
58
58
|
"playwright-core": "^1.64.1",
|
|
59
59
|
"typescript": "5.9",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"optionalDependencies": {
|
|
76
|
-
"tslaws-compiler-darwin-arm64": "0.
|
|
77
|
-
"tslaws-compiler-darwin-x64": "0.
|
|
78
|
-
"tslaws-compiler-linux-arm64-gnu": "0.
|
|
79
|
-
"tslaws-compiler-linux-x64-gnu": "0.
|
|
80
|
-
"tslaws-compiler-win32-x64-msvc": "0.
|
|
76
|
+
"tslaws-compiler-darwin-arm64": "0.9.0",
|
|
77
|
+
"tslaws-compiler-darwin-x64": "0.9.0",
|
|
78
|
+
"tslaws-compiler-linux-arm64-gnu": "0.9.0",
|
|
79
|
+
"tslaws-compiler-linux-x64-gnu": "0.9.0",
|
|
80
|
+
"tslaws-compiler-win32-x64-msvc": "0.9.0"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|