eutaxy 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +2 -2
  2. package/dist/aws.d.mts +7 -5
  3. package/dist/aws.d.mts.map +1 -1
  4. package/dist/aws.mjs +41 -135
  5. package/dist/aws.mjs.map +1 -1
  6. package/dist/bin.mjs +2 -2
  7. package/dist/checked-CGpA2-F0.d.mts +285 -0
  8. package/dist/checked-CGpA2-F0.d.mts.map +1 -0
  9. package/dist/cli-IJrKkeYS.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 +232 -51
  13. package/dist/cloudflare.d.mts.map +1 -1
  14. package/dist/cloudflare.mjs +3 -1083
  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-Cuxdna28.mjs +39 -0
  18. package/dist/delivery-invariants-Cuxdna28.mjs.map +1 -0
  19. package/dist/index.d.mts +66 -5
  20. package/dist/index.d.mts.map +1 -1
  21. package/dist/index.mjs +81 -5
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/{platform-TwATAkL3.d.mts → platform-DfMwknw1.d.mts} +179 -42
  24. package/dist/platform-DfMwknw1.d.mts.map +1 -0
  25. package/dist/src-Bqc9Eyb1.mjs +2655 -0
  26. package/dist/src-Bqc9Eyb1.mjs.map +1 -0
  27. package/dist/src-DKb-fkdb.mjs +3399 -0
  28. package/dist/src-DKb-fkdb.mjs.map +1 -0
  29. package/dist/src-Dxl9ZlKn.mjs +1752 -0
  30. package/dist/src-Dxl9ZlKn.mjs.map +1 -0
  31. package/package.json +1 -1
  32. package/dist/cli-Dr-Ziogu.mjs +0 -2
  33. package/dist/cloudflare.mjs.map +0 -1
  34. package/dist/explore-YVHTRjjS.d.mts +0 -63
  35. package/dist/explore-YVHTRjjS.d.mts.map +0 -1
  36. package/dist/platform-TwATAkL3.d.mts.map +0 -1
  37. package/dist/src-BBXd0WEp.mjs +0 -117
  38. package/dist/src-BBXd0WEp.mjs.map +0 -1
  39. package/dist/src-BGdIBGkN.mjs +0 -311
  40. package/dist/src-BGdIBGkN.mjs.map +0 -1
  41. package/dist/src-Brt0dfNL.mjs +0 -1286
  42. package/dist/src-Brt0dfNL.mjs.map +0 -1
  43. package/dist/src-s6uYyC0B.mjs +0 -89
  44. package/dist/src-s6uYyC0B.mjs.map +0 -1
  45. package/dist/verdict-evEM5Gxx.mjs +0 -12
  46. package/dist/verdict-evEM5Gxx.mjs.map +0 -1
@@ -0,0 +1,5 @@
1
+ import { E as EffectSelector, k as JsonValue, m as AtMostOncePerKey, p as AtLeastOnce } from "./platform-DfMwknw1.mjs";
2
+ declare function atMostOncePerKey(name: string, effect: EffectSelector, key: string): AtMostOncePerKey;
3
+ declare function atLeastOnce(name: string, effect: EffectSelector, key: string, expected: readonly JsonValue[]): AtLeastOnce;
4
+ export { atMostOncePerKey as n, atLeastOnce as t };
5
+ //# sourceMappingURL=delivery-invariants-BraYqcYN.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-invariants-BraYqcYN.d.mts","names":[],"sources":["../../core/src/delivery-invariants.ts"],"mappings":";iBAUgB,iBACd,cACA,QAAQ,gBACR,cACC;iBAIa,YACd,cACA,QAAQ,gBACR,aACA,mBAAmB,cAClB"}
@@ -0,0 +1,39 @@
1
+ import { x as getPath } from "./src-Bqc9Eyb1.mjs";
2
+ // packages/core/src/delivery-invariants.ts
3
+ function atMostOncePerKey(name, effect, key) {
4
+ return {
5
+ kind: "atMostOncePerKey",
6
+ name,
7
+ effect,
8
+ key
9
+ };
10
+ }
11
+ function atLeastOnce(name, effect, key, expected) {
12
+ return {
13
+ kind: "atLeastOnce",
14
+ name,
15
+ effect,
16
+ key,
17
+ expected
18
+ };
19
+ }
20
+ /**
21
+ * Every event's `bodyKey` value must appear at least once as `key` in a
22
+ * selected effect. The expected keys are re-derived from the bodies that
23
+ * remain when shrinking removes events.
24
+ */
25
+ function atLeastOncePerMessage(name, events, effect, key, bodyKey) {
26
+ const expected = [];
27
+ for (const e of events) {
28
+ const v = getPath(e.body, bodyKey);
29
+ if (v === void 0) throw new Error(`event ${e.id} has no ${JSON.stringify(bodyKey)} in its body`);
30
+ expected.push(v);
31
+ }
32
+ return {
33
+ ...atLeastOnce(name, effect, key, expected),
34
+ perMessage: { bodyKey }
35
+ };
36
+ }
37
+ export { atLeastOncePerMessage as n, atMostOncePerKey as r, atLeastOnce as t };
38
+
39
+ //# sourceMappingURL=delivery-invariants-Cuxdna28.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-invariants-Cuxdna28.mjs","names":[],"sources":["../../core/src/delivery-invariants.ts"],"sourcesContent":["/**\n * Constructors for the delivery invariants every platform's scenarios use:\n * nothing delivered twice, nothing lost. Platforms wrap them to take their\n * own drive shapes.\n */\n\nimport type { JsonValue } from \"./canonical-json.ts\";\nimport type { AtLeastOnce, AtMostOncePerKey } from \"./invariants.ts\";\nimport { type EffectSelector, getPath } from \"./selectors.ts\";\n\nexport function atMostOncePerKey(\n name: string,\n effect: EffectSelector,\n key: string,\n): AtMostOncePerKey {\n return { kind: \"atMostOncePerKey\", name, effect, key };\n}\n\nexport function atLeastOnce(\n name: string,\n effect: EffectSelector,\n key: string,\n expected: readonly JsonValue[],\n): AtLeastOnce {\n return { kind: \"atLeastOnce\", name, effect, key, expected };\n}\n\n/**\n * Every event's `bodyKey` value must appear at least once as `key` in a\n * selected effect. The expected keys are re-derived from the bodies that\n * remain when shrinking removes events.\n */\nexport function atLeastOncePerMessage(\n name: string,\n events: readonly { readonly id: string; readonly body: JsonValue }[],\n effect: EffectSelector,\n key: string,\n bodyKey: string,\n): AtLeastOnce {\n const expected: JsonValue[] = [];\n for (const e of events) {\n const v = getPath(e.body, bodyKey);\n if (v === undefined)\n throw new Error(`event ${e.id} has no ${JSON.stringify(bodyKey)} in its body`);\n expected.push(v);\n }\n return { ...atLeastOnce(name, effect, key, expected), perMessage: { bodyKey } };\n}\n"],"mappings":";;AAUA,SAAgB,iBACd,MACA,QACA,KACkB;CAClB,OAAO;EAAE,MAAM;EAAoB;EAAM;EAAQ;CAAI;AACvD;AAEA,SAAgB,YACd,MACA,QACA,KACA,UACa;CACb,OAAO;EAAE,MAAM;EAAe;EAAM;EAAQ;EAAK;CAAS;AAC5D;;;;;;AAOA,SAAgB,sBACd,MACA,QACA,QACA,KACA,SACa;CACb,MAAM,WAAwB,CAAC;CAC/B,KAAK,MAAM,KAAK,QAAQ;EACtB,MAAM,IAAI,QAAQ,EAAE,MAAM,OAAO;EACjC,IAAI,MAAM,KAAA,GACR,MAAM,IAAI,MAAM,SAAS,EAAE,GAAG,UAAU,KAAK,UAAU,OAAO,EAAE,aAAa;EAC/E,SAAS,KAAK,CAAC;CACjB;CACA,OAAO;EAAE,GAAG,YAAY,MAAM,QAAQ,KAAK,QAAQ;EAAG,YAAY,EAAE,QAAQ;CAAE;AAChF"}
package/dist/index.d.mts CHANGED
@@ -1,7 +1,46 @@
1
- import { C as Schedule, S as FaultKind, T as EffectRecord, _ as StateQuery, b as checkInvariants, d as AtMostOncePerKey, f as EffectSelector, g as RowCondition, 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 Violation, w as EffectLog, x as FaultDecision, y as checkInvariant } from "./platform-TwATAkL3.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-YVHTRjjS.mjs";
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 { C as Checked, D as SpecVerdict, E as SpecUnknown, O as describeSpecVerdict, S as describeVerdict, T as Refuted, _ as Bounded, a as lemmaUnresolved$1, b as Unsupported, c as Formula, d as ModuleSpecs, f as NamedProperty, g as replay, h as explore, i as lemmaBool$1, l as FunctionSpec, m as ExploreOptions, n as checkSpecModule$1, o as Binder, p as Property, r as checkedRung, s as Domain, t as ModulePredicates$1, u as Guard, v as BoundsReached, w as Counterexample, x as Violated, y as ScenarioVerdict } from "./checked-CGpA2-F0.mjs";
3
+ /**
4
+ * Observe a module's pure core functions while runs are installed: each call
5
+ * from outside the module is recorded with its arguments, for spec checks
6
+ * on the inputs the simulator passed, and logged as a decision of the
7
+ * invocation that made it (`Core:<function>`, payload `{ args, result }` or
8
+ * `{ args, error }`), for `refines`. Calls the module makes to itself do not
9
+ * go through its exports and are not seen.
10
+ *
11
+ * Observing replaces the export on the module's namespace object, which
12
+ * works where a bundler or test runner gives modules a namespace with
13
+ * configurable properties (Vite, so Vitest and the Cloudflare plugin); a
14
+ * native ESM namespace is frozen, and the function is reported unobservable.
15
+ */
16
+ interface ObservedCall {
17
+ readonly function: string;
18
+ /** The arguments as passed; primitives exactly, objects by reference. */
19
+ readonly args: readonly unknown[];
20
+ readonly threw: boolean;
21
+ }
22
+ interface CoreObserver {
23
+ readonly calls: readonly ObservedCall[];
24
+ /** Functions that could not be observed, with why. */
25
+ readonly unobservable: {
26
+ readonly [fn: string]: string;
27
+ };
28
+ /** Put the original exports back. Safe to call twice. */
29
+ restore(): void;
30
+ }
31
+ export declare function observeCore(namespace: object, functions: readonly string[]): CoreObserver;
3
32
  /** The scenario restricted to the kept events, with per-message invariants re-derived. */
4
33
  export declare function restrictSpec(platform: Platform, spec: ScenarioSpec, keepIds: readonly string[]): ScenarioSpec;
34
+ export declare function extractSpecs(source: string): ModuleSpecs;
35
+ /** A property that is not Lemma. `stage` says which part rejected it. */
36
+ export declare class LemmaSyntaxError extends Error {
37
+ readonly stage: "prefix" | "formula";
38
+ constructor(stage: "prefix" | "formula", message: string);
39
+ }
40
+ /** Parse the text after `@ensures{name}`. Throws LemmaSyntaxError. */
41
+ export declare function parseProperty(text: string): Property;
42
+ /** The property as Lemma text (what follows `@ensures{name}`). */
43
+ export declare function printProperty(p: Property): string;
5
44
  interface RegressionTestOptions {
6
45
  /** Import lines for the scenario, the platform's dependencies, and anything the platform expression needs. */
7
46
  readonly imports: readonly string[];
@@ -12,13 +51,35 @@ interface RegressionTestOptions {
12
51
  /** Module that exports `replay`, `restrictSpec` and `checkInvariants`; the public facade by default. */
13
52
  readonly engineModule?: string;
14
53
  readonly expect?: "holds" | "violates";
54
+ /**
55
+ * Core functions to observe during the replay, as `refines` needs their
56
+ * decisions in the log: an expression for each module's namespace (from
57
+ * the imports) and the functions to observe on it.
58
+ */
59
+ readonly observe?: readonly {
60
+ readonly namespace: string;
61
+ readonly functions: readonly string[];
62
+ }[];
15
63
  }
16
64
  export declare function emitRegressionTest(verdict: Violated, options: RegressionTestOptions): string;
17
- /** The JSON report: one object, canonical, with a schema version at the top. */
18
- export declare function renderJson(verdict: ScenarioVerdict): string;
65
+ /**
66
+ * The JSON report: one object, canonical, with a schema version at the top.
67
+ * Spec verdicts, when there are any, sit beside the scenario's, never in it.
68
+ */
69
+ export declare function renderJson(verdict: ScenarioVerdict, specs?: readonly SpecVerdict[]): string;
70
+ /** Spec verdicts as text: one line each, a counterexample under a refutation. */
71
+ export declare function renderSpecs(specs: readonly SpecVerdict[]): string;
19
72
  /** The trace as a fixed-width table; evidence rows are marked with `*`. */
20
73
  export declare function renderTrace(log: EffectLog, evidence?: readonly number[]): string;
21
74
  /** A readable report: verdict, what it rests on, and for a violation the schedule and trace. */
22
75
  export declare function renderText(verdict: ScenarioVerdict): string;
23
- export { type AtLeastOnce, type AtMostOncePerKey, type Bounded, type Bounds, type BoundsReached, type EffectLog, type EffectRecord, type EffectSelector, type EventRef, type EveryRow, type ExploreOptions, type FaultDecision, type FaultKind, type Implies, type Invariant, type Platform, type RegressionTestOptions, type RowCondition, type ScenarioSpec, type ScenarioVerdict, type Schedule, type StateQuery, type Unsupported, type Violated, type Violation, checkInvariant, checkInvariants, describeVerdict, explore, replay, validateScenario };
76
+ /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
77
+ export declare const checkSpecModule: typeof checkSpecModule$1;
78
+ /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
79
+ export declare const lemmaBool: typeof lemmaBool$1;
80
+ /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
81
+ export declare const lemmaUnresolved: typeof lemmaUnresolved$1;
82
+ /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
83
+ export type ModulePredicates = ModulePredicates$1;
84
+ 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 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, checkedRung, describeSpecVerdict, describeVerdict, explore, replay, validateScenario };
24
85
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../engine/src/shrink.ts","../../report/src/regression.ts","../../report/src/render.ts"],"mappings":";;;wBAsCgB,aACd,UAAU,UACV,MAAM,cACN,6BACC;UC7Bc;;WAEN;;WAEA;;WAEA;;WAEA;WACA;;wBAGK,mBAAmB,SAAS,UAAU,SAAS;;wBCf/C,WAAW,SAAS;;wBAiBpB,YAAY,KAAK,WAAW;;wBAuB5B,WAAW,SAAS"}
1
+ {"version":3,"file":"index.d.mts","names":["prover.checkSpecModule","prover.lemmaBool","prover.lemmaUnresolved","prover.ModulePredicates"],"sources":["../../engine/src/observe.ts","../../engine/src/shrink.ts","../../spec/src/extract.ts","../../spec/src/parse.ts","../../spec/src/print.ts","../../report/src/regression.ts","../../report/src/render.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAkBiB;WACN;;WAEA;WACA;;UAGM;WACN,gBAAgB;;WAEhB;cAA0B;;;EAEnC;;wBAGc,YAAY,mBAAmB,+BAA+B;;wBCK9D,aACd,UAAU,UACV,MAAM,cACN,6BACC;wBCkIa,aAAa,iBAAiB;;qBCjJjC,yBAAyB;WAC3B;EACT,YAAY,6BAA6B;;;wBAmC3B,cAAc,eAAe;;wBCa7B,cAAc,GAAG;UChEhB;;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;;qBCrCvB,wBAAeA;;qBAEf,kBAASC;;qBAET,wBAAeC;;YAEhB,mBAAmBC"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,81 @@
1
- import "./src-s6uYyC0B.mjs";
2
- import { d as validateScenario, f as checkInvariant, n as replay, p as checkInvariants, r as restrictSpec, t as explore } from "./src-Brt0dfNL.mjs";
3
- import { t as describeVerdict } from "./verdict-evEM5Gxx.mjs";
4
- import { i as emitRegressionTest, n as renderText, r as renderTrace, t as renderJson } from "./src-BBXd0WEp.mjs";
5
- export { checkInvariant, checkInvariants, describeVerdict, emitRegressionTest, explore, renderJson, renderText, renderTrace, replay, restrictSpec, validateScenario };
1
+ import { a as emitRegressionTest, c as checkedRung, f as extractSpecs, i as renderTrace, l as lemmaBool$1, m as parseProperty, n as renderSpecs, o as describeVerdict, p as LemmaSyntaxError, r as renderText, s as checkSpecModule$1, t as renderJson, u as lemmaUnresolved$1 } from "./src-Dxl9ZlKn.mjs";
2
+ import { a as explore, b as checkInvariants, o as replay, s as restrictSpec, t as observeCore, v as validateScenario, y as checkInvariant } from "./src-Bqc9Eyb1.mjs";
3
+ // packages/spec/src/print.ts
4
+ const precedence = {
5
+ iff: 1,
6
+ implies: 2,
7
+ or: 3,
8
+ and: 4,
9
+ not: 5,
10
+ atom: 6,
11
+ equation: 6
12
+ };
13
+ function guardText(g) {
14
+ if (g.kind === "regex") return `/${g.pattern}/${g.flags}`;
15
+ return `${g.lower.inclusive ? "[" : "("}${g.lower.value}, ${g.upper.value}${g.upper.inclusive ? "]" : ")"}`;
16
+ }
17
+ function sameGroup(a, b) {
18
+ return a.domain === b.domain && a.guard === void 0 === (b.guard === void 0) && (a.guard === void 0 || b.guard !== void 0 && guardText(a.guard) === guardText(b.guard));
19
+ }
20
+ function prefixText(binders) {
21
+ const groups = [];
22
+ for (const b of binders) {
23
+ const last = groups[groups.length - 1];
24
+ if (last && sameGroup(last[0], b)) last.push(b);
25
+ else groups.push([b]);
26
+ }
27
+ return `forall ${groups.map((g) => {
28
+ const head = g[0];
29
+ const guard = head.guard ? ` ∈ ${guardText(head.guard)}` : "";
30
+ return `(${g.map((b) => b.name).join(" ")}: ${head.domain}${guard})`;
31
+ }).join(" ")}`;
32
+ }
33
+ /** Print a formula, parenthesized when its precedence is below `min`. */
34
+ function printFormula(f, min = 0) {
35
+ let s;
36
+ switch (f.kind) {
37
+ case "atom":
38
+ s = f.text;
39
+ break;
40
+ case "equation":
41
+ s = `${f.left} ${f.negated ? "≢" : "≡"} ${f.right}`;
42
+ break;
43
+ case "not":
44
+ s = `¬${printFormula(f.operand, precedence.not)}`;
45
+ break;
46
+ case "and":
47
+ case "or":
48
+ s = f.operands.map((o) => printFormula(o, precedence[f.kind] + 1)).join(f.kind === "and" ? " ∧ " : " ∨ ");
49
+ break;
50
+ case "implies":
51
+ s = [...f.antecedents, f.consequent].map((o) => printFormula(o, precedence.or)).join(" → ");
52
+ break;
53
+ case "iff": s = `${printFormula(f.left, precedence.implies)} ↔ ${printFormula(f.right, precedence.implies)}`;
54
+ }
55
+ return precedence[f.kind] < min ? `(${s})` : s;
56
+ }
57
+ /** The property as Lemma text (what follows `@ensures{name}`). */
58
+ function printProperty(p) {
59
+ const body = p.requires.length > 0 ? [...p.requires, p.claim].map((f) => printFormula(f, precedence.or)).join(" → ") : printFormula(p.claim, p.claim.kind === "implies" ? precedence.or : 0);
60
+ return `${prefixText(p.binders)} { ${body} }`;
61
+ }
62
+ // packages/core/src/spec-verdict.ts
63
+ /** One line per spec verdict, for error messages; full rendering lives in `report`. */
64
+ function describeSpecVerdict(v) {
65
+ const what = `${v.function} ${v.property}`;
66
+ switch (v.kind) {
67
+ case "CHECKED": return `CHECKED ${what}: held on ${v.inputs} input(s) the simulator passed`;
68
+ case "REFUTED": return `REFUTED ${what}: ${v.counterexample.call}${v.counterexample.error ? ` threw ${v.counterexample.error}` : ""}`;
69
+ case "UNKNOWN": return `UNKNOWN ${what}: ${v.cause}: ${v.reason}`;
70
+ }
71
+ }
72
+ // packages/eutaxy/src/index.ts
73
+ /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
74
+ const checkSpecModule = checkSpecModule$1;
75
+ /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
76
+ const lemmaBool = lemmaBool$1;
77
+ /** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */
78
+ const lemmaUnresolved = lemmaUnresolved$1;
79
+ export { LemmaSyntaxError, checkInvariant, checkInvariants, checkSpecModule, checkedRung, describeSpecVerdict, describeVerdict, emitRegressionTest, explore, extractSpecs, lemmaBool, lemmaUnresolved, observeCore, parseProperty, printProperty, renderJson, renderSpecs, renderText, renderTrace, replay, restrictSpec, validateScenario };
80
+
81
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["prover.checkSpecModule","prover.lemmaBool","prover.lemmaUnresolved"],"sources":["../../spec/src/print.ts","../../core/src/spec-verdict.ts","../src/index.ts"],"sourcesContent":["/**\n * Print SpecIR back as Lemma, canonically: glyph connectives, binders with\n * the same domain and guard grouped, and parentheses only where precedence\n * or a root-level material implication needs them. Parsing what it prints\n * gives the same IR.\n */\n\nimport type { Binder, Formula, Guard, Property } from \"./ir.ts\";\n\nconst precedence: { readonly [k in Formula[\"kind\"]]: number } = {\n iff: 1,\n implies: 2,\n or: 3,\n and: 4,\n not: 5,\n atom: 6,\n equation: 6,\n};\n\nfunction guardText(g: Guard): string {\n if (g.kind === \"regex\") return `/${g.pattern}/${g.flags}`;\n return `${g.lower.inclusive ? \"[\" : \"(\"}${g.lower.value}, ${g.upper.value}${g.upper.inclusive ? \"]\" : \")\"}`;\n}\n\nfunction sameGroup(a: Binder, b: Binder): boolean {\n return (\n a.domain === b.domain &&\n (a.guard === undefined) === (b.guard === undefined) &&\n (a.guard === undefined || (b.guard !== undefined && guardText(a.guard) === guardText(b.guard)))\n );\n}\n\nfunction prefixText(binders: readonly Binder[]): string {\n const groups: Binder[][] = [];\n for (const b of binders) {\n const last = groups[groups.length - 1];\n if (last && sameGroup(last[0] as Binder, b)) last.push(b);\n else groups.push([b]);\n }\n const text = groups.map((g) => {\n const head = g[0] as Binder;\n const guard = head.guard ? ` ∈ ${guardText(head.guard)}` : \"\";\n return `(${g.map((b) => b.name).join(\" \")}: ${head.domain}${guard})`;\n });\n return `forall ${text.join(\" \")}`;\n}\n\n/** Print a formula, parenthesized when its precedence is below `min`. */\nexport function printFormula(f: Formula, min = 0): string {\n let s: string;\n switch (f.kind) {\n case \"atom\":\n s = f.text;\n break;\n case \"equation\":\n s = `${f.left} ${f.negated ? \"≢\" : \"≡\"} ${f.right}`;\n break;\n case \"not\":\n s = `¬${printFormula(f.operand, precedence.not)}`;\n break;\n case \"and\":\n case \"or\":\n s = f.operands\n .map((o) => printFormula(o, precedence[f.kind] + 1))\n .join(f.kind === \"and\" ? \" ∧ \" : \" ∨ \");\n break;\n case \"implies\":\n s = [...f.antecedents, f.consequent].map((o) => printFormula(o, precedence.or)).join(\" → \");\n break;\n case \"iff\":\n s = `${printFormula(f.left, precedence.implies)} ↔ ${printFormula(f.right, precedence.implies)}`;\n break;\n }\n return precedence[f.kind] < min ? `(${s})` : s;\n}\n\n/** The property as Lemma text (what follows `@ensures{name}`). */\nexport function printProperty(p: Property): string {\n // A root implication is the preconditions; a material one there needs its parentheses.\n const body =\n p.requires.length > 0\n ? [...p.requires, p.claim].map((f) => printFormula(f, precedence.or)).join(\" → \")\n : printFormula(p.claim, p.claim.kind === \"implies\" ? precedence.or : 0);\n return `${prefixText(p.binders)} { ${body} }`;\n}\n","/**\n * Spec verdicts: what is known about one property of one pure function.\n * Kept apart from scenario verdicts in every report. The ladder starts at\n * `CHECKED` (held on every input the simulator passed); `TESTED` and\n * `PROVEN` come with the provers.\n */\n\ninterface SpecVerdictBase {\n /** The module, as the scenario names it. */\n readonly module: string;\n readonly function: string;\n /** The `@ensures` name, or `@total` / `@throws` for those markers. */\n readonly property: string;\n /** The property as written. */\n readonly text: string;\n readonly assumptions: readonly string[];\n}\n\nexport interface Checked extends SpecVerdictBase {\n readonly kind: \"CHECKED\";\n /** Distinct inputs the property was evaluated on. */\n readonly inputs: number;\n /** Distinct inputs outside the claim: a precondition failed, or a value fell outside its binder's domain. */\n readonly discarded: number;\n}\n\n/** One assignment that breaks the property, as JavaScript literals, and the call it came from. */\nexport interface Counterexample {\n /** In the property's binder order. */\n readonly binders: readonly { readonly name: string; readonly value: string }[];\n readonly call: string;\n /** Set when evaluating the property threw instead of returning false. */\n readonly error?: string;\n}\n\nexport interface Refuted extends SpecVerdictBase {\n readonly kind: \"REFUTED\";\n readonly rung: \"CHECKED\";\n readonly counterexample: Counterexample;\n}\n\nexport type SpecUnknownCause = \"gave_up\" | \"unsupported\" | \"unavailable\";\n\nexport interface SpecUnknown extends SpecVerdictBase {\n readonly kind: \"UNKNOWN\";\n readonly cause: SpecUnknownCause;\n readonly reason: string;\n}\n\nexport type SpecVerdict = Checked | Refuted | SpecUnknown;\n\n/** One line per spec verdict, for error messages; full rendering lives in `report`. */\nexport function describeSpecVerdict(v: SpecVerdict): string {\n const what = `${v.function} ${v.property}`;\n switch (v.kind) {\n case \"CHECKED\":\n return `CHECKED ${what}: held on ${v.inputs} input(s) the simulator passed`;\n case \"REFUTED\":\n return `REFUTED ${what}: ${v.counterexample.call}${v.counterexample.error ? ` threw ${v.counterexample.error}` : \"\"}`;\n case \"UNKNOWN\":\n return `UNKNOWN ${what}: ${v.cause}: ${v.reason}`;\n }\n}\n","// eutaxy: the public API. Platform-specific entry points live under subpaths.\nimport * as prover from \"@eutaxy/prover\";\n\nexport {\n type AtLeastOnce,\n type AtMostOncePerKey,\n type Bounded,\n type Bounds,\n type BoundsReached,\n type Checked,\n type Counterexample,\n checkInvariant,\n checkInvariants,\n describeSpecVerdict,\n describeVerdict,\n type EffectLog,\n type EffectRecord,\n type EffectSelector,\n type EventRef,\n type EveryRow,\n type FaultDecision,\n type FaultKind,\n type Implies,\n type Invariant,\n type Platform,\n type Refines,\n type Refuted,\n type RowCondition,\n type ScenarioSpec,\n type ScenarioVerdict,\n type Schedule,\n type SpecUnknown,\n type SpecVerdict,\n type StateQuery,\n type Unique,\n type Unsupported,\n type Violated,\n type Violation,\n validateScenario,\n} from \"@eutaxy/core\";\nexport {\n type CoreObserver,\n type ExploreOptions,\n explore,\n type ObservedCall,\n observeCore,\n replay,\n restrictSpec,\n} from \"@eutaxy/engine\";\nexport { checkedRung } from \"@eutaxy/prover\";\n\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport const checkSpecModule = prover.checkSpecModule;\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport const lemmaBool = prover.lemmaBool;\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport const lemmaUnresolved = prover.lemmaUnresolved;\n/** @deprecated Internal to `eutaxy check` since 0.5.1; removed in 0.6.0. */\nexport type ModulePredicates = prover.ModulePredicates;\nexport {\n emitRegressionTest,\n type RegressionTestOptions,\n renderJson,\n renderSpecs,\n renderText,\n renderTrace,\n} from \"@eutaxy/report\";\nexport {\n type Binder,\n type Domain,\n extractSpecs,\n type Formula,\n type FunctionSpec,\n type Guard,\n LemmaSyntaxError,\n type ModuleSpecs,\n type NamedProperty,\n type Property,\n parseProperty,\n printProperty,\n} from \"@eutaxy/spec\";\n"],"mappings":"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"}
@@ -24,27 +24,6 @@ interface EffectRecord {
24
24
  interface EffectLog {
25
25
  readonly entries: readonly EffectRecord[];
26
26
  }
27
- /**
28
- * `cut_off` is a crash that happens after a response or acknowledgement was
29
- * already sent, so only background work (ctx.waitUntil) is lost; platforms
30
- * offer it at the point where that work would start.
31
- */
32
- type FaultKind = "crash_before" | "crash_after" | "ambiguous" | "error" | "cut_off";
33
- interface FaultDecision {
34
- /** The invocation the effect belongs to, e.g. "msg-1#2". */
35
- readonly invocation: string;
36
- /** Position of the effect within that invocation, from 0. Stable when other invocations are removed. */
37
- readonly ordinal: number;
38
- readonly fault: FaultKind;
39
- /** What the effect was, for people reading the schedule. */
40
- readonly target: string;
41
- readonly op: string;
42
- }
43
- interface Schedule {
44
- /** The per-run seed the decisions were drawn from. */
45
- readonly seed: number;
46
- readonly faults: readonly FaultDecision[];
47
- }
48
27
  /** Picks effect records by target, op, kind and payload fields. */
49
28
  interface EffectSelector {
50
29
  readonly target: string;
@@ -59,24 +38,32 @@ interface EffectSelector {
59
38
  readonly [path: string]: number;
60
39
  };
61
40
  }
62
- /** No two selected effects share the same key. Catches duplicate writes. */
63
- interface AtMostOncePerKey {
64
- readonly kind: "atMostOncePerKey";
65
- readonly name: string;
66
- readonly effect: EffectSelector;
67
- /** Dot path into the payload that identifies the key. */
68
- readonly key: string;
69
- }
70
- /** Every expected key appears in at least one selected effect. Catches lost work. */
71
- interface AtLeastOnce {
72
- readonly kind: "atLeastOnce";
41
+ /**
42
+ * The shell follows the core. Calls to a pure core function are recorded as
43
+ * decisions (`Core:<function>` results, payload `{ args, result }`). Every
44
+ * selected effect must come after a decision of `decision` in its own
45
+ * invocation; the latest such decision is the one it carries out. With
46
+ * `follows`, the effect's payload agrees with that decision at each pair of
47
+ * paths. With `state`, the decision rests on the last `read` its invocation
48
+ * made before it (none is a violation), and no other invocation's `write`
49
+ * (to the same `key`, when given) commits between that read and the effect:
50
+ * otherwise the effect carried out a decision made on a stale read.
51
+ */
52
+ interface Refines {
53
+ readonly kind: "refines";
73
54
  readonly name: string;
55
+ /** The core function, as recorded. */
56
+ readonly decision: string;
74
57
  readonly effect: EffectSelector;
75
- readonly key: string;
76
- readonly expected: readonly JsonValue[];
77
- /** Set when `expected` was derived from the drive's message bodies, so it can be re-derived when messages are removed. */
78
- readonly perMessage?: {
79
- readonly bodyKey: string;
58
+ readonly follows?: readonly {
59
+ readonly effect: string;
60
+ readonly decision: string;
61
+ }[];
62
+ readonly state?: {
63
+ readonly read: EffectSelector;
64
+ readonly write: EffectSelector;
65
+ /** Dot path into the read's and the writes' payloads naming the state they touch. */
66
+ readonly key?: string;
80
67
  };
81
68
  }
82
69
  /** A condition on one column of a row. */
@@ -124,7 +111,53 @@ interface Implies {
124
111
  readonly state: StateQuery;
125
112
  readonly column: string;
126
113
  }
127
- type Invariant = AtMostOncePerKey | AtLeastOnce | EveryRow | Implies;
114
+ /**
115
+ * No two rows the query returns share the value at `path`, a dot path into
116
+ * the row (a column name for flat rows). Rows where it is absent or null are
117
+ * skipped. Catches a resource handed out twice, e.g. "no project holds two
118
+ * slots".
119
+ */
120
+ interface Unique {
121
+ readonly kind: "unique";
122
+ readonly name: string;
123
+ readonly query: StateQuery;
124
+ readonly path: string;
125
+ }
126
+ /**
127
+ * Every row the query returns is pointed at: some row of `in` has its
128
+ * `column` equal to the row's value at `path`, as with a foreign key. Rows
129
+ * where the value is absent or null are skipped. Catches orphans across two
130
+ * stores, e.g. "no stored object without the row that names it".
131
+ */
132
+ interface References {
133
+ readonly kind: "references";
134
+ readonly name: string;
135
+ readonly query: StateQuery;
136
+ readonly path: string;
137
+ readonly in: StateQuery;
138
+ readonly column: string;
139
+ }
140
+ /** No two selected effects share the same key. Catches duplicate writes. */
141
+ interface AtMostOncePerKey {
142
+ readonly kind: "atMostOncePerKey";
143
+ readonly name: string;
144
+ readonly effect: EffectSelector;
145
+ /** Dot path into the payload that identifies the key. */
146
+ readonly key: string;
147
+ }
148
+ /** Every expected key appears in at least one selected effect. Catches lost work. */
149
+ interface AtLeastOnce {
150
+ readonly kind: "atLeastOnce";
151
+ readonly name: string;
152
+ readonly effect: EffectSelector;
153
+ readonly key: string;
154
+ readonly expected: readonly JsonValue[];
155
+ /** Set when `expected` was derived from the drive's message bodies, so it can be re-derived when messages are removed. */
156
+ readonly perMessage?: {
157
+ readonly bodyKey: string;
158
+ };
159
+ }
160
+ type Invariant = AtMostOncePerKey | AtLeastOnce | EveryRow | Implies | Unique | References | Refines;
128
161
  interface Violation {
129
162
  readonly invariant: string;
130
163
  readonly message: string;
@@ -135,6 +168,34 @@ interface Violation {
135
168
  }
136
169
  declare function checkInvariant(log: EffectLog, inv: Invariant): Violation | null;
137
170
  declare function checkInvariants(log: EffectLog, invariants: readonly Invariant[]): readonly Violation[];
171
+ /**
172
+ * `cut_off` is a crash that happens after a response or acknowledgement was
173
+ * already sent, so only background work (ctx.waitUntil) is lost; platforms
174
+ * offer it at the point where that work would start.
175
+ */
176
+ type FaultKind = "crash_before" | "crash_after" | "ambiguous" | "error" | "cut_off";
177
+ interface FaultDecision {
178
+ /** The invocation the effect belongs to, e.g. "msg-1#2". */
179
+ readonly invocation: string;
180
+ /** Position of the effect within that invocation, from 0. Stable when other invocations are removed. */
181
+ readonly ordinal: number;
182
+ readonly fault: FaultKind;
183
+ /** What the effect was, for people reading the schedule. */
184
+ readonly target: string;
185
+ readonly op: string;
186
+ }
187
+ interface Schedule {
188
+ /** The per-run seed the decisions were drawn from. */
189
+ readonly seed: number;
190
+ readonly faults: readonly FaultDecision[];
191
+ /**
192
+ * The turn picked at each scheduling decision with more than one option,
193
+ * in order, as an index into the options (parked invocations by start
194
+ * order, then starting the next event). Absent: turns follow the seed.
195
+ * Exhaustive exploration records them, since it picks rather than draws.
196
+ */
197
+ readonly turns?: readonly number[];
198
+ }
138
199
  /** Opaque, JSON-shaped data owned by a platform package. `kind` names its shape. */
139
200
  interface PlatformData {
140
201
  readonly kind: string;
@@ -198,6 +259,12 @@ interface ScenarioSpec {
198
259
  readonly externals: readonly ExternalDecl[];
199
260
  readonly invariants: readonly Invariant[];
200
261
  readonly bounds: Bounds;
262
+ /**
263
+ * Modules of pure core functions with Lemma specs, relative to the
264
+ * scenario. Calls to their annotated functions are recorded as decisions
265
+ * during exploration, and each property is checked on the inputs seen.
266
+ */
267
+ readonly specs?: readonly string[];
201
268
  }
202
269
  /** Every reason a spec is not usable; empty when it is. */
203
270
  declare function validateScenario(spec: ScenarioSpec): readonly string[];
@@ -207,6 +274,18 @@ interface EventRef {
207
274
  /** 1 for the first delivery, 2 for the first redelivery, and so on. */
208
275
  readonly attempt: number;
209
276
  readonly data: JsonValue;
277
+ /**
278
+ * Virtual time (ms since the epoch) before which the event is not
279
+ * delivered, e.g. a resend after the caller's retry delay. Absent: as soon
280
+ * as possible. The engine advances the virtual clock to it once nothing
281
+ * else can move.
282
+ */
283
+ readonly at?: number;
284
+ /**
285
+ * What produced the event when it is not the scenario's drive, e.g. a
286
+ * Durable Object alarm, so the platform knows how to deliver it.
287
+ */
288
+ readonly source?: string;
210
289
  }
211
290
  /** What a proxy tells the engine about an effect it is about to perform. */
212
291
  interface EffectPoint {
@@ -216,6 +295,29 @@ interface EffectPoint {
216
295
  readonly args: JsonValue;
217
296
  /** Which faults make sense here; the engine only injects from this list. */
218
297
  readonly allowed: readonly FaultKind[];
298
+ /**
299
+ * Performing this effect runs user code that may make effects of its own
300
+ * (a Durable Object call). Those are part of this effect's turn even when
301
+ * the runtime does not carry async context into that code.
302
+ */
303
+ readonly hostsEffects?: boolean;
304
+ }
305
+ interface EffectOptions {
306
+ /**
307
+ * Called when the effect is abandoned while its `perform` is still
308
+ * running, because its invocation crashed inside it or its I/O hung: the
309
+ * place to reset whatever the perform left busy (a Durable Object). For a
310
+ * crash inside, it is called synchronously where the crash happens, in the
311
+ * async context of the code the perform runs.
312
+ */
313
+ readonly onAbandon?: () => void;
314
+ /**
315
+ * Whether an effect the hosted code makes may wait for its turn now. False
316
+ * while the hosted code holds every other event out (a Durable Object
317
+ * inside blockConcurrencyWhile): nothing else could enter it then, and it
318
+ * could not notice its release, so the effect runs at once.
319
+ */
320
+ readonly mayPark?: () => boolean;
219
321
  }
220
322
  /** One invocation of the Worker, as the engine tracks it. */
221
323
  interface Invocation {
@@ -226,13 +328,41 @@ interface Invocation {
226
328
  }
227
329
  /** What the engine offers a platform during one run. */
228
330
  interface RunHooks {
229
- startInvocation(id: string): Invocation;
331
+ /**
332
+ * Start tracking an invocation; it becomes the running one.
333
+ * @param options.bookkeeping Deprecated: use `bookkeeping()`. Tracks the
334
+ * invocation without it ever becoming the running one.
335
+ */
336
+ startInvocation(id: string, options?: {
337
+ readonly bookkeeping?: boolean;
338
+ }): Invocation;
339
+ /**
340
+ * The invocation the platform's own actions are recorded under (a dead
341
+ * letter, a caller giving up, an end-of-run snapshot), started on first
342
+ * use in the run. No fault crashes it and it never becomes the running
343
+ * one, so it cannot take over the effects of the handler it was started
344
+ * during.
345
+ */
346
+ bookkeeping(): string;
230
347
  /** Perform an asynchronous effect under fault injection and record it. */
231
- effect<T>(point: EffectPoint, perform: () => Promise<T>, summarize: (value: T) => JsonValue): Promise<T>;
348
+ effect<T>(point: EffectPoint, perform: () => Promise<T>, summarize: (value: T) => JsonValue, options?: EffectOptions): Promise<T>;
232
349
  /** Perform a synchronous effect under fault injection and record it. */
233
350
  effectSync<T>(point: EffectPoint, perform: () => T, summarize: (value: T) => JsonValue): T;
234
351
  /** Declare that the run touched something Eutaxy cannot control. */
235
352
  unsupported(reason: string): void;
353
+ /**
354
+ * The invocation whose code is running now. Proxies that cannot tell which
355
+ * invocation called them attribute their effects to it; with concurrent
356
+ * invocations only one runs at a time, so this is always the caller.
357
+ */
358
+ running(): string;
359
+ /**
360
+ * Queue an event now, before the current delivery finishes, e.g. a resend
361
+ * the caller makes as soon as it gives up while the handler's background
362
+ * work still runs. Equivalent to returning it in `followUps`, except for
363
+ * when it can start.
364
+ */
365
+ enqueue(event: EventRef): void;
236
366
  /** Record a state snapshot (not an effect point; never faulted). */
237
367
  snapshot(invocation: string, target: string, payload: JsonValue): void;
238
368
  /**
@@ -252,6 +382,13 @@ interface Platform {
252
382
  readonly name: string;
253
383
  /** What a verdict rests on that this platform decides, one line each. */
254
384
  readonly assumptions: readonly string[];
385
+ /**
386
+ * True when `deliver` may be called again before an earlier delivery has
387
+ * finished, which `maxConcurrentInvocations` above 1 needs. Such a
388
+ * platform attributes effects per delivery or through `RunHooks.running`,
389
+ * never through state shared between deliveries.
390
+ */
391
+ readonly concurrent?: boolean;
255
392
  /** Establish the scenario's initial state. Called before every run. */
256
393
  reset(spec: ScenarioSpec): Promise<void>;
257
394
  /** The events the scenario's drive produces, in order. */
@@ -265,5 +402,5 @@ interface Platform {
265
402
  /** Called when a run ends for any reason, after `finish` or after a failure: undo any per-run patching. */
266
403
  cleanup?(spec: ScenarioSpec): Promise<void>;
267
404
  }
268
- export { Schedule as C, JsonValue as E, FaultKind as S, EffectRecord as T, StateQuery as _, PlatformData as a, checkInvariants as b, WorkerRef as c, AtMostOncePerKey as d, EffectSelector as f, RowCondition as g, Invariant as h, ExternalDecl as i, validateScenario as l, Implies as m, Platform as n, ScenarioSpec as o, EveryRow as p, Bounds as r, ScriptedResponse as s, EventRef as t, AtLeastOnce as u, Violation as v, EffectLog as w, FaultDecision as x, checkInvariant as y };
269
- //# sourceMappingURL=platform-TwATAkL3.d.mts.map
405
+ export { StateQuery as C, EffectLog as D, EffectSelector as E, EffectRecord as O, RowCondition as S, Refines as T, checkInvariant as _, PlatformData as a, Implies as b, WorkerRef as c, FaultKind as d, Schedule as f, Violation as g, Invariant as h, ExternalDecl as i, JsonValue as k, validateScenario as l, AtMostOncePerKey as m, Platform as n, ScenarioSpec as o, AtLeastOnce as p, Bounds as r, ScriptedResponse as s, EventRef as t, FaultDecision as u, checkInvariants as v, Unique as w, References as x, EveryRow as y };
406
+ //# sourceMappingURL=platform-DfMwknw1.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-DfMwknw1.d.mts","names":[],"sources":["../../core/src/canonical-json.ts","../../core/src/effect-log.ts","../../core/src/selectors.ts","../../core/src/refines.ts","../../core/src/state.ts","../../core/src/invariants.ts","../../core/src/faults.ts","../../core/src/scenario.ts","../../core/src/platform.ts"],"mappings":";;;;;KAMY,wDAKC;YACG,cAAc;;;KCDlB;UAEK;;WAEN;WACA,MAAM;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;UAGH;WACN,kBAAkB;;;UCtBZ;WACN;WACA;WACA,OAAO;;WAEP;cAAoB,eAAe;;;WAEnC;cAAsB;;;;;;;;;;;;;;UCYhB;WACN;WACA;;WAEA;WACA,QAAQ;WACR;aAA8B;aAAyB;;WACvD;aACE,MAAM;aACN,OAAO;;aAEP;;;;KC5BD;WACG;WAAyB;WAA2B,OAAO;;WAC3D;WAAyB;WAA0C;;WACnE;WAAyB;WAAmB,gBAAgB;;WAC5D;WAAyB;;;UAGvB;;WAEN;WACA;WACA,iBAAiB;;;UAIX;WACN;WACA;WACA,OAAO;WACP,gBAAgB;;;;;;;UAQV;WACN;WACA;WACA,MAAM;;WAEN;WACA,OAAO;WACP;;;;;;;;UASM;WACN;WACA;WACA,OAAO;WACP;;;;;;;;UASM;WACN;WACA;WACA,OAAO;WACP;WACA,IAAI;WACJ;;;UChDM;WACN;WACA;WACA,QAAQ;;WAER;;;UAIM;WACN;WACA;WACA,QAAQ;WACR;WACA,mBAAmB;;WAEnB;aAAwB;;;KAoBvB,YACR,mBACA,cACA,WACA,UACA,SACA,aACA;UAEa;WACN;WACA;;WAEA;;WAEA;;iBAYK,eAAe,KAAK,WAAW,KAAK,YAAY;iBAiDhD,gBACd,KAAK,WACL,qBAAqB,uBACX;;;;;;KC7HA;UAEK;;WAEN;;WAEA;WACA,OAAO;;WAEP;WACA;;UAGM;;WAEN;WACA,iBAAiB;;;;;;;WAOjB;;;UCxBM;WACN;YACC,cAAc;;;UAIT;WACN;WACA;;;UAIM;;WAEN;;WAEA;WACA;WACA;cAAsB;;;WAEtB,OAAO;;;;;;;UAQD;WACN;;WAEA;WACA;;;;;;aAME;;;WAGF,qBAAqB;;;UAIf;WACN;WACA;WACA;WACA;;UAGM;WACN;WACA;;WAEA;WACA,QAAQ;;WAER,OAAO;;WAEP,gBAAgB;WAChB,oBAAoB;WACpB,qBAAqB;WACrB,QAAQ;;;;;;WAMR;;;iBAeK,iBAAiB,MAAM;;UCpFtB;WACN;;WAEA;WACA,MAAM;;;;;;;WAON;;;;;WAKA;;;UAIM;WACN;WACA;WACA;WACA,MAAM;;WAEN,kBAAkB;;;;;;WAMlB;;UAGM;;;;;;;;WAQN;;;;;;;WAOA;;;UAIM;WACN;;WAEA,SAAS;EAClB;;;UAIe;;;;;;EAMf,gBAAgB,YAAY;aAAqB;MAA0B;;;;;;;;EAQ3E;;EAEA,OAAO,GACL,OAAO,aACP,eAAe,QAAQ,IACvB,YAAY,OAAO,MAAM,WACzB,UAAU,gBACT,QAAQ;;EAEX,WAAW,GAAG,OAAO,aAAa,eAAe,GAAG,YAAY,OAAO,MAAM,YAAY;;EAEzF,YAAY;;;;;;EAMZ;;;;;;;EAOA,QAAQ,OAAO;;EAEf,SAAS,oBAAoB,gBAAgB,SAAS;;;;;;;EAOtD,OAAO,GAAG,SAAS,QAAQ,IAAI,qBAAqB,QAAQ;;UAG7C;WACN;;WAEA,oBAAoB;;UAGd;WACN;;WAEA;;;;;;;WAOA;;EAET,MAAM,MAAM,eAAe;;EAE3B,cAAc,MAAM,wBAAwB;;EAE5C,QAAQ,OAAO,UAAU,OAAO,UAAU,MAAM,eAAe,QAAQ;;EAEvE,eAAe,MAAM,cAAc,6BAA6B;;EAEhE,QAAQ,MAAM,cAAc,OAAO,WAAW;;EAE9C,SAAS,MAAM,eAAe"}