@voltro/workflow 0.84.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 (89) hide show
  1. package/CHANGELOG.md +1215 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -151
  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.d.ts +304 -280
  16. package/dist/cluster.js +8 -2
  17. package/dist/clusterCron.js +11 -0
  18. package/dist/clusterDiagnostics.js +20 -0
  19. package/dist/clusterDiagnosticsSql.js +145 -0
  20. package/dist/clusterLayer.js +110 -0
  21. package/dist/clusterMigrationGate.js +61 -0
  22. package/dist/clusterRunnerLayer.js +21 -0
  23. package/dist/clusterTestSuite.d.ts +11 -11
  24. package/dist/clusterTestSuite.js +257 -257
  25. package/dist/controlMonitor.js +13 -0
  26. package/dist/controlRequest.js +367 -0
  27. package/dist/executionRefusal.js +162 -0
  28. package/dist/failureHandoff.js +183 -0
  29. package/dist/failureMessage.js +12 -0
  30. package/dist/failureRecovery.js +50 -0
  31. package/dist/failureReportStore.js +60 -0
  32. package/dist/flowControl.js +142 -0
  33. package/dist/forwardStartReceipts.js +41 -0
  34. package/dist/inMemoryLayer.js +7 -0
  35. package/dist/inMemoryRecorder.js +56 -0
  36. package/dist/index.d.ts +456 -360
  37. package/dist/index.js +49 -5
  38. package/dist/inspectWorkflow.js +101 -0
  39. package/dist/journalEncryption.js +147 -0
  40. package/dist/messages.js +92 -0
  41. package/dist/nondeterminism.js +51 -0
  42. package/dist/parentClosure.js +141 -0
  43. package/dist/parentClosureRecovery.js +54 -0
  44. package/dist/pendingSubmission.js +85 -0
  45. package/dist/prepareSubmissionDispatch.js +17 -0
  46. package/dist/preparedExecution.js +14 -0
  47. package/dist/primitives.d.ts +56 -31
  48. package/dist/primitives.js +225 -2
  49. package/dist/queuedCancellationRequest.js +364 -0
  50. package/dist/queuedControl.js +21 -0
  51. package/dist/recorder.js +11 -0
  52. package/dist/residentExecutionEvidence.js +64 -0
  53. package/dist/retryPolicy.js +57 -0
  54. package/dist/runEventsTable.js +17 -0
  55. package/dist/runGeneration.js +345 -0
  56. package/dist/runRecording.js +615 -0
  57. package/dist/runStepsTable.js +28 -0
  58. package/dist/runnerStorageGuard.js +29 -0
  59. package/dist/runsTable.js +42 -0
  60. package/dist/scheduleDeclaration.js +44 -0
  61. package/dist/signalHint.js +23 -0
  62. package/dist/signals.js +70 -0
  63. package/dist/signalsSuspending.js +57 -0
  64. package/dist/sqliteWorkflowOwnership.js +26 -0
  65. package/dist/stalenessSweep.js +191 -0
  66. package/dist/startContextsTable.js +20 -0
  67. package/dist/startReceipt.js +143 -0
  68. package/dist/submissionRecovery.js +122 -0
  69. package/dist/submissionRejection.js +10 -0
  70. package/dist/submissionRetry.js +71 -0
  71. package/dist/suspensionUnavailable.js +9 -0
  72. package/dist/updates.js +87 -0
  73. package/dist/watermarkTable.js +9 -0
  74. package/dist/webCrypto.js +17 -0
  75. package/dist/workflowDelivery.js +24 -0
  76. package/dist/workflowJournal.js +124 -0
  77. package/dist/workflowJournalReset.js +111 -0
  78. package/dist/workflowReadSelections.js +12 -0
  79. package/dist/workflowRestartDispatch.js +29 -0
  80. package/dist/workflowRestartObservation.js +60 -0
  81. package/dist/workflowRestartPreparation.js +109 -0
  82. package/dist/workflowRestartReservation.js +426 -0
  83. package/dist/workflowResumeDispatch.js +29 -0
  84. package/package.json +6 -9
  85. package/dist/cluster-i3frC3Da.js +0 -646
  86. package/dist/clusterDiagnostics-CGUtnJkX.js +0 -2084
  87. package/dist/journalEncryption--n5VDdYO.js +0 -148
  88. package/dist/primitives-Btjhjm8P.js +0 -483
  89. package/dist/src-DP-lKqaG.js +0 -3867
package/dist/index.d.ts CHANGED
@@ -2,28 +2,28 @@ import { Cause } from 'effect';
2
2
  import { ColumnBuilder } from '@voltro/database';
3
3
  import { Context } from 'effect';
4
4
  import { DataStore } from '@voltro/database';
5
- import { DurableClock as durableClock } from '@effect/workflow';
6
- import { DurableQueue as durableQueueModule } from '@effect/workflow';
7
- import { DurableRateLimiter as durableRateLimiterModule } from '@effect/workflow';
5
+ import { DurableClock as durableClock } from 'effect/workflow';
6
+ import { DurableQueue as durableQueueModule } from 'effect/workflow';
8
7
  import { Duration } from 'effect';
9
8
  import { Effect } from 'effect';
10
- import { FiberRef } from 'effect';
11
9
  import { FieldBinding } from '@voltro/database';
12
10
  import { FieldCipher } from '@voltro/database';
13
11
  import { FieldDefinitions } from '@voltro/database';
14
12
  import { Layer } from 'effect';
15
- import { ParseResult } from 'effect';
13
+ import { Predicate } from '@voltro/database';
16
14
  import { QueryDescriptor } from '@voltro/database';
15
+ import { RateLimiter } from 'effect/persistence';
17
16
  import { Row } from '@voltro/database';
18
17
  import { Schema } from 'effect';
19
18
  import { SchemaTable } from '@voltro/database';
20
- import { Activity as stepModule } from '@effect/workflow';
19
+ import { Activity as stepModule } from 'effect/workflow';
21
20
  import { Subject } from '@voltro/protocol';
22
21
  import { Table } from '@voltro/database';
23
22
  import { TableLike } from '@voltro/database';
24
23
  import { WorkflowAccessOptions } from '@voltro/protocol';
25
- import { WorkflowEngine } from '@effect/workflow';
26
- import { Workflow as workflowModule } from '@effect/workflow';
24
+ import { WorkflowEngine } from 'effect/workflow';
25
+ import { WorkflowInstance } from 'effect/workflow/WorkflowEngine';
26
+ import { Workflow as workflowModule } from 'effect/workflow';
27
27
  import { WorkflowParentClosePolicy } from '@voltro/protocol';
28
28
  import { WorkflowQueuedCancellationResult } from '@voltro/protocol';
29
29
  import { WorkflowRestartObservation } from '@voltro/protocol';
@@ -96,8 +96,8 @@ export declare type AdmissionDecision = {
96
96
  readonly deadlineAt?: number;
97
97
  /** `'replace'` — one pending row per key, newest payload wins (debounce).
98
98
  * `'append'` — one row per item, they accumulate (batch).
99
- * `'hold'` — the row already exists and only its `dueAt` moves
100
- * (throttle / concurrency / paused re-checks). */
99
+ * `'hold'` — retain the existing row; persist only a changed future
100
+ * deadline (throttle / concurrency / paused re-checks). */
101
101
  readonly collapse: 'replace' | 'append' | 'hold';
102
102
  readonly keys: AdmissionKeys;
103
103
  } | {
@@ -220,6 +220,11 @@ export declare interface AdmissionKeys {
220
220
  readonly priority: number;
221
221
  }
222
222
 
223
+ /** Unknown acceptance cannot expire into proof of spare capacity. Only an
224
+ * acknowledged execution uses the ordinary crash backstop. Share this rule
225
+ * between admission decisions and read-only capacity observations. */
226
+ export declare const admissionLeaseHeldPredicate: (now: number) => Predicate;
227
+
223
228
  export declare const ADMISSIONS_TABLE = "_voltro_workflow_admissions";
224
229
 
225
230
  /** What the store observed for these keys. Every field optional: the store only
@@ -257,6 +262,31 @@ export declare interface AdmissionState {
257
262
  * or a batch that has accumulated additional items. */
258
263
  export declare type AdmissionSubmission = typeof SubmissionSchema.Type;
259
264
 
265
+ export declare type AdmissionSubmissionRetryInspection = {
266
+ readonly kind: 'eligible';
267
+ readonly submissionId: string;
268
+ readonly expected: AdmissionSubmissionRetryToken;
269
+ } | {
270
+ readonly kind: 'refused';
271
+ readonly submissionId: string;
272
+ readonly reason: AdmissionSubmissionRetryRefusal;
273
+ };
274
+
275
+ export declare type AdmissionSubmissionRetryRefusal = 'missing-submission' | 'incomplete-transfer' | 'accepted' | 'rejected' | 'prepared-execution' | 'dispatch-attempted' | 'not-stopped' | 'changed-retry' | 'missing-lease' | 'foreign-lease' | 'released-lease' | 'bound-lease';
276
+
277
+ export declare type AdmissionSubmissionRetryResult = {
278
+ readonly kind: 'retried' | 'already-retried';
279
+ readonly submissionId: string;
280
+ readonly expected: AdmissionSubmissionRetryToken;
281
+ } | Extract<AdmissionSubmissionRetryInspection, {
282
+ kind: 'refused';
283
+ }>;
284
+
285
+ export declare interface AdmissionSubmissionRetryToken {
286
+ readonly attempts: number;
287
+ readonly stoppedAt: number;
288
+ }
289
+
260
290
  /** What the caller learns about a start that went through flow control. */
261
291
  export declare type AdmissionVerdict = {
262
292
  /** Start it now. The ledger row is already written; call `linkExecution`
@@ -384,7 +414,7 @@ export declare const attachPreparedWorkflowExecution: (definition: object, execu
384
414
  * Journaled like every other activity: once it has matched, a replay returns the
385
415
  * matched event from the journal without re-reading anything.
386
416
  */
387
- export declare const awaitEvent: <A>(ctx: AwaitEventCtx, options: AwaitEventOptions<A>) => Effect.Effect<A, Cause.UnknownException | ParseResult.ParseError>;
417
+ export declare const awaitEvent: <A>(ctx: AwaitEventCtx, options: AwaitEventOptions<A>) => Effect.Effect<A, Cause.UnknownError | Schema.SchemaError>;
388
418
 
389
419
  /** The slice of `ctx.store` this needs — the same shape `awaitSignal` takes, so
390
420
  * a full `AppContext` store is assignable without a cast. */
@@ -406,7 +436,7 @@ export declare interface AwaitEventOptions<A> {
406
436
  /** Parsed against the event's payload. A parse failure fails the activity
407
437
  * rather than matching — a correlated event whose SHAPE is wrong is a bug in
408
438
  * the publisher, and silently skipping it would hide that. */
409
- readonly schema: Schema.Schema<A, any>;
439
+ readonly schema: Schema.Codec<A, any>;
410
440
  /**
411
441
  * Does this event belong to this run?
412
442
  *
@@ -463,7 +493,7 @@ export declare interface AwaitEventOptions<A> {
463
493
  * From the dashboard, click "Send signal" on the run row and pick
464
494
  * `approval` with a JSON body matching the schema.
465
495
  */
466
- export declare const awaitSignal: <A>(ctx: AwaitSignalCtx, options: AwaitSignalOptions<A>) => Effect.Effect<A, Cause.UnknownException | ParseResult.ParseError>;
496
+ export declare const awaitSignal: <A>(ctx: AwaitSignalCtx, options: AwaitSignalOptions<A>) => Effect.Effect<A, Cause.UnknownError | Schema.SchemaError>;
467
497
 
468
498
  /** The slice of `ctx.store` awaitSignal needs — just `query`, typed against
469
499
  * the real `QueryDescriptor` so a full `AppContext` store (`DataStore`) is
@@ -484,7 +514,7 @@ export declare interface AwaitSignalOptions<A> {
484
514
  /** Schema the incoming payload is parsed against. Parse failures
485
515
  * fail the activity with a typed error (the schema's ParseError);
486
516
  * fix the sender's payload shape and re-send. */
487
- readonly schema: Schema.Schema<A, any>;
517
+ readonly schema: Schema.Codec<A, any>;
488
518
  /** Initial poll interval in milliseconds. Default 200 ms — gives
489
519
  * sub-second wake for fresh signals. Subsequent polls back off
490
520
  * exponentially up to `maxPollIntervalMs`. */
@@ -518,7 +548,7 @@ export declare interface AwaitSignalOptions<A> {
518
548
  * interchangeable in a body); the suspending variant reads the durable
519
549
  * deferred, not `ctx.store`.
520
550
  */
521
- export declare const awaitSignalSuspending: <A>(ctx: AwaitSignalCtx, options: AwaitSignalSuspendingOptions<A>) => Effect.Effect<A, ParseResult.ParseError>;
551
+ export declare const awaitSignalSuspending: <A>(ctx: AwaitSignalCtx, options: AwaitSignalSuspendingOptions<A>) => Effect.Effect<A, Schema.SchemaError>;
522
552
 
523
553
  export declare interface AwaitSignalSuspendingOptions<A> {
524
554
  /** Caller-chosen signal name. The external completer targets this exact
@@ -526,7 +556,7 @@ export declare interface AwaitSignalSuspendingOptions<A> {
526
556
  readonly name: string;
527
557
  /** Schema the incoming payload is decoded against. A decode failure fails
528
558
  * the workflow with the schema's `ParseError`. */
529
- readonly schema: Schema.Schema<A, any>;
559
+ readonly schema: Schema.Codec<A, any>;
530
560
  /** Max time to wait before failing the workflow. Default 24 h. The timeout
531
561
  * is itself durable (a raced `DurableClock`), so a long wait frees the
532
562
  * runner too. Pass `Number.POSITIVE_INFINITY` for an unbounded wait. */
@@ -547,8 +577,8 @@ export declare interface AwaitUpdateCtx {
547
577
 
548
578
  export declare interface AwaitUpdateOptions<A, B = A> {
549
579
  readonly name: string;
550
- readonly schema: Schema.Schema<A, any>;
551
- readonly success?: Schema.Schema<B, any>;
580
+ readonly schema: Schema.Codec<A, any>;
581
+ readonly success?: Schema.Codec<B, any>;
552
582
  readonly handle?: (payload: A) => Effect.Effect<B, unknown, never>;
553
583
  readonly pollIntervalMs?: number;
554
584
  readonly maxPollIntervalMs?: number;
@@ -557,6 +587,9 @@ export declare interface AwaitUpdateOptions<A, B = A> {
557
587
 
558
588
  /** Persist BEFORE calling the engine. Failed acknowledgements and process
559
589
  * death must leave evidence that an earlier call could have been accepted.
590
+ * The first dispatch starts the original finite lease interval: time spent
591
+ * waiting before engine I/O must not consume the running crash backstop.
592
+ * Later attempts retain that first deadline, including after a lost ACK.
560
593
  * Return null when this source is no longer dispatchable. Database-only;
561
594
  * the returned attempt number fences a later permanent-rejection decision. */
562
595
  export declare const beginAdmissionSubmissionDispatchInTransaction: (tx: Pick<DataStore, "query" | "update">, id: string, now: number) => Promise<AdmissionSubmission | null>;
@@ -570,31 +603,25 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
570
603
  kind: "settled";
571
604
  request: {
572
605
  readonly id: string;
573
- readonly cause?: {
574
- readonly detail?: {
575
- readonly [x: string]: unknown;
576
- } | undefined;
577
- readonly reason: string;
578
- } | null | undefined;
579
606
  readonly result: {
580
- readonly status: "failed" | "cancelled" | "succeeded";
581
607
  readonly kind: "confirmed" | "already-terminal";
608
+ readonly status: "failed" | "cancelled" | "succeeded";
609
+ readonly completedAt: number;
582
610
  readonly output: unknown;
583
- readonly errorMessage: string | null;
584
611
  readonly errorTag: string | null;
585
- readonly completedAt: number;
612
+ readonly errorMessage: string | null;
586
613
  } | {
587
- readonly status: "running";
588
614
  readonly kind: "confirmed";
589
- readonly generation: string;
615
+ readonly status: "running";
590
616
  readonly enteredAt: number;
617
+ readonly generation: string;
591
618
  } | null;
619
+ readonly operation: "resume" | "cancel" | "terminate";
592
620
  readonly generation: string;
593
621
  readonly runId: string;
594
622
  readonly requestedAt: number;
595
623
  readonly executionId: string;
596
624
  readonly workflowName: string;
597
- readonly operation: "resume" | "cancel" | "terminate";
598
625
  readonly dispatchAttempts: number;
599
626
  readonly owner: {
600
627
  readonly tenantId: string | null;
@@ -604,37 +631,37 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
604
631
  readonly replyId: string;
605
632
  readonly restartToken: string | null;
606
633
  } | null;
634
+ readonly cause?: {
635
+ readonly reason: string;
636
+ readonly detail?: {
637
+ readonly [x: string]: unknown;
638
+ } | undefined;
639
+ } | null | undefined;
607
640
  };
608
641
  run?: never;
609
642
  } | {
610
643
  kind: "unknown";
611
644
  request: {
612
645
  readonly id: string;
613
- readonly cause?: {
614
- readonly detail?: {
615
- readonly [x: string]: unknown;
616
- } | undefined;
617
- readonly reason: string;
618
- } | null | undefined;
619
646
  readonly result: {
620
- readonly status: "failed" | "cancelled" | "succeeded";
621
647
  readonly kind: "confirmed" | "already-terminal";
648
+ readonly status: "failed" | "cancelled" | "succeeded";
649
+ readonly completedAt: number;
622
650
  readonly output: unknown;
623
- readonly errorMessage: string | null;
624
651
  readonly errorTag: string | null;
625
- readonly completedAt: number;
652
+ readonly errorMessage: string | null;
626
653
  } | {
627
- readonly status: "running";
628
654
  readonly kind: "confirmed";
629
- readonly generation: string;
655
+ readonly status: "running";
630
656
  readonly enteredAt: number;
657
+ readonly generation: string;
631
658
  } | null;
659
+ readonly operation: "resume" | "cancel" | "terminate";
632
660
  readonly generation: string;
633
661
  readonly runId: string;
634
662
  readonly requestedAt: number;
635
663
  readonly executionId: string;
636
664
  readonly workflowName: string;
637
- readonly operation: "resume" | "cancel" | "terminate";
638
665
  readonly dispatchAttempts: number;
639
666
  readonly owner: {
640
667
  readonly tenantId: string | null;
@@ -644,37 +671,37 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
644
671
  readonly replyId: string;
645
672
  readonly restartToken: string | null;
646
673
  } | null;
674
+ readonly cause?: {
675
+ readonly reason: string;
676
+ readonly detail?: {
677
+ readonly [x: string]: unknown;
678
+ } | undefined;
679
+ } | null | undefined;
647
680
  };
648
681
  run?: never;
649
682
  } | {
650
683
  kind: "superseded";
651
684
  request: {
652
685
  readonly id: string;
653
- readonly cause?: {
654
- readonly detail?: {
655
- readonly [x: string]: unknown;
656
- } | undefined;
657
- readonly reason: string;
658
- } | null | undefined;
659
686
  readonly result: {
660
- readonly status: "failed" | "cancelled" | "succeeded";
661
687
  readonly kind: "confirmed" | "already-terminal";
688
+ readonly status: "failed" | "cancelled" | "succeeded";
689
+ readonly completedAt: number;
662
690
  readonly output: unknown;
663
- readonly errorMessage: string | null;
664
691
  readonly errorTag: string | null;
665
- readonly completedAt: number;
692
+ readonly errorMessage: string | null;
666
693
  } | {
667
- readonly status: "running";
668
694
  readonly kind: "confirmed";
669
- readonly generation: string;
695
+ readonly status: "running";
670
696
  readonly enteredAt: number;
697
+ readonly generation: string;
671
698
  } | null;
699
+ readonly operation: "resume" | "cancel" | "terminate";
672
700
  readonly generation: string;
673
701
  readonly runId: string;
674
702
  readonly requestedAt: number;
675
703
  readonly executionId: string;
676
704
  readonly workflowName: string;
677
- readonly operation: "resume" | "cancel" | "terminate";
678
705
  readonly dispatchAttempts: number;
679
706
  readonly owner: {
680
707
  readonly tenantId: string | null;
@@ -684,37 +711,37 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
684
711
  readonly replyId: string;
685
712
  readonly restartToken: string | null;
686
713
  } | null;
714
+ readonly cause?: {
715
+ readonly reason: string;
716
+ readonly detail?: {
717
+ readonly [x: string]: unknown;
718
+ } | undefined;
719
+ } | null | undefined;
687
720
  };
688
721
  run?: never;
689
722
  } | {
690
723
  kind: "already-terminal";
691
724
  request: {
692
725
  readonly id: string;
693
- readonly cause?: {
694
- readonly detail?: {
695
- readonly [x: string]: unknown;
696
- } | undefined;
697
- readonly reason: string;
698
- } | null | undefined;
699
726
  readonly result: {
700
- readonly status: "failed" | "cancelled" | "succeeded";
701
727
  readonly kind: "confirmed" | "already-terminal";
728
+ readonly status: "failed" | "cancelled" | "succeeded";
729
+ readonly completedAt: number;
702
730
  readonly output: unknown;
703
- readonly errorMessage: string | null;
704
731
  readonly errorTag: string | null;
705
- readonly completedAt: number;
732
+ readonly errorMessage: string | null;
706
733
  } | {
707
- readonly status: "running";
708
734
  readonly kind: "confirmed";
709
- readonly generation: string;
735
+ readonly status: "running";
710
736
  readonly enteredAt: number;
737
+ readonly generation: string;
711
738
  } | null;
739
+ readonly operation: "resume" | "cancel" | "terminate";
712
740
  readonly generation: string;
713
741
  readonly runId: string;
714
742
  readonly requestedAt: number;
715
743
  readonly executionId: string;
716
744
  readonly workflowName: string;
717
- readonly operation: "resume" | "cancel" | "terminate";
718
745
  readonly dispatchAttempts: number;
719
746
  readonly owner: {
720
747
  readonly tenantId: string | null;
@@ -724,6 +751,12 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
724
751
  readonly replyId: string;
725
752
  readonly restartToken: string | null;
726
753
  } | null;
754
+ readonly cause?: {
755
+ readonly reason: string;
756
+ readonly detail?: {
757
+ readonly [x: string]: unknown;
758
+ } | undefined;
759
+ } | null | undefined;
727
760
  };
728
761
  run: Readonly<Record<string, unknown>>;
729
762
  } | {
@@ -731,31 +764,25 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
731
764
  request: {
732
765
  dispatchAttempts: number;
733
766
  id: string;
734
- cause?: {
735
- readonly detail?: {
736
- readonly [x: string]: unknown;
737
- } | undefined;
738
- readonly reason: string;
739
- } | null | undefined;
740
767
  result: {
741
- readonly status: "failed" | "cancelled" | "succeeded";
742
768
  readonly kind: "confirmed" | "already-terminal";
769
+ readonly status: "failed" | "cancelled" | "succeeded";
770
+ readonly completedAt: number;
743
771
  readonly output: unknown;
744
- readonly errorMessage: string | null;
745
772
  readonly errorTag: string | null;
746
- readonly completedAt: number;
773
+ readonly errorMessage: string | null;
747
774
  } | {
748
- readonly status: "running";
749
775
  readonly kind: "confirmed";
750
- readonly generation: string;
776
+ readonly status: "running";
751
777
  readonly enteredAt: number;
778
+ readonly generation: string;
752
779
  } | null;
780
+ operation: "resume" | "cancel" | "terminate";
753
781
  generation: string;
754
782
  runId: string;
755
783
  requestedAt: number;
756
784
  executionId: string;
757
785
  workflowName: string;
758
- operation: "resume" | "cancel" | "terminate";
759
786
  owner: {
760
787
  readonly tenantId: string | null;
761
788
  } | null;
@@ -764,6 +791,12 @@ export declare const beginWorkflowControlDispatchInTransaction: (tx: Store, id:
764
791
  readonly replyId: string;
765
792
  readonly restartToken: string | null;
766
793
  } | null;
794
+ cause?: {
795
+ readonly reason: string;
796
+ readonly detail?: {
797
+ readonly [x: string]: unknown;
798
+ } | undefined;
799
+ } | null | undefined;
767
800
  };
768
801
  run?: never;
769
802
  }>;
@@ -781,31 +814,25 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
781
814
  kind: "settled";
782
815
  request: {
783
816
  readonly id: string;
784
- readonly cause?: {
785
- readonly detail?: {
786
- readonly [x: string]: unknown;
787
- } | undefined;
788
- readonly reason: string;
789
- } | null | undefined;
790
817
  readonly result: {
791
- readonly status: "failed" | "cancelled" | "succeeded";
792
818
  readonly kind: "confirmed" | "already-terminal";
819
+ readonly status: "failed" | "cancelled" | "succeeded";
820
+ readonly completedAt: number;
793
821
  readonly output: unknown;
794
- readonly errorMessage: string | null;
795
822
  readonly errorTag: string | null;
796
- readonly completedAt: number;
823
+ readonly errorMessage: string | null;
797
824
  } | {
798
- readonly status: "running";
799
825
  readonly kind: "confirmed";
800
- readonly generation: string;
826
+ readonly status: "running";
801
827
  readonly enteredAt: number;
828
+ readonly generation: string;
802
829
  } | null;
830
+ readonly operation: "resume" | "cancel" | "terminate";
803
831
  readonly generation: string;
804
832
  readonly runId: string;
805
833
  readonly requestedAt: number;
806
834
  readonly executionId: string;
807
835
  readonly workflowName: string;
808
- readonly operation: "resume" | "cancel" | "terminate";
809
836
  readonly dispatchAttempts: number;
810
837
  readonly owner: {
811
838
  readonly tenantId: string | null;
@@ -815,36 +842,36 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
815
842
  readonly replyId: string;
816
843
  readonly restartToken: string | null;
817
844
  } | null;
818
- };
819
- } | {
820
- kind: "unknown";
821
- request: {
822
- readonly id: string;
823
845
  readonly cause?: {
846
+ readonly reason: string;
824
847
  readonly detail?: {
825
848
  readonly [x: string]: unknown;
826
849
  } | undefined;
827
- readonly reason: string;
828
850
  } | null | undefined;
851
+ };
852
+ } | {
853
+ kind: "unknown";
854
+ request: {
855
+ readonly id: string;
829
856
  readonly result: {
830
- readonly status: "failed" | "cancelled" | "succeeded";
831
857
  readonly kind: "confirmed" | "already-terminal";
858
+ readonly status: "failed" | "cancelled" | "succeeded";
859
+ readonly completedAt: number;
832
860
  readonly output: unknown;
833
- readonly errorMessage: string | null;
834
861
  readonly errorTag: string | null;
835
- readonly completedAt: number;
862
+ readonly errorMessage: string | null;
836
863
  } | {
837
- readonly status: "running";
838
864
  readonly kind: "confirmed";
839
- readonly generation: string;
865
+ readonly status: "running";
840
866
  readonly enteredAt: number;
867
+ readonly generation: string;
841
868
  } | null;
869
+ readonly operation: "resume" | "cancel" | "terminate";
842
870
  readonly generation: string;
843
871
  readonly runId: string;
844
872
  readonly requestedAt: number;
845
873
  readonly executionId: string;
846
874
  readonly workflowName: string;
847
- readonly operation: "resume" | "cancel" | "terminate";
848
875
  readonly dispatchAttempts: number;
849
876
  readonly owner: {
850
877
  readonly tenantId: string | null;
@@ -854,36 +881,36 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
854
881
  readonly replyId: string;
855
882
  readonly restartToken: string | null;
856
883
  } | null;
857
- };
858
- } | {
859
- kind: "superseded";
860
- request: {
861
- readonly id: string;
862
884
  readonly cause?: {
885
+ readonly reason: string;
863
886
  readonly detail?: {
864
887
  readonly [x: string]: unknown;
865
888
  } | undefined;
866
- readonly reason: string;
867
889
  } | null | undefined;
890
+ };
891
+ } | {
892
+ kind: "superseded";
893
+ request: {
894
+ readonly id: string;
868
895
  readonly result: {
869
- readonly status: "failed" | "cancelled" | "succeeded";
870
896
  readonly kind: "confirmed" | "already-terminal";
897
+ readonly status: "failed" | "cancelled" | "succeeded";
898
+ readonly completedAt: number;
871
899
  readonly output: unknown;
872
- readonly errorMessage: string | null;
873
900
  readonly errorTag: string | null;
874
- readonly completedAt: number;
901
+ readonly errorMessage: string | null;
875
902
  } | {
876
- readonly status: "running";
877
903
  readonly kind: "confirmed";
878
- readonly generation: string;
904
+ readonly status: "running";
879
905
  readonly enteredAt: number;
906
+ readonly generation: string;
880
907
  } | null;
908
+ readonly operation: "resume" | "cancel" | "terminate";
881
909
  readonly generation: string;
882
910
  readonly runId: string;
883
911
  readonly requestedAt: number;
884
912
  readonly executionId: string;
885
913
  readonly workflowName: string;
886
- readonly operation: "resume" | "cancel" | "terminate";
887
914
  readonly dispatchAttempts: number;
888
915
  readonly owner: {
889
916
  readonly tenantId: string | null;
@@ -893,36 +920,36 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
893
920
  readonly replyId: string;
894
921
  readonly restartToken: string | null;
895
922
  } | null;
896
- };
897
- } | {
898
- kind: "not-suspended";
899
- request: {
900
- readonly id: string;
901
923
  readonly cause?: {
924
+ readonly reason: string;
902
925
  readonly detail?: {
903
926
  readonly [x: string]: unknown;
904
927
  } | undefined;
905
- readonly reason: string;
906
928
  } | null | undefined;
929
+ };
930
+ } | {
931
+ kind: "not-suspended";
932
+ request: {
933
+ readonly id: string;
907
934
  readonly result: {
908
- readonly status: "failed" | "cancelled" | "succeeded";
909
935
  readonly kind: "confirmed" | "already-terminal";
936
+ readonly status: "failed" | "cancelled" | "succeeded";
937
+ readonly completedAt: number;
910
938
  readonly output: unknown;
911
- readonly errorMessage: string | null;
912
939
  readonly errorTag: string | null;
913
- readonly completedAt: number;
940
+ readonly errorMessage: string | null;
914
941
  } | {
915
- readonly status: "running";
916
942
  readonly kind: "confirmed";
917
- readonly generation: string;
943
+ readonly status: "running";
918
944
  readonly enteredAt: number;
945
+ readonly generation: string;
919
946
  } | null;
947
+ readonly operation: "resume" | "cancel" | "terminate";
920
948
  readonly generation: string;
921
949
  readonly runId: string;
922
950
  readonly requestedAt: number;
923
951
  readonly executionId: string;
924
952
  readonly workflowName: string;
925
- readonly operation: "resume" | "cancel" | "terminate";
926
953
  readonly dispatchAttempts: number;
927
954
  readonly owner: {
928
955
  readonly tenantId: string | null;
@@ -932,36 +959,36 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
932
959
  readonly replyId: string;
933
960
  readonly restartToken: string | null;
934
961
  } | null;
935
- };
936
- } | {
937
- kind: "bound";
938
- request: {
939
- readonly id: string;
940
962
  readonly cause?: {
963
+ readonly reason: string;
941
964
  readonly detail?: {
942
965
  readonly [x: string]: unknown;
943
966
  } | undefined;
944
- readonly reason: string;
945
967
  } | null | undefined;
968
+ };
969
+ } | {
970
+ kind: "bound";
971
+ request: {
972
+ readonly id: string;
946
973
  readonly result: {
947
- readonly status: "failed" | "cancelled" | "succeeded";
948
974
  readonly kind: "confirmed" | "already-terminal";
975
+ readonly status: "failed" | "cancelled" | "succeeded";
976
+ readonly completedAt: number;
949
977
  readonly output: unknown;
950
- readonly errorMessage: string | null;
951
978
  readonly errorTag: string | null;
952
- readonly completedAt: number;
979
+ readonly errorMessage: string | null;
953
980
  } | {
954
- readonly status: "running";
955
981
  readonly kind: "confirmed";
956
- readonly generation: string;
982
+ readonly status: "running";
957
983
  readonly enteredAt: number;
984
+ readonly generation: string;
958
985
  } | null;
986
+ readonly operation: "resume" | "cancel" | "terminate";
959
987
  readonly generation: string;
960
988
  readonly runId: string;
961
989
  readonly requestedAt: number;
962
990
  readonly executionId: string;
963
991
  readonly workflowName: string;
964
- readonly operation: "resume" | "cancel" | "terminate";
965
992
  readonly dispatchAttempts: number;
966
993
  readonly owner: {
967
994
  readonly tenantId: string | null;
@@ -971,36 +998,36 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
971
998
  readonly replyId: string;
972
999
  readonly restartToken: string | null;
973
1000
  } | null;
974
- };
975
- } | {
976
- kind: "waiting-journal";
977
- request: {
978
- readonly id: string;
979
1001
  readonly cause?: {
1002
+ readonly reason: string;
980
1003
  readonly detail?: {
981
1004
  readonly [x: string]: unknown;
982
1005
  } | undefined;
983
- readonly reason: string;
984
1006
  } | null | undefined;
1007
+ };
1008
+ } | {
1009
+ kind: "waiting-journal";
1010
+ request: {
1011
+ readonly id: string;
985
1012
  readonly result: {
986
- readonly status: "failed" | "cancelled" | "succeeded";
987
1013
  readonly kind: "confirmed" | "already-terminal";
1014
+ readonly status: "failed" | "cancelled" | "succeeded";
1015
+ readonly completedAt: number;
988
1016
  readonly output: unknown;
989
- readonly errorMessage: string | null;
990
1017
  readonly errorTag: string | null;
991
- readonly completedAt: number;
1018
+ readonly errorMessage: string | null;
992
1019
  } | {
993
- readonly status: "running";
994
1020
  readonly kind: "confirmed";
995
- readonly generation: string;
1021
+ readonly status: "running";
996
1022
  readonly enteredAt: number;
1023
+ readonly generation: string;
997
1024
  } | null;
1025
+ readonly operation: "resume" | "cancel" | "terminate";
998
1026
  readonly generation: string;
999
1027
  readonly runId: string;
1000
1028
  readonly requestedAt: number;
1001
1029
  readonly executionId: string;
1002
1030
  readonly workflowName: string;
1003
- readonly operation: "resume" | "cancel" | "terminate";
1004
1031
  readonly dispatchAttempts: number;
1005
1032
  readonly owner: {
1006
1033
  readonly tenantId: string | null;
@@ -1010,6 +1037,12 @@ export declare const bindWorkflowResumeJournalInTransaction: (tx: Store, id: str
1010
1037
  readonly replyId: string;
1011
1038
  readonly restartToken: string | null;
1012
1039
  } | null;
1040
+ readonly cause?: {
1041
+ readonly reason: string;
1042
+ readonly detail?: {
1043
+ readonly [x: string]: unknown;
1044
+ } | undefined;
1045
+ } | null | undefined;
1013
1046
  };
1014
1047
  }>;
1015
1048
 
@@ -1115,7 +1148,7 @@ export declare interface CancelOnPlanInput {
1115
1148
  /** The workflow's own payload schema. When absent the stored payload is
1116
1149
  * handed to `match` as-is — correct for JSON-shaped payloads and the honest
1117
1150
  * fallback when a definition cannot be resolved. */
1118
- readonly payloadSchema?: Schema.Schema.Any | undefined;
1151
+ readonly payloadSchema?: Schema.Top | undefined;
1119
1152
  readonly events: ReadonlyArray<DomainEventRow>;
1120
1153
  readonly runs: ReadonlyArray<CancellableRun>;
1121
1154
  readonly intents: ReadonlyArray<CancellableIntent>;
@@ -1178,7 +1211,7 @@ export declare interface CancelOnSweepResult {
1178
1211
  export declare interface CancelOnWorkflow {
1179
1212
  readonly workflowName: string;
1180
1213
  readonly entries: ReadonlyArray<ResolvedCancelOn>;
1181
- readonly payloadSchema?: Schema.Schema.Any | undefined;
1214
+ readonly payloadSchema?: Schema.Top | undefined;
1182
1215
  }
1183
1216
 
1184
1217
  /**
@@ -1218,7 +1251,7 @@ export declare const CLUSTER_REREAD_WINDOW_MS: number;
1218
1251
  export declare class ClusterDiagnostics extends ClusterDiagnostics_base {
1219
1252
  }
1220
1253
 
1221
- declare const ClusterDiagnostics_base: Context.TagClass<ClusterDiagnostics, "@voltro/workflow/ClusterDiagnostics", ClusterDiagnosticsOps>;
1254
+ declare const ClusterDiagnostics_base: Context.ServiceClass<ClusterDiagnostics, "@voltro/workflow/ClusterDiagnostics", ClusterDiagnosticsOps>;
1222
1255
 
1223
1256
  export declare interface ClusterDiagnosticsOps {
1224
1257
  /** This runner's advertised address — what keys its locks and its runner row. */
@@ -1307,7 +1340,7 @@ export declare const comparePendingOrder: (a: {
1307
1340
  */
1308
1341
  export declare const completeSuspendingSignal: (input: CompleteSuspendingSignalInput) => Effect.Effect<{
1309
1342
  readonly completed: boolean;
1310
- }, Cause.UnknownException, WorkflowEngine.WorkflowEngine>;
1343
+ }, Cause.UnknownError, WorkflowEngine.WorkflowEngine>;
1311
1344
 
1312
1345
  /** Input to {@link completeSuspendingSignal}. */
1313
1346
  export declare interface CompleteSuspendingSignalInput {
@@ -1342,7 +1375,7 @@ export declare const completeWorkflowRunGenerationInTransaction: (tx: AdmissionD
1342
1375
  * from `CurrentWorkflowRunId` (which is the runs-row primary key)
1343
1376
  * because the natural durable id used by other workflows is the
1344
1377
  * engine-assigned executionId, not our row id. */
1345
- export declare const CurrentWorkflowExecutionId: FiberRef.FiberRef<string | undefined>;
1378
+ export declare const CurrentWorkflowExecutionId: Context.Reference<string | undefined>;
1346
1379
 
1347
1380
  /**
1348
1381
  * FiberRef carrying the patch markers that were declared on the workflow at the
@@ -1355,7 +1388,7 @@ export declare const CurrentWorkflowExecutionId: FiberRef.FiberRef<string | unde
1355
1388
  * Empty outside a recorded workflow body, so `patch()` is `false` there — the
1356
1389
  * safe direction: an un-recorded context gets the PRE-patch branch.
1357
1390
  */
1358
- export declare const CurrentWorkflowPatches: FiberRef.FiberRef<readonly string[]>;
1391
+ export declare const CurrentWorkflowPatches: Context.Reference<readonly string[]>;
1359
1392
 
1360
1393
  /**
1361
1394
  * The tracker for the CURRENT body entry, or `undefined` when there is nothing
@@ -1365,12 +1398,12 @@ export declare const CurrentWorkflowPatches: FiberRef.FiberRef<readonly string[]
1365
1398
  * whose row already exists). A first entry has no prior shape, so the whole
1366
1399
  * mechanism costs one `FiberRef` read per step and nothing else.
1367
1400
  */
1368
- export declare const CurrentWorkflowReplayShape: FiberRef.FiberRef<ReplayShapeTracker | undefined>;
1401
+ export declare const CurrentWorkflowReplayShape: Context.Reference<ReplayShapeTracker | undefined>;
1369
1402
 
1370
1403
  /** FiberRef carrying the active workflow run's id. The outer
1371
1404
  * `wrapWithRunRecording` in dev.ts sets it via
1372
- * `Effect.locally(CurrentWorkflowRunId, runId)`. */
1373
- export declare const CurrentWorkflowRunId: FiberRef.FiberRef<string | undefined>;
1405
+ * `Effect.provideService(CurrentWorkflowRunId, runId)`. */
1406
+ export declare const CurrentWorkflowRunId: Context.Reference<string | undefined>;
1374
1407
 
1375
1408
  /**
1376
1409
  * FiberRef carrying the name of the `step()` whose body is running — set by
@@ -1382,7 +1415,7 @@ export declare const CurrentWorkflowRunId: FiberRef.FiberRef<string | undefined>
1382
1415
  * and `(executionId, step, call)` is the identity that makes the second send a
1383
1416
  * replay. Read through `currentWorkflowStep`, never directly.
1384
1417
  */
1385
- export declare const CurrentWorkflowStep: FiberRef.FiberRef<string | undefined>;
1418
+ export declare const CurrentWorkflowStep: Context.Reference<string | undefined>;
1386
1419
 
1387
1420
  /**
1388
1421
  * The step this fiber is running inside, with its durable execution — or
@@ -1536,8 +1569,8 @@ export declare const deferringControlsOf: (control: ResolvedFlowControl | undefi
1536
1569
  export declare const deleteIntent: (store: AdmissionDataStore, id: string) => Promise<boolean>;
1537
1570
 
1538
1571
  declare const Delivery: Schema.Struct<{
1539
- requestId: typeof Schema.NonEmptyString;
1540
- restartToken: Schema.NullOr<typeof Schema.NonEmptyString>;
1572
+ readonly requestId: Schema.NonEmptyString;
1573
+ readonly restartToken: Schema.NullOr<Schema.NonEmptyString>;
1541
1574
  }>;
1542
1575
 
1543
1576
  /**
@@ -1661,14 +1694,12 @@ export declare const dueIntents: (store: AdmissionDataStore, now: number, limit:
1661
1694
  export { durableClock }
1662
1695
 
1663
1696
  /** Define a durable queue for concurrency-controlled side work. */
1664
- export declare const durableQueue: typeof durableQueueModule.make & (<Options extends Parameters<typeof durableQueueModule.make>[0] & {
1697
+ export declare const durableQueue: <Payload extends Schema.Top | Schema.Struct.Fields, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never>(options: Parameters<typeof durableQueueModule.make<Payload, Success, Error>>[0] & {
1665
1698
  readonly encrypted?: boolean;
1666
- }>(options: Options) => ReturnType<typeof durableQueueModule.make>);
1699
+ }) => ReturnType<typeof durableQueueModule.make<Payload, Success, Error>>;
1667
1700
 
1668
1701
  export { durableQueueModule }
1669
1702
 
1670
- export { durableRateLimiterModule }
1671
-
1672
1703
  /** Establish the body-entry owner before running application code. Existing
1673
1704
  * execution identity retains its run ID and original input; return the previous
1674
1705
  * snapshot so crash/version guards decide from the state they actually replaced.
@@ -1723,31 +1754,33 @@ declare type Execute = (payload: unknown, executionId: string, discard: boolean)
1723
1754
  * the typed body result under that same ID and preserves its failure channel.
1724
1755
  * Record acceptance before joining; body completion is a separate event.
1725
1756
  * Ordinary starts do not opt into this capability automatically. */
1726
- export declare const executePreparedWorkflow: <Payload extends Schema.Schema.Any, Success extends Schema.Schema.Any, Error extends Schema.Schema.All, Discard extends boolean = true>(definition: {
1757
+ export declare const executePreparedWorkflow: <Payload extends Schema.Top, Success extends Schema.Top, Error extends Schema.Top, Discard extends boolean = true>(definition: {
1727
1758
  readonly payloadSchema: Payload;
1728
1759
  readonly successSchema: Success;
1729
1760
  readonly errorSchema: Error;
1730
1761
  }, payload: Payload["Type"], executionId: string, options?: {
1731
1762
  readonly discard: Discard;
1732
- }) => Effect.Effect<Discard extends true ? string : Success["Type"], Error["Type"], WorkflowEngine.WorkflowEngine | Payload["Context"] | Success["Context"] | Error["Context"]>;
1763
+ }) => Effect.Effect<Discard extends true ? string : Success["Type"], Error["Type"], WorkflowEngine.WorkflowEngine | Payload["DecodingServices"] | Success["DecodingServices"] | Error["DecodingServices"]>;
1764
+
1765
+ export declare const failureMessage: (error: unknown) => string;
1733
1766
 
1734
1767
  declare const FailureRecordSchema: Schema.Struct<{
1735
- id: typeof Schema.String;
1736
- workflowName: typeof Schema.String;
1737
- tenantId: Schema.NullOr<typeof Schema.String>;
1738
- sourceId: typeof Schema.String;
1739
- sourceKind: Schema.Literal<["submission", "intent", "run"]>;
1740
- handler: Schema.NullOr<typeof Schema.String>;
1741
- callerContext: typeof Schema.Unknown;
1742
- report: Schema.Struct<{
1743
- workflow: typeof Schema.String;
1744
- payload: typeof Schema.Unknown;
1745
- errorTag: Schema.NullOr<typeof Schema.String>;
1746
- errorMessage: Schema.NullOr<typeof Schema.String>;
1747
- runId: Schema.NullOr<typeof Schema.String>;
1748
- executionId: Schema.NullOr<typeof Schema.String>;
1749
- reason: typeof Schema.String;
1750
- failedAt: typeof Schema.Number;
1768
+ readonly id: Schema.String;
1769
+ readonly workflowName: Schema.String;
1770
+ readonly tenantId: Schema.NullOr<Schema.String>;
1771
+ readonly sourceId: Schema.String;
1772
+ readonly sourceKind: Schema.Literals<readonly ["submission", "intent", "run"]>;
1773
+ readonly handler: Schema.NullOr<Schema.String>;
1774
+ readonly callerContext: Schema.Unknown;
1775
+ readonly report: Schema.Struct<{
1776
+ readonly workflow: Schema.String;
1777
+ readonly payload: Schema.Unknown;
1778
+ readonly errorTag: Schema.NullOr<Schema.String>;
1779
+ readonly errorMessage: Schema.NullOr<Schema.String>;
1780
+ readonly runId: Schema.NullOr<Schema.String>;
1781
+ readonly executionId: Schema.NullOr<Schema.String>;
1782
+ readonly reason: Schema.String;
1783
+ readonly failedAt: Schema.Number;
1751
1784
  }>;
1752
1785
  }>;
1753
1786
 
@@ -1763,7 +1796,7 @@ export declare class FlowControlKeyError extends Error {
1763
1796
  /** A duration in any shape Effect accepts: `'15 minutes'`, `900_000`,
1764
1797
  * `Duration.minutes(15)`. Same input type `sleep({ duration })` takes, so
1765
1798
  * there is one duration vocabulary in the whole workflow surface. */
1766
- export declare type FlowDuration = Duration.DurationInput;
1799
+ export declare type FlowDuration = Duration.Input;
1767
1800
 
1768
1801
  /** Try to read the current workflow execution id. Returns undefined
1769
1802
  * when called outside a recorded workflow body. */
@@ -1824,7 +1857,10 @@ export declare interface InMemoryRecorder {
1824
1857
  readonly readEvents: () => ReadonlyArray<RecordedEvent>;
1825
1858
  }
1826
1859
 
1827
- export declare const inMemoryWorkflowEngineLayer: Layer.Layer<WorkflowEngine.WorkflowEngine>;
1860
+ /** `rateLimit()` counts on the `RateLimiter` service; in memory it is per process. */
1861
+ export declare const inMemoryWorkflowEngineLayer: Layer.Layer<WorkflowEngine.WorkflowEngine | RateLimiter.RateLimiter>;
1862
+
1863
+ export declare const inspectAdmissionSubmissionRetry: (tx: Pick<DataStore, "query">, id: string) => Promise<AdmissionSubmissionRetryInspection>;
1828
1864
 
1829
1865
  export declare interface InspectedStep {
1830
1866
  readonly name: string;
@@ -1879,6 +1915,10 @@ export declare interface InspectStore {
1879
1915
  */
1880
1916
  export declare const inspectWorkflow: (idOrExecutionId: string, store: InspectStore) => Promise<InspectedWorkflow | null>;
1881
1917
 
1918
+ /** A value that can carry definition metadata: a workflow definition is a
1919
+ * callable in v4 (`Workflow.make` returns a function), a queue is an object. */
1920
+ export declare const isCarrier: (value: unknown) => value is object;
1921
+
1882
1922
  /**
1883
1923
  * Has an admitted run outlived `timeouts.finish`?
1884
1924
  *
@@ -2007,7 +2047,7 @@ export declare type NondeterminismKind = 'unreached-step' | 'extra-step-occurren
2007
2047
  declare type NormaliseWorkflowMessages<M extends WorkflowMessageSchemas | undefined> = {
2008
2048
  readonly signals: M extends {
2009
2049
  readonly signals: infer Signals;
2010
- } ? NonNullable<Signals> & Readonly<Record<string, Schema.Schema.Any>> : {};
2050
+ } ? NonNullable<Signals> & Readonly<Record<string, Schema.Top>> : {};
2011
2051
  readonly updates: M extends {
2012
2052
  readonly updates: infer Updates;
2013
2053
  } ? NonNullable<Updates> & Readonly<Record<string, WorkflowMessagePairSchemas>> : {};
@@ -2023,8 +2063,12 @@ export declare const normaliseWorkflowPatches: (value: unknown) => ReadonlyArray
2023
2063
  * pending row. Missing acknowledgement does NOT prove that the engine rejected
2024
2064
  * the call; this record deliberately makes no terminal-execution claim.
2025
2065
  * Call inside the owning admission transaction. A reached attempt limit stops
2026
- * automatic retry but retains the lease and receipt for reconciliation. */
2027
- export declare const noteAdmissionSubmissionFailure: (tx: Pick<DataStore, "query" | "update">, id: string, error: string, now: number, maxAttempts?: number | false) => Promise<AdmissionSubmission>;
2066
+ * automatic retry but retains the lease and receipt for reconciliation.
2067
+ * Pass the attempt's observed `retry.recovery?.attempts ?? 0`: an older
2068
+ * in-flight failure must not consume an operator's newly granted budget.
2069
+ * Omission means the original, unrecovered epoch; it cannot change a recovered
2070
+ * submission. An actual dispatch adopts the epoch returned by its begin call. */
2071
+ export declare const noteAdmissionSubmissionFailure: (tx: Pick<DataStore, "query" | "update">, id: string, error: string, now: number, maxAttempts?: number | false, expectedRecoveryAttempts?: number) => Promise<AdmissionSubmission>;
2028
2072
 
2029
2073
  export declare const noteIntentAttempt: (store: AdmissionDataStore, intent: PendingIntent, error: string, now: number) => Promise<void>;
2030
2074
 
@@ -2126,7 +2170,7 @@ export declare interface ParkDelayedStartInput {
2126
2170
  * however many times it replays and whatever the deployed code says — which is
2127
2171
  * the property that makes the branch deterministic across a redeploy.
2128
2172
  *
2129
- * Under `@effect/workflow` the naive implementation does the opposite: an
2173
+ * Under `effect/workflow` the naive implementation does the opposite: an
2130
2174
  * activity that is ABSENT from an old run's journal EXECUTES on replay (the
2131
2175
  * journal is keyed name/attempt), so a marker journaled by an activity would
2132
2176
  * answer `true` for exactly the old runs it must answer `false` for. Reading
@@ -2328,8 +2372,26 @@ export declare const queuedCancellationRequestsTable: SchemaTable;
2328
2372
  * inferred type) is what emits in the `.d.ts`, so it stays portable. */
2329
2373
  export declare const queueWorker: typeof durableQueueModule.worker;
2330
2374
 
2331
- /** Durable rate limiter activity. Delays through the workflow clock. */
2332
- export declare const rateLimit: typeof durableRateLimiterModule.rateLimit;
2375
+ /**
2376
+ * Durable rate limit. Consumes from the shared limiter; when the window is
2377
+ * exhausted the wait is a durable clock sleep under `name`, so a deploy or a
2378
+ * worker crash does not lose the delay and a replay does not consume twice.
2379
+ */
2380
+ export declare const rateLimit: (options: RateLimitOptions) => Effect.Effect<void, RateLimiter.RateLimiterError, RateLimiter.RateLimiter | WorkflowEngine.WorkflowEngine | WorkflowEngine.WorkflowInstance>;
2381
+
2382
+ /** What `rateLimit` admits: one unit of work under `limit` per `window` for
2383
+ * `key`, counted by the `RateLimiter` service the boot provides. */
2384
+ export declare interface RateLimitOptions {
2385
+ /** Names this ADMISSION within the run: the decision is journaled under it, so a
2386
+ * replay reads it back instead of consuming again. Two calls with the same name
2387
+ * in one run share one decision — give each call its own (`send/${i}` in a loop). */
2388
+ readonly name: string;
2389
+ readonly window: Duration.Input;
2390
+ readonly limit: number;
2391
+ readonly key: string;
2392
+ readonly algorithm?: 'fixed-window' | 'token-bucket' | undefined;
2393
+ readonly tokens?: number | undefined;
2394
+ }
2333
2395
 
2334
2396
  /**
2335
2397
  * Read exactly the state the declared controls need — no more.
@@ -2389,26 +2451,13 @@ declare const readWorkflowRestartCommandInTransaction: (tx: AdmissionDataStore,
2389
2451
  readonly selection: WorkflowRestartSelection;
2390
2452
  }) => Promise<{
2391
2453
  readonly id: string;
2392
- readonly tenantId: string | null;
2393
- readonly token: string;
2394
- readonly generation: string;
2395
2454
  readonly runId: string;
2396
- readonly requestedAt: Date;
2397
- readonly executionId: string;
2398
2455
  readonly workflowName: string;
2399
- readonly selection: {
2400
- readonly kind: "failed-steps";
2401
- } | {
2402
- readonly kind: "from-step";
2403
- readonly stepName: string;
2404
- };
2405
- readonly dispatchAttempts: number;
2406
- readonly enteredGeneration: string | null;
2456
+ readonly executionId: string;
2457
+ readonly generation: string;
2458
+ readonly token: string;
2407
2459
  readonly ledgerId: string;
2408
- readonly eviction: {
2409
- readonly runId: string;
2410
- readonly executionId: string;
2411
- } | null;
2460
+ readonly tenantId: string | null;
2412
2461
  readonly delivery: {
2413
2462
  readonly requestId: string;
2414
2463
  readonly restartToken: string | null;
@@ -2417,6 +2466,19 @@ declare const readWorkflowRestartCommandInTransaction: (tx: AdmissionDataStore,
2417
2466
  readonly requestId: string;
2418
2467
  readonly replyId: string;
2419
2468
  }[];
2469
+ readonly selection: {
2470
+ readonly kind: "failed-steps";
2471
+ } | {
2472
+ readonly kind: "from-step";
2473
+ readonly stepName: string;
2474
+ };
2475
+ readonly eviction: {
2476
+ readonly executionId: string;
2477
+ readonly runId: string;
2478
+ } | null;
2479
+ readonly requestedAt: Date;
2480
+ readonly dispatchAttempts: number;
2481
+ readonly enteredGeneration: string | null;
2420
2482
  } | undefined>;
2421
2483
 
2422
2484
  /** Read-only reconciliation. No observation of engine replies, admission,
@@ -2436,34 +2498,34 @@ export declare const readWorkflowStartRequest: (store: Pick<DataStore, "query">,
2436
2498
  readonly requestFingerprint: string;
2437
2499
  }) => Promise<WorkflowStartReceipt | undefined>;
2438
2500
 
2439
- declare const ReceiptSchema: Schema.filter<Schema.Struct<{
2440
- id: typeof Schema.String;
2441
- workflowName: typeof Schema.String;
2442
- tenantId: Schema.NullOr<typeof Schema.String>;
2443
- pendingId: typeof Schema.String;
2444
- submissionId: Schema.NullOr<typeof Schema.String>;
2445
- terminal: Schema.NullOr<Schema.Union<[Schema.Struct<{
2446
- kind: Schema.Literal<["dropped"]>;
2447
- at: typeof Schema.Number;
2448
- retryAfterMs: typeof Schema.Number;
2501
+ declare const ReceiptSchema: Schema.Struct<{
2502
+ readonly id: Schema.String;
2503
+ readonly workflowName: Schema.String;
2504
+ readonly tenantId: Schema.NullOr<Schema.String>;
2505
+ readonly pendingId: Schema.String;
2506
+ readonly submissionId: Schema.NullOr<Schema.String>;
2507
+ readonly terminal: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
2508
+ readonly kind: Schema.Literal<"dropped">;
2509
+ readonly at: Schema.Number;
2510
+ readonly retryAfterMs: Schema.Number;
2449
2511
  }>, Schema.Struct<{
2450
- kind: Schema.Literal<["skipped"]>;
2451
- at: typeof Schema.Number;
2452
- executionId: typeof Schema.String;
2453
- runId: typeof Schema.String;
2512
+ readonly kind: Schema.Literal<"skipped">;
2513
+ readonly at: Schema.Number;
2514
+ readonly executionId: Schema.String;
2515
+ readonly runId: Schema.String;
2454
2516
  }>, Schema.Struct<{
2455
- kind: Schema.Literal<["superseded"]>;
2456
- at: typeof Schema.Number;
2517
+ readonly kind: Schema.Literal<"superseded">;
2518
+ readonly at: Schema.Number;
2457
2519
  }>, Schema.Struct<{
2458
- kind: Schema.Literal<["cancelled"]>;
2459
- at: typeof Schema.Number;
2520
+ readonly kind: Schema.Literal<"cancelled">;
2521
+ readonly at: Schema.Number;
2460
2522
  }>, Schema.Struct<{
2461
- kind: Schema.Literal<["abandoned"]>;
2462
- at: typeof Schema.Number;
2463
- failureId: typeof Schema.NonEmptyString;
2523
+ readonly kind: Schema.Literal<"abandoned">;
2524
+ readonly at: Schema.Number;
2525
+ readonly failureId: Schema.NonEmptyString;
2464
2526
  }>]>>;
2465
- requestFingerprint: Schema.optional<Schema.NullOr<Schema.filter<typeof Schema.String>>>;
2466
- }>>;
2527
+ readonly requestFingerprint: Schema.optional<Schema.NullOr<Schema.String>>;
2528
+ }>;
2467
2529
 
2468
2530
  /** Reconcile under the resident admission lock. Only a terminal pre-admission
2469
2531
  * drop/skip/supersession or proven pre-engine rejection permits a new arrival. Preserve every previous receipt and
@@ -2536,6 +2598,17 @@ export declare interface RecordedStepShape {
2536
2598
  readonly stepName: string;
2537
2599
  }
2538
2600
 
2601
+ /** Record a known caller's pre-body refusal without replay/version/crash guards
2602
+ * treating the refused attempt as application execution. Entry and completion
2603
+ * use the ordinary resident transactions, delivery identity and generation
2604
+ * fences; an unknown identity cannot create a run. The original failure is
2605
+ * returned to the engine after its terminal record commits. */
2606
+ export declare const recordWorkflowExecutionRefusal: (options: WorkflowExecutionRefusalRecordingOptions, input: {
2607
+ readonly executionId: string;
2608
+ readonly payload: unknown;
2609
+ readonly cause: Cause.Cause<unknown>;
2610
+ }) => Effect.Effect<never, unknown, WorkflowInstance>;
2611
+
2539
2612
  /** Database-only: call inside the resident admission transaction, together
2540
2613
  * with the source's terminal transition. Never notify the handler from here.
2541
2614
  * Replaying an identity keeps the first report AND recipient, even after a
@@ -2550,12 +2623,14 @@ export declare const recordWorkflowStartReceipt: (tx: Pick<DataStore, "insertIgn
2550
2623
  /** Record proven pre-engine rejection together with its source and lease.
2551
2624
  * Attempt 0 means local validation before any engine call. Attempt 1 means the
2552
2625
  * first call returned a failure the host guarantees occurs before engine I/O.
2553
- * A prior or competing attempt makes acceptance unknown, not rejected. */
2626
+ * A prior or competing attempt makes acceptance unknown, not rejected.
2627
+ * Pass the same observed recovery epoch as failure bookkeeping: an older
2628
+ * pre-engine error cannot reject an explicitly recovered submission. */
2554
2629
  export declare const rejectAdmissionSubmissionInTransaction: (tx: AdmissionDataStore, id: string, attempt: number, failure: {
2555
2630
  readonly handler: string | null;
2556
2631
  readonly errorMessage: string;
2557
2632
  readonly now: number;
2558
- }) => Promise<WorkflowFailureRecord | undefined>;
2633
+ }, expectedRecoveryAttempts?: number) => Promise<WorkflowFailureRecord | undefined>;
2559
2634
 
2560
2635
  /**
2561
2636
  * Resume every run parked on `budget`.
@@ -2618,8 +2693,8 @@ export declare interface ReplayShapeTracker {
2618
2693
  }
2619
2694
 
2620
2695
  declare const Reply: Schema.Struct<{
2621
- requestId: typeof Schema.NonEmptyString;
2622
- replyId: typeof Schema.NonEmptyString;
2696
+ readonly requestId: Schema.NonEmptyString;
2697
+ readonly replyId: Schema.NonEmptyString;
2623
2698
  }>;
2624
2699
 
2625
2700
  /**
@@ -2633,39 +2708,39 @@ declare const Reply: Schema.Struct<{
2633
2708
  export declare const reportNondeterminism: (findings: ReadonlyArray<NondeterminismFinding>) => Effect.Effect<void>;
2634
2709
 
2635
2710
  declare const RequestSchema: Schema.Struct<{
2636
- id: Schema.filter<typeof Schema.String>;
2637
- runId: Schema.filter<typeof Schema.String>;
2638
- workflowName: Schema.filter<typeof Schema.String>;
2639
- executionId: Schema.filter<typeof Schema.String>;
2640
- generation: Schema.filter<typeof Schema.String>;
2641
- operation: Schema.Literal<["cancel", "terminate", "resume"]>;
2642
- requestedAt: Schema.filter<typeof Schema.Number>;
2711
+ readonly id: Schema.String;
2712
+ readonly runId: Schema.String;
2713
+ readonly workflowName: Schema.String;
2714
+ readonly executionId: Schema.String;
2715
+ readonly generation: Schema.String;
2716
+ readonly operation: Schema.Literals<readonly ["cancel", "terminate", "resume"]>;
2717
+ readonly requestedAt: Schema.Number;
2643
2718
  /** Null means no proven owner, not a null-tenant owner. */
2644
- owner: Schema.NullOr<Schema.Struct<{
2645
- tenantId: Schema.NullOr<typeof Schema.String>;
2719
+ readonly owner: Schema.NullOr<Schema.Struct<{
2720
+ readonly tenantId: Schema.NullOr<Schema.String>;
2646
2721
  }>>;
2647
- cause: Schema.optional<Schema.NullOr<Schema.Struct<{
2648
- reason: typeof Schema.NonEmptyString;
2649
- detail: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
2722
+ readonly cause: Schema.optional<Schema.NullOr<Schema.Struct<{
2723
+ readonly reason: Schema.NonEmptyString;
2724
+ readonly detail: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
2650
2725
  }>>>;
2651
- dispatchAttempts: Schema.filter<Schema.filter<typeof Schema.Number>>;
2652
- resumeJournal: Schema.NullOr<Schema.Struct<{
2653
- requestId: Schema.filter<typeof Schema.String>;
2654
- replyId: Schema.filter<typeof Schema.String>;
2655
- restartToken: Schema.NullOr<typeof Schema.NonEmptyString>;
2726
+ readonly dispatchAttempts: Schema.Number;
2727
+ readonly resumeJournal: Schema.NullOr<Schema.Struct<{
2728
+ readonly requestId: Schema.String;
2729
+ readonly replyId: Schema.String;
2730
+ readonly restartToken: Schema.NullOr<Schema.NonEmptyString>;
2656
2731
  }>>;
2657
- result: Schema.NullOr<Schema.Union<[Schema.Struct<{
2658
- kind: Schema.Literal<["confirmed", "already-terminal"]>;
2659
- status: Schema.Literal<["succeeded", "failed", "cancelled"]>;
2660
- completedAt: Schema.filter<typeof Schema.Number>;
2661
- output: typeof Schema.Unknown;
2662
- errorTag: Schema.NullOr<typeof Schema.String>;
2663
- errorMessage: Schema.NullOr<typeof Schema.String>;
2732
+ readonly result: Schema.NullOr<Schema.Union<readonly [Schema.Struct<{
2733
+ readonly kind: Schema.Literals<readonly ["confirmed", "already-terminal"]>;
2734
+ readonly status: Schema.Literals<readonly ["succeeded", "failed", "cancelled"]>;
2735
+ readonly completedAt: Schema.Number;
2736
+ readonly output: Schema.Unknown;
2737
+ readonly errorTag: Schema.NullOr<Schema.String>;
2738
+ readonly errorMessage: Schema.NullOr<Schema.String>;
2664
2739
  }>, Schema.Struct<{
2665
- kind: Schema.Literal<["confirmed"]>;
2666
- status: Schema.Literal<["running"]>;
2667
- enteredAt: Schema.filter<typeof Schema.Number>;
2668
- generation: Schema.filter<typeof Schema.String>;
2740
+ readonly kind: Schema.Literal<"confirmed">;
2741
+ readonly status: Schema.Literal<"running">;
2742
+ readonly enteredAt: Schema.Number;
2743
+ readonly generation: Schema.String;
2669
2744
  }>]>>;
2670
2745
  }>;
2671
2746
 
@@ -2727,26 +2802,13 @@ export declare const reserveWorkflowRestartInTransaction: (tx: AdmissionDataStor
2727
2802
  kind: "reserved";
2728
2803
  request: {
2729
2804
  readonly id: string;
2730
- readonly tenantId: string | null;
2731
- readonly token: string;
2732
- readonly generation: string;
2733
2805
  readonly runId: string;
2734
- readonly requestedAt: Date;
2735
- readonly executionId: string;
2736
2806
  readonly workflowName: string;
2737
- readonly selection: {
2738
- readonly kind: "failed-steps";
2739
- } | {
2740
- readonly kind: "from-step";
2741
- readonly stepName: string;
2742
- };
2743
- readonly dispatchAttempts: number;
2744
- readonly enteredGeneration: string | null;
2807
+ readonly executionId: string;
2808
+ readonly generation: string;
2809
+ readonly token: string;
2745
2810
  readonly ledgerId: string;
2746
- readonly eviction: {
2747
- readonly runId: string;
2748
- readonly executionId: string;
2749
- } | null;
2811
+ readonly tenantId: string | null;
2750
2812
  readonly delivery: {
2751
2813
  readonly requestId: string;
2752
2814
  readonly restartToken: string | null;
@@ -2755,6 +2817,19 @@ export declare const reserveWorkflowRestartInTransaction: (tx: AdmissionDataStor
2755
2817
  readonly requestId: string;
2756
2818
  readonly replyId: string;
2757
2819
  }[];
2820
+ readonly selection: {
2821
+ readonly kind: "failed-steps";
2822
+ } | {
2823
+ readonly kind: "from-step";
2824
+ readonly stepName: string;
2825
+ };
2826
+ readonly eviction: {
2827
+ readonly executionId: string;
2828
+ readonly runId: string;
2829
+ } | null;
2830
+ readonly requestedAt: Date;
2831
+ readonly dispatchAttempts: number;
2832
+ readonly enteredGeneration: string | null;
2758
2833
  };
2759
2834
  reused: boolean;
2760
2835
  decision?: never;
@@ -2801,7 +2876,7 @@ export declare const resolveAdmissionKeys: (control: ResolvedFlowControl, payloa
2801
2876
  * event at all". */
2802
2877
  export declare interface ResolvedCancelOn {
2803
2878
  readonly event: string;
2804
- readonly schema: Schema.Schema.Any;
2879
+ readonly schema: Schema.Top;
2805
2880
  readonly match: (event: unknown, payload: unknown) => boolean;
2806
2881
  readonly withinMs?: number;
2807
2882
  readonly reason: string;
@@ -2905,6 +2980,12 @@ export declare const resolveWorkflowStartReceipt: (tx: Pick<DataStore, "query">,
2905
2980
 
2906
2981
  export declare const resumeWorkflow: (store: AdmissionDataStore, workflowName: string) => Promise<boolean>;
2907
2982
 
2983
+ /** Call under the SAME resident admission transaction as preparation, dispatch,
2984
+ * cancellation and ACK. The preview is advisory; this locked reread decides.
2985
+ * Keep lifetime attempts monotonic and retain the consumed stop token so a lost
2986
+ * response can be retried without resuming a later exhausted retry budget. */
2987
+ export declare const retryAdmissionSubmissionInTransaction: (tx: Pick<DataStore, "query" | "update">, id: string, expected: AdmissionSubmissionRetryToken, now: number) => Promise<AdmissionSubmissionRetryResult>;
2988
+
2908
2989
  /** Re-arm one dead-lettered intent after an operator has deployed a schema or
2909
2990
  * handler fix. The payload and its queue-time provenance stay untouched; only
2910
2991
  * the terminal classification and retry history are reset. */
@@ -2917,11 +2998,11 @@ export declare const retryDeadLetterIntent: (store: AdmissionDataStore, intentId
2917
2998
  */
2918
2999
  export declare const sealJournalValue: (value: unknown, what: string, binding?: FieldBinding) => unknown;
2919
3000
 
2920
- declare const Selection: Schema.Union<[Schema.Struct<{
2921
- kind: Schema.Literal<["failed-steps"]>;
3001
+ declare const Selection: Schema.Union<readonly [Schema.Struct<{
3002
+ readonly kind: Schema.Literal<"failed-steps">;
2922
3003
  }>, Schema.Struct<{
2923
- kind: Schema.Literal<["from-step"]>;
2924
- stepName: Schema.filter<typeof Schema.NonEmptyString>;
3004
+ readonly kind: Schema.Literal<"from-step">;
3005
+ readonly stepName: Schema.NonEmptyString;
2925
3006
  }>]>;
2926
3007
 
2927
3008
  export declare const sendWorkflowSignal: (input: {
@@ -3141,7 +3222,7 @@ export declare type StallReason =
3141
3222
  * returns, or a runner that vanished without the reclaim path noticing. */
3142
3223
  | 'no-progress';
3143
3224
 
3144
- export declare const step: <R, Success extends Schema.Schema.Any = typeof Schema.Void, Error extends Schema.Schema.All = typeof Schema.Never>(options: StepOptions<R, Success, Error>) => ReturnType<typeof stepModule.make<R, Success, Error>>;
3225
+ export declare const step: <R, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never>(options: StepOptions<R, Success, Error>) => ReturnType<typeof stepModule.make<R, Success, Error>>;
3145
3226
 
3146
3227
  /** The address the step journal's values are sealed to (`encrypted` via the
3147
3228
  * recorder's `encryptStepPayload`). ONE definition, shared with the CLI. */
@@ -3164,7 +3245,7 @@ export { stepModule }
3164
3245
  /**
3165
3246
  * Define a checkpointed step (activity) inside a workflow body.
3166
3247
  *
3167
- * Wraps `@effect/workflow`'s `Activity.make` to record every
3248
+ * Wraps `effect/workflow`'s `Activity.make` to record every
3168
3249
  * invocation in `_voltro_workflow_run_steps`. The wrapping is
3169
3250
  * transparent — accepts everything `Activity.make` accepts, plus an
3170
3251
  * optional `input` field whose value is persisted to the step row
@@ -3183,7 +3264,7 @@ export { stepModule }
3183
3264
  * Without the recorder service in scope (unit tests, etc.) the input
3184
3265
  * is dropped and the wrap is a no-op.
3185
3266
  */
3186
- declare type StepOptions<R, Success extends Schema.Schema.Any, Error extends Schema.Schema.All> = {
3267
+ declare type StepOptions<R, Success extends Schema.Top, Error extends Schema.Top> = {
3187
3268
  readonly name: string;
3188
3269
  readonly success?: Success | undefined;
3189
3270
  readonly error?: Error | undefined;
@@ -3249,29 +3330,36 @@ export declare interface StepRetryPolicy {
3249
3330
 
3250
3331
  declare type Store = Pick<DataStore, 'query' | 'insert' | 'update'>;
3251
3332
 
3333
+ export declare const SUBMISSIONS_TABLE = "_voltro_workflow_submissions";
3334
+
3252
3335
  declare const SubmissionSchema: Schema.Struct<{
3253
- id: typeof Schema.String;
3254
- workflowName: typeof Schema.String;
3255
- tenantId: Schema.NullOr<typeof Schema.String>;
3256
- ledgerId: typeof Schema.String;
3257
- preparedExecutionId: Schema.NullOr<typeof Schema.String>;
3258
- executionId: Schema.NullOr<typeof Schema.String>;
3259
- runId: Schema.NullOr<typeof Schema.String>;
3260
- receiptsBound: typeof Schema.Boolean;
3261
- dispatchAttempts: Schema.refine<number, typeof Schema.NonNegative>;
3262
- failureId: Schema.NullOr<typeof Schema.String>;
3263
- retry: Schema.Struct<{
3264
- attempts: typeof Schema.Int;
3265
- after: typeof Schema.Number;
3266
- lastError: Schema.NullOr<typeof Schema.String>;
3267
- stoppedAt: Schema.NullOr<typeof Schema.Number>;
3336
+ readonly id: Schema.String;
3337
+ readonly workflowName: Schema.String;
3338
+ readonly tenantId: Schema.NullOr<Schema.String>;
3339
+ readonly ledgerId: Schema.String;
3340
+ readonly preparedExecutionId: Schema.NullOr<Schema.String>;
3341
+ readonly executionId: Schema.NullOr<Schema.String>;
3342
+ readonly runId: Schema.NullOr<Schema.String>;
3343
+ readonly receiptsBound: Schema.Boolean;
3344
+ readonly dispatchAttempts: Schema.Number;
3345
+ readonly failureId: Schema.NullOr<Schema.String>;
3346
+ readonly retry: Schema.Struct<{
3347
+ readonly attempts: Schema.Int;
3348
+ readonly after: Schema.Number;
3349
+ readonly lastError: Schema.NullOr<Schema.String>;
3350
+ readonly stoppedAt: Schema.NullOr<Schema.Number>;
3351
+ readonly recovery: Schema.optional<Schema.Struct<{
3352
+ readonly attempts: Schema.Int;
3353
+ readonly stoppedAt: Schema.Number;
3354
+ readonly retriedAt: Schema.Number;
3355
+ }>>;
3268
3356
  }>;
3269
- payload: typeof Schema.Unknown;
3270
- callerContext: typeof Schema.Unknown;
3271
- intentIds: Schema.Array$<typeof Schema.String>;
3272
- eviction: Schema.NullOr<Schema.Struct<{
3273
- executionId: typeof Schema.String;
3274
- runId: typeof Schema.String;
3357
+ readonly payload: Schema.Unknown;
3358
+ readonly callerContext: Schema.Unknown;
3359
+ readonly intentIds: Schema.$Array<Schema.String>;
3360
+ readonly eviction: Schema.NullOr<Schema.Struct<{
3361
+ readonly executionId: Schema.String;
3362
+ readonly runId: Schema.String;
3275
3363
  }>>;
3276
3364
  }>;
3277
3365
 
@@ -3349,10 +3437,7 @@ export declare interface SuspendHintInput {
3349
3437
  */
3350
3438
  export declare const suspendingSignalDeferredName: (workflowName: string, signalName: string) => string;
3351
3439
 
3352
- export declare class SuspensionUnavailable extends SuspensionUnavailable_base {
3353
- }
3354
-
3355
- declare const SuspensionUnavailable_base: Context.ReferenceClass<SuspensionUnavailable, "@voltro/workflow/SuspensionUnavailable", string | undefined>;
3440
+ export declare const SuspensionUnavailable: Context.Reference<string | undefined>;
3356
3441
 
3357
3442
  /**
3358
3443
  * One cancellation tick. Never throws.
@@ -3379,27 +3464,32 @@ export declare const sweepStalledRuns: (deps: StalenessSweepDeps, options?: Stal
3379
3464
  * The caller supplies the encoded payload derived under this same lock. */
3380
3465
  export declare const takeAdmittedSubmissionInTransaction: (tx: AdmissionDataStore, input: Parameters<typeof persistReservedSubmission>[1]) => Promise<{
3381
3466
  readonly id: string;
3467
+ readonly workflowName: string;
3382
3468
  readonly tenantId: string | null;
3469
+ readonly ledgerId: string;
3470
+ readonly preparedExecutionId: string | null;
3471
+ readonly executionId: string | null;
3472
+ readonly runId: string | null;
3473
+ readonly receiptsBound: boolean;
3474
+ readonly dispatchAttempts: number;
3475
+ readonly failureId: string | null;
3383
3476
  readonly retry: {
3384
3477
  readonly lastError: string | null;
3385
3478
  readonly attempts: number;
3386
- readonly after: number;
3387
3479
  readonly stoppedAt: number | null;
3480
+ readonly after: number;
3481
+ readonly recovery?: {
3482
+ readonly attempts: number;
3483
+ readonly stoppedAt: number;
3484
+ readonly retriedAt: number;
3485
+ } | undefined;
3388
3486
  };
3389
3487
  readonly payload: unknown;
3390
- readonly runId: string | null;
3391
- readonly executionId: string | null;
3392
- readonly failureId: string | null;
3393
- readonly workflowName: string;
3394
- readonly dispatchAttempts: number;
3395
3488
  readonly callerContext: unknown;
3396
3489
  readonly intentIds: readonly string[];
3397
- readonly ledgerId: string;
3398
- readonly receiptsBound: boolean;
3399
- readonly preparedExecutionId: string | null;
3400
3490
  readonly eviction: {
3401
- readonly runId: string;
3402
3491
  readonly executionId: string;
3492
+ readonly runId: string;
3403
3493
  } | null;
3404
3494
  }>;
3405
3495
 
@@ -3412,10 +3502,10 @@ export declare const takePendingAdmissionSubmission: (store: Pick<DataStore, "in
3412
3502
  }>;
3413
3503
 
3414
3504
  declare const Target: Schema.Struct<{
3415
- requestId: typeof Schema.NonEmptyString;
3416
- receiptId: typeof Schema.NonEmptyString;
3417
- workflowName: typeof Schema.NonEmptyString;
3418
- tenantId: Schema.NullOr<typeof Schema.String>;
3505
+ readonly requestId: Schema.NonEmptyString;
3506
+ readonly receiptId: Schema.NonEmptyString;
3507
+ readonly workflowName: Schema.NonEmptyString;
3508
+ readonly tenantId: Schema.NullOr<Schema.String>;
3419
3509
  }>;
3420
3510
 
3421
3511
  export declare const truncateWorkflowValue: (value: unknown, bytes?: number) => unknown;
@@ -3569,9 +3659,9 @@ export declare const withdrawWorkflowRestartInTransaction: (tx: AdmissionDataSto
3569
3659
  kind: "withdrawn";
3570
3660
  withdrawal: {
3571
3661
  readonly id: string;
3572
- readonly tenantId: string | null;
3573
3662
  readonly runId: string;
3574
3663
  readonly workflowName: string;
3664
+ readonly tenantId: string | null;
3575
3665
  readonly selection: {
3576
3666
  readonly kind: "failed-steps";
3577
3667
  } | {
@@ -3586,26 +3676,13 @@ export declare const withdrawWorkflowRestartInTransaction: (tx: AdmissionDataSto
3586
3676
  kind: "reserved";
3587
3677
  request: {
3588
3678
  readonly id: string;
3589
- readonly tenantId: string | null;
3590
- readonly token: string;
3591
- readonly generation: string;
3592
3679
  readonly runId: string;
3593
- readonly requestedAt: Date;
3594
- readonly executionId: string;
3595
3680
  readonly workflowName: string;
3596
- readonly selection: {
3597
- readonly kind: "failed-steps";
3598
- } | {
3599
- readonly kind: "from-step";
3600
- readonly stepName: string;
3601
- };
3602
- readonly dispatchAttempts: number;
3603
- readonly enteredGeneration: string | null;
3681
+ readonly executionId: string;
3682
+ readonly generation: string;
3683
+ readonly token: string;
3604
3684
  readonly ledgerId: string;
3605
- readonly eviction: {
3606
- readonly runId: string;
3607
- readonly executionId: string;
3608
- } | null;
3685
+ readonly tenantId: string | null;
3609
3686
  readonly delivery: {
3610
3687
  readonly requestId: string;
3611
3688
  readonly restartToken: string | null;
@@ -3614,6 +3691,19 @@ export declare const withdrawWorkflowRestartInTransaction: (tx: AdmissionDataSto
3614
3691
  readonly requestId: string;
3615
3692
  readonly replyId: string;
3616
3693
  }[];
3694
+ readonly selection: {
3695
+ readonly kind: "failed-steps";
3696
+ } | {
3697
+ readonly kind: "from-step";
3698
+ readonly stepName: string;
3699
+ };
3700
+ readonly eviction: {
3701
+ readonly executionId: string;
3702
+ readonly runId: string;
3703
+ } | null;
3704
+ readonly requestedAt: Date;
3705
+ readonly dispatchAttempts: number;
3706
+ readonly enteredGeneration: string | null;
3617
3707
  };
3618
3708
  withdrawal?: never;
3619
3709
  reused?: never;
@@ -3631,7 +3721,9 @@ export declare const workflow: WorkflowFn;
3631
3721
  */
3632
3722
  export declare const WORKFLOW_JOURNAL_BINDING: FieldBinding;
3633
3723
 
3634
- declare type WorkflowBaseOptions = Parameters<WorkflowMake>[0];
3724
+ declare type WorkflowBaseOptions = Parameters<WorkflowMake>[1] & {
3725
+ readonly name: Parameters<WorkflowMake>[0];
3726
+ };
3635
3727
 
3636
3728
  /**
3637
3729
  * Collect many starts into ONE run over an array of items.
@@ -3690,7 +3782,7 @@ export declare interface WorkflowBatch<Item> {
3690
3782
  * }],
3691
3783
  * ```
3692
3784
  */
3693
- export declare interface WorkflowCancelOn<EventSchema extends Schema.Schema.Any, Payload> {
3785
+ export declare interface WorkflowCancelOn<EventSchema extends Schema.Top, Payload> {
3694
3786
  /** The event NAME, exactly as `ctx.events.publish` writes it. */
3695
3787
  readonly event: string;
3696
3788
  /** Decoded before `match` sees it, so the predicate reads the domain type
@@ -3724,7 +3816,7 @@ export declare interface WorkflowCancelOn<EventSchema extends Schema.Schema.Any,
3724
3816
  * the per-entry-inferred {@link WorkflowCancelOnList}; this is what survives
3725
3817
  * erasure, and it is deliberately not the public spelling. */
3726
3818
  export declare interface WorkflowCancelOnDeclared {
3727
- readonly cancelOn?: ReadonlyArray<WorkflowCancelOn<Schema.Schema.Any, never>>;
3819
+ readonly cancelOn?: ReadonlyArray<WorkflowCancelOn<Schema.Top, never>>;
3728
3820
  }
3729
3821
 
3730
3822
  /** The `cancelOn` array as declared, with each entry's event type inferred
@@ -3732,7 +3824,7 @@ export declare interface WorkflowCancelOnDeclared {
3732
3824
  * per-entry inference work — a plain `ReadonlyArray<WorkflowCancelOn<…>>`
3733
3825
  * collapses every entry's event to the constraint (`any`), which is how the
3734
3826
  * predicate silently stops being checked. */
3735
- export declare type WorkflowCancelOnList<Cancels extends ReadonlyArray<Schema.Schema.Any>, Payload> = {
3827
+ export declare type WorkflowCancelOnList<Cancels extends ReadonlyArray<Schema.Top>, Payload> = {
3736
3828
  readonly [I in keyof Cancels]: WorkflowCancelOn<Cancels[I], Payload>;
3737
3829
  };
3738
3830
 
@@ -3887,6 +3979,8 @@ export declare interface WorkflowExecuteRecordingOptions extends WorkflowRunReco
3887
3979
  readonly replayShapeLimit?: number;
3888
3980
  }
3889
3981
 
3982
+ export declare type WorkflowExecutionRefusalRecordingOptions = WorkflowExecuteRecordingOptions & Required<Pick<WorkflowExecuteRecordingOptions, 'subject' | 'failureContext'>>;
3983
+
3890
3984
  export declare type WorkflowFailureDelivery = WorkflowFailureHandoff | {
3891
3985
  readonly kind: 'accepted';
3892
3986
  readonly executionId: string;
@@ -4043,7 +4137,7 @@ export declare const WorkflowFlowControlProperty = "__voltroWorkflowFlowControl"
4043
4137
  * meaning anything if this ever regresses to `any` — which is precisely what
4044
4138
  * all three failed attempts did.
4045
4139
  */
4046
- declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPayloadInput, Success extends Schema.Schema.Any = typeof Schema.Void, Error extends Schema.Schema.All = typeof Schema.Never, const Messages extends WorkflowMessageSchemas | undefined = undefined, Cancels extends ReadonlyArray<Schema.Schema.Any> = readonly []>(options: {
4140
+ declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPayloadInput, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never, const Messages extends WorkflowMessageSchemas | undefined = undefined, Cancels extends ReadonlyArray<Schema.Top> = readonly []>(options: {
4047
4141
  readonly name: Name;
4048
4142
  readonly payload: Payload;
4049
4143
  readonly idempotencyKey: (payload: DecodedPayload<Payload>) => string;
@@ -4061,13 +4155,15 @@ declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPa
4061
4155
  readonly schedule?: WorkflowScheduleDeclaration<DecodedPayload<Payload>>;
4062
4156
  } & Omit<WorkflowBaseOptions, 'name' | 'payload' | 'idempotencyKey' | 'success' | 'error'> & WorkflowVersionOptions & {
4063
4157
  readonly messages?: Messages;
4064
- } & WorkflowFlowControl<DecodedPayload<Payload>> & WorkflowAccessOptions<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
4158
+ } & WorkflowFlowControl<DecodedPayload<Payload>> & WorkflowAccessOptions<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> & {
4159
+ readonly name: Name;
4160
+ } & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
4065
4161
 
4066
4162
  declare type WorkflowMake = typeof workflowModule.make;
4067
4163
 
4068
4164
  export declare interface WorkflowMessagePairSchemas {
4069
- readonly payload: Schema.Schema.Any;
4070
- readonly success: Schema.Schema.Any;
4165
+ readonly payload: Schema.Top;
4166
+ readonly success: Schema.Top;
4071
4167
  }
4072
4168
 
4073
4169
  export declare interface WorkflowMessagesCarrier<M extends WorkflowMessagesMetadata = WorkflowMessagesMetadata> {
@@ -4085,12 +4181,12 @@ export declare interface WorkflowMessagesCarrier<M extends WorkflowMessagesMetad
4085
4181
  * and updates (synchronous, with a result) are the channels that exist.
4086
4182
  */
4087
4183
  export declare interface WorkflowMessageSchemas {
4088
- readonly signals?: Readonly<Record<string, Schema.Schema.Any>>;
4184
+ readonly signals?: Readonly<Record<string, Schema.Top>>;
4089
4185
  readonly updates?: Readonly<Record<string, WorkflowMessagePairSchemas>>;
4090
4186
  }
4091
4187
 
4092
4188
  export declare interface WorkflowMessagesMetadata {
4093
- readonly signals: Readonly<Record<string, Schema.Schema.Any>>;
4189
+ readonly signals: Readonly<Record<string, Schema.Top>>;
4094
4190
  readonly updates: Readonly<Record<string, WorkflowMessagePairSchemas>>;
4095
4191
  }
4096
4192
 
@@ -4308,7 +4404,7 @@ declare interface WorkflowRunOutcome {
4308
4404
  export declare class WorkflowRunRecorder extends WorkflowRunRecorder_base {
4309
4405
  }
4310
4406
 
4311
- declare const WorkflowRunRecorder_base: Context.TagClass<WorkflowRunRecorder, "@voltro/WorkflowRunRecorder", WorkflowRunRecorderService>;
4407
+ declare const WorkflowRunRecorder_base: Context.ServiceClass<WorkflowRunRecorder, "@voltro/WorkflowRunRecorder", WorkflowRunRecorderService>;
4312
4408
 
4313
4409
  export declare interface WorkflowRunRecorderOptions {
4314
4410
  readonly store: WorkflowRecordingStore;
@@ -4541,7 +4637,7 @@ export declare type WorkflowStartResolution = {
4541
4637
  * Receives the user's `execute` Effect + a `WorkflowStepContext`
4542
4638
  * carrying `{ runId, stepName, attempt }`. Returns a wrapped Effect.
4543
4639
  * A FAIL inside the interceptor abort the step the same way a fail
4544
- * in the user effect would — including triggering @effect/workflow's
4640
+ * in the user effect would — including triggering effect/workflow's
4545
4641
  * retry policy.
4546
4642
  */
4547
4643
  export declare interface WorkflowStepContext {
@@ -4567,7 +4663,7 @@ export declare interface WorkflowStepInterceptorService {
4567
4663
  export declare class WorkflowStepInterceptorTag extends WorkflowStepInterceptorTag_base {
4568
4664
  }
4569
4665
 
4570
- declare const WorkflowStepInterceptorTag_base: Context.TagClass<WorkflowStepInterceptorTag, "@voltro/WorkflowStepInterceptor", WorkflowStepInterceptorService>;
4666
+ declare const WorkflowStepInterceptorTag_base: Context.ServiceClass<WorkflowStepInterceptorTag, "@voltro/WorkflowStepInterceptor", WorkflowStepInterceptorService>;
4571
4667
 
4572
4668
  /**
4573
4669
  * Smooth throughput: excess starts QUEUE and are admitted as capacity frees up.
@@ -4650,7 +4746,7 @@ export declare interface WorkflowVersionOptions {
4650
4746
  * suspended-on-failure run shows up under `--status suspended`, NOT in the
4651
4747
  * dead-letter view — it is recoverable, not dead.
4652
4748
  *
4653
- * Maps to `@effect/workflow`'s `SuspendOnFailure` annotation.
4749
+ * Maps to `effect/workflow`'s `SuspendOnFailure` annotation.
4654
4750
  */
4655
4751
  readonly suspendOnFailure?: boolean;
4656
4752
  }