@nagi-js/core 0.1.1-rc.22 → 0.1.1-rc.24
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/{chunk-PUAV56FC.js → chunk-TXWUVL6W.js} +116 -48
- package/dist/chunk-TXWUVL6W.js.map +1 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.js +260 -96
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +377 -3
- package/dist/testing.js.map +1 -1
- package/dist/{types-Ct5xHI4W.d.ts → types-B5LHEF3v.d.ts} +20 -14
- package/package.json +1 -1
- package/dist/chunk-PUAV56FC.js.map +0 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Millis, aY as Store, b7 as Tx,
|
|
1
|
+
import { P as Millis, aY as Store, b7 as Tx, ax as StandardSchemaV1 } from './types-B5LHEF3v.js';
|
|
2
2
|
|
|
3
3
|
declare function passthroughSchema<T>(): StandardSchemaV1<T, T>;
|
|
4
4
|
interface StoreContractHarness {
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Facts, isRunEnd, stepStateOf,
|
|
1
|
+
import { InMemoryQueue, Facts, isRunEnd, stepStateOf, stepStatusOf, NagiConcurrencyConflictError } from './chunk-TXWUVL6W.js';
|
|
2
2
|
|
|
3
3
|
// src/testing.ts
|
|
4
4
|
function passthroughSchema() {
|
|
@@ -261,6 +261,67 @@ var storeContract = [
|
|
|
261
261
|
);
|
|
262
262
|
}
|
|
263
263
|
},
|
|
264
|
+
{
|
|
265
|
+
name: "tryStartRun: a seed is enqueued with the start, once",
|
|
266
|
+
async run(h) {
|
|
267
|
+
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
268
|
+
const runId = rid();
|
|
269
|
+
const flowId = fid();
|
|
270
|
+
const queue = new InMemoryQueue();
|
|
271
|
+
const fact = Facts.flowStarted({
|
|
272
|
+
runId,
|
|
273
|
+
flowId,
|
|
274
|
+
input: {},
|
|
275
|
+
at: /* @__PURE__ */ new Date()
|
|
276
|
+
});
|
|
277
|
+
const steps = ["a", "b"];
|
|
278
|
+
const res = await s.tryStartRun(runId, fact, void 0, {
|
|
279
|
+
queue,
|
|
280
|
+
flowId,
|
|
281
|
+
steps
|
|
282
|
+
});
|
|
283
|
+
ok(res.started, "start reports started");
|
|
284
|
+
const queued = await queue.dequeue({ count: 10 });
|
|
285
|
+
eq(
|
|
286
|
+
queued.map((m) => ({ runId: m.runId, stepId: m.stepId, flowId: m.flowId })).sort((x, y) => x.stepId < y.stepId ? -1 : 1),
|
|
287
|
+
[
|
|
288
|
+
{ runId, stepId: "a", flowId },
|
|
289
|
+
{ runId, stepId: "b", flowId }
|
|
290
|
+
],
|
|
291
|
+
"both seed steps are queued once, for this run and flowId"
|
|
292
|
+
);
|
|
293
|
+
const again = await s.tryStartRun(runId, fact, void 0, {
|
|
294
|
+
queue,
|
|
295
|
+
flowId,
|
|
296
|
+
steps
|
|
297
|
+
});
|
|
298
|
+
eq(again.started, false, "second identical call is refused");
|
|
299
|
+
eq(await queue.dequeue({ count: 10 }), [], "nothing more is queued");
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "tryStartRun: a refused start enqueues nothing",
|
|
304
|
+
async run(h) {
|
|
305
|
+
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
306
|
+
const runId = rid();
|
|
307
|
+
const flowId = fid();
|
|
308
|
+
await startRun(s, runId, { flowId });
|
|
309
|
+
const queue = new InMemoryQueue();
|
|
310
|
+
const fact = Facts.flowStarted({
|
|
311
|
+
runId,
|
|
312
|
+
flowId,
|
|
313
|
+
input: {},
|
|
314
|
+
at: /* @__PURE__ */ new Date()
|
|
315
|
+
});
|
|
316
|
+
const res = await s.tryStartRun(runId, fact, void 0, {
|
|
317
|
+
queue,
|
|
318
|
+
flowId,
|
|
319
|
+
steps: ["a"]
|
|
320
|
+
});
|
|
321
|
+
eq(res.started, false, "refused: runId already exists");
|
|
322
|
+
eq(await queue.dequeue({ count: 10 }), [], "the queue is empty");
|
|
323
|
+
}
|
|
324
|
+
},
|
|
264
325
|
{
|
|
265
326
|
// The third face of nagi#29, and the one the issue's hypothesis list
|
|
266
327
|
// misses: tryStartRun is atomic, but nothing keeps the superseder ALIVE.
|
|
@@ -562,6 +623,34 @@ var storeContract = [
|
|
|
562
623
|
);
|
|
563
624
|
}
|
|
564
625
|
},
|
|
626
|
+
{
|
|
627
|
+
name: "runStep: the body reads run state on its tx and sees committed facts",
|
|
628
|
+
async run(h) {
|
|
629
|
+
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
630
|
+
const runId = rid();
|
|
631
|
+
await startRun(s, runId);
|
|
632
|
+
await startStep(s, runId, "s");
|
|
633
|
+
await s.appendFact(
|
|
634
|
+
runId,
|
|
635
|
+
Facts.stepAbortRequested({
|
|
636
|
+
runId,
|
|
637
|
+
stepId: "s",
|
|
638
|
+
attempt: A1,
|
|
639
|
+
at: /* @__PURE__ */ new Date()
|
|
640
|
+
})
|
|
641
|
+
);
|
|
642
|
+
let seenTag;
|
|
643
|
+
await s.runStep(runId, "s", A1, async (tx) => {
|
|
644
|
+
const seen = await s.loadRunState(runId, tx);
|
|
645
|
+
seenTag = stepStateOf(seen, "s").tag;
|
|
646
|
+
return {
|
|
647
|
+
output: null,
|
|
648
|
+
fact: Facts.stepCanceled(runId, "s", A1, /* @__PURE__ */ new Date())
|
|
649
|
+
};
|
|
650
|
+
});
|
|
651
|
+
eq(seenTag, "aborting", "tx read sees the abort-requested fold");
|
|
652
|
+
}
|
|
653
|
+
},
|
|
565
654
|
{
|
|
566
655
|
name: "settleSignal(deliver): releases the lease and the armed timer",
|
|
567
656
|
async run(h) {
|
|
@@ -587,6 +676,34 @@ var storeContract = [
|
|
|
587
676
|
);
|
|
588
677
|
}
|
|
589
678
|
},
|
|
679
|
+
{
|
|
680
|
+
name: "settleSignal(consume): parking an awaiting step releases its lease and keeps its timer",
|
|
681
|
+
async run(h) {
|
|
682
|
+
const s = await h.makeStore({ leaseMs: SHORT_LEASE_MS });
|
|
683
|
+
const queue = new InMemoryQueue();
|
|
684
|
+
const runId = rid();
|
|
685
|
+
await startRun(s, runId);
|
|
686
|
+
await startStep(s, runId, "gate", { kind: "signal" });
|
|
687
|
+
ok(await s.claimStep(runId, "gate", A1) !== null, "claim");
|
|
688
|
+
const fireAt = new Date(Date.now() + HOUR_MS);
|
|
689
|
+
await s.upsertTimer(runId, "gate", fireAt);
|
|
690
|
+
eq(
|
|
691
|
+
await s.settleSignal({ runId, stepId: "gate", at: /* @__PURE__ */ new Date() }),
|
|
692
|
+
{ tag: "noop" },
|
|
693
|
+
"parks"
|
|
694
|
+
);
|
|
695
|
+
await sleep(PAST_LEASE_MS);
|
|
696
|
+
eq(
|
|
697
|
+
await s.sweepLeases({ now: /* @__PURE__ */ new Date(), queue }),
|
|
698
|
+
[],
|
|
699
|
+
"nothing to reap"
|
|
700
|
+
);
|
|
701
|
+
const timedOut = await s.sweepSignalTimeouts({
|
|
702
|
+
now: new Date(fireAt.getTime() + 1)
|
|
703
|
+
});
|
|
704
|
+
eq(timedOut.length, 1, "timer survived the park");
|
|
705
|
+
}
|
|
706
|
+
},
|
|
590
707
|
{
|
|
591
708
|
name: "sweepSignalTimeouts: fails an awaiting step past its deadline with NagiSignalTimeoutError, releases its lease, consumes the timer",
|
|
592
709
|
async run(h) {
|
|
@@ -950,6 +1067,36 @@ var storeContract = [
|
|
|
950
1067
|
await claimableAgain(s, runId, "s", "sweepLeases");
|
|
951
1068
|
}
|
|
952
1069
|
},
|
|
1070
|
+
{
|
|
1071
|
+
name: "step.retried releases the failed attempt's lease, so the reaper leaves the backoff alone",
|
|
1072
|
+
async run(h) {
|
|
1073
|
+
const s = await h.makeStore({ leaseMs: SHORT_LEASE_MS });
|
|
1074
|
+
const queue = new InMemoryQueue();
|
|
1075
|
+
const runId = rid();
|
|
1076
|
+
await startRun(s, runId);
|
|
1077
|
+
await startStep(s, runId, "s");
|
|
1078
|
+
ok(await s.claimStep(runId, "s", A1) !== null, "claim");
|
|
1079
|
+
const now = Date.now();
|
|
1080
|
+
await s.appendFact(
|
|
1081
|
+
runId,
|
|
1082
|
+
Facts.stepRetried(
|
|
1083
|
+
runId,
|
|
1084
|
+
"s",
|
|
1085
|
+
A1,
|
|
1086
|
+
new Date(now + HOUR_MS),
|
|
1087
|
+
{ name: "Error", message: "boom" },
|
|
1088
|
+
new Date(now)
|
|
1089
|
+
)
|
|
1090
|
+
);
|
|
1091
|
+
await sleep(PAST_LEASE_MS);
|
|
1092
|
+
eq(
|
|
1093
|
+
await s.sweepLeases({ now: /* @__PURE__ */ new Date(), queue }),
|
|
1094
|
+
[],
|
|
1095
|
+
"nothing to reap"
|
|
1096
|
+
);
|
|
1097
|
+
await claimableAgain(s, runId, "s", "step.retried");
|
|
1098
|
+
}
|
|
1099
|
+
},
|
|
953
1100
|
{
|
|
954
1101
|
name: "sweepLeases: skips live leases and the released lease of a settled step",
|
|
955
1102
|
async run(h) {
|
|
@@ -1341,6 +1488,80 @@ var storeContract = [
|
|
|
1341
1488
|
);
|
|
1342
1489
|
}
|
|
1343
1490
|
},
|
|
1491
|
+
{
|
|
1492
|
+
name: "a settle needs its attempt to have started: after a reset, a pre-reset attempt's completion, failure or cancel changes nothing in loadRunState or describe",
|
|
1493
|
+
async run(h) {
|
|
1494
|
+
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
1495
|
+
const runId = rid();
|
|
1496
|
+
const t = (n) => new Date(17e11 + n * 1e3);
|
|
1497
|
+
const error = { name: "E", message: "stale" };
|
|
1498
|
+
const stale = (at) => [
|
|
1499
|
+
Facts.stepCompleted(runId, "s", A2, { stale: true }, at),
|
|
1500
|
+
Facts.stepFailed(runId, "s", A2, error, at),
|
|
1501
|
+
Facts.stepCanceled(runId, "s", A2, at, error)
|
|
1502
|
+
];
|
|
1503
|
+
await startRun(s, runId, { at: t(0) });
|
|
1504
|
+
await s.appendFact(
|
|
1505
|
+
runId,
|
|
1506
|
+
Facts.stepStarted(runId, "s", A1, "task", t(1))
|
|
1507
|
+
);
|
|
1508
|
+
await s.appendFact(
|
|
1509
|
+
runId,
|
|
1510
|
+
Facts.stepStarted(runId, "s", A2, "task", t(2))
|
|
1511
|
+
);
|
|
1512
|
+
await s.appendFact(
|
|
1513
|
+
runId,
|
|
1514
|
+
Facts.stepReset({ runId, stepId: "s", at: t(3) })
|
|
1515
|
+
);
|
|
1516
|
+
for (const fact of stale(t(4))) await s.appendFact(runId, fact);
|
|
1517
|
+
eq(
|
|
1518
|
+
stepStateOf(await s.loadRunState(runId), "s"),
|
|
1519
|
+
{ tag: "pending" },
|
|
1520
|
+
"loadRunState: a reset step ignores a settle before it restarts"
|
|
1521
|
+
);
|
|
1522
|
+
eq(
|
|
1523
|
+
await stepView(s, runId, "s"),
|
|
1524
|
+
void 0,
|
|
1525
|
+
"describe: a reset step ignores a settle before it restarts"
|
|
1526
|
+
);
|
|
1527
|
+
await s.appendFact(
|
|
1528
|
+
runId,
|
|
1529
|
+
Facts.stepStarted(runId, "s", A1, "task", t(5))
|
|
1530
|
+
);
|
|
1531
|
+
for (const fact of stale(t(6))) await s.appendFact(runId, fact);
|
|
1532
|
+
eq(
|
|
1533
|
+
stepStateOf(await s.loadRunState(runId), "s"),
|
|
1534
|
+
{ tag: "running", attempt: A1 },
|
|
1535
|
+
"loadRunState: a settle for an attempt that has not started is ignored"
|
|
1536
|
+
);
|
|
1537
|
+
eq(
|
|
1538
|
+
await stepView(s, runId, "s"),
|
|
1539
|
+
{ stepId: "s", attempt: A1, status: "running", startedAt: t(5) },
|
|
1540
|
+
"describe: a settle for an attempt that has not started is ignored"
|
|
1541
|
+
);
|
|
1542
|
+
await s.appendFact(
|
|
1543
|
+
runId,
|
|
1544
|
+
Facts.stepCompleted(runId, "s", A1, { fresh: true }, t(7))
|
|
1545
|
+
);
|
|
1546
|
+
eq(
|
|
1547
|
+
stepStateOf(await s.loadRunState(runId), "s"),
|
|
1548
|
+
{ tag: "completed", attempt: A1, output: { fresh: true } },
|
|
1549
|
+
"loadRunState: the restarted attempt settles"
|
|
1550
|
+
);
|
|
1551
|
+
eq(
|
|
1552
|
+
await stepView(s, runId, "s"),
|
|
1553
|
+
{
|
|
1554
|
+
stepId: "s",
|
|
1555
|
+
attempt: A1,
|
|
1556
|
+
status: "completed",
|
|
1557
|
+
startedAt: t(5),
|
|
1558
|
+
completedAt: t(7),
|
|
1559
|
+
output: { fresh: true }
|
|
1560
|
+
},
|
|
1561
|
+
"describe: the restarted attempt settles"
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1344
1565
|
{
|
|
1345
1566
|
name: "describe: a skipped step settles its view; a settled step changes only by reset",
|
|
1346
1567
|
async run(h) {
|
|
@@ -1670,6 +1891,55 @@ var storeContract = [
|
|
|
1670
1891
|
);
|
|
1671
1892
|
}
|
|
1672
1893
|
},
|
|
1894
|
+
{
|
|
1895
|
+
name: "events: step.canceled and step.reset are events",
|
|
1896
|
+
async run(h) {
|
|
1897
|
+
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
1898
|
+
if (s.events === void 0) return;
|
|
1899
|
+
const runId = rid();
|
|
1900
|
+
const seen = [];
|
|
1901
|
+
const off = s.events.watchRuns((e) => {
|
|
1902
|
+
if (e.runId === runId) seen.push(e);
|
|
1903
|
+
});
|
|
1904
|
+
try {
|
|
1905
|
+
await startRun(s, runId);
|
|
1906
|
+
await startStep(s, runId, "s");
|
|
1907
|
+
await s.appendFact(
|
|
1908
|
+
runId,
|
|
1909
|
+
Facts.stepCanceled(runId, "s", A1, /* @__PURE__ */ new Date())
|
|
1910
|
+
);
|
|
1911
|
+
await s.appendFact(
|
|
1912
|
+
runId,
|
|
1913
|
+
Facts.stepReset({ runId, stepId: "s", at: /* @__PURE__ */ new Date() })
|
|
1914
|
+
);
|
|
1915
|
+
const want = [
|
|
1916
|
+
"flow.started",
|
|
1917
|
+
"step.started",
|
|
1918
|
+
"step.canceled",
|
|
1919
|
+
"step.reset"
|
|
1920
|
+
];
|
|
1921
|
+
await eventually(() => seen.length >= want.length, "all four events");
|
|
1922
|
+
eq(
|
|
1923
|
+
seen.map((e) => e.type),
|
|
1924
|
+
want,
|
|
1925
|
+
"cancel and reset are observable"
|
|
1926
|
+
);
|
|
1927
|
+
eq(
|
|
1928
|
+
seen.slice(2).map((e) => ({
|
|
1929
|
+
type: e.type,
|
|
1930
|
+
stepId: e.stepId
|
|
1931
|
+
})),
|
|
1932
|
+
[
|
|
1933
|
+
{ type: "step.canceled", stepId: "s" },
|
|
1934
|
+
{ type: "step.reset", stepId: "s" }
|
|
1935
|
+
],
|
|
1936
|
+
"carry the stepId"
|
|
1937
|
+
);
|
|
1938
|
+
} finally {
|
|
1939
|
+
off();
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
},
|
|
1673
1943
|
{
|
|
1674
1944
|
name: "events: a superseded run announces flow.canceled naming its superseder",
|
|
1675
1945
|
async run(h) {
|
|
@@ -1697,6 +1967,33 @@ var storeContract = [
|
|
|
1697
1967
|
);
|
|
1698
1968
|
}
|
|
1699
1969
|
},
|
|
1970
|
+
{
|
|
1971
|
+
name: "events: a run whose outputs exceed 8 KB still commits, and its events carry no payload",
|
|
1972
|
+
async run(h) {
|
|
1973
|
+
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
1974
|
+
if (s.events === void 0) return;
|
|
1975
|
+
const runId = rid();
|
|
1976
|
+
const seen = [];
|
|
1977
|
+
s.events.watchRun(runId, (e) => seen.push(e));
|
|
1978
|
+
await startRun(s, runId);
|
|
1979
|
+
await startStep(s, runId, "s");
|
|
1980
|
+
const big = { text: "x".repeat(2e4) };
|
|
1981
|
+
await s.appendFact(
|
|
1982
|
+
runId,
|
|
1983
|
+
Facts.stepCompleted(runId, "s", A1, big, /* @__PURE__ */ new Date())
|
|
1984
|
+
);
|
|
1985
|
+
await s.endRun(runId, Facts.flowCompleted(runId, big, /* @__PURE__ */ new Date()));
|
|
1986
|
+
await eventually(
|
|
1987
|
+
() => seen.some((e) => e.type === "flow.completed"),
|
|
1988
|
+
"flow.completed"
|
|
1989
|
+
);
|
|
1990
|
+
ok(
|
|
1991
|
+
seen.every((e) => !("output" in e) && !("error" in e)),
|
|
1992
|
+
"events carry no payload"
|
|
1993
|
+
);
|
|
1994
|
+
eq((await s.loadRunState(runId)).phase.tag, "completed", "run committed");
|
|
1995
|
+
}
|
|
1996
|
+
},
|
|
1700
1997
|
{
|
|
1701
1998
|
name: "stream: a subscriber receives published chunks, then closes on step.completed",
|
|
1702
1999
|
async run(h) {
|
|
@@ -1723,7 +2020,7 @@ var storeContract = [
|
|
|
1723
2020
|
}
|
|
1724
2021
|
},
|
|
1725
2022
|
{
|
|
1726
|
-
name: "stream: step.failed
|
|
2023
|
+
name: "stream: step.failed ends the stream with an error event; a run end closes a step that never emitted",
|
|
1727
2024
|
async run(h) {
|
|
1728
2025
|
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
1729
2026
|
if (s.stream === void 0) return;
|
|
@@ -1738,7 +2035,7 @@ var storeContract = [
|
|
|
1738
2035
|
runId,
|
|
1739
2036
|
Facts.stepFailed(runId, "bad", A1, error, /* @__PURE__ */ new Date())
|
|
1740
2037
|
);
|
|
1741
|
-
eq(await bad, [{ kind: "error"
|
|
2038
|
+
eq(await bad, [{ kind: "error" }], "error event, then closed");
|
|
1742
2039
|
await endRun(s, runId, "canceled");
|
|
1743
2040
|
eq(await quiet, [], "closed by the run end");
|
|
1744
2041
|
}
|
|
@@ -1762,6 +2059,83 @@ var storeContract = [
|
|
|
1762
2059
|
);
|
|
1763
2060
|
}
|
|
1764
2061
|
},
|
|
2062
|
+
{
|
|
2063
|
+
name: "stream: a reset step's channel reopens for its rerun",
|
|
2064
|
+
async run(h) {
|
|
2065
|
+
const s = await h.makeStore({ leaseMs: LEASE_MS });
|
|
2066
|
+
if (s.stream === void 0) return;
|
|
2067
|
+
const runId = rid();
|
|
2068
|
+
await startRun(s, runId);
|
|
2069
|
+
await startStep(s, runId, "s", { kind: "streaming" });
|
|
2070
|
+
const first = drain(
|
|
2071
|
+
s.stream.subscribeStream(runId, "s"),
|
|
2072
|
+
"first attempt"
|
|
2073
|
+
);
|
|
2074
|
+
s.stream.publishChunk(runId, "s", "one");
|
|
2075
|
+
await s.appendFact(
|
|
2076
|
+
runId,
|
|
2077
|
+
Facts.stepCompleted(runId, "s", A1, null, /* @__PURE__ */ new Date())
|
|
2078
|
+
);
|
|
2079
|
+
eq(
|
|
2080
|
+
await first,
|
|
2081
|
+
[{ kind: "chunk", chunk: "one" }],
|
|
2082
|
+
"first attempt streamed"
|
|
2083
|
+
);
|
|
2084
|
+
await s.appendFact(
|
|
2085
|
+
runId,
|
|
2086
|
+
Facts.stepReset({ runId, stepId: "s", at: /* @__PURE__ */ new Date() })
|
|
2087
|
+
);
|
|
2088
|
+
await startStep(s, runId, "s", { attempt: A1, kind: "streaming" });
|
|
2089
|
+
const rerun = drain(
|
|
2090
|
+
s.stream.subscribeStream(runId, "s"),
|
|
2091
|
+
"rerun completed"
|
|
2092
|
+
);
|
|
2093
|
+
s.stream.publishChunk(runId, "s", "again");
|
|
2094
|
+
await s.appendFact(
|
|
2095
|
+
runId,
|
|
2096
|
+
Facts.stepCompleted(runId, "s", A1, null, /* @__PURE__ */ new Date())
|
|
2097
|
+
);
|
|
2098
|
+
eq(
|
|
2099
|
+
await rerun,
|
|
2100
|
+
[{ kind: "chunk", chunk: "again" }],
|
|
2101
|
+
"rerun chunk delivered"
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
name: "stream: a reaped lease tells subscribers a new attempt started",
|
|
2107
|
+
async run(h) {
|
|
2108
|
+
const s = await h.makeStore({ leaseMs: SHORT_LEASE_MS });
|
|
2109
|
+
if (s.stream === void 0) return;
|
|
2110
|
+
const queue = new InMemoryQueue();
|
|
2111
|
+
const runId = rid();
|
|
2112
|
+
await startRun(s, runId);
|
|
2113
|
+
await startStep(s, runId, "s", { kind: "streaming" });
|
|
2114
|
+
ok(await s.claimStep(runId, "s", A1) !== null, "claim");
|
|
2115
|
+
const events = drain(
|
|
2116
|
+
s.stream.subscribeStream(runId, "s"),
|
|
2117
|
+
"reaped then rerun"
|
|
2118
|
+
);
|
|
2119
|
+
s.stream.publishChunk(runId, "s", "a");
|
|
2120
|
+
await sleep(PAST_LEASE_MS);
|
|
2121
|
+
await s.sweepLeases({ now: /* @__PURE__ */ new Date(), queue });
|
|
2122
|
+
await startStep(s, runId, "s", { attempt: A2, kind: "streaming" });
|
|
2123
|
+
s.stream.publishChunk(runId, "s", "b");
|
|
2124
|
+
await s.appendFact(
|
|
2125
|
+
runId,
|
|
2126
|
+
Facts.stepCompleted(runId, "s", A2, null, /* @__PURE__ */ new Date())
|
|
2127
|
+
);
|
|
2128
|
+
eq(
|
|
2129
|
+
await events,
|
|
2130
|
+
[
|
|
2131
|
+
{ kind: "chunk", chunk: "a" },
|
|
2132
|
+
{ kind: "retry", attempt: 2 },
|
|
2133
|
+
{ kind: "chunk", chunk: "b" }
|
|
2134
|
+
],
|
|
2135
|
+
"chunk, retry marker, chunk"
|
|
2136
|
+
);
|
|
2137
|
+
}
|
|
2138
|
+
},
|
|
1765
2139
|
{
|
|
1766
2140
|
name: "sweepLeases: a failing enqueue leaves nothing half-reaped \u2014 the lease stays reapable and no lease.reaped is written",
|
|
1767
2141
|
async run(h) {
|