lawspec 0.14.0 → 0.15.1

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/api.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // Generated from LawSpec.Gen. Do not edit.
1
+ // Generated by lawspec-dev generate. Do not edit.
2
2
  import {loadCore} from './launcher.mjs';
3
3
 
4
4
  export async function createCompiler() {
package/bin/lawspec.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ // Generated from templates/npm/bin/lawspec.mjs by lawspec-dev generate. Do not edit.
2
3
  import { readFile, mkdir, readdir, stat } from "node:fs/promises";
3
4
  import path from "node:path";
4
5
  import { createCompiler } from "../api.mjs";
@@ -13,6 +14,7 @@ import {
13
14
  atomicWrite,
14
15
  safePath,
15
16
  } from "../files.mjs";
17
+ const VERSION = "0.15.1";
16
18
  const args = process.argv.slice(2);
17
19
  const verb = args.shift();
18
20
  const options = {};
@@ -242,16 +244,16 @@ async function main() {
242
244
  }
243
245
  if (!verb || ["help", "--help", "-h"].includes(verb)) {
244
246
  output(
245
- "LawSpec 0.14.0\nUsage: lawspec init --target <language> [--project <directory>] [--minify]\n lawspec check | doctor | explain <unit>::<law> | generate\n lawspec package [--project <package directory>]\n lawspec examples [--example payments] [--target <language>] [--output <directory>]\nOptions: --config <path>, --target <language>, --machine-bits <32|64>, --json\nGeneration: --dry-run, --check, --minify\nTargets: " +
247
+ "LawSpec " + VERSION + "\nUsage: lawspec init --target <language> [--project <directory>] [--minify]\n lawspec check | doctor | explain <unit>::<law> | generate\n lawspec evidence [<unit> | <unit>::<declaration>]\n lawspec package [--project <package directory>]\n lawspec examples [--example payments] [--target <language>] [--output <directory>]\nOptions: --config <path>, --target <language>, --machine-bits <32|64>, --json\nGeneration: --dry-run, --check, --minify\nTargets: " +
246
248
  targets.join(", "),
247
249
  );
248
250
  return;
249
251
  }
250
252
  if (verb === "--version") {
251
- output("0.14.0");
253
+ output(VERSION);
252
254
  return;
253
255
  }
254
- if (positional.length > (verb === "explain" ? 1 : 0))
256
+ if (positional.length > (["explain", "evidence"].includes(verb) ? 1 : 0))
255
257
  throw new Error(`Unexpected argument: ${positional.join(" ")}`);
256
258
  if (verb === "examples") {
257
259
  if (
@@ -288,7 +290,7 @@ async function main() {
288
290
  throw new Error("--minify applies to init, generate and examples");
289
291
  if (verb === "init") return init();
290
292
  if (verb === "package") return packageCommand();
291
- if (!["check", "doctor", "explain", "generate"].includes(verb))
293
+ if (!["check", "doctor", "evidence", "explain", "generate"].includes(verb))
292
294
  throw new Error(`Unknown command: ${verb}`);
293
295
  const config = JSON.parse(await readFile(configFile, "utf8"));
294
296
  if (
@@ -332,12 +334,20 @@ async function main() {
332
334
  machineBits: options.machineBits ?? config.machineBits ?? 64,
333
335
  };
334
336
  const compiler = await createCompiler();
335
- // Proved obligations need no runtime check; the rest are enforced at runtime.
337
+ // Each obligation reports how it is discharged, strongest first.
338
+ const statuses = [
339
+ ["proved", "PROVED"],
340
+ ["exhaustively-checked", "EXHAUSTIVELY CHECKED"],
341
+ ["property-tested", "PROPERTY TESTED"],
342
+ ["runtime-checked", "RUNTIME CHECKED"],
343
+ ["assumed", "ASSUMED / EXTERNAL"],
344
+ ];
336
345
  const evidenceSummary = (evidence) => {
337
346
  if (!evidence.length) return "";
338
347
  const count = (status) => evidence.filter((item) => item.status === status).length;
339
- return ` Evidence: ${count("proved")} proved, ${count("runtime-checked")} runtime-checked obligation(s).`;
348
+ return ` Evidence: ${statuses.map(([status, label]) => `${count(status)} ${label.toLowerCase()}`).join(", ")}.`;
340
349
  };
350
+ const obligationName = (item) => item.declaration.replace("::law::", "::");
341
351
  if (verb === "check") {
342
352
  const result = diagnostics(await compiler.check(input));
343
353
  for (const target of selected) {
@@ -351,6 +361,36 @@ async function main() {
351
361
  );
352
362
  return;
353
363
  }
364
+ if (verb === "evidence") {
365
+ const result = diagnostics(await compiler.check(input));
366
+ let evidence = result.evidence;
367
+ // Native bindings are configured per target; their obligations are added.
368
+ for (const target of selected) {
369
+ if (target.nativeBindings === undefined) continue;
370
+ const bound = diagnostics(await compiler.check({...input, nativeBindings: target.nativeBindings}));
371
+ evidence = evidence.concat(bound.evidence
372
+ .filter((item) => ["binding", "codec", "generator", "native-function"].includes(item.stage))
373
+ .map((item) => ({...item, target: target.language})));
374
+ }
375
+ evidence = evidence.filter((item) => !positional[0] ||
376
+ obligationName(item) === positional[0] || item.owner === positional[0]);
377
+ if (positional[0] && !evidence.length) throw new Error("No matching obligation");
378
+ output(
379
+ options.json
380
+ ? evidence
381
+ : statuses
382
+ .map(([status, label]) => {
383
+ const items = evidence.filter((item) => item.status === status);
384
+ if (!items.length) return null;
385
+ return `${label} (${items.length})\n` + items.map((item) =>
386
+ ` ${item.stage} ${obligationName(item)}${item.target ? ` [${item.target}]` : ""}` +
387
+ (item.claim ? `: ${item.claim.text}` : "") + `\n ${item.reason}`).join("\n");
388
+ })
389
+ .filter((section) => section !== null)
390
+ .join("\n\n"),
391
+ );
392
+ return;
393
+ }
354
394
  if (verb === "explain") {
355
395
  const result = diagnostics(await compiler.expand(input));
356
396
  const indices = result.laws
package/build.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "version": 1,
3
3
  "compilerSources": [
4
+ "dev/Gen/Embed.hs",
4
5
  "lawspec.cabal",
5
6
  "package.yaml",
6
7
  "runtime/LawSpecCodecs.hs",
@@ -57,13 +58,13 @@
57
58
  "src/LawSpec/Data.hs",
58
59
  "src/LawSpec/DataNames.hs",
59
60
  "src/LawSpec/DefinitionTotality.hs",
61
+ "src/LawSpec/Discharge.hs",
60
62
  "src/LawSpec/Domain.hs",
61
63
  "src/LawSpec/DomainModel.hs",
62
64
  "src/LawSpec/Elaboration.hs",
63
65
  "src/LawSpec/Emit.hs",
64
66
  "src/LawSpec/Eval.hs",
65
67
  "src/LawSpec/Frontend.hs",
66
- "src/LawSpec/Gen.hs",
67
68
  "src/LawSpec/GoData.hs",
68
69
  "src/LawSpec/GoDefinitions.hs",
69
70
  "src/LawSpec/GoExpr.hs",
@@ -126,15 +127,15 @@
126
127
  "src/LawSpec/WebTypes.hs",
127
128
  "stack.yaml",
128
129
  "stack.yaml.lock",
129
- "tools/embed-runtimes.py",
130
130
  "wasm/app/Exports.hs",
131
131
  "wasm/cabal.project",
132
132
  "wasm/cabal.project.freeze",
133
133
  "wasm/lawspec-wasm.cabal"
134
134
  ],
135
135
  "digests": {
136
- "lawspec.cabal": "1d976756374bc2916c3247e8f16677d711bdfbd9312cb4ba86da468028bc0709",
137
- "package.yaml": "ea0daa1aadb9271b81868507fdaee32380ccb6cc80f9d8ebe9e5ddff0a0e459d",
136
+ "dev/Gen/Embed.hs": "fd79909790f2026ff40a6de58897a934141e5eba1ca31b2d8cd3b128335def55",
137
+ "lawspec.cabal": "ca830fac0e43b0d4f879a8c283e34cf4c4352245a4808e974e82c60762f32217",
138
+ "package.yaml": "8566732125bcaab57ddecbe06e12e073a327df60fb71e97a16201586b7333a6b",
138
139
  "runtime/LawSpecCodecs.hs": "90cb1ed15d7ab664a17a054580c849408d77cfd2b2adcb4a3228b05132caeaca",
139
140
  "runtime/LawSpecDataStrategies.hs": "cbe9f1946228db1076c19cd3158e8798fe32766cfdbea3f66b63d22d3d217508",
140
141
  "runtime/LawSpecDataStrategies.java": "e3416efe8a0d7b1276cb4d1a8105fd01b1f5f3f02a803bf55d955d9e3ec39095",
@@ -158,9 +159,9 @@
158
159
  "runtime/lawspec_schema.mjs": "60eb4204461eaa2c207fc7c3394014e2a814e4383b7045c065b4dae7c7a202c2",
159
160
  "runtime/lawspec_schema.py": "b6967ef1a33fe6a1a180d5573ec37cd8bb2079c06e961ac2eeb05f23cffcdd07",
160
161
  "runtime/lawspec_strategies.rs": "cac9ca301d4614fff9acfe61e7cc5678fabc044edadfa89ec11599b6780dc5f3",
161
- "runtime/rust/Cargo.lock": "ce3773a6636b3c40c1ec23dd45a267dc98ac2c68fa605d2b05f4f6abf6996fae",
162
- "runtime/rust/Cargo.toml": "b52ba13a9b8d428b382c97cdb04659b8da3f83d4c54da4b5286245f547bc9108",
163
- "src/LawSpec/Api.hs": "b629bbf854f9213629eeda404548075b56657ee1337ad37d67c54751ed1fc5dc",
162
+ "runtime/rust/Cargo.lock": "0b1ebb624714087ee18ff2faf8b8299e6758e769fda82ff2861019c331c234ca",
163
+ "runtime/rust/Cargo.toml": "27b9680d77513379a8d9aa200adfe22437fcdab8baf8659d2cf6cfb6fd3c0215",
164
+ "src/LawSpec/Api.hs": "b7315b30890e3e38382c7e4d60afdfc6c7c3647f056636c230a91c16047f9944",
164
165
  "src/LawSpec/Backend.hs": "03c3b0cd62467ca677c88d29d7b12b2ab505cc0076d93d1f48fbddb0e9bcf133",
165
166
  "src/LawSpec/Capabilities.hs": "e43d4fc3a4481fbb8aa3ff1c3f41f7e7fca5db01bfe256a30162a45d75a00c1c",
166
167
  "src/LawSpec/Code/Doc.hs": "9e3b70f85deb1dcbce385af1d0cd4bea2dfa8a2d806d54745d4bb437406673e5",
@@ -171,7 +172,7 @@
171
172
  "src/LawSpec/Core/DefinitionContracts.hs": "b7f60f038b231187ecf898e585ae1a8fb1fc113bb55bad6d1bb2660350fd969e",
172
173
  "src/LawSpec/Core/Definitions.hs": "52f024fca59661142f70f9aa7dd2cbdb4892e5d3b1ca8079c878c5a1ba667112",
173
174
  "src/LawSpec/Core/Eval.hs": "e1ad8af5b240dd99c3b1126408d2be5f9b42b86ca6189ecd3868680a5119d931",
174
- "src/LawSpec/Core/Evidence.hs": "460af282299258c87ddba58b55ad09290d7d89e6e7d43a02f5470fbd5b7974a3",
175
+ "src/LawSpec/Core/Evidence.hs": "84976ccfc84f8f31c8391008cd767b75753488f9e7872045ab0c997f6f1d8613",
175
176
  "src/LawSpec/Core/Expression.hs": "84985f4f685126253d3af7b6b605d80d28fc9aa115bd5e2946f989eeb1355224",
176
177
  "src/LawSpec/Core/Payload.hs": "df6a2b250c27c12bb6ac16b84847c52546081d066a3dca7575ed0d743cc13d50",
177
178
  "src/LawSpec/Core/PayloadPlan.hs": "f2a7d2dc58c6a0f79707bdc24773bd3aad3a3b8eea2735a8284b2a9f3a4af4a8",
@@ -179,7 +180,7 @@
179
180
  "src/LawSpec/Core/Schema.hs": "9a4ec3967803913e6ff43d33e00a1b4b3b8ec0c79dbdbd80ae98101c85bf430f",
180
181
  "src/LawSpec/Core/Semantics.hs": "a9d019433e3b9731f8cd0f65ec0ccc53179824bea58247b72df26760b878c2b6",
181
182
  "src/LawSpec/Core/Total.hs": "95d2b19ba7fbfd033295504d31f786815384003b3b4d370776860b423cf079dd",
182
- "src/LawSpec/Core/Totality.hs": "a96fc3b9e8be5d18997065b9d09c0f8a2ede4d6ed2974b3bf355967986b0e459",
183
+ "src/LawSpec/Core/Totality.hs": "3bd81ebdd2020d8b17809904a42a2d5f0a12075d8b8b3fa3b1907bdc7024bd46",
183
184
  "src/LawSpec/Core/Types.hs": "48ed1d197ce7089737895b7279f93437301fcfacff8b3a8dd98ecd7f1cb32b37",
184
185
  "src/LawSpec/Core/Validate.hs": "0f045241215e068081d6cd7cf451f0166671bae5fffafda71a2e2320e8014c27",
185
186
  "src/LawSpec/Core/Value.hs": "f2b2e4d82491e184d60b1217922b25c57a06cbbaecb2cb6f31174af50268fbc9",
@@ -189,13 +190,13 @@
189
190
  "src/LawSpec/Data.hs": "9dbeafa120276b114dad790ec69e617f7ad0c632e3c718962f2f7faf8ca327f4",
190
191
  "src/LawSpec/DataNames.hs": "f10da6137dade8ac369fabb9231d87bf0d801655eb6756e816369102d147b4c0",
191
192
  "src/LawSpec/DefinitionTotality.hs": "7671b7efb0cac5d796b074d48b2c10940e5bd0b5df082b926aee694903285efa",
193
+ "src/LawSpec/Discharge.hs": "4b0a5692b31be7620239a4ac5175a0ef2950fc223f708b34895a7cde17a98e95",
192
194
  "src/LawSpec/Domain.hs": "222d15f0012ae630802238a6d7e1ee78d1e718b599f5ebb5a1ddc4e8d29d68c3",
193
195
  "src/LawSpec/DomainModel.hs": "3be67117c44e66a39d42d7ce094c2940c48ea1541017b64027afa6ea4b77092f",
194
196
  "src/LawSpec/Elaboration.hs": "86e3ef77a977cb1b55985e2939648135acd0c2c015afe76e34e09615d555f53e",
195
197
  "src/LawSpec/Emit.hs": "9f34f5765915a2a12a66a6dca647ddaef9289372956802c6d99cf0cfec447c7a",
196
198
  "src/LawSpec/Eval.hs": "b0872ba8a6974463b32776653c2939826a6be87318c15641401f913f6b139de2",
197
199
  "src/LawSpec/Frontend.hs": "fbf091b9c96f5b5361dbf4f65819634c0f8526ff98550d97c434c0d47af7839e",
198
- "src/LawSpec/Gen.hs": "dcf5e49fca5671af7e7f878768746e1222e5c91d5eb85f032bc96b49866e368d",
199
200
  "src/LawSpec/GoData.hs": "1b1882906ba676cdd37c744b91d271c7d25279b137f0c5ba5863f4423729bc86",
200
201
  "src/LawSpec/GoDefinitions.hs": "3cb55c22f28443fff73e73c59780bf1977ab9260b8d66c7f19d1b94b40d1397e",
201
202
  "src/LawSpec/GoExpr.hs": "da3a7cc0e3d2906886dc44f6b990e72098bb351558bbb31ee335da7382fac58a",
@@ -233,14 +234,14 @@
233
234
  "src/LawSpec/PortableGenerator.hs": "69d457e39f539c77fc7a4c08205e75352bbecd9dfdff031a283a39bf44b22d49",
234
235
  "src/LawSpec/PortableTestHelpers.hs": "8ba4d87183c8c11f6ef1ce21c170127335797154f29fb97ad3429f032a167fd3",
235
236
  "src/LawSpec/Prelude.hs": "b1e155c12f58e7c346551a0c65c5d5af76d045b3f1625977ca2a5d1c97cb8c46",
236
- "src/LawSpec/Public.hs": "ca7f3edd3e5d623ecb1aecb2386fdcf4b1e334cf7bd7770b6a14f5690d8f5ed5",
237
+ "src/LawSpec/Public.hs": "ac46d7b8c5130faf922f10b402e035901d851bb8a229ea823ce0afaaf3011028",
237
238
  "src/LawSpec/PythonData.hs": "07e9bb54a1515f3f4744b7b9bb43633cbdbf07b3f9e35efef511753f97e216d5",
238
239
  "src/LawSpec/PythonDefinitions.hs": "30f3d2d71a378e194d62261e0fd1baade5a49ac8b5eaac97578ca015a48ce8e4",
239
240
  "src/LawSpec/PythonExpr.hs": "23d7d24b5fb4efff9cb63d38c02a93d95744ec79b4565daf1412088fc7c4ba59",
240
241
  "src/LawSpec/PythonNativeBinding.hs": "4e35ff8781062d0f614e45ea45f98038c8d609ab78bd671cb0a239eaa9db1690",
241
242
  "src/LawSpec/PythonTypes.hs": "61c7271279e33b59f5b70cdee6363e0c0efb53a2f58c3256950dbec522ad7f10",
242
243
  "src/LawSpec/Refinement.hs": "3bbdc090f9ebce60d99254dbe93dec6e11bd838df8537df828fd9c768c79d126",
243
- "src/LawSpec/RuntimeSources.hs": "22c9f7e4f977b4f548363f494c9d66edeb4d3247c7a1e7e7cad470b1059019be",
244
+ "src/LawSpec/RuntimeSources.hs": "a880283705bac3840b3039322f70923829298d8f05754c7fa51a4a3875baba57",
244
245
  "src/LawSpec/RustData.hs": "0d28ff5b35c5085c55604ef1eea366dec737b29d3352ef1576bb82c7421b615c",
245
246
  "src/LawSpec/RustDefinitions.hs": "8c289e2779d7ed623f3578f20974dd9e2016c67734ee1447ed7f4b7c22caedf9",
246
247
  "src/LawSpec/RustEmit.hs": "d08797ca26180b6ed2884c0576ec7b0265cadc2236a95d8754cfea89bb2940e0",
@@ -250,7 +251,7 @@
250
251
  "src/LawSpec/Scaffold.hs": "2cdaeaa0708803e6abf3b8e9062dfc2fe31e2d3a6df3b252a17b1ad91eb5d8f2",
251
252
  "src/LawSpec/Scalar.hs": "52e61fec81a337bb5b35e9e6f501446cf0b18bffa6c6af2ddc5aeac2d6e07131",
252
253
  "src/LawSpec/SpecializeDefinitions.hs": "08f2fe674a5e00d1be396d9edab0dd2c948b7beb12fa99f2a6aba00cbdf01e33",
253
- "src/LawSpec/Testing.hs": "7b0a2e58bcef24365883b479b6a5af720cc2ac4c217ae23bb771c2621d82aec3",
254
+ "src/LawSpec/Testing.hs": "9626e43e4c02a0c88435ffe2d629110a99b1b91e8d0bcaa98b468509da69d438",
254
255
  "src/LawSpec/WebData.hs": "919af27be12f63f17762e0c052341ab82dcee5d45951a4fd9c66abead98d1ee0",
255
256
  "src/LawSpec/WebDefinitions.hs": "d654df765e4bafcb1acdd35058f8a510c2cd81920153c0a75ff1e7e1137c96e5",
256
257
  "src/LawSpec/WebExpr.hs": "0389dcd5cf7479dd23ef034b1012de6ebd70bf1dc9e3d90981dfb0ba2702596f",
@@ -258,14 +259,13 @@
258
259
  "src/LawSpec/WebTypes.hs": "f74c6e346e3e3922223f8738a8f85e2b036e8f0469d9d7f027400e2f60f6957e",
259
260
  "stack.yaml": "20ccf4d599e355e60b7aa4f814a7cd4299fe2048616cc2e6dbdc22a7bd8cec73",
260
261
  "stack.yaml.lock": "ae222b9c81af920c56e50fa4596fa57786e7fa5a7b461390362b2b2ff63818c7",
261
- "tools/embed-runtimes.py": "91a05197fc542a65387f3ccf4614a4817c850031eb4b84196c621b8baf344865",
262
262
  "wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
263
263
  "wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
264
264
  "wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
265
- "wasm/lawspec-wasm.cabal": "8121d57d0724e191598f25cfea986a18bc298c2fab38febb38fc721c7a9660f8",
266
- "npm/core.wasm": "19d1ed55f899cb73a926d5982746c4ffd803f8cfe60ee83fbc86d400896edb2c",
265
+ "wasm/lawspec-wasm.cabal": "251c6b297505fdcda2520c05ea01eec1e1bd1674babde621f3be777808a65afe",
266
+ "npm/core.wasm": "fd43be00cd2681e53c2422ff03a04eb1f0e351e4b091bf865c3be16f6f21dccd",
267
267
  "npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
268
- "npm/api.mjs": "e93251db289ff0609abaff78ad67f0a9af82508c1141c6a999604f67c56b6e7d",
269
- "npm/index.d.ts": "4847f99a55b5948b5f5cc1ed22cd404c3df625472148e0d57d2d9c3406ce6afd"
268
+ "npm/api.mjs": "19e1624f91258c1397f3212faf65b407c62671b0fc5b118520e6a91f7ad7c6ba",
269
+ "npm/index.d.ts": "2215087cc6628a2ddbdd573210c4f9021cffeb00c142d4f3ae1314fd59a397f6"
270
270
  }
271
271
  }
package/core.wasm CHANGED
Binary file
package/doctor.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ // Generated from templates/npm/doctor.mjs by lawspec-dev generate. Do not edit.
1
2
  import { execFile } from "node:child_process";
2
3
  import { promisify } from "node:util";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ // Generated from templates/npm/examples-command.mjs by lawspec-dev generate. Do not edit.
1
2
  import { readFile, readdir, mkdir } from "node:fs/promises";
2
3
  import path from "node:path";
3
4
  import { createCompiler } from "./api.mjs";
package/files.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ // Generated from templates/npm/files.mjs by lawspec-dev generate. Do not edit.
1
2
  import {
2
3
  readFile,
3
4
  mkdir,
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Generated from LawSpec.Gen. Do not edit.
1
+ // Generated by lawspec-dev generate. Do not edit.
2
2
  export type Target =
3
3
  'java' |
4
4
  'python' |
@@ -212,6 +212,22 @@ export interface NativeBindings {
212
212
  goImports?: NativeGoImport[];
213
213
  }
214
214
 
215
+ export type DischargeStatus =
216
+ 'proved' |
217
+ 'exhaustively-checked' |
218
+ 'property-tested' |
219
+ 'runtime-checked' |
220
+ 'assumed';
221
+
222
+ export interface ObligationEvidence {
223
+ owner: string;
224
+ declaration: string;
225
+ stage: string;
226
+ status: DischargeStatus;
227
+ reason: string;
228
+ claim: Expr | null;
229
+ }
230
+
215
231
  export interface PackageVersion {
216
232
  name: string;
217
233
  version: string;
@@ -262,6 +278,7 @@ export interface Result {
262
278
  diagnostics: Diagnostic[];
263
279
  expansions?: string[];
264
280
  files?: Artifact[];
281
+ evidence?: ObligationEvidence[];
265
282
  packages?: PackageView[];
266
283
  project?: {package?: PackageVersion; dependencies: Record<string, string>;};
267
284
  }
package/launcher.mjs CHANGED
@@ -1,26 +1,18 @@
1
+ // Generated from templates/npm/launcher.mjs by lawspec-dev generate. Do not edit.
1
2
  import { readFile } from "node:fs/promises";
2
3
  let compiled;
3
- export async function loadCore() {
4
- const { WASI } = await import("node:wasi");
5
- if (Number(process.versions.node.split(".")[0]) < 22)
6
- throw new Error("LawSpec requires Node 22+");
7
- compiled ??= readFile(new URL("./core.wasm", import.meta.url)).then(
8
- WebAssembly.compile,
9
- );
10
- const wasi = new WASI({
11
- version: "preview1",
12
- args: ["lawspec"],
13
- env: { PWD: "/" },
14
- preopens: { "/": process.cwd() },
15
- });
4
+
5
+ // Instantiate the compiler core with a platform's WASI preview1 imports and
6
+ // serialize calls: the core handles one JSON request at a time.
7
+ async function instantiateCore(module, wasiImports, initialize) {
16
8
  const exports = {};
17
9
  const jsffi = (await import("./core_jsffi.js")).default;
18
- const instance = await WebAssembly.instantiate(await compiled, {
19
- wasi_snapshot_preview1: wasi.wasiImport,
10
+ const instance = await WebAssembly.instantiate(module, {
11
+ wasi_snapshot_preview1: wasiImports,
20
12
  ghc_wasm_jsffi: jsffi(exports),
21
13
  });
22
14
  Object.assign(exports, instance.exports);
23
- wasi.initialize(instance);
15
+ initialize(instance);
24
16
  let pending = Promise.resolve();
25
17
  return (input) => {
26
18
  const result = pending.then(async () =>
@@ -30,3 +22,21 @@ export async function loadCore() {
30
22
  return result;
31
23
  };
32
24
  }
25
+
26
+ export async function loadCore() {
27
+ const { WASI } = await import("node:wasi");
28
+ if (Number(process.versions.node.split(".")[0]) < 22)
29
+ throw new Error("LawSpec requires Node 22+");
30
+ compiled ??= readFile(new URL("./core.wasm", import.meta.url)).then(
31
+ WebAssembly.compile,
32
+ );
33
+ const wasi = new WASI({
34
+ version: "preview1",
35
+ args: ["lawspec"],
36
+ env: { PWD: "/" },
37
+ preopens: { "/": process.cwd() },
38
+ });
39
+ return instantiateCore(await compiled, wasi.wasiImport, (instance) =>
40
+ wasi.initialize(instance),
41
+ );
42
+ }
@@ -1,3 +1,4 @@
1
+ // Generated from templates/npm/native-examples.mjs by lawspec-dev generate. Do not edit.
1
2
  import {readFile, readdir, mkdir} from 'node:fs/promises';
2
3
  import path from 'node:path';
3
4
  import {templates, commands, setup} from './templates.mjs';
package/package.json CHANGED
@@ -1,13 +1,40 @@
1
1
  {
2
2
  "name": "lawspec",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "State the law once. Check it everywhere.",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/brain-fuel/lawspec.git"
9
+ },
6
10
  "type": "module",
7
- "engines": { "node": ">=22" },
8
- "bin": { "lawspec": "bin/lawspec.mjs" },
9
- "exports": { ".": { "types": "./index.d.ts", "import": "./api.mjs" } },
11
+ "engines": {
12
+ "node": ">=22"
13
+ },
14
+ "bin": {
15
+ "lawspec": "bin/lawspec.mjs"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./index.d.ts",
20
+ "import": "./api.mjs"
21
+ }
22
+ },
10
23
  "types": "index.d.ts",
11
- "files": ["*.mjs", "*.json", "index.d.ts", "bin", "core.wasm", "core_jsffi.js", "README.md", "NATIVE-BINDINGS.md", "PRIMITIVES.md", "REFINEMENTS.md", "RUST.md", "JAVA.md", "PYTHON.md", "GO.md", "HASKELL.md", "KOTLIN.md", "WEB.md", "LANGUAGE.md", "API-MIGRATION.md", "RELEASE-0.9.md", "RELEASE-0.10.md", "RELEASE-0.11.md", "RELEASE-0.12.md", "RELEASE-0.13.md", "RELEASE-0.14.md", "LICENSE", "starter.lawspec", "examples"],
12
- "scripts": { "test": "node --test test/*.test.mjs" }
24
+ "files": [
25
+ "*.mjs",
26
+ "*.json",
27
+ "index.d.ts",
28
+ "bin",
29
+ "core.wasm",
30
+ "core_jsffi.js",
31
+ "README.md",
32
+ "CHANGELOG.md",
33
+ "LICENSE",
34
+ "starter.lawspec",
35
+ "examples"
36
+ ],
37
+ "scripts": {
38
+ "test": "node --test test/*.test.mjs"
39
+ }
13
40
  }
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ // Generated from templates/npm/read-only-hpack.mjs by lawspec-dev generate. Do not edit.
2
3
  import { readdirSync } from "node:fs";
3
4
  if (process.argv.some((a) => a === "--numeric-version" || a === "--version"))
4
5
  console.log("0.38.1");
package/scalars.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ // Generated from templates/npm/scalars.mjs by lawspec-dev generate. Do not edit.
1
2
  // Human-readable, lossless API v2 scalar display.
2
3
  export function showScalar(v) {
3
4
  if (!v || typeof v !== 'object') throw new TypeError('Expected an API v2 scalar');