lawspec 0.14.0 → 0.15.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/API-MIGRATION.md +19 -0
- package/LANGUAGE.md +54 -8
- package/PRIMITIVES.md +1 -1
- package/README.md +27 -14
- package/REFINEMENTS.md +1 -1
- package/RELEASE-0.15.md +44 -0
- package/bin/lawspec.mjs +44 -6
- package/build.json +15 -13
- package/core.wasm +0 -0
- package/index.d.ts +17 -0
- package/package.json +2 -2
package/API-MIGRATION.md
CHANGED
|
@@ -318,3 +318,22 @@ Imported declarations need no new wire forms. Data declarations keep the ID of
|
|
|
318
318
|
the unit that declares them. An imported checked definition appears among the
|
|
319
319
|
importing unit's definitions with a name derived from its unit
|
|
320
320
|
(`shop.orders::shopDomainCentsOf`).
|
|
321
|
+
|
|
322
|
+
## Evidence and discharge (0.15)
|
|
323
|
+
|
|
324
|
+
`evidence` items now cover every obligation, and `status` is one of `proved`,
|
|
325
|
+
`exhaustively-checked`, `property-tested`, `runtime-checked` or `assumed`
|
|
326
|
+
(`DischargeStatus`). New stages:
|
|
327
|
+
|
|
328
|
+
- `law`: `declaration` is the law's identity (`unit::law::name`) and `claim` the
|
|
329
|
+
law as a Boolean expression over its inputs;
|
|
330
|
+
- `adapter`: an adapter declaration, `assumed`, with `claim: null`;
|
|
331
|
+
- with native bindings: `binding` (`runtime-checked`), `codec`, `generator` and
|
|
332
|
+
`native-function` (`assumed`), each with `claim: null`.
|
|
333
|
+
|
|
334
|
+
Clients that compared `status` against `proved` and `runtime-checked` only must
|
|
335
|
+
handle the new values. Law obligations come first, then contracts,
|
|
336
|
+
adapters, constructions and bindings.
|
|
337
|
+
|
|
338
|
+
A false law over checked definitions with a finite domain is now reported as a
|
|
339
|
+
diagnostic with code `refuted` instead of compiling.
|
package/LANGUAGE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# LawSpec language and compiler boundary (0.
|
|
1
|
+
# LawSpec language and compiler boundary (0.15)
|
|
2
2
|
|
|
3
3
|
LawSpec describes portable laws, concrete examples, and adapter contracts. The
|
|
4
4
|
compiler is written in Haskell. Rust is an output backend alongside Java, Python,
|
|
@@ -204,15 +204,57 @@ recursive call contributes its own signature as the induction hypothesis, and
|
|
|
204
204
|
natural measures are non-negative. A definition whose result index does not
|
|
205
205
|
follow fails with `definition result refinement could not be proved`.
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
native code that LawSpec cannot inspect, so both are `runtime-checked`.
|
|
211
|
-
`lawspec check` summarizes the evidence, and the API reports each obligation in
|
|
212
|
-
the `evidence` field. A proved definition is a natural reference model for a
|
|
207
|
+
Definition postconditions are `proved`, and generated code omits their runtime
|
|
208
|
+
checks; see [evidence and discharge](#evidence-and-discharge) for every other
|
|
209
|
+
obligation. A proved definition is a natural reference model for a
|
|
213
210
|
native adapter, as in `append xs ys = concatV xs ys` in the
|
|
214
211
|
[indexed example](examples/specs/indexed_families.lawspec).
|
|
215
212
|
|
|
213
|
+
## Evidence and discharge
|
|
214
|
+
|
|
215
|
+
Every obligation of a program reports how it is discharged, strongest first:
|
|
216
|
+
|
|
217
|
+
| Status | Obligations | How |
|
|
218
|
+
| --- | --- | --- |
|
|
219
|
+
| `PROVED` | laws over checked definitions; definition postconditions and indices | statically, by the prover |
|
|
220
|
+
| `EXHAUSTIVELY CHECKED` | laws whose inputs form a finite domain | every input, by the compiler or the generated tests |
|
|
221
|
+
| `PROPERTY TESTED` | other laws | generated cases, boundary cases and examples |
|
|
222
|
+
| `RUNTIME CHECKED` | adapter contracts, definition preconditions, constructor constraints, native type bindings | at every native boundary |
|
|
223
|
+
| `ASSUMED / EXTERNAL` | adapters, native functions, custom generators and codec hooks | taken on trust |
|
|
224
|
+
|
|
225
|
+
A law that calls only checked definitions is attempted as a proof: its claim
|
|
226
|
+
must follow from its input refinements by the same exact linear arithmetic that
|
|
227
|
+
proves definition results. Definitions without preconditions are unfolded
|
|
228
|
+
into the claim; a definition with preconditions stays a call, and its arguments
|
|
229
|
+
must be shown to satisfy them. For example, with
|
|
230
|
+
`definition twice (x :: Int32) :: BigInt is x + x end`, the law
|
|
231
|
+
`` `for all` (x :: Int32) . twice x = x * 2 `` is proved.
|
|
232
|
+
|
|
233
|
+
A law over checked definitions that is not proved but has a finite domain (at
|
|
234
|
+
most `exhaustiveLimit` inputs) is evaluated by the compiler for every input. A
|
|
235
|
+
counterexample is a compile error with code `refuted`:
|
|
236
|
+
|
|
237
|
+
```text
|
|
238
|
+
law always positive is false for x = -128
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
A law that calls an adapter is checked by the generated tests: for every input
|
|
242
|
+
of a finite domain, or else by property testing, with the adapters it relies on
|
|
243
|
+
listed. A law with no inputs has a single case and is exhaustively checked.
|
|
244
|
+
Proved and compiler-checked laws are still emitted as tests, which check the
|
|
245
|
+
generated native definitions.
|
|
246
|
+
|
|
247
|
+
An adapter is native code that LawSpec cannot inspect: its only evidence is the
|
|
248
|
+
laws that call it, and one that no law calls is reported as such. Native type
|
|
249
|
+
bindings decode values through checked codecs, so they are runtime-checked,
|
|
250
|
+
while native functions, custom generators and codec hooks are taken on trust
|
|
251
|
+
(their values are still validated).
|
|
252
|
+
|
|
253
|
+
`lawspec check` summarizes the evidence by status. `lawspec evidence` lists each
|
|
254
|
+
obligation with its claim and reason, grouped by status, and accepts a unit or a
|
|
255
|
+
`unit::declaration` filter; with `--json` it prints the API records. The API
|
|
256
|
+
reports the obligations in the `evidence` field.
|
|
257
|
+
|
|
216
258
|
## Domain modeling
|
|
217
259
|
|
|
218
260
|
### Wrappers and constrained primitives
|
|
@@ -616,7 +658,7 @@ GADTs that refine type arguments.
|
|
|
616
658
|
|
|
617
659
|
Still open: re-exports, and several versions of one package in one build.
|
|
618
660
|
|
|
619
|
-
### 0.15 Evidence/discharge model
|
|
661
|
+
### 0.15 Evidence/discharge model (released)
|
|
620
662
|
|
|
621
663
|
Each obligation reports how it was discharged:
|
|
622
664
|
|
|
@@ -626,6 +668,10 @@ Each obligation reports how it was discharged:
|
|
|
626
668
|
- `RUNTIME CHECKED`: adapter contracts and checked codecs at native boundaries.
|
|
627
669
|
- `ASSUMED / EXTERNAL`: native adapters and bindings taken on trust.
|
|
628
670
|
|
|
671
|
+
Laws over checked definitions are proved or exhaustively evaluated by the
|
|
672
|
+
compiler, and false ones on finite domains are rejected. See
|
|
673
|
+
[evidence and discharge](#evidence-and-discharge).
|
|
674
|
+
|
|
629
675
|
## Generated project formatting
|
|
630
676
|
|
|
631
677
|
`lawspec init --target java` creates a readable Maven scaffold; Kotlin init
|
package/PRIMITIVES.md
CHANGED
package/README.md
CHANGED
|
@@ -91,7 +91,17 @@ and tests the adapters of the contracts they publish. See
|
|
|
91
91
|
[imports and packages](LANGUAGE.md#imports-and-packages), the
|
|
92
92
|
[package example](examples/packages) and the [release notes](RELEASE-0.14.md).
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
## Evidence and discharge in 0.15
|
|
95
|
+
|
|
96
|
+
Every obligation now reports how it is discharged: `PROVED`, `EXHAUSTIVELY
|
|
97
|
+
CHECKED`, `PROPERTY TESTED`, `RUNTIME CHECKED` or `ASSUMED / EXTERNAL`. Laws over
|
|
98
|
+
checked definitions are proved by the compiler's linear-arithmetic prover or,
|
|
99
|
+
on finite domains, evaluated for every input, and a false one is a compile
|
|
100
|
+
error. Laws over adapters are exhaustively or property tested by the generated
|
|
101
|
+
tests, and adapters, native functions and custom generators are listed as taken
|
|
102
|
+
on trust. `lawspec evidence` shows each obligation and why. See
|
|
103
|
+
[evidence and discharge](LANGUAGE.md#evidence-and-discharge) and the
|
|
104
|
+
[release notes](RELEASE-0.15.md).
|
|
95
105
|
|
|
96
106
|
## Install and try it
|
|
97
107
|
|
|
@@ -102,7 +112,7 @@ support to use it; GitHub currently uses the Haskell fallback.
|
|
|
102
112
|
Install [LawSpec from npm](https://www.npmjs.com/package/lawspec):
|
|
103
113
|
|
|
104
114
|
```sh
|
|
105
|
-
npm install --save-dev lawspec@0.
|
|
115
|
+
npm install --save-dev lawspec@0.15.0
|
|
106
116
|
npx lawspec --version
|
|
107
117
|
```
|
|
108
118
|
|
|
@@ -116,8 +126,8 @@ local dependencies so LawSpec can create its `package.json` and test script:
|
|
|
116
126
|
```sh
|
|
117
127
|
mkdir lawspec-example
|
|
118
128
|
cd lawspec-example
|
|
119
|
-
npm exec --package=lawspec@0.
|
|
120
|
-
npm install --save-dev lawspec@0.
|
|
129
|
+
npm exec --package=lawspec@0.15.0 -- lawspec init --target javascript
|
|
130
|
+
npm install --save-dev lawspec@0.15.0
|
|
121
131
|
npx lawspec check
|
|
122
132
|
npx lawspec explain 'example.atoi_codec::itoa and then atoi yields a'
|
|
123
133
|
npx lawspec doctor
|
|
@@ -207,7 +217,10 @@ uses `test/Spec.hs` with `hspec-discover`.
|
|
|
207
217
|
|
|
208
218
|
Commands:
|
|
209
219
|
|
|
210
|
-
- `check`: parse, resolve, type-check and expand laws without target dependencies
|
|
220
|
+
- `check`: parse, resolve, type-check and expand laws without target dependencies,
|
|
221
|
+
and summarize how the obligations are discharged.
|
|
222
|
+
- `evidence [unit | unit::declaration]`: list each obligation, its claim and how
|
|
223
|
+
it is discharged, grouped by status.
|
|
211
224
|
- `explain [unit::law]`: display expansions, example inputs, and expected results.
|
|
212
225
|
- `doctor`: inspect selected native environments and print corrective instructions.
|
|
213
226
|
- `generate`: check environments, validate every output, then write artifacts.
|
|
@@ -332,7 +345,7 @@ reusable laws accept these curried functions, their partial applications, and
|
|
|
332
345
|
scalar parameters. Quantified test inputs remain scalar.
|
|
333
346
|
|
|
334
347
|
The prelude defines the following laws. Every row has an executable example in
|
|
335
|
-
[algebra.lawspec](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
348
|
+
[algebra.lawspec](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/algebra.lawspec), including both sides of every
|
|
336
349
|
combined law. `f` and `g` are binary operations, `inverse` is unary, and `e` and
|
|
337
350
|
`zero` are scalar parameters. All these laws require equality of the element type.
|
|
338
351
|
|
|
@@ -400,7 +413,7 @@ their entire consequence. Every conjunct is type-checked and emitted. As with
|
|
|
400
413
|
existing assertions, the first failure stops that individual test. `and` is now
|
|
401
414
|
a reserved word.
|
|
402
415
|
|
|
403
|
-
[Currying examples](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
416
|
+
[Currying examples](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/currying.lawspec) demonstrate a four-argument
|
|
404
417
|
function partially applied twice, a formatter with four heterogeneous arguments,
|
|
405
418
|
and composition after partial application. Each example states its exact outputs.
|
|
406
419
|
Run `node npm/bin/lawspec.mjs examples` after rebuilding to inspect all nine units
|
|
@@ -452,7 +465,7 @@ law `valid ports round trip` is
|
|
|
452
465
|
end
|
|
453
466
|
```
|
|
454
467
|
|
|
455
|
-
The [complete port example](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
468
|
+
The [complete port example](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/parse_port.lawspec)
|
|
456
469
|
defines valid ports as 1–65535, and covers both endpoints, ordinary ports, zero,
|
|
457
470
|
negative values, and 65536. All explicit `expect` assertions run regardless of
|
|
458
471
|
the law's condition. A false condition skips only the consequence: invalid ports
|
|
@@ -470,7 +483,7 @@ The prelude includes `satisfies predicate` (the predicate holds for every input)
|
|
|
470
483
|
and `left inverse when predicate parse render` (the guarded round trip above).
|
|
471
484
|
These reusable laws preserve the condition and its lexical bindings when expanded.
|
|
472
485
|
`equivalent` can also compare two predicates, since `Bool` supports equality.
|
|
473
|
-
The [Boolean flags example](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
486
|
+
The [Boolean flags example](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/boolean_flags.lawspec)
|
|
474
487
|
checks that flipping twice restores both `false` and `true`; all targets generate
|
|
475
488
|
Boolean property inputs and explicit tests for both Boolean boundary values. Java caps Boolean-only JetCheck runs at the number of
|
|
476
489
|
possible input combinations (up to 100), avoiding generator exhaustion.
|
|
@@ -549,7 +562,7 @@ This expands to `for all (x :: Int32) . render (x) = referenceRender (x)`.
|
|
|
549
562
|
The example inherits the input name `x` from the prelude. Both functions are
|
|
550
563
|
user-owned adapter functions; either may delegate to your existing code.
|
|
551
564
|
|
|
552
|
-
[The complete example](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
565
|
+
[The complete example](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/equivalent.lawspec) compares decimal
|
|
553
566
|
renderers and two implementations that clamp negative integers to zero. For
|
|
554
567
|
JavaScript, their adapters can be:
|
|
555
568
|
|
|
@@ -586,7 +599,7 @@ law `normalizers agree` is
|
|
|
586
599
|
end
|
|
587
600
|
```
|
|
588
601
|
|
|
589
|
-
The [slug example](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
602
|
+
The [slug example](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/slug.lawspec)
|
|
590
603
|
compares two implementations of ASCII-space replacement. It includes empty,
|
|
591
604
|
Unicode and escaped text. Each target uses its native string generator:
|
|
592
605
|
JetCheck `Generator.stringsOf(Generator.asciiPrintableChars())`, Hypothesis `st.text()`, fast-check `fc.string()`,
|
|
@@ -613,7 +626,7 @@ law `canonicalization reaches a fixed point` is
|
|
|
613
626
|
end
|
|
614
627
|
```
|
|
615
628
|
|
|
616
|
-
The [canonical URL example](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
629
|
+
The [canonical URL example](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/canonical_url.lawspec)
|
|
617
630
|
uses removal of **all trailing slashes** as a small fixed-point demonstration,
|
|
618
631
|
not a complete URL canonicalization algorithm. For JavaScript:
|
|
619
632
|
|
|
@@ -622,7 +635,7 @@ export const canonicalize = value => value.replace(/\/+$/, "");
|
|
|
622
635
|
```
|
|
623
636
|
|
|
624
637
|
Removing just one trailing slash fails the supplied repeated-slash example.
|
|
625
|
-
The [mixed-input example](https://github.com/brain-fuel/lawspec/blob/v0.
|
|
638
|
+
The [mixed-input example](https://github.com/brain-fuel/lawspec/blob/v0.15.0/examples/specs/mixed_inputs.lawspec)
|
|
626
639
|
shows `Text` and `Int32` in the same quantified property and executable example.
|
|
627
640
|
The JavaScript API represents example bindings as typed records whose values use
|
|
628
641
|
`DataValue`: lossless tagged scalar payloads or structural constructors. Expected results are
|
|
@@ -705,7 +718,7 @@ by the JS shim.
|
|
|
705
718
|
## Build and verify
|
|
706
719
|
|
|
707
720
|
For contributors working from a repository checkout, build a local archive with
|
|
708
|
-
`npm pack ./npm` and install it with `npm install --save-dev ./lawspec-0.
|
|
721
|
+
`npm pack ./npm` and install it with `npm install --save-dev ./lawspec-0.15.0.tgz`.
|
|
709
722
|
The package payload lives in `npm/`.
|
|
710
723
|
|
|
711
724
|
```sh
|
package/REFINEMENTS.md
CHANGED
package/RELEASE-0.15.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# LawSpec 0.15
|
|
2
|
+
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Evidence and discharge
|
|
6
|
+
|
|
7
|
+
Every obligation of a program reports how it is discharged, strongest first:
|
|
8
|
+
|
|
9
|
+
- `proved`: statically. Definition postconditions and indices, as since 0.12,
|
|
10
|
+
and now laws that call only checked definitions.
|
|
11
|
+
- `exhaustively-checked`: every input of a finite domain, by the compiler for
|
|
12
|
+
laws over checked definitions and otherwise by the generated tests. A law with
|
|
13
|
+
no inputs is a single case.
|
|
14
|
+
- `property-tested`: generated cases, boundary cases and examples.
|
|
15
|
+
- `runtime-checked`: adapter contracts, definition preconditions, constructor
|
|
16
|
+
constraints and native type bindings, at every native boundary.
|
|
17
|
+
- `assumed`: adapters, native functions, custom generators and codec hooks,
|
|
18
|
+
taken on trust. Each adapter reports how many laws call it, or that none does.
|
|
19
|
+
|
|
20
|
+
`lawspec check` summarizes the obligations by status, and the new
|
|
21
|
+
`lawspec evidence` lists each with its claim and reason (`--json` for the API
|
|
22
|
+
records, and a unit or `unit::declaration` filter).
|
|
23
|
+
|
|
24
|
+
### Laws proved and refuted by the compiler
|
|
25
|
+
|
|
26
|
+
A law over checked definitions is attempted as a proof by the same exact linear
|
|
27
|
+
arithmetic that proves definition results, from its input refinements, with
|
|
28
|
+
definitions that have no preconditions unfolded into the claim. When it is not
|
|
29
|
+
proved and its domain is finite, the compiler evaluates every input; a
|
|
30
|
+
counterexample is a compile error with code `refuted`, such as
|
|
31
|
+
`law always positive is false for x = -128`. Specifications that compiled
|
|
32
|
+
before may therefore be rejected if a law over definitions is false.
|
|
33
|
+
|
|
34
|
+
The prover also handles constant factors on integer expressions (`x * 2`),
|
|
35
|
+
which it previously treated as non-linear, so more definition results are
|
|
36
|
+
proved.
|
|
37
|
+
|
|
38
|
+
### API
|
|
39
|
+
|
|
40
|
+
`evidence` items have the five statuses above and new stages: `law`,
|
|
41
|
+
`adapter`, and, with native bindings, `binding`, `codec`, `generator` and
|
|
42
|
+
`native-function`. `claim` is `null` for obligations without one. The
|
|
43
|
+
TypeScript API declares `ObligationEvidence` and `DischargeStatus`. See
|
|
44
|
+
[API migration](API-MIGRATION.md#evidence-and-discharge-015).
|
package/bin/lawspec.mjs
CHANGED
|
@@ -242,16 +242,16 @@ async function main() {
|
|
|
242
242
|
}
|
|
243
243
|
if (!verb || ["help", "--help", "-h"].includes(verb)) {
|
|
244
244
|
output(
|
|
245
|
-
"LawSpec 0.
|
|
245
|
+
"LawSpec 0.15.0\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
246
|
targets.join(", "),
|
|
247
247
|
);
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
250
|
if (verb === "--version") {
|
|
251
|
-
output("0.
|
|
251
|
+
output("0.15.0");
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
|
-
if (positional.length > (
|
|
254
|
+
if (positional.length > (["explain", "evidence"].includes(verb) ? 1 : 0))
|
|
255
255
|
throw new Error(`Unexpected argument: ${positional.join(" ")}`);
|
|
256
256
|
if (verb === "examples") {
|
|
257
257
|
if (
|
|
@@ -288,7 +288,7 @@ async function main() {
|
|
|
288
288
|
throw new Error("--minify applies to init, generate and examples");
|
|
289
289
|
if (verb === "init") return init();
|
|
290
290
|
if (verb === "package") return packageCommand();
|
|
291
|
-
if (!["check", "doctor", "explain", "generate"].includes(verb))
|
|
291
|
+
if (!["check", "doctor", "evidence", "explain", "generate"].includes(verb))
|
|
292
292
|
throw new Error(`Unknown command: ${verb}`);
|
|
293
293
|
const config = JSON.parse(await readFile(configFile, "utf8"));
|
|
294
294
|
if (
|
|
@@ -332,12 +332,20 @@ async function main() {
|
|
|
332
332
|
machineBits: options.machineBits ?? config.machineBits ?? 64,
|
|
333
333
|
};
|
|
334
334
|
const compiler = await createCompiler();
|
|
335
|
-
//
|
|
335
|
+
// Each obligation reports how it is discharged, strongest first.
|
|
336
|
+
const statuses = [
|
|
337
|
+
["proved", "PROVED"],
|
|
338
|
+
["exhaustively-checked", "EXHAUSTIVELY CHECKED"],
|
|
339
|
+
["property-tested", "PROPERTY TESTED"],
|
|
340
|
+
["runtime-checked", "RUNTIME CHECKED"],
|
|
341
|
+
["assumed", "ASSUMED / EXTERNAL"],
|
|
342
|
+
];
|
|
336
343
|
const evidenceSummary = (evidence) => {
|
|
337
344
|
if (!evidence.length) return "";
|
|
338
345
|
const count = (status) => evidence.filter((item) => item.status === status).length;
|
|
339
|
-
return ` Evidence: ${count(
|
|
346
|
+
return ` Evidence: ${statuses.map(([status, label]) => `${count(status)} ${label.toLowerCase()}`).join(", ")}.`;
|
|
340
347
|
};
|
|
348
|
+
const obligationName = (item) => item.declaration.replace("::law::", "::");
|
|
341
349
|
if (verb === "check") {
|
|
342
350
|
const result = diagnostics(await compiler.check(input));
|
|
343
351
|
for (const target of selected) {
|
|
@@ -351,6 +359,36 @@ async function main() {
|
|
|
351
359
|
);
|
|
352
360
|
return;
|
|
353
361
|
}
|
|
362
|
+
if (verb === "evidence") {
|
|
363
|
+
const result = diagnostics(await compiler.check(input));
|
|
364
|
+
let evidence = result.evidence;
|
|
365
|
+
// Native bindings are configured per target; their obligations are added.
|
|
366
|
+
for (const target of selected) {
|
|
367
|
+
if (target.nativeBindings === undefined) continue;
|
|
368
|
+
const bound = diagnostics(await compiler.check({...input, nativeBindings: target.nativeBindings}));
|
|
369
|
+
evidence = evidence.concat(bound.evidence
|
|
370
|
+
.filter((item) => ["binding", "codec", "generator", "native-function"].includes(item.stage))
|
|
371
|
+
.map((item) => ({...item, target: target.language})));
|
|
372
|
+
}
|
|
373
|
+
evidence = evidence.filter((item) => !positional[0] ||
|
|
374
|
+
obligationName(item) === positional[0] || item.owner === positional[0]);
|
|
375
|
+
if (positional[0] && !evidence.length) throw new Error("No matching obligation");
|
|
376
|
+
output(
|
|
377
|
+
options.json
|
|
378
|
+
? evidence
|
|
379
|
+
: statuses
|
|
380
|
+
.map(([status, label]) => {
|
|
381
|
+
const items = evidence.filter((item) => item.status === status);
|
|
382
|
+
if (!items.length) return null;
|
|
383
|
+
return `${label} (${items.length})\n` + items.map((item) =>
|
|
384
|
+
` ${item.stage} ${obligationName(item)}${item.target ? ` [${item.target}]` : ""}` +
|
|
385
|
+
(item.claim ? `: ${item.claim.text}` : "") + `\n ${item.reason}`).join("\n");
|
|
386
|
+
})
|
|
387
|
+
.filter((section) => section !== null)
|
|
388
|
+
.join("\n\n"),
|
|
389
|
+
);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
354
392
|
if (verb === "explain") {
|
|
355
393
|
const result = diagnostics(await compiler.expand(input));
|
|
356
394
|
const indices = result.laws
|
package/build.json
CHANGED
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"src/LawSpec/Data.hs",
|
|
58
58
|
"src/LawSpec/DataNames.hs",
|
|
59
59
|
"src/LawSpec/DefinitionTotality.hs",
|
|
60
|
+
"src/LawSpec/Discharge.hs",
|
|
60
61
|
"src/LawSpec/Domain.hs",
|
|
61
62
|
"src/LawSpec/DomainModel.hs",
|
|
62
63
|
"src/LawSpec/Elaboration.hs",
|
|
@@ -133,8 +134,8 @@
|
|
|
133
134
|
"wasm/lawspec-wasm.cabal"
|
|
134
135
|
],
|
|
135
136
|
"digests": {
|
|
136
|
-
"lawspec.cabal": "
|
|
137
|
-
"package.yaml": "
|
|
137
|
+
"lawspec.cabal": "b929e618142528937531dfa7f524facd2dfb26d12724c3b09a7dc655e4c7c425",
|
|
138
|
+
"package.yaml": "cc4b0ee63fbca1f1bcb7a12adf4fc52d013875a20bbd3f051b542a2f5bfc0f05",
|
|
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": "
|
|
162
|
-
"runtime/rust/Cargo.toml": "
|
|
163
|
-
"src/LawSpec/Api.hs": "
|
|
162
|
+
"runtime/rust/Cargo.lock": "4cf7b8d8d86a8f4d9609675d34e2e5da3efc45bd86a338bec67377c4276df5b2",
|
|
163
|
+
"runtime/rust/Cargo.toml": "519ee452ecc764d512120209a33d32a66e51af62fb608638711db15e88a58652",
|
|
164
|
+
"src/LawSpec/Api.hs": "766d9d2f0c4c43c12524b51e17c42e634b87ba52c78743bd5a2cd6b8dca78983",
|
|
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": "
|
|
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": "
|
|
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,14 @@
|
|
|
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": "9b41c93980ae8bc44a11e4ad27efa702d1e6776c9c8584f691464de072c0c2d7",
|
|
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": "
|
|
200
|
+
"src/LawSpec/Gen.hs": "534c994a500c8af40b5750a6a25505d346b928afa771453466f1980925bae9d8",
|
|
199
201
|
"src/LawSpec/GoData.hs": "1b1882906ba676cdd37c744b91d271c7d25279b137f0c5ba5863f4423729bc86",
|
|
200
202
|
"src/LawSpec/GoDefinitions.hs": "3cb55c22f28443fff73e73c59780bf1977ab9260b8d66c7f19d1b94b40d1397e",
|
|
201
203
|
"src/LawSpec/GoExpr.hs": "da3a7cc0e3d2906886dc44f6b990e72098bb351558bbb31ee335da7382fac58a",
|
|
@@ -233,7 +235,7 @@
|
|
|
233
235
|
"src/LawSpec/PortableGenerator.hs": "69d457e39f539c77fc7a4c08205e75352bbecd9dfdff031a283a39bf44b22d49",
|
|
234
236
|
"src/LawSpec/PortableTestHelpers.hs": "8ba4d87183c8c11f6ef1ce21c170127335797154f29fb97ad3429f032a167fd3",
|
|
235
237
|
"src/LawSpec/Prelude.hs": "b1e155c12f58e7c346551a0c65c5d5af76d045b3f1625977ca2a5d1c97cb8c46",
|
|
236
|
-
"src/LawSpec/Public.hs": "
|
|
238
|
+
"src/LawSpec/Public.hs": "ac46d7b8c5130faf922f10b402e035901d851bb8a229ea823ce0afaaf3011028",
|
|
237
239
|
"src/LawSpec/PythonData.hs": "07e9bb54a1515f3f4744b7b9bb43633cbdbf07b3f9e35efef511753f97e216d5",
|
|
238
240
|
"src/LawSpec/PythonDefinitions.hs": "30f3d2d71a378e194d62261e0fd1baade5a49ac8b5eaac97578ca015a48ce8e4",
|
|
239
241
|
"src/LawSpec/PythonExpr.hs": "23d7d24b5fb4efff9cb63d38c02a93d95744ec79b4565daf1412088fc7c4ba59",
|
|
@@ -250,7 +252,7 @@
|
|
|
250
252
|
"src/LawSpec/Scaffold.hs": "2cdaeaa0708803e6abf3b8e9062dfc2fe31e2d3a6df3b252a17b1ad91eb5d8f2",
|
|
251
253
|
"src/LawSpec/Scalar.hs": "52e61fec81a337bb5b35e9e6f501446cf0b18bffa6c6af2ddc5aeac2d6e07131",
|
|
252
254
|
"src/LawSpec/SpecializeDefinitions.hs": "08f2fe674a5e00d1be396d9edab0dd2c948b7beb12fa99f2a6aba00cbdf01e33",
|
|
253
|
-
"src/LawSpec/Testing.hs": "
|
|
255
|
+
"src/LawSpec/Testing.hs": "9626e43e4c02a0c88435ffe2d629110a99b1b91e8d0bcaa98b468509da69d438",
|
|
254
256
|
"src/LawSpec/WebData.hs": "919af27be12f63f17762e0c052341ab82dcee5d45951a4fd9c66abead98d1ee0",
|
|
255
257
|
"src/LawSpec/WebDefinitions.hs": "d654df765e4bafcb1acdd35058f8a510c2cd81920153c0a75ff1e7e1137c96e5",
|
|
256
258
|
"src/LawSpec/WebExpr.hs": "0389dcd5cf7479dd23ef034b1012de6ebd70bf1dc9e3d90981dfb0ba2702596f",
|
|
@@ -262,10 +264,10 @@
|
|
|
262
264
|
"wasm/app/Exports.hs": "4ecbdac8faa2449e6fc61b93c82e6278fa14374154f29b4dacf0eef433f06a47",
|
|
263
265
|
"wasm/cabal.project": "021e560afdc5eb4cb7169e7119ecb8f92c9ee170245af909c94b612941bff5cc",
|
|
264
266
|
"wasm/cabal.project.freeze": "733dbed3d2ecccb26e874fd58f136296dad772184deb1658c196b5d54a0814dc",
|
|
265
|
-
"wasm/lawspec-wasm.cabal": "
|
|
266
|
-
"npm/core.wasm": "
|
|
267
|
+
"wasm/lawspec-wasm.cabal": "ccc2458717fa37d0bf5d96dfd9a517804d1850553a3a571729886a31618b00ec",
|
|
268
|
+
"npm/core.wasm": "1cb825c73738eb0e05329e24fc7d7a3c905761ff2be7ebf1b8ea8614a8f40319",
|
|
267
269
|
"npm/core_jsffi.js": "88d136efe92f7cff5758c8fec8d9b6bbc9707fe37741cebeeb415fe34ce3d72b",
|
|
268
270
|
"npm/api.mjs": "e93251db289ff0609abaff78ad67f0a9af82508c1141c6a999604f67c56b6e7d",
|
|
269
|
-
"npm/index.d.ts": "
|
|
271
|
+
"npm/index.d.ts": "470cff02e89c1f2ec458075c63eff60382b9dc4a7f961691eb4f0ed9afc71e73"
|
|
270
272
|
}
|
|
271
273
|
}
|
package/core.wasm
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lawspec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "State the law once. Check it everywhere.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"bin": { "lawspec": "bin/lawspec.mjs" },
|
|
9
9
|
"exports": { ".": { "types": "./index.d.ts", "import": "./api.mjs" } },
|
|
10
10
|
"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"],
|
|
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", "RELEASE-0.15.md", "LICENSE", "starter.lawspec", "examples"],
|
|
12
12
|
"scripts": { "test": "node --test test/*.test.mjs" }
|
|
13
13
|
}
|