lawspec 0.24.0 → 0.26.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/CHANGELOG.md +109 -1
- package/README.md +34 -26
- package/UNICODE-LICENSE.txt +39 -0
- package/api.mjs +6 -23
- package/bin/lawspec.mjs +148 -65
- package/build.json +245 -177
- package/builtin-data-names.mjs +73 -0
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -0
- package/examples/native-payments/clojure/lawspec.json +13 -2
- package/examples/native-payments/csharp/lawspec.json +13 -2
- package/examples/native-payments/elixir/lawspec.json +14 -3
- package/examples/native-payments/erlang/lawspec.json +14 -3
- package/examples/native-payments/fsharp/lawspec.json +14 -3
- package/examples/native-payments/gleam/lawspec.json +14 -3
- package/examples/native-payments/go/lawspec.json +14 -3
- package/examples/native-payments/groovy/lawspec.json +14 -3
- package/examples/native-payments/haskell/lawspec.json +14 -3
- package/examples/native-payments/java/lawspec.json +14 -3
- package/examples/native-payments/javascript/lawspec.json +14 -3
- package/examples/native-payments/kotlin/lawspec.json +14 -3
- package/examples/native-payments/python/lawspec.json +14 -3
- package/examples/native-payments/rust/lawspec.json +14 -3
- package/examples/native-payments/scala/lawspec.json +14 -3
- package/examples/native-payments/swift/lawspec.json +14 -3
- package/examples/native-payments/typescript/lawspec.json +14 -3
- package/examples/packages/orders/lawspec.json +25 -5
- package/examples/packages/orders/orders.lawspec +57 -53
- package/examples/packages/shop-domain/src/domain.lawspec +36 -33
- package/examples/packages/shop-tax-1/src/api.lawspec +1 -0
- package/examples/packages/shop-tax-1/src/rates.lawspec +5 -4
- package/examples/packages/shop-tax-2/src/api.lawspec +1 -0
- package/examples/packages/shop-tax-2/src/rates.lawspec +6 -4
- package/examples/rc1/authorization-snapshots.lawspec +113 -0
- package/examples/rc1/banner-filenames.lawspec +64 -0
- package/examples/rc1/bit-codec.lawspec +57 -0
- package/examples/rc1/bounded-witness-search.lawspec +151 -0
- package/examples/rc1/conflicting-requirements.lawspec +31 -0
- package/examples/rc1/constructive-witnesses.lawspec +120 -0
- package/examples/rc1/documentary-review.lawspec +43 -0
- package/examples/rc1/empty-domains.lawspec +47 -0
- package/examples/rc1/finite-integer-domains.lawspec +76 -0
- package/examples/rc1/law-metadata.lawspec +30 -0
- package/examples/rc1/native-payments.lawspec +108 -0
- package/examples/rc1/nesting/rrr.lawspec +34 -0
- package/examples/rc1/nesting/rru.lawspec +57 -0
- package/examples/rc1/nesting/rur.lawspec +58 -0
- package/examples/rc1/nesting/ruu.lawspec +78 -0
- package/examples/rc1/nesting/urr.lawspec +53 -0
- package/examples/rc1/nesting/uru.lawspec +73 -0
- package/examples/rc1/nesting/uur.lawspec +74 -0
- package/examples/rc1/nesting/uuu.lawspec +96 -0
- package/examples/rc1/order-workflow.lawspec +127 -0
- package/examples/rc1/parcel-measurements.lawspec +93 -0
- package/examples/rc1/picture-records.lawspec +52 -0
- package/examples/rc1/picture-tuples.lawspec +48 -0
- package/examples/rc1/record-payloads.lawspec +57 -0
- package/examples/rc1/recursive-records.lawspec +65 -0
- package/examples/rc1/refund-conformance.lawspec +45 -0
- package/examples/rc1/refund-policy.lawspec +89 -0
- package/examples/rc1/requirement-composition.lawspec +90 -0
- package/examples/rc1/structural-records.lawspec +54 -0
- package/examples/rc1-authoring.lawspec +57 -0
- package/examples/specs/abilities.lawspec +67 -65
- package/examples/specs/ability_imports.lawspec +58 -57
- package/examples/specs/actors.lawspec +23 -22
- package/examples/specs/algebra.lawspec +142 -141
- package/examples/specs/approvals.lawspec +16 -15
- package/examples/specs/async_bindings.lawspec +10 -9
- package/examples/specs/async_fetch.lawspec +12 -11
- package/examples/specs/atoi_codec.lawspec +16 -15
- package/examples/specs/boolean_flags.lawspec +10 -9
- package/examples/specs/builtins.lawspec +73 -72
- package/examples/specs/canonical_url.lawspec +14 -13
- package/examples/specs/collections.lawspec +153 -154
- package/examples/specs/composition.lawspec +70 -66
- package/examples/specs/concurrent_collections.lawspec +8 -7
- package/examples/specs/consistency.lawspec +4 -3
- package/examples/specs/contracts.lawspec +80 -79
- package/examples/specs/crypto.lawspec +26 -25
- package/examples/specs/ctc.lawspec +148 -0
- package/examples/specs/currying.lawspec +32 -31
- package/examples/specs/data_types.lawspec +50 -49
- package/examples/specs/distribution.lawspec +57 -56
- package/examples/specs/domain_modeling.lawspec +48 -47
- package/examples/specs/durations.lawspec +39 -38
- package/examples/specs/equivalent.lawspec +25 -24
- package/examples/specs/failures.lawspec +64 -63
- package/examples/specs/finite_data.lawspec +32 -31
- package/examples/specs/flow_stack.lawspec +64 -63
- package/examples/specs/gadt_expressions.lawspec +50 -49
- package/examples/specs/generation.lawspec +115 -114
- package/examples/specs/handler_bindings.lawspec +42 -40
- package/examples/specs/handles.lawspec +2 -1
- package/examples/specs/harness.lawspec +45 -43
- package/examples/specs/harness_testing.lawspec +18 -13
- package/examples/specs/indexed_arithmetic.lawspec +401 -126
- package/examples/specs/indexed_families.lawspec +182 -66
- package/examples/specs/keywords.lawspec +22 -21
- package/examples/specs/limits.lawspec +6 -5
- package/examples/specs/list_contracts.lawspec +121 -120
- package/examples/specs/list_refinements.lawspec +43 -42
- package/examples/specs/lists.lawspec +45 -44
- package/examples/specs/matchers.lawspec +79 -78
- package/examples/specs/matching.lawspec +43 -42
- package/examples/specs/mixed_inputs.lawspec +25 -24
- package/examples/specs/models.lawspec +44 -43
- package/examples/specs/parse_port.lawspec +28 -27
- package/examples/specs/payments.lawspec +55 -54
- package/examples/specs/railway.lawspec +59 -58
- package/examples/specs/records.lawspec +149 -148
- package/examples/specs/records_inner.lawspec +5 -4
- package/examples/specs/recursive_refinements.lawspec +30 -29
- package/examples/specs/refined_definitions.lawspec +24 -23
- package/examples/specs/refinements.lawspec +58 -57
- package/examples/specs/resilience.lawspec +159 -158
- package/examples/specs/resources.lawspec +61 -60
- package/examples/specs/scalar_adapters.lawspec +60 -59
- package/examples/specs/scalar_catalog.lawspec +165 -164
- package/examples/specs/scalars.lawspec +78 -77
- package/examples/specs/scheduling_order.lawspec +8 -7
- package/examples/specs/scheduling_overlap.lawspec +5 -4
- package/examples/specs/sequences.lawspec +66 -65
- package/examples/specs/sessions.lawspec +13 -12
- package/examples/specs/slug.lawspec +16 -15
- package/examples/specs/sum_refinements.lawspec +42 -41
- package/examples/specs/tables.lawspec +29 -28
- package/examples/specs/total_functions.lawspec +71 -70
- package/examples/specs/workflows.lawspec +101 -100
- package/examples-command.mjs +8 -4
- package/explain.mjs +114 -0
- package/expression-presentation.mjs +333 -0
- package/files.mjs +16 -0
- package/index.d.ts +406 -11
- package/launcher.mjs +9 -2
- package/lsp.mjs +235 -0
- package/native-evidence.mjs +187 -0
- package/native-examples.mjs +8 -1
- package/node-events-reporter.mjs +23 -0
- package/package.json +8 -1
- package/positional-fields.mjs +13 -0
- package/proof.d.ts +35 -0
- package/proof.mjs +174 -0
- package/starter-rc1.lawspec +26 -0
- package/starter.lawspec +16 -15
- package/templates.mjs +6 -4
- package/test-command.mjs +107 -35
- package/typed-presentation.mjs +165 -0
package/lsp.mjs
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// Generated from templates/npm/lsp.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { createCompiler } from './api.mjs';
|
|
6
|
+
|
|
7
|
+
export function utf16Position(text, location) {
|
|
8
|
+
const line = Math.max(0, location.line - 1);
|
|
9
|
+
const content = text.split('\n')[line] ?? '';
|
|
10
|
+
let column = 1, character = 0;
|
|
11
|
+
for (const value of content) {
|
|
12
|
+
if (column >= location.column) break;
|
|
13
|
+
column += value === '\t' ? 8 - ((column - 1) % 8) : 1;
|
|
14
|
+
character += value.length;
|
|
15
|
+
}
|
|
16
|
+
return { line, character };
|
|
17
|
+
}
|
|
18
|
+
const endPosition = text => {
|
|
19
|
+
const lines = text.split('\n');
|
|
20
|
+
return { line: lines.length - 1, character: lines.at(-1).length };
|
|
21
|
+
};
|
|
22
|
+
const within = (position, range) => (position.line > range.start.line || position.line === range.start.line && position.character >= range.start.character)
|
|
23
|
+
&& (position.line < range.end.line || position.line === range.end.line && position.character < range.end.character);
|
|
24
|
+
|
|
25
|
+
// A framed JSON-RPC transport keeps UTF-8 byte lengths distinct from editor
|
|
26
|
+
// UTF-16 positions. It accepts fragmented and coalesced messages.
|
|
27
|
+
export async function serveLanguage(input = process.stdin, output = process.stdout, suppliedCompiler) {
|
|
28
|
+
const compiler = suppliedCompiler ?? await createCompiler();
|
|
29
|
+
const documents = new Map();
|
|
30
|
+
let workspace = process.cwd(), buffer = Buffer.alloc(0), queue = Promise.resolve(), shuttingDown = false;
|
|
31
|
+
let last = { sources: [], result: null }, warnMatches = false;
|
|
32
|
+
let finish;
|
|
33
|
+
const ended = new Promise(resolve => { finish = resolve; });
|
|
34
|
+
const send = value => {
|
|
35
|
+
const payload = Buffer.from(JSON.stringify(value));
|
|
36
|
+
output.write(`Content-Length: ${payload.length}\r\n\r\n`);
|
|
37
|
+
output.write(payload);
|
|
38
|
+
};
|
|
39
|
+
async function projectSources() {
|
|
40
|
+
const sources = new Map();
|
|
41
|
+
async function visit(file) {
|
|
42
|
+
const info = await stat(file);
|
|
43
|
+
if (info.isDirectory()) for (const name of (await readdir(file)).sort()) await visit(path.join(file, name));
|
|
44
|
+
else if (file.endsWith('.lawspec')) sources.set(file, { path: file, content: await readFile(file, 'utf8') });
|
|
45
|
+
}
|
|
46
|
+
let config;
|
|
47
|
+
try { config = JSON.parse(await readFile(path.join(workspace, 'lawspec.json'), 'utf8')); }
|
|
48
|
+
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
49
|
+
if(config&&(config.version!==2||config.languageProfile!=='1.0-rc.2'))
|
|
50
|
+
throw new Error('The language server requires configuration version 2 and languageProfile 1.0-rc.2.');
|
|
51
|
+
for (const entry of config?.sources ?? []) await visit(path.resolve(workspace, entry));
|
|
52
|
+
for (const [uri, document] of documents) sources.set(fileURLToPath(uri), { path: fileURLToPath(uri), content: document.text });
|
|
53
|
+
return [...sources.values()];
|
|
54
|
+
}
|
|
55
|
+
function location(location, sources = last.sources) {
|
|
56
|
+
const source = sources.find(s => s.path === location.file);
|
|
57
|
+
if (!source) return null;
|
|
58
|
+
return { uri: pathToFileURL(source.path).href, position: utf16Position(source.content, location) };
|
|
59
|
+
}
|
|
60
|
+
function span(span) {
|
|
61
|
+
const start = location(span.start ?? span.spanStart), end = location(span.end ?? span.spanEnd);
|
|
62
|
+
return start && end ? { uri: start.uri, range: { start: start.position, end: end.position } } : null;
|
|
63
|
+
}
|
|
64
|
+
async function check() {
|
|
65
|
+
const sources = await projectSources();
|
|
66
|
+
const result = await compiler.check({ sources, languageProfile: '1.0-rc.2', verification: { layers: [] }, ...(warnMatches ? {warnMatches:true} : {}) });
|
|
67
|
+
last = { sources, result };
|
|
68
|
+
for (const [uri, document] of documents) {
|
|
69
|
+
const file = fileURLToPath(uri);
|
|
70
|
+
const diagnostics = [...(result.diagnostics ?? []), ...(warnMatches ? result.warnings ?? [] : [])].filter(d => !d.at || d.at.file === file).map(d => {
|
|
71
|
+
const start = d.at ? utf16Position(document.text, d.at) : { line: 0, character: 0 };
|
|
72
|
+
const content = document.text.split('\n')[start.line] ?? '';
|
|
73
|
+
const end = { ...start, character: Math.min(content.length, start.character + ([...content.slice(start.character)][0]?.length ?? 0)) };
|
|
74
|
+
const range = d.span ? span(d.span)?.range ?? {start,end} : {start,end};
|
|
75
|
+
return { range, severity: d.severity === 'warning' ? 2 : 1, code: d.code, source: 'LawSpec', message: d.message,
|
|
76
|
+
...(d.related?.length ? {relatedInformation: d.related.flatMap(item => {
|
|
77
|
+
const origin = span(item.span);
|
|
78
|
+
return origin ? [{location: {uri: origin.uri, range: origin.range}, message: item.message}] : [];
|
|
79
|
+
})} : {}) };
|
|
80
|
+
});
|
|
81
|
+
send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri, version: document.version, diagnostics } });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function declarations() {
|
|
85
|
+
const result = last.result;
|
|
86
|
+
if (!result) return [];
|
|
87
|
+
const entries = [];
|
|
88
|
+
for (const unit of result.units ?? []) for (const d of unit.declarations) {
|
|
89
|
+
const origin = d.origin?.kind === 'source' ? span(d.origin.span) : null;
|
|
90
|
+
if (origin) entries.push({ id: d.id, name: d.name, kind: 12, detail: JSON.stringify(d.type), ...origin });
|
|
91
|
+
}
|
|
92
|
+
for (const d of result.dataTypes ?? []) {
|
|
93
|
+
const origin = d.origin?.kind === 'source' ? span(d.origin.span) : null;
|
|
94
|
+
if (origin) entries.push({ id: d.id, name: d.name, kind: 23, detail: 'Type', ...origin });
|
|
95
|
+
}
|
|
96
|
+
for (const law of result.laws ?? []) {
|
|
97
|
+
const origin = location(law.location);
|
|
98
|
+
if (origin) entries.push({ id: law.id, name: law.name, kind: 12, detail: law.description || 'Law', uri: origin.uri,
|
|
99
|
+
range: { start: origin.position, end: { ...origin.position, character: origin.position.character + 3 } } });
|
|
100
|
+
}
|
|
101
|
+
return entries;
|
|
102
|
+
}
|
|
103
|
+
function documentaryLinks() {
|
|
104
|
+
return (last.result?.laws ?? []).flatMap(law => (law.references ?? [])
|
|
105
|
+
.filter(reference => reference?.kind === 'law' || reference?.kind === 'function'));
|
|
106
|
+
}
|
|
107
|
+
function documentaryDeclaration(id) {
|
|
108
|
+
const reference = documentaryLinks().find(reference => reference.target.id === id);
|
|
109
|
+
const target = reference?.target, origin = target && span(target.span);
|
|
110
|
+
return origin ? { id, name: target.name, detail: reference.kind === 'law' ? 'Law' : 'Function', ...origin } : null;
|
|
111
|
+
}
|
|
112
|
+
function uses() {
|
|
113
|
+
const result = last.result;
|
|
114
|
+
if (!result) return [];
|
|
115
|
+
const entries = [];
|
|
116
|
+
function walk(value) {
|
|
117
|
+
if (!value || typeof value !== 'object') return;
|
|
118
|
+
if (value.node?.kind === 'call' && value.origin?.kind === 'source') {
|
|
119
|
+
const origin = span(value.origin.span);
|
|
120
|
+
if (origin) entries.push({ id: value.node.declaration, ...origin });
|
|
121
|
+
}
|
|
122
|
+
for (const child of Object.values(value)) if (typeof child === 'object') {
|
|
123
|
+
if (Array.isArray(child)) child.forEach(walk); else walk(child);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
walk(result.laws); walk(result.definitions);
|
|
127
|
+
for (const reference of documentaryLinks()) {
|
|
128
|
+
const origin = span(reference.target.referenceSpan);
|
|
129
|
+
if (origin) entries.push({ id: reference.target.id, ...origin });
|
|
130
|
+
}
|
|
131
|
+
return entries;
|
|
132
|
+
}
|
|
133
|
+
function selected(params) {
|
|
134
|
+
const candidates = [...uses(), ...declarations()].filter(d => d.uri === params.textDocument.uri && within(params.position, d.range));
|
|
135
|
+
candidates.sort((a, b) => (a.range.end.line - a.range.start.line) - (b.range.end.line - b.range.start.line)
|
|
136
|
+
|| (a.range.end.character - a.range.start.character) - (b.range.end.character - b.range.start.character));
|
|
137
|
+
return candidates[0];
|
|
138
|
+
}
|
|
139
|
+
async function handle(message) {
|
|
140
|
+
const params = message.params ?? {};
|
|
141
|
+
let result = null;
|
|
142
|
+
switch (message.method) {
|
|
143
|
+
case 'initialize':
|
|
144
|
+
if (params.initializationOptions?.warnMatches !== undefined && typeof params.initializationOptions.warnMatches !== 'boolean')
|
|
145
|
+
throw new Error('warnMatches must be a Boolean');
|
|
146
|
+
warnMatches = params.initializationOptions?.warnMatches ?? false;
|
|
147
|
+
workspace = params.rootUri ? fileURLToPath(params.rootUri) : params.rootPath ?? workspace;
|
|
148
|
+
result = { capabilities: { textDocumentSync: 1, positionEncoding: 'utf-16', documentFormattingProvider: true,
|
|
149
|
+
documentSymbolProvider: true, hoverProvider: true, definitionProvider: true, referencesProvider: true },
|
|
150
|
+
serverInfo: { name: 'LawSpec', version: '1.0-rc.2' } };
|
|
151
|
+
break;
|
|
152
|
+
case 'initialized': break;
|
|
153
|
+
case 'workspace/didChangeConfiguration': {
|
|
154
|
+
const next = params.settings?.lawspec?.warnMatches;
|
|
155
|
+
if (next !== undefined && typeof next !== 'boolean') throw new Error('lawspec.warnMatches must be a Boolean');
|
|
156
|
+
warnMatches = next ?? false;
|
|
157
|
+
await check(); break;
|
|
158
|
+
}
|
|
159
|
+
case 'shutdown': shuttingDown = true; break;
|
|
160
|
+
case 'exit': input.pause(); finish(); return;
|
|
161
|
+
case 'textDocument/didOpen': documents.set(params.textDocument.uri, params.textDocument); await check(); break;
|
|
162
|
+
case 'textDocument/didChange': {
|
|
163
|
+
const document = documents.get(params.textDocument.uri);
|
|
164
|
+
if (params.contentChanges.some(change => change.range)) throw new Error('LawSpec requires full-document synchronization');
|
|
165
|
+
if (document && params.contentChanges.length) documents.set(params.textDocument.uri, {
|
|
166
|
+
...document, text: params.contentChanges.at(-1).text, version: params.textDocument.version });
|
|
167
|
+
await check(); break;
|
|
168
|
+
}
|
|
169
|
+
case 'textDocument/didClose': documents.delete(params.textDocument.uri);
|
|
170
|
+
send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri: params.textDocument.uri, diagnostics: [] } }); break;
|
|
171
|
+
case 'textDocument/formatting': {
|
|
172
|
+
const document = documents.get(params.textDocument.uri);
|
|
173
|
+
if (!document) { result = []; break; }
|
|
174
|
+
const sourcePath = fileURLToPath(params.textDocument.uri);
|
|
175
|
+
const response = await compiler.format({ sources: await projectSources(), languageProfile: '1.0-rc.2', verification: { layers: [] } });
|
|
176
|
+
if (response.diagnostics?.length) { result = []; break; }
|
|
177
|
+
const formatted = response.formattedSources.find(s => s.path === sourcePath);
|
|
178
|
+
result = formatted && formatted.content !== document.text
|
|
179
|
+
? [{ range: { start: { line: 0, character: 0 }, end: endPosition(document.text) }, newText: formatted.content }] : [];
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case 'textDocument/documentSymbol': result = declarations().filter(d => d.uri === params.textDocument.uri)
|
|
183
|
+
.map(d => ({ name: d.name, detail: d.detail, kind: d.kind, range: d.range, selectionRange: d.range })); break;
|
|
184
|
+
case 'textDocument/hover': {
|
|
185
|
+
const use = selected(params), declaration = use && (declarations().find(d => d.id === use.id) ?? documentaryDeclaration(use.id));
|
|
186
|
+
result = declaration ? { contents: { kind: 'plaintext', value: `${declaration.name}\n${declaration.detail}` }, range: use.range } : null;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
case 'textDocument/definition': {
|
|
190
|
+
const use = selected(params), declaration = use && (declarations().find(d => d.id === use.id) ?? documentaryDeclaration(use.id));
|
|
191
|
+
result = declaration ? { uri: declaration.uri, range: declaration.range } : null;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case 'textDocument/references': {
|
|
195
|
+
const use = selected(params);
|
|
196
|
+
const declared = use && (declarations().find(d => d.id === use.id) ?? documentaryDeclaration(use.id));
|
|
197
|
+
result = use ? [...uses(), ...(params.context?.includeDeclaration && declared ? [declared] : [])].filter(d => d.id === use.id)
|
|
198
|
+
.map(d => ({ uri: d.uri, range: d.range })) : [];
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case '$/cancelRequest': break;
|
|
202
|
+
default: if (message.id !== undefined) send({ jsonrpc: '2.0', id: message.id, error: { code: -32601, message: 'Method not found' } }); return;
|
|
203
|
+
}
|
|
204
|
+
if (message.id !== undefined) send({ jsonrpc: '2.0', id: message.id, result });
|
|
205
|
+
}
|
|
206
|
+
input.on('data', data => {
|
|
207
|
+
buffer = Buffer.concat([buffer, data]);
|
|
208
|
+
for (;;) {
|
|
209
|
+
const headerEnd = buffer.indexOf('\r\n\r\n');
|
|
210
|
+
if (headerEnd < 0) break;
|
|
211
|
+
const length = /^Content-Length:\s*(\d+)\s*$/im.exec(buffer.subarray(0, headerEnd).toString());
|
|
212
|
+
if (!length || Number(length[1]) > 16 * 1024 * 1024) {
|
|
213
|
+
send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Invalid Content-Length' } }); input.pause(); finish(); break;
|
|
214
|
+
}
|
|
215
|
+
const end = headerEnd + 4 + Number(length[1]);
|
|
216
|
+
if (buffer.length < end) break;
|
|
217
|
+
const body = buffer.subarray(headerEnd + 4, end); buffer = buffer.subarray(end);
|
|
218
|
+
queue = queue.then(async () => {
|
|
219
|
+
let message;
|
|
220
|
+
try { message = JSON.parse(body.toString()); }
|
|
221
|
+
catch { send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } }); return; }
|
|
222
|
+
try {
|
|
223
|
+
if (shuttingDown && !['exit', 'shutdown'].includes(message.method)) throw new Error('Server is shutting down');
|
|
224
|
+
await handle(message);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
if (message.id !== undefined) send({ jsonrpc: '2.0', id: message.id, error: { code: -32603, message: error.message } });
|
|
227
|
+
else send({ jsonrpc: '2.0', method: 'window/logMessage', params: { type: 1, message: error.message } });
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
input.once('end', finish);
|
|
233
|
+
await ended;
|
|
234
|
+
await queue;
|
|
235
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// Generated from templates/npm/native-evidence.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
import {readFile} from 'node:fs/promises';
|
|
3
|
+
import {isDeepStrictEqual} from 'node:util';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {doctor} from './doctor.mjs';
|
|
6
|
+
import {planWrites} from './files.mjs';
|
|
7
|
+
import {projectKey} from './failure-database.mjs';
|
|
8
|
+
import {lawKeys,environmentDigest,recordedDigest,projectDigest,invocations} from './test-command.mjs';
|
|
9
|
+
|
|
10
|
+
// Native execution observations are scoped to actual completed test slots.
|
|
11
|
+
// They never establish a universal model proof or a witness-search completeness claim.
|
|
12
|
+
export const obligationTargets = entry => entry.obligations ?? [{declaration:entry.law,stage:'law'}];
|
|
13
|
+
|
|
14
|
+
export function nativeSeed(value){
|
|
15
|
+
const text=String(value),number=Number(text);
|
|
16
|
+
if(!/^[0-9]+$/.test(text))throw new Error('A native seed must be a whole number');
|
|
17
|
+
if(typeof value==='number'&&!Number.isSafeInteger(value))
|
|
18
|
+
throw new Error('The recorded numeric seed lost precision; rerun with an explicit exact seed');
|
|
19
|
+
return Number.isSafeInteger(number)?number:text;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function recordNativeAttempts(run, tests, {keys,seed,ok,profile,output,allEntries=run.laws,at=new Date().toISOString()}) {
|
|
23
|
+
return Object.fromEntries((run.laws??[]).map(entry=>{
|
|
24
|
+
const matched=tests.filter(test=>(run.matches?.(test)??[]).includes(entry));
|
|
25
|
+
const model=(entry.obligations?.length??0)>0;
|
|
26
|
+
const complete=matched.length>0&&matched.every(test=>test.status==='passed')&&(ok||model);
|
|
27
|
+
const outcome=matched.some(test=>test.status==='failed')?'failed':
|
|
28
|
+
entry.skip?'skipped':complete?(entry.knownFailing?'known-failing':'passed'):
|
|
29
|
+
matched.length&&matched.every(test=>test.status==='skipped')?'skipped':'incomplete';
|
|
30
|
+
return [entry.law,{key:keys.get(entry.law),planKey:entry.key,seed:nativeSeed(seed),at,outcome,
|
|
31
|
+
profile,coverage:entry.coverage??{kind:'sampled',scopedQuantifiers:true},check:{id:entry.law,unit:entry.unit,file:entry.file,name:entry.name,label:entry.label,
|
|
32
|
+
...(entry.scope?{scope:entry.scope}:{}),obligations:obligationTargets(entry),
|
|
33
|
+
nativeGroup:(allEntries??[]).filter(other=>other.file===entry.file&&other.name===entry.name&&other.scope===entry.scope)
|
|
34
|
+
.map(other=>other.law)},
|
|
35
|
+
// A passed combined method covers all its logical model aliases. A failed
|
|
36
|
+
// combined method completes none successfully, even if another method passed.
|
|
37
|
+
tests:matched,invocation:{ok,command:run.command,
|
|
38
|
+
...(!ok&&['failed','incomplete'].includes(outcome)&&output&&
|
|
39
|
+
!matched.some(test=>test.status==='failed'&&(test.failure||test.reason||test.message))?{output}: {})},
|
|
40
|
+
verification:'native-execution',searchCompleteness:'not-established'}];
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function attestedKeys(result) {
|
|
45
|
+
return new Map((result.evidence??[]).filter(item=>item.against||item.plannedAgainst)
|
|
46
|
+
.map(item=>[item.declaration,JSON.stringify([
|
|
47
|
+
item.environment??item.plannedEnvironment,item.against??item.plannedAgainst])]));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const subject = (entry,item) => obligationTargets(entry).some(target=>
|
|
51
|
+
target.declaration===item.declaration&&target.stage===item.stage);
|
|
52
|
+
const runtimeStages=new Set(['law','model','linearizable','sequentially consistent','causally consistent',
|
|
53
|
+
'eventually consistent','restart','scenario','supervision']);
|
|
54
|
+
|
|
55
|
+
// Only observations with matching current compiler/configuration/source/native
|
|
56
|
+
// inputs are eligible for completed evidence. A stored timestamp alone is not.
|
|
57
|
+
export async function readNativeObservations({compiler,input,selected,roots,configRoot,build,evidence,attestation}) {
|
|
58
|
+
const records=await Promise.all(selected.map(async(target,index)=>{
|
|
59
|
+
const root=roots[index],file=path.join(configRoot,'.lawspec/results',`${target.language}-${projectKey(root)}.json`);
|
|
60
|
+
const record=JSON.parse(await readFile(file,'utf8').catch(error=>{
|
|
61
|
+
if(error.code==='ENOENT')return '{}';throw error;
|
|
62
|
+
}));
|
|
63
|
+
return {target,root,attempts:record.attempts??{},runs:record.laws??{}};
|
|
64
|
+
}));
|
|
65
|
+
if(!records.some(record=>Object.keys(record.attempts).length))return [];
|
|
66
|
+
const observations=[];
|
|
67
|
+
for(const {target,root,attempts,runs}of records){
|
|
68
|
+
const plans=new Map(),contexts=new Map();
|
|
69
|
+
async function plan(minify){
|
|
70
|
+
if(!plans.has(minify))plans.set(minify,await compiler.planGeneration({...input,target:target.language,
|
|
71
|
+
sourceDir:target.sourceDir,testDir:target.testDir,nativeBindings:target.nativeBindings,minify,
|
|
72
|
+
...(attestation?{attestation}:{})}));
|
|
73
|
+
return plans.get(minify);
|
|
74
|
+
}
|
|
75
|
+
const modes=[...new Set(Object.values(attempts).map(attempt=>attempt.profile?.minify)
|
|
76
|
+
.filter(mode=>typeof mode==='boolean'))];
|
|
77
|
+
if(!modes.length)modes.push(false);
|
|
78
|
+
const base=await plan(modes[0]);
|
|
79
|
+
if(base.diagnostics.length){
|
|
80
|
+
observations.push({target:target.language,root,freshness:'unavailable',outcome:'incomplete',
|
|
81
|
+
obligations:evidence.filter(item=>runtimeStages.has(item.stage)).map(({declaration,stage})=>({declaration,stage})),
|
|
82
|
+
reason:'Native generation is unavailable: '+base.diagnostics.map(diagnostic=>diagnostic.message).join('; ')});
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const expected=new Map(base.tests.map(entry=>[entry.law,entry]));
|
|
86
|
+
async function context(minify){
|
|
87
|
+
if(contexts.has(minify))return contexts.get(minify);
|
|
88
|
+
const generated=await plan(minify);
|
|
89
|
+
let result;
|
|
90
|
+
if(generated.diagnostics.length)result={reason:'Native generation is unavailable for the recorded layout'};
|
|
91
|
+
else {
|
|
92
|
+
const pending=await planWrites(root,generated.files);
|
|
93
|
+
if(pending.changes.length)result={stale:true,reason:'Generated files differ from the recorded/current plan'};
|
|
94
|
+
else {
|
|
95
|
+
const report=await doctor(target,root,generated.files);
|
|
96
|
+
if(!report.ok)result={reason:'The current native environment could not be checked: '+report.message};
|
|
97
|
+
else {
|
|
98
|
+
const owned=new Set(generated.files.filter(file=>file.ownership==='generated').map(file=>file.path));
|
|
99
|
+
const keys=lawKeys({build,target,machineBits:input.machineBits,minify,tests:generated.tests,files:generated.files,
|
|
100
|
+
environment:await environmentDigest(root,report)+await recordedDigest(path.join(configRoot,'recorded')),
|
|
101
|
+
project:await projectDigest(root,owned),attested:attestedKeys(generated)});
|
|
102
|
+
result={generated,keys};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
contexts.set(minify,result);return result;
|
|
107
|
+
}
|
|
108
|
+
for(const [id,baseline]of expected){
|
|
109
|
+
const attempt=attempts[id];
|
|
110
|
+
const row={target:target.language,root,check:{id,obligations:obligationTargets(baseline)},
|
|
111
|
+
outcome:attempt?.outcome??'not-run',coverage:baseline.coverage,attempt};
|
|
112
|
+
if(!attempt){observations.push({...row,freshness:'not-run',reason:'No completed native observation was recorded'});continue;}
|
|
113
|
+
const profile=attempt.profile??{};
|
|
114
|
+
if(profile.target!==target.language||profile.root!==root||profile.machineBits!==input.machineBits||profile.build!==build||
|
|
115
|
+
typeof profile.minify!=='boolean'){
|
|
116
|
+
observations.push({...row,freshness:'stale',reason:'Compiler, target or machine profile differs'});continue;
|
|
117
|
+
}
|
|
118
|
+
const current=await context(profile.minify);
|
|
119
|
+
if(current.reason){observations.push({...row,freshness:current.stale?'stale':'unavailable',reason:current.reason});continue;}
|
|
120
|
+
const entry=current.generated.tests.find(entry=>entry.law===id);
|
|
121
|
+
if(!entry||attempt.key!==current.keys.get(id)||attempt.planKey!==entry.key||
|
|
122
|
+
!isDeepStrictEqual(attempt.check?.obligations,obligationTargets(entry))||
|
|
123
|
+
!isDeepStrictEqual(attempt.coverage,entry.coverage)){
|
|
124
|
+
observations.push({...row,freshness:'stale',reason:'Specification, selection, bindings, native source or toolchain inputs differ'});continue;
|
|
125
|
+
}
|
|
126
|
+
const invocation=invocations(target,[entry],{root}).find(run=>run.laws?.includes(entry));
|
|
127
|
+
const validSeed=(typeof attempt.seed==='number'&&Number.isSafeInteger(attempt.seed)&&attempt.seed>=0)||
|
|
128
|
+
(typeof attempt.seed==='string'&&/^[0-9]+$/.test(attempt.seed));
|
|
129
|
+
const recomputed=validSeed&&Number.isFinite(Date.parse(attempt.at))&&invocation&&Array.isArray(attempt.tests)&&recordNativeAttempts(invocation,attempt.tests,
|
|
130
|
+
{keys:current.keys,seed:attempt.seed,ok:attempt.invocation?.ok===true,profile,at:attempt.at,
|
|
131
|
+
allEntries:current.generated.tests})[id];
|
|
132
|
+
if(!recomputed||recomputed.outcome!==attempt.outcome||
|
|
133
|
+
!isDeepStrictEqual(recomputed.check.nativeGroup,attempt.check?.nativeGroup)){
|
|
134
|
+
observations.push({...row,freshness:'unavailable',reason:'The stored observation does not establish the current native completion'});continue;
|
|
135
|
+
}
|
|
136
|
+
const run=runs[id];
|
|
137
|
+
observations.push({...row,freshness:'matching-inputs',
|
|
138
|
+
...(attempt.outcome==='passed'&&run?.key===attempt.key&&(run.flaky||run.adequacy)?
|
|
139
|
+
{harness:{...(run.flaky?{flaky:true}:{}),...(run.adequacy?{adequacy:run.adequacy}:{})}}:{}),
|
|
140
|
+
reason:attempt.outcome==='passed'?'Recorded native completion matches the current inputs':'Recorded native attempt matches the current inputs'});
|
|
141
|
+
}
|
|
142
|
+
for(const [id,attempt]of Object.entries(attempts))if(!expected.has(id)&&Array.isArray(attempt.check?.obligations))
|
|
143
|
+
observations.push({target:target.language,root,check:attempt.check,attempt,outcome:attempt.outcome,
|
|
144
|
+
coverage:attempt.coverage,freshness:'not-selected',reason:'This native check is not selected by the current configuration'});
|
|
145
|
+
}
|
|
146
|
+
return observations;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function attachNativeEvidence(evidence,observations){
|
|
150
|
+
return evidence.map(item=>{
|
|
151
|
+
const rows=observations.filter(row=>row.check?subject({obligations:row.check.obligations},item):
|
|
152
|
+
row.obligations?.some(target=>target.declaration===item.declaration&&target.stage===item.stage));
|
|
153
|
+
if(!rows.length)return item;
|
|
154
|
+
const current=rows.filter(row=>row.freshness==='matching-inputs');
|
|
155
|
+
const failed=current.filter(row=>row.outcome==='failed');
|
|
156
|
+
const combinedFailure=failed.some(row=>(row.attempt?.check.nativeGroup?.length??0)>1);
|
|
157
|
+
const status=failed.length?(combinedFailure?'incomplete':'failed'):
|
|
158
|
+
current.length===rows.length&¤t.every(row=>row.outcome==='passed')?'passed':
|
|
159
|
+
current.length===rows.length&¤t.every(row=>row.outcome==='skipped')?'skipped':
|
|
160
|
+
current.length===rows.length&¤t.every(row=>row.outcome==='known-failing')?'known-failing':
|
|
161
|
+
current.some(row=>row.outcome==='passed')?'partial':
|
|
162
|
+
current.some(row=>['incomplete','not-run'].includes(row.outcome))?'incomplete':
|
|
163
|
+
rows.every(row=>row.freshness==='not-selected')?'not-selected':
|
|
164
|
+
rows.some(row=>row.freshness==='stale')?'stale':'unavailable';
|
|
165
|
+
const completeFinite=status==='passed'&&rows.every(row=>row.coverage?.kind==='finite-inputs'&&
|
|
166
|
+
row.coverage.scopedQuantifiers===false);
|
|
167
|
+
const nativeEvidence={kind:'native-conformance',status,
|
|
168
|
+
searchCompleteness:completeFinite?'complete-finite-inputs':'not-established',observations:rows};
|
|
169
|
+
const adequacy=current.flatMap(row=>row.harness?.adequacy??[]);
|
|
170
|
+
const enriched={...item,nativeEvidence,...(adequacy.length?{adequacy}:{})};
|
|
171
|
+
if(item.status!=='planned')return enriched;
|
|
172
|
+
const flaky=current.some(row=>row.harness?.flaky);
|
|
173
|
+
if(status==='passed')return {...enriched,plannedEvidence:{status:item.status,reason:item.reason},
|
|
174
|
+
status:flaky?'flaky':completeFinite?'exhaustively-checked':'property-tested',
|
|
175
|
+
reason:`Recorded native checks completed for ${new Set(rows.map(row=>row.target+'\0'+row.root)).size} requested target(s); `+
|
|
176
|
+
(completeFinite?'every finite input was checked.':'this is scoped native execution evidence, not a universal model or search proof.')+
|
|
177
|
+
(flaky?' Its last run failed, then passed on a retry.':'')};
|
|
178
|
+
if(['failed','incomplete'].includes(status))return {...enriched,
|
|
179
|
+
plannedEvidence:{status:item.status,reason:item.reason},status:'incomplete',
|
|
180
|
+
reason:combinedFailure?'A combined native method failed; the specific included logical check is not identified, and no successful conformance result is established.':
|
|
181
|
+
status==='failed'?'A recorded native implementation check failed; no successful conformance result is established.':
|
|
182
|
+
'Native execution did not complete all selected checks; no successful conformance result is established.'};
|
|
183
|
+
return enriched;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export {nativeEvidenceText} from './explain.mjs';
|
package/native-examples.mjs
CHANGED
|
@@ -19,7 +19,7 @@ async function projectFiles(directory, prefix = '') {
|
|
|
19
19
|
export async function exportNativePayments(options, selected) {
|
|
20
20
|
const root = await safePath(process.cwd(), options.output || 'native_payments');
|
|
21
21
|
await mkdir(root, {recursive: true});
|
|
22
|
-
const law = await readFile(new URL('./examples/
|
|
22
|
+
const law = await readFile(new URL('./examples/rc1/native-payments.lawspec', import.meta.url), 'utf8');
|
|
23
23
|
const plans = [];
|
|
24
24
|
const results = [];
|
|
25
25
|
for (const target of selected) {
|
|
@@ -31,6 +31,8 @@ export async function exportNativePayments(options, selected) {
|
|
|
31
31
|
'laws/payments.lawspec': law,
|
|
32
32
|
};
|
|
33
33
|
const config = JSON.parse(files['lawspec.json']);
|
|
34
|
+
if(config.version!==2||config.languageProfile!=='1.0-rc.2')
|
|
35
|
+
throw new Error(`Bundled native payments configuration for ${target} must use version 2 and languageProfile 1.0-rc.2`);
|
|
34
36
|
config.machineBits = options.machineBits ?? 64;
|
|
35
37
|
files['lawspec.json'] = JSON.stringify(config, null, options.minify ? undefined : 2) + '\n';
|
|
36
38
|
const instructions = target === 'gleam' ? setup[target].replace(
|
|
@@ -42,6 +44,11 @@ This project checks application-owned payment types against the shared LawSpec
|
|
|
42
44
|
model. Money maps to Price, currency variants have application names, and the
|
|
43
45
|
archive preserves distinct present and absent payments.
|
|
44
46
|
|
|
47
|
+
The specification uses the canonical language profile. The version 2 project
|
|
48
|
+
configuration selects its verification layers explicitly. Most targets bind
|
|
49
|
+
application-owned domain types; C# and Clojure use the generated model data
|
|
50
|
+
and bind the application's functions and generators.
|
|
51
|
+
|
|
45
52
|
## Run
|
|
46
53
|
|
|
47
54
|
Install LawSpec and the native dependencies described below, then run:
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Generated from templates/npm/node-events-reporter.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
// Node's structured reporter stream preserves names without XML encoding.
|
|
3
|
+
// A nonce and final seal tie execution evidence to this invocation only.
|
|
4
|
+
export default async function* report(source) {
|
|
5
|
+
const run=process.env.LAWSPEC_NODE_RUN;
|
|
6
|
+
if(!run) throw new Error('LawSpec Node reporting requires an invocation identity');
|
|
7
|
+
const row=value=>JSON.stringify({version:1,run,...value})+'\n';
|
|
8
|
+
let count=0;
|
|
9
|
+
yield row({event:'start'});
|
|
10
|
+
for await(const event of source) {
|
|
11
|
+
if(!['test:pass','test:fail'].includes(event.type)||event.data?.details?.type==='suite') continue;
|
|
12
|
+
const data=event.data;
|
|
13
|
+
const skipped=[data.skip,data.todo].some(value=>value!==undefined&&value!==false);
|
|
14
|
+
const duration=data.details?.duration_ms;
|
|
15
|
+
const failure=data.details?.error?.message;
|
|
16
|
+
yield row({event:'test',name:data.name,classname:data.file??'',
|
|
17
|
+
status:skipped?'skipped':event.type==='test:pass'?'passed':'failed',
|
|
18
|
+
...(Number.isFinite(duration)&&duration>=0?{time:duration/1000}:{}),
|
|
19
|
+
...(event.type==='test:fail'?{failure:typeof failure==='string'?failure:'native test failed'}:{})});
|
|
20
|
+
count++;
|
|
21
|
+
}
|
|
22
|
+
yield row({event:'end',count});
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lawspec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "State the law once. Check it everywhere.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./index.d.ts",
|
|
20
20
|
"import": "./api.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./proof": {
|
|
23
|
+
"types": "./proof.d.ts",
|
|
24
|
+
"import": "./proof.mjs"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"types": "index.d.ts",
|
|
@@ -25,13 +29,16 @@
|
|
|
25
29
|
"*.mjs",
|
|
26
30
|
"*.json",
|
|
27
31
|
"index.d.ts",
|
|
32
|
+
"proof.d.ts",
|
|
28
33
|
"bin",
|
|
29
34
|
"core.wasm",
|
|
30
35
|
"core_jsffi.js",
|
|
31
36
|
"README.md",
|
|
32
37
|
"CHANGELOG.md",
|
|
33
38
|
"LICENSE",
|
|
39
|
+
"UNICODE-LICENSE.txt",
|
|
34
40
|
"starter.lawspec",
|
|
41
|
+
"starter-rc1.lawspec",
|
|
35
42
|
"examples"
|
|
36
43
|
],
|
|
37
44
|
"scripts": {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Generated from templates/npm/positional-fields.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
// Positions come from checked compiler metadata, never from guessing labels.
|
|
3
|
+
export function positionalFields(declaration) {
|
|
4
|
+
const structure = declaration?.structure, constructors = declaration?.constructors;
|
|
5
|
+
const positions = structure?.positions;
|
|
6
|
+
if (structure?.kind !== 'record' || !Array.isArray(positions) || positions.length < 2
|
|
7
|
+
|| constructors?.length !== 1 || new Set(positions).size !== positions.length) return undefined;
|
|
8
|
+
const fields = constructors[0].fields;
|
|
9
|
+
if (fields.length !== positions.length) return undefined;
|
|
10
|
+
const byName = new Map(fields.map(field => [field.name, field]));
|
|
11
|
+
if (byName.size !== positions.length || !positions.every(label => byName.has(label))) return undefined;
|
|
12
|
+
return positions.map(label => byName.get(label));
|
|
13
|
+
}
|
package/proof.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Generated from templates/npm/proof.d.ts by lawspec-dev generate. Do not edit.
|
|
2
|
+
import type {CheckRequest,Compiler,Location,Result} from './index.d.ts';
|
|
3
|
+
|
|
4
|
+
export interface Z3Options {
|
|
5
|
+
binary?: string;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
memoryMb?: number;
|
|
8
|
+
resourceLimit?: number;
|
|
9
|
+
seed?: number;
|
|
10
|
+
maxOutputBytes?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SolverEvidence {
|
|
13
|
+
owner: string;
|
|
14
|
+
declaration: string;
|
|
15
|
+
at: Location;
|
|
16
|
+
encoding: 'lawspec-smtlib-v1';
|
|
17
|
+
machineBits: 32 | 64;
|
|
18
|
+
programFingerprint: string;
|
|
19
|
+
taskFingerprint?: string;
|
|
20
|
+
status: 'proved' | 'incomplete' | 'unsupported';
|
|
21
|
+
outcome: 'unsat' | 'sat' | 'unknown' | 'timeout' | 'resource-limit' | 'out-of-memory' | 'unavailable' | 'failed' | 'unsupported';
|
|
22
|
+
reason: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
modelValidated?: false;
|
|
25
|
+
stdout?: string;
|
|
26
|
+
stderr?: string;
|
|
27
|
+
elapsedMs?: number;
|
|
28
|
+
exitCode?: number | null;
|
|
29
|
+
signal?: string | null;
|
|
30
|
+
runFingerprint?: string;
|
|
31
|
+
prover?: {name:'z3'; version:string; binary:string; binaryFingerprint:string; fingerprint:string; arguments:string[]};
|
|
32
|
+
configuration?: Required<Z3Options>;
|
|
33
|
+
}
|
|
34
|
+
export function proofTaskFingerprint(task: {encoding:string;programFingerprint:string;machineBits:number;owner:string;declaration:string;script:string}):string;
|
|
35
|
+
export function proveWithZ3(compiler:Compiler,request:CheckRequest,options?:Z3Options):Promise<Result & {solverEvidence:SolverEvidence[]}>;
|