@dudousxd/nestjs-durable-testing 0.22.3 → 0.23.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/index.d.ts CHANGED
@@ -256,6 +256,12 @@ interface StateStoreContext {
256
256
  * a real engine) still asserts it, so this doesn't hide drift in the supported configurations.
257
257
  */
258
258
  supportsTagFilter?: boolean;
259
+ /**
260
+ * How many statements the store has sent to its database so far (from the driver's query log).
261
+ * When given, the contract checks that the batched checkpoint methods send a fixed number of them
262
+ * for a wide batch, not one per row.
263
+ */
264
+ statements?: () => number;
259
265
  }
260
266
  /** Builds a fresh, empty store for one test. Called once per `it` (in `beforeEach`). */
261
267
  type StateStoreFactory = () => Promise<StateStoreContext>;
@@ -350,4 +356,44 @@ interface RunDispatchContractOptions {
350
356
  */
351
357
  declare function runRunDispatchContract(name: string, makeHarness: RunDispatchHarnessFactory, options?: RunDispatchContractOptions): void;
352
358
 
353
- export { type AdmissionBackendFactory, DURABLE_CANONICAL_COLUMNS, type DurableColumnMap, type DurableColumnMismatch, type HandleableTransport, MutableClock, type RunDispatchContractOptions, type RunDispatchHarness, type RunDispatchHarnessFactory, type RunHistory, type StateStoreContext, type StateStoreFactory, StateStoreUnavailableError, type TestEngine, aggregationFixture, assertDurableColumns, assertOutput, assertReplayable, assertRunStatus, assertStepAttempts, assertStepsRan, assertTransportConformance, captureHistory, createTestEngine, failOnce, failTimes, parseRunHistory, preserveColumnExpectation, recordedSteps, registerCheckpointAggregationCases, runAdmissionBackendContract, runRunDispatchContract, runStateStoreContract, serializeRunHistory };
359
+ /** The step every case fans out over. */
360
+ declare const STEP_FAN_STEP = "fan-results-double";
361
+ /** Two engine-side transports on one broker (two instances of a deployment) and the worker side. */
362
+ interface StepFanResultsHarness {
363
+ /**
364
+ * Fresh queues (prefix, tables) for one case: two engine-side transports, and a worker serving
365
+ * {@link STEP_FAN_STEP} with `handler` (registered on whichever transport the backend runs
366
+ * workers on). `close` releases everything the case opened.
367
+ */
368
+ open(handler: (input: unknown) => Promise<unknown>): Promise<{
369
+ engines: [Transport, Transport];
370
+ close: () => Promise<void>;
371
+ }>;
372
+ }
373
+ /** Builds the harness, or returns why the backend is unavailable (no Docker, say): the case skips. */
374
+ type StepFanResultsHarnessFactory = () => Promise<StepFanResultsHarness | string>;
375
+ interface StepFanResultsContractOptions {
376
+ /** Per-case budget. Default 60s. */
377
+ timeoutMs?: number;
378
+ /** Steps in the fan. Default 2000. */
379
+ fanSize?: number;
380
+ /**
381
+ * The fewest results the largest batched write of a backlog settles. Default 8: a consumer that
382
+ * hands the engine one result at a time settles a fan in one write and one barrier read each.
383
+ */
384
+ minBatch?: number;
385
+ /**
386
+ * Whether the transport sends many tasks at once (`dispatchMany`). Default true: the contract
387
+ * then checks that a fan's steps are dispatched through it, never one `dispatch` per step.
388
+ */
389
+ bulkDispatch?: boolean;
390
+ }
391
+ /**
392
+ * A wide step fan (`ctx.all` / `ctx.allSettled` over a `@Step`) whose results come back over a
393
+ * real broker to two engine instances: every step settles once, the parent wakes O(1) times per
394
+ * wave, and the results consumer hands the engine enough results at once that they are written in
395
+ * batches rather than one by one.
396
+ */
397
+ declare function runStepFanResultsContract(name: string, makeHarness: StepFanResultsHarnessFactory, options?: StepFanResultsContractOptions): void;
398
+
399
+ export { type AdmissionBackendFactory, DURABLE_CANONICAL_COLUMNS, type DurableColumnMap, type DurableColumnMismatch, type HandleableTransport, MutableClock, type RunDispatchContractOptions, type RunDispatchHarness, type RunDispatchHarnessFactory, type RunHistory, STEP_FAN_STEP, type StateStoreContext, type StateStoreFactory, StateStoreUnavailableError, type StepFanResultsContractOptions, type StepFanResultsHarness, type StepFanResultsHarnessFactory, type TestEngine, aggregationFixture, assertDurableColumns, assertOutput, assertReplayable, assertRunStatus, assertStepAttempts, assertStepsRan, assertTransportConformance, captureHistory, createTestEngine, failOnce, failTimes, parseRunHistory, preserveColumnExpectation, recordedSteps, registerCheckpointAggregationCases, runAdmissionBackendContract, runRunDispatchContract, runStateStoreContract, runStepFanResultsContract, serializeRunHistory };
package/dist/index.js CHANGED
@@ -841,6 +841,7 @@ function runStateStoreContract(name, makeStore) {
841
841
  let cleanup;
842
842
  let supportsAsyncTransaction = true;
843
843
  let supportsTagFilter = true;
844
+ let statements;
844
845
  let skipReason;
845
846
  let loggedSkip = false;
846
847
  beforeEach(async () => {
@@ -851,6 +852,7 @@ function runStateStoreContract(name, makeStore) {
851
852
  cleanup = ctx.cleanup;
852
853
  supportsAsyncTransaction = ctx.supportsAsyncTransaction ?? true;
853
854
  supportsTagFilter = ctx.supportsTagFilter ?? true;
855
+ statements = ctx.statements;
854
856
  skipReason = void 0;
855
857
  } catch (err) {
856
858
  if (isUnavailable(err) && !process.env.DURABLE_TEST_REQUIRE_BACKENDS) {
@@ -2120,6 +2122,191 @@ function runStateStoreContract(name, makeStore) {
2120
2122
  n: 3
2121
2123
  });
2122
2124
  });
2125
+ t("getCheckpoints reads many of a run's checkpoints at once, in seq order", async () => {
2126
+ expect3(store.getCheckpoints).toBeDefined();
2127
+ if (!store.getCheckpoints) return;
2128
+ await store.createRun(run());
2129
+ await store.createRun(run({
2130
+ id: "r2"
2131
+ }));
2132
+ expect3(await store.getCheckpoints("r1", [])).toEqual([]);
2133
+ for (const seq of [
2134
+ 0,
2135
+ 1,
2136
+ 2,
2137
+ 5
2138
+ ]) {
2139
+ await store.saveCheckpoint(checkpoint({
2140
+ seq,
2141
+ stepId: `r1:${seq}`,
2142
+ output: {
2143
+ seq
2144
+ },
2145
+ wakeAt: seq === 2 ? 7e3 : void 0
2146
+ }));
2147
+ }
2148
+ await store.saveCheckpoint(checkpoint({
2149
+ runId: "r2",
2150
+ seq: 3,
2151
+ stepId: "r2:3"
2152
+ }));
2153
+ const read = await store.getCheckpoints("r1", [
2154
+ 5,
2155
+ 0,
2156
+ 3,
2157
+ 2,
2158
+ 0
2159
+ ]);
2160
+ expect3(read.map((c) => [
2161
+ c.runId,
2162
+ c.seq,
2163
+ c.output
2164
+ ])).toEqual([
2165
+ [
2166
+ "r1",
2167
+ 0,
2168
+ {
2169
+ seq: 0
2170
+ }
2171
+ ],
2172
+ [
2173
+ "r1",
2174
+ 2,
2175
+ {
2176
+ seq: 2
2177
+ }
2178
+ ],
2179
+ [
2180
+ "r1",
2181
+ 5,
2182
+ {
2183
+ seq: 5
2184
+ }
2185
+ ]
2186
+ ]);
2187
+ expect3(read[1]).toEqual(await store.getCheckpoint("r1", 2));
2188
+ const n = 1200;
2189
+ for (let seq = 10; seq < 10 + n; seq += 1) {
2190
+ await store.saveCheckpoint(checkpoint({
2191
+ seq,
2192
+ stepId: `r1:${seq}`
2193
+ }));
2194
+ }
2195
+ const wide = await store.getCheckpoints("r1", Array.from({
2196
+ length: n
2197
+ }, (_, i) => 10 + i));
2198
+ expect3(wide.map((c) => c.seq)).toEqual(Array.from({
2199
+ length: n
2200
+ }, (_, i) => 10 + i));
2201
+ });
2202
+ t("saveCheckpoints writes many checkpoints at once, inserting or overwriting each", async () => {
2203
+ expect3(store.saveCheckpoints).toBeDefined();
2204
+ if (!store.saveCheckpoints) return;
2205
+ await store.saveCheckpoints([]);
2206
+ await store.createRun(run());
2207
+ await store.saveCheckpoint(checkpoint({
2208
+ seq: 1,
2209
+ stepId: "r1:1",
2210
+ output: {
2211
+ old: true
2212
+ }
2213
+ }));
2214
+ await store.saveCheckpoints([
2215
+ checkpoint({
2216
+ seq: 0,
2217
+ stepId: "r1:0",
2218
+ status: "pending",
2219
+ output: void 0,
2220
+ wakeAt: 4e3
2221
+ }),
2222
+ checkpoint({
2223
+ seq: 1,
2224
+ stepId: "r1:1",
2225
+ output: {
2226
+ new: true
2227
+ },
2228
+ parallelGroup: "g"
2229
+ }),
2230
+ checkpoint({
2231
+ seq: 2,
2232
+ stepId: "r1:2",
2233
+ input: {
2234
+ i: 2
2235
+ },
2236
+ workerGroup: "w"
2237
+ })
2238
+ ]);
2239
+ const rows = await store.listCheckpoints("r1");
2240
+ expect3(rows.map((c) => [
2241
+ c.seq,
2242
+ c.status,
2243
+ c.output
2244
+ ])).toEqual([
2245
+ [
2246
+ 0,
2247
+ "pending",
2248
+ void 0
2249
+ ],
2250
+ [
2251
+ 1,
2252
+ "completed",
2253
+ {
2254
+ new: true
2255
+ }
2256
+ ],
2257
+ [
2258
+ 2,
2259
+ "completed",
2260
+ {
2261
+ ok: true
2262
+ }
2263
+ ]
2264
+ ]);
2265
+ expect3(rows[0]?.wakeAt).toBe(4e3);
2266
+ expect3(rows[1]?.parallelGroup).toBe("g");
2267
+ expect3(rows[2]?.input).toEqual({
2268
+ i: 2
2269
+ });
2270
+ expect3(rows[2]?.workerGroup).toBe("w");
2271
+ });
2272
+ t("the batched checkpoint methods send a fixed number of statements for a wide batch", async () => {
2273
+ if (!statements || !store.saveCheckpoints || !store.saveCheckpointsIfPending) return;
2274
+ if (!store.getCheckpoints) return;
2275
+ await store.createRun(run());
2276
+ const n = 600;
2277
+ const limit = n / 20;
2278
+ const rows = Array.from({
2279
+ length: n
2280
+ }, (_, seq) => checkpoint({
2281
+ seq,
2282
+ stepId: `r1:${seq}`,
2283
+ status: "pending",
2284
+ output: void 0
2285
+ }));
2286
+ const sent = /* @__PURE__ */ __name(async (work) => {
2287
+ const before = statements();
2288
+ await work();
2289
+ return statements() - before;
2290
+ }, "sent");
2291
+ expect3(await sent(() => store.saveCheckpoints?.(rows))).toBeLessThanOrEqual(limit);
2292
+ const seqs = rows.map((r) => r.seq);
2293
+ expect3(await sent(() => store.getCheckpoints?.("r1", seqs))).toBeLessThanOrEqual(limit);
2294
+ const settled = rows.map((row) => ({
2295
+ ...row,
2296
+ status: "completed",
2297
+ output: {
2298
+ seq: row.seq
2299
+ }
2300
+ }));
2301
+ let wrote = [];
2302
+ expect3(await sent(async () => {
2303
+ wrote = await store.saveCheckpointsIfPending?.(settled) ?? [];
2304
+ })).toBeLessThanOrEqual(limit);
2305
+ expect3(wrote.every((w) => w)).toBe(true);
2306
+ expect3(await store.countCheckpoints?.("r1", 0, n - 1, [
2307
+ "completed"
2308
+ ])).toBe(n);
2309
+ });
2123
2310
  t("saveCheckpointsIfPending writes a wide batch", async () => {
2124
2311
  if (!store.saveCheckpointsIfPending) return;
2125
2312
  await store.createRun(run());
@@ -4695,6 +4882,26 @@ var MID_TURN = [
4695
4882
  signal: true
4696
4883
  }
4697
4884
  ];
4885
+ var HOLDER_DIES = [
4886
+ {
4887
+ when: "after deciding to run the turn a kept wake asks for, before running it",
4888
+ // The lease of that turn, or its dispatch on the run queue.
4889
+ storeTrigger: [
4890
+ "tryLockRun"
4891
+ ],
4892
+ transportTrigger: [
4893
+ "dispatchRuns"
4894
+ ]
4895
+ },
4896
+ {
4897
+ when: "right after writing its suspension, before looking at the kept wake",
4898
+ // Releasing the lease, which comes before the look.
4899
+ storeTrigger: [
4900
+ "releaseRunLock"
4901
+ ],
4902
+ transportTrigger: []
4903
+ }
4904
+ ];
4698
4905
  async function shutdown(all, transports) {
4699
4906
  await Promise.allSettled(all.map(({ engine }) => engine.drain(2e3)));
4700
4907
  await Promise.allSettled(transports.map((t) => t.close?.()));
@@ -5420,13 +5627,287 @@ function runRunDispatchContract(name, makeHarness, options = {}) {
5420
5627
  }
5421
5628
  }, timeoutMs + 2e4);
5422
5629
  }
5630
+ for (const { when, storeTrigger, transportTrigger } of HOLDER_DIES) {
5631
+ it3(`a wake kept for a turn survives the instance holding the run going down ${when}`, async (ctx) => {
5632
+ const pair = await pairOrSkip(() => ctx.skip());
5633
+ if (!pair) return;
5634
+ const inner = new InMemoryStateStore4();
5635
+ let now = Date.now();
5636
+ const clock = /* @__PURE__ */ __name(() => now, "clock");
5637
+ let armed = false;
5638
+ let dead = false;
5639
+ const hang = /* @__PURE__ */ __name(() => new Promise(() => {
5640
+ }), "hang");
5641
+ const cutOff = /* @__PURE__ */ __name((target, trigger) => new Proxy(target, {
5642
+ get(t, prop, receiver) {
5643
+ const value = Reflect.get(t, prop, receiver);
5644
+ if (typeof value !== "function") return value;
5645
+ return (...args) => {
5646
+ if (armed && trigger.includes(String(prop))) dead = true;
5647
+ return dead ? hang() : value.apply(t, args);
5648
+ };
5649
+ }
5650
+ }), "cutOff");
5651
+ const holderStore = cutOff(inner, storeTrigger);
5652
+ const holderTransport = cutOff(pair[0], transportTrigger);
5653
+ let requesterDead = false;
5654
+ const requesterStore = new Proxy(inner, {
5655
+ get(t, prop, receiver) {
5656
+ const value = Reflect.get(t, prop, receiver);
5657
+ if (typeof value !== "function") return value;
5658
+ return (...args) => requesterDead ? hang() : value.apply(t, args);
5659
+ }
5660
+ });
5661
+ let turns = 0;
5662
+ let openTurn;
5663
+ const held = new Promise((resolve) => {
5664
+ openTurn = resolve;
5665
+ });
5666
+ const make = /* @__PURE__ */ __name((store, transport) => {
5667
+ const engine = new WorkflowEngine5({
5668
+ store,
5669
+ transport,
5670
+ clock,
5671
+ reconcileMs: 3e5
5672
+ });
5673
+ engine.register("kept", "1", async (wctx) => {
5674
+ turns += 1;
5675
+ if (turns === 2) await held;
5676
+ await wctx.waitForSignal("go");
5677
+ });
5678
+ return engine;
5679
+ }, "make");
5680
+ const holder = make(holderStore, holderTransport);
5681
+ const requester = make(requesterStore, pair[1]);
5682
+ let survivor;
5683
+ try {
5684
+ holder.consumeRuns();
5685
+ await holder.start("kept", {}, "p");
5686
+ await until(async () => (await inner.getRun("p"))?.status === "suspended", timeoutMs);
5687
+ void holder.resume("p").catch(() => void 0);
5688
+ await until(() => turns === 2, timeoutMs);
5689
+ await requester.resume("p");
5690
+ await until(async () => {
5691
+ const run2 = await inner.getRun("p");
5692
+ return run2?.wakeAt !== void 0 && run2.wakeAt <= now + 31e3;
5693
+ }, timeoutMs);
5694
+ await pause(100);
5695
+ requesterDead = true;
5696
+ armed = true;
5697
+ openTurn();
5698
+ await until(() => dead, timeoutMs);
5699
+ expect4(turns).toBe(2);
5700
+ await Promise.race([
5701
+ pair[0].close?.(),
5702
+ pause(2e3)
5703
+ ]);
5704
+ await pause(1500);
5705
+ survivor = make(inner, pair[1]);
5706
+ survivor.consumeRuns();
5707
+ now += 31e3;
5708
+ await survivor.resumeDueTimers(now);
5709
+ await until(() => turns === 3, timeoutMs);
5710
+ expect4((await inner.getRun("p"))?.status).toBe("suspended");
5711
+ } finally {
5712
+ openTurn();
5713
+ requesterDead = true;
5714
+ await Promise.allSettled([
5715
+ survivor?.drain(2e3)
5716
+ ]);
5717
+ await Promise.race([
5718
+ Promise.allSettled(pair.map((t) => t.close?.())),
5719
+ pause(5e3)
5720
+ ]);
5721
+ }
5722
+ }, timeoutMs + 2e4);
5723
+ }
5423
5724
  });
5424
5725
  }
5425
5726
  __name(runRunDispatchContract, "runRunDispatchContract");
5727
+
5728
+ // src/step-fan-results-contract.ts
5729
+ import { DURABLE_STEP_NAME, InMemoryStateStore as InMemoryStateStore5, WorkflowEngine as WorkflowEngine6 } from "@dudousxd/nestjs-durable-core";
5730
+ import { describe as describe4, expect as expect5, it as it4 } from "vitest";
5731
+ var STEP_FAN_STEP = "fan-results-double";
5732
+ var doubleLine = /* @__PURE__ */ __name(() => {
5733
+ }, "doubleLine");
5734
+ doubleLine[DURABLE_STEP_NAME] = STEP_FAN_STEP;
5735
+ function counted(inner, counts) {
5736
+ return new Proxy(inner, {
5737
+ get(target, prop, receiver) {
5738
+ const value = Reflect.get(target, prop, receiver);
5739
+ if (typeof value !== "function") return value;
5740
+ return (...args) => {
5741
+ const name = String(prop);
5742
+ counts.calls.set(name, (counts.calls.get(name) ?? 0) + 1);
5743
+ if (name === "saveCheckpointsIfPending") counts.batches.push(args[0].length);
5744
+ if (name === "saveCheckpointIfPending") counts.batches.push(1);
5745
+ return new Promise((resolve) => setImmediate(resolve)).then(() => value.apply(target, args));
5746
+ };
5747
+ }
5748
+ });
5749
+ }
5750
+ __name(counted, "counted");
5751
+ function behind(transport, gate, dispatched) {
5752
+ return new Proxy(transport, {
5753
+ get(target, prop, receiver) {
5754
+ if (prop === "dispatch") {
5755
+ return (...args) => {
5756
+ dispatched.one += 1;
5757
+ return target.dispatch(...args);
5758
+ };
5759
+ }
5760
+ if (prop === "onResult") {
5761
+ return (handler) => target.onResult(async (result) => {
5762
+ await gate;
5763
+ return handler(result);
5764
+ });
5765
+ }
5766
+ const value = Reflect.get(target, prop, receiver);
5767
+ return typeof value === "function" ? value.bind(target) : value;
5768
+ }
5769
+ });
5770
+ }
5771
+ __name(behind, "behind");
5772
+ async function until2(check, timeoutMs) {
5773
+ const deadline = Date.now() + timeoutMs;
5774
+ while (Date.now() < deadline) {
5775
+ if (await check()) return;
5776
+ await new Promise((resolve) => setTimeout(resolve, 20));
5777
+ }
5778
+ throw new Error("condition not met");
5779
+ }
5780
+ __name(until2, "until");
5781
+ var FORMS = [
5782
+ {
5783
+ form: "ctx.all",
5784
+ settle: false,
5785
+ waves: 1
5786
+ },
5787
+ {
5788
+ form: "ctx.allSettled",
5789
+ settle: true,
5790
+ waves: 1
5791
+ },
5792
+ {
5793
+ form: "ctx.all with concurrency",
5794
+ settle: false,
5795
+ waves: 4
5796
+ },
5797
+ {
5798
+ form: "ctx.allSettled with concurrency",
5799
+ settle: true,
5800
+ waves: 4
5801
+ }
5802
+ ];
5803
+ function runStepFanResultsContract(name, makeHarness, options = {}) {
5804
+ const timeoutMs = options.timeoutMs ?? 6e4;
5805
+ const fanSize = options.fanSize ?? 2e3;
5806
+ const minBatch = options.minBatch ?? 8;
5807
+ const bulkDispatch = options.bulkDispatch ?? true;
5808
+ describe4(`Step fan results contract: ${name}`, () => {
5809
+ for (const { form, settle: settle2, waves } of FORMS) {
5810
+ const size = waves === 1 ? fanSize : Math.floor(fanSize / 2);
5811
+ const concurrency = waves === 1 ? void 0 : Math.ceil(size / waves);
5812
+ it4(`settles a ${form} fan of ${size} steps over two instances in batches`, async (ctx) => {
5813
+ const harness = await makeHarness();
5814
+ if (typeof harness === "string") {
5815
+ console.warn(`[step-fan-results contract] ${name} skipped: ${harness}`);
5816
+ ctx.skip();
5817
+ return;
5818
+ }
5819
+ const failing = settle2 ? /* @__PURE__ */ new Set([
5820
+ 1,
5821
+ size - 2
5822
+ ]) : /* @__PURE__ */ new Set();
5823
+ let ran = 0;
5824
+ let openBacklog;
5825
+ const backlog = new Promise((resolve) => {
5826
+ openBacklog = resolve;
5827
+ });
5828
+ const { engines: opened, close } = await harness.open(async (input) => {
5829
+ ran += 1;
5830
+ if (ran >= (concurrency ?? size)) openBacklog();
5831
+ const { i } = input;
5832
+ if (failing.has(i)) throw Object.assign(new Error(`bad ${i}`), {
5833
+ retryable: false
5834
+ });
5835
+ return i * 2;
5836
+ });
5837
+ const dispatched = {
5838
+ one: 0
5839
+ };
5840
+ const transports = opened.map((t) => behind(t, backlog, dispatched));
5841
+ if (bulkDispatch) {
5842
+ for (const t of opened) expect5(t.dispatchMany).toBeTypeOf("function");
5843
+ }
5844
+ const inner = new InMemoryStateStore5();
5845
+ const counts = {
5846
+ calls: /* @__PURE__ */ new Map(),
5847
+ batches: []
5848
+ };
5849
+ let turns = 0;
5850
+ const settled = /* @__PURE__ */ new Map();
5851
+ const engines = transports.map((transport) => {
5852
+ const engine = new WorkflowEngine6({
5853
+ store: counted(inner, counts),
5854
+ transport,
5855
+ reconcileMs: 0
5856
+ });
5857
+ engine.register("fan", "1", async (c) => {
5858
+ turns += 1;
5859
+ const inputs = Array.from({
5860
+ length: size
5861
+ }, (_, i) => ({
5862
+ i
5863
+ }));
5864
+ const opts = concurrency === void 0 ? {} : {
5865
+ concurrency
5866
+ };
5867
+ if (!settle2) return c.all(doubleLine, inputs, opts);
5868
+ const all = await c.allSettled(doubleLine, inputs, opts);
5869
+ return all.map((s) => s.status === "fulfilled" ? s.value : "failed");
5870
+ });
5871
+ engine.subscribe((e) => {
5872
+ if ((e.type === "step.completed" || e.type === "step.failed") && e.seq !== void 0) {
5873
+ settled.set(e.seq, (settled.get(e.seq) ?? 0) + 1);
5874
+ }
5875
+ });
5876
+ return engine;
5877
+ });
5878
+ try {
5879
+ await engines[0].start("fan", {}, "p");
5880
+ await until2(async () => {
5881
+ const status = (await inner.getRun("p"))?.status;
5882
+ return status === "completed" || status === "failed";
5883
+ }, timeoutMs - 5e3);
5884
+ const run2 = await inner.getRun("p");
5885
+ expect5(run2?.status).toBe("completed");
5886
+ expect5(run2?.output).toEqual(Array.from({
5887
+ length: size
5888
+ }, (_, i) => failing.has(i) ? "failed" : i * 2));
5889
+ expect5(settled.size).toBe(size);
5890
+ expect5([
5891
+ ...settled.values()
5892
+ ].every((n) => n === 1)).toBe(true);
5893
+ const barrierReads = counts.calls.get("countCheckpoints") ?? 0;
5894
+ expect5(Math.max(...counts.batches)).toBeGreaterThanOrEqual(minBatch);
5895
+ if (bulkDispatch) expect5(dispatched.one).toBe(0);
5896
+ if (waves === 1) expect5(barrierReads).toBeLessThanOrEqual(size / minBatch);
5897
+ expect5(turns).toBeLessThanOrEqual(1 + 2 * waves + failing.size);
5898
+ } finally {
5899
+ await close();
5900
+ }
5901
+ }, timeoutMs);
5902
+ }
5903
+ });
5904
+ }
5905
+ __name(runStepFanResultsContract, "runStepFanResultsContract");
5426
5906
  export {
5427
5907
  DURABLE_CANONICAL_COLUMNS,
5428
5908
  MutableClock,
5429
5909
  RUN_HISTORY_FIXTURE_VERSION,
5910
+ STEP_FAN_STEP,
5430
5911
  StateStoreUnavailableError,
5431
5912
  aggregationFixture,
5432
5913
  assertDurableColumns,
@@ -5447,6 +5928,7 @@ export {
5447
5928
  runAdmissionBackendContract,
5448
5929
  runRunDispatchContract,
5449
5930
  runStateStoreContract,
5931
+ runStepFanResultsContract,
5450
5932
  serializeRunHistory
5451
5933
  };
5452
5934
  //# sourceMappingURL=index.js.map