lawspec 0.23.0 → 0.25.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 +167 -1
- package/README.md +29 -22
- package/UNICODE-LICENSE.txt +39 -0
- package/api.mjs +14 -23
- package/bin/lawspec.mjs +200 -67
- package/build.json +381 -155
- package/builtin-data-names.mjs +73 -0
- package/compatibility.json +21 -0
- package/core.wasm +2 -2
- package/doctor.mjs +98 -1
- package/examples/native-payments/clojure/lawspec.json +62 -0
- package/examples/native-payments/clojure/src/domain/payments.clj +11 -0
- package/examples/native-payments/clojure/test/domain/payment_generators.clj +9 -0
- 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 +176 -0
- package/examples/native-payments/groovy/src/main/groovy/domain/PaymentsDomain.groovy +49 -0
- package/examples/native-payments/groovy/src/test/groovy/domain/PaymentGenerators.groovy +15 -0
- 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 +176 -0
- package/examples/native-payments/scala/src/main/scala/domain/PaymentsDomain.scala +18 -0
- package/examples/native-payments/scala/src/test/scala/domain/PaymentGenerators.scala +8 -0
- package/examples/native-payments/swift/lawspec.json +165 -0
- package/examples/native-payments/swift/src/Native/PaymentsDomain.swift +35 -0
- package/examples/native-payments/swift/tests/Native/PaymentGenerators.swift +12 -0
- package/examples/native-payments/typescript/lawspec.json +14 -3
- package/examples/packages/orders/lawspec.json +25 -5
- package/examples/packages/orders/orders.lawspec +36 -34
- package/examples/packages/shop-domain/src/domain.lawspec +23 -21
- package/examples/packages/shop-tax-1/src/rates.lawspec +4 -4
- package/examples/packages/shop-tax-2/src/rates.lawspec +5 -4
- package/examples/rc1/authorization-snapshots.lawspec +112 -0
- package/examples/rc1/banner-filenames.lawspec +63 -0
- package/examples/rc1/bit-codec.lawspec +56 -0
- package/examples/rc1/bounded-witness-search.lawspec +144 -0
- package/examples/rc1/conflicting-requirements.lawspec +30 -0
- package/examples/rc1/constructive-witnesses.lawspec +113 -0
- package/examples/rc1/documentary-review.lawspec +42 -0
- package/examples/rc1/empty-domains.lawspec +46 -0
- package/examples/rc1/finite-integer-domains.lawspec +75 -0
- package/examples/rc1/law-metadata.lawspec +29 -0
- package/examples/rc1/native-payments.lawspec +107 -0
- package/examples/rc1/nesting/rrr.lawspec +33 -0
- package/examples/rc1/nesting/rru.lawspec +56 -0
- package/examples/rc1/nesting/rur.lawspec +57 -0
- package/examples/rc1/nesting/ruu.lawspec +77 -0
- package/examples/rc1/nesting/urr.lawspec +52 -0
- package/examples/rc1/nesting/uru.lawspec +72 -0
- package/examples/rc1/nesting/uur.lawspec +73 -0
- package/examples/rc1/nesting/uuu.lawspec +95 -0
- package/examples/rc1/order-workflow.lawspec +126 -0
- package/examples/rc1/parcel-measurements.lawspec +92 -0
- package/examples/rc1/picture-records.lawspec +51 -0
- package/examples/rc1/picture-tuples.lawspec +47 -0
- package/examples/rc1/record-payloads.lawspec +56 -0
- package/examples/rc1/recursive-records.lawspec +64 -0
- package/examples/rc1/refund-conformance.lawspec +44 -0
- package/examples/rc1/refund-policy.lawspec +88 -0
- package/examples/rc1/requirement-composition.lawspec +89 -0
- package/examples/rc1/structural-records.lawspec +53 -0
- package/examples/rc1-authoring.lawspec +56 -0
- package/examples-command.mjs +11 -5
- package/explain.mjs +112 -0
- package/expression-presentation.mjs +333 -0
- package/files.mjs +16 -0
- package/index.d.ts +934 -12
- package/lsp.mjs +231 -0
- package/migrate.mjs +135 -0
- package/migration-bindings.mjs +86 -0
- package/migration-cases.mjs +45 -0
- package/migration-collections.mjs +54 -0
- package/migration-correspondence.mjs +275 -0
- package/migration-generation.mjs +99 -0
- package/migration-laws.mjs +102 -0
- package/migration-records.mjs +166 -0
- package/migration-source.mjs +247 -0
- package/migration-write.mjs +156 -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/scala-coverage.mjs +56 -0
- package/starter-rc1.lawspec +25 -0
- package/templates.mjs +65 -3
- package/test-command.mjs +177 -29
- package/typed-presentation.mjs +165 -0
package/bin/lawspec.mjs
CHANGED
|
@@ -6,12 +6,19 @@ import path from "node:path";
|
|
|
6
6
|
import { createCompiler } from "../api.mjs";
|
|
7
7
|
import { targets, templates, commands, setup } from "../templates.mjs";
|
|
8
8
|
import { generateExamples } from "../examples-command.mjs";
|
|
9
|
+
import { migrationReport } from "../migrate.mjs";
|
|
10
|
+
import { writeMigration } from "../migration-write.mjs";
|
|
11
|
+
import { proveWithZ3 } from "../proof.mjs";
|
|
12
|
+
import { serveLanguage } from "../lsp.mjs";
|
|
13
|
+
import { explainLaw, explanationViews } from "../explain.mjs";
|
|
9
14
|
import { showScalar } from "../scalars.mjs";
|
|
10
15
|
import { doctor } from "../doctor.mjs";
|
|
16
|
+
import { recordNativeAttempts, nativeSeed, attestedKeys, readNativeObservations, attachNativeEvidence, nativeEvidenceText } from "../native-evidence.mjs";
|
|
11
17
|
import { beamCoverageRequirement, collectBeamCoverage } from "../beam-coverage.mjs";
|
|
18
|
+
import { collectScalaCoverage } from "../scala-coverage.mjs";
|
|
12
19
|
import { failureDatabase, projectKey } from "../failure-database.mjs";
|
|
13
20
|
import { spawn, spawnSync } from "node:child_process";
|
|
14
|
-
import { benchmarkInvocations, preparationInvocations, environmentDigest, executedTests, invocations, lawKeys, projectDigest, recordedDigest, selectByTags, mergeJunit,
|
|
21
|
+
import { benchmarkInvocations, configurationInvocations, preparationInvocations, environmentDigest, executedTests, invocations, lawKeys, projectDigest, recordedDigest, selectByTags, mergeJunit,
|
|
15
22
|
harnessStatistics, coverageTools, junitFromTests, testsToRun } from "../test-command.mjs";
|
|
16
23
|
import {
|
|
17
24
|
readOptional,
|
|
@@ -19,15 +26,16 @@ import {
|
|
|
19
26
|
applyWrites,
|
|
20
27
|
atomicWrite,
|
|
21
28
|
safePath,
|
|
29
|
+
collectSources,
|
|
22
30
|
} from "../files.mjs";
|
|
23
|
-
const VERSION = "0.
|
|
31
|
+
const VERSION = "0.25.0";
|
|
24
32
|
const args = process.argv.slice(2);
|
|
25
33
|
const verb = args.shift();
|
|
26
34
|
const options = {};
|
|
27
35
|
const positional = [];
|
|
28
36
|
for (let i = 0; i < args.length; i++) {
|
|
29
37
|
const arg = args[i];
|
|
30
|
-
if (["--target", "--project", "--config", "--output", "--machine-bits", "--example", "--seed", "--report", "--attestation"].includes(arg)) {
|
|
38
|
+
if (["--target", "--project", "--config", "--output", "--machine-bits", "--example", "--seed", "--report", "--attestation", "--view", "--from", "--solver", "--proof-timeout", "--proof-memory", "--proof-rlimit", "--proof-seed"].includes(arg)) {
|
|
31
39
|
if (!args[i + 1] || args[i + 1].startsWith("--"))
|
|
32
40
|
throw new Error(`Missing value for ${arg}`);
|
|
33
41
|
options[arg.slice(2)] = args[++i];
|
|
@@ -36,7 +44,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
36
44
|
if (!args[i + 1] || args[i + 1].startsWith("--"))
|
|
37
45
|
throw new Error(`Missing value for ${arg}`);
|
|
38
46
|
options[arg.slice(2)] = [...(options[arg.slice(2)] ?? []), ...args[++i].split(",").filter(Boolean)];
|
|
39
|
-
} else if (["--dry-run", "--check", "--json", "--minify", "--no-cache", "--fresh", "--coverage", "--update-recorded", "--benchmarks"].includes(arg))
|
|
47
|
+
} else if (["--dry-run", "--check", "--json", "--minify", "--no-cache", "--fresh", "--coverage", "--update-recorded", "--benchmarks", "--write", "--stdio", "--warn-matches"].includes(arg))
|
|
40
48
|
options[arg.slice(2)] = true;
|
|
41
49
|
else if (arg.startsWith("--")) throw new Error(`Unknown option: ${arg}`);
|
|
42
50
|
else positional.push(arg);
|
|
@@ -58,6 +66,8 @@ function testCommand(target, root) {
|
|
|
58
66
|
command = `${shellQuote(target.maven || "mvn")} test`;
|
|
59
67
|
if (target.language === "kotlin")
|
|
60
68
|
command = `${shellQuote(target.gradle || "gradle")} test`;
|
|
69
|
+
if (target.language === "scala")
|
|
70
|
+
command = `${shellQuote(target.scala || "scala")} test .`;
|
|
61
71
|
if (target.language === "javascript")
|
|
62
72
|
command = `node --test ${shellQuote(testDir)}/*.test.mjs`;
|
|
63
73
|
if (target.language === "typescript")
|
|
@@ -82,24 +92,7 @@ function diagnostics(result) {
|
|
|
82
92
|
async function sources(config) {
|
|
83
93
|
return lawspecFiles(configRoot, config.sources);
|
|
84
94
|
}
|
|
85
|
-
async function lawspecFiles(root, entries)
|
|
86
|
-
const files = [];
|
|
87
|
-
async function visit(file) {
|
|
88
|
-
const info = await stat(file);
|
|
89
|
-
if (info.isDirectory())
|
|
90
|
-
for (const entry of (await readdir(file)).sort())
|
|
91
|
-
await visit(path.join(file, entry));
|
|
92
|
-
else if (file.endsWith(".lawspec")) files.push(file);
|
|
93
|
-
}
|
|
94
|
-
for (const source of entries) await visit(path.resolve(root, source));
|
|
95
|
-
if (!files.length) throw new Error("No .lawspec source files found");
|
|
96
|
-
return Promise.all(
|
|
97
|
-
[...new Set(files)].sort().map(async (file) => ({
|
|
98
|
-
path: path.relative(configRoot, file).split(path.sep).join("/"),
|
|
99
|
-
content: await readFile(file, "utf8"),
|
|
100
|
-
})),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
95
|
+
async function lawspecFiles(root,entries){return collectSources(root,entries,configRoot);}
|
|
103
96
|
// A package directory holds lawspec-package.json: its name, version, source
|
|
104
97
|
// directories and dependency ranges. The compiler checks names, versions,
|
|
105
98
|
// namespaces and which units may import which.
|
|
@@ -133,12 +126,64 @@ async function packageInput(owner, root) {
|
|
|
133
126
|
...(owner.dependencies !== undefined ? { dependencies: owner.dependencies } : {}),
|
|
134
127
|
};
|
|
135
128
|
}
|
|
129
|
+
async function migrateCommand() {
|
|
130
|
+
if(options.write&&options["dry-run"])throw new Error("--write and --dry-run cannot be combined");
|
|
131
|
+
if (options.from !== "0.24") throw new Error("migrate requires --from 0.24");
|
|
132
|
+
const configurationText=await readFile(configFile,"utf8");
|
|
133
|
+
const config = JSON.parse(configurationText);
|
|
134
|
+
if (config.version !== 1) throw new Error("migrate --from 0.24 requires configuration version 1");
|
|
135
|
+
const compiler = await createCompiler();
|
|
136
|
+
const input={
|
|
137
|
+
sources: await sources(config), ...(await packageInput(config, configRoot)),
|
|
138
|
+
generation: config.generation, machineBits: config.machineBits ?? 64, minify: options.minify === true,
|
|
139
|
+
};
|
|
140
|
+
const recheck=async()=>{
|
|
141
|
+
const current={sources:await sources(config),...(await packageInput(config,configRoot))};
|
|
142
|
+
const original={sources:input.sources,...Object.fromEntries(['packages','dependencies']
|
|
143
|
+
.filter(key=>input[key]!==undefined).map(key=>[key,input[key]]))};
|
|
144
|
+
if(JSON.stringify(current)!==JSON.stringify(original))throw new Error('Project sources or package dependencies changed during migration.');
|
|
145
|
+
};
|
|
146
|
+
const report=options.write?await writeMigration(compiler,configRoot,path.basename(configFile),configurationText,input,{recheck}):
|
|
147
|
+
await migrationReport(compiler,config,input);
|
|
148
|
+
diagnostics(report);
|
|
149
|
+
const bindingChanges=report.bindingPreview.targets.flatMap(target=>target.evidence?.changes??[]).length;
|
|
150
|
+
const bindingChecked=report.bindingPreview.targets.filter(target=>target.evidence?.beforeValidated===true).length;
|
|
151
|
+
const bindingMatched=report.bindingPreview.targets.filter(target=>target.status==='matched').length;
|
|
152
|
+
const bindingSummary=`Native binding preview: ${bindingChecked} of ${report.bindingPreview.configurationCount} original configurations checked; ${bindingMatched} proposals match; ${bindingChanges} field changes.\n`;
|
|
153
|
+
const generationAccepted=report.generationPreview.targets.filter(target=>target.status==='accepted').length;
|
|
154
|
+
const generationSummary=`Target generation preview: ${generationAccepted} of ${report.generationPreview.configurationCount} configurations accepted. Native implementation conformance remains unestablished.\n`;
|
|
155
|
+
const boundaryMatched=report.generationPreview.targets.filter(target=>target.nativeBoundary.status==='matched').length;
|
|
156
|
+
const boundarySummary=`Native boundary comparison: ${boundaryMatched} of ${report.generationPreview.configurationCount} configurations match under their existing native implementation assumptions.\n`;
|
|
157
|
+
output(options.json ? report : `${options.write?"Written":"Read-only"} migration report: ${report.baseline.laws.length} laws, ${report.baseline.definitions.length} definitions, ${report.constructorChanges.length} constructor payload changes.\n` + bindingSummary + generationSummary + boundarySummary +
|
|
158
|
+
report.blockers.join("\n") + (options.write?`\n${report.filesWritten.length} files written. Existing native implementation assumptions are retained; no law verification is claimed.`:
|
|
159
|
+
`\nNo files were written. ${report.validated?'The migration is validated under its existing compiler and native implementation assumptions. Use --write to apply it.':'Migration remains incomplete.'} Use --json to inspect the complete report.`));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function formatCommand() {
|
|
163
|
+
const config = positional.length ? null : JSON.parse(await readFile(configFile, "utf8"));
|
|
164
|
+
if(config&&(config.version!==2||config.languageProfile!=="1.0-rc.1"))
|
|
165
|
+
throw new Error("Formatting a project requires configuration version 2 and languageProfile 1.0-rc.1; run lawspec migrate --from 0.24 first.");
|
|
166
|
+
const root = positional.length ? process.cwd() : configRoot;
|
|
167
|
+
const files = await collectSources(root, positional.length ? positional : config.sources);
|
|
168
|
+
const compiler = await createCompiler();
|
|
169
|
+
const result = diagnostics(await compiler.format({
|
|
170
|
+
sources: files, ...(config ? await packageInput(config, configRoot) : {}),
|
|
171
|
+
languageProfile: "1.0-rc.1", verification: { layers: [] },
|
|
172
|
+
}));
|
|
173
|
+
const changed = result.formattedSources.filter((file, index) => file.content !== files[index].content);
|
|
174
|
+
if (!options.check) for (const file of changed) await atomicWrite(path.resolve(root, file.path), file.content);
|
|
175
|
+
output(options.json ? { changed: changed.map(file => file.path), check: !!options.check }
|
|
176
|
+
: changed.length ? `${changed.length} source file(s) ${options.check ? "need formatting" : "formatted"}.` : "All sources are formatted.");
|
|
177
|
+
if (options.check && changed.length) process.exitCode = 1;
|
|
178
|
+
}
|
|
179
|
+
|
|
136
180
|
async function packageCommand() {
|
|
137
181
|
const directory = path.resolve(options.project || ".");
|
|
138
182
|
const { manifest, package: own } = await loadPackage(directory);
|
|
139
183
|
const compiler = await createCompiler();
|
|
140
184
|
const result = diagnostics(
|
|
141
185
|
await compiler.check({
|
|
186
|
+
languageProfile: '1.0-rc.1', verification: {layers: []},
|
|
142
187
|
sources: own.sources,
|
|
143
188
|
package: { name: own.name, version: own.version },
|
|
144
189
|
...(await packageInput(manifest, directory)),
|
|
@@ -178,8 +223,10 @@ async function init() {
|
|
|
178
223
|
const current = await readOptional(configFile);
|
|
179
224
|
const config =
|
|
180
225
|
current === null
|
|
181
|
-
? { version: 1, sources: ["laws"], targets: [] }
|
|
226
|
+
? { version: 2, languageProfile: "1.0-rc.1", verification: { layers: [] }, sources: ["laws"], targets: [] }
|
|
182
227
|
: JSON.parse(current);
|
|
228
|
+
if(config.version!==2||config.languageProfile!=='1.0-rc.1')
|
|
229
|
+
throw new Error('Existing projects require configuration version 2 and languageProfile 1.0-rc.1; run lawspec migrate --from 0.24 first.');
|
|
183
230
|
if (
|
|
184
231
|
config.targets.some(
|
|
185
232
|
(t) =>
|
|
@@ -225,7 +272,7 @@ async function init() {
|
|
|
225
272
|
if (current === null)
|
|
226
273
|
await atomicWrite(
|
|
227
274
|
starter,
|
|
228
|
-
await readFile(new URL("../starter.lawspec", import.meta.url), "utf8"),
|
|
275
|
+
await readFile(new URL("../starter-rc1.lawspec", import.meta.url), "utf8"),
|
|
229
276
|
true,
|
|
230
277
|
);
|
|
231
278
|
if (options.machineBits !== undefined) config.machineBits = options.machineBits;
|
|
@@ -287,7 +334,7 @@ async function lastRuns() {
|
|
|
287
334
|
const known = runs.get(law) ?? {};
|
|
288
335
|
const latest = (known.passed ?? "") > (run.passed ?? "") ? known : run;
|
|
289
336
|
runs.set(law, { flaky: known.flaky || run.flaky, adequacy: run.adequacy ?? known.adequacy,
|
|
290
|
-
passed: latest.passed, environment: latest.environment });
|
|
337
|
+
passed: latest.passed, seed: latest.seed, environment: latest.environment });
|
|
291
338
|
}
|
|
292
339
|
}
|
|
293
340
|
return { runs, attestations };
|
|
@@ -398,11 +445,19 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
398
445
|
}));
|
|
399
446
|
// The laws the attestation touches, each with how its dependencies
|
|
400
447
|
// were wired (the run's id and times aside).
|
|
401
|
-
const attested =
|
|
402
|
-
|
|
448
|
+
const attested = attestedKeys(planned);
|
|
449
|
+
if(!planned.tests.length&&!options.benchmarks){
|
|
450
|
+
summaries.push({target:target.language,root:target.root,seed:nativeSeed(seed),ran:[],unchanged:0,
|
|
451
|
+
ok:true,testsExecuted:0,selection:'no-selected-native-checks'});
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
403
454
|
const pending = await planWrites(root, planned.files);
|
|
404
455
|
if (pending.changes.length)
|
|
405
456
|
throw new Error(`${target.language}: generated files are out of date; run lawspec generate${options.minify ? " --minify" : ""}`);
|
|
457
|
+
for(const preparation of configurationInvocations(target)){
|
|
458
|
+
const result=await spawned(preparation.command,preparation.args,root,process.env);
|
|
459
|
+
if(!result.ok)throw new Error(`${target.language}: native build metadata preparation failed`);
|
|
460
|
+
}
|
|
406
461
|
const report_ = await doctor(target, root, planned.files);
|
|
407
462
|
if (!report_.ok) throw new Error(`${target.language}: ${report_.message}\n${report_.instructions}`);
|
|
408
463
|
const generated = new Set(planned.files.filter((f) => f.ownership === "generated").map((f) => f.path));
|
|
@@ -417,6 +472,7 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
417
472
|
const identity = projectKey(root);
|
|
418
473
|
const resultsFile = path.join(configRoot, ".lawspec", "results", `${target.language}-${identity}.json`);
|
|
419
474
|
const previous = JSON.parse((await readOptional(resultsFile)) ?? '{"version":1,"laws":{}}');
|
|
475
|
+
const attempts = {...(previous.attempts ?? {})};
|
|
420
476
|
const {directory: failures, file: databaseFile, database} = await failureDatabase(configRoot, target.language, root);
|
|
421
477
|
// Recording again runs every law, so each records what it sees now.
|
|
422
478
|
const chosen = selectByTags(planned.tests, options.tag ?? [], options["exclude-tag"] ?? []);
|
|
@@ -428,10 +484,23 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
428
484
|
// databases beside it (Hypothesis, proptest).
|
|
429
485
|
const replayed = options.seed === undefined ? stale.filter((entry) => database[entry.law]) : [];
|
|
430
486
|
const batches = [
|
|
431
|
-
...[...new Set(replayed.map((entry) => database[entry.law].seed))].map((s) =>
|
|
432
|
-
({ seed: String(s), entries: replayed.filter((entry) => database[entry.law].seed === s) })),
|
|
487
|
+
...[...new Set(replayed.map((entry) => nativeSeed(database[entry.law].seed)))].map((s) =>
|
|
488
|
+
({ seed: String(s), entries: replayed.filter((entry) => nativeSeed(database[entry.law].seed) === s) })),
|
|
433
489
|
{ seed, entries: stale.filter((entry) => !replayed.includes(entry)) },
|
|
434
490
|
].filter((batch) => batch.entries.length);
|
|
491
|
+
const profile = {target:target.language,root,machineBits:input.machineBits,
|
|
492
|
+
minify:options.minify===true,build};
|
|
493
|
+
// Persist pending attempts before starting a native process. Interrupted or
|
|
494
|
+
// failed setup cannot leave an older passing cache entry looking completed.
|
|
495
|
+
for(const entry of stale){
|
|
496
|
+
Object.assign(attempts,recordNativeAttempts({laws:[entry],command:null},[],
|
|
497
|
+
{keys,seed,ok:false,profile,allEntries:planned.tests}));
|
|
498
|
+
}
|
|
499
|
+
const pendingLaws=Object.fromEntries(Object.entries(previous.laws??{})
|
|
500
|
+
.filter(([id])=>!stale.some(entry=>entry.law===id)));
|
|
501
|
+
await mkdir(path.dirname(resultsFile),{recursive:true});
|
|
502
|
+
await writeFile(path.join(path.dirname(resultsFile),".gitignore"),"*\n");
|
|
503
|
+
await atomicWrite(resultsFile,JSON.stringify({...previous,version:1,laws:pendingLaws,attempts},null,2)+"\n");
|
|
435
504
|
const passed = [];
|
|
436
505
|
const unrun = [];
|
|
437
506
|
let failed = false;
|
|
@@ -450,7 +519,7 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
450
519
|
if (missingCoverage)
|
|
451
520
|
console.error(`${target.language}: --coverage needs ${missingCoverage.tool}, which is not available; ${missingCoverage.install}. Running without coverage.`);
|
|
452
521
|
if (useCoverage) {
|
|
453
|
-
if (beam) await rm(coverage, {recursive: true, force: true});
|
|
522
|
+
if (beam || target.language === "scala") await rm(coverage, {recursive: true, force: true});
|
|
454
523
|
await mkdir(beam ? path.join(coverage, "runs") : coverage, { recursive: true });
|
|
455
524
|
}
|
|
456
525
|
// parallel on Python needs pytest-xdist; without it the tests run one
|
|
@@ -474,24 +543,37 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
474
543
|
batches: for (const batch of batches) {
|
|
475
544
|
for (const run of invocations(target, batch.entries, { offline, scratch, coverage: useCoverage ? coverage : null,
|
|
476
545
|
xdist, root, coverageConfig: report_.coverage })) {
|
|
477
|
-
const since = Date.now()
|
|
546
|
+
const since = Date.now();
|
|
478
547
|
const { ok, output } = await spawned(run.command, run.args, root,
|
|
479
548
|
{ ...process.env, ...run.env, LAWSPEC_SEED: batch.seed, HSPEC_SEED: batch.seed,
|
|
480
549
|
LAWSPEC_STATS: stats, LAWSPEC_FAILURES: failures, LAWSPEC_RECORDED: recordedFolder,
|
|
481
550
|
...(options["update-recorded"] ? { LAWSPEC_UPDATE_RECORDED: "1" } : {}) }, run.report?.kind === "go-json");
|
|
482
551
|
if (run.coverage) coverageRuns.push(run.coverage);
|
|
483
552
|
const executed = await executedTests(run.report, output, root, since);
|
|
553
|
+
const observed=recordNativeAttempts(run,executed,{keys,seed:batch.seed,ok,profile,output,allEntries:planned.tests});
|
|
554
|
+
if(!ok&&!run.laws.length)Object.assign(attempts,recordNativeAttempts({laws:batch.entries,command:run.command},[],
|
|
555
|
+
{keys,seed:batch.seed,ok:false,profile,output,allEntries:planned.tests}));
|
|
556
|
+
Object.assign(attempts,observed);
|
|
484
557
|
for (const law of run.laws) seedOf.set(law.law, batch.seed);
|
|
558
|
+
// A completed combined model method remains scoped to its own checks,
|
|
559
|
+
// even if another selected method in this invocation failed.
|
|
560
|
+
passed.push(...run.laws.filter(entry=>['passed','known-failing'].includes(observed[entry.law]?.outcome)||!expected(entry)));
|
|
485
561
|
if (report) junit.push({ target: `${target.language} (${target.root})`, xml: await junitOf(run, executed, root, since) });
|
|
486
562
|
if (!ok || executed.some((test) => test.status === "failed")) { failed = true; break batches; }
|
|
487
563
|
// A runner whose filter matched nothing reports success, so a law
|
|
488
564
|
// counts as passed only if the runner's report shows its tests ran.
|
|
489
|
-
|
|
490
|
-
passed.push(...run.laws.filter((law) => ran.has(law) || !expected(law)));
|
|
491
|
-
unrun.push(...run.laws.filter((law) => !ran.has(law) && expected(law)));
|
|
565
|
+
unrun.push(...run.laws.filter(entry=>!passed.includes(entry)&&expected(entry)));
|
|
492
566
|
}
|
|
493
567
|
}
|
|
494
568
|
if (unrun.length) failed = true;
|
|
569
|
+
if (useCoverage && target.language === "scala" && !failed) {
|
|
570
|
+
try {
|
|
571
|
+
coverageWritten = await collectScalaCoverage({root, directory: coverage, command: target.scala || "scala", offline});
|
|
572
|
+
} catch (error) {
|
|
573
|
+
failed = true;
|
|
574
|
+
coverageError = error.message;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
495
577
|
if (useCoverage && beam) {
|
|
496
578
|
try {
|
|
497
579
|
coverageWritten = !!(await collectBeamCoverage({root, directory: coverage, runs: coverageRuns}));
|
|
@@ -512,7 +594,7 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
512
594
|
for (const entry of passed) {
|
|
513
595
|
const label = entry.label;
|
|
514
596
|
const observed = statistics.filter((s) => s.law === label);
|
|
515
|
-
laws[entry.law] = { key: keys.get(entry.law), seed:
|
|
597
|
+
laws[entry.law] = { key: keys.get(entry.law), seed: nativeSeed(seedOf.get(entry.law) ?? seed), passed: new Date().toISOString(),
|
|
516
598
|
// A law the attestation touches names the run it passed in.
|
|
517
599
|
...(attestation && attested.has(entry.law) ? { environment: attestation.run.id } : {}),
|
|
518
600
|
...(observed.some((s) => s.outcome === "flaky") ? { flaky: true } : {}),
|
|
@@ -522,9 +604,10 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
522
604
|
// A law that failed is recorded with its seed; one that passed leaves.
|
|
523
605
|
for (const entry of stale) {
|
|
524
606
|
if (passed.includes(entry)) delete database[entry.law];
|
|
525
|
-
else
|
|
607
|
+
else {
|
|
526
608
|
delete laws[entry.law];
|
|
527
|
-
|
|
609
|
+
if(!seedOf.has(entry.law))continue;
|
|
610
|
+
database[entry.law] = { seed: nativeSeed(seedOf.get(entry.law)), failed: new Date().toISOString() };
|
|
528
611
|
}
|
|
529
612
|
}
|
|
530
613
|
await writeFile(path.join(configRoot, ".lawspec", "failures", ".gitignore"), "*\n");
|
|
@@ -535,14 +618,14 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
535
618
|
const attestations = Object.fromEntries(Object.entries({ ...(previous.attestations ?? {}),
|
|
536
619
|
...(attestation ? { [attestation.run.id]: attestation } : {}) })
|
|
537
620
|
.filter(([id]) => Object.values(laws).some((run) => run.environment === id)));
|
|
538
|
-
await
|
|
621
|
+
await atomicWrite(resultsFile, JSON.stringify({ version: 1, laws, attempts,
|
|
539
622
|
...(Object.keys(attestations).length ? { attestations } : {}) }, null, 2) + "\n");
|
|
540
623
|
const flaky = statistics.filter((s) => s.outcome === "flaky").map((s) => s.law);
|
|
541
624
|
const unmet = statistics.flatMap((s) => (s.cover ?? []).filter((c) => !c.met).map((c) => `${s.law}: cover ${c.required}% "${c.label}" (${c.observed}%)`));
|
|
542
625
|
const benchmarks = statistics.filter((s) => s.benchmark);
|
|
543
626
|
// How each parallel unit's tests actually ran at the same time.
|
|
544
627
|
const parallelism = statistics.filter((s) => s.parallel).map(({ parallel, mode, workers }) => ({ unit: parallel, mode, workers }));
|
|
545
|
-
summaries.push({ target: target.language, root: target.root, seed:
|
|
628
|
+
summaries.push({ target: target.language, root: target.root, seed: nativeSeed(seed), ran: stale.map((e) => e.law),
|
|
546
629
|
...(attestation ? { environment: attestation.environment } : {}),
|
|
547
630
|
unchanged: chosen.length - stale.length, ok: !failed,
|
|
548
631
|
...(chosen.length !== planned.tests.length ? { deselected: planned.tests.length - chosen.length } : {}),
|
|
@@ -552,7 +635,7 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
552
635
|
...(benchmarks.length ? { benchmarks } : {}),
|
|
553
636
|
...(parallelism.length ? { parallelism } : {}),
|
|
554
637
|
...(coverageError ? {coverageError} : {}),
|
|
555
|
-
...(useCoverage && (!beam || coverageWritten) ? { coverage: path.relative(process.cwd(), coverage) || "." } : {}) });
|
|
638
|
+
...(useCoverage && ((!beam && target.language !== "scala") || coverageWritten) ? { coverage: path.relative(process.cwd(), coverage) || "." } : {}) });
|
|
556
639
|
}
|
|
557
640
|
if (report) {
|
|
558
641
|
await mkdir(path.dirname(path.resolve(report.path)), { recursive: true });
|
|
@@ -560,7 +643,8 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
560
643
|
}
|
|
561
644
|
output(options.json ? summaries : summaries.map((s) =>
|
|
562
645
|
`${s.target}${summaries.filter(other => other.target === s.target).length > 1 ? ` (${s.root})` : ""}: ${s.ran.length ? `ran ${s.ran.length} law(s) with seed ${s.seed}${s.environment ? ` in environment ${s.environment}` : ""}` : "nothing to run"}` +
|
|
563
|
-
|
|
646
|
+
(s.selection==='no-selected-native-checks'?'; no native checks selected; intrinsic definition checks passed.':
|
|
647
|
+
`, ${s.unchanged} unchanged since their last passing run.${s.ok ? "" : " FAILED"}`) +
|
|
564
648
|
(s.deselected ? `\n${s.deselected} law(s) not selected by --tag or --exclude-tag.` : "") +
|
|
565
649
|
(s.unrun ? `\nNo tests ran for ${s.unrun.join(", ")}; the runner matched none of their tests.` : "") +
|
|
566
650
|
(s.flaky ? `\nFlaky (failed, then passed on a retry): ${s.flaky.join(", ")}` : "") +
|
|
@@ -618,6 +702,7 @@ async function coverageMissing(target, root, report) {
|
|
|
618
702
|
const build = await readFile(path.join(root, "build.gradle.kts"), "utf8").catch(() => "");
|
|
619
703
|
return build.includes("kover") ? null : tool;
|
|
620
704
|
}
|
|
705
|
+
if (target.language === "scala") return null;
|
|
621
706
|
return null;
|
|
622
707
|
}
|
|
623
708
|
// Run a native test command, showing its output (on stderr with --json) and
|
|
@@ -660,7 +745,7 @@ async function main() {
|
|
|
660
745
|
}
|
|
661
746
|
if (!verb || ["help", "--help", "-h"].includes(verb)) {
|
|
662
747
|
output(
|
|
663
|
-
"LawSpec " + VERSION + "\nUsage: lawspec init --target <language> [--project <directory>] [--minify]\n lawspec check | doctor | explain <unit>::<law> | generate\n lawspec evidence [<unit> | <unit>::<declaration>] [--attestation <file>]\n lawspec test [--target <language>] [--fresh] [--seed <n>] [--attestation <file>] [--update-recorded] [--tag <t>] [--exclude-tag <t>] [--report junit=<path>] [--coverage] [--benchmarks]\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, --no-cache\nGeneration: --dry-run, --check, --minify\nTargets: " +
|
|
748
|
+
"LawSpec " + VERSION + "\nUsage: lawspec init --target <language> [--project <directory>] [--minify]\n lawspec fmt [paths...] [--check]\n lawspec migrate --from 0.24 [--write]\n lawspec lsp --stdio\n lawspec prove [--solver <z3-executable>] [--proof-timeout <ms>] [--json]\n lawspec check [--warn-matches] | doctor | explain [<unit>::<law>] [--view developer|business|formal|evidence] | generate\n lawspec evidence [<unit> | <unit>::<declaration>] [--attestation <file>]\n lawspec test [--target <language>] [--fresh] [--seed <n>] [--attestation <file>] [--update-recorded] [--tag <t>] [--exclude-tag <t>] [--report junit=<path>] [--coverage] [--benchmarks]\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, --no-cache\nGeneration: --dry-run, --check, --minify\nTargets: " +
|
|
664
749
|
targets.join(", "),
|
|
665
750
|
);
|
|
666
751
|
return;
|
|
@@ -669,7 +754,7 @@ async function main() {
|
|
|
669
754
|
output(VERSION);
|
|
670
755
|
return;
|
|
671
756
|
}
|
|
672
|
-
if (positional.length > (["explain", "evidence"].includes(verb) ? 1 : 0))
|
|
757
|
+
if (verb !== "fmt" && positional.length > (["explain", "evidence"].includes(verb) ? 1 : 0))
|
|
673
758
|
throw new Error(`Unexpected argument: ${positional.join(" ")}`);
|
|
674
759
|
if (verb === "examples") {
|
|
675
760
|
if (
|
|
@@ -700,6 +785,9 @@ async function main() {
|
|
|
700
785
|
);
|
|
701
786
|
return;
|
|
702
787
|
}
|
|
788
|
+
if (["solver","proof-timeout","proof-memory","proof-rlimit","proof-seed"].some(key => options[key] !== undefined) && verb !== "prove")
|
|
789
|
+
throw new Error("Z3 options apply to prove");
|
|
790
|
+
if (options.view && verb !== "explain") throw new Error("--view applies to explain");
|
|
703
791
|
if (options.output) throw new Error("--output is only supported by examples");
|
|
704
792
|
if (options.example) throw new Error("--example is only supported by examples");
|
|
705
793
|
if (options.minify && !["init", "generate", "examples", "test"].includes(verb))
|
|
@@ -711,23 +799,35 @@ async function main() {
|
|
|
711
799
|
throw new Error("--attestation applies to evidence and test");
|
|
712
800
|
if (options.seed !== undefined && !/^[0-9]+$/.test(options.seed))
|
|
713
801
|
throw new Error("--seed must be a whole number");
|
|
802
|
+
if (options.from && verb !== "migrate") throw new Error("--from applies to migrate");
|
|
803
|
+
if (options.write && verb !== "migrate") throw new Error("--write applies to migrate");
|
|
804
|
+
if (options["warn-matches"] && verb !== "check") throw new Error("--warn-matches applies to check");
|
|
805
|
+
if (options.stdio && verb !== "lsp") throw new Error("--stdio applies to lsp");
|
|
806
|
+
if (verb === "migrate") return migrateCommand();
|
|
807
|
+
if (verb === "lsp") {
|
|
808
|
+
if (!options.stdio) throw new Error("lsp requires --stdio");
|
|
809
|
+
return serveLanguage();
|
|
810
|
+
}
|
|
811
|
+
if (verb === "fmt") return formatCommand();
|
|
714
812
|
if (verb === "init") return init();
|
|
715
813
|
if (verb === "package") return packageCommand();
|
|
716
|
-
if (!["check", "doctor", "evidence", "explain", "generate", "test"].includes(verb))
|
|
814
|
+
if (!["check", "doctor", "evidence", "explain", "generate", "test", "prove"].includes(verb))
|
|
717
815
|
throw new Error(`Unknown command: ${verb}`);
|
|
718
816
|
const config = JSON.parse(await readFile(configFile, "utf8"));
|
|
719
817
|
if (
|
|
720
|
-
config.version
|
|
818
|
+
config.version!==2 ||
|
|
721
819
|
!Array.isArray(config.sources) ||
|
|
722
820
|
!Array.isArray(config.targets)
|
|
723
821
|
)
|
|
724
822
|
throw new Error(
|
|
725
|
-
"Expected lawspec.json version
|
|
823
|
+
"Expected lawspec.json version 2 with languageProfile 1.0-rc.1, sources and targets arrays; run lawspec migrate --from 0.24 for version 1 projects",
|
|
726
824
|
);
|
|
825
|
+
if (config.languageProfile !== "1.0-rc.1") throw new Error("Configuration version 2 requires languageProfile 1.0-rc.1");
|
|
727
826
|
const selected = config.targets.filter(
|
|
728
827
|
(t) => !options.target || t.language === options.target,
|
|
729
828
|
);
|
|
730
|
-
if (["doctor", "generate", "test"].includes(verb) && !selected.length
|
|
829
|
+
if (["doctor", "generate", "test"].includes(verb) && !selected.length &&
|
|
830
|
+
!(verb === "test" && !options.benchmarks && config.version === 2 && !(config.verification?.layers ?? []).some(layer => ["exhaustive", "property", "examples", "model"].includes(layer))))
|
|
731
831
|
throw new Error("No matching configured target");
|
|
732
832
|
const roots = selected.map((t) => path.resolve(configRoot, t.root));
|
|
733
833
|
if (new Set(roots).size !== roots.length)
|
|
@@ -757,11 +857,28 @@ async function main() {
|
|
|
757
857
|
const input = {
|
|
758
858
|
...(cache === undefined ? {} : { cacheDirectory: cache }),
|
|
759
859
|
sources: await sources(config),
|
|
860
|
+
languageProfile: config.languageProfile, verification: config.verification ?? { layers: [] },
|
|
760
861
|
...(await packageInput(config, configRoot)),
|
|
761
862
|
generation: config.generation,
|
|
762
863
|
machineBits: options.machineBits ?? config.machineBits ?? 64,
|
|
763
864
|
};
|
|
764
865
|
const compiler = await createCompiler();
|
|
866
|
+
if (verb === "prove") {
|
|
867
|
+
if (config.version !== 2) throw new Error("prove requires configuration version 2 and languageProfile 1.0-rc.1");
|
|
868
|
+
const result = diagnostics(await proveWithZ3(compiler, input, {
|
|
869
|
+
...(options.solver !== undefined ? {binary: options.solver} : {}),
|
|
870
|
+
...Object.fromEntries([["proof-timeout","timeoutMs"],["proof-memory","memoryMb"],
|
|
871
|
+
["proof-rlimit","resourceLimit"],["proof-seed","seed"]]
|
|
872
|
+
.filter(([name]) => options[name] !== undefined).map(([name,key]) => [key,Number(options[name])])),
|
|
873
|
+
}));
|
|
874
|
+
output(options.json ? result : result.solverEvidence.length
|
|
875
|
+
? result.solverEvidence.map(row => `${row.declaration}: ${row.status} (${row.outcome}). ${row.reason}`).join("\n")
|
|
876
|
+
: (input.verification?.layers.includes("proof")
|
|
877
|
+
? "No source law obligations are available. No solver was invoked."
|
|
878
|
+
: "No proof layer selected. Intrinsic definition checks passed; no solver was invoked."));
|
|
879
|
+
if (result.solverEvidence.some(row => row.status !== "proved")) process.exitCode = 2;
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
765
882
|
// Each obligation reports how it is discharged, strongest first.
|
|
766
883
|
const statuses = [
|
|
767
884
|
["proved", "PROVED"],
|
|
@@ -776,6 +893,10 @@ async function main() {
|
|
|
776
893
|
["known-failing", "KNOWN FAILING"],
|
|
777
894
|
["flaky", "FLAKY"],
|
|
778
895
|
["skipped", "SKIPPED"],
|
|
896
|
+
["planned", "PLANNED"],
|
|
897
|
+
["not-verified", "NOT VERIFIED"],
|
|
898
|
+
["incomplete", "INCOMPLETE"],
|
|
899
|
+
["unsupported", "UNSUPPORTED"],
|
|
779
900
|
];
|
|
780
901
|
const evidenceSummary = (evidence) => {
|
|
781
902
|
if (!evidence.length) return "";
|
|
@@ -788,7 +909,9 @@ async function main() {
|
|
|
788
909
|
};
|
|
789
910
|
const obligationName = (item) => item.declaration.replace("::law::", "::");
|
|
790
911
|
if (verb === "check") {
|
|
791
|
-
const result = diagnostics(await compiler.check(input));
|
|
912
|
+
const result = diagnostics(await compiler.check({...input, ...(options["warn-matches"] ? {warnMatches:true} : {})}));
|
|
913
|
+
if (!options.json) for (const warning of result.warnings ?? [])
|
|
914
|
+
console.error(`${warning.at ? `${warning.at.file}:${warning.at.line}:${warning.at.column}: ` : ""}warning ${warning.code}: ${warning.message}`);
|
|
792
915
|
for (const target of selected) {
|
|
793
916
|
if (target.nativeBindings !== undefined)
|
|
794
917
|
diagnostics(await compiler.check({...input, nativeBindings: target.nativeBindings}));
|
|
@@ -796,7 +919,9 @@ async function main() {
|
|
|
796
919
|
output(
|
|
797
920
|
options.json
|
|
798
921
|
? result
|
|
799
|
-
: `
|
|
922
|
+
: `Compiled ${result.laws.length} law(s). Intrinsic definition checks passed.` +
|
|
923
|
+
(result.verification?.selection === "no-selected-checks"
|
|
924
|
+
? " No law checks selected." : evidenceSummary(result.evidence ?? [])),
|
|
800
925
|
);
|
|
801
926
|
return;
|
|
802
927
|
}
|
|
@@ -805,18 +930,20 @@ async function main() {
|
|
|
805
930
|
// ran; otherwise each law shows the attested run it last passed in.
|
|
806
931
|
const named = await readAttestation(config);
|
|
807
932
|
const result = diagnostics(await compiler.check({ ...input, ...(named ? { attestation: named } : {}) }));
|
|
808
|
-
let evidence = result.evidence
|
|
933
|
+
let evidence = attachNativeEvidence(result.evidence,await readNativeObservations({compiler,input,selected,roots,
|
|
934
|
+
configRoot,build:await buildDigest(),evidence:result.evidence,attestation:named}));
|
|
809
935
|
const { runs, attestations } = await lastRuns();
|
|
810
936
|
const environments = named ? [result.attestation] : [];
|
|
811
937
|
if (!named) for (const [id, attestation] of attestations) {
|
|
812
938
|
const laws = new Set([...runs].filter(([, run]) => run.environment === id).map(([law]) => law));
|
|
813
939
|
if (!laws.size) continue;
|
|
814
940
|
const attested = diagnostics(await compiler.check({ ...input, attestation }));
|
|
815
|
-
const fields = new Map(attested.evidence.filter((item) => item.against && laws.has(item.declaration))
|
|
816
|
-
.map(
|
|
941
|
+
const fields = new Map(attested.evidence.filter((item) => (item.against || item.plannedAgainst) && laws.has(item.declaration))
|
|
942
|
+
.map(item => [item.declaration, {environment: item.environment ?? item.plannedEnvironment,
|
|
943
|
+
environmentRun: item.environmentRun ?? item.plannedEnvironmentRun, against: item.against ?? item.plannedAgainst}]));
|
|
817
944
|
evidence = evidence.map((item) => item.stage === "law" && fields.has(item.declaration) ? { ...item, ...fields.get(item.declaration) } : item);
|
|
818
945
|
environments.push({ ...attested.attestation, dependencies: attested.attestation.dependencies
|
|
819
|
-
.map((d) => ({ ...d, obligations: d.obligations.filter((law) => laws.has(law)) })) });
|
|
946
|
+
.map((d) => ({ ...d, obligations: [...new Set([...d.obligations, ...(d.plannedObligations ?? [])])].filter((law) => laws.has(law)), plannedObligations: [] })) });
|
|
820
947
|
}
|
|
821
948
|
// Native bindings are configured per target; their obligations are added.
|
|
822
949
|
for (const target of selected) {
|
|
@@ -832,9 +959,10 @@ async function main() {
|
|
|
832
959
|
// The last run's outcome (lawspec test): a law that failed, then passed
|
|
833
960
|
// on a retry, is flaky; what its generated cases covered is its adequacy.
|
|
834
961
|
evidence = evidence.map((item) => {
|
|
962
|
+
if(item.nativeEvidence)return item;
|
|
835
963
|
const run = item.stage === "law" ? runs.get(item.declaration) : undefined;
|
|
836
964
|
if (!run) return item;
|
|
837
|
-
return { ...item, ...(run.adequacy ? { adequacy: run.adequacy } : {}),
|
|
965
|
+
return { ...item, lastNativeRun: {passed: run.passed, seed: run.seed}, ...(run.adequacy ? { adequacy: run.adequacy } : {}),
|
|
838
966
|
...(run.flaky && ["property-tested", "exhaustively-checked"].includes(item.status)
|
|
839
967
|
? { status: "flaky", reason: `${item.reason}; its last run failed, then passed on a retry` } : {}) };
|
|
840
968
|
});
|
|
@@ -849,7 +977,9 @@ async function main() {
|
|
|
849
977
|
return `${label} (${items.length})\n` + items.map((item) =>
|
|
850
978
|
` ${item.stage} ${obligationName(item)}${item.target ? ` [${item.target}]` : ""}` +
|
|
851
979
|
(item.claim ? `: ${item.claim.text}` : "") + `\n ${item.reason}` +
|
|
852
|
-
(item.
|
|
980
|
+
(item.nativeEvidence ? `\n ${nativeEvidenceText(item).replaceAll("\n","\n ")}` : "") +
|
|
981
|
+
(item.lastNativeRun ? `\n last native run passed at ${item.lastNativeRun.passed} (seed ${item.lastNativeRun.seed})` : "") +
|
|
982
|
+
(item.against ? `\n last recorded passing run in environment ${item.environment} (run ${item.environmentRun.id}) against ` +
|
|
853
983
|
item.against.map(dependencyText).join("; ") : "")).join("\n");
|
|
854
984
|
})
|
|
855
985
|
.filter((section) => section !== null),
|
|
@@ -859,7 +989,8 @@ async function main() {
|
|
|
859
989
|
// Where the tests ran: reporting only, so no status above changes.
|
|
860
990
|
...environments.map((e) => `ENVIRONMENT ${e.environment} (run ${e.run.id}, recorded ${e.run.recordedAt})\n` +
|
|
861
991
|
e.dependencies.map((d) => ` ${dependencyText(d)}; ` + (d.obligations.length
|
|
862
|
-
? `${d.obligations.length} tested obligation(s)` :
|
|
992
|
+
? `${d.obligations.length} tested obligation(s)` :
|
|
993
|
+
d.plannedObligations?.length ? `${d.plannedObligations.length} planned obligation(s); no completed run linked` : "no tested obligation relies on it")).join("\n"))]
|
|
863
994
|
.join("\n\n"),
|
|
864
995
|
);
|
|
865
996
|
return;
|
|
@@ -872,17 +1003,19 @@ async function main() {
|
|
|
872
1003
|
({ e }) => !positional[0] || `${e.owner}::${e.name}` === positional[0],
|
|
873
1004
|
);
|
|
874
1005
|
if (!indices.length) throw new Error("No matching law");
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
);
|
|
1006
|
+
const view = options.view ?? "developer";
|
|
1007
|
+
if (!explanationViews.includes(view)) throw new Error(`Choose --view ${explanationViews.join("|")}`);
|
|
1008
|
+
const observed={...result,evidence:attachNativeEvidence(result.evidence,await readNativeObservations({
|
|
1009
|
+
compiler,input,selected,roots,configRoot,build:await buildDigest(),evidence:result.evidence,
|
|
1010
|
+
attestation:await readAttestation(config)}))};
|
|
1011
|
+
const explanations = indices.map(({e}) => explainLaw(e, observed, view));
|
|
1012
|
+
output(options.json ? explanations : explanations.map(e => e.text).join("\n\n"));
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
if (verb === "test" && !options.benchmarks && config.version === 2 && !(config.verification?.layers ?? []).some(layer => ["exhaustive", "property", "examples", "model"].includes(layer))) {
|
|
1016
|
+
const checked = diagnostics(await compiler.check(input));
|
|
1017
|
+
output(options.json ? { verification: checked.verification, evidence: checked.evidence, testsExecuted: 0 }
|
|
1018
|
+
: (config.verification?.layers?.length ? "No native law checks selected. See lawspec evidence for the selected static analyses." : "No law verification layers selected. Intrinsic definition checks passed; no law checks ran."));
|
|
886
1019
|
return;
|
|
887
1020
|
}
|
|
888
1021
|
if (verb === "test") return runTests(compiler, input, selected, roots, config);
|