eutaxy 0.0.0-stage → 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.
Files changed (43) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +16 -2
  3. package/dist/aws.d.mts +15464 -0
  4. package/dist/aws.d.mts.map +1 -0
  5. package/dist/aws.mjs +24057 -0
  6. package/dist/aws.mjs.map +1 -0
  7. package/dist/bin.d.mts +1 -0
  8. package/dist/bin.mjs +17 -0
  9. package/dist/bin.mjs.map +1 -0
  10. package/dist/checksum-DhS6ofSm.mjs +6049 -0
  11. package/dist/checksum-DhS6ofSm.mjs.map +1 -0
  12. package/dist/cli-NqY61bpo.mjs +2 -0
  13. package/dist/cli.d.mts +8 -0
  14. package/dist/cli.d.mts.map +1 -0
  15. package/dist/cli.mjs +2 -0
  16. package/dist/cloudflare.d.mts +272 -0
  17. package/dist/cloudflare.d.mts.map +1 -0
  18. package/dist/cloudflare.mjs +1815 -0
  19. package/dist/cloudflare.mjs.map +1 -0
  20. package/dist/es5-DtZuPEgt.mjs +1721 -0
  21. package/dist/es5-DtZuPEgt.mjs.map +1 -0
  22. package/dist/event-streams-BANyO9xt.mjs +801 -0
  23. package/dist/event-streams-BANyO9xt.mjs.map +1 -0
  24. package/dist/explore-BHYvAZKN.d.mts +84 -0
  25. package/dist/explore-BHYvAZKN.d.mts.map +1 -0
  26. package/dist/index.d.mts +252 -0
  27. package/dist/index.d.mts.map +1 -0
  28. package/dist/index.mjs +261 -0
  29. package/dist/index.mjs.map +1 -0
  30. package/dist/platform-eVgCMbX0.d.mts +385 -0
  31. package/dist/platform-eVgCMbX0.d.mts.map +1 -0
  32. package/dist/rolldown-runtime-C1I3wEg2.mjs +43 -0
  33. package/dist/src-BD3jkjgG.mjs +477 -0
  34. package/dist/src-BD3jkjgG.mjs.map +1 -0
  35. package/dist/src-C19_yfMM.mjs +2237 -0
  36. package/dist/src-C19_yfMM.mjs.map +1 -0
  37. package/dist/src-CgfGiH25.mjs +1546 -0
  38. package/dist/src-CgfGiH25.mjs.map +1 -0
  39. package/dist/src-s6uYyC0B.mjs +89 -0
  40. package/dist/src-s6uYyC0B.mjs.map +1 -0
  41. package/dist/verdict-evEM5Gxx.mjs +12 -0
  42. package/dist/verdict-evEM5Gxx.mjs.map +1 -0
  43. package/package.json +76 -3
@@ -0,0 +1,2 @@
1
+ import "./src-BD3jkjgG.mjs";
2
+ export {};
package/dist/cli.d.mts ADDED
@@ -0,0 +1,8 @@
1
+ interface Io {
2
+ readonly cwd: string;
3
+ readonly stdout: (text: string) => void;
4
+ readonly stderr: (text: string) => void;
5
+ }
6
+ export declare function main(argv: readonly string[], io: Io): Promise<number>;
7
+ export {};
8
+ //# sourceMappingURL=cli.d.mts.map
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,2 @@
1
+ export { t as main } from "./src-BD3jkjgG.mjs";
2
+ import "./cli-NqY61bpo.mjs";
@@ -0,0 +1,272 @@
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
+ interface CloudflareRegressionOptions {
4
+ /** Import path of the scenario module, relative to the emitted file. */
5
+ readonly scenarioPath: string;
6
+ /** Import path of the Worker module. */
7
+ readonly workerPath: string;
8
+ /** D1 binding name to schema file path, imported with `?raw`. */
9
+ readonly schemaPaths: Readonly<Record<string, string>>;
10
+ /** The platform's retry limit, when the scenario was checked with a non-default one. */
11
+ readonly maxRetries?: number;
12
+ /** The scenario sets up Durable Objects: pass the Cloudflare test helpers to the platform. */
13
+ readonly durableObjects?: boolean;
14
+ readonly expect?: "holds" | "violates";
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
+ }[];
21
+ }
22
+ /** A Vitest regression test for a Cloudflare scenario, to run under the Cloudflare Vitest plugin. */
23
+ export declare function cloudflareRegressionTest(verdict: Violated, options: CloudflareRegressionOptions): string;
24
+ /** Explore a scenario on a platform and return its verdict. */
25
+ export declare function check(spec: ScenarioSpec, platform: Platform, options?: ExploreOptions): Promise<ScenarioVerdict>;
26
+ /** For use from a test: passes only when the scenario is BOUNDED. */
27
+ export declare function expectHolds(spec: ScenarioSpec, platform: Platform, options?: ExploreOptions): Promise<void>;
28
+ /** Every user table's rows, sorted canonically, read through the real binding (not an effect). */
29
+ export declare function snapshotD1(real: D1Database): Promise<{
30
+ readonly [table: string]: readonly JsonValue[];
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
+ }
42
+ /** One queue message to deliver; `id` defaults to its position. */
43
+ interface QueueMessage {
44
+ readonly id?: string;
45
+ readonly body: JsonValue;
46
+ }
47
+ /** Drive the Worker's `queue()` handler with these messages. */
48
+ interface QueueDrive extends PlatformData {
49
+ readonly kind: "queue";
50
+ readonly queue: string;
51
+ readonly messages: readonly {
52
+ readonly id: string;
53
+ readonly body: JsonValue;
54
+ }[];
55
+ }
56
+ /** One inbound request; `id` defaults to its position, `method` to POST with a body and GET without. */
57
+ interface HttpRequestInput {
58
+ readonly id?: string;
59
+ readonly method?: string;
60
+ readonly path: string;
61
+ readonly headers?: {
62
+ readonly [name: string]: string;
63
+ };
64
+ /** JSON body (sent as application/json) or a string body. */
65
+ readonly body?: JsonValue;
66
+ }
67
+ /** A type alias, not an interface, so it is assignable to the JSON shape of `PlatformData`. */
68
+ type HttpRequestSpec = {
69
+ readonly id: string;
70
+ readonly method: string;
71
+ readonly path: string;
72
+ readonly headers: {
73
+ readonly [name: string]: string;
74
+ };
75
+ /** Absent: no body at all. `null` is a JSON body, sent as `null`. */
76
+ readonly body?: JsonValue;
77
+ };
78
+ /**
79
+ * Drive the Worker's `fetch()` handler with these requests. The caller's
80
+ * retry policy decides redelivery: a webhook provider resends a request it
81
+ * got no 2xx for (`retryOn: "non-2xx"`, the default) or only on 5xx and
82
+ * failures (`"5xx"`), up to `retries` times; a browser-like caller has
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.
87
+ */
88
+ interface HttpDrive extends PlatformData {
89
+ readonly kind: "http";
90
+ readonly requests: readonly HttpRequestSpec[];
91
+ readonly retries: number;
92
+ readonly retryOn: "non-2xx" | "5xx";
93
+ readonly delaysMs?: readonly number[];
94
+ readonly deadlineMs?: number;
95
+ }
96
+ interface HttpCallerOptions {
97
+ readonly retries?: number;
98
+ readonly retryOn?: "non-2xx" | "5xx";
99
+ readonly delaysMs?: readonly number[];
100
+ readonly deadlineMs?: number;
101
+ }
102
+ export declare function http(requests: readonly HttpRequestInput[], options?: HttpCallerOptions): HttpDrive;
103
+ /** Apply a SQL file to a D1 binding before each run. */
104
+ interface D1Setup extends PlatformData {
105
+ readonly kind: "d1";
106
+ readonly binding: string;
107
+ readonly schemaFile: string;
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;
140
+ interface CloudflareScenarioInput {
141
+ readonly name: string;
142
+ readonly worker: WorkerRef;
143
+ readonly drive: QueueDrive | HttpDrive | {
144
+ readonly kind: "queue";
145
+ readonly queue: string;
146
+ readonly messages: readonly QueueMessage[];
147
+ };
148
+ readonly setup?: readonly (D1Setup | DurableObjectSetup)[];
149
+ readonly externals?: readonly ExternalDecl[];
150
+ readonly invariants: readonly Invariant[];
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[];
154
+ }
155
+ export declare function queue(name: string, messages: readonly QueueMessage[]): QueueDrive;
156
+ export declare function d1Schema(binding: string, schemaFile: string): D1Setup;
157
+ /**
158
+ * Effect conventions for D1 (what the proxies record):
159
+ * call payload { args: { sql, params } }
160
+ * result payload { args: { sql, params }, result: { changes, lastRowId } }
161
+ * A committed write is a `result` whose `result.changes` is at least 1.
162
+ */
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;
166
+ /** Dot path to the Nth bound parameter of a D1 statement, in an effect payload. */
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;
177
+ export declare function atMostOncePerKey(name: string, effect: EffectSelector, key: string): AtMostOncePerKey;
178
+ export declare function atLeastOnce(name: string, effect: EffectSelector, key: string, expected: readonly JsonValue[]): AtLeastOnce;
179
+ /**
180
+ * Every message's (or request's) `bodyKey` value must appear at least once
181
+ * as `key` in a selected effect: nothing the drive delivered may be lost.
182
+ */
183
+ export declare function atLeastOncePerMessage(name: string, drive: QueueDrive | HttpDrive, effect: EffectSelector, key: string, bodyKey: string): AtLeastOnce;
184
+ /**
185
+ * Selects the responses the Worker returned for a path (`ok` narrows to 2xx
186
+ * or to everything else). One `result` per attempt: a crash before the
187
+ * response leaves none, a thrown error records status 500.
188
+ */
189
+ export declare function httpResponse(path: string, options?: {
190
+ readonly ok?: boolean;
191
+ }): EffectSelector;
192
+ /** Rows of a D1 table in the end-of-run snapshot, optionally filtered. */
193
+ export declare function d1Rows(binding: string, table: string, where?: readonly RowCondition[]): StateQuery;
194
+ /** Every row the query selects satisfies all conditions. */
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;
198
+ /** Every selected effect has a row whose column equals the effect's key. */
199
+ export declare function implies(name: string, when: EffectSelector, key: string, state: StateQuery, column: string): Implies;
200
+ /** Selects the acknowledgement that took effect for each message (explicit or implicit; not one ignored after a retry). */
201
+ export declare function queueAck(queueName: string): EffectSelector;
202
+ /**
203
+ * Declare an external service: requests to `host` are answered from
204
+ * `responses` (every request gets 200 and an empty body when omitted), and
205
+ * `dedupeBy` names the header whose value makes repeated requests
206
+ * idempotent at that service.
207
+ */
208
+ export declare function external(name: string, host: string, options?: {
209
+ readonly dedupeBy?: string;
210
+ readonly responses?: readonly ScriptedResponse[];
211
+ }): ExternalDecl;
212
+ /**
213
+ * Selects the requests to an external that took effect: a request replayed
214
+ * under a dedupe key the external had already seen is not counted.
215
+ */
216
+ export declare function fetchCall(externalName: string, method?: string): EffectSelector;
217
+ /** Build and validate a scenario spec; throws with every problem listed. */
218
+ export declare function defineScenario(input: CloudflareScenarioInput): ScenarioSpec;
219
+ /** The Worker's default export, as far as the platform drives it. */
220
+ interface WorkerHandler {
221
+ queue?(batch: MessageBatch<unknown>, env: unknown, ctx: ExecutionContext): void | Promise<void>;
222
+ fetch?(request: Request, env: unknown, ctx: ExecutionContext): Response | Promise<Response>;
223
+ }
224
+ /** The former name of `WorkerHandler`, kept for callers written against 0.1. */
225
+ type QueueHandler = WorkerHandler;
226
+ interface CloudflarePlatformOptions {
227
+ /** The bindings from `cloudflare:workers`. */
228
+ readonly env: object;
229
+ /** The Worker's default export. */
230
+ readonly handler: WorkerHandler;
231
+ /** Schema SQL per D1 binding named in the scenario's setup. */
232
+ readonly schemas: Readonly<Record<string, string>>;
233
+ /** Cloudflare's default when the consumer does not set max_retries. */
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;
241
+ }
242
+ export declare function createCloudflarePlatform(options: CloudflarePlatformOptions): Platform;
243
+ interface AttemptRecord {
244
+ readonly event: string;
245
+ readonly attempt: number;
246
+ readonly status: "completed" | "errored";
247
+ /** Queue drive: the acknowledgement that took effect. */
248
+ readonly decision: "ack" | "retry" | null;
249
+ /** HTTP drive: the response status the caller saw (500 for an uncaught exception). */
250
+ readonly response?: number;
251
+ }
252
+ interface Side {
253
+ readonly attempts: readonly AttemptRecord[];
254
+ readonly state: {
255
+ readonly [binding: string]: {
256
+ readonly [table: string]: readonly JsonValue[];
257
+ };
258
+ };
259
+ }
260
+ interface DifferentialResult {
261
+ /** True only when both sides agree and the proxied run touched nothing unmodelled. */
262
+ readonly equal: boolean;
263
+ readonly eutaxy: Side;
264
+ readonly raw: Side;
265
+ readonly differences: readonly string[];
266
+ /** What the proxied run could not control; non-empty means the comparison proves nothing. */
267
+ readonly unsupported: readonly string[];
268
+ }
269
+ /** Run both sides and compare. The Eutaxy side runs first; both start from the schema. */
270
+ export declare function runDifferential(spec: ScenarioSpec, options: CloudflarePlatformOptions): Promise<DifferentialResult>;
271
+ export type { CloudflarePlatformOptions, CloudflareRegressionOptions, CloudflareScenarioInput, D1Setup, DifferentialResult, DurableObjectSetup, DurableObjectTestHelpers, HttpCallerOptions, HttpDrive, HttpRequestInput, HttpRequestSpec, QueueDrive, QueueHandler, QueueMessage, WorkerHandler };
272
+ //# sourceMappingURL=cloudflare.d.mts.map
@@ -0,0 +1 @@
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;;wBAKW,YACpB,MAAM,cACN,UAAU,UACV,UAAU,iBACT;;wBCiOmB,WACpB,MAA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