@voltro/workflow 0.85.0 → 0.86.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 (85) hide show
  1. package/CHANGELOG.md +666 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -33
  3. package/dist/admission.js +140 -0
  4. package/dist/admissionDrainer.js +705 -0
  5. package/dist/admissionGate.js +115 -0
  6. package/dist/admissionStore.js +347 -0
  7. package/dist/admissionSubmission.js +297 -0
  8. package/dist/admissionTables.js +137 -0
  9. package/dist/admissionTransaction.js +21 -0
  10. package/dist/awaitEvent.js +82 -0
  11. package/dist/budgetHold.js +136 -0
  12. package/dist/cancelOnPlan.js +75 -0
  13. package/dist/cancelOnSweep.js +188 -0
  14. package/dist/cancelPendingStart.js +50 -0
  15. package/dist/cluster.js +8 -2
  16. package/dist/clusterCron.js +11 -0
  17. package/dist/clusterDiagnostics.js +20 -0
  18. package/dist/clusterDiagnosticsSql.js +145 -0
  19. package/dist/clusterLayer.js +110 -0
  20. package/dist/clusterMigrationGate.js +61 -0
  21. package/dist/clusterRunnerLayer.js +21 -0
  22. package/dist/clusterTestSuite.js +101 -101
  23. package/dist/controlMonitor.js +13 -0
  24. package/dist/controlRequest.js +367 -0
  25. package/dist/executionRefusal.js +162 -0
  26. package/dist/failureHandoff.js +183 -0
  27. package/dist/failureMessage.js +12 -0
  28. package/dist/failureRecovery.js +50 -0
  29. package/dist/failureReportStore.js +60 -0
  30. package/dist/flowControl.js +142 -0
  31. package/dist/forwardStartReceipts.js +41 -0
  32. package/dist/inMemoryLayer.js +7 -0
  33. package/dist/inMemoryRecorder.js +56 -0
  34. package/dist/index.d.ts +82 -8
  35. package/dist/index.js +49 -5
  36. package/dist/inspectWorkflow.js +101 -0
  37. package/dist/{journalEncryption-DTyhUzaS.js → journalEncryption.js} +30 -37
  38. package/dist/messages.js +92 -0
  39. package/dist/nondeterminism.js +51 -0
  40. package/dist/parentClosure.js +141 -0
  41. package/dist/parentClosureRecovery.js +54 -0
  42. package/dist/pendingSubmission.js +85 -0
  43. package/dist/prepareSubmissionDispatch.js +17 -0
  44. package/dist/preparedExecution.js +14 -0
  45. package/dist/primitives.js +225 -2
  46. package/dist/queuedCancellationRequest.js +364 -0
  47. package/dist/queuedControl.js +21 -0
  48. package/dist/recorder.js +11 -0
  49. package/dist/residentExecutionEvidence.js +64 -0
  50. package/dist/retryPolicy.js +57 -0
  51. package/dist/runEventsTable.js +17 -0
  52. package/dist/runGeneration.js +345 -0
  53. package/dist/runRecording.js +615 -0
  54. package/dist/runStepsTable.js +28 -0
  55. package/dist/runnerStorageGuard.js +29 -0
  56. package/dist/runsTable.js +42 -0
  57. package/dist/scheduleDeclaration.js +44 -0
  58. package/dist/signalHint.js +23 -0
  59. package/dist/signals.js +70 -0
  60. package/dist/signalsSuspending.js +57 -0
  61. package/dist/sqliteWorkflowOwnership.js +26 -0
  62. package/dist/stalenessSweep.js +191 -0
  63. package/dist/startContextsTable.js +20 -0
  64. package/dist/startReceipt.js +143 -0
  65. package/dist/submissionRecovery.js +122 -0
  66. package/dist/submissionRejection.js +10 -0
  67. package/dist/submissionRetry.js +71 -0
  68. package/dist/suspensionUnavailable.js +9 -0
  69. package/dist/updates.js +87 -0
  70. package/dist/watermarkTable.js +9 -0
  71. package/dist/webCrypto.js +17 -0
  72. package/dist/workflowDelivery.js +24 -0
  73. package/dist/workflowJournal.js +124 -0
  74. package/dist/workflowJournalReset.js +111 -0
  75. package/dist/workflowReadSelections.js +12 -0
  76. package/dist/workflowRestartDispatch.js +29 -0
  77. package/dist/workflowRestartObservation.js +60 -0
  78. package/dist/workflowRestartPreparation.js +109 -0
  79. package/dist/workflowRestartReservation.js +426 -0
  80. package/dist/workflowResumeDispatch.js +29 -0
  81. package/package.json +4 -4
  82. package/dist/cluster-F_bhqVP7.js +0 -679
  83. package/dist/primitives-DX04WTWh.js +0 -507
  84. package/dist/src-C2NEyUM8.js +0 -3925
  85. package/dist/workflowReadSelections-CZAUjP7f.js +0 -2096
@@ -1,11 +1,11 @@
1
1
  # Third-Party Notices — @voltro/workflow
2
2
 
3
- This package depends on the open-source software listed below. Each is the
3
+ This package uses the open-source software listed below. Each is the
4
4
  property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/workflow itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (5 packages).
8
+ Generated from the resolved runtime dependency closure (4 packages).
9
9
 
10
10
  ---
11
11
 
@@ -37,34 +37,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
37
  SOFTWARE.
38
38
  ```
39
39
 
40
- ## layerr@3.0.0
41
-
42
- License: MIT
43
-
44
- ```
45
- MIT License
46
-
47
- Copyright (c) 2020 Perry Mitchell
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining a copy
50
- of this software and associated documentation files (the "Software"), to deal
51
- in the Software without restriction, including without limitation the rights
52
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
- copies of the Software, and to permit persons to whom the Software is
54
- furnished to do so, subject to the following conditions:
55
-
56
- The above copyright notice and this permission notice shall be included in all
57
- copies or substantial portions of the Software.
58
-
59
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65
- SOFTWARE.
66
- ```
67
-
68
40
  ## typeid-js@1.2.0
69
41
 
70
42
  License: Apache-2.0
@@ -273,14 +245,14 @@ Apache License
273
245
  limitations under the License.
274
246
  ```
275
247
 
276
- ## ulidx@2.4.1
248
+ ## ulid@3.0.2
277
249
 
278
250
  License: MIT
279
251
 
280
252
  ```
281
- MIT License
253
+ The MIT License (MIT)
282
254
 
283
- Copyright (c) 2021 Perry Mitchell
255
+ Copyright (c) 2017 Alizain Feerasta
284
256
 
285
257
  Permission is hereby granted, free of charge, to any person obtaining a copy
286
258
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,140 @@
1
+ //#region src/admission.ts
2
+ var e = class extends Error {
3
+ workflowName;
4
+ field;
5
+ constructor(e, t, n) {
6
+ super(`workflow '${e}': ${t}(payload) threw — a flow-control key function must be total over every payload the workflow accepts, because it runs before the run exists and there is nowhere to report a partial failure to. Cause: ${n instanceof Error ? n.message : String(n)}`), this.name = "FlowControlKeyError", this.workflowName = e, this.field = t, this.cause = n;
7
+ }
8
+ }, t = (t, n, r, i) => {
9
+ try {
10
+ let e = r(i);
11
+ if (typeof e != "string" || e.length === 0) throw Error(`returned ${e === "" ? "an empty string" : String(e)}; expected a non-empty string`);
12
+ return e;
13
+ } catch (r) {
14
+ throw new e(t, n, r);
15
+ }
16
+ }, n = (e, t) => JSON.stringify([e ?? null, t]), r = (r, i) => {
17
+ let a = r.workflowName, o = 0;
18
+ if (r.priority !== void 0) try {
19
+ let e = r.priority(i);
20
+ if (!Number.isFinite(e)) throw Error(`returned ${String(e)}; expected a finite number`);
21
+ o = Math.trunc(e);
22
+ } catch (t) {
23
+ throw new e(a, "priority", t);
24
+ }
25
+ return {
26
+ ...r.debounce === void 0 ? {} : { debounceKey: t(a, "debounce.key", r.debounce.key, i) },
27
+ ...r.singleton === void 0 ? {} : { singletonKey: t(a, "singleton.key", r.singleton.key, i) },
28
+ ...r.concurrency === void 0 ? {} : { concurrencyKey: n(r.concurrency.pool, r.concurrency.key === void 0 ? "" : t(a, "concurrency.key", r.concurrency.key, i)) },
29
+ ...r.throttle?.key === void 0 ? r.throttle === void 0 ? {} : { throttleKey: "" } : { throttleKey: t(a, "throttle.key", r.throttle.key, i) },
30
+ ...r.rateLimit?.key === void 0 ? r.rateLimit === void 0 ? {} : { rateLimitKey: "" } : { rateLimitKey: t(a, "rateLimit.key", r.rateLimit.key, i) },
31
+ ...r.batch?.key === void 0 ? r.batch === void 0 ? {} : { batchKey: "" } : { batchKey: t(a, "batch.key", r.batch.key, i) },
32
+ priority: o
33
+ };
34
+ }, i = (e, t, n, r) => {
35
+ let i = e.filter((e) => e > r - n);
36
+ if (i.length < t) return;
37
+ let a = [...i].sort((e, t) => t - e)[t - 1];
38
+ if (a !== void 0) return a + n;
39
+ }, a = (e) => {
40
+ let { control: t, keys: n, state: r, now: a, reconsidering: c } = e;
41
+ if (r.paused === !0) return {
42
+ kind: "defer",
43
+ mode: "paused",
44
+ dueAt: a,
45
+ collapse: c ? "hold" : "append",
46
+ keys: n
47
+ };
48
+ if (t.rateLimit !== void 0) {
49
+ let e = i(r.recentAdmissions ?? [], t.rateLimit.limit, t.rateLimit.periodMs, a);
50
+ if (e !== void 0) return {
51
+ kind: "drop",
52
+ reason: "rate-limit",
53
+ retryAfterMs: Math.max(0, e - a),
54
+ keys: n
55
+ };
56
+ }
57
+ if (t.singleton !== void 0 && r.singletonUnacknowledged === !0) return {
58
+ kind: "defer",
59
+ mode: "singleton",
60
+ dueAt: a,
61
+ collapse: c ? "hold" : "append",
62
+ keys: n
63
+ };
64
+ if (t.singleton !== void 0 && t.singleton.mode === "skip" && r.singletonHolder !== void 0) return {
65
+ kind: "skip",
66
+ incumbent: r.singletonHolder,
67
+ keys: n
68
+ };
69
+ if (t.debounce !== void 0) {
70
+ let e = r.debouncePending, i = e?.firstSeenAt ?? a, o = e?.deadlineAt ?? (t.debounce.timeoutMs === void 0 ? void 0 : i + t.debounce.timeoutMs);
71
+ return c ? o !== void 0 && a >= o ? {
72
+ kind: "admit",
73
+ reason: "debounce-deadline",
74
+ keys: n,
75
+ ...s(t, r)
76
+ } : {
77
+ kind: "admit",
78
+ reason: "debounce-elapsed",
79
+ keys: n,
80
+ ...s(t, r)
81
+ } : {
82
+ kind: "defer",
83
+ mode: "debounce",
84
+ dueAt: o === void 0 ? a + t.debounce.periodMs : Math.min(a + t.debounce.periodMs, o),
85
+ ...o === void 0 ? {} : { deadlineAt: o },
86
+ collapse: "replace",
87
+ keys: n
88
+ };
89
+ }
90
+ if (t.batch !== void 0) {
91
+ let e = r.batchPending, i = (e?.count ?? 0) + +!c, o = (e?.firstSeenAt ?? a) + t.batch.timeoutMs;
92
+ return i >= t.batch.maxSize ? {
93
+ kind: "admit",
94
+ reason: "batch-full",
95
+ keys: n,
96
+ ...s(t, r)
97
+ } : c && a >= o ? {
98
+ kind: "admit",
99
+ reason: "batch-timeout",
100
+ keys: n,
101
+ ...s(t, r)
102
+ } : {
103
+ kind: "defer",
104
+ mode: "batch",
105
+ dueAt: o,
106
+ collapse: c ? "hold" : "append",
107
+ keys: n
108
+ };
109
+ }
110
+ if (t.throttle !== void 0) {
111
+ let e = i(r.recentAdmissions ?? [], t.throttle.limit, t.throttle.periodMs, a);
112
+ if (e !== void 0) return {
113
+ kind: "defer",
114
+ mode: "throttle",
115
+ dueAt: e,
116
+ collapse: c ? "hold" : "append",
117
+ keys: n
118
+ };
119
+ }
120
+ return t.concurrency !== void 0 && (r.inFlight ?? 0) >= t.concurrency.limit ? {
121
+ kind: "defer",
122
+ mode: "concurrency",
123
+ dueAt: a,
124
+ collapse: c ? "hold" : "append",
125
+ keys: n
126
+ } : {
127
+ kind: "admit",
128
+ reason: o(t) ? "under-limits" : "no-controls",
129
+ keys: n,
130
+ ...s(t, r)
131
+ };
132
+ }, o = (e) => e.debounce !== void 0 || e.singleton !== void 0 || e.concurrency !== void 0 || e.throttle !== void 0 || e.rateLimit !== void 0 || e.batch !== void 0, s = (e, t) => e.singleton?.mode === "cancel" && t.singletonHolder !== void 0 ? { evict: t.singletonHolder } : {}, c = (e, t, n) => {
133
+ let r = e.timeouts?.startMs;
134
+ return r !== void 0 && n - t.firstSeenAt >= r;
135
+ }, l = (e, t, n) => {
136
+ let r = e.timeouts?.finishMs;
137
+ return r === void 0 || t.terminal ? !1 : n - t.startedAt >= r;
138
+ }, u = (e, t) => e.priority === t.priority ? e.firstSeenAt === t.firstSeenAt ? e.id < t.id ? -1 : +(e.id > t.id) : e.firstSeenAt - t.firstSeenAt : t.priority - e.priority;
139
+ //#endregion
140
+ export { e as FlowControlKeyError, u as comparePendingOrder, a as decideAdmission, l as isFinishExpired, c as isStartExpired, i as nextSlotAt, n as pooledConcurrencyKey, r as resolveAdmissionKeys };