tslaws 0.10.0 → 1.0.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 +7 -2
- package/bin/tslaws.js +8 -2
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +25 -5
- package/dist/bundled.js +2 -2
- package/dist/bundlerPlugins.d.ts +2 -0
- package/dist/bundlerPlugins.js +7 -0
- package/dist/certificates.d.ts +139 -0
- package/dist/certificates.js +433 -0
- package/dist/chc.d.ts +85 -0
- package/dist/chc.js +298 -0
- package/dist/check.d.ts +13 -1
- package/dist/check.js +211 -27
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +175 -34
- package/dist/compile.d.ts +15 -5
- package/dist/compile.js +198 -69
- package/dist/coverage.d.ts +38 -1
- package/dist/coverage.js +94 -12
- package/dist/e2eApi.js +3 -1
- package/dist/generators.js +12 -2
- package/dist/github.d.ts +49 -5
- package/dist/github.js +107 -24
- package/dist/githubCli.d.ts +28 -0
- package/dist/githubCli.js +1039 -211
- package/dist/hints.js +2 -1
- package/dist/init.js +42 -0
- package/dist/isolate.d.ts +28 -0
- package/dist/isolate.js +262 -0
- package/dist/isolatedCheck.d.ts +1 -0
- package/dist/isolatedCheck.js +16 -0
- package/dist/lawHost.d.ts +50 -0
- package/dist/lawHost.js +199 -0
- package/dist/lawRuntime.d.ts +39 -0
- package/dist/lawRuntime.js +242 -0
- package/dist/lock.d.ts +49 -9
- package/dist/lock.js +132 -21
- package/dist/mcp.js +28 -7
- package/dist/mutate.d.ts +4 -0
- package/dist/mutate.js +7 -1
- package/dist/plan.d.ts +1 -0
- package/dist/plan.js +4 -0
- package/dist/pluginHooks.d.ts +16 -0
- package/dist/pluginHooks.js +48 -0
- package/dist/pluginHost.d.ts +5 -0
- package/dist/pluginHost.js +43 -0
- package/dist/pluginWorker.d.ts +1 -0
- package/dist/pluginWorker.js +40 -0
- package/dist/plural.d.ts +2 -0
- package/dist/plural.js +4 -0
- package/dist/pool.d.ts +80 -7
- package/dist/pool.js +222 -11
- package/dist/projects.d.ts +43 -1
- package/dist/projects.js +283 -11
- package/dist/promote.d.ts +56 -2
- package/dist/promote.js +429 -13
- package/dist/property.js +5 -1
- package/dist/propertyWorker.js +7 -0
- package/dist/proposals.d.ts +52 -4
- package/dist/proposals.js +484 -21
- package/dist/reporters.js +5 -1
- package/dist/runtimeEnv.d.ts +13 -5
- package/dist/runtimeEnv.js +48 -10
- package/dist/sandbox.d.ts +98 -0
- package/dist/sandbox.js +673 -0
- package/dist/sandboxGuard.d.ts +56 -0
- package/dist/sandboxGuard.js +249 -0
- package/dist/seal.d.ts +9 -0
- package/dist/seal.js +426 -0
- package/dist/security/cli.d.ts +6 -0
- package/dist/security/cli.js +39 -0
- package/dist/security/cwe.d.ts +14 -0
- package/dist/security/cwe.js +40 -0
- package/dist/security/deps/cache.d.ts +28 -0
- package/dist/security/deps/cache.js +107 -0
- package/dist/security/deps/config.d.ts +16 -0
- package/dist/security/deps/config.js +43 -0
- package/dist/security/deps/imports.d.ts +4 -0
- package/dist/security/deps/imports.js +33 -0
- package/dist/security/deps/lockfiles.d.ts +23 -0
- package/dist/security/deps/lockfiles.js +153 -0
- package/dist/security/deps/osv.d.ts +66 -0
- package/dist/security/deps/osv.js +137 -0
- package/dist/security/deps/run.d.ts +54 -0
- package/dist/security/deps/run.js +135 -0
- package/dist/security/deps/severity.d.ts +26 -0
- package/dist/security/deps/severity.js +78 -0
- package/dist/security/generators.d.ts +9 -0
- package/dist/security/generators.js +36 -0
- package/dist/security/index.d.ts +27 -0
- package/dist/security/index.js +18 -0
- package/dist/security/integers.d.ts +31 -0
- package/dist/security/integers.js +105 -0
- package/dist/security/law.d.ts +54 -0
- package/dist/security/law.js +54 -0
- package/dist/security/pathTraversal.d.ts +29 -0
- package/dist/security/pathTraversal.js +146 -0
- package/dist/security/prototypePollution.d.ts +30 -0
- package/dist/security/prototypePollution.js +142 -0
- package/dist/security/redirect.d.ts +21 -0
- package/dist/security/redirect.js +154 -0
- package/dist/security/redos.d.ts +21 -0
- package/dist/security/redos.js +93 -0
- package/dist/security/validation.d.ts +25 -0
- package/dist/security/validation.js +89 -0
- package/dist/security/xss.d.ts +21 -0
- package/dist/security/xss.js +90 -0
- package/dist/settings.d.ts +20 -0
- package/dist/settings.js +32 -0
- package/dist/smt.d.ts +29 -1
- package/dist/smt.js +239 -107
- package/dist/smtWorker.d.ts +1 -0
- package/dist/smtWorker.js +26 -0
- package/dist/solvers.d.ts +9 -0
- package/dist/solvers.js +11 -5
- package/dist/symbolic.d.ts +54 -1
- package/dist/symbolic.js +239 -13
- package/dist/tsconfigResolve.d.ts +28 -0
- package/dist/tsconfigResolve.js +141 -0
- package/dist/types.d.ts +28 -0
- package/hooks/claude-hook.mjs +2 -0
- package/package.json +18 -6
package/README.md
CHANGED
|
@@ -172,10 +172,13 @@ See [docs/laws.md](../../docs/laws.md#the-dashboard).
|
|
|
172
172
|
|
|
173
173
|
## Agents cannot move the goalposts
|
|
174
174
|
|
|
175
|
-
`tsc-laws.lock` holds a hash of every law
|
|
175
|
+
`tsc-laws.lock` holds a hash of every law and the list of coverage exemptions. A law's hash covers its declaration, the helpers,
|
|
176
|
+
generators and top-level code of its file that it reaches, every module the file imports (a registry package by name and
|
|
177
|
+
version), and the whole effective `tslaws.json` apart from `github`, `security` and `levels`, so weakening a helper or setting
|
|
178
|
+
`runs: 1` reads as tampering too; comments, layout and edits no law reaches do not. A change, an added law, a removed
|
|
176
179
|
law or a new `@tslaws-exempt` fails the check until a person runs `tslaws accept`, which refuses to run without a terminal,
|
|
177
180
|
under `CI`, or with `TSLAWS_AGENT` set, unless a person has lent it for a limited time with `tslaws delegate grant`. Agents propose laws in `*.proposed.laws.ts` files (or optionally in `.tslaws/proposals/`, outside the tree and git-ignored; `tslaws propose` or the MCP tool) and try them with `tslaws check
|
|
178
|
-
--proposed` (no lock, no coverage gate); a person moves one into the tree with `tslaws promote` and accepts. Every laws file in the tree must be in the lock.
|
|
181
|
+
--proposed` (no lock, no coverage gate); a person moves one into the tree with `tslaws promote` and accepts. Every laws file in the tree must be in the lock. A project that accepts laws on GitHub (a `github` section in `tslaws.json`) still lets a person run `tslaws accept` by hand, and a maintainer can run the workflow on demand; set `github.local` to false to leave the lock to the workflow alone. See [docs/github.md](../../docs/github.md).
|
|
179
182
|
|
|
180
183
|
`hooks/claude-hook.mjs` is a Claude Code hook that blocks `git commit` and sends an agent back to work when the check fails;
|
|
181
184
|
`hooks/claude-settings.example.json` wires it up and `hooks/AGENTS.snippet.md` tells the agent the rules.
|
|
@@ -192,6 +195,8 @@ tslaws check [files...] [--json] [--summary] [--watch] [--runs N] [--seed N] [--
|
|
|
192
195
|
[--proof-timeout MS] [--property-timeout MS] [--proposed] [--compiler PATH]
|
|
193
196
|
```
|
|
194
197
|
|
|
198
|
+
- `check <files>` and `accept <files>` work on the named laws files only: the lock is compared only for their laws, so a locked law in
|
|
199
|
+
another file is not reported as removed, and `accept` keeps the lock entries of the other files. A law removed from a named file is still reported.
|
|
195
200
|
- `init` scaffolds `tslaws.json`, the `.tslaws` ignore entry, the agent rules in `AGENTS.md`, the Claude Code hook in
|
|
196
201
|
`.claude/settings.json`, and a starter law if none exists. It never writes the lock; a person then runs `accept`.
|
|
197
202
|
- `accept` records the laws and the `@tslaws-exempt` functions in `tsc-laws.lock`. It refuses to run without a terminal,
|
package/bin/tslaws.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { main } from '../dist/cli.js';
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
|
|
4
|
+
// Let the process end by itself once `main` returns: every worker the CLI starts is unref'd. `process.exit()` skips
|
|
5
|
+
// the teardown of the JavaScript engine, and it can deadlock: it joins V8's background threads first, and a thread
|
|
6
|
+
// that is compiling code and needs a garbage collection waits for the main thread, which is now waiting for it. The
|
|
7
|
+
// report is already printed and the process never ends. Ending by itself tears the engine down properly.
|
|
8
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
9
|
+
|
|
10
|
+
// Only if a handle somewhere would still hold the process open after that: end it anyway, a few seconds later.
|
|
11
|
+
setTimeout(() => process.exit(), 5000).unref();
|
package/dist/browser.d.ts
CHANGED
package/dist/browser.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// each input is sent to a page where the compiled law and the code it checks run against a live DOM.
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { mkdirSync } from 'node:fs';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
5
6
|
import { delimiter, join, relative as pathRelative, resolve, sep } from 'node:path';
|
|
6
7
|
import { build as bundleWith } from 'esbuild';
|
|
7
8
|
import { explainBundleError, loadBundlerPlugins } from "./bundlerPlugins.js";
|
|
8
9
|
import { lawEnv, readConfig } from "./coverage.js";
|
|
10
|
+
import { compiledDirOf } from "./lawRuntime.js";
|
|
9
11
|
import { importMetaEnvGlobal } from "./runtimeEnv.js";
|
|
10
|
-
import { chromium, firefox, webkit } from 'playwright-core';
|
|
11
12
|
import { toWire } from "./generators.js";
|
|
12
13
|
import { runProperty, summarise } from "./property.js";
|
|
13
14
|
function findBrowser() {
|
|
@@ -32,13 +33,19 @@ function findBrowser() {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
try {
|
|
35
|
-
candidates.push(chromium.executablePath());
|
|
36
|
+
candidates.push(engineType('chromium').executablePath());
|
|
36
37
|
}
|
|
37
38
|
catch {
|
|
38
39
|
// Playwright has no browser of its own installed.
|
|
39
40
|
}
|
|
40
41
|
return candidates.find((c) => existsSync(c));
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Playwright, loaded when a browser law needs it. It probes the machine when it loads (for WSL, by reading `/proc` and
|
|
45
|
+
* `/run`), which a law process in the sandbox may not do, and a node law has no use for it.
|
|
46
|
+
*/
|
|
47
|
+
let playwright;
|
|
48
|
+
const engineType = (engine) => (playwright ??= createRequire(import.meta.url)('playwright-core'))[engine];
|
|
42
49
|
const engines = ['chromium', 'firefox', 'webkit'];
|
|
43
50
|
/** The engine to use: the requested one, else `TSLAWS_BROWSER_ENGINE`, else chromium. Throws on an unknown name. */
|
|
44
51
|
export function resolveEngine(requested, env = process.env) {
|
|
@@ -64,7 +71,7 @@ export function engineExecutable(engine, env = process.env) {
|
|
|
64
71
|
let path = fromEnv !== undefined && fromEnv !== '' ? fromEnv : undefined;
|
|
65
72
|
if (path === undefined) {
|
|
66
73
|
try {
|
|
67
|
-
path = (engine
|
|
74
|
+
path = engineType(engine).executablePath();
|
|
68
75
|
}
|
|
69
76
|
catch {
|
|
70
77
|
// Playwright has no such browser installed.
|
|
@@ -78,7 +85,7 @@ const browsers = new Map();
|
|
|
78
85
|
export function launch(engine) {
|
|
79
86
|
let open = browsers.get(engine);
|
|
80
87
|
if (open === undefined) {
|
|
81
|
-
const type =
|
|
88
|
+
const type = engineType(engine);
|
|
82
89
|
open = (async () => type.launch({ executablePath: engineExecutable(engine), headless: true }))();
|
|
83
90
|
open.catch(() => browsers.delete(engine));
|
|
84
91
|
browsers.set(engine, open);
|
|
@@ -159,6 +166,8 @@ function projectModulesPlugin(cwd) {
|
|
|
159
166
|
// template, a stylesheet, an image) would look for it there. Such an import resolves to the file beside the source.
|
|
160
167
|
function sourceFilesPlugin(cwd) {
|
|
161
168
|
const out = join(cwd, '.tslaws', 'out');
|
|
169
|
+
// The project's own output may sit below `out` (when sources outside it were compiled too); paths map from there.
|
|
170
|
+
const project = compiledDirOf(cwd);
|
|
162
171
|
return {
|
|
163
172
|
name: 'tslaws-source-files',
|
|
164
173
|
setup(build) {
|
|
@@ -168,7 +177,7 @@ function sourceFilesPlugin(cwd) {
|
|
|
168
177
|
const inOut = resolve(args.resolveDir, args.path);
|
|
169
178
|
if (existsSync(inOut))
|
|
170
179
|
return undefined;
|
|
171
|
-
const source = join(cwd, pathRelative(
|
|
180
|
+
const source = join(cwd, pathRelative(project, inOut));
|
|
172
181
|
return existsSync(source) && !source.endsWith('.js') ? { path: source } : undefined;
|
|
173
182
|
});
|
|
174
183
|
},
|
|
@@ -189,6 +198,16 @@ const assetExtensions = [
|
|
|
189
198
|
'.otf',
|
|
190
199
|
'.eot',
|
|
191
200
|
];
|
|
201
|
+
/**
|
|
202
|
+
* esbuild reads the nearest tsconfig.json by itself (paths, baseUrl, extends); this carries the tslaws.json setting over:
|
|
203
|
+
* a named file, or none for `"tsconfig": false`.
|
|
204
|
+
*/
|
|
205
|
+
function bundlerTsconfig(cwd) {
|
|
206
|
+
const setting = readConfig(cwd).tsconfig;
|
|
207
|
+
if (setting === false)
|
|
208
|
+
return { tsconfigRaw: '{}' };
|
|
209
|
+
return setting === undefined ? {} : { tsconfig: resolve(cwd, setting) };
|
|
210
|
+
}
|
|
192
211
|
/** The project's `bundlerPlugins` from tslaws.json come first, so they can claim a format before the built-in resolver. */
|
|
193
212
|
async function bundleOf(jsFile, cwd) {
|
|
194
213
|
const projectPlugins = await loadBundlerPlugins(cwd, readConfig(cwd).bundlerPlugins);
|
|
@@ -207,6 +226,7 @@ async function bundleOf(jsFile, cwd) {
|
|
|
207
226
|
platform: 'browser',
|
|
208
227
|
target: 'es2022',
|
|
209
228
|
absWorkingDir: cwd,
|
|
229
|
+
...bundlerTsconfig(cwd),
|
|
210
230
|
logLevel: 'silent',
|
|
211
231
|
// A dependency's `import.meta.env` reads the same global the compiled laws do; the page sets it before the bundle.
|
|
212
232
|
define: {
|
package/dist/bundled.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// The compiler that npm installs with tslaws: one optional dependency per platform, `tslaws-compiler-<platform>`, holding
|
|
2
2
|
// the native executable and the TypeScript lib files beside it.
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
import { createRequire } from 'node:module';
|
|
5
4
|
import { dirname, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
6
|
export const platforms = [
|
|
7
7
|
{ name: 'darwin-arm64', os: 'darwin', cpu: 'arm64' },
|
|
8
8
|
{ name: 'darwin-x64', os: 'darwin', cpu: 'x64' },
|
|
@@ -36,7 +36,7 @@ export function bundledCompiler() {
|
|
|
36
36
|
if (platform === undefined)
|
|
37
37
|
return undefined;
|
|
38
38
|
try {
|
|
39
|
-
const manifest =
|
|
39
|
+
const manifest = fileURLToPath(import.meta.resolve(`${packageName(platform)}/package.json`));
|
|
40
40
|
const executable = join(dirname(manifest), 'lib', executableName());
|
|
41
41
|
return existsSync(executable) ? executable : undefined;
|
|
42
42
|
}
|
package/dist/bundlerPlugins.d.ts
CHANGED
|
@@ -18,3 +18,5 @@ export declare function loadBundlerPlugins(cwd: string, paths: readonly string[]
|
|
|
18
18
|
* sign that a `bundlerPlugins` entry is missing). Other messages pass through unchanged.
|
|
19
19
|
*/
|
|
20
20
|
export declare function explainBundleError(error: Error): Error;
|
|
21
|
+
/** The error for a file a node law loads that no `bundlerPlugins` entry handles (and esbuild has no loader for). */
|
|
22
|
+
export declare function explainNodeLoadError(file: string, esbuildMessage: string): Error;
|
package/dist/bundlerPlugins.js
CHANGED
|
@@ -69,3 +69,10 @@ export function explainBundleError(error) {
|
|
|
69
69
|
`JavaScript (see "Bundler plugins" in docs/laws.md)`;
|
|
70
70
|
return new Error(`${advice}. esbuild said: ${error.message.split('\n')[0]}`);
|
|
71
71
|
}
|
|
72
|
+
/** The error for a file a node law loads that no `bundlerPlugins` entry handles (and esbuild has no loader for). */
|
|
73
|
+
export function explainNodeLoadError(file, esbuildMessage) {
|
|
74
|
+
const extension = /No loader is configured for "(\.[^"]+)" files/.exec(esbuildMessage)?.[1] ?? file;
|
|
75
|
+
return new Error(`cannot load "${file}": no bundler plugin handles "${extension}" files. Add one in tslaws.json ` +
|
|
76
|
+
`"${bundlerPluginsSetting}" (an esbuild plugin whose onLoad returns JavaScript for the extension); node laws use ` +
|
|
77
|
+
`the same plugins as browser laws (see "Bundler plugins" in docs/laws.md)`);
|
|
78
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { type HornCertification } from './chc.ts';
|
|
2
|
+
import { cvc5Text } from './solvers.ts';
|
|
3
|
+
/** `certify` in tslaws.json: off (absent or false), on, or `"require"`, where a law without a certificate is an error. */
|
|
4
|
+
export type CertifyMode = boolean | 'require';
|
|
5
|
+
export type CertificateStatus = 'certified' | 'uncertified' | 'unavailable';
|
|
6
|
+
/** What certifying one proof produced. The hashes are set only for `certified`. */
|
|
7
|
+
export interface Certificate {
|
|
8
|
+
status: CertificateStatus;
|
|
9
|
+
/** Why the proof is not certified: what cvc5 or Carcara said, or which syntax cannot be certified. */
|
|
10
|
+
reason?: string;
|
|
11
|
+
/** SHA-256 of the SMT-LIB problem both tools read. */
|
|
12
|
+
problemHash?: string;
|
|
13
|
+
/**
|
|
14
|
+
* For a proof by loop invariants: SHA-256 of the Horn text the invariants are for. The problem holds the invariants
|
|
15
|
+
* Z3 found, which can differ from run to run, so the law is bound to this text (which the code alone yields) instead.
|
|
16
|
+
*/
|
|
17
|
+
systemHash?: string;
|
|
18
|
+
/** SHA-256 of the Alethe proof. */
|
|
19
|
+
proofHash?: string;
|
|
20
|
+
/** SHA-256 of the checker's verdict bound to the problem and proof it checked. */
|
|
21
|
+
checkerHash?: string;
|
|
22
|
+
/** Project-relative path of the saved proof, when a directory was given. */
|
|
23
|
+
proofFile?: string;
|
|
24
|
+
}
|
|
25
|
+
/** What is wrong with a `certify` value from tslaws.json, or undefined when it is valid. */
|
|
26
|
+
export declare function certifyProblem(value: unknown): string | undefined;
|
|
27
|
+
/** `certified`, or `uncertified (reason)` or `unavailable (reason)`: the line a report shows for a law. */
|
|
28
|
+
export declare function certificateLabel(certificate: Certificate): string;
|
|
29
|
+
/** Whether a certificate satisfies the mode: with `require`, only a certified proof does. */
|
|
30
|
+
export declare function certificateFailure(mode: CertifyMode | undefined, certificate: Certificate): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* What cvc5's Alethe proofs cannot cover. Alethe has no rules for floating point or for strings and regular
|
|
33
|
+
* expressions, so a query that uses them has no proof Carcara could check. Returns the reason, or undefined when the
|
|
34
|
+
* query is in the fragment cvc5 can prove in Alethe.
|
|
35
|
+
*/
|
|
36
|
+
export declare function uncertifiable(query: string): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The problem cvc5 and Carcara both read: the query as `cvc5Text` renders it (no Z3 timeout, no `(get-model)`, a logic
|
|
39
|
+
* set), so the proof is checked against exactly the text cvc5 proved.
|
|
40
|
+
*/
|
|
41
|
+
export declare const problemText: typeof cvc5Text;
|
|
42
|
+
/**
|
|
43
|
+
* Options that make cvc5 print an Alethe proof Carcara can check.
|
|
44
|
+
*
|
|
45
|
+
* `--no-proof-alethe-res-pivots` matters: with pivots on, cvc5 names the pivot of each `resolution` step, and for a clause
|
|
46
|
+
* that repeats a literal (every integer range obligation does: `a` is bounded once per use) the named pivot is not found
|
|
47
|
+
* in the clause, so Carcara fails with "pivot was not found" on a proof that is sound. Without them Carcara finds each
|
|
48
|
+
* pivot itself. cvc5's own regression tests check Alethe proofs with this option off.
|
|
49
|
+
*/
|
|
50
|
+
export declare const cvc5ProofArgs: readonly string[];
|
|
51
|
+
/** Carcara's arguments after `check <proof> <problem>`: the options cvc5's proofs need. */
|
|
52
|
+
export declare const carcaraArgs: readonly string[];
|
|
53
|
+
export declare const hashOf: (text: string) => string;
|
|
54
|
+
export interface CertifyOptions {
|
|
55
|
+
/** Wall-clock budget for each tool, in milliseconds. */
|
|
56
|
+
timeoutMs: number;
|
|
57
|
+
/** Where to keep the problem and proof (`<name>.smt2`, `<name>.alethe`); without it they are removed after the check. */
|
|
58
|
+
keep?: {
|
|
59
|
+
dir: string;
|
|
60
|
+
name: string;
|
|
61
|
+
root: string;
|
|
62
|
+
};
|
|
63
|
+
/** Set when the query is a loop proof made by `certificationProblem`: the text it came from, kept beside the proof. */
|
|
64
|
+
horn?: HornCertification;
|
|
65
|
+
}
|
|
66
|
+
/** The names of the RARE rewrite rules an Alethe proof applies. */
|
|
67
|
+
export declare function rareRulesOf(proof: string): string[];
|
|
68
|
+
/**
|
|
69
|
+
* The RARE rule declarations for `names`, in the form Carcara reads. cvc5 itself prints its database of rewrite rules, so
|
|
70
|
+
* the rules a proof may lean on come from the same binary that wrote the proof and never from a file beside the proof;
|
|
71
|
+
* the few rules in `aletheRareRules` are the exception, because the binary's own text for them cannot be checked.
|
|
72
|
+
*/
|
|
73
|
+
export declare function rareDeclarations(names: string[], work: string, budget: number): Promise<{
|
|
74
|
+
text: string;
|
|
75
|
+
} | {
|
|
76
|
+
status: 'uncertified' | 'unavailable';
|
|
77
|
+
reason: string;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Certifies the `unsat` answer of a query: cvc5 proves it again in Alethe, Carcara checks the proof. Never throws for a
|
|
81
|
+
* missing or failing tool; the outcome is in the certificate's status.
|
|
82
|
+
*/
|
|
83
|
+
export declare function certify(query: string, options: CertifyOptions): Promise<Certificate>;
|
|
84
|
+
/**
|
|
85
|
+
* Certifies a proof by loop invariants. The invariants Z3's Spacer found are put back into the clauses
|
|
86
|
+
* (`certificationProblem`), and the problem that results is an ordinary query, refuted by cvc5 and checked by Carcara
|
|
87
|
+
* like any other: a certificate says that the invariants hold at entry, are kept by every pass of the body, and imply the
|
|
88
|
+
* law, and Spacer needs no more trust than a guess does.
|
|
89
|
+
*/
|
|
90
|
+
export declare function certifyHorn(certification: HornCertification, options: CertifyOptions): Promise<Certificate>;
|
|
91
|
+
/**
|
|
92
|
+
* One certified law as the lock records it. `law` is the law's lock hash, so a later edit voids the record, and
|
|
93
|
+
* `problemHash` is the hash of the exact SMT-LIB problem that was proved, so a change to code the law calls (which the
|
|
94
|
+
* law's own hash does not cover) voids it too: a record is made only from a proof this run produced.
|
|
95
|
+
*/
|
|
96
|
+
export interface CertificateRecord {
|
|
97
|
+
law: string;
|
|
98
|
+
problemHash: string;
|
|
99
|
+
/** For a proof by loop invariants: the hash of the Horn text, which is what the code determines (see `Certificate`). */
|
|
100
|
+
systemHash?: string;
|
|
101
|
+
proofHash: string;
|
|
102
|
+
checkerHash: string;
|
|
103
|
+
}
|
|
104
|
+
/** What binds a record to the code: the Horn text for a loop proof, the problem itself for any other. */
|
|
105
|
+
export declare const bindingOf: (hashes: {
|
|
106
|
+
problemHash?: string;
|
|
107
|
+
systemHash?: string;
|
|
108
|
+
}) => string | undefined;
|
|
109
|
+
/** The file name a law's problem and proof are kept under, beside `.tslaws/certificates/`. */
|
|
110
|
+
export declare function certificateName(key: string): string;
|
|
111
|
+
/** Where `tslaws check` keeps the problems and proofs of the laws it certified. */
|
|
112
|
+
export declare const certificatesDir: (cwd: string) => string;
|
|
113
|
+
/**
|
|
114
|
+
* Where `tslaws check` leaves the records of the laws it certified, for `tslaws accept` to consider. Anyone can write this
|
|
115
|
+
* file, so accept trusts none of it: see `verifyRecord`.
|
|
116
|
+
*/
|
|
117
|
+
export declare const recordsPath: (cwd: string) => string;
|
|
118
|
+
export declare function readRecords(cwd: string): Record<string, CertificateRecord>;
|
|
119
|
+
/**
|
|
120
|
+
* Updates the records after a check: each law that was proved or bounded has its record replaced by the new one when it
|
|
121
|
+
* is certified and removed when it is not (a law that did not run keeps what it had).
|
|
122
|
+
*/
|
|
123
|
+
export declare function writeRecords(cwd: string, updates: Map<string, CertificateRecord | undefined>): void;
|
|
124
|
+
/**
|
|
125
|
+
* Whether a record from the sidecar may enter the lock, or why not. Nothing in the sidecar is trusted. The record must
|
|
126
|
+
* be for the law as it is now (`lawNow`) and for a problem the law still yields (`problems`, the hashes of the problems
|
|
127
|
+
* `tslaws accept` rebuilt from the code); the saved problem and proof must exist and hash as the record says; and
|
|
128
|
+
* Carcara must accept them again, here and now. With Carcara missing nothing is kept.
|
|
129
|
+
*/
|
|
130
|
+
export declare function verifyRecord(cwd: string, key: string, record: unknown, lawNow: string, problems: ReadonlySet<string>, timeoutMs?: number): Promise<string | undefined>;
|
|
131
|
+
/** The record for a certified certificate, or undefined for any other. */
|
|
132
|
+
export declare function recordOf(lawHash: string, certificate: Certificate): CertificateRecord | undefined;
|
|
133
|
+
/** The certificate a proved or bounded law gets when certifying is on but no proof was checked. */
|
|
134
|
+
export declare const noCertificate: Certificate;
|
|
135
|
+
/**
|
|
136
|
+
* Whether a lock record still describes what a run just proved: the same problem. A law with no record, or a run
|
|
137
|
+
* that did not certify it, has nothing to compare.
|
|
138
|
+
*/
|
|
139
|
+
export declare function staleRecord(record: CertificateRecord | undefined, certificate: Certificate): boolean;
|