eutaxy 0.4.0 → 0.5.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/dist/bin.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as main } from "./src-BGdIBGkN.mjs";
3
- import "./cli-Dr-Ziogu.mjs";
2
+ import { t as main } from "./src-BD3jkjgG.mjs";
3
+ import "./cli-NqY61bpo.mjs";
4
4
  // packages/eutaxy/src/bin.ts
5
5
  process.stdout.on("error", (err) => {
6
6
  if (err.code === "EPIPE") process.exit(process.exitCode ?? 0);
@@ -0,0 +1,2 @@
1
+ import "./src-BD3jkjgG.mjs";
2
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.mts","names":[],"sources":["../../cli/src/main.ts"],"mappings":"A,UAqBiB;WACN;WACA,SAAS;WACT,SAAS;;wBAGE,KAAK,yBAAyB,IAAI,KAAK"}
1
+ {"version":3,"file":"cli.d.mts","names":[],"sources":["../../cli/src/main.ts"],"mappings":"A,UAsBiB;WACN;WACA,SAAS;WACT,SAAS;;wBAGE,KAAK,yBAAyB,IAAI,KAAK"}
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { t as main } from "./src-BGdIBGkN.mjs";
2
- import "./cli-Dr-Ziogu.mjs";
1
+ export { t as main } from "./src-BD3jkjgG.mjs";
2
+ import "./cli-NqY61bpo.mjs";
@@ -1,5 +1,5 @@
1
- import { E as JsonValue, _ as StateQuery, a as PlatformData, c as WorkerRef, d as AtMostOncePerKey, f as EffectSelector, g as RowCondition, h as Invariant, i as ExternalDecl, m as Implies, n as Platform, o as ScenarioSpec, p as EveryRow, r as Bounds, s as ScriptedResponse, u as AtLeastOnce } from "./platform-TwATAkL3.mjs";
2
- import { c as Violated, o as ScenarioVerdict, t as ExploreOptions } from "./explore-YVHTRjjS.mjs";
1
+ import { O as JsonValue, _ as RowCondition, a as PlatformData, c as WorkerRef, d as AtMostOncePerKey, f as EffectSelector, g as Refines, h as Invariant, i as ExternalDecl, m as Implies, n as Platform, o as ScenarioSpec, p as EveryRow, r as Bounds, s as ScriptedResponse, u as AtLeastOnce, v as StateQuery, y as Unique } from "./platform-eVgCMbX0.mjs";
2
+ import { c as Violated, o as ScenarioVerdict, t as ExploreOptions } from "./explore-BHYvAZKN.mjs";
3
3
  interface CloudflareRegressionOptions {
4
4
  /** Import path of the scenario module, relative to the emitted file. */
5
5
  readonly scenarioPath: string;
@@ -9,8 +9,15 @@ interface CloudflareRegressionOptions {
9
9
  readonly schemaPaths: Readonly<Record<string, string>>;
10
10
  /** The platform's retry limit, when the scenario was checked with a non-default one. */
11
11
  readonly maxRetries?: number;
12
+ /** The scenario sets up Durable Objects: pass the Cloudflare test helpers to the platform. */
13
+ readonly durableObjects?: boolean;
12
14
  readonly expect?: "holds" | "violates";
13
15
  readonly engineModule?: string;
16
+ /** Core modules to observe during the replay (import path, functions), for `refines`. */
17
+ readonly specModules?: readonly {
18
+ readonly path: string;
19
+ readonly functions: readonly string[];
20
+ }[];
14
21
  }
15
22
  /** A Vitest regression test for a Cloudflare scenario, to run under the Cloudflare Vitest plugin. */
16
23
  export declare function cloudflareRegressionTest(verdict: Violated, options: CloudflareRegressionOptions): string;
@@ -22,6 +29,16 @@ export declare function expectHolds(spec: ScenarioSpec, platform: Platform, opti
22
29
  export declare function snapshotD1(real: D1Database): Promise<{
23
30
  readonly [table: string]: readonly JsonValue[];
24
31
  }>;
32
+ /**
33
+ * The Cloudflare Vitest plugin's test helpers, as exported by
34
+ * `cloudflare:test` (pass the module namespace). Typed loosely on purpose:
35
+ * the plugin's generic overloads are too deep to check against an interface.
36
+ */
37
+ interface DurableObjectTestHelpers {
38
+ readonly runInDurableObject: unknown;
39
+ readonly evictDurableObject: unknown;
40
+ readonly listDurableObjectIds: unknown;
41
+ }
25
42
  /** One queue message to deliver; `id` defaults to its position. */
26
43
  interface QueueMessage {
27
44
  readonly id?: string;
@@ -63,24 +80,63 @@ type HttpRequestSpec = {
63
80
  * retry policy decides redelivery: a webhook provider resends a request it
64
81
  * got no 2xx for (`retryOn: "non-2xx"`, the default) or only on 5xx and
65
82
  * failures (`"5xx"`), up to `retries` times; a browser-like caller has
66
- * `retries: 0`.
83
+ * `retries: 0`. `delaysMs[i]` is the virtual time the caller waits before
84
+ * its resend number i + 1 (the last entry repeats; none means at once).
85
+ * `deadlineMs` is how long the caller waits for an answer: one that comes
86
+ * later counts as failed and is resent while the handler may still run.
67
87
  */
68
88
  interface HttpDrive extends PlatformData {
69
89
  readonly kind: "http";
70
90
  readonly requests: readonly HttpRequestSpec[];
71
91
  readonly retries: number;
72
92
  readonly retryOn: "non-2xx" | "5xx";
93
+ readonly delaysMs?: readonly number[];
94
+ readonly deadlineMs?: number;
73
95
  }
74
- export declare function http(requests: readonly HttpRequestInput[], options?: {
96
+ interface HttpCallerOptions {
75
97
  readonly retries?: number;
76
98
  readonly retryOn?: "non-2xx" | "5xx";
77
- }): HttpDrive;
99
+ readonly delaysMs?: readonly number[];
100
+ readonly deadlineMs?: number;
101
+ }
102
+ export declare function http(requests: readonly HttpRequestInput[], options?: HttpCallerOptions): HttpDrive;
78
103
  /** Apply a SQL file to a D1 binding before each run. */
79
104
  interface D1Setup extends PlatformData {
80
105
  readonly kind: "d1";
81
106
  readonly binding: string;
82
107
  readonly schemaFile: string;
83
108
  }
109
+ /**
110
+ * Clear a Durable Object namespace before each run and seed the named
111
+ * objects' storage with these entries; its storage is snapshotted after the
112
+ * run for state invariants (see `durableObjectRows`).
113
+ */
114
+ interface DurableObjectSetup extends PlatformData {
115
+ readonly kind: "durable_object";
116
+ readonly binding: string;
117
+ readonly objects: {
118
+ readonly [name: string]: {
119
+ readonly [key: string]: JsonValue;
120
+ };
121
+ };
122
+ /**
123
+ * How many times each object's alarm may fire in one run (retries not
124
+ * counted); an object that keeps re-arming stops there. Default 3.
125
+ */
126
+ readonly alarmsPerObject?: number;
127
+ }
128
+ export declare function durableObject(binding: string, objects?: {
129
+ readonly [name: string]: {
130
+ readonly [key: string]: JsonValue;
131
+ };
132
+ }, options?: {
133
+ readonly alarmsPerObject?: number;
134
+ }): DurableObjectSetup;
135
+ /**
136
+ * The storage of one object (by the name its id was made from) as rows
137
+ * `{ key, value }`, for state invariants.
138
+ */
139
+ export declare function durableObjectRows(binding: string, object: string, where?: readonly RowCondition[]): StateQuery;
84
140
  interface CloudflareScenarioInput {
85
141
  readonly name: string;
86
142
  readonly worker: WorkerRef;
@@ -89,10 +145,12 @@ interface CloudflareScenarioInput {
89
145
  readonly queue: string;
90
146
  readonly messages: readonly QueueMessage[];
91
147
  };
92
- readonly setup?: readonly D1Setup[];
148
+ readonly setup?: readonly (D1Setup | DurableObjectSetup)[];
93
149
  readonly externals?: readonly ExternalDecl[];
94
150
  readonly invariants: readonly Invariant[];
95
151
  readonly bounds?: Partial<Bounds>;
152
+ /** Modules of pure core functions with Lemma specs, relative to the scenario (see ScenarioSpec.specs). */
153
+ readonly specs?: readonly string[];
96
154
  }
97
155
  export declare function queue(name: string, messages: readonly QueueMessage[]): QueueDrive;
98
156
  export declare function d1Schema(binding: string, schemaFile: string): D1Setup;
@@ -103,8 +161,19 @@ export declare function d1Schema(binding: string, schemaFile: string): D1Setup;
103
161
  * A committed write is a `result` whose `result.changes` is at least 1.
104
162
  */
105
163
  export declare function d1Write(binding: string, op?: "run" | "batch"): EffectSelector;
164
+ /** Reads of a D1 binding: `first` (result payload `{ row }`), `all` or `raw`. */
165
+ export declare function d1Read(binding: string, op?: "first" | "all" | "raw"): EffectSelector;
106
166
  /** Dot path to the Nth bound parameter of a D1 statement, in an effect payload. */
107
167
  export declare function d1Param(index: number): string;
168
+ /**
169
+ * The shell follows the core function `decision` (see the `refines`
170
+ * invariant): every selected effect carries out the latest decision of its
171
+ * invocation, agrees with it on `follows`, and, with `state`, was not made
172
+ * stale by another invocation's write between the read it rests on and the
173
+ * effect. The core function's module must be listed in the scenario's
174
+ * `specs`, which is what records its calls.
175
+ */
176
+ export declare function refines(name: string, decision: string, effect: EffectSelector, options?: Pick<Refines, "follows" | "state">): Refines;
108
177
  export declare function atMostOncePerKey(name: string, effect: EffectSelector, key: string): AtMostOncePerKey;
109
178
  export declare function atLeastOnce(name: string, effect: EffectSelector, key: string, expected: readonly JsonValue[]): AtLeastOnce;
110
179
  /**
@@ -124,6 +193,8 @@ export declare function httpResponse(path: string, options?: {
124
193
  export declare function d1Rows(binding: string, table: string, where?: readonly RowCondition[]): StateQuery;
125
194
  /** Every row the query selects satisfies all conditions. */
126
195
  export declare function everyRow(name: string, query: StateQuery, holds: readonly RowCondition[]): EveryRow;
196
+ /** No two rows the query selects share the value at `path` (a column, or a dot path into the row). */
197
+ export declare function unique(name: string, query: StateQuery, path: string): Unique;
127
198
  /** Every selected effect has a row whose column equals the effect's key. */
128
199
  export declare function implies(name: string, when: EffectSelector, key: string, state: StateQuery, column: string): Implies;
129
200
  /** Selects the acknowledgement that took effect for each message (explicit or implicit; not one ignored after a retry). */
@@ -161,6 +232,12 @@ interface CloudflarePlatformOptions {
161
232
  readonly schemas: Readonly<Record<string, string>>;
162
233
  /** Cloudflare's default when the consumer does not set max_retries. */
163
234
  readonly maxRetries?: number;
235
+ /**
236
+ * The Cloudflare Vitest plugin's test helpers (`import * as helpers from
237
+ * "cloudflare:test"`), needed for Durable Object bindings: Eutaxy resets,
238
+ * seeds and snapshots the real objects through them.
239
+ */
240
+ readonly durableObjects?: DurableObjectTestHelpers;
164
241
  }
165
242
  export declare function createCloudflarePlatform(options: CloudflarePlatformOptions): Platform;
166
243
  interface AttemptRecord {
@@ -191,5 +268,5 @@ interface DifferentialResult {
191
268
  }
192
269
  /** Run both sides and compare. The Eutaxy side runs first; both start from the schema. */
193
270
  export declare function runDifferential(spec: ScenarioSpec, options: CloudflarePlatformOptions): Promise<DifferentialResult>;
194
- export type { CloudflarePlatformOptions, CloudflareRegressionOptions, CloudflareScenarioInput, D1Setup, DifferentialResult, HttpDrive, HttpRequestInput, HttpRequestSpec, QueueDrive, QueueHandler, QueueMessage, WorkerHandler };
271
+ export type { CloudflarePlatformOptions, CloudflareRegressionOptions, CloudflareScenarioInput, D1Setup, DifferentialResult, DurableObjectSetup, DurableObjectTestHelpers, HttpCallerOptions, HttpDrive, HttpRequestInput, HttpRequestSpec, QueueDrive, QueueHandler, QueueMessage, WorkerHandler };
195
272
  //# sourceMappingURL=cloudflare.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudflare.d.mts","names":[],"sources":["../../cli/src/regression.ts","../../cloudflare/src/check.ts","../../cloudflare/src/d1.ts","../../cloudflare/src/scenario.ts","../../cloudflare/src/platform.ts","../../cloudflare/src/differential.ts"],"mappings":";;UAGiB;;WAEN;;WAEA;;WAEA,aAAa,SAAS;;WAEtB;WACA;WACA;;;wBAIK,yBACd,SAAS,UACT,SAAS;;wBCVK,MACd,MAAM,cACN,UAAU,UACV,UAAS,iBACR,QAAQ;;wBAKW,YACpB,MAAM,cACN,UAAU,UACV,UAAU,iBACT;;wBCiOmB,WACpB,MAAM,aACL;YAAoB,yBAAyB;;;UC5N/B;WACN;WACA,MAAM;;;UAIA,mBAAmB;WACzB;WACA;WACA;aAA8B;aAAqB,MAAM;;;;UAInD;WACN;WACA;WACA;WACA;cAAsB;;;WAEtB,OAAO;;;KAIN;WACD;WACA;WACA;WACA;cAAqB;;;WAErB,OAAO;;;;;;;;;UAUD,kBAAkB;WACxB;WACA,mBAAmB;WACnB;WACA;;wBAGK,KACd,mBAAmB,oBACnB;WAAoB;WAA2B;IAC9C;;UAgBc,gBAAgB;WACtB;WACA;WACA;;UAGM;WACN;WACA,QAAQ;WACR,OACL,aACA;aAEW;aACA;aACA,mBAAmB;;WAEzB,iBAAiB;WACjB,qBAAqB;WACrB,qBAAqB;WACrB,SAAS,QAAQ;;wBAGZ,MAAM,cAAc,mBAAmB,iBAAiB;wBAQxD,SAAS,iBAAiB,qBAAqB;;;;;;;wBAU/C,QAAQ,iBAAiB,uBAA8B;;wBAKvD,QAAQ;wBAIR,iBACd,cACA,QAAQ,gBACR,cACC;wBAIa,YACd,cACA,QAAQ,gBACR,aACA,mBAAmB,cAClB;;;;;wBAQa,sBACd,cACA,OAAO,aAAa,WACpB,QAAQ,gBACR,aACA,kBACC;;;;;;wBAyBa,aACd,cACA;WAAoB;IACnB;;wBAUa,OACd,iBACA,eACA,iBAAiB,iBAChB;;wBAKa,SACd,cACA,OAAO,YACP,gBAAgB,iBACf;;wBAKa,QACd,cACA,MAAM,gBACN,aACA,OAAO,YACP,iBACC;;wBAKa,SAAS,oBAAoB;;;;;;;wBAe7B,SACd,cACA,cACA;WAAoB;WAA4B,qBAAqB;IACpE;;;;;wBAaa,UAAU,sBAAsB,kBAAkB;;wBA2BlD,eAAe,OAAO,0BAA0B;;UC7Q/C;EACf,OAAO,OAAO,uBAAuB,cAAc,KAAK,0BAA0B;EAClF,OAAO,SAAS,SAAS,cAAc,KAAK,mBAAmB,WAAW,QAAQ;;;KAIxE,eAAe;UAkCV;;WAEN;;WAEA,SAAS;;WAET,SAAS,SAAS;;WAElB;;wBAqCK,yBAAyB,SAAS,4BAA4B;UChF7D;WACN;WACA;WACA;;WAEA;;WAEA;;UAGM;WACN,mBAAmB;WACnB;cACG;gBAA8B,yBAAyB;;;;UAIpD;;WAEN;WACA,QAAQ;WACR,KAAK;WACL;;WAEA;;;wBAiSW,gBACpB,MAAM,cACN,SAAS,4BACR,QAAQ"}
1
+ {"version":3,"file":"cloudflare.d.mts","names":[],"sources":["../../cli/src/regression.ts","../../cloudflare/src/check.ts","../../cloudflare/src/d1.ts","../../cloudflare/src/durable-objects.ts","../../cloudflare/src/scenario.ts","../../cloudflare/src/platform.ts","../../cloudflare/src/differential.ts"],"mappings":";;UAGiB;;WAEN;;WAEA;;WAEA,aAAa,SAAS;;WAEtB;;WAEA;WACA;WACA;;WAEA;aACE;aACA;;;;wBAKG,yBACd,SAAS,UACT,SAAS;;wBCjBK,MACd,MAAM,cACN,UAAU,UACV,UAAS,iBACR,QAAQ;;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