lawspec 0.31.1 → 0.31.3
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 +89 -2
- package/README.md +85 -9
- package/api.mjs +14 -9
- package/authoring.mjs +899 -0
- package/beam-coverage.mjs +190 -65
- package/beam-doctor.mjs +343 -124
- package/bin/lawspec.mjs +1949 -661
- package/build.json +134 -128
- package/component-packages.mjs +662 -176
- package/component.d.ts +82 -20
- package/component.mjs +317 -94
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -5
- package/doctor.mjs +558 -299
- package/examples-command.mjs +44 -23
- package/failure-database.mjs +60 -17
- package/files.mjs +122 -62
- package/index.d.ts +585 -312
- package/input-files.mjs +90 -25
- package/launcher.mjs +72 -31
- package/learn/coverage.json +184 -112
- package/learn/curriculum.json +4 -1
- package/learn/vendor/fantomas/{LawSpec.Learn.Formatter.5arcua4vy0.wasm → LawSpec.Learn.Formatter.poiijdbsl9.wasm} +0 -0
- package/learn/vendor/fantomas/dotnet.js +3 -3
- package/learn/vendor/manifest.json +4 -8
- package/lsp.mjs +444 -133
- package/mcp.mjs +250 -0
- package/native-evidence.mjs +668 -182
- package/native-examples.mjs +56 -19
- package/native-host.mjs +136 -42
- package/native-parsers/clojure.LICENSE +121 -0
- package/native-parsers/clojure.wasm +0 -0
- package/native-parsers/csharp.LICENSE +21 -0
- package/native-parsers/csharp.wasm +0 -0
- package/native-parsers/elixir.LICENSE +176 -0
- package/native-parsers/elixir.wasm +0 -0
- package/native-parsers/erlang.LICENSE +201 -0
- package/native-parsers/erlang.wasm +0 -0
- package/native-parsers/fsharp.LICENSE +21 -0
- package/native-parsers/fsharp.wasm +0 -0
- package/native-parsers/gleam.LICENSE +202 -0
- package/native-parsers/gleam.wasm +0 -0
- package/native-parsers/go.LICENSE +21 -0
- package/native-parsers/go.wasm +0 -0
- package/native-parsers/groovy.LICENSE +21 -0
- package/native-parsers/groovy.wasm +0 -0
- package/native-parsers/haskell.LICENSE +21 -0
- package/native-parsers/haskell.wasm +0 -0
- package/native-parsers/java.LICENSE +21 -0
- package/native-parsers/java.wasm +0 -0
- package/native-parsers/javascript.LICENSE +21 -0
- package/native-parsers/javascript.wasm +0 -0
- package/native-parsers/kotlin.LICENSE +9 -0
- package/native-parsers/kotlin.wasm +0 -0
- package/native-parsers/lock.json +114 -0
- package/native-parsers/prolog.LICENSE +21 -0
- package/native-parsers/prolog.wasm +0 -0
- package/native-parsers/python.LICENSE +21 -0
- package/native-parsers/python.wasm +0 -0
- package/native-parsers/rust.LICENSE +21 -0
- package/native-parsers/rust.wasm +0 -0
- package/native-parsers/scala.LICENSE +21 -0
- package/native-parsers/scala.wasm +0 -0
- package/native-parsers/swift.LICENSE +21 -0
- package/native-parsers/swift.wasm +0 -0
- package/native-parsers/typescript.LICENSE +21 -0
- package/native-parsers/typescript.wasm +0 -0
- package/node-events-reporter.mjs +41 -17
- package/package.json +4 -3
- package/project.mjs +338 -0
- package/proof.d.ts +93 -19
- package/proof.mjs +1538 -447
- package/read-only-hpack.mjs +6 -5
- package/scala-build-state.mjs +131 -41
- package/scala-coverage.mjs +57 -34
- package/scalars.mjs +23 -8
- package/templates.mjs +566 -617
- package/test-command.mjs +1671 -521
- package/learn/vendor/fantomas/LawSpec.Learn.Formatter.u1ne3a6xd2.wasm +0 -0
package/input-files.mjs
CHANGED
|
@@ -2,46 +2,111 @@
|
|
|
2
2
|
// Native implementations may depend on declared files outside their target
|
|
3
3
|
// directory. Component descriptions and native result keys share this walker.
|
|
4
4
|
import {createHash} from 'node:crypto';
|
|
5
|
-
import {lstat,readFile,readdir} from 'node:fs/promises';
|
|
5
|
+
import {lstat, readFile, readdir} from 'node:fs/promises';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
|
|
8
|
-
export const buildDirectories = new Set([
|
|
9
|
-
'.
|
|
10
|
-
'.
|
|
8
|
+
export const buildDirectories = new Set([
|
|
9
|
+
'.git',
|
|
10
|
+
'.lawspec',
|
|
11
|
+
'node_modules',
|
|
12
|
+
'dist',
|
|
13
|
+
'build',
|
|
14
|
+
'target',
|
|
15
|
+
'out',
|
|
16
|
+
'.gradle',
|
|
17
|
+
'bin',
|
|
18
|
+
'obj',
|
|
19
|
+
'TestResults',
|
|
20
|
+
'.stack-work',
|
|
21
|
+
'_build',
|
|
22
|
+
'deps',
|
|
23
|
+
'.elixir_ls',
|
|
24
|
+
'__pycache__',
|
|
25
|
+
'.hypothesis',
|
|
26
|
+
'.pytest_cache',
|
|
27
|
+
'.venv',
|
|
28
|
+
'venv',
|
|
29
|
+
'.idea',
|
|
30
|
+
'.vscode',
|
|
31
|
+
'.scala-build',
|
|
32
|
+
'.bsp',
|
|
33
|
+
'.bloop',
|
|
34
|
+
'.metals',
|
|
35
|
+
'.build',
|
|
36
|
+
'.swiftpm',
|
|
37
|
+
'.cpcache',
|
|
38
|
+
]);
|
|
11
39
|
|
|
12
40
|
// These outputs belong to the generated crypto builder; its sources and
|
|
13
41
|
// other priv/ assets still contribute to the native implementation identity.
|
|
14
|
-
export const cryptoBuildOutput = file =>
|
|
42
|
+
export const cryptoBuildOutput = file =>
|
|
43
|
+
/(?:^|\/)priv\/lawspec_crypto_native\.(?:so|dll)(?:\.build|\.\d+\.tmp)?$/.test(
|
|
44
|
+
file,
|
|
45
|
+
);
|
|
15
46
|
|
|
16
47
|
// Execution reports are observations, independent of implementation inputs.
|
|
17
48
|
// ref:DEC-completed-run-attestation
|
|
18
|
-
export function isAttestation(content)
|
|
19
|
-
|
|
49
|
+
export function isAttestation(content)
|
|
50
|
+
{
|
|
51
|
+
try
|
|
52
|
+
{
|
|
20
53
|
const value = JSON.parse(content);
|
|
21
|
-
return
|
|
22
|
-
|
|
54
|
+
return (
|
|
55
|
+
value !== null &&
|
|
56
|
+
typeof value === 'object' &&
|
|
57
|
+
value.format === 'environment-attestation'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
catch
|
|
61
|
+
{
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
23
64
|
}
|
|
24
65
|
|
|
25
|
-
export async function fingerprintInputs(
|
|
26
|
-
|
|
66
|
+
export async function fingerprintInputs(
|
|
67
|
+
root,
|
|
68
|
+
inputs,
|
|
69
|
+
{generated = new Set()} = {},
|
|
70
|
+
)
|
|
71
|
+
{
|
|
72
|
+
if (
|
|
73
|
+
!Array.isArray(inputs) ||
|
|
74
|
+
inputs.some(entry => typeof entry !== 'string' || !entry)
|
|
75
|
+
)
|
|
27
76
|
throw new Error('Component inputs must be an array of nonempty paths');
|
|
28
77
|
const rows = new Map();
|
|
29
|
-
async function visit(file,relative)
|
|
78
|
+
async function visit(file, relative)
|
|
79
|
+
{
|
|
30
80
|
const info = await lstat(file);
|
|
31
|
-
if(info.isSymbolicLink())
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
81
|
+
if (info.isSymbolicLink())
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Symbolic links are not supported in component inputs: ${relative}`,
|
|
84
|
+
);
|
|
85
|
+
if (info.isDirectory())
|
|
86
|
+
{
|
|
87
|
+
for (const entry of (await readdir(file)).sort())
|
|
88
|
+
{
|
|
89
|
+
if (buildDirectories.has(entry)) continue;
|
|
90
|
+
const next = relative + '/' + entry;
|
|
91
|
+
if (next.endsWith('testdata/rapid')) continue;
|
|
92
|
+
await visit(path.join(file, entry), next);
|
|
38
93
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
94
|
+
}
|
|
95
|
+
else if (
|
|
96
|
+
info.isFile() &&
|
|
97
|
+
!generated.has(path.resolve(file)) &&
|
|
98
|
+
!cryptoBuildOutput(relative)
|
|
99
|
+
)
|
|
100
|
+
{
|
|
101
|
+
const content = await readFile(file);
|
|
102
|
+
if (relative.endsWith('.json') && isAttestation(content.toString('utf8')))
|
|
103
|
+
return;
|
|
104
|
+
rows.set(relative, createHash('sha256').update(content).digest('hex'));
|
|
43
105
|
}
|
|
44
106
|
}
|
|
45
|
-
for(const entry of inputs)
|
|
46
|
-
|
|
107
|
+
for (const entry of inputs)
|
|
108
|
+
await visit(path.resolve(root, entry), entry.split(path.sep).join('/'));
|
|
109
|
+
return [...rows].sort(([left], [right]) =>
|
|
110
|
+
left < right ? -1 : left > right ? 1 : 0,
|
|
111
|
+
);
|
|
47
112
|
}
|
package/launcher.mjs
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
// Generated from templates/npm/launcher.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import path from
|
|
2
|
+
import {mkdir, readFile} from 'node:fs/promises';
|
|
3
|
+
import {createHash} from 'node:crypto';
|
|
4
|
+
import path from 'node:path';
|
|
5
5
|
let compiled;
|
|
6
6
|
|
|
7
7
|
// GHC's JSFFI reactor reads these WASI arguments during initialization. Bound
|
|
8
8
|
// the heap below wasm32's address ceiling and compact the oldest generation
|
|
9
9
|
// in place instead of reserving a second copy near that ceiling.
|
|
10
10
|
// -with-rtsopts has no effect on this -no-hs-main reactor build.
|
|
11
|
-
const coreArguments = [
|
|
11
|
+
const coreArguments = ['lawspec', '+RTS', '-M3584m', '-c', '-RTS'];
|
|
12
12
|
|
|
13
13
|
// Instantiate the compiler core with a platform's WASI preview1 imports and
|
|
14
14
|
// serialize calls: the core handles one JSON request at a time.
|
|
15
|
-
async function instantiateCore(module, wasiImports, initialize)
|
|
15
|
+
async function instantiateCore(module, wasiImports, initialize)
|
|
16
|
+
{
|
|
16
17
|
const exports = {};
|
|
17
|
-
const jsffi = (await import(
|
|
18
|
+
const jsffi = (await import('./core_jsffi.js')).default;
|
|
18
19
|
const instance = await WebAssembly.instantiate(module, {
|
|
19
20
|
wasi_snapshot_preview1: wasiImports,
|
|
20
21
|
ghc_wasm_jsffi: jsffi(exports),
|
|
@@ -22,48 +23,88 @@ async function instantiateCore(module, wasiImports, initialize) {
|
|
|
22
23
|
Object.assign(exports, instance.exports);
|
|
23
24
|
initialize(instance);
|
|
24
25
|
let pending = Promise.resolve();
|
|
25
|
-
return
|
|
26
|
+
return input =>
|
|
27
|
+
{
|
|
26
28
|
const result = pending.then(async () =>
|
|
27
29
|
JSON.parse(await instance.exports.lawspec_call(JSON.stringify(input))),
|
|
28
30
|
);
|
|
29
31
|
// The queue needs completion only, not the previous generated project DTO.
|
|
30
|
-
pending = result.then(
|
|
32
|
+
pending = result.then(
|
|
33
|
+
() =>
|
|
34
|
+
{},
|
|
35
|
+
() =>
|
|
36
|
+
{},
|
|
37
|
+
);
|
|
31
38
|
return result;
|
|
32
39
|
};
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
export async function loadCore()
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
export async function loadCore()
|
|
43
|
+
{
|
|
44
|
+
const {WASI} = await import('node:wasi');
|
|
45
|
+
if (Number(process.versions.node.split('.')[0]) < 22)
|
|
46
|
+
throw new Error('LawSpec requires Node 22+');
|
|
47
|
+
compiled ??= readFile(new URL('./core.wasm', import.meta.url)).then(
|
|
48
|
+
async bytes => ({
|
|
49
|
+
module: await WebAssembly.compile(bytes),
|
|
50
|
+
build: createHash('sha256').update(bytes).digest('hex'),
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
const {module, build} = await compiled;
|
|
44
54
|
let activeRoot, invoke;
|
|
45
|
-
let pending=Promise.resolve();
|
|
46
|
-
const request=async input=>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
let pending = Promise.resolve();
|
|
56
|
+
const request = async input =>
|
|
57
|
+
{
|
|
58
|
+
const validCache = typeof input.cacheDirectory === 'string';
|
|
59
|
+
let root =
|
|
60
|
+
validCache && input.cacheDirectory
|
|
61
|
+
? path.resolve(input.cacheDirectory)
|
|
62
|
+
: null;
|
|
63
|
+
if (root)
|
|
64
|
+
try
|
|
65
|
+
{
|
|
66
|
+
await mkdir(root, {recursive: true});
|
|
67
|
+
}
|
|
68
|
+
catch
|
|
69
|
+
{
|
|
70
|
+
root = null;
|
|
71
|
+
}
|
|
50
72
|
// The requested host directory is an explicit mount, rather than an
|
|
51
73
|
// absolute WASI path accidentally interpreted below cwd. The binary
|
|
52
74
|
// identity separates persisted memos even within one package version.
|
|
53
|
-
if(!invoke||root!==activeRoot)
|
|
75
|
+
if (!invoke || root !== activeRoot)
|
|
76
|
+
{
|
|
54
77
|
const wasi = new WASI({
|
|
55
|
-
version:
|
|
56
|
-
|
|
78
|
+
version: 'preview1',
|
|
79
|
+
args: coreArguments,
|
|
80
|
+
env: {PWD: '/'},
|
|
81
|
+
preopens: {
|
|
82
|
+
'/': process.cwd(),
|
|
83
|
+
...(root ? {'/lawspec-cache': root} : {}),
|
|
84
|
+
},
|
|
57
85
|
});
|
|
58
|
-
invoke=await instantiateCore(module,wasi.wasiImport,instance=>
|
|
59
|
-
|
|
86
|
+
invoke = await instantiateCore(module, wasi.wasiImport, instance =>
|
|
87
|
+
wasi.initialize(instance),
|
|
88
|
+
);
|
|
89
|
+
activeRoot = root;
|
|
60
90
|
}
|
|
61
|
-
return invoke({
|
|
91
|
+
return invoke({
|
|
92
|
+
...input,
|
|
93
|
+
...(validCache
|
|
94
|
+
? {cacheDirectory: root ? `/lawspec-cache/${build}` : undefined}
|
|
95
|
+
: {}),
|
|
96
|
+
});
|
|
62
97
|
};
|
|
63
98
|
// Cache-root changes are serialized with calls on the active instance.
|
|
64
|
-
return input=>
|
|
65
|
-
|
|
66
|
-
pending
|
|
99
|
+
return input =>
|
|
100
|
+
{
|
|
101
|
+
const result = pending.then(() => request(input));
|
|
102
|
+
pending = result.then(
|
|
103
|
+
() =>
|
|
104
|
+
{},
|
|
105
|
+
() =>
|
|
106
|
+
{},
|
|
107
|
+
);
|
|
67
108
|
return result;
|
|
68
109
|
};
|
|
69
110
|
}
|