@workflow/core 5.2.3 → 5.4.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 (283) hide show
  1. package/README.md +27 -0
  2. package/dist/capabilities.d.ts +2 -0
  3. package/dist/capabilities.d.ts.map +1 -1
  4. package/dist/capabilities.js +7 -1
  5. package/dist/classify-error.d.ts.map +1 -1
  6. package/dist/classify-error.js +3 -2
  7. package/dist/create-hook.d.ts +15 -0
  8. package/dist/create-hook.d.ts.map +1 -1
  9. package/dist/create-hook.js +1 -1
  10. package/dist/events-consumer.d.ts +98 -6
  11. package/dist/events-consumer.d.ts.map +1 -1
  12. package/dist/events-consumer.js +198 -13
  13. package/dist/flushable-stream.js +11 -2
  14. package/dist/global.d.ts +6 -0
  15. package/dist/global.d.ts.map +1 -1
  16. package/dist/global.js +1 -1
  17. package/dist/logger.d.ts.map +1 -1
  18. package/dist/logger.js +65 -35
  19. package/dist/private.d.ts +41 -2
  20. package/dist/private.d.ts.map +1 -1
  21. package/dist/private.js +39 -4
  22. package/dist/replay-payload-cache.d.ts +13 -2
  23. package/dist/replay-payload-cache.d.ts.map +1 -1
  24. package/dist/replay-payload-cache.js +20 -10
  25. package/dist/runtime/after-terminal-write.d.ts +33 -0
  26. package/dist/runtime/after-terminal-write.d.ts.map +1 -0
  27. package/dist/runtime/after-terminal-write.js +23 -0
  28. package/dist/runtime/child-run-completion-notify.d.ts +36 -0
  29. package/dist/runtime/child-run-completion-notify.d.ts.map +1 -0
  30. package/dist/runtime/child-run-completion-notify.js +97 -0
  31. package/dist/runtime/child-run-completion.d.ts +45 -0
  32. package/dist/runtime/child-run-completion.d.ts.map +1 -0
  33. package/dist/runtime/child-run-completion.js +192 -0
  34. package/dist/runtime/constants.d.ts +161 -176
  35. package/dist/runtime/constants.d.ts.map +1 -1
  36. package/dist/runtime/constants.js +194 -273
  37. package/dist/runtime/delivery.d.ts +270 -0
  38. package/dist/runtime/delivery.d.ts.map +1 -0
  39. package/dist/runtime/delivery.js +325 -0
  40. package/dist/runtime/deployment-guard.d.ts +8 -1
  41. package/dist/runtime/deployment-guard.d.ts.map +1 -1
  42. package/dist/runtime/deployment-guard.js +12 -6
  43. package/dist/runtime/get-port-lazy.d.ts.map +1 -1
  44. package/dist/runtime/get-port-lazy.js +77 -14
  45. package/dist/runtime/helpers.d.ts +50 -4
  46. package/dist/runtime/helpers.d.ts.map +1 -1
  47. package/dist/runtime/helpers.js +88 -10
  48. package/dist/runtime/hook-creation.d.ts +45 -0
  49. package/dist/runtime/hook-creation.d.ts.map +1 -0
  50. package/dist/runtime/hook-creation.js +98 -0
  51. package/dist/runtime/hook-wake.d.ts +16 -14
  52. package/dist/runtime/hook-wake.d.ts.map +1 -1
  53. package/dist/runtime/hook-wake.js +31 -18
  54. package/dist/runtime/invocations.d.ts.map +1 -1
  55. package/dist/runtime/invocations.js +9 -3
  56. package/dist/runtime/out-of-band-observation.d.ts +28 -17
  57. package/dist/runtime/out-of-band-observation.d.ts.map +1 -1
  58. package/dist/runtime/out-of-band-observation.js +12 -3
  59. package/dist/runtime/quickjs-delivery-shared.d.ts +126 -0
  60. package/dist/runtime/quickjs-delivery-shared.d.ts.map +1 -0
  61. package/dist/runtime/quickjs-delivery-shared.js +176 -0
  62. package/dist/runtime/quickjs-log-view.d.ts +17 -0
  63. package/dist/runtime/quickjs-log-view.d.ts.map +1 -1
  64. package/dist/runtime/quickjs-log-view.js +31 -1
  65. package/dist/runtime/quickjs-pending-ops.d.ts +181 -0
  66. package/dist/runtime/quickjs-pending-ops.d.ts.map +1 -0
  67. package/dist/runtime/quickjs-pending-ops.js +633 -0
  68. package/dist/runtime/quickjs-runtime.d.ts +30 -5
  69. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  70. package/dist/runtime/quickjs-runtime.js +546 -169
  71. package/dist/runtime/quickjs-serde.d.ts.map +1 -1
  72. package/dist/runtime/quickjs-serde.js +96 -5
  73. package/dist/runtime/replay-budget.d.ts +8 -1
  74. package/dist/runtime/replay-budget.d.ts.map +1 -1
  75. package/dist/runtime/replay-budget.js +12 -8
  76. package/dist/runtime/resume-hook.d.ts +15 -10
  77. package/dist/runtime/resume-hook.d.ts.map +1 -1
  78. package/dist/runtime/resume-hook.js +211 -65
  79. package/dist/runtime/run-spec-routing.d.ts +52 -0
  80. package/dist/runtime/run-spec-routing.d.ts.map +1 -0
  81. package/dist/runtime/run-spec-routing.js +78 -0
  82. package/dist/runtime/run-spec-version.d.ts +8 -4
  83. package/dist/runtime/run-spec-version.d.ts.map +1 -1
  84. package/dist/runtime/run-spec-version.js +11 -7
  85. package/dist/runtime/run.d.ts +29 -3
  86. package/dist/runtime/run.d.ts.map +1 -1
  87. package/dist/runtime/run.js +116 -11
  88. package/dist/runtime/runs.d.ts +58 -2
  89. package/dist/runtime/runs.d.ts.map +1 -1
  90. package/dist/runtime/runs.js +228 -30
  91. package/dist/runtime/spec8/constants.d.ts +177 -0
  92. package/dist/runtime/spec8/constants.d.ts.map +1 -0
  93. package/dist/runtime/spec8/constants.js +232 -0
  94. package/dist/runtime/spec8/count-step-started-events.d.ts.map +1 -0
  95. package/dist/runtime/spec8/count-step-started-events.js +72 -0
  96. package/dist/runtime/spec8/delivery.d.ts +6 -0
  97. package/dist/runtime/spec8/delivery.d.ts.map +1 -0
  98. package/dist/runtime/spec8/delivery.js +4250 -0
  99. package/dist/runtime/spec8/inline-steps-in-flight.d.ts +58 -0
  100. package/dist/runtime/spec8/inline-steps-in-flight.d.ts.map +1 -0
  101. package/dist/runtime/spec8/inline-steps-in-flight.js +104 -0
  102. package/dist/runtime/spec8/open-hook-wait-state.d.ts.map +1 -0
  103. package/dist/runtime/spec8/open-hook-wait-state.js +93 -0
  104. package/dist/runtime/{quickjs-entrypoint.d.ts → spec8/quickjs-entrypoint.d.ts} +0 -20
  105. package/dist/runtime/spec8/quickjs-entrypoint.d.ts.map +1 -0
  106. package/dist/runtime/spec8/quickjs-entrypoint.js +1779 -0
  107. package/dist/runtime/{step-executor.d.ts → spec8/step-executor.d.ts} +11 -7
  108. package/dist/runtime/spec8/step-executor.d.ts.map +1 -0
  109. package/dist/runtime/spec8/step-executor.js +1134 -0
  110. package/dist/runtime/{step-ownership.d.ts → spec8/step-ownership.d.ts} +1 -1
  111. package/dist/runtime/spec8/step-ownership.d.ts.map +1 -0
  112. package/dist/runtime/spec8/step-ownership.js +114 -0
  113. package/dist/runtime/spec8/step-single-flight.d.ts +34 -0
  114. package/dist/runtime/spec8/step-single-flight.d.ts.map +1 -0
  115. package/dist/runtime/spec8/step-single-flight.js +36 -0
  116. package/dist/runtime/{suspension-handler.d.ts → spec8/suspension-handler.d.ts} +68 -24
  117. package/dist/runtime/spec8/suspension-handler.d.ts.map +1 -0
  118. package/dist/runtime/spec8/suspension-handler.js +1291 -0
  119. package/dist/runtime/spec9/consume-after-commit.d.ts +33 -0
  120. package/dist/runtime/spec9/consume-after-commit.d.ts.map +1 -0
  121. package/dist/runtime/spec9/consume-after-commit.js +13 -0
  122. package/dist/runtime/spec9/consumed-position.d.ts +38 -0
  123. package/dist/runtime/spec9/consumed-position.d.ts.map +1 -0
  124. package/dist/runtime/spec9/consumed-position.js +48 -0
  125. package/dist/runtime/spec9/creator-rules.d.ts +220 -0
  126. package/dist/runtime/spec9/creator-rules.d.ts.map +1 -0
  127. package/dist/runtime/spec9/creator-rules.js +357 -0
  128. package/dist/runtime/spec9/deadline.d.ts +18 -0
  129. package/dist/runtime/spec9/deadline.d.ts.map +1 -0
  130. package/dist/runtime/spec9/deadline.js +27 -0
  131. package/dist/runtime/spec9/delivery.d.ts +17 -0
  132. package/dist/runtime/spec9/delivery.d.ts.map +1 -0
  133. package/dist/runtime/spec9/delivery.js +3837 -0
  134. package/dist/runtime/spec9/fence-refusals.d.ts +20 -0
  135. package/dist/runtime/spec9/fence-refusals.d.ts.map +1 -0
  136. package/dist/runtime/spec9/fence-refusals.js +55 -0
  137. package/dist/runtime/spec9/in-band-writer.d.ts +275 -0
  138. package/dist/runtime/spec9/in-band-writer.d.ts.map +1 -0
  139. package/dist/runtime/spec9/in-band-writer.js +831 -0
  140. package/dist/runtime/spec9/live-feed.d.ts +151 -0
  141. package/dist/runtime/spec9/live-feed.d.ts.map +1 -0
  142. package/dist/runtime/spec9/live-feed.js +311 -0
  143. package/dist/runtime/spec9/log-state.d.ts +137 -0
  144. package/dist/runtime/spec9/log-state.d.ts.map +1 -0
  145. package/dist/runtime/spec9/log-state.js +176 -0
  146. package/dist/runtime/spec9/quickjs-entrypoint.d.ts +185 -0
  147. package/dist/runtime/spec9/quickjs-entrypoint.d.ts.map +1 -0
  148. package/dist/runtime/spec9/quickjs-entrypoint.js +2332 -0
  149. package/dist/runtime/spec9/read-deadline.d.ts +46 -0
  150. package/dist/runtime/spec9/read-deadline.d.ts.map +1 -0
  151. package/dist/runtime/spec9/read-deadline.js +88 -0
  152. package/dist/runtime/spec9/run-ahead.d.ts +65 -0
  153. package/dist/runtime/spec9/run-ahead.d.ts.map +1 -0
  154. package/dist/runtime/spec9/run-ahead.js +102 -0
  155. package/dist/runtime/spec9/step-delivery.d.ts +111 -0
  156. package/dist/runtime/spec9/step-delivery.d.ts.map +1 -0
  157. package/dist/runtime/spec9/step-delivery.js +149 -0
  158. package/dist/runtime/spec9/step-executor.d.ts +217 -0
  159. package/dist/runtime/spec9/step-executor.d.ts.map +1 -0
  160. package/dist/runtime/spec9/step-executor.js +782 -0
  161. package/dist/runtime/spec9/step-handler.d.ts +92 -0
  162. package/dist/runtime/spec9/step-handler.d.ts.map +1 -0
  163. package/dist/runtime/spec9/step-handler.js +375 -0
  164. package/dist/runtime/spec9/step-message.d.ts +42 -0
  165. package/dist/runtime/spec9/step-message.d.ts.map +1 -0
  166. package/dist/runtime/spec9/step-message.js +81 -0
  167. package/dist/runtime/spec9/step-retention.d.ts +44 -0
  168. package/dist/runtime/spec9/step-retention.d.ts.map +1 -0
  169. package/dist/runtime/spec9/step-retention.js +51 -0
  170. package/dist/runtime/spec9/step-single-flight.d.ts +19 -0
  171. package/dist/runtime/spec9/step-single-flight.d.ts.map +1 -0
  172. package/dist/runtime/spec9/step-single-flight.js +24 -0
  173. package/dist/runtime/spec9/step-wait-creation.d.ts +162 -0
  174. package/dist/runtime/spec9/step-wait-creation.d.ts.map +1 -0
  175. package/dist/runtime/spec9/step-wait-creation.js +450 -0
  176. package/dist/runtime/spec9/suspension-handler.d.ts +125 -0
  177. package/dist/runtime/spec9/suspension-handler.d.ts.map +1 -0
  178. package/dist/runtime/spec9/suspension-handler.js +327 -0
  179. package/dist/runtime/spec9/wait-timer.d.ts +143 -0
  180. package/dist/runtime/spec9/wait-timer.d.ts.map +1 -0
  181. package/dist/runtime/spec9/wait-timer.js +173 -0
  182. package/dist/runtime/start-hook-binding.d.ts +50 -0
  183. package/dist/runtime/start-hook-binding.d.ts.map +1 -0
  184. package/dist/runtime/start-hook-binding.js +85 -0
  185. package/dist/runtime/start-hook-delivery.d.ts +47 -0
  186. package/dist/runtime/start-hook-delivery.d.ts.map +1 -0
  187. package/dist/runtime/start-hook-delivery.js +94 -0
  188. package/dist/runtime/start-hook-holder.d.ts +50 -0
  189. package/dist/runtime/start-hook-holder.d.ts.map +1 -0
  190. package/dist/runtime/start-hook-holder.js +149 -0
  191. package/dist/runtime/start.d.ts +76 -4
  192. package/dist/runtime/start.d.ts.map +1 -1
  193. package/dist/runtime/start.js +451 -62
  194. package/dist/runtime/step-latency.d.ts +3 -3
  195. package/dist/runtime/step-latency.js +1 -1
  196. package/dist/runtime/step-single-flight.d.ts +4 -8
  197. package/dist/runtime/step-single-flight.d.ts.map +1 -1
  198. package/dist/runtime/step-single-flight.js +23 -36
  199. package/dist/runtime/step-streams.d.ts +6 -0
  200. package/dist/runtime/step-streams.d.ts.map +1 -0
  201. package/dist/runtime/step-streams.js +40 -0
  202. package/dist/runtime/suspension-hooks.d.ts +84 -0
  203. package/dist/runtime/suspension-hooks.d.ts.map +1 -0
  204. package/dist/runtime/suspension-hooks.js +310 -0
  205. package/dist/runtime/wait-continuation.d.ts +27 -0
  206. package/dist/runtime/wait-continuation.d.ts.map +1 -1
  207. package/dist/runtime/wait-continuation.js +27 -2
  208. package/dist/runtime/world-compatibility.d.ts +22 -3
  209. package/dist/runtime/world-compatibility.d.ts.map +1 -1
  210. package/dist/runtime/world-compatibility.js +37 -2
  211. package/dist/runtime/world.d.ts.map +1 -1
  212. package/dist/runtime/world.js +2 -1
  213. package/dist/runtime.d.ts +2 -2
  214. package/dist/runtime.d.ts.map +1 -1
  215. package/dist/runtime.js +118 -4154
  216. package/dist/serialization/abort-stream.d.ts +11 -0
  217. package/dist/serialization/abort-stream.d.ts.map +1 -0
  218. package/dist/serialization/abort-stream.js +86 -0
  219. package/dist/serialization/reducers/common-vm.d.ts.map +1 -1
  220. package/dist/serialization/reducers/common-vm.js +39 -2
  221. package/dist/serialization/reducers/common.d.ts.map +1 -1
  222. package/dist/serialization/reducers/common.js +26 -3
  223. package/dist/serialization/types.d.ts +10 -1
  224. package/dist/serialization/types.d.ts.map +1 -1
  225. package/dist/serialization/types.js +1 -1
  226. package/dist/serialization.d.ts +21 -5
  227. package/dist/serialization.d.ts.map +1 -1
  228. package/dist/serialization.js +136 -79
  229. package/dist/set-attributes.d.ts.map +1 -1
  230. package/dist/set-attributes.js +9 -14
  231. package/dist/step/context-storage.d.ts +2 -0
  232. package/dist/step/context-storage.d.ts.map +1 -1
  233. package/dist/step/context-storage.js +1 -1
  234. package/dist/step.d.ts.map +1 -1
  235. package/dist/step.js +23 -16
  236. package/dist/telemetry/semantic-conventions.d.ts +218 -3
  237. package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
  238. package/dist/telemetry/semantic-conventions.js +161 -2
  239. package/dist/test-support/append-only-world.d.ts +437 -0
  240. package/dist/test-support/append-only-world.d.ts.map +1 -0
  241. package/dist/test-support/append-only-world.js +816 -0
  242. package/dist/test-support/fence-snapshot.d.ts +11 -0
  243. package/dist/test-support/fence-snapshot.d.ts.map +1 -0
  244. package/dist/test-support/fence-snapshot.js +12 -0
  245. package/dist/test-support/load-events.d.ts +8 -0
  246. package/dist/test-support/load-events.d.ts.map +1 -0
  247. package/dist/test-support/load-events.js +27 -0
  248. package/dist/test-support/orchestrator-harness.d.ts +502 -0
  249. package/dist/test-support/orchestrator-harness.d.ts.map +1 -0
  250. package/dist/test-support/orchestrator-harness.js +116 -0
  251. package/dist/version.d.ts +1 -1
  252. package/dist/version.js +2 -2
  253. package/dist/workflow/abort-controller.d.ts.map +1 -1
  254. package/dist/workflow/abort-controller.js +7 -5
  255. package/dist/workflow/hook.d.ts +5 -0
  256. package/dist/workflow/hook.d.ts.map +1 -1
  257. package/dist/workflow/hook.js +83 -19
  258. package/dist/workflow.d.ts +45 -16
  259. package/dist/workflow.d.ts.map +1 -1
  260. package/dist/workflow.js +111 -50
  261. package/docs/api-reference/create-hook.mdx +8 -0
  262. package/docs/api-reference/create-webhook.mdx +1 -1
  263. package/docs/api-reference/fetch.mdx +2 -0
  264. package/docs/foundations/errors-and-retries.mdx +6 -0
  265. package/docs/foundations/hooks.mdx +3 -1
  266. package/docs/foundations/idempotency.mdx +190 -60
  267. package/docs/foundations/starting-workflows.mdx +3 -7
  268. package/docs/how-it-works/event-sourcing.mdx +6 -0
  269. package/package.json +5 -5
  270. package/dist/runtime/count-step-started-events.d.ts.map +0 -1
  271. package/dist/runtime/count-step-started-events.js +0 -72
  272. package/dist/runtime/open-hook-wait-state.d.ts.map +0 -1
  273. package/dist/runtime/open-hook-wait-state.js +0 -93
  274. package/dist/runtime/quickjs-entrypoint.d.ts.map +0 -1
  275. package/dist/runtime/quickjs-entrypoint.js +0 -2314
  276. package/dist/runtime/step-executor.d.ts.map +0 -1
  277. package/dist/runtime/step-executor.js +0 -1156
  278. package/dist/runtime/step-ownership.d.ts.map +0 -1
  279. package/dist/runtime/step-ownership.js +0 -114
  280. package/dist/runtime/suspension-handler.d.ts.map +0 -1
  281. package/dist/runtime/suspension-handler.js +0 -1562
  282. /package/dist/runtime/{count-step-started-events.d.ts → spec8/count-step-started-events.d.ts} +0 -0
  283. /package/dist/runtime/{open-hook-wait-state.d.ts → spec8/open-hook-wait-state.d.ts} +0 -0
@@ -0,0 +1,20 @@
1
+ /** Consecutive refusals of one run after which a refusal is logged at warn. */
2
+ export declare const REPEATED_FENCE_REFUSAL_WARN_THRESHOLD = 3;
3
+ /** Records one refusal of `runId`'s delivery; returns the run's streak. */
4
+ export declare function noteFenceRefusal(runId: string): number;
5
+ /** Ends `runId`'s streak: one of its deliveries finished without a refusal. */
6
+ export declare function clearFenceRefusals(runId: string): void;
7
+ /**
8
+ * Whether a streak of `count` refusals is logged at warn: at the threshold,
9
+ * then at every power of two above it, so a long loop logs O(log n) lines.
10
+ */
11
+ export declare function warnsOnFenceRefusal(count: number): boolean;
12
+ /**
13
+ * The delay of the redelivery a fence-refused orchestrator delivery asks for
14
+ * (`{ timeoutSeconds }`) instead of acknowledging its message: long enough
15
+ * for a second delivery of the message that is still running to commit or
16
+ * fail, short enough that a refusal no other delivery explains costs about
17
+ * a second.
18
+ */
19
+ export declare const FENCE_REFUSAL_REDELIVERY_SECONDS = 1;
20
+ //# sourceMappingURL=fence-refusals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fence-refusals.d.ts","sourceRoot":"","sources":["../../../src/runtime/spec9/fence-refusals.ts"],"names":[],"mappings":"AAkBA,+EAA+E;AAC/E,eAAO,MAAM,qCAAqC,IAAI,CAAC;AAIvD,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAStD;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM1D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,IAAI,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Consecutive in-band fence refusals per run in this process, so that a run
3
+ * whose every pass is refused is reported at warn level instead of only at
4
+ * info on each pass.
5
+ *
6
+ * One refusal is expected (an overlap the queue let through, or the World
7
+ * sealing a slow writer's own position). Many in a row point at a World-side
8
+ * fault or a pathological write latency: each pass asks for a redelivery of
9
+ * its message, and nothing else surfaces the loop until the delivery cap
10
+ * fails the run (on a World that counts such a redelivery as an attempt).
11
+ * Bounded: the oldest run is
12
+ * forgotten past {@link MAX_TRACKED_RUNS}.
13
+ */
14
+ // per-copy-ok: a diagnostic streak of one run's deliveries, which run in the
15
+ // copy of the orchestrator module that handles the run's queue route. A
16
+ // streak split across copies only delays the warning.
17
+ const refusals = new Map();
18
+ /** Consecutive refusals of one run after which a refusal is logged at warn. */
19
+ export const REPEATED_FENCE_REFUSAL_WARN_THRESHOLD = 3;
20
+ const MAX_TRACKED_RUNS = 1_000;
21
+ /** Records one refusal of `runId`'s delivery; returns the run's streak. */
22
+ export function noteFenceRefusal(runId) {
23
+ const count = (refusals.get(runId) ?? 0) + 1;
24
+ refusals.delete(runId);
25
+ refusals.set(runId, count);
26
+ if (refusals.size > MAX_TRACKED_RUNS) {
27
+ const oldest = refusals.keys().next().value;
28
+ if (oldest !== undefined)
29
+ refusals.delete(oldest);
30
+ }
31
+ return count;
32
+ }
33
+ /** Ends `runId`'s streak: one of its deliveries finished without a refusal. */
34
+ export function clearFenceRefusals(runId) {
35
+ refusals.delete(runId);
36
+ }
37
+ /**
38
+ * Whether a streak of `count` refusals is logged at warn: at the threshold,
39
+ * then at every power of two above it, so a long loop logs O(log n) lines.
40
+ */
41
+ export function warnsOnFenceRefusal(count) {
42
+ if (count < REPEATED_FENCE_REFUSAL_WARN_THRESHOLD)
43
+ return false;
44
+ return (count === REPEATED_FENCE_REFUSAL_WARN_THRESHOLD ||
45
+ (count & (count - 1)) === 0);
46
+ }
47
+ /**
48
+ * The delay of the redelivery a fence-refused orchestrator delivery asks for
49
+ * (`{ timeoutSeconds }`) instead of acknowledging its message: long enough
50
+ * for a second delivery of the message that is still running to commit or
51
+ * fail, short enough that a refusal no other delivery explains costs about
52
+ * a second.
53
+ */
54
+ export const FENCE_REFUSAL_REDELIVERY_SECONDS = 1;
55
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVuY2UtcmVmdXNhbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcnVudGltZS9zcGVjOS9mZW5jZS1yZWZ1c2Fscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7O0dBWUc7QUFDSCw2RUFBNkU7QUFDN0Usd0VBQXdFO0FBQ3hFLHNEQUFzRDtBQUN0RCxNQUFNLFFBQVEsR0FBRyxJQUFJLEdBQUcsRUFBa0IsQ0FBQztBQUUzQywrRUFBK0U7QUFDL0UsTUFBTSxDQUFDLE1BQU0scUNBQXFDLEdBQUcsQ0FBQyxDQUFDO0FBRXZELE1BQU0sZ0JBQWdCLEdBQUcsS0FBSyxDQUFDO0FBRS9CLDJFQUEyRTtBQUMzRSxNQUFNLFVBQVUsZ0JBQWdCLENBQUMsS0FBYTtJQUM1QyxNQUFNLEtBQUssR0FBRyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0lBQzdDLFFBQVEsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDdkIsUUFBUSxDQUFDLEdBQUcsQ0FBQyxLQUFLLEVBQUUsS0FBSyxDQUFDLENBQUM7SUFDM0IsSUFBSSxRQUFRLENBQUMsSUFBSSxHQUFHLGdCQUFnQixFQUFFLENBQUM7UUFDckMsTUFBTSxNQUFNLEdBQUcsUUFBUSxDQUFDLElBQUksRUFBRSxDQUFDLElBQUksRUFBRSxDQUFDLEtBQUssQ0FBQztRQUM1QyxJQUFJLE1BQU0sS0FBSyxTQ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gUkVQRUFURURfRkVOQ0VfUkVGVVNBTF9XQVJOX1RIUkVTSE9MRCkgcmV0dXJuIGZhbHNlO1xuICByZXR1cm4gKFxuICAgIGNvdW50ID09PSBSRVBFQVRFRF9GRU5DRV9SRUZVU0FMX1dBUk5fVEhSRVNIT0xEIHx8XG4gICAgKGNvdW50ICYgKGNvdW50IC0gMSkpID09PSAwXG4gICk7XG59XG5cbi8qKlxuICogVGhlIGRlbGF5IG9mIHRoZSByZWRlbGl2ZXJ5IGEgZmVuY2UtcmVmdXNlZCBvcmNoZXN0cmF0b3IgZGVsaXZlcnkgYXNrcyBmb3JcbiAqIChgeyB0aW1lb3V0U2Vjb25kcyB9YCkgaW5zdGVhZCBvZiBhY2tub3dsZWRnaW5nIGl0cyBtZXNzYWdlOiBsb25nIGVub3VnaFxuICogZm9yIGEgc2Vjb25kIGRlbGl2ZXJ5IG9mIHRoZSBtZXNzYWdlIHRoYXQgaXMgc3RpbGwgcnVubmluZyB0byBjb21taXQgb3JcbiAqIGZhaWwsIHNob3J0IGVub3VnaCB0aGF0IGEgcmVmdXNhbCBubyBvdGhlciBkZWxpdmVyeSBleHBsYWlucyBjb3N0cyBhYm91dFxuICogYSBzZWNvbmQuXG4gKi9cbmV4cG9ydCBjb25zdCBGRU5DRV9SRUZVU0FMX1JFREVMSVZFUllfU0VDT05EUyA9IDE7XG4iXX0=
@@ -0,0 +1,275 @@
1
+ import type { BatchEventRequest, CreateEventBatchParams, CreateEventParams, CreateEventRequest, Event, EventBatchResult, EventLogSnapshot, EventResult, World } from '@workflow/world';
2
+ /**
3
+ * Thrown by an {@link InBandWriter} once the World has refused one of its
4
+ * writes as superseded, for that write and for every write after it. The
5
+ * orchestrator delivery that sees it stops writing and stops starting inline
6
+ * step bodies, sends the queue messages its own committed writes still owe
7
+ * (see {@link InBandWriter.onAccepted}), and asks for a redelivery of its own
8
+ * message (`{ timeoutSeconds: 1 }`) instead of acknowledging it. The
9
+ * redelivery is counted as an attempt.
10
+ *
11
+ * The refusal does not say that another writer is running. The World
12
+ * refuses a write whose expected count is stale, which happens when another
13
+ * orchestrator wrote in-band, when the World sealed this writer's own
14
+ * position because its write outlived the World's staleness bound, or when
15
+ * an earlier write of this writer was refused after the World had allocated
16
+ * its position. The redelivery covers the cases with no other writer, and
17
+ * re-sends whatever a delivery that died left unsent.
18
+ */
19
+ export declare class OrchestratorSupersededError extends Error {
20
+ readonly cause: unknown;
21
+ constructor(cause: unknown);
22
+ static is(value: unknown): value is OrchestratorSupersededError;
23
+ }
24
+ /**
25
+ * The fence snapshot a full log load hands the {@link InBandWriter}.
26
+ *
27
+ * Every page of a single-orchestrator run's log carries one
28
+ * (`EventListResponse.snapshot`). The one case without it is a resilient
29
+ * start: `run_created` never landed, so there is no run and the load is empty.
30
+ * The delivery's first in-band write, `run_started` carrying the creation
31
+ * data, follows the creation the World performs for it, which holds the run's
32
+ * first in-band position, so the count is 1.
33
+ *
34
+ * A non-empty log without a snapshot means the World broke the contract, and
35
+ * this throws a World contract error, which fails the run instead of writing
36
+ * without the fence.
37
+ */
38
+ export declare function requireLoadSnapshot(runId: string, loaded: {
39
+ events: readonly unknown[];
40
+ snapshot?: EventLogSnapshot;
41
+ }): EventLogSnapshot;
42
+ /** {@link requireLoadSnapshot}'s answer for a run that does not exist yet. */
43
+ export declare const RESILIENT_START_SNAPSHOT: EventLogSnapshot;
44
+ /**
45
+ * Writes the orchestrator's in-band events and keeps its count of in-band
46
+ * positions.
47
+ *
48
+ * - The count starts from the first page's `snapshot.seqInBand` of the
49
+ * delivery's full log load ({@link adoptSnapshot}), never from counting
50
+ * events: a count cannot say which positions were in-band.
51
+ * - It advances by the number of positions each accepted write allocated,
52
+ * as the World reports it (`allocated`). A World that does not report it
53
+ * is assumed to allocate 1 per create and the whole block per batch,
54
+ * except for an event answered at a slot this writer already knew: that
55
+ * is an idempotent replay, which allocated nothing.
56
+ * - Writes are serialized. Two concurrent in-band writes would both carry the
57
+ * same expected count and the second would be refused, so a fan-out goes
58
+ * through {@link createBatch} or waits its turn.
59
+ * - Run-ahead writes ({@link createAhead}, {@link createBatchAhead}) that queue
60
+ * up behind a write in flight coalesce: when their turn comes they go out
61
+ * together as one batch, in the order they were made, with one fence check,
62
+ * so a pipeline of speculative steps costs one round trip per turn rather
63
+ * than one per write. Any other write closes the group, so it never
64
+ * reorders writes. Each write's result is its slice of the batch, checked
65
+ * in order; a refusal or a failed check stops the writer for every write
66
+ * behind it, as it does for a required write. A batch on a spec >= 9 run is
67
+ * not atomic, but every World orders it per entity (see `Storage.events`):
68
+ * it refuses a step's outcome behind its refused creation itself, so a
69
+ * group may carry several writes for one step. A group stays within
70
+ * {@link MAX_BATCH_EVENTS} events and, counted as a creation batch is,
71
+ * {@link MAX_IN_BAND_CREATION_BATCH_BYTES} bytes: a World refuses an
72
+ * oversized batch whole.
73
+ * - The first refusal stops the writer for good: every later write throws
74
+ * {@link OrchestratorSupersededError} without reaching the World. The value
75
+ * the error carries is never adopted.
76
+ * - A write that fails without a definite answer (a transport error, a 5xx)
77
+ * may or may not have allocated positions, so the count is no longer
78
+ * known. The writer stops in the same way and the error propagates, so the
79
+ * delivery is retried and loads the log afresh. A definite refusal (any
80
+ * other 4xx) leaves the count as it was.
81
+ * - In-band writes on a spec >= 9 run all go through one writer per delivery.
82
+ * A write made outside it would move the World's count without this one
83
+ * knowing, and the next write here would be refused.
84
+ *
85
+ * The runtime drives a spec 9 run only on a World that implements the fence
86
+ * (`WorldCapabilities.inBandFence`), so the writer always sends an expected
87
+ * count. A write before any snapshot was
88
+ * adopted is a runtime bug, and fails without reaching the World.
89
+ */
90
+ export declare class InBandWriter {
91
+ private readonly world;
92
+ private readonly runId;
93
+ private expected;
94
+ /**
95
+ * Highest slot this writer knows is allocated: the load snapshot's `seq`,
96
+ * raised by the slots of its own accepted writes. Used to tell a write
97
+ * that allocated nothing (an idempotent replay answered with the existing
98
+ * event) from one that allocated, and as the fallback `eventCount`.
99
+ */
100
+ private knownMaxSlot;
101
+ /** `snapshot.seq` of the last full load: an understated position. */
102
+ private loadedSlot;
103
+ /**
104
+ * Every event at or below this slot has reached this writer: through a
105
+ * full load, or the complete skipped-slot report of an accepted write
106
+ * (see {@link sendPosition}).
107
+ */
108
+ private completeThrough;
109
+ private stoppedBy;
110
+ private stopped;
111
+ /**
112
+ * Set by {@link stopDecisions}: the error every write it does not allow
113
+ * fails with, and the test of what it still allows.
114
+ */
115
+ private decisionsStop;
116
+ /**
117
+ * Run-ahead writes waiting for their turn, sent together as one batch when
118
+ * it comes. Closed (unset) once the turn starts or another write queues.
119
+ */
120
+ private openGroup;
121
+ private tail;
122
+ /**
123
+ * Called with every event a write of this writer committed, in commit
124
+ * order, before the write's own checks run: a run-ahead write that fails
125
+ * its check, or a batch whose later items were refused, still committed
126
+ * these. The delivery keeps from them what it owes the queue (a
127
+ * background step's message, a wait's timer) until it sends it.
128
+ */
129
+ onAccepted: ((event: Event) => void) | undefined;
130
+ /** Throws for a World that does not declare the fence. */
131
+ constructor(world: Pick<World, 'events' | 'capabilities'>, runId: string);
132
+ private accepted;
133
+ /**
134
+ * Take the snapshot of a full load (see {@link requireLoadSnapshot}). Later
135
+ * full loads replace it.
136
+ */
137
+ adoptSnapshot(snapshot: EventLogSnapshot): void;
138
+ /** Whether a snapshot was adopted, so the writer has a count to send. */
139
+ get hasSnapshot(): boolean;
140
+ /** Whether a refusal or an unknown allocation stopped this writer. */
141
+ get isStopped(): boolean;
142
+ /**
143
+ * Stops the writer for every write `mayStillWrite` does not allow, and keeps
144
+ * sending the ones it does, in order. Used when the run's path may have
145
+ * changed under decisions this delivery made ahead of their writes: those
146
+ * decisions must not reach the World, while the outcome of a step whose
147
+ * body already ran is a fact about that body and still can. Every refused
148
+ * write, and {@link assertActive}, throws `error`. A later {@link halt} or
149
+ * failed write still stops the writer for good.
150
+ */
151
+ stopDecisions(error: unknown, mayStillWrite: (events: readonly CreateEventRequest[]) => boolean): void;
152
+ /** Throws when the writer may not send these events. */
153
+ private assertMayWrite;
154
+ /** Whether the stop came from a fence refusal. */
155
+ get isSuperseded(): boolean;
156
+ /** Whether the World can take a batch write. */
157
+ get supportsBatch(): boolean;
158
+ /** The current expected count, for diagnostics and tests. */
159
+ get expectedSeqInBand(): number | undefined;
160
+ /**
161
+ * Throws when the writer has stopped; call before starting an inline body.
162
+ * See the comment inside for which error.
163
+ */
164
+ assertActive(): void;
165
+ create<T extends CreateEventRequest>(data: T, params?: CreateEventParams): Promise<EventResult<T['eventType']>>;
166
+ /**
167
+ * A write every later write of this delivery depends on: turbo mode's
168
+ * backgrounded `run_started`. Writes queue behind it like any other, but
169
+ * any failure stops the writer, a definite refusal included, so nothing
170
+ * this delivery writes afterwards reaches the World, and
171
+ * {@link assertActive} refuses to start further inline bodies. The later
172
+ * writes and {@link assertActive} throw this write's error.
173
+ */
174
+ createRequired<T extends CreateEventRequest>(data: T, params?: CreateEventParams,
175
+ /**
176
+ * Checks the accepted write before any later write is sent. A throw
177
+ * stops the writer with the thrown error, as a failed write would. Used
178
+ * by run-ahead to confirm that a speculative write landed where the
179
+ * workflow already consumed it.
180
+ */
181
+ verify?: (result: EventResult<T['eventType']>) => void): Promise<EventResult<T['eventType']>>;
182
+ /**
183
+ * The slot the next write would take if no other writer appends first:
184
+ * one past every position this writer knows is allocated, including the
185
+ * writes still queued in it. Run-ahead places a speculative event there.
186
+ */
187
+ predictNextSlot(): number;
188
+ /** A position another writer took, seen in a load, a report or the feed. */
189
+ observeSlot(slot: number): void;
190
+ /**
191
+ * Stops the writer for good with `error`, as a failed write would: every
192
+ * later write and {@link assertActive} throw it.
193
+ */
194
+ halt(error: unknown): void;
195
+ /** The error that stopped the writer, if it stopped. */
196
+ get stopCause(): unknown;
197
+ /**
198
+ * Runs `read` in the writer's queue: after every write queued before it has
199
+ * settled (its position counted or refused), and before any write queued
200
+ * after it is sent. A full load reads the run's in-band count and adopts it
201
+ * ({@link adoptSnapshot}) inside one, so no write commits between the read
202
+ * and the adoption and is then counted twice, or not at all. Waiting for
203
+ * {@link idle} first is not enough: a write queued while the read is in
204
+ * flight would be sent beside it.
205
+ */
206
+ exclusive<T>(read: () => Promise<T>): Promise<T>;
207
+ /** Resolves once every write queued so far has settled. */
208
+ idle(): Promise<void>;
209
+ private write;
210
+ private sendSingle;
211
+ createBatch(events: BatchEventRequest[], params?: Omit<CreateEventBatchParams, 'inBand' | 'expectedSeqInBand'>): Promise<EventBatchResult>;
212
+ /**
213
+ * {@link createBatch} as a required write (see {@link createRequired}):
214
+ * any failure stops the writer, and `verify` checks the result before any
215
+ * later write is sent.
216
+ */
217
+ createBatchRequired(events: BatchEventRequest[], params: Omit<CreateEventBatchParams, 'inBand' | 'expectedSeqInBand'>, verify: (result: EventBatchResult) => void): Promise<EventBatchResult>;
218
+ /**
219
+ * A run-ahead write: a required write (see {@link createRequired}) that may
220
+ * coalesce with the run-ahead writes queued next to it. `verify` checks the
221
+ * accepted write before any later write is sent.
222
+ */
223
+ createAhead(data: CreateEventRequest, params: CreateEventParams, verify: (result: EventResult) => void): Promise<EventResult>;
224
+ /**
225
+ * A run-ahead batch: {@link createBatchRequired} that may coalesce with the
226
+ * run-ahead writes queued next to it.
227
+ */
228
+ createBatchAhead(events: BatchEventRequest[], params: Omit<CreateEventBatchParams, 'inBand' | 'expectedSeqInBand'>, verify: (result: EventBatchResult) => void): Promise<EventBatchResult>;
229
+ private enqueueAhead;
230
+ /** Sends a group of run-ahead writes as one batch and splits the result. */
231
+ private sendGroup;
232
+ /**
233
+ * A lone run-ahead batch of one event goes out as a single write. A
234
+ * definite refusal reaches `verify` as the batch's refused item, the way a
235
+ * batch reports it.
236
+ */
237
+ private sendBatchOfOne;
238
+ private writeBatch;
239
+ private fenceParams;
240
+ private advance;
241
+ /**
242
+ * Positions a single accepted write allocated. The World's response does
243
+ * not state it, so it is inferred: an event at a slot this writer already
244
+ * knew to be allocated when it sent the write is an idempotent replay of
245
+ * an earlier write (for example a deduplicated `hook_received`), which
246
+ * allocated nothing. Slots learned while the write was in flight do not
247
+ * count: the live feed can deliver the write's own events, and later
248
+ * ones, before its response.
249
+ */
250
+ private allocatedBy;
251
+ private noteSlot;
252
+ /**
253
+ * The position an in-band write names when it is sent: the one it was
254
+ * decided from (a caller that names none gets the last full load's
255
+ * `snapshot.seq`), raised to {@link completeThrough}. A write queued behind
256
+ * others was decided from a position below theirs, and naming it would
257
+ * have the World report back every event those writes made, which this
258
+ * writer already has from their responses. Naming more than the decision
259
+ * saw is safe because everything up to `completeThrough` has reached this
260
+ * writer: a load, or a response whose report was complete.
261
+ */
262
+ private sendPosition;
263
+ /**
264
+ * Raises {@link completeThrough} past an accepted write whose response
265
+ * reported everything below it: the write named a position, and its
266
+ * skipped-slot report is neither incomplete nor truncated.
267
+ */
268
+ private noteComplete;
269
+ private stop;
270
+ /** Positions of the writes queued in this writer and not yet settled. */
271
+ private pendingPositions;
272
+ private serialize;
273
+ }
274
+ export declare function withWrittenEventData<E extends Event>(event: E, request: CreateEventRequest, fresh: boolean): E;
275
+ //# sourceMappingURL=in-band-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-band-writer.d.ts","sourceRoot":"","sources":["../../../src/runtime/spec9/in-band-writer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,KAAK,EACN,MAAM,iBAAiB,CAAC;AASzB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACxC,QAAQ,CAAC,KAAK,EAAE,OAAO;gBAAd,KAAK,EAAE,OAAO;IAOnC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,2BAA2B;CAKhE;AAyBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE;IAAE,MAAM,EAAE,SAAS,OAAO,EA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