eutaxy 0.5.0 → 0.6.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.
Files changed (48) hide show
  1. package/README.md +96 -12
  2. package/dist/aws.d.mts +7 -5
  3. package/dist/aws.d.mts.map +1 -1
  4. package/dist/aws.mjs +44 -138
  5. package/dist/aws.mjs.map +1 -1
  6. package/dist/bin.mjs +2 -2
  7. package/dist/{checksum-DhS6ofSm.mjs → checksum-DHr5qb3Y.mjs} +2 -2
  8. package/dist/{checksum-DhS6ofSm.mjs.map → checksum-DHr5qb3Y.mjs.map} +1 -1
  9. package/dist/cli-CsiVEsS-.mjs +2 -0
  10. package/dist/cli.d.mts.map +1 -1
  11. package/dist/cli.mjs +2 -2
  12. package/dist/cloudflare.d.mts +156 -54
  13. package/dist/cloudflare.d.mts.map +1 -1
  14. package/dist/cloudflare.mjs +3 -1815
  15. package/dist/delivery-invariants-BraYqcYN.d.mts +5 -0
  16. package/dist/delivery-invariants-BraYqcYN.d.mts.map +1 -0
  17. package/dist/delivery-invariants-hmhwh_qD.mjs +39 -0
  18. package/dist/delivery-invariants-hmhwh_qD.mjs.map +1 -0
  19. package/dist/{event-streams-BANyO9xt.mjs → event-streams-i8OGzuFN.mjs} +2 -2
  20. package/dist/{event-streams-BANyO9xt.mjs.map → event-streams-i8OGzuFN.mjs.map} +1 -1
  21. package/dist/explore-CDpJA9zX.d.mts +342 -0
  22. package/dist/explore-CDpJA9zX.d.mts.map +1 -0
  23. package/dist/index.d.mts +84 -195
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +10 -191
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/{platform-eVgCMbX0.d.mts → platform-DfMwknw1.d.mts} +94 -73
  28. package/dist/platform-DfMwknw1.d.mts.map +1 -0
  29. package/dist/{src-C19_yfMM.mjs → src-BO7I3f-1.mjs} +961 -543
  30. package/dist/src-BO7I3f-1.mjs.map +1 -0
  31. package/dist/src-C43iUZgr.mjs +5039 -0
  32. package/dist/src-C43iUZgr.mjs.map +1 -0
  33. package/dist/{src-CgfGiH25.mjs → src-Cs4Mg55e.mjs} +1148 -22
  34. package/dist/src-Cs4Mg55e.mjs.map +1 -0
  35. package/package.json +16 -1
  36. package/dist/cli-NqY61bpo.mjs +0 -2
  37. package/dist/cloudflare.mjs.map +0 -1
  38. package/dist/explore-BHYvAZKN.d.mts +0 -84
  39. package/dist/explore-BHYvAZKN.d.mts.map +0 -1
  40. package/dist/platform-eVgCMbX0.d.mts.map +0 -1
  41. package/dist/src-BD3jkjgG.mjs +0 -477
  42. package/dist/src-BD3jkjgG.mjs.map +0 -1
  43. package/dist/src-C19_yfMM.mjs.map +0 -1
  44. package/dist/src-CgfGiH25.mjs.map +0 -1
  45. package/dist/src-s6uYyC0B.mjs +0 -89
  46. package/dist/src-s6uYyC0B.mjs.map +0 -1
  47. package/dist/verdict-evEM5Gxx.mjs +0 -12
  48. package/dist/verdict-evEM5Gxx.mjs.map +0 -1
@@ -0,0 +1,342 @@
1
+ import { D as EffectLog, f as Schedule, g as Violation, n as Platform, o as ScenarioSpec, r as Bounds } from "./platform-DfMwknw1.mjs";
2
+ /**
3
+ * Spec verdicts: what is known about one property of one pure function.
4
+ * Kept apart from scenario verdicts in every report. The ladder runs
5
+ * `CHECKED` (held on every input the simulator passed), then `TESTED` (held
6
+ * on inputs generated from the binders' domains), then `PROVEN` (an engine
7
+ * proved it for every input); `CONFLICT` when engines disagree.
8
+ */
9
+ interface SpecVerdictBase {
10
+ /** The module, as the scenario names it. */
11
+ readonly module: string;
12
+ readonly function: string;
13
+ /** The `@ensures` name, or `@total` / `@throws` for those markers. */
14
+ readonly property: string;
15
+ /** The property as written. */
16
+ readonly text: string;
17
+ readonly assumptions: readonly string[];
18
+ }
19
+ interface Checked extends SpecVerdictBase {
20
+ readonly kind: "CHECKED";
21
+ /** Distinct inputs the property was evaluated on. */
22
+ readonly inputs: number;
23
+ /** Distinct inputs outside the claim: a precondition failed, or a value fell outside its binder's domain. */
24
+ readonly discarded: number;
25
+ }
26
+ /** The property held on inputs generated from its binders' domains, and on the simulator's where it passed any. */
27
+ interface Tested extends SpecVerdictBase {
28
+ readonly kind: "TESTED";
29
+ /** Generated assignments the property held on. */
30
+ readonly inputs: number;
31
+ /** Generated assignments outside the claim: a precondition failed. */
32
+ readonly discarded: number;
33
+ /** The seed the assignments were drawn from; the same seed draws the same assignments. */
34
+ readonly seed: string;
35
+ /** Distinct inputs the simulator passed that the property also held on, when it passed any. */
36
+ readonly checked?: number;
37
+ }
38
+ /** One assignment that breaks the property, as JavaScript literals, and where it came from. */
39
+ interface Counterexample {
40
+ /** In the property's binder order. */
41
+ readonly binders: readonly {
42
+ readonly name: string;
43
+ readonly value: string;
44
+ }[];
45
+ /** The simulator's call the assignment was taken from; absent when it was generated. */
46
+ readonly call?: string;
47
+ /** Set when evaluating the property threw instead of returning false. */
48
+ readonly error?: string;
49
+ }
50
+ interface Refuted extends SpecVerdictBase {
51
+ readonly kind: "REFUTED";
52
+ /** The rung that found the counterexample: a rung of the simulator, or an engine by name. */
53
+ readonly rung: "CHECKED" | "TESTED" | "PROVEN";
54
+ /** The engine, when the rung is PROVEN. */
55
+ readonly engine?: {
56
+ readonly name: string;
57
+ readonly version: string;
58
+ };
59
+ readonly counterexample: Counterexample;
60
+ }
61
+ /** Proved for every input by a named engine; the lower rungs' evidence is kept beside it. */
62
+ interface Proven extends SpecVerdictBase {
63
+ readonly kind: "PROVEN";
64
+ readonly engine: {
65
+ readonly name: string;
66
+ readonly version: string;
67
+ };
68
+ /** Generated inputs the TESTED rung held on, when it ran. */
69
+ readonly tested?: number;
70
+ /** Distinct inputs the simulator passed that the CHECKED rung held on, when it passed any. */
71
+ readonly checked?: number;
72
+ }
73
+ /** Two engines disagree: one proves, one refutes. Never resolved automatically. */
74
+ interface Conflict extends SpecVerdictBase {
75
+ readonly kind: "CONFLICT";
76
+ readonly proven: {
77
+ readonly name: string;
78
+ readonly version: string;
79
+ };
80
+ readonly refuted: {
81
+ readonly name: string;
82
+ readonly version: string;
83
+ readonly counterexample?: Counterexample;
84
+ };
85
+ }
86
+ type SpecUnknownCause = "gave_up" | "unsupported" | "unavailable";
87
+ interface SpecUnknown extends SpecVerdictBase {
88
+ readonly kind: "UNKNOWN";
89
+ readonly cause: SpecUnknownCause;
90
+ readonly reason: string;
91
+ }
92
+ type SpecVerdict = Checked | Tested | Proven | Refuted | Conflict | SpecUnknown;
93
+ /** One line per spec verdict, for error messages; full rendering lives in `report`. */
94
+ declare function describeSpecVerdict(v: SpecVerdict): string;
95
+ interface BoundsReached {
96
+ readonly runs: number;
97
+ readonly effectPoints: number;
98
+ readonly faultsInjected: number;
99
+ readonly elapsedMs: number;
100
+ /**
101
+ * Present when exploration was exhaustive: how many distinct schedules ran
102
+ * (runs that only repeated an order the reduction had covered are not
103
+ * counted), and whether every schedule within the bounds was reached
104
+ * before the budget ran out.
105
+ */
106
+ readonly exhaustive?: {
107
+ readonly complete: boolean;
108
+ readonly schedules: number;
109
+ readonly reduction: boolean;
110
+ };
111
+ }
112
+ interface VerdictBase {
113
+ readonly scenario: string;
114
+ readonly seed: number | string;
115
+ readonly reached: BoundsReached;
116
+ readonly assumptions: readonly string[];
117
+ }
118
+ interface Shrunk {
119
+ readonly faultsRemoved: number;
120
+ readonly eventsRemoved: number;
121
+ readonly runs: number;
122
+ }
123
+ interface Violated extends VerdictBase {
124
+ readonly kind: "VIOLATED";
125
+ readonly violation: Violation;
126
+ /** The replayed, shrunk trace that breaks the invariant. */
127
+ readonly trace: EffectLog;
128
+ readonly schedule: Schedule;
129
+ /** Ids of the drive's events that remain after shrinking. */
130
+ readonly keptEvents: readonly string[];
131
+ readonly shrunk: Shrunk;
132
+ }
133
+ interface Bounded extends VerdictBase {
134
+ readonly kind: "BOUNDED";
135
+ readonly bounds: Bounds;
136
+ }
137
+ type UnsupportedCause = "unsupported_api" | "not_replayable" | "module_state_leak" | "unsupported_bounds";
138
+ interface Unsupported extends VerdictBase {
139
+ readonly kind: "UNSUPPORTED";
140
+ readonly cause: UnsupportedCause;
141
+ readonly reason: string;
142
+ }
143
+ type ScenarioVerdict = Violated | Bounded | Unsupported;
144
+ /** One line per verdict, for error messages; full rendering lives in `report`. */
145
+ declare function describeVerdict(v: ScenarioVerdict): string;
146
+ /**
147
+ * SpecIR: function specs as plain data. The surface syntax is Lemma
148
+ * (https://github.com/jessealama/lemma-lang, grammar.ebnf and
149
+ * semantics.md); the IR is Eutaxy's own, so engines and the simulator read
150
+ * one shape whatever the annotation looked like. Leaves are opaque
151
+ * TypeScript expressions, kept as written.
152
+ */
153
+ /** Lemma's binder domains. */
154
+ type Domain = "int" | "nat" | "number" | "boolean" | "string" | "bigint";
155
+ /**
156
+ * One end of an interval: a numeric literal as written (sign included), or
157
+ * `∞` / `-∞` for either infinity. `[` and `]` include the endpoint.
158
+ */
159
+ interface Endpoint {
160
+ readonly value: string;
161
+ readonly inclusive: boolean;
162
+ }
163
+ /** A binder's constraint: an interval for numeric domains, a whole-string regex for `string`. */
164
+ type Guard = {
165
+ readonly kind: "interval";
166
+ readonly lower: Endpoint;
167
+ readonly upper: Endpoint;
168
+ } | {
169
+ readonly kind: "regex";
170
+ readonly pattern: string;
171
+ readonly flags: string;
172
+ };
173
+ interface Binder {
174
+ readonly name: string;
175
+ readonly domain: Domain;
176
+ readonly guard?: Guard;
177
+ }
178
+ /**
179
+ * A formula over boolean atoms. Atoms and equation sides are TypeScript
180
+ * expressions, verbatim. `and` and `or` are n-ary (both are associative);
181
+ * `implies` keeps Lemma's chain: every segment but the last is an
182
+ * antecedent. An implication at a property's root is not a formula node but
183
+ * the property's preconditions (`Property.requires`).
184
+ */
185
+ type Formula = {
186
+ readonly kind: "atom";
187
+ readonly text: string;
188
+ } | {
189
+ readonly kind: "equation";
190
+ readonly left: string;
191
+ readonly right: string;
192
+ /** `≢` rather than `≡`. */
193
+ readonly negated: boolean;
194
+ } | {
195
+ readonly kind: "not";
196
+ readonly operand: Formula;
197
+ } | {
198
+ readonly kind: "and" | "or";
199
+ readonly operands: readonly Formula[];
200
+ } | {
201
+ readonly kind: "implies";
202
+ readonly antecedents: readonly Formula[];
203
+ readonly consequent: Formula;
204
+ } | {
205
+ readonly kind: "iff";
206
+ readonly left: Formula;
207
+ readonly right: Formula;
208
+ };
209
+ /**
210
+ * A universally quantified claim: for every assignment of the binders from
211
+ * their (guarded) domains where every precondition holds, `claim` holds.
212
+ * Assignments failing a precondition are outside the claim.
213
+ */
214
+ interface Property {
215
+ readonly binders: readonly Binder[];
216
+ readonly requires: readonly Formula[];
217
+ readonly claim: Formula;
218
+ }
219
+ /** An `@ensures{name}` annotation. */
220
+ interface NamedProperty {
221
+ readonly name: string;
222
+ readonly property: Property;
223
+ /** The annotation's property text, as written. */
224
+ readonly text: string;
225
+ }
226
+ /** The specs on one exported function. */
227
+ interface FunctionSpec {
228
+ readonly name: string;
229
+ /** Parameter names in order; null for a destructured or rest parameter. */
230
+ readonly params: readonly (string | null)[];
231
+ readonly ensures: readonly NamedProperty[];
232
+ /** `@total`: the function terminates on every input. */
233
+ readonly total: boolean;
234
+ /** `@throws`: the function throws (Lemma has not fixed its semantics yet). */
235
+ readonly throws: boolean;
236
+ /** 1-based line of the declaration. */
237
+ readonly line: number;
238
+ /** Offset in the source of the `(` opening the parameters: the declaration's identity, for tools that read the module themselves. */
239
+ readonly offset: number;
240
+ }
241
+ /** A problem with an annotation, located in the module. */
242
+ interface SpecError {
243
+ readonly line: number;
244
+ readonly message: string;
245
+ }
246
+ /** Every spec in one module, the names it exports, and the annotations that did not parse. */
247
+ interface ModuleSpecs {
248
+ readonly functions: readonly FunctionSpec[];
249
+ readonly exports: readonly string[];
250
+ readonly errors: readonly SpecError[];
251
+ }
252
+ /** The outcome a predicate returns for one assignment. */
253
+ type PredicateOutcome = "held" | "discarded" | "refuted";
254
+ /** What generated predicates call when free names did not resolve. */
255
+ declare function lemmaUnresolved(names: readonly string[]): never;
256
+ /** The atom check generated predicates call: its argument when it is a boolean. */
257
+ declare function lemmaBool(value: unknown): boolean;
258
+ interface CheckedInput {
259
+ readonly module: string;
260
+ readonly fn: FunctionSpec;
261
+ readonly property: NamedProperty;
262
+ /** The calls the simulator made, with their arguments. */
263
+ readonly calls: readonly {
264
+ readonly args: readonly unknown[];
265
+ }[];
266
+ /** The compiled predicate over the binders, or undefined when it could not be built. */
267
+ readonly predicate: ((...binders: never[]) => PredicateOutcome) | undefined;
268
+ /** Why the function's calls could not be observed, when they could not. */
269
+ readonly unobservable?: string;
270
+ }
271
+ declare function checkedRung(input: CheckedInput): SpecVerdict;
272
+ interface TestedOptions {
273
+ /** The check's seed; each property derives its own stream from it and its name. */
274
+ readonly seed: string;
275
+ /** Distinct assignments the property must hold on; default 100. Drawing stops after 20 times as many draws, whatever they were. */
276
+ readonly inputs?: number;
277
+ }
278
+ interface TestedInput extends TestedOptions {
279
+ readonly module: string;
280
+ readonly fn: FunctionSpec;
281
+ readonly property: NamedProperty;
282
+ /** The compiled predicate over the binders, or undefined when it could not be built. */
283
+ readonly predicate: ((...binders: never[]) => PredicateOutcome) | undefined;
284
+ }
285
+ declare function testedRung(input: TestedInput): SpecVerdict;
286
+ interface LadderOptions {
287
+ /** Run the `TESTED` rung with these options; `false` stops the ladder at `CHECKED`. */
288
+ readonly tested?: TestedOptions | false;
289
+ }
290
+ /** One property through the ladder's rungs. */
291
+ declare function specLadder(input: CheckedInput, options?: LadderOptions): SpecVerdict;
292
+ /** Compiled predicates of a module, by function and property name. */
293
+ interface ModulePredicates {
294
+ readonly [fn: string]: {
295
+ readonly [property: string]: (...binders: never[]) => PredicateOutcome;
296
+ };
297
+ }
298
+ interface ExploreOptions {
299
+ readonly seed: number | string;
300
+ /** Hard cap on runs, in addition to the scenario's time budget. */
301
+ readonly maxRuns?: number;
302
+ /**
303
+ * Replaces the scenario's `budgetMs` for this exploration: the real time
304
+ * exploring and shrinking may take, and the real time one effect's I/O
305
+ * may take before it counts as hung. With a generous budget and
306
+ * `maxRuns`, the run cap ends exploration, so a seed decides the verdict
307
+ * on any machine.
308
+ */
309
+ readonly budgetMs?: number;
310
+ /**
311
+ * The share of seeded runs after the first (which injects none) that
312
+ * inject faults (see `planFaults`). Default 0.9: the runs without faults
313
+ * also check the scenario as it runs without them, and measure how many
314
+ * eligible points a run without faults has, which can vary with the seed.
315
+ */
316
+ readonly faultProbability?: number;
317
+ /** Clock for the time budget; injectable for tests. */
318
+ readonly now?: () => number;
319
+ /** Hard cap on replay runs spent shrinking a violation. */
320
+ readonly maxShrinkRuns?: number;
321
+ /**
322
+ * How many of the first exploration runs to replay in reverse order
323
+ * before reporting BOUNDED, to detect module-level state leaking between
324
+ * runs. 0 disables the pass.
325
+ */
326
+ readonly leakCheckRuns?: number;
327
+ /**
328
+ * Explore every schedule within the bounds, each once, instead of drawing
329
+ * schedules from the seed: every fault (or none) at every effect point
330
+ * that may still take one, and every order of turns. With `reduction`
331
+ * (the default), turns of different invocations on different targets
332
+ * commute and only one order of them is run.
333
+ */
334
+ readonly exhaustive?: boolean | {
335
+ readonly reduction?: boolean;
336
+ };
337
+ }
338
+ /** Re-run a recorded schedule exactly. */
339
+ declare function replay(spec: ScenarioSpec, platform: Platform, schedule: Schedule): Promise<EffectLog>;
340
+ declare function explore(scenario: ScenarioSpec, platform: Platform, options: ExploreOptions): Promise<ScenarioVerdict>;
341
+ export { Proven as A, ScenarioVerdict as C, Checked as D, describeVerdict as E, describeSpecVerdict as F, SpecUnknown as M, SpecVerdict as N, Conflict as O, Tested as P, BoundsReached as S, Violated as T, ModuleSpecs as _, ModulePredicates as a, SpecError as b, testedRung as c, lemmaUnresolved as d, Binder as f, Guard as g, FunctionSpec as h, LadderOptions as i, Refuted as j, Counterexample as k, checkedRung as l, Formula as m, explore as n, specLadder as o, Domain as p, replay as r, TestedOptions as s, ExploreOptions as t, lemmaBool as u, NamedProperty as v, Unsupported as w, Bounded as x, Property as y };
342
+ //# sourceMappingURL=explore-CDpJA9zX.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explore-CDpJA9zX.d.mts","names":[],"sources":["../../core/src/spec-verdict.ts","../../core/src/verdict.ts","../../spec/src/ir.ts","../../spec/src/predicate.ts","../../prover/src/checked.ts","../../prover/src/tested.ts","../../prover/src/ladder.ts","../../engine/src/explore.ts"],"mappings":";;;;;;;;UAQU;;WAEC;WACA;;WAEA;;WAEA;WACA;;UAGM,gBAAgB;WACtB;;WAEA;;WAEA;;;UAIM,eAAe;WACrB;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;aAA6B;aAAuB;;;WAEpD;;WAEA;;UAGM,gBAAgB;WACtB;;WAEA;;WAEA;aAAoB;aAAuB;;WAC3C,gBAAgB;;;UAIV,eAAe;WACrB;WACA;aAAmB;aAAuB;;;WAE1C;;WAEA;;;UAIM,iBAAiB;WACvB;WACA;aAAmB;aAAuB;;WAC1C;aACE;aACA;aACA,iBAAiB;;;KAIlB;UAEK,oBAAoB;WAC1B;WACA,OAAO;WACP;;KAGC,cAAc,UAAU,SAAS,SAAS,UAAU,WAAW;;iBAG3D,oBAAoB,GAAG;UCpFtB;WACN;WACA;WACA;WACA;;;;;;;WAOA;aACE;aACA;aACA;;;UAIH;WACC;WACA;WACA,SAAS;WACT;;UAGM;WACN;WACA;WACA;;UAGM,iBAAiB;WACvB;WACA,WAAW;;WAEX,OAAO;WACP,UAAU;;WAEV;WACA,QAAQ;;UAGF,gBAAgB;WACtB;WACA,QAAQ;;KAGP;UAMK,oBAAoB;WAC1B;WACA,OAAO;WACP;;KAGC,kBAAkB,WAAW,UAAU;;iBAGnC,gBAAgB,GAAG;;;;;;;;;KC5DvB;;;;;UAQK;WACN;WACA;;;KAIC;WACG;WAA2B,OAAO;WAAmB,OAAO;;WAC5D;WAAwB;WAA0B;;UAEhD;WACN;WACA,QAAQ;WACR,QAAQ;;;;;;;;;KAUP;WACG;WAAuB;;WAEvB;WACA;WACA;;WAEA;;WAEA;WAAsB,SAAS;;WAC/B;WAA6B,mBAAmB;;WAEhD;WACA,sBAAsB;WACtB,YAAY;;WAEZ;WAAsB,MAAM;WAAkB,OAAO;;;;;;;UAOnD;WACN,kBAAkB;WAClB,mBAAmB;WACnB,OAAO;;;UAID;WACN;WACA,UAAU;;WAEV;;;UAIM;WACN;;WAEA;WACA,kBAAkB;;WAElB;;WAEA;;WAEA;;WAEA;;;UAIM;WACN;WACA;;;UAIM;WACN,oBAAoB;WACpB;WACA,iBAAiB;;;KC1FhB;;iBCaI,gBAAgB;;iBAOhB,UAAU;UA0GT;WACN;WACA,IAAI;WACJ,UAAU;;WAEV;aAA2B;;;WAE3B,gBAAgB,qBAAqB;;WAErC;;iBAGK,YAAY,OAAO,eAAe;UCzIjC;;WAEN;;WAEA;;UAGM,oBAAoB;WAC1B;WACA,IAAI;WACJ,UAAU;;WAEV,gBAAgB,qBAAqB;;iBAMhC,WAAW,OAAO,cAAc;UCpB/B;;WAEN,SAAS;;;iBAIJ,WAAW,OAAO,cAAc,UAAS,gBAAqB;;UAuC7D;YACL;cAAyB,uBAAuB,qBAAqB;;;UC/BhE;WACN;;WAEA;;;;;;;;WAQA;;;;;;;WAOA;;WAEA;;WAEA;;;;;;WAMA;;;;;;;;WAQA;aAAkC;;;;iBAqKvB,OACpB,MAAM,cACN,UAAU,UACV,UAAU,WACT,QAAQ;iBAIW,QACpB,UAAU,cACV,UAAU,UACV,SAAS,iBACR,QAAQ"}
package/dist/index.d.mts CHANGED
@@ -1,53 +1,92 @@
1
- import { C as FaultDecision, D as EffectRecord, E as EffectLog, S as checkInvariants, T as Schedule, _ as RowCondition, b as Violation, d as AtMostOncePerKey, f as EffectSelector, g as Refines, h as Invariant, l as validateScenario, m as Implies, n as Platform, o as ScenarioSpec, p as EveryRow, r as Bounds, t as EventRef, u as AtLeastOnce, v as StateQuery, w as FaultKind, x as checkInvariant, y as Unique } from "./platform-eVgCMbX0.mjs";
2
- import { a as BoundsReached, c as Violated, i as Bounded, l as describeVerdict, n as explore, o as ScenarioVerdict, r as replay, s as Unsupported, t as ExploreOptions } from "./explore-BHYvAZKN.mjs";
3
- /**
4
- * Spec verdicts: what is known about one property of one pure function.
5
- * Kept apart from scenario verdicts in every report. The ladder starts at
6
- * `CHECKED` (held on every input the simulator passed); `TESTED` and
7
- * `PROVEN` come with the provers.
8
- */
9
- interface SpecVerdictBase {
10
- /** The module, as the scenario names it. */
11
- readonly module: string;
12
- readonly function: string;
13
- /** The `@ensures` name, or `@total` / `@throws` for those markers. */
14
- readonly property: string;
15
- /** The property as written. */
16
- readonly text: string;
17
- readonly assumptions: readonly string[];
18
- }
19
- interface Checked extends SpecVerdictBase {
20
- readonly kind: "CHECKED";
21
- /** Distinct inputs the property was evaluated on. */
22
- readonly inputs: number;
23
- /** Distinct inputs outside the claim: a precondition failed, or a value fell outside its binder's domain. */
24
- readonly discarded: number;
1
+ import { C as StateQuery, D as EffectLog, E as EffectSelector, O as EffectRecord, S as RowCondition, T as Refines, _ as checkInvariant, b as Implies, d as FaultKind, f as Schedule, g as Violation, h as Invariant, l as validateScenario, m as AtMostOncePerKey, n as Platform, o as ScenarioSpec, p as AtLeastOnce, r as Bounds, t as EventRef, u as FaultDecision, v as checkInvariants, w as Unique, y as EveryRow } from "./platform-DfMwknw1.mjs";
2
+ import { A as Proven, C as ScenarioVerdict, D as Checked, E as describeVerdict, F as describeSpecVerdict, M as SpecUnknown, N as SpecVerdict, O as Conflict, P as Tested, S as BoundsReached, T as Violated, _ as ModuleSpecs, b as SpecError, c as testedRung, f as Binder, g as Guard, h as FunctionSpec, i as LadderOptions, j as Refuted, k as Counterexample, l as checkedRung, m as Formula, n as explore, o as specLadder, p as Domain, r as replay, s as TestedOptions, t as ExploreOptions, v as NamedProperty, w as Unsupported, x as Bounded, y as Property } from "./explore-CDpJA9zX.mjs";
3
+ export declare function extractSpecs(source: string): ModuleSpecs;
4
+ /** A property that is not Lemma. `stage` says which part rejected it. */
5
+ export declare class LemmaSyntaxError extends Error {
6
+ readonly stage: "prefix" | "formula";
7
+ constructor(stage: "prefix" | "formula", message: string);
25
8
  }
26
- /** One assignment that breaks the property, as JavaScript literals, and the call it came from. */
27
- interface Counterexample {
28
- /** In the property's binder order. */
29
- readonly binders: readonly {
30
- readonly name: string;
31
- readonly value: string;
32
- }[];
33
- readonly call: string;
34
- /** Set when evaluating the property threw instead of returning false. */
35
- readonly error?: string;
9
+ /** Parse the text after `@ensures{name}`. Throws LemmaSyntaxError. */
10
+ export declare function parseProperty(text: string): Property;
11
+ /** The property as Lemma text (what follows `@ensures{name}`). */
12
+ export declare function printProperty(p: Property): string;
13
+ interface EngineId {
14
+ readonly name: string;
15
+ readonly version: string;
36
16
  }
37
- interface Refuted extends SpecVerdictBase {
17
+ type ProofOutcome = {
18
+ readonly kind: "PROVEN";
19
+ readonly engine: EngineId;
20
+ readonly assumptions: readonly string[];
21
+ } | {
38
22
  readonly kind: "REFUTED";
39
- readonly rung: "CHECKED";
40
- readonly counterexample: Counterexample;
41
- }
42
- type SpecUnknownCause = "gave_up" | "unsupported" | "unavailable";
43
- interface SpecUnknown extends SpecVerdictBase {
23
+ readonly engine: EngineId;
24
+ readonly counterexample?: Counterexample;
25
+ readonly assumptions: readonly string[];
26
+ } | {
44
27
  readonly kind: "UNKNOWN";
45
- readonly cause: SpecUnknownCause;
28
+ readonly cause: "gave_up" | "unsupported" | "unavailable";
46
29
  readonly reason: string;
30
+ };
31
+ interface PropertyProof {
32
+ readonly function: string;
33
+ /** The `@ensures` name, or `@total`. */
34
+ readonly property: string;
35
+ readonly outcome: ProofOutcome;
36
+ }
37
+ interface ModuleProofs {
38
+ readonly results: readonly PropertyProof[];
39
+ /** Annotations that did not parse: properties asked for and never checked. */
40
+ readonly specErrors: readonly SpecError[];
41
+ }
42
+ interface ProveInput {
43
+ /** The module's source text. */
44
+ readonly source: string;
45
+ /** The annotated functions to prove; every annotated one when omitted. */
46
+ readonly functions?: readonly string[];
47
+ /** The module's specs when the caller has them already. */
48
+ readonly specs?: ModuleSpecs;
49
+ readonly timeoutMs?: number;
50
+ }
51
+ interface Prover {
52
+ readonly name: string;
53
+ /** Whether the engine can run here, or why not. */
54
+ available(): Promise<{
55
+ readonly version: string;
56
+ } | {
57
+ readonly unavailable: string;
58
+ }>;
59
+ prove(input: ProveInput): Promise<ModuleProofs>;
60
+ }
61
+ /** What an engine said about one module, by its name. */
62
+ interface EngineReport {
63
+ readonly engine: string;
64
+ readonly proofs: ModuleProofs;
47
65
  }
48
- type SpecVerdict = Checked | Refuted | SpecUnknown;
49
- /** One line per spec verdict, for error messages; full rendering lives in `report`. */
50
- export declare function describeSpecVerdict(v: SpecVerdict): string;
66
+ /**
67
+ * The simulator's verdicts for a module (CHECKED, TESTED, REFUTED, UNKNOWN,
68
+ * markers included) combined with what the engines proved. A simulator
69
+ * counterexample stands. One engine proving is `PROVEN`, the lower rungs'
70
+ * counts kept beside it; an engine refuting where nothing else did is
71
+ * `REFUTED` at the PROVEN rung; one proving and another refuting is
72
+ * `CONFLICT`. An engine that gave up, could not run or does not take the
73
+ * function leaves the verdict as it was, with why among the assumptions.
74
+ * `@total` is proved by acceptance where the engine says so.
75
+ */
76
+ export declare function aggregate(module: string, verdicts: readonly SpecVerdict[], reports: readonly EngineReport[]): SpecVerdict[];
77
+ /**
78
+ * Observe a module's pure core functions while runs are installed: each call
79
+ * from outside the module is recorded with its arguments, for spec checks
80
+ * on the inputs the simulator passed, and logged as a decision of the
81
+ * invocation that made it (`Core:<function>`, payload `{ args, result }` or
82
+ * `{ args, error }`), for `refines`. Calls the module makes to itself do not
83
+ * go through its exports and are not seen.
84
+ *
85
+ * Observing replaces the export on the module's namespace object, which
86
+ * works where a bundler or test runner gives modules a namespace with
87
+ * configurable properties (Vite, so Vitest and the Cloudflare plugin); a
88
+ * native ESM namespace is frozen, and the function is reported unobservable.
89
+ */
51
90
  interface ObservedCall {
52
91
  readonly function: string;
53
92
  /** The arguments as passed; primitives exactly, objects by reference. */
@@ -66,156 +105,6 @@ interface CoreObserver {
66
105
  export declare function observeCore(namespace: object, functions: readonly string[]): CoreObserver;
67
106
  /** The scenario restricted to the kept events, with per-message invariants re-derived. */
68
107
  export declare function restrictSpec(platform: Platform, spec: ScenarioSpec, keepIds: readonly string[]): ScenarioSpec;
69
- /**
70
- * SpecIR: function specs as plain data. The surface syntax is Lemma
71
- * (https://github.com/jessealama/lemma-lang, grammar.ebnf and
72
- * semantics.md); the IR is Eutaxy's own, so engines and the simulator read
73
- * one shape whatever the annotation looked like. Leaves are opaque
74
- * TypeScript expressions, kept as written.
75
- */
76
- /** Lemma's binder domains. */
77
- type Domain = "int" | "nat" | "number" | "boolean" | "string" | "bigint";
78
- /**
79
- * One end of an interval: a numeric literal as written (sign included), or
80
- * `∞` / `-∞` for either infinity. `[` and `]` include the endpoint.
81
- */
82
- interface Endpoint {
83
- readonly value: string;
84
- readonly inclusive: boolean;
85
- }
86
- /** A binder's constraint: an interval for numeric domains, a whole-string regex for `string`. */
87
- type Guard = {
88
- readonly kind: "interval";
89
- readonly lower: Endpoint;
90
- readonly upper: Endpoint;
91
- } | {
92
- readonly kind: "regex";
93
- readonly pattern: string;
94
- readonly flags: string;
95
- };
96
- interface Binder {
97
- readonly name: string;
98
- readonly domain: Domain;
99
- readonly guard?: Guard;
100
- }
101
- /**
102
- * A formula over boolean atoms. Atoms and equation sides are TypeScript
103
- * expressions, verbatim. `and` and `or` are n-ary (both are associative);
104
- * `implies` keeps Lemma's chain: every segment but the last is an
105
- * antecedent. An implication at a property's root is not a formula node but
106
- * the property's preconditions (`Property.requires`).
107
- */
108
- type Formula = {
109
- readonly kind: "atom";
110
- readonly text: string;
111
- } | {
112
- readonly kind: "equation";
113
- readonly left: string;
114
- readonly right: string;
115
- /** `≢` rather than `≡`. */
116
- readonly negated: boolean;
117
- } | {
118
- readonly kind: "not";
119
- readonly operand: Formula;
120
- } | {
121
- readonly kind: "and" | "or";
122
- readonly operands: readonly Formula[];
123
- } | {
124
- readonly kind: "implies";
125
- readonly antecedents: readonly Formula[];
126
- readonly consequent: Formula;
127
- } | {
128
- readonly kind: "iff";
129
- readonly left: Formula;
130
- readonly right: Formula;
131
- };
132
- /**
133
- * A universally quantified claim: for every assignment of the binders from
134
- * their (guarded) domains where every precondition holds, `claim` holds.
135
- * Assignments failing a precondition are outside the claim.
136
- */
137
- interface Property {
138
- readonly binders: readonly Binder[];
139
- readonly requires: readonly Formula[];
140
- readonly claim: Formula;
141
- }
142
- /** An `@ensures{name}` annotation. */
143
- interface NamedProperty {
144
- readonly name: string;
145
- readonly property: Property;
146
- /** The annotation's property text, as written. */
147
- readonly text: string;
148
- }
149
- /** The specs on one exported function. */
150
- interface FunctionSpec {
151
- readonly name: string;
152
- /** Parameter names in order; null for a destructured or rest parameter. */
153
- readonly params: readonly (string | null)[];
154
- readonly ensures: readonly NamedProperty[];
155
- /** `@total`: the function terminates on every input. */
156
- readonly total: boolean;
157
- /** `@throws`: the function throws (Lemma has not fixed its semantics yet). */
158
- readonly throws: boolean;
159
- /** 1-based line of the declaration. */
160
- readonly line: number;
161
- }
162
- /** A problem with an annotation, located in the module. */
163
- interface SpecError {
164
- readonly line: number;
165
- readonly message: string;
166
- }
167
- /** Every spec in one module, the names it exports, and the annotations that did not parse. */
168
- interface ModuleSpecs {
169
- readonly functions: readonly FunctionSpec[];
170
- readonly exports: readonly string[];
171
- readonly errors: readonly SpecError[];
172
- }
173
- export declare function extractSpecs(source: string): ModuleSpecs;
174
- /** A property that is not Lemma. `stage` says which part rejected it. */
175
- export declare class LemmaSyntaxError extends Error {
176
- readonly stage: "prefix" | "formula";
177
- constructor(stage: "prefix" | "formula", message: string);
178
- }
179
- /** Parse the text after `@ensures{name}`. Throws LemmaSyntaxError. */
180
- export declare function parseProperty(text: string): Property;
181
- /** The outcome a predicate returns for one assignment. */
182
- type PredicateOutcome = "held" | "discarded" | "refuted";
183
- /** The property as Lemma text (what follows `@ensures{name}`). */
184
- export declare function printProperty(p: Property): string;
185
- /** What generated predicates call when free names did not resolve. */
186
- export declare function lemmaUnresolved(names: readonly string[]): never;
187
- /** The atom check generated predicates call: its argument when it is a boolean. */
188
- export declare function lemmaBool(value: unknown): boolean;
189
- interface CheckedInput {
190
- readonly module: string;
191
- readonly fn: FunctionSpec;
192
- readonly property: NamedProperty;
193
- /** The calls the simulator made, with their arguments. */
194
- readonly calls: readonly {
195
- readonly args: readonly unknown[];
196
- }[];
197
- /** The compiled predicate over the binders, or undefined when it could not be built. */
198
- readonly predicate: ((...binders: never[]) => PredicateOutcome) | undefined;
199
- /** Why the function's calls could not be observed, when they could not. */
200
- readonly unobservable?: string;
201
- }
202
- export declare function checkedRung(input: CheckedInput): SpecVerdict;
203
- /** Compiled predicates of a module, by function and property name. */
204
- interface ModulePredicates {
205
- readonly [fn: string]: {
206
- readonly [property: string]: (...binders: never[]) => PredicateOutcome;
207
- };
208
- }
209
- /** Every spec verdict for one module, from what was observed of its calls. */
210
- export declare function checkSpecModule(module: string, specs: ModuleSpecs, predicates: ModulePredicates, observed: {
211
- readonly calls: readonly {
212
- readonly function: string;
213
- readonly args: readonly unknown[];
214
- }[];
215
- readonly unobservable: {
216
- readonly [fn: string]: string;
217
- };
218
- }): SpecVerdict[];
219
108
  interface RegressionTestOptions {
220
109
  /** Import lines for the scenario, the platform's dependencies, and anything the platform expression needs. */
221
110
  readonly imports: readonly string[];
@@ -248,5 +137,5 @@ export declare function renderSpecs(specs: readonly SpecVerdict[]): string;
248
137
  export declare function renderTrace(log: EffectLog, evidence?: readonly number[]): string;
249
138
  /** A readable report: verdict, what it rests on, and for a violation the schedule and trace. */
250
139
  export declare function renderText(verdict: ScenarioVerdict): string;
251
- export { type AtLeastOnce, type AtMostOncePerKey, type Binder, type Bounded, type Bounds, type BoundsReached, type Checked, type CoreObserver, type Counterexample, type Domain, type EffectLog, type EffectRecord, type EffectSelector, type EventRef, type EveryRow, type ExploreOptions, type FaultDecision, type FaultKind, type Formula, type FunctionSpec, type Guard, type Implies, type Invariant, type ModulePredicates, type ModuleSpecs, type NamedProperty, type ObservedCall, type Platform, type Property, type Refines, type Refuted, type RegressionTestOptions, type RowCondition, type ScenarioSpec, type ScenarioVerdict, type Schedule, type SpecUnknown, type SpecVerdict, type StateQuery, type Unique, type Unsupported, type Violated, type Violation, checkInvariant, checkInvariants, describeVerdict, explore, replay, validateScenario };
140
+ export { type AtLeastOnce, type AtMostOncePerKey, type Binder, type Bounded, type Bounds, type BoundsReached, type Checked, type Conflict, type CoreObserver, type Counterexample, type Domain, type EffectLog, type EffectRecord, type EffectSelector, type EngineId, type EngineReport, type EventRef, type EveryRow, type ExploreOptions, type FaultDecision, type FaultKind, type Formula, type FunctionSpec, type Guard, type Implies, type Invariant, type LadderOptions, type ModuleProofs, type ModuleSpecs, type NamedProperty, type ObservedCall, type Platform, type ProofOutcome, type Property, type PropertyProof, type ProveInput, type Proven, type Prover, type Refines, type Refuted, type RegressionTestOptions, type RowCondition, type ScenarioSpec, type ScenarioVerdict, type Schedule, type SpecUnknown, type SpecVerdict, type StateQuery, type Tested, type TestedOptions, type Unique, type Unsupported, type Violated, type Violation, checkInvariant, checkInvariants, checkedRung, describeSpecVerdict, describeVerdict, explore, replay, specLadder, testedRung, validateScenario };
252
141
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../core/src/spec-verdict.ts","../../engine/src/observe.ts","../../engine/src/shrink.ts","../../spec/src/ir.ts","../../spec/src/extract.ts","../../spec/src/parse.ts","../../spec/src/predicate.ts","../../spec/src/print.ts","../../prover/src/checked.ts","../../report/src/regression.ts","../../report/src/render.ts"],"mappings":";;;;;;;;UAOU;;WAEC;WACA;;WAEA;;WAEA;WACA;;UAGM,gBAAgB;WACtB;;WAEA;;WAEA;;;UAIM;;WAEN;aAA6B;aAAuB;;WACpD;;WAEA;;UAGM,gBAAgB;WACtB;WACA;WACA,gBAAgB;;KAGf;UAEK,oBAAoB;WAC1B;WACA,OAAO;WACP;;KAGC,cAAc,UAAU,UAAU;;wBAG9B,oBAAoB,GAAG;UCnCtB;WACN;;WAEA;WACA;;UAGM;WACN,gBAAgB;;WAEhB;cAA0B;;;EAEnC;;wBA0Cc,YAAY,mBAAmB,+BAA+B;;wBCjC9D,aACd,UAAU,UACV,MAAM,cACN,6BACC;;;;;;;;;KCjCS;;;;;UAQK;WACN;WACA;;;KAIC;WACG;WAA2B,OAAO;WAAmB,OAAO;;WAC5D;WAAwB;WAA0B;;UAEhD;WACN;WACA,QAAQ;WACR,QAAQ;;;;;;;;;KAUP;WACG;WAAuB;;WAEvB;WACA;WACA;;WAEA;;WAEA;WAAsB,SAAS;;WAC/B;WAA6B,mBAAmB;;WAEhD;WACA,sBAAsB;WACtB,YAAY;;WAEZ;WAAsB,MAAM;WAAkB,OAAO;;;;;;;UAOnD;WACN,kBAAkB;WAClB,mBAAmB;WACnB,OAAO;;;UAID;WACN;WACA,UAAU;;WAEV;;;UAIM;WACN;;WAEA;WACA,kBAAkB;;WAElB;;WAEA;;WAEA;;;UAIM;WACN;WACA;;;UAIM;WACN,oBAAoB;WACpB;WACA,iBAAiB;;wBCuEZ,aAAa,iBAAiB;;qBCjJjC,yBAAyB;WAC3B;EACT,YAAY,6BAA6B;;;wBAmC3B,cAAc,eAAe;;KCnDjC;;wBCgEI,cAAc,GAAG;;wBClDjB,gBAAgB;;wBAOhB,UAAU;UAqET;WACN;WACA,IAAI;WACJ,UAAU;;WAEV;aAA2B;;;WAE3B,gBAAgB,qBAAqB;;WAErC;;wBAGK,YAAY,OAAO,eAAe;;UA2HjC;YACL;cAAyB,uBAAuB,qBAAqB;;;;wBAIjE,gBACd,gBACA,OAAO,aACP,YAAY,kBACZ;WACW;aAA2B;aAA2B;;WACtD;cAA0B;;IAEpC;UC9Oc;;WAEN;;WAEA;;WAEA;;WAEA;WACA;;;;;;WAMA;aACE;aACA;;;wBAIG,mBAAmB,SAAS,UAAU,SAAS;;;;;wBCf/C,WAAW,SAAS,iBAAiB,iBAAgB;;wBAUrD,YAAY,gBAAgB;;wBAqC5B,YAAY,KAAK,WAAW;;wBAuB5B,WAAW,SAAS"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../spec/src/extract.ts","../../spec/src/parse.ts","../../spec/src/print.ts","../../prover/src/provers.ts","../../engine/src/observe.ts","../../engine/src/shrink.ts","../../report/src/regression.ts","../../report/src/render.ts"],"mappings":";;wBA4KgB,aAAa,iBAAiB;;qBCjJjC,yBAAyB;WAC3B;EACT,YAAY,6BAA6B;;;wBAmC3B,cAAc,eAAe;;wBCa7B,cAAc,GAAG;UC/DhB;WACN;WACA;;KAGC;WACG;WAAyB,QAAQ;WAAmB;;WAEpD;WACA,QAAQ;WACR,iBAAiB;WACjB;;WAGA;WACA;WACA;;UAGE;WACN;;WAEA;WACA,SAAS;;UAGH;WACN,kBAAkB;;WAElB,qBAAqB;;UAGf;;WAEN;;WAEA;;WAEA,QAAQ;WACR;;UAGM;WACN;;EAET,aAAa;aAAmB;;aAA+B;;EAC/D,MAAM,OAAO,aAAa,QAAQ;;;UAInB;WACN;WACA,QAAQ;;;;;;;;;;;;wBAaH,UACd,gBACA,mBAAmB,eACnB,kBAAkB,iBACjB;;;;;;;;;;;;;;UCjEc;WACN;;WAEA;WACA;;UAGM;WACN,gBAAgB;;WAEhB;cAA0B;;;EAEnC;;wBAGc,YAAY,mBAAmB,+BAA+B;;wBCK9D,aACd,UAAU,UACV,MAAM,cACN,6BACC;UC7Bc;;WAEN;;WAEA;;WAEA;;WAEA;WACA;;;;;;WAMA;aACE;aACA;;;wBAIG,mBAAmB,SAAS,UAAU,SAAS;;;;;wBCf/C,WAAW,SAAS,iBAAiB,iBAAgB;;wBAUrD,YAAY,gBAAgB;;wBAwE5B,YAAY,KAAK,WAAW;;wBAuB5B,WAAW,SAAS"}