lawspec 0.26.0 → 0.28.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 +178 -1
- package/NORMALIZATION-LICENSES.txt +296 -0
- package/README.md +8 -0
- package/bin/lawspec.mjs +126 -33
- package/build.json +159 -131
- package/builtin-data-names.mjs +4 -4
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -5
- package/doctor.mjs +14 -4
- package/examples/native-payments/elixir/lib/payments_domain.ex +1 -1
- package/examples/native-payments/erlang/src/payments_domain.erl +1 -1
- package/examples/native-payments/prolog/lawspec.json +20 -0
- package/examples/native-payments/prolog/src/domain/payments.pl +23 -0
- package/examples/native-payments/prolog/tests/domain/payment_generators.pl +17 -0
- package/examples/rc1/bit-codec.lawspec +6 -6
- package/examples/rc1/native-payments.lawspec +6 -6
- package/examples/rc1/nesting/rrr.lawspec +2 -2
- package/examples/rc1/nesting/rru.lawspec +4 -4
- package/examples/rc1/nesting/rur.lawspec +4 -4
- package/examples/rc1/nesting/ruu.lawspec +5 -5
- package/examples/rc1/nesting/urr.lawspec +4 -4
- package/examples/rc1/nesting/uru.lawspec +5 -5
- package/examples/rc1/nesting/uur.lawspec +5 -5
- package/examples/rc1/nesting/uuu.lawspec +6 -6
- package/examples/rc1/recursive-records.lawspec +5 -5
- package/examples/rc1/refund-policy.lawspec +4 -0
- package/examples/specs/approvals.lawspec +3 -3
- package/examples/specs/builtins.lawspec +2 -2
- package/examples/specs/collections.lawspec +8 -8
- package/examples/specs/composition.lawspec +10 -10
- package/examples/specs/contracts.lawspec +2 -2
- package/examples/specs/crypto.lawspec +2 -2
- package/examples/specs/domain_modeling.lawspec +20 -0
- package/examples/specs/flow_stack.lawspec +4 -4
- package/examples/specs/generation.lawspec +2 -2
- package/examples/specs/limits.lawspec +1 -1
- package/examples/specs/list_contracts.lawspec +3 -3
- package/examples/specs/lists.lawspec +6 -6
- package/examples/specs/matching.lawspec +8 -8
- package/examples/specs/payments.lawspec +5 -5
- package/examples/specs/records.lawspec +4 -4
- package/examples/specs/refinements.lawspec +4 -0
- package/examples/specs/resilience.lawspec +2 -2
- package/examples/specs/resources.lawspec +5 -5
- package/examples/specs/sequences.lawspec +1 -1
- package/examples/specs/sum_refinements.lawspec +11 -11
- package/examples-command.mjs +3 -1
- package/index.d.ts +160 -4
- package/native-evidence.mjs +25 -12
- package/native-examples.mjs +1 -1
- package/package.json +2 -1
- package/proof.d.ts +57 -12
- package/proof.mjs +277 -13
- package/templates.mjs +84 -3
- package/test-command.mjs +40 -4
package/bin/lawspec.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { readFile, mkdir, readdir, rm, stat, writeFile } from "node:fs/promises"
|
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { createCompiler } from "../api.mjs";
|
|
7
|
-
import { targets, templates, commands, setup } from "../templates.mjs";
|
|
7
|
+
import { targets, artifactTargets, templates, commands, setup } from "../templates.mjs";
|
|
8
8
|
import { generateExamples } from "../examples-command.mjs";
|
|
9
9
|
import { proveWithZ3 } from "../proof.mjs";
|
|
10
10
|
import { serveLanguage } from "../lsp.mjs";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
safePath,
|
|
27
27
|
collectSources,
|
|
28
28
|
} from "../files.mjs";
|
|
29
|
-
const VERSION = "0.
|
|
29
|
+
const VERSION = "0.28.0";
|
|
30
30
|
const args = process.argv.slice(2);
|
|
31
31
|
const verb = args.shift();
|
|
32
32
|
const options = {};
|
|
@@ -56,10 +56,13 @@ const output = (value) =>
|
|
|
56
56
|
const shellQuote = (value) =>
|
|
57
57
|
"'" + String(value).replaceAll("'", "'\\''") + "'";
|
|
58
58
|
function testCommand(target, root) {
|
|
59
|
+
if (artifactTargets.includes(target.language)) return null;
|
|
59
60
|
const testDir = target.testDir || "test";
|
|
60
61
|
let command = commands[target.language];
|
|
61
62
|
if (target.language === "python")
|
|
62
63
|
command = `${shellQuote(target.python || "python3")} -m pytest`;
|
|
64
|
+
if (target.language === "prolog")
|
|
65
|
+
command = `${shellQuote(target.python || "python3")} lawspec_test.py`;
|
|
63
66
|
if (target.language === "java")
|
|
64
67
|
command = `${shellQuote(target.maven || "mvn")} test`;
|
|
65
68
|
if (target.language === "kotlin")
|
|
@@ -72,6 +75,13 @@ function testCommand(target, root) {
|
|
|
72
75
|
command = `npm exec -- tsc -p tsconfig.json && node --test ${shellQuote("dist/" + testDir)}/*.test.js`;
|
|
73
76
|
return `(cd ${shellQuote(root)} && ${command})`;
|
|
74
77
|
}
|
|
78
|
+
// A refuted law fails the command, but evidence still lists it: the
|
|
79
|
+
// diagnostics then only say which laws are refuted.
|
|
80
|
+
function refutedOnly(result) {
|
|
81
|
+
return result.diagnostics?.length && result.diagnostics.every((d) => d.code === "refuted") && result.evidence
|
|
82
|
+
? { ...result, refuted: result.diagnostics, diagnostics: [] } : result;
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
function diagnostics(result) {
|
|
76
86
|
if (result.diagnostics?.length)
|
|
77
87
|
throw Object.assign(
|
|
@@ -237,7 +247,9 @@ async function init() {
|
|
|
237
247
|
if (current === null)
|
|
238
248
|
await atomicWrite(
|
|
239
249
|
starter,
|
|
240
|
-
|
|
250
|
+
artifactTargets.includes(language) && language !== "make"
|
|
251
|
+
? "unit configuration\ntype Settings is a record{port :: UInt16 enabled :: Bool} end type\nfunction settings (unused :: Unit) -> Settings is Settings record{port = 8080, enabled = true} end function\nend unit\n"
|
|
252
|
+
: await readFile(new URL("../starter-rc1.lawspec", import.meta.url), "utf8"),
|
|
241
253
|
true,
|
|
242
254
|
);
|
|
243
255
|
if (options.machineBits !== undefined) config.machineBits = options.machineBits;
|
|
@@ -291,10 +303,23 @@ async function lastRuns() {
|
|
|
291
303
|
const folder = path.join(configRoot, ".lawspec", "results");
|
|
292
304
|
const runs = new Map();
|
|
293
305
|
const attestations = new Map();
|
|
306
|
+
// The outcome each law last had in each attested run, by run id; across
|
|
307
|
+
// targets a failure outweighs a pass.
|
|
308
|
+
const outcomes = new Map();
|
|
309
|
+
const rank = (o) => ["passed", "known-failing", "skipped", "incomplete", "failed"].indexOf(o);
|
|
294
310
|
for (const name of (await readOptionalDirectory(folder)) ?? []) {
|
|
295
311
|
if (!name.endsWith(".json")) continue;
|
|
296
312
|
const recorded = JSON.parse((await readOptional(path.join(folder, name))) ?? "{}");
|
|
297
313
|
for (const [id, attestation] of Object.entries(recorded.attestations ?? {})) attestations.set(id, attestation);
|
|
314
|
+
const outcome = (id, law, value) => {
|
|
315
|
+
const known = outcomes.get(id) ?? {};
|
|
316
|
+
if (known[law] === undefined || rank(value) > rank(known[law])) known[law] = value;
|
|
317
|
+
outcomes.set(id, known);
|
|
318
|
+
};
|
|
319
|
+
for (const [law, attempt] of Object.entries(recorded.attempts ?? {}))
|
|
320
|
+
if (attempt.environment) outcome(attempt.environment, law, attempt.outcome);
|
|
321
|
+
for (const [law, run] of Object.entries(recorded.laws ?? {}))
|
|
322
|
+
if (run.environment && recorded.attempts?.[law]?.environment !== run.environment) outcome(run.environment, law, "passed");
|
|
298
323
|
for (const [law, run] of Object.entries(recorded.laws ?? {})) {
|
|
299
324
|
const known = runs.get(law) ?? {};
|
|
300
325
|
const latest = (known.passed ?? "") > (run.passed ?? "") ? known : run;
|
|
@@ -302,7 +327,7 @@ async function lastRuns() {
|
|
|
302
327
|
passed: latest.passed, seed: latest.seed, environment: latest.environment });
|
|
303
328
|
}
|
|
304
329
|
}
|
|
305
|
-
return { runs, attestations };
|
|
330
|
+
return { runs, attestations, outcomes };
|
|
306
331
|
}
|
|
307
332
|
// An environment attestation: a versioned JSON document any tool may write,
|
|
308
333
|
// recording for one run where each dependency was wired and whether it was
|
|
@@ -323,10 +348,29 @@ async function readAttestation(config) {
|
|
|
323
348
|
// One attested dependency, as lawspec evidence shows it.
|
|
324
349
|
function dependencyText(d) {
|
|
325
350
|
const level = (c) => /^[0-9]+$/.test(c) ? `conformance level ${c}` : `conformance ${c}`;
|
|
351
|
+
const ran = d.ranAgainst ?? {};
|
|
352
|
+
const history = ran.historyDigest ?? d.standIn?.historyDigest;
|
|
326
353
|
return `${d.dependency}: ` + (d.standIn
|
|
327
354
|
? `stand-in ${d.standIn.identity} ${d.standIn.version} (${level(d.standIn.conformance)}` +
|
|
328
|
-
(
|
|
329
|
-
: "real") + ` at ${d.endpoint}` + (d.reached ? "" : " (not reached when recorded)")
|
|
355
|
+
(history ? `, history ${history}${ran.historyFrom === "completed" ? " when completed" : ""}` : "") + ")"
|
|
356
|
+
: "real") + ` at ${d.endpoint}` + (d.reached ? "" : " (not reached when recorded)") +
|
|
357
|
+
(d.implementation ? `; ${d.implementation.kind} ${d.implementation.product} ${d.implementation.version}` : "") +
|
|
358
|
+
(d.contract ? `; contract ${d.contract.package} ${d.contract.version}` : "") +
|
|
359
|
+
(d.node ? `; node ${d.node}` + (d.edge ? ` via ${d.edge}` : "") : "") +
|
|
360
|
+
(d.completed && !d.completed.reached ? " (not reached when completed)" : "");
|
|
361
|
+
}
|
|
362
|
+
// What an attested run's document records, as lawspec evidence shows it.
|
|
363
|
+
function executionText(run) {
|
|
364
|
+
const e = run?.execution;
|
|
365
|
+
if (!e) return "";
|
|
366
|
+
return e.status === "completed" ? `, completed with exit code ${e.exitCode}` :
|
|
367
|
+
e.status === "running" ? ", in progress" : ", wiring only";
|
|
368
|
+
}
|
|
369
|
+
// Why a law relying on an attested dependency has no completed run linked.
|
|
370
|
+
function unlinkedText(run) {
|
|
371
|
+
const status = run?.execution?.status;
|
|
372
|
+
return status === "wired" ? "wiring only; nothing ran" :
|
|
373
|
+
status === "running" ? "run in progress; no completed run linked" : "no completed run linked";
|
|
330
374
|
}
|
|
331
375
|
// One law's harness, as lawspec evidence shows it.
|
|
332
376
|
function harnessText(item) {
|
|
@@ -345,9 +389,7 @@ function harnessText(item) {
|
|
|
345
389
|
if (h.skip) parts.push(`skip "${h.skip}"`);
|
|
346
390
|
if (h.knownFailing) parts.push(`known failing "${h.knownFailing}"`);
|
|
347
391
|
if (h.orderRandom) parts.push("order random");
|
|
348
|
-
|
|
349
|
-
// pytest-xdist; without it, parallel changes nothing there.
|
|
350
|
-
if (h.parallel) parts.push("parallel (on Python only with pytest-xdist; otherwise one after another)");
|
|
392
|
+
if (h.parallel) parts.push("parallel");
|
|
351
393
|
const lines = [` ${item.declaration.replace("::law::", "::")}: ${parts.join("; ") || "no harness settings"}`];
|
|
352
394
|
for (const run of item.adequacy ?? []) {
|
|
353
395
|
lines.push(` last run: ${run.cases} generated case(s)` +
|
|
@@ -487,12 +529,11 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
487
529
|
if (beam || target.language === "scala") await rm(coverage, {recursive: true, force: true});
|
|
488
530
|
await mkdir(beam ? path.join(coverage, "runs") : coverage, { recursive: true });
|
|
489
531
|
}
|
|
490
|
-
//
|
|
491
|
-
//
|
|
532
|
+
// Python may use xdist processes; the host harness otherwise supplies
|
|
533
|
+
// its existing thread scheduler, which Prolog also uses through Janus.
|
|
492
534
|
let xdist = false;
|
|
493
535
|
if (target.language === "python" && stale.some((entry) => entry.parallel)) {
|
|
494
536
|
xdist = spawnSync(target.python || "python3", ["-c", "import xdist"], { cwd: root, stdio: "ignore" }).status === 0;
|
|
495
|
-
if (!xdist) console.error("python: `parallel` runs tests at the same time only with pytest-xdist (pip install pytest-xdist); without it they run one after another.");
|
|
496
537
|
}
|
|
497
538
|
// A skipped law runs nothing. BEAM known-failing checks finish as native
|
|
498
539
|
// passing tests, so their completion must appear in the native report.
|
|
@@ -579,10 +620,14 @@ async function runTests(compiler, input, selected, roots, config) {
|
|
|
579
620
|
await writeFile(databaseFile, JSON.stringify(database, null, 2) + "\n");
|
|
580
621
|
await mkdir(path.dirname(resultsFile), { recursive: true });
|
|
581
622
|
await writeFile(path.join(path.dirname(resultsFile), ".gitignore"), "*\n");
|
|
623
|
+
// Each attempt at a law the attestation touches names the run it was
|
|
624
|
+
// made in, whatever its outcome.
|
|
625
|
+
if (attestation) for (const entry of stale)
|
|
626
|
+
if (attested.has(entry.law) && attempts[entry.law]) attempts[entry.law] = { ...attempts[entry.law], environment: attestation.run.id };
|
|
582
627
|
// Each attestation a recorded law ran under is kept with the results.
|
|
583
628
|
const attestations = Object.fromEntries(Object.entries({ ...(previous.attestations ?? {}),
|
|
584
629
|
...(attestation ? { [attestation.run.id]: attestation } : {}) })
|
|
585
|
-
.filter(([id]) => Object.values(laws).some((run) => run.environment === id)));
|
|
630
|
+
.filter(([id]) => [...Object.values(laws), ...Object.values(attempts)].some((run) => run.environment === id)));
|
|
586
631
|
await atomicWrite(resultsFile, JSON.stringify({ version: 1, laws, attempts,
|
|
587
632
|
...(Object.keys(attestations).length ? { attestations } : {}) }, null, 2) + "\n");
|
|
588
633
|
const flaky = statistics.filter((s) => s.outcome === "flaky").map((s) => s.law);
|
|
@@ -785,8 +830,11 @@ async function main() {
|
|
|
785
830
|
"Expected lawspec.json version 2 with languageProfile 1.0-rc.2, sources and targets arrays",
|
|
786
831
|
);
|
|
787
832
|
if (config.languageProfile !== "1.0-rc.2") throw new Error("Configuration version 2 requires languageProfile 1.0-rc.2");
|
|
833
|
+
if (verb === "test" && artifactTargets.includes(options.target))
|
|
834
|
+
throw new Error(`${options.target} is an artifact target and cannot execute application laws`);
|
|
788
835
|
const selected = config.targets.filter(
|
|
789
|
-
(t) => !options.target || t.language === options.target
|
|
836
|
+
(t) => (!options.target || t.language === options.target) &&
|
|
837
|
+
(verb !== "test" || !artifactTargets.includes(t.language)),
|
|
790
838
|
);
|
|
791
839
|
if (["doctor", "generate", "test"].includes(verb) && !selected.length &&
|
|
792
840
|
!(verb === "test" && !options.benchmarks && config.version === 2 && !(config.verification?.layers ?? []).some(layer => ["exhaustive", "property", "examples", "model"].includes(layer))))
|
|
@@ -804,7 +852,7 @@ async function main() {
|
|
|
804
852
|
: reports
|
|
805
853
|
.map(
|
|
806
854
|
(r) =>
|
|
807
|
-
`${r.target}: ${r.ok ? "ready" : `${r.message}\n${r.instructions}`}`,
|
|
855
|
+
`${r.target}: ${r.ok ? (r.kind === "artifact" ? "generation ready" : "ready") : `${r.message}\n${r.instructions}`}`,
|
|
808
856
|
)
|
|
809
857
|
.join("\n"),
|
|
810
858
|
);
|
|
@@ -823,6 +871,10 @@ async function main() {
|
|
|
823
871
|
...(await packageInput(config, configRoot)),
|
|
824
872
|
generation: config.generation,
|
|
825
873
|
machineBits: options.machineBits ?? config.machineBits ?? 64,
|
|
874
|
+
// What a law-set exemption's until is compared with: the project's
|
|
875
|
+
// version and the current UTC time.
|
|
876
|
+
...(typeof config.projectVersion === "string" ? { projectVersion: config.projectVersion } : {}),
|
|
877
|
+
now: new Date().toISOString(),
|
|
826
878
|
};
|
|
827
879
|
const compiler = await createCompiler();
|
|
828
880
|
if (verb === "prove") {
|
|
@@ -834,11 +886,13 @@ async function main() {
|
|
|
834
886
|
.filter(([name]) => options[name] !== undefined).map(([name,key]) => [key,Number(options[name])])),
|
|
835
887
|
}));
|
|
836
888
|
output(options.json ? result : result.solverEvidence.length
|
|
837
|
-
? result.solverEvidence.map(row => `${row.declaration}: ${row.status} (${row.outcome}). ${row.reason}`).join("\n")
|
|
889
|
+
? result.solverEvidence.map(row => `${row.declaration}${row.kind === "analysis" ? ` ${row.stage}` : ""}: ${row.status} (${row.outcome}). ${row.reason}`).join("\n")
|
|
838
890
|
: (input.verification?.layers.includes("proof")
|
|
839
891
|
? "No source law obligations are available. No solver was invoked."
|
|
840
892
|
: "No proof layer selected. Intrinsic definition checks passed; no solver was invoked."));
|
|
841
|
-
|
|
893
|
+
// A refuted law is a definite failure; anything else not proved is incomplete.
|
|
894
|
+
if (result.solverEvidence.some(row => row.status === "refuted")) process.exitCode = 1;
|
|
895
|
+
else if (result.solverEvidence.some(row => !["proved", "exempted"].includes(row.status))) process.exitCode = 2;
|
|
842
896
|
return;
|
|
843
897
|
}
|
|
844
898
|
// Each obligation reports how it is discharged, strongest first.
|
|
@@ -850,11 +904,17 @@ async function main() {
|
|
|
850
904
|
["runtime-checked", "RUNTIME CHECKED"],
|
|
851
905
|
["default-handler", "DEFAULT HANDLER"],
|
|
852
906
|
["assumed", "ASSUMED / EXTERNAL"],
|
|
907
|
+
// A law-set check a laws-for block excuses, with its reason and expiry.
|
|
908
|
+
["exempted", "EXEMPTED"],
|
|
909
|
+
// A law a confirmed counterexample shows false; the build fails.
|
|
910
|
+
["refuted", "REFUTED"],
|
|
853
911
|
// The harness plane: a law it marks as known to fail, a law whose last
|
|
854
912
|
// run was flaky, and a law whose tests it skips.
|
|
855
913
|
["known-failing", "KNOWN FAILING"],
|
|
856
914
|
["flaky", "FLAKY"],
|
|
857
915
|
["skipped", "SKIPPED"],
|
|
916
|
+
// A law about an open history that the entries so far do not decide.
|
|
917
|
+
["pending", "PENDING"],
|
|
858
918
|
["planned", "PLANNED"],
|
|
859
919
|
["not-verified", "NOT VERIFIED"],
|
|
860
920
|
["incomplete", "INCOMPLETE"],
|
|
@@ -863,9 +923,9 @@ async function main() {
|
|
|
863
923
|
const evidenceSummary = (evidence) => {
|
|
864
924
|
if (!evidence.length) return "";
|
|
865
925
|
const count = (status) => evidence.filter((item) => item.status === status).length;
|
|
866
|
-
//
|
|
867
|
-
//
|
|
868
|
-
const harnessFrom = statuses.findIndex(([status]) => status === "
|
|
926
|
+
// Exempted, refuted and the harness statuses (after assumed) are counted only when
|
|
927
|
+
// some obligation has them.
|
|
928
|
+
const harnessFrom = statuses.findIndex(([status]) => status === "exempted");
|
|
869
929
|
const shown = statuses.filter(([status], i) => i < harnessFrom || count(status));
|
|
870
930
|
return ` Evidence: ${shown.map(([status, label]) => `${count(status)} ${label.toLowerCase()}`).join(", ")}.`;
|
|
871
931
|
};
|
|
@@ -890,22 +950,41 @@ async function main() {
|
|
|
890
950
|
if (verb === "evidence") {
|
|
891
951
|
// An attestation named here, or in lawspec.json, says where the tests
|
|
892
952
|
// ran; otherwise each law shows the attested run it last passed in.
|
|
953
|
+
// A named attestation of a run lawspec test recorded links each law to
|
|
954
|
+
// that run, with the outcome recorded for it, unless the document says
|
|
955
|
+
// the run has not completed.
|
|
893
956
|
const named = await readAttestation(config);
|
|
894
|
-
const
|
|
957
|
+
const { runs, attestations, outcomes } = await lastRuns();
|
|
958
|
+
const recorded = named && typeof named.run?.id === "string" ? outcomes.get(named.run.id) : undefined;
|
|
959
|
+
const result = diagnostics(refutedOnly(await compiler.check({ ...input,
|
|
960
|
+
...(named ? { attestation: named, ...(recorded ? { attestedOutcomes: recorded } : {}) } : {}) })));
|
|
961
|
+
if (result.refuted) process.exitCode = 1;
|
|
895
962
|
let evidence = attachNativeEvidence(result.evidence,await readNativeObservations({compiler,input,selected,roots,
|
|
896
963
|
configRoot,build:await buildDigest(),evidence:result.evidence,attestation:named}));
|
|
897
|
-
const { runs, attestations } = await lastRuns();
|
|
898
964
|
const environments = named ? [result.attestation] : [];
|
|
899
965
|
if (!named) for (const [id, attestation] of attestations) {
|
|
900
966
|
const laws = new Set([...runs].filter(([, run]) => run.environment === id).map(([law]) => law));
|
|
901
967
|
if (!laws.size) continue;
|
|
902
|
-
const attested = diagnostics(await compiler.check({ ...input, attestation }));
|
|
968
|
+
const attested = diagnostics(await compiler.check({ ...input, attestation, attestedOutcomes: outcomes.get(id) ?? {} }));
|
|
903
969
|
const fields = new Map(attested.evidence.filter((item) => (item.against || item.plannedAgainst) && laws.has(item.declaration))
|
|
904
|
-
.map(item =>
|
|
905
|
-
|
|
970
|
+
.map(item => {
|
|
971
|
+
// Receipts predating execution states keep their historical meaning.
|
|
972
|
+
// An explicit running/wired state must retain the compiler's planned
|
|
973
|
+
// fields; a cached passing law does not complete its environment run.
|
|
974
|
+
const legacy = !attestation.execution && !item.against;
|
|
975
|
+
return [item.declaration, legacy ? {
|
|
976
|
+
environment: item.plannedEnvironment, environmentRun: item.plannedEnvironmentRun,
|
|
977
|
+
against: item.plannedAgainst, environmentProviders: item.plannedEnvironmentProviders,
|
|
978
|
+
} : Object.fromEntries(["environment", "environmentRun", "against", "environmentProviders", "environmentOutcome",
|
|
979
|
+
"plannedEnvironment", "plannedEnvironmentRun", "plannedAgainst", "plannedEnvironmentProviders"]
|
|
980
|
+
.filter(key => item[key] !== undefined).map(key => [key, item[key]]))];
|
|
981
|
+
}));
|
|
906
982
|
evidence = evidence.map((item) => item.stage === "law" && fields.has(item.declaration) ? { ...item, ...fields.get(item.declaration) } : item);
|
|
907
983
|
environments.push({ ...attested.attestation, dependencies: attested.attestation.dependencies
|
|
908
|
-
.map((d) => ({ ...d,
|
|
984
|
+
.map((d) => ({ ...d,
|
|
985
|
+
obligations: (attestation.execution ? d.obligations : [...new Set([...d.obligations, ...(d.plannedObligations ?? [])])])
|
|
986
|
+
.filter((law) => laws.has(law)),
|
|
987
|
+
plannedObligations: attestation.execution ? (d.plannedObligations ?? []).filter((law) => laws.has(law)) : [] })) });
|
|
909
988
|
}
|
|
910
989
|
// Native bindings are configured per target; their obligations are added.
|
|
911
990
|
for (const target of selected) {
|
|
@@ -941,18 +1020,32 @@ async function main() {
|
|
|
941
1020
|
(item.claim ? `: ${item.claim.text}` : "") + `\n ${item.reason}` +
|
|
942
1021
|
(item.nativeEvidence ? `\n ${nativeEvidenceText(item).replaceAll("\n","\n ")}` : "") +
|
|
943
1022
|
(item.lastNativeRun ? `\n last native run passed at ${item.lastNativeRun.passed} (seed ${item.lastNativeRun.seed})` : "") +
|
|
944
|
-
(item.against ?
|
|
945
|
-
item.
|
|
1023
|
+
(item.against ? (item.environmentOutcome
|
|
1024
|
+
? `\n ${item.environmentOutcome} in completed run ${item.environmentRun.id} in environment ${item.environment}${executionText(item.environmentRun)} against `
|
|
1025
|
+
: `\n last recorded passing run in environment ${item.environment} (run ${item.environmentRun.id}) against `) +
|
|
1026
|
+
item.against.map(dependencyText).join("; ") : "") +
|
|
1027
|
+
(item.plannedAgainst ? `\n planned in environment ${item.plannedEnvironment} (run ${item.plannedEnvironmentRun.id}` +
|
|
1028
|
+
`${executionText(item.plannedEnvironmentRun)}; ${unlinkedText(item.plannedEnvironmentRun)}) against ` +
|
|
1029
|
+
item.plannedAgainst.map(dependencyText).join("; ") : "")).join("\n");
|
|
946
1030
|
})
|
|
947
1031
|
.filter((section) => section !== null),
|
|
948
1032
|
// How each law is discharged: the harness plane, apart from what
|
|
949
1033
|
// the laws say.
|
|
950
1034
|
...(harnessed.length ? [`HARNESS (${harnessed.length})\n` + harnessed.map(harnessText).join("\n")] : []),
|
|
951
1035
|
// Where the tests ran: reporting only, so no status above changes.
|
|
952
|
-
...environments.map((e) => `ENVIRONMENT ${e.environment} (run ${e.run.id}, recorded ${e.run.recordedAt})\n` +
|
|
953
|
-
e.
|
|
954
|
-
?
|
|
955
|
-
|
|
1036
|
+
...environments.map((e) => `ENVIRONMENT ${e.environment} (run ${e.run.id}, recorded ${e.run.recordedAt}${executionText(e.run)})\n` +
|
|
1037
|
+
(e.architecture ? ` architecture ${e.architecture.document} ${e.architecture.digest}` +
|
|
1038
|
+
(e.architecture.topologyDigest ? `, topology ${e.architecture.topologyDigest}` : "") + "\n" : "") +
|
|
1039
|
+
(e.application ? ` application ${e.application.node}: contract ${e.application.contract.package} ${e.application.contract.version}; ` +
|
|
1040
|
+
`${e.application.implementation.kind} ${e.application.implementation.product} ${e.application.implementation.version}` +
|
|
1041
|
+
(e.application.implementation.commit ? ` (commit ${e.application.implementation.commit})` : "") + "\n" : "") +
|
|
1042
|
+
e.dependencies.map((d) => {
|
|
1043
|
+
const outcome = (o) => evidence.find((item) => item.declaration === o && item.environmentOutcome)?.environmentOutcome;
|
|
1044
|
+
const failed = d.obligations.filter((o) => ["failed", "incomplete"].includes(outcome(o))).length;
|
|
1045
|
+
return ` ${dependencyText(d)}; ` + (d.obligations.length
|
|
1046
|
+
? `${d.obligations.length} tested obligation(s)` + (failed ? `, ${failed} failed` : "") :
|
|
1047
|
+
d.plannedObligations?.length ? `${d.plannedObligations.length} planned obligation(s); ${unlinkedText(e.run)}` : "no tested obligation relies on it");
|
|
1048
|
+
}).join("\n"))]
|
|
956
1049
|
.join("\n\n"),
|
|
957
1050
|
);
|
|
958
1051
|
return;
|
|
@@ -1024,7 +1117,7 @@ async function main() {
|
|
|
1024
1117
|
: summary
|
|
1025
1118
|
.map(
|
|
1026
1119
|
(r) =>
|
|
1027
|
-
`${r.target}: ${r.changes.length} ${options["dry-run"] || options.check ? "planned" : "applied"} change(s), ${r.preservedAdapters.length} user adapter(s) preserved.${r.adapterUpdates.length ? "\nReview required adapter signatures:\n" + r.adapterUpdates.map((a) => a.path + "\n" + a.requiredAdapter).join("\n") : ""}\
|
|
1120
|
+
`${r.target}: ${r.changes.length} ${options["dry-run"] || options.check ? "planned" : "applied"} change(s), ${r.preservedAdapters.length} user adapter(s) preserved.${r.adapterUpdates.length ? "\nReview required adapter signatures:\n" + r.adapterUpdates.map((a) => a.path + "\n" + a.requiredAdapter).join("\n") : ""}\n${r.test === null ? "Artifact generation complete." : "Test: " + r.test}`,
|
|
1028
1121
|
)
|
|
1029
1122
|
.join("\n"),
|
|
1030
1123
|
);
|