@makaio/framework 1.0.0-dev-1788258714339 → 1.0.0-dev-1788511348215

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 (86) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/attempt-record-codec-dC9LSFUE.mjs +1 -0
  3. package/dist/authority-state-bootstrap-eitx6Ukn.mjs +1 -0
  4. package/dist/bus/index.mjs +1 -1
  5. package/dist/capabilities-DEvmD9VJ.mjs +1 -0
  6. package/dist/{context-resolution-CW4OtPrS.d.mts → context-resolution-841T7jBI.d.mts} +2 -2
  7. package/dist/contracts/artifact/index.d.mts +2 -2
  8. package/dist/contracts/capabilities/index.d.mts +2 -2
  9. package/dist/contracts/capabilities/index.mjs +1 -1
  10. package/dist/contracts/client/index.d.mts +1 -1
  11. package/dist/contracts/extension/index.d.mts +2 -2
  12. package/dist/contracts/harness/index.d.mts +1 -1
  13. package/dist/contracts/index.d.mts +12 -12
  14. package/dist/contracts/index.mjs +1 -1
  15. package/dist/contracts/materialization/index.d.mts +3 -3
  16. package/dist/contracts/worker/index.d.mts +2 -0
  17. package/dist/contracts/worker/index.mjs +1 -0
  18. package/dist/contracts/workflow/index.d.mts +2 -2
  19. package/dist/contracts/workflow/index.mjs +1 -1
  20. package/dist/{execution-attempt-repository-BJ2W6wwx.d.mts → execution-attempt-repository-DY4KTptE.d.mts} +359 -57
  21. package/dist/{index-8NdPPzUh2.d.mts → index-6trZYnUP2.d.mts} +12 -12
  22. package/dist/{index-CPi0UpRh.d.mts → index-B_8bA2JW.d.mts} +1 -1
  23. package/dist/{index-DJ2KgJDJ2.d.mts → index-BmilK-co2.d.mts} +49 -49
  24. package/dist/{index-CMekqu_D.d.mts → index-C6aSnO8m.d.mts} +42 -42
  25. package/dist/{index-DXqG0r3o.d.mts → index-CDud4NAm.d.mts} +24 -24
  26. package/dist/{index-B9V3T4EQ.d.mts → index-D037TVsm.d.mts} +4 -4
  27. package/dist/{index-DWkFkvRn2.d.mts → index-D8D-yibS2.d.mts} +3 -3
  28. package/dist/{index-CYjgoYeX.d.mts → index-DHH-93YD.d.mts} +1 -1
  29. package/dist/{index-BqlCDBfc.d.mts → index-DI2lS7VT.d.mts} +3 -3
  30. package/dist/{index-C3lu_fy5.d.mts → index-DNI6UF9h.d.mts} +73 -73
  31. package/dist/{index-4KJ6IDE7.d.mts → index-DXtQRehh.d.mts} +6 -6
  32. package/dist/{index-OG402CBI.d.mts → index-Wbd_syN2.d.mts} +83 -83
  33. package/dist/kernel/extension/index.d.mts +1 -1
  34. package/dist/kernel/index.d.mts +2 -2
  35. package/dist/kernel/observability/index.d.mts +1 -1
  36. package/dist/{namespace-C06lJSuj.d.mts → namespace-K23m4b0n.d.mts} +6 -6
  37. package/dist/package-Cgjpm9om.mjs +7 -0
  38. package/dist/{package-BNFTUFLB.d.mts → package-efR90JGe.d.mts} +59 -30
  39. package/dist/package.json +1 -1
  40. package/dist/runtime-node/index.d.mts +1 -1
  41. package/dist/runtime-node/index.mjs +1 -1
  42. package/dist/runtime-node/makaio-config.d.mts +2 -2
  43. package/dist/runtime-node/makaio-config.mjs +1 -1
  44. package/dist/runtime-node/workflow-execution-bus-access.mjs +1 -1
  45. package/dist/runtime-node/workflow-worker/index.d.mts +2 -2
  46. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  47. package/dist/{schemas-OWvBn7AH.d.mts → schemas-BCXvEWyF.d.mts} +4 -4
  48. package/dist/{schemas-Dd0po67F.d.mts → schemas-D7EeKBDJ.d.mts} +5 -5
  49. package/dist/services/adapter-subsystem/index.d.mts +2 -2
  50. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  51. package/dist/services/harness/index.d.mts +3 -3
  52. package/dist/services/index.d.mts +9 -9
  53. package/dist/services/provider-context/index.d.mts +1 -1
  54. package/dist/services/session/index.d.mts +1 -1
  55. package/dist/services/settings/namespace.d.mts +4 -4
  56. package/dist/services/subagent-template/index.d.mts +1 -1
  57. package/dist/services/subagent-template/schemas.d.mts +1 -1
  58. package/dist/{transition-DXmCUq6w.d.mts → transition-D3zUBTPc.d.mts} +1 -1
  59. package/dist/ui-components/index.d.mts +4 -4
  60. package/dist/{view-builder-k82f5KFd.d.mts → view-builder-B0j9p5C0.d.mts} +1 -1
  61. package/dist/worker-CARV52hT.mjs +1 -0
  62. package/dist/worker-CLsRbzpk.mjs +1 -0
  63. package/dist/workflow-BomH9DBB.mjs +1 -0
  64. package/dist/workflow-engine/execution-attempt-repository.d.mts +2 -2
  65. package/dist/workflow-engine/execution-attempt-repository.mjs +1 -1
  66. package/dist/workflow-engine/index.d.mts +193 -38
  67. package/dist/workflow-engine/index.mjs +1 -1
  68. package/dist/workflow-engine/package.d.mts +1 -1
  69. package/dist/workflow-engine/package.mjs +1 -1
  70. package/dist/workflow-engine/testing/index.d.mts +30 -9
  71. package/dist/workflow-engine/testing/index.mjs +1 -1
  72. package/dist/workflow-engine/testing/sqlite.d.mts +3 -2
  73. package/dist/workflow-engine/testing/sqlite.mjs +20 -20
  74. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  75. package/dist/workflow-worker-Dul-wcOR.mjs +1 -0
  76. package/package.json +4 -4
  77. package/dist/attempt-record-codec-BYfYkj4M.mjs +0 -1
  78. package/dist/authority-state-bootstrap-CLYus369.mjs +0 -1
  79. package/dist/capabilities-BUwuA7XX.mjs +0 -1
  80. package/dist/contracts/worker-node/index.d.mts +0 -2
  81. package/dist/contracts/worker-node/index.mjs +0 -1
  82. package/dist/package-B01gmu75.mjs +0 -7
  83. package/dist/worker-node-CjuQb9hl.mjs +0 -1
  84. package/dist/worker-node-Dtf9ilsR.mjs +0 -1
  85. package/dist/workflow-C4mck_NW.mjs +0 -1
  86. package/dist/workflow-worker-aNbdgqml.mjs +0 -1
@@ -1,12 +1,12 @@
1
1
  import { a as ProviderOperationClaim, c as ProviderOperationObligation, i as ProcessBoundProvisionerLossProof, l as ProviderOperationOwnershipRecord, n as InitialProviderOperationClaimContextSource, o as ProviderOperationClaimDecision, r as PROVIDER_OPERATION_OBLIGATIONS, s as ProviderOperationMutationDecision, t as InitialProviderOperationClaimContext } from "../provider-operation-DbdyFwNm.mjs";
2
- import { A as RecoverableAttemptRecord, C as ProvisioningClaimDecision, D as RecordProviderOperationUncertaintyInput, E as RecordInfrastructureFailureInput, M as TakeOverProviderOperationInput, N as sameAllocationRef, O as RecordProvisionerIncarnationLostInput, P as sameWorkflowResult, S as ProvisioningAbsenceDecision, T as RecordAllocationTerminatedInput, _ as ExecutionAttemptStatus, a as BeginProvisioningInput, b as PendingAttemptAbandonmentDecision, c as EXECUTION_ATTEMPT_SETTLEMENT_KINDS, d as ExecutionAttemptOutcomeCommit, f as ExecutionAttemptOutcomeDecision, g as ExecutionAttemptSettlementKind, h as ExecutionAttemptRepository, i as AllocationTerminationDecision, j as RenewProviderOperationClaimInput, k as RecordProvisioningAbsentInput, l as EXECUTION_ATTEMPT_STATUSES, m as ExecutionAttemptRecoveryOperations, n as AllocationRefEvolution, o as DiscoveredAllocationDecision, p as ExecutionAttemptRecord, r as AllocationRefEvolutionDecision, s as DuplicateExecutionAttemptError, t as AllocationRecordingDecision, u as ExecutionAttemptCreate, v as HandoffProviderOperationInput, w as RecordAllocationInput, x as ProvisionerIncarnationLossDecision, y as InfrastructureFailureDecision } from "../execution-attempt-repository-BJ2W6wwx.mjs";
3
- import { a as WorkflowEngineServiceOptions, c as ExecutionAttemptAuthority, d as WorkflowWorkspaceRootResolver, f as registerDrizzleWorkflowStorage, i as WorkflowEngineService, l as WorkflowMaterializationSpecResolution, n as createWorkflowEnginePackage, o as WorkflowTriggerReconciler, r as workflowEnginePackage, s as WorkflowExecutor, t as WorkflowEngineToken, u as WorkflowMaterializationSpecResolver } from "../package-BNFTUFLB.mjs";
2
+ import { A as RecordProviderOperationUncertaintyInput, C as PendingAttemptAbandonmentDecision, D as RecordAllocationInput, E as ProvisioningClaimDecision, F as TakeOverProviderOperationInput, I as decodeDurableOutcome, L as durableOutcome, M as RecordProvisioningAbsentInput, N as RecoverableAttemptRecord, O as RecordAllocationTerminatedInput, P as RenewProviderOperationClaimInput, R as sameAllocationRef, S as OutcomeCodec, T as ProvisioningAbsenceDecision, _ as ExecutionAttemptSettlementKind, a as BeginProvisioningInput, b as HandoffProviderOperationInput, c as DurableOutcome, d as ExecutionAttemptCreate, f as ExecutionAttemptOutcomeCommit, g as ExecutionAttemptRepository, h as ExecutionAttemptRecoveryOperations, i as AllocationTerminationDecision, j as RecordProvisionerIncarnationLostInput, k as RecordInfrastructureFailureInput, l as EXECUTION_ATTEMPT_SETTLEMENT_KINDS, m as ExecutionAttemptRecord, n as AllocationRefEvolution, o as DiscoveredAllocationDecision, p as ExecutionAttemptOutcomeDecision, r as AllocationRefEvolutionDecision, s as DuplicateExecutionAttemptError, t as AllocationRecordingDecision, u as EXECUTION_ATTEMPT_STATUSES, v as ExecutionAttemptStatus, w as ProvisionerIncarnationLossDecision, x as InfrastructureFailureDecision, y as ExecutionOwnerId, z as sameDurableOutcome } from "../execution-attempt-repository-DY4KTptE.mjs";
3
+ import { a as WorkflowEngineServiceOptions, c as ExecutionAttemptAuthority, d as WorkflowWorkspaceRootResolver, f as registerDrizzleWorkflowStorage, i as WorkflowEngineService, l as WorkflowMaterializationSpecResolution, n as createWorkflowEnginePackage, o as WorkflowTriggerReconciler, r as workflowEnginePackage, s as WorkflowExecutor, t as WorkflowEngineToken, u as WorkflowMaterializationSpecResolver } from "../package-efR90JGe.mjs";
4
4
  import { WorkflowTriggerPayloadPredicate, assertWorkflowTriggerPayload, compileWorkflowTriggerBindingFilter } from "./workflow-trigger-binding-consumer.mjs";
5
5
  import { z } from "zod";
6
6
  import * as _$_makaio_core0 from "@makaio/framework/core";
7
7
  import { IMakaioBus } from "@makaio/framework/bus";
8
8
  import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
9
- import { JsonPatchOperation, JsonValue, WorkflowAutomationTriggerBinding, WorkflowExecution, WorkflowExecutionSchema, WorkflowListQuerySchema, WorkflowRunResult, WorkflowRunnerCompletion, createWorkflowFinalizerNamespace } from "@makaio/framework/contracts";
9
+ import { JsonPatchOperation, JsonValue, WorkflowAutomationTriggerBinding, WorkflowExecution, WorkflowExecutionSchema, WorkflowListQuerySchema, WorkflowRunResult, createWorkflowFinalizerNamespace } from "@makaio/framework/contracts";
10
10
  import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
11
11
  import * as _$drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
12
12
  import * as _$_makaio_storage_drizzle0 from "@makaio/framework/storage/drizzle";
@@ -26,26 +26,181 @@ interface WorkflowSuccessFinalizer {
26
26
  //#endregion
27
27
  //#region subsystems/workflow-engine/src/authority-dispatch-runner.d.ts
28
28
  /**
29
- * Inputs for dispatching an Authority-owned workflow attempt.
29
+ * Inputs for dispatching an Authority-owned attempt.
30
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
30
31
  */
31
- interface AuthorityDispatchRunnerOptions {
32
+ interface AuthorityDispatchRunnerOptions<TOutcome> {
32
33
  /** Authority that persists and owns the execution attempt. */
33
- readonly authority: ExecutionAttemptAuthority;
34
- /** Workflow execution that owns the attempt. */
35
- readonly executionId: string;
34
+ readonly authority: ExecutionAttemptAuthority<TOutcome>;
35
+ /** Owner identifier of the aggregate that owns the attempt. */
36
+ readonly executionId: ExecutionOwnerId;
36
37
  /** Dispatch operation whose successful return acknowledges acceptance. */
37
38
  readonly dispatch: (executionAttemptId: string) => Promise<unknown>;
38
39
  }
39
40
  /**
40
- * Dispatch an Authority-owned attempt and await its canonical terminal outcome.
41
+ * Dispatch an Authority-owned attempt and await its canonical outcome.
41
42
  *
42
43
  * A rejected dispatch operation is not proof that no provider received the
43
44
  * request. The pending-abandonment CAS distinguishes a confirmed pre-allocation
44
45
  * failure from a lost acknowledgement after provisioning, allocation, or settlement.
45
- * @param options - Authority, execution identity, and dispatch operation.
46
- * @returns The Authority-committed workflow completion.
46
+ * @param options - Authority, owner identity, and dispatch operation.
47
+ * @returns The Authority-committed outcome.
47
48
  */
48
- declare function runAuthorityDispatchedAttempt(options: AuthorityDispatchRunnerOptions): Promise<WorkflowRunnerCompletion>;
49
+ declare function runAuthorityDispatchedAttempt<TOutcome>(options: AuthorityDispatchRunnerOptions<TOutcome>): Promise<TOutcome>;
50
+ //#endregion
51
+ //#region subsystems/workflow-engine/src/outcome-convergence.d.ts
52
+ /**
53
+ * Input handed to {@link OutcomeConvergence.converge}.
54
+ *
55
+ * Named rather than inlined so an owner-side realization can state the shape
56
+ * it implements against, and so a consumer can pin it from the public surface.
57
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
58
+ */
59
+ interface OutcomeConvergenceInput<TOutcome> {
60
+ /** Owner identifier the attempt belongs to. */
61
+ readonly executionId: ExecutionOwnerId;
62
+ /** Authority-created attempt identifier. */
63
+ readonly executionAttemptId: string;
64
+ /** The canonical committed outcome, never the submitter's copy of it. */
65
+ readonly outcome: TOutcome;
66
+ /** The durable decision that produced the committed outcome. */
67
+ readonly decision: 'accepted' | 'duplicate';
68
+ }
69
+ /**
70
+ * Owner-side convergence of a committed attempt outcome.
71
+ *
72
+ * Runs after the durable commit and before waiter settlement and ACK. It is
73
+ * idempotent by contract: it is re-entered for every duplicate retry, because
74
+ * a worker whose first submission committed but did not converge resubmits
75
+ * the same outcome, receives `duplicate`, and must converge again.
76
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
77
+ */
78
+ interface OutcomeConvergence<TOutcome> {
79
+ /**
80
+ * Converge owner state with the committed outcome.
81
+ * @param input - Attempt identity, the canonical committed outcome, and the
82
+ * durable decision that produced it.
83
+ */
84
+ converge(input: OutcomeConvergenceInput<TOutcome>): Promise<void>;
85
+ }
86
+ /**
87
+ * Owner-side validation that runs before the durable commit.
88
+ *
89
+ * Performs reads only: an outcome it rejects never becomes an immutable
90
+ * attempt outcome, so a corrected retry is not answered as a conflict. What
91
+ * it inspects is the canonical outcome the attempt will hold, obtained from
92
+ * `ExecutionAttemptAuthority.canonicalizeOutcome` before the commit.
93
+ *
94
+ * **A realization must be retry-stable.** {@link submitAttemptOutcome} runs it
95
+ * ahead of every commit, including the retry of a submission that already
96
+ * committed, so its verdict may depend only on the submission itself and on
97
+ * owner facts no convergence step rewrites — never on owner state convergence
98
+ * moves forward. A validator that read, say, a mutable lifecycle status would
99
+ * reject the identical retry of an outcome its own convergence already
100
+ * committed, and the waiter for that outcome would never settle.
101
+ *
102
+ * Retry-stable is measured on the outcome, not on its text. A retry need not
103
+ * render the same text as the first commit: `sameDurableOutcome` judges
104
+ * two texts the same outcome whatever member order they carry and answers
105
+ * `duplicate` for such a retry, while the validator sees the retry's own
106
+ * canonical rendering, never the stored one. Its verdict may therefore turn
107
+ * only on what `sameDurableOutcome` compares — the members and their values
108
+ * — and never on member order or any other detail of one particular
109
+ * rendering. A validator that keyed on which member comes first would reject
110
+ * the retry the repository is about to report as `duplicate`, and the
111
+ * committed-but-unconverged waiter could never recover. Validating the stored
112
+ * representation instead is not an option, for the reason the next paragraph
113
+ * gives: validation runs ahead of the commit, where the retry's rendering is
114
+ * the only one there is.
115
+ *
116
+ * The rule is stated here rather than worked around downstream because the
117
+ * order it constrains is the one that keeps a spoofed outcome out of durable
118
+ * storage: validation cannot move behind the commit without committing what
119
+ * it exists to reject. The workflow adapter's `validateOutcomeExecutionIdentity`
120
+ * satisfies it by correlating the submitted result against immutable durable
121
+ * identity — the execution's own id and workflow id, and the run context's
122
+ * terminal-authority binding, none of which outcome convergence touches.
123
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
124
+ */
125
+ interface OutcomePreCommitValidation<TOutcome> {
126
+ /**
127
+ * Validate an outcome against owner state.
128
+ *
129
+ * Called again for every retry of the same submission, so the same outcome
130
+ * owes the same verdict — the same as `sameDurableOutcome` reads it,
131
+ * which ignores member order and every other rendering detail, not the
132
+ * same text.
133
+ *
134
+ * The outcome handed over is the canonical one — what the attempt will
135
+ * hold and what {@link OutcomeConvergence.converge} will receive — not the
136
+ * submitter's copy of it. A codec may normalize while serializing, so
137
+ * validating the copy would let an outcome the validator would have
138
+ * rejected become the immutable committed one.
139
+ * @param executionId - Owner identifier the attempt belongs to.
140
+ * @param outcome - Canonical outcome about to be committed.
141
+ * @throws When the outcome must not be committed.
142
+ */
143
+ validate(executionId: ExecutionOwnerId, outcome: TOutcome): Promise<void>;
144
+ }
145
+ /**
146
+ * Dependencies of {@link submitAttemptOutcome}.
147
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
148
+ */
149
+ interface AttemptOutcomeSubmissionDeps<TOutcome> {
150
+ /** Authority that commits the outcome and holds the in-process waiter. */
151
+ readonly authority: ExecutionAttemptAuthority<TOutcome>;
152
+ /** Owner convergence that runs for `accepted` and `duplicate` decisions. */
153
+ readonly convergence: OutcomeConvergence<TOutcome>;
154
+ /** Optional owner validation that runs before the durable commit. */
155
+ readonly validation?: OutcomePreCommitValidation<TOutcome>;
156
+ }
157
+ /**
158
+ * Input of {@link submitAttemptOutcome}.
159
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
160
+ */
161
+ interface AttemptOutcomeSubmission<TOutcome> {
162
+ /** Owner identifier the attempt belongs to. */
163
+ readonly executionId: ExecutionOwnerId;
164
+ /** Authority-created attempt identifier. */
165
+ readonly executionAttemptId: string;
166
+ /** Outcome the worker submitted. */
167
+ readonly outcome: TOutcome;
168
+ }
169
+ /**
170
+ * Submit an attempt outcome through the generic owner boundary.
171
+ *
172
+ * Order: one canonicalization of the submitted outcome, optional pre-commit
173
+ * validation of that canonical value, durable commit of that same rendering
174
+ * through the authority, owner convergence for `accepted` and `duplicate`,
175
+ * then waiter settlement on a fresh decode of the text the decision reports
176
+ * as committed. The decision kind is returned for the caller's
177
+ * acknowledgement.
178
+ *
179
+ * Invariants this function keeps:
180
+ * - the submission is rendered exactly once, and the submitter's object is
181
+ * never read again after that: an outcome the caller mutates while an await
182
+ * is pending can reach neither the validation nor the durable write;
183
+ * - validation and convergence see one and the same value: the canonical
184
+ * outcome the attempt holds, never the submitter's copy of it;
185
+ * - convergence only ever sees `decision.outcome`, the repository's own
186
+ * committed object;
187
+ * - the waiter settles on a value decoded afresh from the text the attempt
188
+ * stores — the decision's own text, which for a `duplicate` is the first
189
+ * commit's rather than the retry's — so what a runner receives is the
190
+ * committed outcome even when convergence mutated the object it was handed;
191
+ * - a throwing convergence leaves the outcome durably committed and the
192
+ * waiter pending, so the worker's retry yields `duplicate` and converges
193
+ * again; nothing is rejected or deleted here. That recovery path runs the
194
+ * validation again first, which is why {@link OutcomePreCommitValidation}
195
+ * owes a retry-stable verdict;
196
+ * - `conflict` and `fenced` skip convergence and settlement; their waiter
197
+ * rejection already happened inside `ExecutionAttemptAuthority.commitOutcome`.
198
+ * @param deps - Authority, convergence, and optional validation.
199
+ * @param input - Attempt identity and submitted outcome.
200
+ * @returns The durable decision kind.
201
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
202
+ */
203
+ declare function submitAttemptOutcome<TOutcome>(deps: AttemptOutcomeSubmissionDeps<TOutcome>, input: AttemptOutcomeSubmission<TOutcome>): Promise<'accepted' | 'duplicate' | 'conflict' | 'fenced'>;
49
204
  //#endregion
50
205
  //#region subsystems/workflow-engine/src/storage/namespace.d.ts
51
206
  /**
@@ -1190,8 +1345,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1190
1345
  cancelled: "cancelled";
1191
1346
  failed: "failed";
1192
1347
  running: "running";
1193
- skipped: "skipped";
1194
1348
  waiting: "waiting";
1349
+ skipped: "skipped";
1195
1350
  }>;
1196
1351
  attempt: z.ZodDefault<z.ZodNumber>;
1197
1352
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -1236,8 +1391,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1236
1391
  cancelled: "cancelled";
1237
1392
  failed: "failed";
1238
1393
  running: "running";
1239
- skipped: "skipped";
1240
1394
  waiting: "waiting";
1395
+ skipped: "skipped";
1241
1396
  }>;
1242
1397
  attempt: z.ZodDefault<z.ZodNumber>;
1243
1398
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -1279,8 +1434,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1279
1434
  cancelled: "cancelled";
1280
1435
  failed: "failed";
1281
1436
  running: "running";
1282
- skipped: "skipped";
1283
1437
  waiting: "waiting";
1438
+ skipped: "skipped";
1284
1439
  }>;
1285
1440
  attempt: z.ZodDefault<z.ZodNumber>;
1286
1441
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -1307,8 +1462,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1307
1462
  status: z.ZodEnum<{
1308
1463
  cancelled: "cancelled";
1309
1464
  rejected: "rejected";
1310
- resumed: "resumed";
1311
1465
  waiting: "waiting";
1466
+ resumed: "resumed";
1312
1467
  "timed-out": "timed-out";
1313
1468
  }>;
1314
1469
  autoAction: z.ZodEnum<{
@@ -1439,8 +1594,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1439
1594
  status: z.ZodEnum<{
1440
1595
  cancelled: "cancelled";
1441
1596
  rejected: "rejected";
1442
- resumed: "resumed";
1443
1597
  waiting: "waiting";
1598
+ resumed: "resumed";
1444
1599
  "timed-out": "timed-out";
1445
1600
  }>;
1446
1601
  autoAction: z.ZodEnum<{
@@ -1464,8 +1619,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1464
1619
  status: z.ZodOptional<z.ZodEnum<{
1465
1620
  cancelled: "cancelled";
1466
1621
  rejected: "rejected";
1467
- resumed: "resumed";
1468
1622
  waiting: "waiting";
1623
+ resumed: "resumed";
1469
1624
  "timed-out": "timed-out";
1470
1625
  }>>;
1471
1626
  limit: z.ZodDefault<z.ZodNumber>;
@@ -1480,8 +1635,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1480
1635
  status: z.ZodEnum<{
1481
1636
  cancelled: "cancelled";
1482
1637
  rejected: "rejected";
1483
- resumed: "resumed";
1484
1638
  waiting: "waiting";
1639
+ resumed: "resumed";
1485
1640
  "timed-out": "timed-out";
1486
1641
  }>;
1487
1642
  autoAction: z.ZodEnum<{
@@ -1515,8 +1670,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1515
1670
  status: z.ZodEnum<{
1516
1671
  cancelled: "cancelled";
1517
1672
  rejected: "rejected";
1518
- resumed: "resumed";
1519
1673
  waiting: "waiting";
1674
+ resumed: "resumed";
1520
1675
  "timed-out": "timed-out";
1521
1676
  }>;
1522
1677
  autoAction: z.ZodEnum<{
@@ -2972,7 +3127,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
2972
3127
  tableName: "workflow_execution_frames";
2973
3128
  dataType: "string";
2974
3129
  columnType: "SQLiteText";
2975
- data: "pending" | "completed" | "cancelled" | "failed" | "running" | "skipped" | "waiting";
3130
+ data: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
2976
3131
  driverParam: string;
2977
3132
  notNull: true;
2978
3133
  hasDefault: true;
@@ -2985,7 +3140,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
2985
3140
  generated: undefined;
2986
3141
  }, {}, {
2987
3142
  length: number | undefined;
2988
- $type: "pending" | "completed" | "cancelled" | "failed" | "running" | "skipped" | "waiting";
3143
+ $type: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
2989
3144
  }>;
2990
3145
  attempt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
2991
3146
  name: string;
@@ -3255,7 +3410,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
3255
3410
  tableName: "workflow_gate_instances";
3256
3411
  dataType: "string";
3257
3412
  columnType: "SQLiteText";
3258
- data: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
3413
+ data: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
3259
3414
  driverParam: string;
3260
3415
  notNull: true;
3261
3416
  hasDefault: true;
@@ -3268,7 +3423,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
3268
3423
  generated: undefined;
3269
3424
  }, {}, {
3270
3425
  length: number | undefined;
3271
- $type: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
3426
+ $type: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
3272
3427
  }>;
3273
3428
  autoAction: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3274
3429
  name: "auto_action";
@@ -4767,7 +4922,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
4767
4922
  tableName: "worklog_frame_entries";
4768
4923
  dataType: "string";
4769
4924
  columnType: "SQLiteText";
4770
- data: "pending" | "completed" | "cancelled" | "failed" | "running" | "skipped" | "waiting";
4925
+ data: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
4771
4926
  driverParam: string;
4772
4927
  notNull: true;
4773
4928
  hasDefault: false;
@@ -5201,7 +5356,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
5201
5356
  tableName: "worklog_gate_events";
5202
5357
  dataType: "string";
5203
5358
  columnType: "SQLiteText";
5204
- data: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
5359
+ data: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
5205
5360
  driverParam: string;
5206
5361
  notNull: true;
5207
5362
  hasDefault: false;
@@ -5214,7 +5369,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
5214
5369
  generated: undefined;
5215
5370
  }, {}, {
5216
5371
  length: number | undefined;
5217
- $type: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
5372
+ $type: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
5218
5373
  }>;
5219
5374
  prompt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
5220
5375
  name: "prompt";
@@ -6813,8 +6968,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6813
6968
  cancelled: "cancelled";
6814
6969
  failed: "failed";
6815
6970
  running: "running";
6816
- skipped: "skipped";
6817
6971
  waiting: "waiting";
6972
+ skipped: "skipped";
6818
6973
  }>;
6819
6974
  attempt: z.ZodDefault<z.ZodNumber>;
6820
6975
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -6859,8 +7014,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6859
7014
  cancelled: "cancelled";
6860
7015
  failed: "failed";
6861
7016
  running: "running";
6862
- skipped: "skipped";
6863
7017
  waiting: "waiting";
7018
+ skipped: "skipped";
6864
7019
  }>;
6865
7020
  attempt: z.ZodDefault<z.ZodNumber>;
6866
7021
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -6902,8 +7057,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6902
7057
  cancelled: "cancelled";
6903
7058
  failed: "failed";
6904
7059
  running: "running";
6905
- skipped: "skipped";
6906
7060
  waiting: "waiting";
7061
+ skipped: "skipped";
6907
7062
  }>;
6908
7063
  attempt: z.ZodDefault<z.ZodNumber>;
6909
7064
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -6930,8 +7085,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6930
7085
  status: z.ZodEnum<{
6931
7086
  cancelled: "cancelled";
6932
7087
  rejected: "rejected";
6933
- resumed: "resumed";
6934
7088
  waiting: "waiting";
7089
+ resumed: "resumed";
6935
7090
  "timed-out": "timed-out";
6936
7091
  }>;
6937
7092
  autoAction: z.ZodEnum<{
@@ -7062,8 +7217,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7062
7217
  status: z.ZodEnum<{
7063
7218
  cancelled: "cancelled";
7064
7219
  rejected: "rejected";
7065
- resumed: "resumed";
7066
7220
  waiting: "waiting";
7221
+ resumed: "resumed";
7067
7222
  "timed-out": "timed-out";
7068
7223
  }>;
7069
7224
  autoAction: z.ZodEnum<{
@@ -7087,8 +7242,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7087
7242
  status: z.ZodOptional<z.ZodEnum<{
7088
7243
  cancelled: "cancelled";
7089
7244
  rejected: "rejected";
7090
- resumed: "resumed";
7091
7245
  waiting: "waiting";
7246
+ resumed: "resumed";
7092
7247
  "timed-out": "timed-out";
7093
7248
  }>>;
7094
7249
  limit: z.ZodDefault<z.ZodNumber>;
@@ -7103,8 +7258,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7103
7258
  status: z.ZodEnum<{
7104
7259
  cancelled: "cancelled";
7105
7260
  rejected: "rejected";
7106
- resumed: "resumed";
7107
7261
  waiting: "waiting";
7262
+ resumed: "resumed";
7108
7263
  "timed-out": "timed-out";
7109
7264
  }>;
7110
7265
  autoAction: z.ZodEnum<{
@@ -7138,8 +7293,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7138
7293
  status: z.ZodEnum<{
7139
7294
  cancelled: "cancelled";
7140
7295
  rejected: "rejected";
7141
- resumed: "resumed";
7142
7296
  waiting: "waiting";
7297
+ resumed: "resumed";
7143
7298
  "timed-out": "timed-out";
7144
7299
  }>;
7145
7300
  autoAction: z.ZodEnum<{
@@ -7767,7 +7922,7 @@ declare const workflowDefinitionsDual: _$_makaio_storage_drizzle0.DualTable<"wor
7767
7922
  }>>;
7768
7923
  /**
7769
7924
  * Portable executable source for worker dispatch (JSON).
7770
- * Tells the runtime where to load the workflow module on a worker node.
7925
+ * Tells the runtime where to load the workflow module on a worker.
7771
7926
  */
7772
7927
  executableSource: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.$Type<_$drizzle_orm_sqlite_core0.SQLiteTextJsonBuilderInitial<string>, {
7773
7928
  kind: "path";
@@ -7791,7 +7946,7 @@ declare const workflowDefinitionsDual: _$_makaio_storage_drizzle0.DualTable<"wor
7791
7946
  workflowId: string;
7792
7947
  }>>;
7793
7948
  /**
7794
- * Resource requirements for WorkerNode provider selection (JSON).
7949
+ * Resource requirements for Worker provider selection (JSON).
7795
7950
  * Constrains pool/provider matching during dispatch.
7796
7951
  */
7797
7952
  requirements: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.$Type<_$drizzle_orm_sqlite_core0.SQLiteTextJsonBuilderInitial<string>, {
@@ -8067,4 +8222,4 @@ declare function patchWorkflowState(db: MakaioDatabase, params: {
8067
8222
  value: JsonValue;
8068
8223
  }>;
8069
8224
  //#endregion
8070
- export { type AllocationRecordingDecision, type AllocationRefEvolution, type AllocationRefEvolutionDecision, type AllocationTerminationDecision, type AuthorityDispatchRunnerOptions, type BeginProvisioningInput, type DiscoveredAllocationDecision, DuplicateExecutionAttemptError, EXECUTION_ATTEMPT_SETTLEMENT_KINDS, EXECUTION_ATTEMPT_STATUSES, ExecutionAttemptAuthority, type ExecutionAttemptCreate, type ExecutionAttemptOutcomeCommit, type ExecutionAttemptOutcomeDecision, type ExecutionAttemptRecord, type ExecutionAttemptRecoveryOperations, type ExecutionAttemptRepository, type ExecutionAttemptSettlementKind, type ExecutionAttemptStatus, type HandoffProviderOperationInput, type InfrastructureFailureDecision, type InitialProviderOperationClaimContext, type InitialProviderOperationClaimContextSource, PROVIDER_OPERATION_OBLIGATIONS, type PendingAttemptAbandonmentDecision, type ProcessBoundProvisionerLossProof, type ProviderOperationClaim, type ProviderOperationClaimDecision, type ProviderOperationMutationDecision, type ProviderOperationObligation, type ProviderOperationOwnershipRecord, type ProvisionerIncarnationLossDecision, type ProvisioningAbsenceDecision, type ProvisioningClaimDecision, type RecordAllocationInput, type RecordAllocationTerminatedInput, type RecordInfrastructureFailureInput, type RecordProviderOperationUncertaintyInput, type RecordProvisionerIncarnationLostInput, type RecordProvisioningAbsentInput, type RecoverableAttemptRecord, type RenewProviderOperationClaimInput, type TakeOverProviderOperationInput, WorkflowEngineService, type WorkflowEngineServiceOptions, WorkflowEngineToken, WorkflowExecutor, type WorkflowMaterializationSpecResolution, type WorkflowMaterializationSpecResolver, WorkflowStorageNamespace, WorkflowStorageSubjects, type WorkflowSuccessFinalizer, type WorkflowTriggerPayloadPredicate, WorkflowTriggerReconciler, type WorkflowWorkspaceRootResolver, assertWorkflowTriggerPayload, buildWorkflowExpressionContextFromResolvedInputs, compileWorkflowTriggerBindingFilter, createWorkflowEnginePackage, getWorkflowState, initializeWorkflowState, patchWorkflowState, registerDrizzleWorkflowStorage, runAuthorityDispatchedAttempt, runShellStep, sameAllocationRef, sameWorkflowResult, workflowDefinitionsDual, workflowEnginePackage, workflowExecutionStateDual, workflowExecutionStateEventsDual, workflowExecutionsDual, workflowFinalizationsDual, workflowStepSpansDual, worklogFrameEntriesDual, worklogSummariesDual };
8225
+ export { type AllocationRecordingDecision, type AllocationRefEvolution, type AllocationRefEvolutionDecision, type AllocationTerminationDecision, type AttemptOutcomeSubmission, type AttemptOutcomeSubmissionDeps, type AuthorityDispatchRunnerOptions, type BeginProvisioningInput, type DiscoveredAllocationDecision, DuplicateExecutionAttemptError, type DurableOutcome, EXECUTION_ATTEMPT_SETTLEMENT_KINDS, EXECUTION_ATTEMPT_STATUSES, ExecutionAttemptAuthority, type ExecutionAttemptCreate, type ExecutionAttemptOutcomeCommit, type ExecutionAttemptOutcomeDecision, type ExecutionAttemptRecord, type ExecutionAttemptRecoveryOperations, type ExecutionAttemptRepository, type ExecutionAttemptSettlementKind, type ExecutionAttemptStatus, type ExecutionOwnerId, type HandoffProviderOperationInput, type InfrastructureFailureDecision, type InitialProviderOperationClaimContext, type InitialProviderOperationClaimContextSource, type OutcomeCodec, type OutcomeConvergence, type OutcomeConvergenceInput, type OutcomePreCommitValidation, PROVIDER_OPERATION_OBLIGATIONS, type PendingAttemptAbandonmentDecision, type ProcessBoundProvisionerLossProof, type ProviderOperationClaim, type ProviderOperationClaimDecision, type ProviderOperationMutationDecision, type ProviderOperationObligation, type ProviderOperationOwnershipRecord, type ProvisionerIncarnationLossDecision, type ProvisioningAbsenceDecision, type ProvisioningClaimDecision, type RecordAllocationInput, type RecordAllocationTerminatedInput, type RecordInfrastructureFailureInput, type RecordProviderOperationUncertaintyInput, type RecordProvisionerIncarnationLostInput, type RecordProvisioningAbsentInput, type RecoverableAttemptRecord, type RenewProviderOperationClaimInput, type TakeOverProviderOperationInput, WorkflowEngineService, type WorkflowEngineServiceOptions, WorkflowEngineToken, WorkflowExecutor, type WorkflowMaterializationSpecResolution, type WorkflowMaterializationSpecResolver, WorkflowStorageNamespace, WorkflowStorageSubjects, type WorkflowSuccessFinalizer, type WorkflowTriggerPayloadPredicate, WorkflowTriggerReconciler, type WorkflowWorkspaceRootResolver, assertWorkflowTriggerPayload, buildWorkflowExpressionContextFromResolvedInputs, compileWorkflowTriggerBindingFilter, createWorkflowEnginePackage, decodeDurableOutcome, durableOutcome, getWorkflowState, initializeWorkflowState, patchWorkflowState, registerDrizzleWorkflowStorage, runAuthorityDispatchedAttempt, runShellStep, sameAllocationRef, sameDurableOutcome, submitAttemptOutcome, workflowDefinitionsDual, workflowEnginePackage, workflowExecutionStateDual, workflowExecutionStateEventsDual, workflowExecutionsDual, workflowFinalizationsDual, workflowStepSpansDual, worklogFrameEntriesDual, worklogSummariesDual };
@@ -1 +1 @@
1
- import{B as e,H as t,M as n,P as r,T as i,W as a,X as o,et as s,g as c,it as l,j as u,ot as d}from"../authority-state-bootstrap-CLYus369.mjs";import{a as f,c as p,d as m,i as h,l as g,n as _,o as v,r as y,s as b,t as x,u as S}from"../package-B01gmu75.mjs";import{assertWorkflowTriggerPayload as C,compileWorkflowTriggerBindingFilter as w}from"./workflow-trigger-binding-consumer.mjs";import{DuplicateExecutionAttemptError as T,EXECUTION_ATTEMPT_SETTLEMENT_KINDS as E,EXECUTION_ATTEMPT_STATUSES as D,sameAllocationRef as O,sameWorkflowResult as k}from"./execution-attempt-repository.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as A}from"./provider-operation.mjs";import{JsonValueSchema as j,WorkflowFrameStateSchema as M}from"@makaio/framework/contracts";const N=new Set([...M.shape.status.options]);function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F(e){if(!P(e))return!1;for(let t of Object.values(e))if(!P(t)||typeof t.status!=`string`||!N.has(t.status)||`result`in t&&t.result!==void 0&&!j.safeParse(t.result).success)return!1;return!0}function I(e){let t={trigger:P(e.trigger)?e.trigger:{},steps:F(e.steps)?e.steps:{},inputs:j.safeParse(e.inputs).success?e.inputs:{}};return`item`in e&&(t.item=e.item),typeof e.index==`number`&&(t.index=e.index),t}export{T as DuplicateExecutionAttemptError,E as EXECUTION_ATTEMPT_SETTLEMENT_KINDS,D as EXECUTION_ATTEMPT_STATUSES,f as ExecutionAttemptAuthority,A as PROVIDER_OPERATION_OBLIGATIONS,h as WorkflowEngineService,x as WorkflowEngineToken,b as WorkflowExecutor,u as WorkflowStorageNamespace,n as WorkflowStorageSubjects,v as WorkflowTriggerReconciler,C as assertWorkflowTriggerPayload,I as buildWorkflowExpressionContextFromResolvedInputs,w as compileWorkflowTriggerBindingFilter,_ as createWorkflowEnginePackage,g as getWorkflowState,S as initializeWorkflowState,m as patchWorkflowState,p as registerDrizzleWorkflowStorage,c as runAuthorityDispatchedAttempt,i as runShellStep,O as sameAllocationRef,k as sameWorkflowResult,r as workflowDefinitionsDual,y as workflowEnginePackage,e as workflowExecutionStateDual,t as workflowExecutionStateEventsDual,a as workflowExecutionsDual,d as workflowFinalizationsDual,o as workflowStepSpansDual,s as worklogFrameEntriesDual,l as worklogSummariesDual};
1
+ import{B as e,H as t,M as n,P as r,T as i,W as a,X as o,et as s,g as c,it as l,j as u,ot as d}from"../authority-state-bootstrap-eitx6Ukn.mjs";import{a as f,c as p,d as m,f as h,i as g,l as _,n as v,o as y,r as b,s as x,t as S,u as C}from"../package-Cgjpm9om.mjs";import{assertWorkflowTriggerPayload as w,compileWorkflowTriggerBindingFilter as T}from"./workflow-trigger-binding-consumer.mjs";import{DuplicateExecutionAttemptError as E,EXECUTION_ATTEMPT_SETTLEMENT_KINDS as D,EXECUTION_ATTEMPT_STATUSES as O,decodeDurableOutcome as k,durableOutcome as A,sameAllocationRef as j,sameDurableOutcome as M}from"./execution-attempt-repository.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as N}from"./provider-operation.mjs";import{JsonValueSchema as P,WorkflowFrameStateSchema as F}from"@makaio/framework/contracts";const I=new Set([...F.shape.status.options]);function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){if(!L(e))return!1;for(let t of Object.values(e))if(!L(t)||typeof t.status!=`string`||!I.has(t.status)||`result`in t&&t.result!==void 0&&!P.safeParse(t.result).success)return!1;return!0}function z(e){let t={trigger:L(e.trigger)?e.trigger:{},steps:R(e.steps)?e.steps:{},inputs:P.safeParse(e.inputs).success?e.inputs:{}};return`item`in e&&(t.item=e.item),typeof e.index==`number`&&(t.index=e.index),t}export{E as DuplicateExecutionAttemptError,D as EXECUTION_ATTEMPT_SETTLEMENT_KINDS,O as EXECUTION_ATTEMPT_STATUSES,f as ExecutionAttemptAuthority,N as PROVIDER_OPERATION_OBLIGATIONS,g as WorkflowEngineService,S as WorkflowEngineToken,x as WorkflowExecutor,u as WorkflowStorageNamespace,n as WorkflowStorageSubjects,y as WorkflowTriggerReconciler,w as assertWorkflowTriggerPayload,z as buildWorkflowExpressionContextFromResolvedInputs,T as compileWorkflowTriggerBindingFilter,v as createWorkflowEnginePackage,k as decodeDurableOutcome,A as durableOutcome,C as getWorkflowState,m as initializeWorkflowState,h as patchWorkflowState,_ as registerDrizzleWorkflowStorage,c as runAuthorityDispatchedAttempt,i as runShellStep,j as sameAllocationRef,M as sameDurableOutcome,p as submitAttemptOutcome,r as workflowDefinitionsDual,b as workflowEnginePackage,e as workflowExecutionStateDual,t as workflowExecutionStateEventsDual,a as workflowExecutionsDual,d as workflowFinalizationsDual,o as workflowStepSpansDual,s as worklogFrameEntriesDual,l as worklogSummariesDual};
@@ -1,2 +1,2 @@
1
- import { n as createWorkflowEnginePackage, r as workflowEnginePackage, t as WorkflowEngineToken } from "../package-BNFTUFLB.mjs";
1
+ import { n as createWorkflowEnginePackage, r as workflowEnginePackage, t as WorkflowEngineToken } from "../package-efR90JGe.mjs";
2
2
  export { WorkflowEngineToken, createWorkflowEnginePackage, workflowEnginePackage };
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"../package-B01gmu75.mjs";export{n as WorkflowEngineToken,e as createWorkflowEnginePackage,t as workflowEnginePackage};
1
+ import{n as e,r as t,t as n}from"../package-Cgjpm9om.mjs";export{n as WorkflowEngineToken,e as createWorkflowEnginePackage,t as workflowEnginePackage};
@@ -1,5 +1,5 @@
1
1
  import { a as ProviderOperationClaim, i as ProcessBoundProvisionerLossProof, l as ProviderOperationOwnershipRecord } from "../../provider-operation-DbdyFwNm.mjs";
2
- import { C as ProvisioningClaimDecision, a as BeginProvisioningInput, h as ExecutionAttemptRepository, p as ExecutionAttemptRecord } from "../../execution-attempt-repository-BJ2W6wwx.mjs";
2
+ import { E as ProvisioningClaimDecision, S as OutcomeCodec, a as BeginProvisioningInput, g as ExecutionAttemptRepository, m as ExecutionAttemptRecord } from "../../execution-attempt-repository-DY4KTptE.mjs";
3
3
  import { BoundedRecoveryEvidence, ProviderAllocationRef, WorkflowRunResult } from "@makaio/framework/contracts";
4
4
 
5
5
  //#region subsystems/workflow-engine/src/testing/in-memory-attempt-repository.d.ts
@@ -7,17 +7,30 @@ import { BoundedRecoveryEvidence, ProviderAllocationRef, WorkflowRunResult } fro
7
7
  * Durable state the in-memory realization keeps.
8
8
  *
9
9
  * The four maps mirror the four durable facts the port owns: canonical attempt
10
- * state, fenced provider-operation ownership, committed workflow outcomes, and
11
- * which attempt is currently active for an execution. They are exposed so a
12
- * test can seed state before the first call and assert against it afterwards.
10
+ * state, fenced provider-operation ownership, committed outcomes, and which
11
+ * attempt is currently active for an owner. They are exposed so a test can
12
+ * seed state before the first call and assert against it afterwards.
13
+ *
14
+ * Not generic over the outcome type: the committed outcomes are held as the
15
+ * codec's durable text, the same representation a store's column holds, so
16
+ * none of the four maps carries an outcome-typed value.
13
17
  */
14
18
  interface InMemoryAttemptRepositoryState {
15
19
  /** Attempt records keyed by `executionAttemptId`. */
16
20
  readonly attempts: Map<string, ExecutionAttemptRecord>;
17
21
  /** Provider operation records keyed by `executionAttemptId`. */
18
22
  readonly operations: Map<string, ProviderOperationOwnershipRecord>;
19
- /** Committed canonical outcomes keyed by `executionAttemptId`. */
20
- readonly committedOutcomes: Map<string, WorkflowRunResult>;
23
+ /**
24
+ * Committed outcome texts keyed by `executionAttemptId`.
25
+ *
26
+ * The codec text and nothing else, exactly the `workflow_result` column a
27
+ * durable realization keeps: it is what a retry is compared against, and
28
+ * every outcome the port reports is a fresh decode of it. Keeping the
29
+ * decoded value here instead would hand every reader one shared instance,
30
+ * and a codec may reconstruct a mutable object — a `URL`, say — that no
31
+ * freeze can protect.
32
+ */
33
+ readonly committedOutcomes: Map<string, string>;
21
34
  /** Active attempt per `executionId`, the fence every bootstrap path reads. */
22
35
  readonly activeAttempts: Map<string, string>;
23
36
  }
@@ -30,8 +43,9 @@ interface InMemoryAttemptRepositoryState {
30
43
  * a single failing durable write without losing the rest of the state machine.
31
44
  * Replacing a recovery operation means spreading `recovery` too, which is the
32
45
  * port's own rule that recovery is offered whole or not at all.
46
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
33
47
  */
34
- interface InMemoryAttemptRepository extends Required<ExecutionAttemptRepository>, InMemoryAttemptRepositoryState {}
48
+ interface InMemoryAttemptRepository<TOutcome> extends Required<ExecutionAttemptRepository<TOutcome>>, InMemoryAttemptRepositoryState {}
35
49
  /**
36
50
  * Create the in-memory reference realization of {@link ExecutionAttemptRepository}.
37
51
  *
@@ -55,10 +69,12 @@ interface InMemoryAttemptRepository extends Required<ExecutionAttemptRepository>
55
69
  * model transaction isolation. Use it wherever a test needs the port's
56
70
  * decisions without a database, and `createSqliteAttemptRepository` when the
57
71
  * test needs real transactional fencing between two independent connections.
72
+ * @param codec - Owner-injected codec that validates every submitted outcome.
58
73
  * @param seed - Pre-existing state to build on, shared with the caller.
59
74
  * @returns A repository exposing the full port surface, plus its backing state.
75
+ * @typeParam TOutcome - Owner-specific outcome type committed per attempt.
60
76
  */
61
- declare function createInMemoryAttemptRepository(seed?: Partial<InMemoryAttemptRepositoryState>): InMemoryAttemptRepository;
77
+ declare function createInMemoryAttemptRepository<TOutcome>(codec: OutcomeCodec<TOutcome>, seed?: Partial<InMemoryAttemptRepositoryState>): InMemoryAttemptRepository<TOutcome>;
62
78
  //#endregion
63
79
  //#region subsystems/workflow-engine/src/testing/attempt-fixtures.d.ts
64
80
  /** Controller process incarnation used by tests that need one fixed owner. */
@@ -135,6 +151,11 @@ declare function makeProcessLossProof(provisionerIncarnationId?: string, evidenc
135
151
  * @returns A versioned allocation reference.
136
152
  */
137
153
  declare function makeTestAllocationRef(providerId?: string, providerData?: Record<string, unknown>): ProviderAllocationRef;
154
+ /**
155
+ * Outcome codec for the workflow adapter: validates through
156
+ * {@link WorkflowRunResultSchema} and persists the canonical JSON text.
157
+ */
158
+ declare const workflowRunResultOutcomeCodec: OutcomeCodec<WorkflowRunResult>;
138
159
  /**
139
160
  * Build a terminal workflow result the port can commit.
140
161
  * @param executionId - Execution the result belongs to.
@@ -143,4 +164,4 @@ declare function makeTestAllocationRef(providerId?: string, providerData?: Recor
143
164
  */
144
165
  declare function makeTestWorkflowResult(executionId: string, status?: 'completed' | 'failed'): WorkflowRunResult;
145
166
  //#endregion
146
- export { type InMemoryAttemptRepository, type InMemoryAttemptRepositoryState, type ProvisioningClaimGrantor, TEST_OWNER_ID, TEST_PROVIDER_ID, TEST_PROVISIONER_INCARNATION_ID, beginTestProvisioning, createInMemoryAttemptRepository, leaseAt, makeBeginProvisioningInput, makeEvidence, makeProcessLossProof, makeTestAllocationRef, makeTestWorkflowResult };
167
+ export { type InMemoryAttemptRepository, type InMemoryAttemptRepositoryState, type ProvisioningClaimGrantor, TEST_OWNER_ID, TEST_PROVIDER_ID, TEST_PROVISIONER_INCARNATION_ID, beginTestProvisioning, createInMemoryAttemptRepository, leaseAt, makeBeginProvisioningInput, makeEvidence, makeProcessLossProof, makeTestAllocationRef, makeTestWorkflowResult, workflowRunResultOutcomeCodec };
@@ -1 +1 @@
1
- import{DuplicateExecutionAttemptError as e,sameAllocationRef as t,sameWorkflowResult as n}from"../execution-attempt-repository.mjs";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"../../attempt-record-codec-BYfYkj4M.mjs";import{BoundedRecoveryEvidenceSchema as f,PROVIDER_ALLOCATION_REF_VERSION as p}from"@makaio/framework/contracts";function m(p={}){let m=p.attempts??new Map,h=p.operations??new Map,g=p.committedOutcomes??new Map,_=p.activeAttempts??new Map,v=e=>{let t=m.get(e.executionAttemptId),n=h.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:t.settlementKind==null?n.token===null||n.token!==e.token||n.generation!==e.generation||n.ownerId!==e.ownerId?{kind:`stale`,attempt:t}:{kind:`authorized`,attempt:t,operation:n}:{kind:`resolved`,attempt:t}},y=(e,t)=>{h.set(e.executionAttemptId,{...e,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t})},b=(e,n)=>{let a=r(e.allocationRef),o=v(e.claim);if(o.kind!==`not-found`&&i(o.attempt,a),o.kind===`resolved`)return{kind:`resolved`,allocationRef:o.attempt.allocationRef};if(o.kind!==`authorized`)return{kind:o.kind};let{attempt:s,operation:c}=o;if(s.allocationRef!==null)return t(s.allocationRef,a)?{kind:`duplicate`,allocationRef:s.allocationRef}:{kind:`conflict`,allocationRef:s.allocationRef};let l=_.get(s.executionId)===s.executionAttemptId;return m.set(s.executionAttemptId,{...s,status:`allocated`,allocationRef:a,claimable:n&&l}),h.set(c.executionAttemptId,{...c,obligation:`allocation-control`}),{kind:`recorded`}};return{async createAttempt(t){if(m.has(t.executionAttemptId))throw new e(t.executionAttemptId);let n={executionAttemptId:t.executionAttemptId,executionId:t.executionId,status:`pending`,allocationRef:null,createdAt:new Date().toISOString(),providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null},r=_.get(t.executionId),i=r===void 0?void 0:m.get(r);return i?.status===`allocated`&&m.set(i.executionAttemptId,{...i,claimable:!1}),m.set(t.executionAttemptId,n),_.set(t.executionId,t.executionAttemptId),n},async beginProvisioning(e){let t=a(e.allocationLifetime),n=m.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(_.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};if(n.settlementKind!=null)return{kind:`resolved`,allocationRef:n.allocationRef};if(n.allocationRef!==null)return{kind:`allocated`,allocationRef:n.allocationRef};if(n.status!==`pending`)return{kind:`already-provisioning`};m.set(e.executionAttemptId,{...n,status:`provisioning`,providerId:e.providerId,allocationLifetime:t,provisionerIncarnationId:e.provisionerIncarnationId});let r={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:l(e.leaseExpiresAt)};return h.set(e.executionAttemptId,{executionAttemptId:e.executionAttemptId,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt,obligation:`provisioning-resolution`,failureCount:0,lastFailure:null}),{kind:`started`,claim:r}},async getProviderOperation(e){return h.get(e)??null},async renewProviderOperationClaim(e){let t=v(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=l(e.leaseExpiresAt);return h.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=m.get(e.executionAttemptId),n=h.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(t.settlementKind!=null)return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&s(n.leaseExpiresAt)>s(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:l(e.leaseExpiresAt)};return h.set(e.executionAttemptId,{...n,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt}),{kind:`claimed`,claim:r}},async handoffProviderOperation(e){let t=e.evidence===void 0?void 0:f.parse(e.evidence),n=v(e.claim);return n.kind===`authorized`?(h.set(e.claim.executionAttemptId,{...n.operation,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t??n.operation.lastFailure}),{kind:`recorded`}):{kind:n.kind}},async recordProviderOperationUncertainty(e){let t=f.parse(e.evidence),n=v(e.claim);return n.kind===`authorized`?(h.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async recordAllocation(e){return b(e,!0)},async recordProvisioningAbsent(e){let t=f.parse(e.evidence),n=v(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?(m.set(r.executionAttemptId,{...r,status:`settled`,settlementKind:`abandoned`,claimable:!1}),y(i,t),{kind:`recorded`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=f.parse(e.proof.evidence),n=v(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationLifetime===`provisioner-process-bound`?r.provisionerIncarnationId===null||r.provisionerIncarnationId!==e.proof.provisionerIncarnationId?{kind:`incarnation-mismatch`,provisionerIncarnationId:r.provisionerIncarnationId}:r.allocationRef===null?(m.set(r.executionAttemptId,{...r,status:`settled`,settlementKind:`abandoned`,claimable:!1}),y(i,t),{kind:`recorded`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-process-bound`,allocationLifetime:r.allocationLifetime}:{kind:`not-found`}},async recordAllocationTerminated(e){let t=f.parse(e.evidence),n=v(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(h.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=v(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(m.set(n.executionAttemptId,{...n,status:`settled`,settlementKind:`infrastructure-failure`,claimable:!1}),y(r,r.lastFailure),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`not-found`}},async getActiveAttempt(e,t){return _.get(e)===t?m.get(t)??null:null},async commitOutcome(e){let t=u(e.result);if(_.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let r=m.get(e.executionAttemptId);if(r===void 0)return{kind:`fenced`};let i=g.get(e.executionAttemptId);if(i)return n(i,t)?{kind:`duplicate`,outcome:i}:{kind:`conflict`};if(r.settlementKind!=null)return{kind:`conflict`};g.set(e.executionAttemptId,t),m.set(e.executionAttemptId,{...r,status:`settled`,settlementKind:`outcome`,claimable:!1});let a=h.get(e.executionAttemptId);return a&&y(a,a.lastFailure),{kind:`accepted`,outcome:t}},async abandonPendingAttempt(e,t){if(_.get(t)!==e)return{kind:`fenced`};let n=m.get(e);return n?n.status===`allocated`?{kind:`allocated`}:n.status===`provisioning`?{kind:`provisioning`}:n.status===`settled`?{kind:n.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:(m.set(e,{...n,status:`settled`,settlementKind:`abandoned`,claimable:!1}),{kind:`abandoned`}):{kind:`fenced`}},recovery:{async getAttemptWithAllocation(e){return m.get(e)??null},async recordDiscoveredAllocation(e){return b(e,!1)},async evolveAllocationRef(e){let{currentRef:n,nextRef:r}=c(e),i=v(e.claim);if(i.kind===`stale`)return{kind:`stale`,storedRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i;return a.executionId===e.executionId?a.allocationRef===null?{kind:`not-allocated`}:t(a.allocationRef,n)?(m.set(a.executionAttemptId,{...a,allocationRef:r}),{kind:`evolved`}):{kind:`stale`,storedRef:a.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=s(new Date().toISOString()),n=[];for(let r of m.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&s(r.claimExpiresAt)<t||n.push(o(r)));return n.sort(d)}},attempts:m,operations:h,committedOutcomes:g,activeAttempts:_}}const h=`controller-incarnation-1`,g=`provisioner-incarnation-1`,_=`test-provider`;function v(e){return new Date(Date.now()+e).toISOString()}function y(e,t,n={}){return{executionAttemptId:e,executionId:t,providerId:_,allocationLifetime:`provider-managed`,provisionerIncarnationId:g,ownerId:h,leaseExpiresAt:v(6e4),...n}}async function b(e,t,n,r={}){let i=await e.beginProvisioning(y(t,n,r));if(i.kind!==`started`)throw Error(`Expected provisioning to start, got '${i.kind}'`);return i.claim}function x(e={}){return{source:_,summary:`provider rejected the request before creating anything`,observedAt:new Date().toISOString(),...e}}function S(e=g,t=x({summary:`supervisor observed the provisioner process exit`})){return{kind:`provisioner-incarnation-lost`,provisionerIncarnationId:e,evidence:t}}function C(e=_,t={runId:1}){return{version:p,providerId:e,providerData:t}}function w(e,t=`completed`){let n={executionId:e,workflowId:`contract-workflow`};return t===`completed`?{...n,status:`completed`}:{...n,status:`failed`,error:`contract failure`}}export{h as TEST_OWNER_ID,_ as TEST_PROVIDER_ID,g as TEST_PROVISIONER_INCARNATION_ID,b as beginTestProvisioning,m as createInMemoryAttemptRepository,v as leaseAt,y as makeBeginProvisioningInput,x as makeEvidence,S as makeProcessLossProof,C as makeTestAllocationRef,w as makeTestWorkflowResult};
1
+ import{DuplicateExecutionAttemptError as e,decodeDurableOutcome as t,durableOutcome as n,sameAllocationRef as r,sameDurableOutcome as i}from"../execution-attempt-repository.mjs";import{a,c as o,i as s,n as c,o as l,r as u,s as d,t as f}from"../../attempt-record-codec-dC9LSFUE.mjs";import{BoundedRecoveryEvidenceSchema as p,PROVIDER_ALLOCATION_REF_VERSION as m,WorkflowRunResultSchema as h}from"@makaio/framework/contracts";function g(m,h={}){let g=h.attempts??new Map,_=h.operations??new Map,v=h.committedOutcomes??new Map,y=h.activeAttempts??new Map,b=e=>{let t=g.get(e.executionAttemptId),n=_.get(e.executionAttemptId);return!t||!n?{kind:`not-found`}:t.settlementKind==null?n.token===null||n.token!==e.token||n.generation!==e.generation||n.ownerId!==e.ownerId?{kind:`stale`,attempt:t}:{kind:`authorized`,attempt:t,operation:n}:{kind:`resolved`,attempt:t}},x=(e,t)=>{_.set(e.executionAttemptId,{...e,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t})},S=(e,t)=>{let n=a(e.allocationRef),i=b(e.claim);if(i.kind!==`not-found`&&d(i.attempt,n),i.kind===`resolved`)return{kind:`resolved`,allocationRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:o,operation:s}=i;if(o.allocationRef!==null)return r(o.allocationRef,n)?{kind:`duplicate`,allocationRef:o.allocationRef}:{kind:`conflict`,allocationRef:o.allocationRef};let c=y.get(o.executionId)===o.executionAttemptId;return g.set(o.executionAttemptId,{...o,status:`allocated`,allocationRef:n,claimable:t&&c}),_.set(s.executionAttemptId,{...s,obligation:`allocation-control`}),{kind:`recorded`}};return{async createAttempt(t){if(g.has(t.executionAttemptId))throw new e(t.executionAttemptId);let n={executionAttemptId:t.executionAttemptId,executionId:t.executionId,status:`pending`,allocationRef:null,createdAt:new Date().toISOString(),providerId:null,allocationLifetime:null,provisionerIncarnationId:null,settlementKind:null,claimable:!1,claimExpiresAt:null},r=y.get(t.executionId),i=r===void 0?void 0:g.get(r);return i?.status===`allocated`&&g.set(i.executionAttemptId,{...i,claimable:!1}),g.set(t.executionAttemptId,n),y.set(t.executionId,t.executionAttemptId),n},async beginProvisioning(e){let t=s(e.allocationLifetime),n=g.get(e.executionAttemptId);if(!n||n.executionId!==e.executionId)return{kind:`not-found`};if(y.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};if(n.settlementKind!=null)return{kind:`resolved`,allocationRef:n.allocationRef};if(n.allocationRef!==null)return{kind:`allocated`,allocationRef:n.allocationRef};if(n.status!==`pending`)return{kind:`already-provisioning`};g.set(e.executionAttemptId,{...n,status:`provisioning`,providerId:e.providerId,allocationLifetime:t,provisionerIncarnationId:e.provisionerIncarnationId});let r={executionAttemptId:e.executionAttemptId,generation:1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:u(e.leaseExpiresAt)};return _.set(e.executionAttemptId,{executionAttemptId:e.executionAttemptId,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt,obligation:`provisioning-resolution`,failureCount:0,lastFailure:null}),{kind:`started`,claim:r}},async getProviderOperation(e){return _.get(e)??null},async renewProviderOperationClaim(e){let t=b(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let n=u(e.leaseExpiresAt);return _.set(e.claim.executionAttemptId,{...t.operation,leaseExpiresAt:n}),{kind:`claimed`,claim:{...e.claim,leaseExpiresAt:n}}},async takeOverProviderOperation(e){let t=g.get(e.executionAttemptId),n=_.get(e.executionAttemptId);if(!t||!n)return{kind:`not-found`};if(t.settlementKind!=null)return{kind:`resolved`};if(n.ownerId!==null&&n.leaseExpiresAt!==null&&c(n.leaseExpiresAt)>c(e.observedAt))return{kind:`stale`};let r={executionAttemptId:e.executionAttemptId,generation:n.generation+1,ownerId:e.ownerId,token:crypto.randomUUID(),leaseExpiresAt:u(e.leaseExpiresAt)};return _.set(e.executionAttemptId,{...n,generation:r.generation,ownerId:r.ownerId,token:r.token,leaseExpiresAt:r.leaseExpiresAt}),{kind:`claimed`,claim:r}},async handoffProviderOperation(e){let t=e.evidence===void 0?void 0:p.parse(e.evidence),n=b(e.claim);return n.kind===`authorized`?(_.set(e.claim.executionAttemptId,{...n.operation,ownerId:null,token:null,leaseExpiresAt:null,lastFailure:t??n.operation.lastFailure}),{kind:`recorded`}):{kind:n.kind}},async recordProviderOperationUncertainty(e){let t=p.parse(e.evidence),n=b(e.claim);return n.kind===`authorized`?(_.set(e.claim.executionAttemptId,{...n.operation,failureCount:n.operation.failureCount+1,lastFailure:t}),{kind:`recorded`}):{kind:n.kind}},async recordAllocation(e){return S(e,!0)},async recordProvisioningAbsent(e){let t=p.parse(e.evidence),n=b(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationRef===null?(g.set(r.executionAttemptId,{...r,status:`settled`,settlementKind:`abandoned`,claimable:!1}),x(i,t),{kind:`recorded`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-found`}},async recordProvisionerIncarnationLost(e){let t=p.parse(e.proof.evidence),n=b(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.executionId===e.executionId?r.allocationLifetime===`provisioner-process-bound`?r.provisionerIncarnationId===null||r.provisionerIncarnationId!==e.proof.provisionerIncarnationId?{kind:`incarnation-mismatch`,provisionerIncarnationId:r.provisionerIncarnationId}:r.allocationRef===null?(g.set(r.executionAttemptId,{...r,status:`settled`,settlementKind:`abandoned`,claimable:!1}),x(i,t),{kind:`recorded`}):{kind:`allocated`,allocationRef:r.allocationRef}:{kind:`not-process-bound`,allocationLifetime:r.allocationLifetime}:{kind:`not-found`}},async recordAllocationTerminated(e){let t=p.parse(e.evidence),n=b(e.claim);if(n.kind!==`authorized`)return{kind:n.kind};let{attempt:r,operation:i}=n;return r.allocationRef===null?{kind:`not-allocated`}:(_.set(i.executionAttemptId,{...i,obligation:`terminal-convergence`,lastFailure:t}),{kind:`recorded`})},async recordInfrastructureFailure(e){let t=b(e.claim);if(t.kind!==`authorized`)return{kind:t.kind};let{attempt:n,operation:r}=t;return n.executionId===e.executionId?n.allocationRef===null?{kind:`not-allocated`}:r.obligation===`terminal-convergence`?(g.set(n.executionAttemptId,{...n,status:`settled`,settlementKind:`infrastructure-failure`,claimable:!1}),x(r,r.lastFailure),{kind:`recorded`}):{kind:`not-terminated`}:{kind:`not-found`}},async getActiveAttempt(e,t){return y.get(e)===t?g.get(t)??null:null},canonicalizeOutcome(e){return n(m,e)},decodeOutcome(e){return t(m,e)},async commitOutcome(e){let n=e.result;if(y.get(e.executionId)!==e.executionAttemptId)return{kind:`fenced`};let r=g.get(e.executionAttemptId);if(r===void 0)return{kind:`fenced`};let a=v.get(e.executionAttemptId);if(a!==void 0){let e=t(m,a);return i(a,n.text)?{kind:`duplicate`,outcome:e,text:a}:{kind:`conflict`}}if(r.settlementKind!=null)return{kind:`conflict`};v.set(e.executionAttemptId,n.text),g.set(e.executionAttemptId,{...r,status:`settled`,settlementKind:`outcome`,claimable:!1});let o=_.get(e.executionAttemptId);return o&&x(o,o.lastFailure),{kind:`accepted`,outcome:t(m,n.text),text:n.text}},async abandonPendingAttempt(e,t){if(y.get(t)!==e)return{kind:`fenced`};let n=g.get(e);return n?n.status===`allocated`?{kind:`allocated`}:n.status===`provisioning`?{kind:`provisioning`}:n.status===`settled`?{kind:n.settlementKind===`abandoned`?`already-abandoned`:`already-settled`}:(g.set(e,{...n,status:`settled`,settlementKind:`abandoned`,claimable:!1}),{kind:`abandoned`}):{kind:`fenced`}},recovery:{async getAttemptWithAllocation(e){return g.get(e)??null},async recordDiscoveredAllocation(e){return S(e,!1)},async evolveAllocationRef(e){let{currentRef:t,nextRef:n}=l(e),i=b(e.claim);if(i.kind===`stale`)return{kind:`stale`,storedRef:i.attempt.allocationRef};if(i.kind!==`authorized`)return{kind:i.kind};let{attempt:a}=i;return a.executionId===e.executionId?a.allocationRef===null?{kind:`not-allocated`}:r(a.allocationRef,t)?(g.set(a.executionAttemptId,{...a,allocationRef:n}),{kind:`evolved`}):{kind:`stale`,storedRef:a.allocationRef}:{kind:`not-found`}},async getRecoverableAttempts(e){let t=c(new Date().toISOString()),n=[];for(let r of g.values())r.executionId===e&&r.status===`allocated`&&r.allocationRef!==null&&r.claimable===!0&&r.settlementKind==null&&(r.claimExpiresAt!=null&&c(r.claimExpiresAt)<t||n.push(o(r)));return n.sort(f)}},attempts:g,operations:_,committedOutcomes:v,activeAttempts:y}}const _=`controller-incarnation-1`,v=`provisioner-incarnation-1`,y=`test-provider`;function b(e){return new Date(Date.now()+e).toISOString()}function x(e,t,n={}){return{executionAttemptId:e,executionId:t,providerId:y,allocationLifetime:`provider-managed`,provisionerIncarnationId:v,ownerId:_,leaseExpiresAt:b(6e4),...n}}async function S(e,t,n,r={}){let i=await e.beginProvisioning(x(t,n,r));if(i.kind!==`started`)throw Error(`Expected provisioning to start, got '${i.kind}'`);return i.claim}function C(e={}){return{source:y,summary:`provider rejected the request before creating anything`,observedAt:new Date().toISOString(),...e}}function w(e=v,t=C({summary:`supervisor observed the provisioner process exit`})){return{kind:`provisioner-incarnation-lost`,provisionerIncarnationId:e,evidence:t}}function T(e=y,t={runId:1}){return{version:m,providerId:e,providerData:t}}const E={parse:e=>h.parse(e),serialize:e=>JSON.stringify(e)};function D(e,t=`completed`){let n={executionId:e,workflowId:`contract-workflow`};return t===`completed`?{...n,status:`completed`}:{...n,status:`failed`,error:`contract failure`}}export{_ as TEST_OWNER_ID,y as TEST_PROVIDER_ID,v as TEST_PROVISIONER_INCARNATION_ID,S as beginTestProvisioning,g as createInMemoryAttemptRepository,b as leaseAt,x as makeBeginProvisioningInput,C as makeEvidence,w as makeProcessLossProof,T as makeTestAllocationRef,D as makeTestWorkflowResult,E as workflowRunResultOutcomeCodec};