effect-mq 0.5.0 → 0.6.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 (59) hide show
  1. package/README.md +85 -17
  2. package/dist/Flow.d.ts +381 -0
  3. package/dist/Flow.d.ts.map +1 -0
  4. package/dist/Flow.js +340 -0
  5. package/dist/Flow.js.map +1 -0
  6. package/dist/Job.d.ts +31 -6
  7. package/dist/Job.d.ts.map +1 -1
  8. package/dist/Job.js +16 -2
  9. package/dist/Job.js.map +1 -1
  10. package/dist/JobStore.d.ts +312 -10
  11. package/dist/JobStore.d.ts.map +1 -1
  12. package/dist/JobStore.js.map +1 -1
  13. package/dist/MemoryJobStore.d.ts.map +1 -1
  14. package/dist/MemoryJobStore.js +334 -7
  15. package/dist/MemoryJobStore.js.map +1 -1
  16. package/dist/Metrics.d.ts +31 -0
  17. package/dist/Metrics.d.ts.map +1 -1
  18. package/dist/Metrics.js +39 -0
  19. package/dist/Metrics.js.map +1 -1
  20. package/dist/Worker.d.ts +120 -11
  21. package/dist/Worker.d.ts.map +1 -1
  22. package/dist/Worker.js +452 -26
  23. package/dist/Worker.js.map +1 -1
  24. package/dist/drizzle-postgres/DrizzleJobStore.d.ts +19 -1
  25. package/dist/drizzle-postgres/DrizzleJobStore.d.ts.map +1 -1
  26. package/dist/drizzle-postgres/DrizzleJobStore.js +653 -77
  27. package/dist/drizzle-postgres/DrizzleJobStore.js.map +1 -1
  28. package/dist/drizzle-postgres/schema.d.ts +293 -3
  29. package/dist/drizzle-postgres/schema.d.ts.map +1 -1
  30. package/dist/drizzle-postgres/schema.js +66 -1
  31. package/dist/drizzle-postgres/schema.js.map +1 -1
  32. package/dist/index.d.ts +7 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +7 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/redis/RedisJobStore.d.ts.map +1 -1
  37. package/dist/redis/RedisJobStore.js +219 -18
  38. package/dist/redis/RedisJobStore.js.map +1 -1
  39. package/dist/redis/scripts.d.ts +117 -10
  40. package/dist/redis/scripts.d.ts.map +1 -1
  41. package/dist/redis/scripts.js +492 -25
  42. package/dist/redis/scripts.js.map +1 -1
  43. package/dist/testing/conformance.d.ts +6 -0
  44. package/dist/testing/conformance.d.ts.map +1 -1
  45. package/dist/testing/conformance.js +728 -1
  46. package/dist/testing/conformance.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/Flow.ts +778 -0
  49. package/src/Job.ts +35 -11
  50. package/src/JobStore.ts +339 -9
  51. package/src/MemoryJobStore.ts +370 -7
  52. package/src/Metrics.ts +43 -0
  53. package/src/Worker.ts +726 -37
  54. package/src/drizzle-postgres/DrizzleJobStore.ts +817 -78
  55. package/src/drizzle-postgres/schema.ts +92 -0
  56. package/src/index.ts +8 -0
  57. package/src/redis/RedisJobStore.ts +289 -8
  58. package/src/redis/scripts.ts +524 -24
  59. package/src/testing/conformance.ts +945 -1
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/drizzle-postgres/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EACL,KAAK,kBAAkB,EAMvB,KAAK,yBAAyB,EAE9B,KAAK,uBAAuB,EAI7B,MAAM,qBAAqB,CAAA;AAG5B,KAAK,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;AAQnC;;;;;;GAMG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAChF,QAAQ,CAAC,WAAW,CAAC,EACjB,CAAC,CAAC,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,uBAAuB,CAAC,CAAC,GAC/E,SAAS,CAAA;CACd;AAED,QAAA,MAAM,WAAW,GAAI,OAAO,SAAS,MAAM,E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AAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIrE,CAAA;AAEJ;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAE7D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;AAEjE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAEvE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,CAAA;AAExE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;AAE5D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAEnE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { sql } from "drizzle-orm";
2
- import { bigint, boolean, index, integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
2
+ import { bigint, bigserial, boolean, index, integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
3
3
  const jobsColumns = () => ({
4
4
  id: text("id").primaryKey().$type(),
5
5
  name: text("name").notNull().$type(),
@@ -19,6 +19,14 @@ const jobsColumns = () => ({
19
19
  cancelRequested: boolean("cancel_requested").notNull().default(false),
20
20
  dedupeKey: text("dedupe_key"),
21
21
  trace: jsonb("trace").$type(),
22
+ /** Flow-parent link on child jobs (opaque envelope, like `trace`). */
23
+ parent: jsonb("parent").$type(),
24
+ /** Flow bookkeeping: NULL together until a FanOut ack lands the manifest. */
25
+ flowFailFast: boolean("flow_fail_fast"),
26
+ flowPending: integer("flow_pending"),
27
+ flowCompleted: integer("flow_completed"),
28
+ flowFailed: integer("flow_failed"),
29
+ flowCancelled: integer("flow_cancelled"),
22
30
  runAt: timestamp("run_at", { withTimezone: true, mode: "date" }).notNull(),
23
31
  enqueuedAt: timestamp("enqueued_at", { withTimezone: true, mode: "date" }).notNull(),
24
32
  processedAt: timestamp("processed_at", { withTimezone: true, mode: "date" }),
@@ -143,6 +151,63 @@ export const mqDedupe = (tableName = "effect_mq_dedupe", options) => pgTable(tab
143
151
  primaryKey({ columns: [table.name, table.key] }),
144
152
  ...options?.extraConfig?.(table) ?? []
145
153
  ]);
154
+ const flowChildrenColumns = () => ({
155
+ /** The parent (flow) job's id in this store. */
156
+ flowId: text("flow_id").notNull().$type(),
157
+ /** Unique within the flow (the idempotency mechanism). */
158
+ childKey: text("child_key").notNull(),
159
+ /** The child job's name (projection of `spec.name` for dashboards). */
160
+ name: text("name").notNull(),
161
+ /** The CHILD store's context-key string (children may live elsewhere). */
162
+ storeKey: text("store_key").notNull(),
163
+ /** The FULL `EnqueueRequest`, so the sweeper can re-enqueue from storage. */
164
+ spec: jsonb("spec").notNull().$type(),
165
+ status: text("status").notNull().$type(),
166
+ /** The child's schema-encoded exit; NULL for store-side failures. */
167
+ exit: jsonb("exit"),
168
+ failedReason: text("failed_reason"),
169
+ /** True once no cancel needs delivering into the child's store. */
170
+ cascaded: boolean("cascaded").notNull(),
171
+ pendingSince: timestamp("pending_since", { withTimezone: true, mode: "date" }).notNull()
172
+ });
173
+ /**
174
+ * Flow dependency rows (one per fan-out child; see `JobStore.FlowChildRecord`).
175
+ * Lives next to the PARENT store's jobs table.
176
+ *
177
+ * @since 0.6.0
178
+ */
179
+ export const mqFlowChildren = (tableName = "effect_mq_flow_children", options) => pgTable(tableName, flowChildrenColumns(), (table) => [
180
+ primaryKey({ columns: [table.flowId, table.childKey] }),
181
+ // flowSweepWork reconcile: pending rows older than the threshold.
182
+ index(`${tableName}_pending_idx`)
183
+ .on(table.pendingSince)
184
+ .where(sql `${table.status} = 'pending'`),
185
+ // flowSweepWork cascade: cancelled rows not yet delivered.
186
+ index(`${tableName}_cascade_idx`)
187
+ .on(table.flowId)
188
+ .where(sql `${table.status} = 'cancelled' AND NOT ${table.cascaded}`),
189
+ ...options?.extraConfig?.(table) ?? []
190
+ ]);
191
+ const flowOutboxColumns = () => ({
192
+ /** Store-assigned, oldest-first; exposed to callers as an opaque string. */
193
+ id: bigserial("id", { mode: "number" }).primaryKey(),
194
+ /** The flow definition's name, for relay routing. */
195
+ flowName: text("flow_name").notNull(),
196
+ /** The PARENT store's context-key string, for relay routing. */
197
+ parentStoreKey: text("parent_store_key").notNull(),
198
+ /** The full `FlowChildReport` to deliver into the parent store. */
199
+ report: jsonb("report").notNull().$type()
200
+ });
201
+ /**
202
+ * Undelivered child-result reports (one per terminal transition of an
203
+ * envelope-carrying job; see `JobStore.OutboxEntry`). Lives next to the
204
+ * CHILD store's jobs table.
205
+ *
206
+ * @since 0.6.0
207
+ */
208
+ export const mqFlowOutbox = (tableName = "effect_mq_flow_outbox", options) => pgTable(tableName, flowOutboxColumns(), (table) => [
209
+ ...options?.extraConfig?.(table) ?? []
210
+ ]);
146
211
  const queueControlColumns = () => ({
147
212
  queue: text("queue").primaryKey().$type(),
148
213
  paused: boolean("paused").notNull().default(false)
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/drizzle-postgres/schema.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAEL,MAAM,EACN,OAAO,EACP,KAAK,EACL,OAAO,EACP,KAAK,EAEL,OAAO,EAEP,UAAU,EACV,IAAI,EACJ,SAAS,EACV,MAAM,qBAAqB,CAAA;AAwB5B,MAAM,WAAW,GAAG,GAAiD,EAAE,CAAC,CAAC;IACvE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EA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AAC,OAAO,CAAC,KAAK,CAAC;CACnD,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,SAAS,GAAG,yBAAyB,EACrC,OAAuE,EACvE,EAAE,CACF,OAAO,CAAC,SAAS,EAAE,mBAAmB,EAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1D,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE;CACvC,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,13 @@
3
3
  *
4
4
  * @since 0.1.0
5
5
  */
6
+ /**
7
+ * Cross-store parent-child flows: `Flow.make`, `Flow.children`, the
8
+ * two-phase `fanOut`/`collect` handler.
9
+ *
10
+ * @since 0.6.0
11
+ */
12
+ export * as Flow from "./Flow.ts";
6
13
  /**
7
14
  * Schema-first job definitions: `Job.make`, `enqueue`, `toLayer`.
8
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B;;;;;GAKG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;;GAIG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;GAIG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;;;GAKG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;GAIG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B;;;;;GAKG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;;GAIG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;GAIG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;;;GAKG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -3,6 +3,13 @@
3
3
  *
4
4
  * @since 0.1.0
5
5
  */
6
+ /**
7
+ * Cross-store parent-child flows: `Flow.make`, `Flow.children`, the
8
+ * two-phase `fanOut`/`collect` handler.
9
+ *
10
+ * @since 0.6.0
11
+ */
12
+ export * as Flow from "./Flow.js";
6
13
  /**
7
14
  * Schema-first job definitions: `Job.make`, `enqueue`, `toLayer`.
8
15
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B;;;;;GAKG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;;GAIG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;GAIG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;;;GAKG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;GAIG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AA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,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAy4B/D,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,KAAK,aACN,oBAAoB,GAAG,SAAS,KACzC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAmD,CAAA;AAEvG;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SACvB,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,YACnC,oBAAoB,GAAG,SAAS,KACzC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAuC,CAAA"}
@@ -56,6 +56,18 @@ const toRecord = (hash) => ({
56
56
  cancelRequested: hash.get("cancelRequested") === "1",
57
57
  dedupeKey: optionalString(hash.get("dedupeKey")),
58
58
  trace: optionalJson(hash.get("trace")),
59
+ parent: optionalJson(hash.get("parent")),
60
+ // Manifest presence IS the phase marker: hashes written before flows (or
61
+ // parents that never fanned out) simply lack the flow fields.
62
+ flow: optionalString(hash.get("flowPending")) === undefined
63
+ ? undefined
64
+ : {
65
+ failFast: hash.get("flowFailFast") === "1",
66
+ pending: Number(hash.get("flowPending")),
67
+ completed: Number(hash.get("flowCompleted") ?? 0),
68
+ failed: Number(hash.get("flowFailed") ?? 0),
69
+ cancelled: Number(hash.get("flowCancelled") ?? 0)
70
+ },
59
71
  runAt: Number(hash.get("runAt") ?? 0),
60
72
  enqueuedAt: Number(hash.get("enqueuedAt") ?? 0),
61
73
  processedAt: optionalNumber(hash.get("processedAt")),
@@ -82,14 +94,57 @@ const toSchedule = (hash) => ({
82
94
  });
83
95
  // cjson encodes an empty Lua table as {}, not [] — normalize.
84
96
  const asArray = (value) => Array.isArray(value) ? value : [];
97
+ /**
98
+ * Decode one outbox zset member: `<seq>\0<json>` where the json carries the
99
+ * verbatim parent envelope plus the terminal outcome. The full member string
100
+ * is the opaque entry id (deleteOutbox is then a plain ZREM).
101
+ */
102
+ const toOutboxEntry = (member) => {
103
+ const sep = member.indexOf("\u0000");
104
+ const body = JSON.parse(member.slice(sep + 1));
105
+ return {
106
+ id: member,
107
+ flowName: body.parent.flowName,
108
+ parentStoreKey: body.parent.parentStoreKey,
109
+ report: {
110
+ flowId: body.parent.flowId,
111
+ childKey: body.parent.childKey,
112
+ outcome: body.outcome,
113
+ // The exit key is omitted entirely when absent (ledger convention),
114
+ // so a legitimate encoded null exit survives the round trip.
115
+ exit: Object.hasOwn(body, "exit") ? body.exit : undefined,
116
+ failedReason: body.failedReason
117
+ }
118
+ };
119
+ };
85
120
  const JOB_STATES = [
86
121
  "waiting",
87
122
  "delayed",
88
123
  "active",
124
+ "waiting-children",
89
125
  "completed",
90
126
  "failed",
91
127
  "cancelled"
92
128
  ];
129
+ /**
130
+ * Fold one positional dependency-row tuple into a `FlowChildRecord`. The
131
+ * order must stay in lockstep with the HMGET field list in the
132
+ * `listChildResults` script:
133
+ * childKey, storeKey, childJobId, name, status, exit, failedReason, cascaded.
134
+ */
135
+ const toChildRecord = (flowId, row) => ({
136
+ flowId,
137
+ childKey: row[0] ?? "",
138
+ storeKey: row[1] ?? "",
139
+ childJobId: JobStore.JobId(row[2] ?? ""),
140
+ name: row[3] ?? "",
141
+ // SAFETY: the status field is only ever written with FlowChildRecord
142
+ // status members ("pending" at insert, a report/settle outcome after).
143
+ status: (row[4] ?? "pending"),
144
+ exit: optionalJson(row[5]),
145
+ failedReason: optionalString(row[6]),
146
+ cascaded: row[7] === "1"
147
+ });
93
148
  /**
94
149
  * Build a `RedisJobStore` service. Needs the `Redis` service and a `Scope`
95
150
  * (the wake-up subscription and the optional history sweeper live in it).
@@ -122,6 +177,11 @@ export const make = (options) => Effect.gen(function* () {
122
177
  const evalEnqueueMany = redis.eval(scripts.enqueueMany);
123
178
  const evalSweepState = redis.eval(scripts.sweepState);
124
179
  const evalSweepDedupes = redis.eval(scripts.sweepDedupes);
180
+ const evalFanOut = redis.eval(scripts.fanOut);
181
+ const evalRecordChildResults = redis.eval(scripts.recordChildResults);
182
+ const evalListChildResults = redis.eval(scripts.listChildResults);
183
+ const evalFlowSweepWork = redis.eval(scripts.flowSweepWork);
184
+ const evalMarkChildrenCascaded = redis.eval(scripts.markChildrenCascaded);
125
185
  // Wake protocol: a queue-filtered waiter registry (same-process wake-ups
126
186
  // never depend on the pub/sub round trip), with the channel carrying
127
187
  // cross-process wake-ups — the message names the queue ("*" broadcasts).
@@ -196,7 +256,46 @@ export const make = (options) => Effect.gen(function* () {
196
256
  const raw = generate(request);
197
257
  return Effect.isEffect(raw) ? raw : Effect.succeed(raw);
198
258
  });
199
- const enqueueOnce = (request, idMode, id, now) => evalEnqueue(prefix, idMode, id, request.name, request.queue, JSON.stringify(request.payload ?? null), JSON.stringify(request.metadata), request.priority, request.attemptsMax, request.backoff === undefined ? "" : JSON.stringify(request.backoff), request.keep === undefined ? "" : JSON.stringify(request.keep), request.timeoutMs === undefined ? "" : String(request.timeoutMs), Math.max(0, request.delayMs), now, request.dedupe?.key ?? "", request.dedupe?.ttlMs === undefined ? "" : String(request.dedupe.ttlMs), request.dedupe?.extend === true ? "1" : "0", request.dedupe?.replace === true ? "1" : "0", request.trace === undefined ? "" : JSON.stringify(request.trace));
259
+ const enqueueOnce = (request, idMode, id, now) => evalEnqueue(prefix, idMode, id, request.name, request.queue, JSON.stringify(request.payload ?? null), JSON.stringify(request.metadata), request.priority, request.attemptsMax, request.backoff === undefined ? "" : JSON.stringify(request.backoff), request.keep === undefined ? "" : JSON.stringify(request.keep), request.timeoutMs === undefined ? "" : String(request.timeoutMs), Math.max(0, request.delayMs), now, request.dedupe?.key ?? "", request.dedupe?.ttlMs === undefined ? "" : String(request.dedupe.ttlMs), request.dedupe?.extend === true ? "1" : "0", request.dedupe?.replace === true ? "1" : "0", request.trace === undefined ? "" : JSON.stringify(request.trace), request.parent === undefined ? "" : JSON.stringify(request.parent));
260
+ // The FanOut ack. Large manifests chunk their dependency rows across
261
+ // several lock-token-guarded script calls (ARGV strides, like
262
+ // enqueueMany); only the FINAL chunk writes the manifest and flips the
263
+ // state, so a crash mid-staging leaves the job active and recoverable —
264
+ // the next attempt's first chunk clears the orphaned staged rows.
265
+ const fanOutAck = (id, token, failFast, children) => Effect.gen(function* () {
266
+ if (children.some((child) => child.request.id === undefined)) {
267
+ // Validate BEFORE any script call, so a bad spec cannot leave the
268
+ // job half-acked (rows staged, ledger written, still active).
269
+ return yield* new JobStore.JobStoreError({
270
+ message: "FanOut child specs require an explicit request.id"
271
+ });
272
+ }
273
+ const now = yield* Clock.currentTimeMillis;
274
+ const chunks = [];
275
+ for (let start = 0; start < children.length; start += 500) {
276
+ chunks.push(children.slice(start, start + 500));
277
+ }
278
+ // An empty manifest still needs the final (state-flipping) call.
279
+ if (chunks.length === 0)
280
+ chunks.push([]);
281
+ for (let i = 0; i < chunks.length; i++) {
282
+ const chunk = chunks[i];
283
+ if (chunk === undefined)
284
+ continue;
285
+ const items = [];
286
+ for (const child of chunk) {
287
+ items.push(child.childKey, child.storeKey, child.request.id ?? "", child.request.name, JSON.stringify(child.request));
288
+ }
289
+ const reply = JSON.parse(yield* evalFanOut(prefix, id, token, i === chunks.length - 1 ? "1" : "0", i === 0 ? "1" : "0", failFast ? "1" : "0", children.length, now, chunk.length, items).pipe(Effect.mapError(storeError("ack failed"))));
290
+ if (reply.error === "notfound")
291
+ return yield* new JobStore.JobNotFoundError({ jobId: id });
292
+ if (reply.error === "locklost")
293
+ return yield* new JobStore.LockLostError({ jobId: id });
294
+ if (reply.wake === true) {
295
+ yield* wakeUp(reply.queue !== undefined ? JobStore.QueueName(reply.queue) : undefined);
296
+ }
297
+ }
298
+ });
200
299
  // Shared by cancel and cancelByDedupe.
201
300
  const cancelJob = (id) => Effect.gen(function* () {
202
301
  const now = yield* Clock.currentTimeMillis;
@@ -263,7 +362,7 @@ export const make = (options) => Effect.gen(function* () {
263
362
  : generate !== undefined
264
363
  ? yield* generateCandidate(request, generate)
265
364
  : "";
266
- itemArgs.push(mode, candidate, request.name, request.queue, JSON.stringify(request.payload ?? null), JSON.stringify(request.metadata), String(request.priority), String(request.attemptsMax), request.backoff === undefined ? "" : JSON.stringify(request.backoff), request.keep === undefined ? "" : JSON.stringify(request.keep), request.timeoutMs === undefined ? "" : String(request.timeoutMs), request.trace === undefined ? "" : JSON.stringify(request.trace), String(Math.max(0, request.delayMs)));
365
+ itemArgs.push(mode, candidate, request.name, request.queue, JSON.stringify(request.payload ?? null), JSON.stringify(request.metadata), String(request.priority), String(request.attemptsMax), request.backoff === undefined ? "" : JSON.stringify(request.backoff), request.keep === undefined ? "" : JSON.stringify(request.keep), request.timeoutMs === undefined ? "" : String(request.timeoutMs), request.trace === undefined ? "" : JSON.stringify(request.trace), request.parent === undefined ? "" : JSON.stringify(request.parent), String(Math.max(0, request.delayMs)));
267
366
  }
268
367
  const replies = JSON
269
368
  .parse(yield* evalEnqueueMany(prefix, now, chunk.length, itemArgs));
@@ -370,21 +469,28 @@ export const make = (options) => Effect.gen(function* () {
370
469
  return empty;
371
470
  });
372
471
  }).pipe(Effect.mapError(storeError("claim failed"))),
373
- ack: (id, token, outcome) => Effect.gen(function* () {
374
- const now = yield* Clock.currentTimeMillis;
375
- const exitJson = outcome._tag === "Cancelled" || outcome.exit === undefined
376
- ? ""
377
- : JSON.stringify(outcome.exit);
378
- const delayMs = outcome._tag === "Retry" ? Math.max(0, outcome.delayMs) : 0;
379
- const reply = JSON.parse(yield* evalAck(prefix, id, token, outcome._tag, exitJson, delayMs, now).pipe(Effect.mapError(storeError("ack failed"))));
380
- if (reply.error === "notfound")
381
- return yield* new JobStore.JobNotFoundError({ jobId: id });
382
- if (reply.error === "locklost")
383
- return yield* new JobStore.LockLostError({ jobId: id });
384
- if (reply.wake === true) {
385
- yield* wakeUp(reply.queue !== undefined ? JobStore.QueueName(reply.queue) : undefined);
472
+ ack: (id, token, outcome) => {
473
+ if (outcome._tag === "FanOut") {
474
+ return fanOutAck(id, token, outcome.failFast, outcome.children);
386
475
  }
387
- }),
476
+ // Narrowed binding: the closure below must see the FanOut-free union.
477
+ const settled = outcome;
478
+ return Effect.gen(function* () {
479
+ const now = yield* Clock.currentTimeMillis;
480
+ const exitJson = settled._tag === "Cancelled" || settled.exit === undefined
481
+ ? ""
482
+ : JSON.stringify(settled.exit);
483
+ const delayMs = settled._tag === "Retry" ? Math.max(0, settled.delayMs) : 0;
484
+ const reply = JSON.parse(yield* evalAck(prefix, id, token, settled._tag, exitJson, delayMs, now).pipe(Effect.mapError(storeError("ack failed"))));
485
+ if (reply.error === "notfound")
486
+ return yield* new JobStore.JobNotFoundError({ jobId: id });
487
+ if (reply.error === "locklost")
488
+ return yield* new JobStore.LockLostError({ jobId: id });
489
+ if (reply.wake === true) {
490
+ yield* wakeUp(reply.queue !== undefined ? JobStore.QueueName(reply.queue) : undefined);
491
+ }
492
+ });
493
+ },
388
494
  release: (id, token) => Effect.gen(function* () {
389
495
  const now = yield* Clock.currentTimeMillis;
390
496
  const reply = JSON.parse(yield* evalRelease(prefix, id, token, now).pipe(Effect.mapError(storeError("release failed"))));
@@ -537,13 +643,108 @@ export const make = (options) => Effect.gen(function* () {
537
643
  });
538
644
  }
539
645
  const now = yield* Clock.currentTimeMillis;
540
- const fired = (yield* evalTickSchedule(prefix, key, expectedRunAt, nextRunAt, request.id, request.name, request.queue, JSON.stringify(request.payload ?? null), JSON.stringify(request.metadata), request.priority, request.attemptsMax, request.backoff === undefined ? "" : JSON.stringify(request.backoff), request.keep === undefined ? "" : JSON.stringify(request.keep), request.timeoutMs === undefined ? "" : String(request.timeoutMs), request.trace === undefined ? "" : JSON.stringify(request.trace), Math.max(0, request.delayMs), now)) === "1";
646
+ const fired = (yield* evalTickSchedule(prefix, key, expectedRunAt, nextRunAt, request.id, request.name, request.queue, JSON.stringify(request.payload ?? null), JSON.stringify(request.metadata), request.priority, request.attemptsMax, request.backoff === undefined ? "" : JSON.stringify(request.backoff), request.keep === undefined ? "" : JSON.stringify(request.keep), request.timeoutMs === undefined ? "" : String(request.timeoutMs), request.trace === undefined ? "" : JSON.stringify(request.trace), request.parent === undefined ? "" : JSON.stringify(request.parent), Math.max(0, request.delayMs), now)) === "1";
541
647
  if (fired) {
542
648
  yield* wakeUp(request.queue);
543
649
  }
544
650
  return fired;
545
651
  }).pipe(Effect.mapError((error) => error instanceof JobStore.JobStoreError ? error : storeError("tickSchedule failed")(error))),
546
- advanceSchedule: (key, expectedRunAt, nextRunAt) => evalAdvanceSchedule(prefix, key, expectedRunAt, nextRunAt).pipe(Effect.mapError(storeError("advanceSchedule failed")), Effect.asVoid)
652
+ advanceSchedule: (key, expectedRunAt, nextRunAt) => evalAdvanceSchedule(prefix, key, expectedRunAt, nextRunAt).pipe(Effect.mapError(storeError("advanceSchedule failed")), Effect.asVoid),
653
+ recordChildResults: (reports) => Effect.gen(function* () {
654
+ if (reports.length === 0) {
655
+ const none = [];
656
+ return none;
657
+ }
658
+ const now = yield* Clock.currentTimeMillis;
659
+ const all = [];
660
+ // One atomic batch per chunk of 500 (ARGV headroom); the
661
+ // contract's per-batch settle semantics then apply per chunk.
662
+ for (let start = 0; start < reports.length; start += 500) {
663
+ const chunk = reports.slice(start, start + 500);
664
+ const items = [];
665
+ for (const report of chunk) {
666
+ items.push(report.flowId, report.childKey, report.outcome, report.exit === undefined ? "" : JSON.stringify(report.exit), report.failedReason ?? "");
667
+ }
668
+ const reply = JSON.parse(yield* evalRecordChildResults(prefix, now, chunk.length, items));
669
+ for (const queue of asArray(reply.wakes)) {
670
+ // A parent settled to runnable collect: wake its queue.
671
+ yield* wakeUp(JobStore.QueueName(queue));
672
+ }
673
+ for (const result of reply.results) {
674
+ all.push(result);
675
+ }
676
+ }
677
+ return all;
678
+ }).pipe(Effect.mapError(storeError("recordChildResults failed"))),
679
+ peekOutbox: (peekOptions) => Effect.gen(function* () {
680
+ const limit = Math.floor(peekOptions.limit);
681
+ if (limit <= 0) {
682
+ const none = [];
683
+ return none;
684
+ }
685
+ // The `after` cursor compares by the id's embedded score (the seq
686
+ // prefix before the NUL), so the walk moves past the named entry
687
+ // whether or not it still exists. Unparseable input reads as unset.
688
+ let afterSeq = undefined;
689
+ if (peekOptions.after !== undefined) {
690
+ const nul = peekOptions.after.indexOf("\u0000");
691
+ const seq = nul > 0 ? Number(peekOptions.after.slice(0, nul)) : Number.NaN;
692
+ if (Number.isFinite(seq))
693
+ afterSeq = seq;
694
+ }
695
+ const raw = afterSeq === undefined
696
+ ? yield* redis.send("ZRANGE", `${prefix}:flowoutbox`, "0", String(limit - 1))
697
+ : yield* redis.send("ZRANGEBYSCORE", `${prefix}:flowoutbox`, `(${afterSeq}`, "+inf", "LIMIT", "0", String(limit));
698
+ // SAFETY: ZRANGE/ZRANGEBYSCORE always reply with arrays of bulk
699
+ // strings.
700
+ const members = raw;
701
+ return members.map(toOutboxEntry);
702
+ }).pipe(Effect.mapError(storeError("peekOutbox failed"))),
703
+ deleteOutbox: (ids) => Effect.gen(function* () {
704
+ // Chunked ZREMs keep the variadic argument count bounded; each
705
+ // chunk is idempotent, so a partial failure just redelivers.
706
+ for (let start = 0; start < ids.length; start += 500) {
707
+ yield* redis.send("ZREM", `${prefix}:flowoutbox`, ...ids.slice(start, start + 500));
708
+ }
709
+ }).pipe(Effect.mapError(storeError("deleteOutbox failed"))),
710
+ listChildResults: (flowId, listOptions) => Effect.gen(function* () {
711
+ const limit = Math.max(1, listOptions?.limit ?? 1000);
712
+ const reply = JSON
713
+ .parse(yield* evalListChildResults(prefix, flowId, listOptions?.cursor ?? "", limit));
714
+ const items = asArray(reply.items).map((row) => toChildRecord(flowId, row));
715
+ const last = items[items.length - 1];
716
+ return {
717
+ items,
718
+ cursor: reply.more && last !== undefined ? last.childKey : undefined
719
+ };
720
+ }).pipe(Effect.mapError(storeError("listChildResults failed"))),
721
+ flowSweepWork: (sweepOptions) => Effect.gen(function* () {
722
+ const now = yield* Clock.currentTimeMillis;
723
+ const limit = Math.max(1, sweepOptions.limit ?? 1000);
724
+ const reply = JSON.parse(yield* evalFlowSweepWork(prefix, sweepOptions.pendingAgeMs, limit, now));
725
+ const work = {
726
+ reconcile: asArray(reply.reconcile).map((group) => ({
727
+ flowId: JobStore.JobId(group.flowId),
728
+ children: group.children.map((child) => {
729
+ // The stored spec is the verbatim JSON this driver wrote at
730
+ // fan-out time (never routed through cjson), so it re-parses
731
+ // to the original EnqueueRequest.
732
+ const request = JSON.parse(child.spec);
733
+ return { childKey: child.childKey, storeKey: child.storeKey, request };
734
+ })
735
+ })),
736
+ cascade: asArray(reply.cascade).map((group) => ({
737
+ flowId: JobStore.JobId(group.flowId),
738
+ children: group.children.map((child) => ({
739
+ childKey: child.childKey,
740
+ storeKey: child.storeKey,
741
+ childJobId: JobStore.JobId(child.childJobId)
742
+ }))
743
+ }))
744
+ };
745
+ return work;
746
+ }).pipe(Effect.mapError(storeError("flowSweepWork failed"))),
747
+ markChildrenCascaded: (flowId, childKeys) => evalMarkChildrenCascaded(prefix, flowId, JSON.stringify(childKeys)).pipe(Effect.mapError(storeError("markChildrenCascaded failed")), Effect.asVoid)
547
748
  };
548
749
  return store;
549
750
  });