@voltro/workflow 0.86.0 → 0.88.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 (99) hide show
  1. package/CHANGELOG.md +5484 -0
  2. package/THIRD-PARTY-NOTICES.md +3 -227
  3. package/dist/admission.js +1 -2
  4. package/dist/admissionDrainer.js +5 -3
  5. package/dist/admissionGate.js +1 -2
  6. package/dist/admissionStore.js +1 -2
  7. package/dist/admissionSubmission.js +1 -2
  8. package/dist/admissionTables.js +4 -4
  9. package/dist/admissionTransaction.js +1 -2
  10. package/dist/awaitEvent.js +1 -2
  11. package/dist/budgetHold.js +1 -2
  12. package/dist/cancelOnPlan.js +1 -2
  13. package/dist/cancelOnSweep.js +1 -2
  14. package/dist/cancelPendingStart.js +1 -2
  15. package/dist/cluster.d.ts +111 -27
  16. package/dist/cluster.js +12 -8
  17. package/dist/clusterCron.js +18 -11
  18. package/dist/clusterDiagnostics.js +1 -2
  19. package/dist/clusterDiagnosticsSql.js +1 -2
  20. package/dist/clusterLayer.js +105 -71
  21. package/dist/clusterMigrationGate.js +1 -2
  22. package/dist/clusterRunnerLayer.js +27 -18
  23. package/dist/clusterShardGroups.js +32 -0
  24. package/dist/clusterTestSuite.d.ts +45 -2
  25. package/dist/clusterTestSuite.js +225 -197
  26. package/dist/controlMonitor.js +1 -2
  27. package/dist/controlRequest.js +1 -2
  28. package/dist/executionRefusal.js +1 -2
  29. package/dist/failureHandoff.js +1 -2
  30. package/dist/failureMessage.js +1 -2
  31. package/dist/failureRecovery.js +1 -2
  32. package/dist/failureReportStore.js +1 -2
  33. package/dist/flowControl.js +1 -2
  34. package/dist/forwardStartReceipts.js +1 -2
  35. package/dist/inMemoryLayer.js +1 -2
  36. package/dist/inMemoryRecorder.js +1 -2
  37. package/dist/index.d.ts +50 -23
  38. package/dist/index.js +24 -23
  39. package/dist/inspectWorkflow.js +2 -3
  40. package/dist/journalEncryption.js +1 -2
  41. package/dist/journalRoutingGuard.js +49 -0
  42. package/dist/journalRoutingLayout.js +46 -0
  43. package/dist/journalRoutingLock.js +38 -0
  44. package/dist/journalRoutingMaintenance.js +23 -0
  45. package/dist/journalRoutingMessageStorage.js +31 -0
  46. package/dist/journalRoutingNamespace.js +22 -0
  47. package/dist/journalRoutingRuntime.js +32 -0
  48. package/dist/journalRoutingSharding.js +27 -0
  49. package/dist/journalRoutingState.js +92 -0
  50. package/dist/journalRoutingTable.js +10 -0
  51. package/dist/journalRoutingTransaction.js +15 -0
  52. package/dist/messages.js +1 -2
  53. package/dist/nondeterminism.js +1 -2
  54. package/dist/parentClosure.js +1 -2
  55. package/dist/parentClosureRecovery.js +1 -2
  56. package/dist/pendingSubmission.js +1 -2
  57. package/dist/prepareSubmissionDispatch.js +1 -2
  58. package/dist/preparedExecution.js +1 -2
  59. package/dist/primitives.js +1 -2
  60. package/dist/queuedCancellationRequest.js +1 -2
  61. package/dist/queuedControl.js +1 -2
  62. package/dist/recorder.js +1 -2
  63. package/dist/residentExecutionEvidence.js +1 -2
  64. package/dist/retryPolicy.js +1 -2
  65. package/dist/runEventsTable.js +1 -2
  66. package/dist/runGeneration.js +1 -2
  67. package/dist/runRecording.js +1 -2
  68. package/dist/runStepsTable.js +1 -2
  69. package/dist/runnerStorageGuard.js +1 -2
  70. package/dist/runsTable.js +1 -2
  71. package/dist/scheduleDeclaration.js +1 -2
  72. package/dist/signalHint.js +1 -2
  73. package/dist/signals.js +1 -2
  74. package/dist/signalsSuspending.js +1 -2
  75. package/dist/sqliteWorkflowOwnership.js +1 -2
  76. package/dist/stalenessSweep.js +1 -2
  77. package/dist/startContextsTable.js +1 -2
  78. package/dist/startReceipt.js +1 -2
  79. package/dist/submissionRecovery.js +1 -2
  80. package/dist/submissionRejection.js +1 -2
  81. package/dist/submissionRetry.js +1 -2
  82. package/dist/suspensionUnavailable.js +1 -2
  83. package/dist/updates.js +1 -2
  84. package/dist/watermarkTable.js +1 -2
  85. package/dist/webCrypto.js +4 -17
  86. package/dist/workflowDelivery.js +1 -2
  87. package/dist/workflowExecutorRouting.js +32 -0
  88. package/dist/workflowJournal.js +1 -2
  89. package/dist/workflowJournalReset.js +1 -2
  90. package/dist/workflowReadSelections.js +1 -2
  91. package/dist/workflowRestartDispatch.js +30 -25
  92. package/dist/workflowRestartObservation.js +1 -2
  93. package/dist/workflowRestartPreparation.js +1 -2
  94. package/dist/workflowRestartReservation.js +158 -157
  95. package/dist/workflowResumeDispatch.js +18 -18
  96. package/dist/workflowRuntimeReadiness.js +11 -0
  97. package/dist/workflowShardRelocation.js +57 -0
  98. package/dist/workflowShardRelocationSql.js +71 -0
  99. package/package.json +5 -11
@@ -1,7 +1,7 @@
1
1
  import { isWorkflowEncrypted as e, sealErrorText as t, sealJournalValue as n } from "./journalEncryption.js";
2
2
  import { Schema as r } from "effect";
3
3
  import { and as i, derivedRowId as a, eq as o, gt as s, or as c } from "@voltro/database";
4
- //#region src/controlRequest.ts
4
+ // src/controlRequest.ts
5
5
  var l = "_voltro_workflow_control_requests", u = r.String.pipe(r.check(r.isMinLength(1))), d = r.Struct({
6
6
  kind: r.Literals(["confirmed", "already-terminal"]),
7
7
  status: r.Literals([
@@ -363,5 +363,4 @@ var l = "_voltro_workflow_control_requests", u = r.String.pipe(r.check(r.isMinLe
363
363
  u = r.id;
364
364
  }
365
365
  };
366
- //#endregion
367
366
  export { l as CONTROL_REQUESTS_TABLE, w as FLOW_CONTROL_FINISH_TIMEOUT, k as acceptWorkflowControlInTransaction, j as beginWorkflowControlDispatchInTransaction, A as bindWorkflowResumeJournalInTransaction, E as finishTimeoutCause, C as hasPendingWorkflowCancellation, O as hasUnsettledParentClosureControls, S as readPendingWorkflowCancellation, x as readPendingWorkflowCancellations, D as readWorkflowControlInTransaction, M as settleWorkflowControlsInTransaction, N as settleWorkflowResumesInTransaction };
@@ -6,7 +6,7 @@ import { Cause as o, Effect as s, Schema as c } from "effect";
6
6
  import { SubjectIdentity as l, publishServerError as u } from "@voltro/protocol";
7
7
  import { randomUUID as d } from "node:crypto";
8
8
  import { WorkflowInstance as f } from "effect/workflow/WorkflowEngine";
9
- //#region src/executionRefusal.ts
9
+ // src/executionRefusal.ts
10
10
  var p = (p, m) => s.gen(function* () {
11
11
  let h = yield* s.sync(() => c.decodeUnknownSync(l)(p.subject));
12
12
  if (h.tenantId !== p.failureContext.tenantId) return yield* s.die(/* @__PURE__ */ Error("Workflow refusal has inconsistent caller tenant"));
@@ -158,5 +158,4 @@ var p = (p, m) => s.gen(function* () {
158
158
  });
159
159
  }), yield* s.failCause(m.cause);
160
160
  });
161
- //#endregion
162
161
  export { p as recordWorkflowExecutionRefusal };
@@ -6,7 +6,7 @@ import { PENDING_TABLE as f, parkDelayedStart as p, retryBackoffMs as m } from "
6
6
  import { Schema as h } from "effect";
7
7
  import { and as g, eq as _, gt as v, isNull as y } from "@voltro/database";
8
8
  import { createHash as b } from "node:crypto";
9
- //#region src/failureHandoff.ts
9
+ // src/failureHandoff.ts
10
10
  var x = async (e, t, n) => {
11
11
  let r, a = t === "submissionId" ? _(t, n) : g(_(t, n), y("submissionId"), y("terminal"));
12
12
  for (;;) {
@@ -179,5 +179,4 @@ var x = async (e, t, n) => {
179
179
  executionId: c.executionId
180
180
  };
181
181
  };
182
- //#endregion
183
182
  export { j as FailureReconciliationError, A as handoffWorkflowFailureInTransaction, w as isFailureDeliveryExecution, C as isFailureDeliveryPending, S as isFailureDeliverySubmission, M as reconcileWorkflowFailureInTransaction };
@@ -1,4 +1,4 @@
1
- //#region src/failureMessage.ts
1
+ // src/failureMessage.ts
2
2
  var e = (e) => {
3
3
  let t = e?.message;
4
4
  if (typeof t == "string" && t.length > 0) return t;
@@ -8,5 +8,4 @@ var e = (e) => {
8
8
  }
9
9
  return String(e);
10
10
  };
11
- //#endregion
12
11
  export { e as failureMessage };
@@ -2,7 +2,7 @@ import { FAILURE_REPORTS_TABLE as e } from "./failureReportStore.js";
2
2
  import { FailureReconciliationError as t, reconcileWorkflowFailureInTransaction as n } from "./failureHandoff.js";
3
3
  import { retryBackoffMs as r } from "./admissionStore.js";
4
4
  import { and as i, gt as a, isNotNull as o, isNull as s } from "@voltro/database";
5
- //#region src/failureRecovery.ts
5
+ // src/failureRecovery.ts
6
6
  var c = /* @__PURE__ */ new WeakMap(), l = async (l, u, d) => {
7
7
  let f = c.get(l), p = await l.store.query({
8
8
  table: e,
@@ -46,5 +46,4 @@ var c = /* @__PURE__ */ new WeakMap(), l = async (l, u, d) => {
46
46
  examined: p.length > 0
47
47
  });
48
48
  };
49
- //#endregion
50
49
  export { l as recoverWorkflowFailures };
@@ -1,7 +1,7 @@
1
1
  import { sealErrorText as e } from "./journalEncryption.js";
2
2
  import { Schema as t } from "effect";
3
3
  import { eq as n } from "@voltro/database";
4
- //#region src/failureReportStore.ts
4
+ // src/failureReportStore.ts
5
5
  var r = "_voltro_workflow_failure_reports", i = t.Struct({
6
6
  id: t.String,
7
7
  workflowName: t.String,
@@ -56,5 +56,4 @@ var r = "_voltro_workflow_failure_reports", i = t.Struct({
56
56
  acceptedExecutionId: null
57
57
  }), l;
58
58
  };
59
- //#endregion
60
59
  export { r as FAILURE_REPORTS_TABLE, a as readWorkflowFailureRecord, o as recordWorkflowFailureInTransaction };
@@ -1,6 +1,6 @@
1
1
  import { sealedSchema as e } from "./journalEncryption.js";
2
2
  import { Duration as t, Schema as n } from "effect";
3
- //#region src/flowControl.ts
3
+ // src/flowControl.ts
4
4
  var r = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0 || e.concurrency !== void 0 || e.throttle !== void 0 || e.rateLimit !== void 0 || e.batch !== void 0 || e.timeouts?.startMs !== void 0 || e.timeouts?.finishMs !== void 0), i = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, a = [
5
5
  "debounce",
6
6
  "batch",
@@ -138,5 +138,4 @@ var r = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
138
138
  else r.workflows.push(n.workflowName);
139
139
  }
140
140
  };
141
- //#endregion
142
141
  export { a as DEFERRING_CONTROLS, f as assertConsistentPools, o as deferringControlsOf, i as hasCancelOn, r as hasFlowControl, d as validateFlowControl };
@@ -2,7 +2,7 @@ import { START_RECEIPTS_TABLE as e, decodeWorkflowStartReceipt as t } from "./st
2
2
  import { PENDING_TABLE as n } from "./admissionStore.js";
3
3
  import { Schema as r } from "effect";
4
4
  import { and as i, eq as a, isNull as o } from "@voltro/database";
5
- //#region src/forwardStartReceipts.ts
5
+ // src/forwardStartReceipts.ts
6
6
  var s = async (s, c) => {
7
7
  if (c.from === c.to) throw Error("Queue transfer requires distinct source and target");
8
8
  let l = await s.query({
@@ -37,5 +37,4 @@ var s = async (s, c) => {
37
37
  }
38
38
  }
39
39
  };
40
- //#endregion
41
40
  export { s as forwardStartReceipts };
@@ -1,7 +1,6 @@
1
1
  import { WorkflowEngine as e } from "effect/workflow";
2
2
  import { RateLimiter as t } from "effect/persistence";
3
3
  import { Layer as n } from "effect";
4
- //#region src/inMemoryLayer.ts
4
+ // src/inMemoryLayer.ts
5
5
  var r = n.merge(e.layerMemory, t.layer.pipe(n.provide(t.layerStoreMemory)));
6
- //#endregion
7
6
  export { r as inMemoryWorkflowEngineLayer };
@@ -1,6 +1,6 @@
1
1
  import { WorkflowRunRecorder as e } from "./recorder.js";
2
2
  import { Layer as t } from "effect";
3
- //#region src/inMemoryRecorder.ts
3
+ // src/inMemoryRecorder.ts
4
4
  var n = () => {
5
5
  let n = [], r = [], i = 0, a = 0;
6
6
  return {
@@ -52,5 +52,4 @@ var n = () => {
52
52
  readEvents: () => r
53
53
  };
54
54
  };
55
- //#endregion
56
55
  export { n as makeInMemoryRecorder };
package/dist/index.d.ts CHANGED
@@ -603,9 +603,10 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
603
603
  kind: "settled";
604
604
  request: {
605
605
  readonly id: string;
606
+ readonly operation: "resume" | "cancel" | "terminate";
606
607
  readonly result: {
607
608
  readonly kind: "confirmed" | "already-terminal";
608
- readonly status: "failed" | "cancelled" | "succeeded";
609
+ readonly status: "failed" | "succeeded" | "cancelled";
609
610
  readonly completedAt: number;
610
611
  readonly output: unknown;
611
612
  readonly errorTag: string | null;
@@ -616,7 +617,6 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
616
617
  readonly enteredAt: number;
617
618
  readonly generation: string;
618
619
  } | null;
619
- readonly operation: "resume" | "cancel" | "terminate";
620
620
  readonly generation: string;
621
621
  readonly runId: string;
622
622
  readonly requestedAt: number;
@@ -643,9 +643,10 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
643
643
  kind: "unknown";
644
644
  request: {
645
645
  readonly id: string;
646
+ readonly operation: "resume" | "cancel" | "terminate";
646
647
  readonly result: {
647
648
  readonly kind: "confirmed" | "already-terminal";
648
- readonly status: "failed" | "cancelled" | "succeeded";
649
+ readonly status: "failed" | "succeeded" | "cancelled";
649
650
  readonly completedAt: number;
650
651
  readonly output: unknown;
651
652
  readonly errorTag: string | null;
@@ -656,7 +657,6 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
656
657
  readonly enteredAt: number;
657
658
  readonly generation: string;
658
659
  } | null;
659
- readonly operation: "resume" | "cancel" | "terminate";
660
660
  readonly generation: string;
661
661
  readonly runId: string;
662
662
  readonly requestedAt: number;
@@ -683,9 +683,10 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
683
683
  kind: "superseded";
684
684
  request: {
685
685
  readonly id: string;
686
+ readonly operation: "resume" | "cancel" | "terminate";
686
687
  readonly result: {
687
688
  readonly kind: "confirmed" | "already-terminal";
688
- readonly status: "failed" | "cancelled" | "succeeded";
689
+ readonly status: "failed" | "succeeded" | "cancelled";
689
690
  readonly completedAt: number;
690
691
  readonly output: unknown;
691
692
  readonly errorTag: string | null;
@@ -696,7 +697,6 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
696
697
  readonly enteredAt: number;
697
698
  readonly generation: string;
698
699
  } | null;
699
- readonly operation: "resume" | "cancel" | "terminate";
700
700
  readonly generation: string;
701
701
  readonly runId: string;
702
702
  readonly requestedAt: number;
@@ -723,9 +723,10 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
723
723
  kind: "already-terminal";
724
724
  request: {
725
725
  readonly id: string;
726
+ readonly operation: "resume" | "cancel" | "terminate";
726
727
  readonly result: {
727
728
  readonly kind: "confirmed" | "already-terminal";
728
- readonly status: "failed" | "cancelled" | "succeeded";
729
+ readonly status: "failed" | "succeeded" | "cancelled";
729
730
  readonly completedAt: number;
730
731
  readonly output: unknown;
731
732
  readonly errorTag: string | null;
@@ -736,7 +737,6 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
736
737
  readonly enteredAt: number;
737
738
  readonly generation: string;
738
739
  } | null;
739
- readonly operation: "resume" | "cancel" | "terminate";
740
740
  readonly generation: string;
741
741
  readonly runId: string;
742
742
  readonly requestedAt: number;
@@ -764,9 +764,10 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
764
764
  request: {
765
765
  dispatchAttempts: number;
766
766
  id: string;
767
+ operation: "resume" | "cancel" | "terminate";
767
768
  result: {
768
769
  readonly kind: "confirmed" | "already-terminal";
769
- readonly status: "failed" | "cancelled" | "succeeded";
770
+ readonly status: "failed" | "succeeded" | "cancelled";
770
771
  readonly completedAt: number;
771
772
  readonly output: unknown;
772
773
  readonly errorTag: string | null;
@@ -777,7 +778,6 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
777
778
  readonly enteredAt: number;
778
779
  readonly generation: string;
779
780
  } | null;
780
- operation: "resume" | "cancel" | "terminate";
781
781
  generation: string;
782
782
  runId: string;
783
783
  requestedAt: number;
@@ -814,9 +814,10 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
814
814
  kind: "settled";
815
815
  request: {
816
816
  readonly id: string;
817
+ readonly operation: "resume" | "cancel" | "terminate";
817
818
  readonly result: {
818
819
  readonly kind: "confirmed" | "already-terminal";
819
- readonly status: "failed" | "cancelled" | "succeeded";
820
+ readonly status: "failed" | "succeeded" | "cancelled";
820
821
  readonly completedAt: number;
821
822
  readonly output: unknown;
822
823
  readonly errorTag: string | null;
@@ -827,7 +828,6 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
827
828
  readonly enteredAt: number;
828
829
  readonly generation: string;
829
830
  } | null;
830
- readonly operation: "resume" | "cancel" | "terminate";
831
831
  readonly generation: string;
832
832
  readonly runId: string;
833
833
  readonly requestedAt: number;
@@ -853,9 +853,10 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
853
853
  kind: "unknown";
854
854
  request: {
855
855
  readonly id: string;
856
+ readonly operation: "resume" | "cancel" | "terminate";
856
857
  readonly result: {
857
858
  readonly kind: "confirmed" | "already-terminal";
858
- readonly status: "failed" | "cancelled" | "succeeded";
859
+ readonly status: "failed" | "succeeded" | "cancelled";
859
860
  readonly completedAt: number;
860
861
  readonly output: unknown;
861
862
  readonly errorTag: string | null;
@@ -866,7 +867,6 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
866
867
  readonly enteredAt: number;
867
868
  readonly generation: string;
868
869
  } | null;
869
- readonly operation: "resume" | "cancel" | "terminate";
870
870
  readonly generation: string;
871
871
  readonly runId: string;
872
872
  readonly requestedAt: number;
@@ -892,9 +892,10 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
892
892
  kind: "superseded";
893
893
  request: {
894
894
  readonly id: string;
895
+ readonly operation: "resume" | "cancel" | "terminate";
895
896
  readonly result: {
896
897
  readonly kind: "confirmed" | "already-terminal";
897
- readonly status: "failed" | "cancelled" | "succeeded";
898
+ readonly status: "failed" | "succeeded" | "cancelled";
898
899
  readonly completedAt: number;
899
900
  readonly output: unknown;
900
901
  readonly errorTag: string | null;
@@ -905,7 +906,6 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
905
906
  readonly enteredAt: number;
906
907
  readonly generation: string;
907
908
  } | null;
908
- readonly operation: "resume" | "cancel" | "terminate";
909
909
  readonly generation: string;
910
910
  readonly runId: string;
911
911
  readonly requestedAt: number;
@@ -931,9 +931,10 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
931
931
  kind: "not-suspended";
932
932
  request: {
933
933
  readonly id: string;
934
+ readonly operation: "resume" | "cancel" | "terminate";
934
935
  readonly result: {
935
936
  readonly kind: "confirmed" | "already-terminal";
936
- readonly status: "failed" | "cancelled" | "succeeded";
937
+ readonly status: "failed" | "succeeded" | "cancelled";
937
938
  readonly completedAt: number;
938
939
  readonly output: unknown;
939
940
  readonly errorTag: string | null;
@@ -944,7 +945,6 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
944
945
  readonly enteredAt: number;
945
946
  readonly generation: string;
946
947
  } | null;
947
- readonly operation: "resume" | "cancel" | "terminate";
948
948
  readonly generation: string;
949
949
  readonly runId: string;
950
950
  readonly requestedAt: number;
@@ -970,9 +970,10 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
970
970
  kind: "bound";
971
971
  request: {
972
972
  readonly id: string;
973
+ readonly operation: "resume" | "cancel" | "terminate";
973
974
  readonly result: {
974
975
  readonly kind: "confirmed" | "already-terminal";
975
- readonly status: "failed" | "cancelled" | "succeeded";
976
+ readonly status: "failed" | "succeeded" | "cancelled";
976
977
  readonly completedAt: number;
977
978
  readonly output: unknown;
978
979
  readonly errorTag: string | null;
@@ -983,7 +984,6 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
983
984
  readonly enteredAt: number;
984
985
  readonly generation: string;
985
986
  } | null;
986
- readonly operation: "resume" | "cancel" | "terminate";
987
987
  readonly generation: string;
988
988
  readonly runId: string;
989
989
  readonly requestedAt: number;
@@ -1009,9 +1009,10 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
1009
1009
  kind: "waiting-journal";
1010
1010
  request: {
1011
1011
  readonly id: string;
1012
+ readonly operation: "resume" | "cancel" | "terminate";
1012
1013
  readonly result: {
1013
1014
  readonly kind: "confirmed" | "already-terminal";
1014
- readonly status: "failed" | "cancelled" | "succeeded";
1015
+ readonly status: "failed" | "succeeded" | "cancelled";
1015
1016
  readonly completedAt: number;
1016
1017
  readonly output: unknown;
1017
1018
  readonly errorTag: string | null;
@@ -1022,7 +1023,6 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
1022
1023
  readonly enteredAt: number;
1023
1024
  readonly generation: string;
1024
1025
  } | null;
1025
- readonly operation: "resume" | "cancel" | "terminate";
1026
1026
  readonly generation: string;
1027
1027
  readonly runId: string;
1028
1028
  readonly requestedAt: number;
@@ -1961,6 +1961,11 @@ export declare const isWorkflowEncrypted: (name: string) => boolean;
1961
1961
 
1962
1962
  export declare const isWorkflowWorkerLayer: (value: unknown) => value is WorkflowWorkerLayerBrand;
1963
1963
 
1964
+ export declare interface JournalRoutingState {
1965
+ readonly generation: number;
1966
+ readonly layout: string;
1967
+ }
1968
+
1964
1969
  /**
1965
1970
  * Attach the engine's execution id to the ledger row written by
1966
1971
  * {@link admitStart}.
@@ -4159,6 +4164,17 @@ declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPa
4159
4164
  readonly name: Name;
4160
4165
  } & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
4161
4166
 
4167
+ /** Journal routing generation per PostgreSQL journal namespace. Declared, so the
4168
+ * schema owns it (plan, fingerprint, backup); the maintenance transition only
4169
+ * reads and writes it inside its pinned journal transaction. */
4170
+ export declare const workflowJournalRoutingTable: Table<"_voltro_workflow_journal_routing", FieldDefinitions<{
4171
+ readonly id: ColumnBuilder<string, "id", boolean>;
4172
+ readonly namespace: ColumnBuilder<string, "text", boolean>;
4173
+ readonly generation: ColumnBuilder<string, "bigint", boolean>;
4174
+ readonly layout: ColumnBuilder<string, "text", boolean>;
4175
+ readonly relocation: ColumnBuilder<string, "text", boolean>;
4176
+ }>, false, never>;
4177
+
4162
4178
  declare type WorkflowMake = typeof workflowModule.make;
4163
4179
 
4164
4180
  export declare interface WorkflowMessagePairSchemas {
@@ -4274,7 +4290,9 @@ export declare const workflowRestartRequestsTable: Table<"_voltro_workflow_resta
4274
4290
  readonly requestedAt: ColumnBuilder<Date, "timestamp", boolean>;
4275
4291
  readonly dispatchAttempts: ColumnBuilder<number, "integer", true>;
4276
4292
  readonly enteredGeneration: ColumnBuilder<string | null, "text", boolean>;
4277
- }>, false, never>;
4293
+ /** Recovery acknowledgement is independent of command replay/entry authority. */
4294
+ readonly poolReleaseSettledAt: ColumnBuilder<Date | null, "timestamp", boolean>;
4295
+ }>, false, "_voltro_workflow_restart_requests_pool_settlement_idx">;
4278
4296
 
4279
4297
  declare type WorkflowRestartSelection = typeof Selection.Type;
4280
4298
 
@@ -4584,6 +4602,15 @@ export declare type WorkflowScheduleOverlap = 'skip' | 'buffer' | 'cancelOther';
4584
4602
  * that crossed a bundler boundary, and symbols do not survive every one. */
4585
4603
  export declare const WorkflowScheduleProperty = "__voltroWorkflowSchedule";
4586
4604
 
4605
+ /** Explicit routing inventory shared by every runner in one cluster. Changing
4606
+ * groups changes persistent addresses; this is not a journal migration. */
4607
+ /** Group names are at most 32 ASCII characters: group + colon + a safe integer
4608
+ * slot fits the existing SQL journal shard_id VARCHAR(50) on every dialect. */
4609
+ export declare interface WorkflowShardGroups {
4610
+ readonly available: ReadonlyArray<string>;
4611
+ readonly assigned: ReadonlyArray<string>;
4612
+ }
4613
+
4587
4614
  /**
4588
4615
  * At most one run per key. The newcomer either stands down or evicts.
4589
4616
  *
package/dist/index.js CHANGED
@@ -24,26 +24,27 @@ import { stageWorkflowParentClosureInTransaction as kt } from "./parentClosure.j
24
24
  import { readWorkflowRestartObservationInTransaction as At, reserveWorkflowRestartInTransaction as jt, withdrawWorkflowRestartInTransaction as Mt, workflowRestartRequestsTable as Nt, workflowRestartWithdrawalsTable as Pt } from "./workflowRestartReservation.js";
25
25
  import { cancelSuspendedWorkflowRunInTransaction as Ft, completeWorkflowRunGenerationInTransaction as It, enterWorkflowRunGenerationInTransaction as Lt } from "./runGeneration.js";
26
26
  import { queuedCancellationRequestsTable as Rt } from "./queuedCancellationRequest.js";
27
- import { cancelQueuedWorkflowStartInTransaction as zt, readQueuedWorkflowCancellationInTransaction as Bt } from "./queuedControl.js";
28
- import { inspectAdmissionSubmissionRetry as Vt, retryAdmissionSubmissionInTransaction as Ht } from "./submissionRetry.js";
29
- import { takeAdmittedSubmissionInTransaction as Ut, takePendingAdmissionSubmission as Wt } from "./pendingSubmission.js";
30
- import { admitStart as Gt, linkExecution as Kt } from "./admissionGate.js";
31
- import { _voltroWorkflowWatermarksTable as qt } from "./watermarkTable.js";
32
- import { newestEventAt as Jt, planCancellations as Yt } from "./cancelOnPlan.js";
33
- import { CANCEL_ON_WATERMARK as Xt, DEFAULT_COLD_LOOKBACK_MS as Zt, DEFAULT_EVENT_BATCH as Qt, EVENTS_TABLE as $t, WATERMARKS_TABLE as en, readWatermark as tn, sweepCancelOn as nn, writeWatermark as rn } from "./cancelOnSweep.js";
34
- import { DEFAULT_STALL_AFTER_MS as an, DEFAULT_STALL_EVENT_LOOKBACK as on, DEFAULT_STALL_RUN_PAGE as sn, sweepStalledRuns as cn } from "./stalenessSweep.js";
35
- import { CLUSTER_REREAD_WINDOW_MS as ln, ClusterDiagnostics as un, describeStalledRun as dn } from "./clusterDiagnostics.js";
36
- import { DEFAULT_DRAIN_BATCH as fn, acceptAdmissionSubmission as pn, drainTick as mn, isUnacknowledgedSubmission as hn } from "./admissionDrainer.js";
37
- import { DEFAULT_SUSPEND_HINT_MS as gn, maybeHintSuspendingSignal as _n, resetSuspendHintsForTest as vn, resolveSuspendHintMs as yn, setSuspendSignalHintMs as bn } from "./signalHint.js";
38
- import { awaitSignal as xn } from "./signals.js";
39
- import { awaitEvent as Sn } from "./awaitEvent.js";
40
- import { SuspensionUnavailable as Cn, WorkflowCannotPark as wn } from "./suspensionUnavailable.js";
41
- import { makeWorkflowUpdateId as Tn, resolveWorkflowMessageRun as En, sendWorkflowSignal as Dn, sendWorkflowUpdate as On } from "./messages.js";
42
- import { awaitSignalSuspending as kn, completeSuspendingSignal as An, suspendingSignalDeferredName as jn } from "./signalsSuspending.js";
43
- import { BUDGET_HOLDS_TABLE as Mn, BudgetHoldExpired as Nn, DEFAULT_BUDGET_HOLD_TIMEOUT_MS as Pn, _voltroBudgetHoldsTable as Fn, budgetHoldGeneration as In, budgetHoldKey as Ln, budgetHoldSignalName as Rn, heldBudgets as zn, pendingBudgetHolds as Bn, releaseBudgetHolds as Vn, suspendForBudget as Hn } from "./budgetHold.js";
44
- import { awaitUpdate as Un } from "./updates.js";
45
- import { inspectWorkflow as Wn } from "./inspectWorkflow.js";
46
- import { makeInMemoryRecorder as Gn } from "./inMemoryRecorder.js";
47
- import { DEFAULT_MAX_RUN_RECLAIMS as Kn, DEFAULT_REPLAY_SHAPE_LIMIT as qn, makeWorkflowRunRecorder as Jn, normaliseWorkflowPatches as Yn, resolveRunGuardTuning as Xn, serialiseWorkflowRowForWire as Zn, truncateWorkflowValue as Qn, wrapWorkflowExecuteWithRunRecording as $n } from "./runRecording.js";
48
- import { recordWorkflowExecutionRefusal as er } from "./executionRefusal.js";
49
- export { et as ADMISSIONS_TABLE, Ie as ADMISSION_SUBMISSION_ID_PREFIX, Mn as BUDGET_HOLDS_TABLE, Nn as BudgetHoldExpired, Xt as CANCEL_ON_WATERMARK, ln as CLUSTER_REREAD_WINDOW_MS, un as ClusterDiagnostics, C as CurrentWorkflowExecutionId, w as CurrentWorkflowPatches, I as CurrentWorkflowReplayShape, T as CurrentWorkflowRunId, E as CurrentWorkflowStep, Pn as DEFAULT_BUDGET_HOLD_TIMEOUT_MS, Zt as DEFAULT_COLD_LOOKBACK_MS, fn as DEFAULT_DRAIN_BATCH, Qt as DEFAULT_EVENT_BATCH, tt as DEFAULT_LEASE_MS, Kn as DEFAULT_MAX_RUN_RECLAIMS, qn as DEFAULT_REPLAY_SHAPE_LIMIT, an as DEFAULT_STALL_AFTER_MS, on as DEFAULT_STALL_EVENT_LOOKBACK, sn as DEFAULT_STALL_RUN_PAGE, gn as DEFAULT_SUSPEND_HINT_MS, M as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, _ as DEFERRING_CONTROLS, $t as EVENTS_TABLE, we as FlowControlKeyError, nt as PAUSES_TABLE, rt as PENDING_TABLE, i as STEP_JOURNAL_BINDING, Le as SUBMISSIONS_TABLE, Cn as SuspensionUnavailable, en as WATERMARKS_TABLE, a as WORKFLOW_JOURNAL_BINDING, wn as WorkflowCannotPark, B as WorkflowFlowControlProperty, V as WorkflowMessagesProperty, D as WorkflowRunRecorder, N as WorkflowScheduleProperty, Je as WorkflowStartRequestConflictError, O as WorkflowStepInterceptorTag, H as WorkflowVersionTypeId, U as WorkflowWorkerLayerTypeId, Fn as _voltroBudgetHoldsTable, me as _voltroWorkflowAdmissionLocksTable, he as _voltroWorkflowAdmissionsTable, ge as _voltroWorkflowControlRequestsTable, _e as _voltroWorkflowFailureReportsTable, ve as _voltroWorkflowParentClosuresTable, ye as _voltroWorkflowPausesTable, be as _voltroWorkflowPendingTable, fe as _voltroWorkflowRunEventsTable, de as _voltroWorkflowRunStepsTable, ue as _voltroWorkflowRunsTable, pe as _voltroWorkflowStartContextsTable, xe as _voltroWorkflowStartReceiptsTable, Se as _voltroWorkflowSubmissionsTable, qt as _voltroWorkflowWatermarksTable, pn as acceptAdmissionSubmission, Tt as acceptWorkflowControlInTransaction, Re as acknowledgeAdmissionSubmission, it as admissionLeaseHeldPredicate, Gt as admitStart, at as allIntents, v as assertConsistentPools, t as attachPreparedWorkflowExecution, Sn as awaitEvent, xn as awaitSignal, kn as awaitSignalSuspending, Un as awaitUpdate, ze as beginAdmissionSubmissionDispatchInTransaction, Et as beginWorkflowControlDispatchInTransaction, Dt as bindWorkflowResumeJournalInTransaction, Ye as bindWorkflowStartReceipts, In as budgetHoldGeneration, Ln as budgetHoldKey, Rn as budgetHoldSignalName, zt as cancelQueuedWorkflowStartInTransaction, Ft as cancelSuspendedWorkflowRunInTransaction, Te as comparePendingOrder, An as completeSuspendingSignal, It as completeWorkflowRunGenerationInTransaction, k as currentWorkflowStep, ot as deadLetterIntent, Ee as decideAdmission, y as deferringControlsOf, st as deleteIntent, dn as describeStalledRun, ct as discardIntent, lt as discardIntentInTransaction, mn as drainTick, ut as dueIntents, W as durableClock, G as durableQueue, K as durableQueueModule, Lt as enterWorkflowRunGenerationInTransaction, dt as evaluateAdmission, n as executePreparedWorkflow, e as failureMessage, A as getCurrentWorkflowExecutionId, j as getCurrentWorkflowRunId, q as getWorkflowFlowControl, o as getWorkflowJournalCipher, P as getWorkflowSchedule, J as getWorkflowVersionMetadata, Pe as handoffWorkflowFailureInTransaction, b as hasCancelOn, x as hasFlowControl, r as hasPreparedWorkflowExecution, zn as heldBudgets, le as inMemoryWorkflowEngineLayer, Vt as inspectAdmissionSubmissionRetry, Wn as inspectWorkflow, Y as isCarrier, De as isFinishExpired, s as isSealedJournalValue, Oe as isStartExpired, hn as isUnacknowledgedSubmission, c as isWorkflowEncrypted, X as isWorkflowWorkerLayer, Kt as linkExecution, Gn as makeInMemoryRecorder, L as makeReplayShapeTracker, Jn as makeWorkflowRunRecorder, Tn as makeWorkflowUpdateId, _n as maybeHintSuspendingSignal, Be as newAdmissionSubmissionId, Jt as newestEventAt, ke as nextSlotAt, R as nondeterminismEventPayload, Yn as normaliseWorkflowPatches, Ve as noteAdmissionSubmissionFailure, ft as noteIntentAttempt, l as openErrorText, u as openEventPayload, d as openJournalValue, f as openPayloadFields, p as openWorkflowRow, pt as parkDelayedStart, Z as patch, mt as pauseWorkflow, He as pendingAdmissionSubmissions, Bn as pendingBudgetHolds, ht as pendingSlotId, gt as pendingWindow, _t as persistDefer, Yt as planCancellations, Ae as pooledConcurrencyKey, Ue as prepareAdmissionSubmissionExecutionInTransaction, Q as processQueue, vt as pruneAdmissions, $ as queueWorker, Rt as queuedCancellationRequestsTable, ee as rateLimit, yt as readAdmissionState, We as readAdmissionSubmission, bt as readPausedWorkflows, Bt as readQueuedWorkflowCancellationInTransaction, tn as readWatermark, Ot as readWorkflowControlInTransaction, Me as readWorkflowFailureRecord, At as readWorkflowRestartObservationInTransaction, Xe as readWorkflowStartReceipt, Ze as readWorkflowStartRequest, Fe as reconcileWorkflowFailureInTransaction, xt as recordAdmission, er as recordWorkflowExecutionRefusal, Ne as recordWorkflowFailureInTransaction, Qe as recordWorkflowStartReceipt, Ge as rejectAdmissionSubmissionInTransaction, Vn as releaseBudgetHolds, St as releaseLease, z as reportNondeterminism, Ke as reserveAdmissionSubmission, qe as reserveAdmissionSubmissionInTransaction, jt as reserveWorkflowRestartInTransaction, vn as resetSuspendHintsForTest, je as resolveAdmissionKeys, Xn as resolveRunGuardTuning, yn as resolveSuspendHintMs, En as resolveWorkflowMessageRun, $e as resolveWorkflowStartReceipt, Ct as resumeWorkflow, Ht as retryAdmissionSubmissionInTransaction, wt as retryDeadLetterIntent, m as sealJournalValue, Dn as sendWorkflowSignal, On as sendWorkflowUpdate, Zn as serialiseWorkflowRowForWire, bn as setSuspendSignalHintMs, h as setWorkflowJournalCipher, te as sleep, ne as sleepUntil, kt as stageWorkflowParentClosureInTransaction, re as step, ie as stepIdempotencyKey, ae as stepModule, Hn as suspendForBudget, jn as suspendingSignalDeferredName, nn as sweepCancelOn, cn as sweepStalledRuns, Ut as takeAdmittedSubmissionInTransaction, Wt as takePendingAdmissionSubmission, Qn as truncateWorkflowValue, g as tryOpenJournalValue, S as validateFlowControl, F as validateWorkflowSchedule, Ce as withAdmissionTransaction, oe as withCompensation, Mt as withdrawWorkflowRestartInTransaction, se as workflow, ce as workflowModule, Nt as workflowRestartRequestsTable, Pt as workflowRestartWithdrawalsTable, $n as wrapWorkflowExecuteWithRunRecording, rn as writeWatermark };
27
+ import { workflowJournalRoutingTable as zt } from "./journalRoutingTable.js";
28
+ import { cancelQueuedWorkflowStartInTransaction as Bt, readQueuedWorkflowCancellationInTransaction as Vt } from "./queuedControl.js";
29
+ import { inspectAdmissionSubmissionRetry as Ht, retryAdmissionSubmissionInTransaction as Ut } from "./submissionRetry.js";
30
+ import { takeAdmittedSubmissionInTransaction as Wt, takePendingAdmissionSubmission as Gt } from "./pendingSubmission.js";
31
+ import { admitStart as Kt, linkExecution as qt } from "./admissionGate.js";
32
+ import { _voltroWorkflowWatermarksTable as Jt } from "./watermarkTable.js";
33
+ import { newestEventAt as Yt, planCancellations as Xt } from "./cancelOnPlan.js";
34
+ import { CANCEL_ON_WATERMARK as Zt, DEFAULT_COLD_LOOKBACK_MS as Qt, DEFAULT_EVENT_BATCH as $t, EVENTS_TABLE as en, WATERMARKS_TABLE as tn, readWatermark as nn, sweepCancelOn as rn, writeWatermark as an } from "./cancelOnSweep.js";
35
+ import { DEFAULT_STALL_AFTER_MS as on, DEFAULT_STALL_EVENT_LOOKBACK as sn, DEFAULT_STALL_RUN_PAGE as cn, sweepStalledRuns as ln } from "./stalenessSweep.js";
36
+ import { CLUSTER_REREAD_WINDOW_MS as un, ClusterDiagnostics as dn, describeStalledRun as fn } from "./clusterDiagnostics.js";
37
+ import { DEFAULT_DRAIN_BATCH as pn, acceptAdmissionSubmission as mn, drainTick as hn, isUnacknowledgedSubmission as gn } from "./admissionDrainer.js";
38
+ import { DEFAULT_SUSPEND_HINT_MS as _n, maybeHintSuspendingSignal as vn, resetSuspendHintsForTest as yn, resolveSuspendHintMs as bn, setSuspendSignalHintMs as xn } from "./signalHint.js";
39
+ import { awaitSignal as Sn } from "./signals.js";
40
+ import { awaitEvent as Cn } from "./awaitEvent.js";
41
+ import { SuspensionUnavailable as wn, WorkflowCannotPark as Tn } from "./suspensionUnavailable.js";
42
+ import { makeWorkflowUpdateId as En, resolveWorkflowMessageRun as Dn, sendWorkflowSignal as On, sendWorkflowUpdate as kn } from "./messages.js";
43
+ import { awaitSignalSuspending as An, completeSuspendingSignal as jn, suspendingSignalDeferredName as Mn } from "./signalsSuspending.js";
44
+ import { BUDGET_HOLDS_TABLE as Nn, BudgetHoldExpired as Pn, DEFAULT_BUDGET_HOLD_TIMEOUT_MS as Fn, _voltroBudgetHoldsTable as In, budgetHoldGeneration as Ln, budgetHoldKey as Rn, budgetHoldSignalName as zn, heldBudgets as Bn, pendingBudgetHolds as Vn, releaseBudgetHolds as Hn, suspendForBudget as Un } from "./budgetHold.js";
45
+ import { awaitUpdate as Wn } from "./updates.js";
46
+ import { inspectWorkflow as Gn } from "./inspectWorkflow.js";
47
+ import { makeInMemoryRecorder as Kn } from "./inMemoryRecorder.js";
48
+ import { DEFAULT_MAX_RUN_RECLAIMS as qn, DEFAULT_REPLAY_SHAPE_LIMIT as Jn, makeWorkflowRunRecorder as Yn, normaliseWorkflowPatches as Xn, resolveRunGuardTuning as Zn, serialiseWorkflowRowForWire as Qn, truncateWorkflowValue as $n, wrapWorkflowExecuteWithRunRecording as er } from "./runRecording.js";
49
+ import { recordWorkflowExecutionRefusal as tr } from "./executionRefusal.js";
50
+ export { et as ADMISSIONS_TABLE, Ie as ADMISSION_SUBMISSION_ID_PREFIX, Nn as BUDGET_HOLDS_TABLE, Pn as BudgetHoldExpired, Zt as CANCEL_ON_WATERMARK, un as CLUSTER_REREAD_WINDOW_MS, dn as ClusterDiagnostics, C as CurrentWorkflowExecutionId, w as CurrentWorkflowPatches, I as CurrentWorkflowReplayShape, T as CurrentWorkflowRunId, E as CurrentWorkflowStep, Fn as DEFAULT_BUDGET_HOLD_TIMEOUT_MS, Qt as DEFAULT_COLD_LOOKBACK_MS, pn as DEFAULT_DRAIN_BATCH, $t as DEFAULT_EVENT_BATCH, tt as DEFAULT_LEASE_MS, qn as DEFAULT_MAX_RUN_RECLAIMS, Jn as DEFAULT_REPLAY_SHAPE_LIMIT, on as DEFAULT_STALL_AFTER_MS, sn as DEFAULT_STALL_EVENT_LOOKBACK, cn as DEFAULT_STALL_RUN_PAGE, _n as DEFAULT_SUSPEND_HINT_MS, M as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, _ as DEFERRING_CONTROLS, en as EVENTS_TABLE, we as FlowControlKeyError, nt as PAUSES_TABLE, rt as PENDING_TABLE, i as STEP_JOURNAL_BINDING, Le as SUBMISSIONS_TABLE, wn as SuspensionUnavailable, tn as WATERMARKS_TABLE, a as WORKFLOW_JOURNAL_BINDING, Tn as WorkflowCannotPark, B as WorkflowFlowControlProperty, V as WorkflowMessagesProperty, D as WorkflowRunRecorder, N as WorkflowScheduleProperty, Je as WorkflowStartRequestConflictError, O as WorkflowStepInterceptorTag, H as WorkflowVersionTypeId, U as WorkflowWorkerLayerTypeId, In as _voltroBudgetHoldsTable, me as _voltroWorkflowAdmissionLocksTable, he as _voltroWorkflowAdmissionsTable, ge as _voltroWorkflowControlRequestsTable, _e as _voltroWorkflowFailureReportsTable, ve as _voltroWorkflowParentClosuresTable, ye as _voltroWorkflowPausesTable, be as _voltroWorkflowPendingTable, fe as _voltroWorkflowRunEventsTable, de as _voltroWorkflowRunStepsTable, ue as _voltroWorkflowRunsTable, pe as _voltroWorkflowStartContextsTable, xe as _voltroWorkflowStartReceiptsTable, Se as _voltroWorkflowSubmissionsTable, Jt as _voltroWorkflowWatermarksTable, mn as acceptAdmissionSubmission, Tt as acceptWorkflowControlInTransaction, Re as acknowledgeAdmissionSubmission, it as admissionLeaseHeldPredicate, Kt as admitStart, at as allIntents, v as assertConsistentPools, t as attachPreparedWorkflowExecution, Cn as awaitEvent, Sn as awaitSignal, An as awaitSignalSuspending, Wn as awaitUpdate, ze as beginAdmissionSubmissionDispatchInTransaction, Et as beginWorkflowControlDispatchInTransaction, Dt as bindWorkflowResumeJournalInTransaction, Ye as bindWorkflowStartReceipts, Ln as budgetHoldGeneration, Rn as budgetHoldKey, zn as budgetHoldSignalName, Bt as cancelQueuedWorkflowStartInTransaction, Ft as cancelSuspendedWorkflowRunInTransaction, Te as comparePendingOrder, jn as completeSuspendingSignal, It as completeWorkflowRunGenerationInTransaction, k as currentWorkflowStep, ot as deadLetterIntent, Ee as decideAdmission, y as deferringControlsOf, st as deleteIntent, fn as describeStalledRun, ct as discardIntent, lt as discardIntentInTransaction, hn as drainTick, ut as dueIntents, W as durableClock, G as durableQueue, K as durableQueueModule, Lt as enterWorkflowRunGenerationInTransaction, dt as evaluateAdmission, n as executePreparedWorkflow, e as failureMessage, A as getCurrentWorkflowExecutionId, j as getCurrentWorkflowRunId, q as getWorkflowFlowControl, o as getWorkflowJournalCipher, P as getWorkflowSchedule, J as getWorkflowVersionMetadata, Pe as handoffWorkflowFailureInTransaction, b as hasCancelOn, x as hasFlowControl, r as hasPreparedWorkflowExecution, Bn as heldBudgets, le as inMemoryWorkflowEngineLayer, Ht as inspectAdmissionSubmissionRetry, Gn as inspectWorkflow, Y as isCarrier, De as isFinishExpired, s as isSealedJournalValue, Oe as isStartExpired, gn as isUnacknowledgedSubmission, c as isWorkflowEncrypted, X as isWorkflowWorkerLayer, qt as linkExecution, Kn as makeInMemoryRecorder, L as makeReplayShapeTracker, Yn as makeWorkflowRunRecorder, En as makeWorkflowUpdateId, vn as maybeHintSuspendingSignal, Be as newAdmissionSubmissionId, Yt as newestEventAt, ke as nextSlotAt, R as nondeterminismEventPayload, Xn as normaliseWorkflowPatches, Ve as noteAdmissionSubmissionFailure, ft as noteIntentAttempt, l as openErrorText, u as openEventPayload, d as openJournalValue, f as openPayloadFields, p as openWorkflowRow, pt as parkDelayedStart, Z as patch, mt as pauseWorkflow, He as pendingAdmissionSubmissions, Vn as pendingBudgetHolds, ht as pendingSlotId, gt as pendingWindow, _t as persistDefer, Xt as planCancellations, Ae as pooledConcurrencyKey, Ue as prepareAdmissionSubmissionExecutionInTransaction, Q as processQueue, vt as pruneAdmissions, $ as queueWorker, Rt as queuedCancellationRequestsTable, ee as rateLimit, yt as readAdmissionState, We as readAdmissionSubmission, bt as readPausedWorkflows, Vt as readQueuedWorkflowCancellationInTransaction, nn as readWatermark, Ot as readWorkflowControlInTransaction, Me as readWorkflowFailureRecord, At as readWorkflowRestartObservationInTransaction, Xe as readWorkflowStartReceipt, Ze as readWorkflowStartRequest, Fe as reconcileWorkflowFailureInTransaction, xt as recordAdmission, tr as recordWorkflowExecutionRefusal, Ne as recordWorkflowFailureInTransaction, Qe as recordWorkflowStartReceipt, Ge as rejectAdmissionSubmissionInTransaction, Hn as releaseBudgetHolds, St as releaseLease, z as reportNondeterminism, Ke as reserveAdmissionSubmission, qe as reserveAdmissionSubmissionInTransaction, jt as reserveWorkflowRestartInTransaction, yn as resetSuspendHintsForTest, je as resolveAdmissionKeys, Zn as resolveRunGuardTuning, bn as resolveSuspendHintMs, Dn as resolveWorkflowMessageRun, $e as resolveWorkflowStartReceipt, Ct as resumeWorkflow, Ut as retryAdmissionSubmissionInTransaction, wt as retryDeadLetterIntent, m as sealJournalValue, On as sendWorkflowSignal, kn as sendWorkflowUpdate, Qn as serialiseWorkflowRowForWire, xn as setSuspendSignalHintMs, h as setWorkflowJournalCipher, te as sleep, ne as sleepUntil, kt as stageWorkflowParentClosureInTransaction, re as step, ie as stepIdempotencyKey, ae as stepModule, Un as suspendForBudget, Mn as suspendingSignalDeferredName, rn as sweepCancelOn, ln as sweepStalledRuns, Wt as takeAdmittedSubmissionInTransaction, Gt as takePendingAdmissionSubmission, $n as truncateWorkflowValue, g as tryOpenJournalValue, S as validateFlowControl, F as validateWorkflowSchedule, Ce as withAdmissionTransaction, oe as withCompensation, Mt as withdrawWorkflowRestartInTransaction, se as workflow, zt as workflowJournalRoutingTable, ce as workflowModule, Nt as workflowRestartRequestsTable, Pt as workflowRestartWithdrawalsTable, er as wrapWorkflowExecuteWithRunRecording, an as writeWatermark };
@@ -3,7 +3,7 @@ import { _voltroWorkflowRunsTable as n } from "./runsTable.js";
3
3
  import { _voltroWorkflowRunStepsTable as r } from "./runStepsTable.js";
4
4
  import { eq as i, or as a, queryFor as o } from "@voltro/database";
5
5
  import { types as s } from "node:util";
6
- //#region src/inspectWorkflow.ts
6
+ // src/inspectWorkflow.ts
7
7
  var c = (e) => {
8
8
  if (e == null) return null;
9
9
  if (e instanceof Date) return e;
@@ -42,7 +42,7 @@ var c = (e) => {
42
42
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = !s.isProxy(e) && Object.getPrototypeOf(e) === Array.prototype && !Object.hasOwn(e, Symbol.iterator) && e.find === Array.prototype.find, i = 0;
43
43
  for (let a of e) {
44
44
  let o = r ? Object.getOwnPropertyDescriptor(e, String(i)) : void 0;
45
- (o === void 0 || !("value" in o) || !d(a)) && (r = !1), i++;
45
+ o !== void 0 && "value" in o && d(a) || (r = !1), i++;
46
46
  let s = String(a.stepName), c = t.get(s);
47
47
  c === void 0 ? (t.set(s, [a]), n.set(s, a)) : c.push(a);
48
48
  }
@@ -97,5 +97,4 @@ var c = (e) => {
97
97
  parentClosePolicy: u(m.parentClosePolicy)
98
98
  };
99
99
  };
100
- //#endregion
101
100
  export { m as inspectWorkflow };
@@ -1,7 +1,7 @@
1
1
  import { failureMessage as e } from "./failureMessage.js";
2
2
  import { Activity as t } from "effect/workflow";
3
3
  import { Cause as n, Context as r, Effect as i, Effectable as a, Schema as o, SchemaAST as s, SchemaGetter as c, SchemaIssue as l } from "effect";
4
- //#region src/journalEncryption.ts
4
+ // src/journalEncryption.ts
5
5
  var u = () => void 0, d = (e) => {
6
6
  u = typeof e == "function" ? e : () => e;
7
7
  }, f = () => u(), p = r.Reference("@voltro/workflow/CurrentWorkflowEncrypted", { defaultValue: () => !1 }), m = { column: "workflow-journal" }, h = /* @__PURE__ */ new Set(), g = (e) => {
@@ -143,5 +143,4 @@ var u = () => void 0, d = (e) => {
143
143
  }
144
144
  return `${r instanceof Error ? r.name : typeof r}: [withheld — workflow '${t}' is declared encrypted; the full cause is recorded sealed on its row]`;
145
145
  };
146
- //#endregion
147
146
  export { p as CurrentWorkflowEncrypted, j as SEALED_DEFECT_NAME, U as STEP_JOURNAL_BINDING, m as WORKFLOW_JOURNAL_BINDING, F as anyWorkflowEncrypted, H as encryptionAwareActivity, f as getWorkflowJournalCipher, y as isQueueEncrypted, x as isSealedJournalValue, b as isWorkflowEncrypted, K as loggableCause, v as markQueueEncrypted, g as markWorkflowEncrypted, N as openDefect, R as openErrorText, V as openEventPayload, w as openJournalValue, k as openPayloadFields, G as openWorkflowRow, M as sealDefect, I as sealErrorText, B as sealEventPayload, C as sealJournalValue, A as sealPayloadFields, D as sealedPayloadFields, E as sealedSchema, d as setWorkflowJournalCipher, L as tryOpenJournalValue };
@@ -0,0 +1,49 @@
1
+ import { Context as e, Deferred as t, Effect as n, Option as r, Schedule as i, Semaphore as a } from "effect";
2
+ // src/journalRoutingGuard.ts
3
+ var o = (e) => n.gen(function* () {
4
+ let r = e.pollMs ?? 1e3, o = e.verify;
5
+ if (!Number.isSafeInteger(r) || r < 1 || r > 3e4) return yield* n.fail(/* @__PURE__ */ Error("Invalid journal routing probe interval"));
6
+ let s = yield* t.make(), c = /* @__PURE__ */ new Set(), l = yield* a.make(1), u = !1, d = (e) => n.gen(function* () {
7
+ u = !0, yield* t.fail(s, Error(e));
8
+ }), f = l.withPermits(1)(n.gen(function* () {
9
+ if (u) return yield* t.await(s);
10
+ let e = yield* n.interruptible(o).pipe(n.timeout(r), n.isSuccess);
11
+ if (u) return yield* t.await(s);
12
+ if (!e) return yield* d("Journal routing lock ownership was lost"), yield* t.await(s);
13
+ })), p = (e) => n.uninterruptibleMask((r) => n.gen(function* () {
14
+ if (u) return yield* t.await(s);
15
+ let i = yield* t.make();
16
+ return c.add(i), yield* r(f.pipe(n.andThen(n.suspend(() => u ? t.await(s) : n.raceFirst(e, n.interruptible(t.await(s))))))).pipe(n.ensuring(n.gen(function* () {
17
+ c.delete(i), yield* t.succeed(i, void 0);
18
+ })));
19
+ })), m = (e) => n.uninterruptibleMask((r) => n.gen(function* () {
20
+ if (u) return yield* t.await(s);
21
+ let i = yield* t.make();
22
+ c.add(i);
23
+ let a = new AbortController(), o = Promise.resolve().then(() => {
24
+ if (u) throw Error("Journal routing admission is closed");
25
+ return e(a.signal);
26
+ });
27
+ return yield* r(n.tryPromise({
28
+ try: () => o,
29
+ catch: (e) => e
30
+ })).pipe(n.ensuring(n.gen(function* () {
31
+ a.abort(), yield* n.promise(() => o.then(() => void 0, () => void 0)), c.delete(i), yield* t.succeed(i, void 0);
32
+ })));
33
+ })), h = n.gen(function* () {
34
+ yield* d("Journal routing admission is closed"), yield* n.forEach([...c], (e) => t.await(e), { discard: !0 });
35
+ });
36
+ return yield* n.addFinalizer(() => h), yield* f.pipe(n.ignore, n.repeat(i.spaced(r)), n.forkScoped), {
37
+ run: p,
38
+ ownPromise: m,
39
+ check: f,
40
+ close: h,
41
+ isClosed: () => u
42
+ };
43
+ }), s = e.Service("@voltro/workflow/JournalRoutingGuard"), c = (e, t) => e === void 0 ? t : n.gen(function* () {
44
+ return yield* yield* e.run(n.exit(t.pipe(n.provideService(s, e)))).pipe(n.orDie);
45
+ }), l = (e) => n.flatMap(n.serviceOption(s), (t) => r.isSome(t) ? t.value.ownPromise(e).pipe(n.orDie) : n.promise(e)), u = (e) => n.flatMap(n.serviceOption(s), (t) => r.isSome(t) ? t.value.ownPromise(e) : n.tryPromise({
46
+ try: e,
47
+ catch: (e) => e
48
+ }));
49
+ export { s as JournalRoutingGuard, o as makeJournalRoutingGuard, l as ownedJournalRoutingPromise, c as protectJournalRoutingEffect, u as tryOwnedJournalRoutingPromise };
@@ -0,0 +1,46 @@
1
+ // src/journalRoutingLayout.ts
2
+ var e = (e) => {
3
+ if (e !== "default" && e !== "api-workloads-v1") throw Error("Unknown journal routing layout");
4
+ let t = e === "api-workloads-v1";
5
+ return Object.freeze({
6
+ id: e,
7
+ workflowGroup: "default",
8
+ webhookGroup: t ? "voltro.webhooks" : "default",
9
+ cronGroup: t ? "voltro.schedules" : "default",
10
+ available: Object.freeze(t ? [
11
+ "default",
12
+ "voltro.webhooks",
13
+ "voltro.schedules"
14
+ ] : ["default"])
15
+ });
16
+ }, t = (t, n) => {
17
+ let r = e(t), i = e(n), a = [];
18
+ return r.webhookGroup !== i.webhookGroup && a.push({
19
+ entity: "workflow",
20
+ name: "voltro.deliverWebhook",
21
+ from: r.webhookGroup,
22
+ to: i.webhookGroup
23
+ }), r.cronGroup !== i.cronGroup && a.push({
24
+ entity: "cron",
25
+ name: "*",
26
+ from: r.cronGroup,
27
+ to: i.cronGroup
28
+ }), Object.freeze(a.map((e) => Object.freeze(e)));
29
+ }, n = (t, n) => {
30
+ let r = e(t);
31
+ return n === "voltro.deliverWebhook" ? r.webhookGroup : r.workflowGroup;
32
+ }, r = (t, n) => {
33
+ let r = e(t), i = [
34
+ n.workflows,
35
+ n.schedules,
36
+ n.webhooks
37
+ ];
38
+ if (i.some((e) => typeof e != "boolean")) throw Error("Explicit executor selection is required");
39
+ if (t === "default" && i.some(Boolean) && !i.every(Boolean)) throw Error("Separate executor roles require the api-workloads-v1 journal routing transition");
40
+ let a = /* @__PURE__ */ new Set();
41
+ return n.workflows && a.add(r.workflowGroup), n.schedules && a.add(r.cronGroup), n.webhooks && a.add(r.webhookGroup), Object.freeze({
42
+ available: r.available,
43
+ assigned: Object.freeze([...a])
44
+ });
45
+ };
46
+ export { r as journalExecutorGroups, e as journalRoutingLayout, t as journalRoutingTransitions, n as journalWorkflowGroup };