@lostgradient/weft 0.20.0 → 0.22.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.
- package/README.md +2 -2
- package/dist/cli/generated/operation-catalog.snapshot.json +207 -80
- package/dist/cli/generated/operation-client.generated.d.ts +120 -43
- package/dist/client/http-client-storage.js +1 -1
- package/dist/core/engine/activity-reconciliation.d.ts +2 -2
- package/dist/core/engine/activity-reconciliation.js +12 -8
- package/dist/core/engine/async-activity-completion.js +12 -4
- package/dist/core/engine/async-activity-records.d.ts +11 -1
- package/dist/core/engine/async-activity-records.js +4 -3
- package/dist/core/engine/attributes-tags.d.ts +11 -1
- package/dist/core/engine/attributes-tags.js +4 -3
- package/dist/core/engine/bulk-operations-purge.js +5 -2
- package/dist/core/engine/bulk-operations.js +17 -5
- package/dist/core/engine/callback-creators-bundles.js +1 -1
- package/dist/core/engine/callback-creators-core.js +4 -2
- package/dist/core/engine/checkpoint-io.js +1 -1
- package/dist/core/engine/child-workflow.js +2 -1
- package/dist/core/engine/completed-review-storage.js +1 -1
- package/dist/core/engine/condition-waiters.d.ts +45 -3
- package/dist/core/engine/condition-waiters.js +12 -3
- package/dist/core/engine/disposal.js +6 -0
- package/dist/core/engine/engine-internal-types.d.ts +12 -4
- package/dist/core/engine/fenced-write.d.ts +46 -15
- package/dist/core/engine/fenced-write.js +39 -6
- package/dist/core/engine/finalizer-state.d.ts +3 -1
- package/dist/core/engine/handle-result.d.ts +49 -1
- package/dist/core/engine/handle-result.js +95 -20
- package/dist/core/engine/index.d.ts +13 -5
- package/dist/core/engine/index.js +155 -5
- package/dist/core/engine/inline-launch-queue.js +9 -0
- package/dist/core/engine/internals.d.ts +73 -0
- package/dist/core/engine/invoke-update-handler.d.ts +19 -0
- package/dist/core/engine/invoke-update-handler.js +7 -0
- package/dist/core/engine/lease-deposition.d.ts +132 -0
- package/dist/core/engine/lease-deposition.js +31 -0
- package/dist/core/engine/lease-errors.d.ts +80 -9
- package/dist/core/engine/lease-errors.js +28 -2
- package/dist/core/engine/lifecycle/resume.js +3 -1
- package/dist/core/engine/lifecycle/standalone-claim-acquire.d.ts +33 -0
- package/dist/core/engine/lifecycle/standalone-claim-acquire.js +25 -0
- package/dist/core/engine/lifecycle/start-commit.js +20 -6
- package/dist/core/engine/lifecycle/transition.d.ts +15 -1
- package/dist/core/engine/lifecycle/transition.js +6 -3
- package/dist/core/engine/operations-activity.js +1 -1
- package/dist/core/engine/operations-time.js +21 -7
- package/dist/core/engine/owner-side-signal-poll.d.ts +132 -0
- package/dist/core/engine/owner-side-signal-poll.js +22 -0
- package/dist/core/engine/owner-side-update-poll.d.ts +116 -0
- package/dist/core/engine/owner-side-update-poll.js +22 -0
- package/dist/core/engine/ownership-bootstrap.d.ts +280 -0
- package/dist/core/engine/ownership-bootstrap.js +89 -0
- package/dist/core/engine/ownership-mode-marker.d.ts +82 -0
- package/dist/core/engine/ownership-mode-marker.js +52 -0
- package/dist/core/engine/ownership-options.d.ts +22 -6
- package/dist/core/engine/ownership-options.js +42 -12
- package/dist/core/engine/pending-updates.js +35 -24
- package/dist/core/engine/queries.d.ts +70 -0
- package/dist/core/engine/queries.js +58 -4
- package/dist/core/engine/schedules.js +1 -1
- package/dist/core/engine/signals.d.ts +11 -1
- package/dist/core/engine/signals.js +11 -7
- package/dist/core/engine/sleep-timer-acknowledgements.d.ts +68 -0
- package/dist/core/engine/sleep-timer-acknowledgements.js +19 -0
- package/dist/core/engine/storage-io.d.ts +58 -10
- package/dist/core/engine/storage-io.js +27 -9
- package/dist/core/engine/termination/cleanup.d.ts +5 -4
- package/dist/core/engine/termination/complete.js +23 -4
- package/dist/core/engine/termination/finalizer-claim.js +4 -4
- package/dist/core/engine/termination/state-commit-callbacks.d.ts +15 -0
- package/dist/core/engine/termination/state-commit-callbacks.js +0 -0
- package/dist/core/engine/termination/suspend.js +1 -1
- package/dist/core/engine/update-validation.d.ts +28 -0
- package/dist/core/engine/update-validation.js +37 -0
- package/dist/core/engine/updates.d.ts +17 -16
- package/dist/core/engine/updates.js +24 -47
- package/dist/core/engine/wake-ownership-check.d.ts +86 -0
- package/dist/core/engine/wake-ownership-check.js +19 -0
- package/dist/core/engine/wake-ownership-guard.d.ts +46 -0
- package/dist/core/engine/wake-ownership-guard.js +23 -0
- package/dist/core/engine/workflow-claim-codec.d.ts +64 -0
- package/dist/core/engine/workflow-claim-codec.js +44 -0
- package/dist/core/engine/workflow-claim-cooldown.d.ts +60 -0
- package/dist/core/engine/workflow-claim-cooldown.js +17 -0
- package/dist/core/engine/workflow-claim-fold.d.ts +82 -0
- package/dist/core/engine/workflow-claim-fold.js +53 -0
- package/dist/core/engine/workflow-claim-metrics.d.ts +131 -0
- package/dist/core/engine/workflow-claim-metrics.js +62 -0
- package/dist/core/engine/workflow-claim-reclaim-scan.d.ts +96 -0
- package/dist/core/engine/workflow-claim-reclaim-scan.js +66 -0
- package/dist/core/engine/workflow-claim-reclaim-target.d.ts +107 -0
- package/dist/core/engine/workflow-claim-reclaim-target.js +155 -0
- package/dist/core/engine/workflow-claim-registry.d.ts +227 -0
- package/dist/core/engine/workflow-claim-registry.js +198 -0
- package/dist/core/engine/workflow-claim-renewal-interval.d.ts +50 -0
- package/dist/core/engine/workflow-claim-renewal-interval.js +132 -0
- package/dist/core/engine/workflow-claim-renewal-subpasses.d.ts +265 -0
- package/dist/core/engine/workflow-claim-renewal-subpasses.js +104 -0
- package/dist/core/engine/workflow-claim-renewal-task.d.ts +159 -0
- package/dist/core/engine/workflow-claim-renewal-task.js +65 -0
- package/dist/core/engine/workflow-claim-transitions.d.ts +186 -0
- package/dist/core/engine/workflow-claim-transitions.js +120 -0
- package/dist/core/inline-execution-strategy.d.ts +20 -0
- package/dist/core/inline-execution-strategy.js +15 -4
- package/dist/core/scheduler/scheduler-class.js +3 -3
- package/dist/core/scheduler/timer-sources.d.ts +13 -0
- package/dist/core/scheduler/timer-sources.js +1 -1
- package/dist/core/types/options.d.ts +17 -1
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +2 -1
- package/dist/http.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -0
- package/dist/indexeddb.js +1 -1
- package/dist/json-schema.js +3 -3
- package/dist/observability/index.js +2 -2
- package/dist/server/operations/get-task-diagnostics.d.ts +115 -25
- package/dist/server/operations/get-task-diagnostics.js +93 -7
- package/dist/storage/auto.js +1 -1
- package/dist/storage/bun-sql.js +115 -2
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/http.js +1 -1
- package/dist/storage/index.d.ts +38 -35
- package/dist/storage/interface.d.ts +87 -125
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-encoding.d.ts +51 -0
- package/dist/storage/key-encoding.js +13 -0
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +3 -0
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +4 -4
- package/dist/storage/node-sqlite.js +115 -2
- package/dist/storage/ownership-keys.d.ts +55 -0
- package/dist/storage/ownership-keys.js +6 -0
- package/dist/storage/postgres.js +4 -4
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/dist/worker/protocol.js +1 -1
- package/package.json +3 -2
|
@@ -19,14 +19,14 @@ export declare const CLIENT_REST_OPERATION_BINDINGS: {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
type
|
|
22
|
+
type SharedAttributesBulkConcurrenc_0f0d07d6 = {
|
|
23
23
|
readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
|
|
24
24
|
readonly bulkConcurrency?: number;
|
|
25
25
|
readonly confirmationToken?: string;
|
|
26
26
|
readonly createdAt?: SharedGtGteLt_d9a61361;
|
|
27
27
|
readonly dryRun?: boolean;
|
|
28
28
|
readonly executionDeadline?: SharedGtGteLt_d9a61361;
|
|
29
|
-
readonly failureCategory?:
|
|
29
|
+
readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
|
|
30
30
|
readonly idPrefix?: string;
|
|
31
31
|
readonly limit?: number;
|
|
32
32
|
readonly offset?: number;
|
|
@@ -34,23 +34,23 @@ type SharedAttributesBulkConcurrenc_ff397168 = {
|
|
|
34
34
|
readonly parentWorkflowId?: string;
|
|
35
35
|
readonly requestId?: string;
|
|
36
36
|
readonly scheduleId?: string;
|
|
37
|
-
readonly status?:
|
|
37
|
+
readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
|
|
38
38
|
readonly tags?: ReadonlyArray<string>;
|
|
39
39
|
readonly type?: string;
|
|
40
40
|
readonly updatedAt?: SharedGtGteLt_d9a61361;
|
|
41
41
|
};
|
|
42
|
-
type
|
|
42
|
+
type SharedAttributesCreatedAtExecu_47f8e20e = {
|
|
43
43
|
readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
|
|
44
44
|
readonly createdAt?: SharedGtGteLt_d9a61361;
|
|
45
45
|
readonly executionDeadline?: SharedGtGteLt_d9a61361;
|
|
46
|
-
readonly failureCategory?:
|
|
46
|
+
readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
|
|
47
47
|
readonly idPrefix?: string;
|
|
48
48
|
readonly limit?: number;
|
|
49
49
|
readonly offset?: number;
|
|
50
50
|
readonly parentWorkflowExecutionToken?: string;
|
|
51
51
|
readonly parentWorkflowId?: string;
|
|
52
52
|
readonly scheduleId?: string;
|
|
53
|
-
readonly status?:
|
|
53
|
+
readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
|
|
54
54
|
readonly tags?: ReadonlyArray<string>;
|
|
55
55
|
readonly type?: string;
|
|
56
56
|
readonly updatedAt?: SharedGtGteLt_d9a61361;
|
|
@@ -76,7 +76,7 @@ export type ClientOperationTypes = {
|
|
|
76
76
|
readonly token: string;
|
|
77
77
|
};
|
|
78
78
|
readonly output: {
|
|
79
|
-
readonly ok:
|
|
79
|
+
readonly ok: true;
|
|
80
80
|
};
|
|
81
81
|
readonly faults: 'InvalidParams' | 'NotFound';
|
|
82
82
|
};
|
|
@@ -89,7 +89,7 @@ export type ClientOperationTypes = {
|
|
|
89
89
|
readonly token: string;
|
|
90
90
|
};
|
|
91
91
|
readonly output: {
|
|
92
|
-
readonly ok:
|
|
92
|
+
readonly ok: true;
|
|
93
93
|
};
|
|
94
94
|
readonly faults: 'InvalidParams' | 'NotFound';
|
|
95
95
|
};
|
|
@@ -98,10 +98,10 @@ export type ClientOperationTypes = {
|
|
|
98
98
|
readonly output: {
|
|
99
99
|
readonly items: ReadonlyArray<{
|
|
100
100
|
readonly currentValue: number;
|
|
101
|
-
readonly firedAt:
|
|
101
|
+
readonly firedAt: number | null;
|
|
102
102
|
readonly metric: 'workflow.failure_rate' | 'activity.p99_duration' | 'storage.size';
|
|
103
103
|
readonly threshold: number;
|
|
104
|
-
readonly window:
|
|
104
|
+
readonly window: string | null;
|
|
105
105
|
}>;
|
|
106
106
|
};
|
|
107
107
|
readonly faults: never;
|
|
@@ -128,7 +128,7 @@ export type ClientOperationTypes = {
|
|
|
128
128
|
readonly workflowId?: unknown;
|
|
129
129
|
};
|
|
130
130
|
readonly output: {
|
|
131
|
-
readonly ok:
|
|
131
|
+
readonly ok: true;
|
|
132
132
|
};
|
|
133
133
|
readonly faults: 'NotFound';
|
|
134
134
|
};
|
|
@@ -147,7 +147,34 @@ export type ClientOperationTypes = {
|
|
|
147
147
|
readonly workflowId?: string;
|
|
148
148
|
};
|
|
149
149
|
readonly output: {
|
|
150
|
-
readonly items: ReadonlyArray<
|
|
150
|
+
readonly items: ReadonlyArray<{
|
|
151
|
+
readonly allowPartial: boolean;
|
|
152
|
+
readonly artifact: unknown;
|
|
153
|
+
readonly createdAt: number;
|
|
154
|
+
readonly reviewId: string;
|
|
155
|
+
readonly reviewType: string;
|
|
156
|
+
readonly reviewers: ReadonlyArray<string>;
|
|
157
|
+
readonly status: 'pending';
|
|
158
|
+
readonly timeout?: number;
|
|
159
|
+
readonly webhookUrl?: string;
|
|
160
|
+
readonly workflowId: string;
|
|
161
|
+
} | {
|
|
162
|
+
readonly allowPartial: boolean;
|
|
163
|
+
readonly artifact: unknown;
|
|
164
|
+
readonly createdAt: number;
|
|
165
|
+
readonly decision: 'approved' | 'rejected' | 'needs-changes';
|
|
166
|
+
readonly feedback?: string;
|
|
167
|
+
readonly reviewId: string;
|
|
168
|
+
readonly reviewType: string;
|
|
169
|
+
readonly reviewer: string;
|
|
170
|
+
readonly reviewers: ReadonlyArray<string>;
|
|
171
|
+
readonly sectionDecisions?: Record<string, unknown>;
|
|
172
|
+
readonly status: 'completed';
|
|
173
|
+
readonly timeout?: number;
|
|
174
|
+
readonly timestamp: number;
|
|
175
|
+
readonly webhookUrl?: string;
|
|
176
|
+
readonly workflowId: string;
|
|
177
|
+
}>;
|
|
151
178
|
};
|
|
152
179
|
readonly faults: never;
|
|
153
180
|
};
|
|
@@ -256,7 +283,7 @@ export type ClientOperationTypes = {
|
|
|
256
283
|
readonly output: {
|
|
257
284
|
readonly method: 'jwt' | 'api-key' | 'mtls' | 'stdio-local' | 'unauthenticated';
|
|
258
285
|
readonly scopes: ReadonlyArray<'workflows:read' | 'workflows:write' | 'workflows:admin' | 'schedules:read' | 'schedules:write' | 'signals:write' | 'updates:write' | 'queries:read' | 'reviews:read' | 'reviews:write' | 'attributes:read' | 'attributes:write' | 'tags:write' | 'streams:read' | 'events:read' | 'storage:read' | 'storage:write' | 'storage:admin' | 'workers:write' | 'system:read' | 'system:admin'>;
|
|
259
|
-
readonly subject:
|
|
286
|
+
readonly subject: string | null;
|
|
260
287
|
};
|
|
261
288
|
readonly faults: never;
|
|
262
289
|
};
|
|
@@ -264,7 +291,7 @@ export type ClientOperationTypes = {
|
|
|
264
291
|
readonly input: {};
|
|
265
292
|
readonly output: {
|
|
266
293
|
readonly activities: unknown;
|
|
267
|
-
readonly registryVersion:
|
|
294
|
+
readonly registryVersion: 1;
|
|
268
295
|
readonly workflows: unknown;
|
|
269
296
|
};
|
|
270
297
|
readonly faults: never;
|
|
@@ -276,8 +303,8 @@ export type ClientOperationTypes = {
|
|
|
276
303
|
readonly backlog: number;
|
|
277
304
|
readonly connectedWorkers: number;
|
|
278
305
|
readonly inFlight: number;
|
|
279
|
-
readonly oldestEnqueuedAt:
|
|
280
|
-
readonly oldestQueuedAgeMs:
|
|
306
|
+
readonly oldestEnqueuedAt: number | null;
|
|
307
|
+
readonly oldestQueuedAgeMs: number | null;
|
|
281
308
|
readonly queue: string;
|
|
282
309
|
readonly schedulingPolicy: 'priority' | 'fifo' | 'lifo';
|
|
283
310
|
readonly waitingPollers: number;
|
|
@@ -287,18 +314,20 @@ export type ClientOperationTypes = {
|
|
|
287
314
|
};
|
|
288
315
|
'weft.tasks.diagnostics': {
|
|
289
316
|
readonly input: {
|
|
317
|
+
readonly includeExpectedDelayed: boolean;
|
|
290
318
|
readonly limit: number;
|
|
291
319
|
readonly operationId?: string;
|
|
292
320
|
readonly queue?: string;
|
|
293
321
|
readonly retryStormMinimumAttempts: number;
|
|
294
322
|
readonly staleHeartbeatAfterMs: number;
|
|
295
323
|
readonly staleQueuedAfterMs: number;
|
|
324
|
+
readonly unadoptedAfterMs: number;
|
|
296
325
|
readonly workflowId?: string;
|
|
297
326
|
};
|
|
298
327
|
readonly output: {
|
|
299
328
|
readonly items: ReadonlyArray<{
|
|
300
329
|
readonly activityName?: string;
|
|
301
|
-
readonly deadLetterReason?:
|
|
330
|
+
readonly deadLetterReason?: 'result-resolution-storage-exhausted';
|
|
302
331
|
readonly deadLetteredAt?: number;
|
|
303
332
|
readonly evidence: ReadonlyArray<string>;
|
|
304
333
|
readonly executionLatencyMs?: number;
|
|
@@ -316,14 +345,35 @@ export type ClientOperationTypes = {
|
|
|
316
345
|
readonly storageError?: string;
|
|
317
346
|
readonly workerId?: string;
|
|
318
347
|
readonly workflowId?: string;
|
|
348
|
+
} | {
|
|
349
|
+
readonly availableAt: number;
|
|
350
|
+
readonly evidence: ReadonlyArray<string>;
|
|
351
|
+
readonly kind: 'delayed';
|
|
352
|
+
readonly operationId: string;
|
|
353
|
+
readonly queue: string;
|
|
354
|
+
readonly requeueCount: number;
|
|
355
|
+
readonly retryCount: number;
|
|
356
|
+
readonly state: 'queued';
|
|
357
|
+
readonly workflowId?: string;
|
|
358
|
+
} | {
|
|
359
|
+
readonly adopted: false;
|
|
360
|
+
readonly evidence: ReadonlyArray<string>;
|
|
361
|
+
readonly kind: 'unadopted-terminal';
|
|
362
|
+
readonly operationId: string;
|
|
363
|
+
readonly queue: string;
|
|
364
|
+
readonly state: 'resolved';
|
|
365
|
+
readonly terminalAt: number;
|
|
366
|
+
readonly workflowId?: string;
|
|
319
367
|
}>;
|
|
320
368
|
readonly limit: number;
|
|
321
369
|
readonly summary: {
|
|
322
370
|
readonly allWorkersAtCapacity: number;
|
|
323
371
|
readonly deadLettered: number;
|
|
372
|
+
readonly delayed: number;
|
|
324
373
|
readonly retryStorms: number;
|
|
325
374
|
readonly staleInflight: number;
|
|
326
375
|
readonly stuckQueued: number;
|
|
376
|
+
readonly unadoptedTerminal: number;
|
|
327
377
|
};
|
|
328
378
|
};
|
|
329
379
|
readonly faults: never;
|
|
@@ -333,7 +383,7 @@ export type ClientOperationTypes = {
|
|
|
333
383
|
readonly operationId: string;
|
|
334
384
|
};
|
|
335
385
|
readonly output: {
|
|
336
|
-
readonly ok:
|
|
386
|
+
readonly ok: true;
|
|
337
387
|
};
|
|
338
388
|
readonly faults: 'NotFound';
|
|
339
389
|
};
|
|
@@ -371,7 +421,29 @@ export type ClientOperationTypes = {
|
|
|
371
421
|
readonly workerId: string;
|
|
372
422
|
};
|
|
373
423
|
readonly output: {
|
|
374
|
-
readonly worker:
|
|
424
|
+
readonly worker: {
|
|
425
|
+
readonly deploymentVersion: {
|
|
426
|
+
readonly artifactDigest: string;
|
|
427
|
+
readonly buildId: string;
|
|
428
|
+
readonly deploymentName: string;
|
|
429
|
+
readonly manifestDigest: string;
|
|
430
|
+
readonly manifestVersion: number;
|
|
431
|
+
readonly protocolVersion: number;
|
|
432
|
+
readonly runtimeName: string;
|
|
433
|
+
readonly runtimeVersion: string;
|
|
434
|
+
readonly sdkVersion: string;
|
|
435
|
+
readonly workflows: Record<string, unknown>;
|
|
436
|
+
};
|
|
437
|
+
readonly instance: {
|
|
438
|
+
readonly connectedAt: number;
|
|
439
|
+
readonly health: 'active' | 'draining' | 'drained';
|
|
440
|
+
readonly heartbeatAgeMs: number;
|
|
441
|
+
readonly lastHeartbeatAt: number;
|
|
442
|
+
readonly queue: string;
|
|
443
|
+
readonly startedAt: number;
|
|
444
|
+
readonly workerId: string;
|
|
445
|
+
};
|
|
446
|
+
} | null;
|
|
375
447
|
};
|
|
376
448
|
readonly faults: never;
|
|
377
449
|
};
|
|
@@ -388,14 +460,14 @@ export type ClientOperationTypes = {
|
|
|
388
460
|
readonly output: {
|
|
389
461
|
readonly deployments: ReadonlyArray<{
|
|
390
462
|
readonly activeWorkers: number;
|
|
391
|
-
readonly buildId:
|
|
392
|
-
readonly deploymentName:
|
|
463
|
+
readonly buildId: string | null;
|
|
464
|
+
readonly deploymentName: string | null;
|
|
393
465
|
readonly drainedWorkers: number;
|
|
394
466
|
readonly drainingWorkers: number;
|
|
395
467
|
readonly health: 'active' | 'draining' | 'drained';
|
|
396
468
|
readonly inFlight: number;
|
|
397
|
-
readonly oldestStartedAt:
|
|
398
|
-
readonly runtimeVersion:
|
|
469
|
+
readonly oldestStartedAt: number | null;
|
|
470
|
+
readonly runtimeVersion: string | null;
|
|
399
471
|
readonly workers: number;
|
|
400
472
|
}>;
|
|
401
473
|
readonly items: ReadonlyArray<{
|
|
@@ -467,14 +539,16 @@ export type ClientOperationTypes = {
|
|
|
467
539
|
readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
|
|
468
540
|
readonly createdAt?: SharedGtGteLt_d9a61361;
|
|
469
541
|
readonly executionDeadline?: SharedGtGteLt_d9a61361;
|
|
470
|
-
readonly failureCategory?:
|
|
471
|
-
readonly groupBy:
|
|
542
|
+
readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
|
|
543
|
+
readonly groupBy: 'status' | 'type' | 'failureCategory' | {
|
|
544
|
+
readonly attribute: string;
|
|
545
|
+
};
|
|
472
546
|
readonly idPrefix?: string;
|
|
473
547
|
readonly limit?: number;
|
|
474
548
|
readonly parentWorkflowExecutionToken?: string;
|
|
475
549
|
readonly parentWorkflowId?: string;
|
|
476
550
|
readonly scheduleId?: string;
|
|
477
|
-
readonly status?:
|
|
551
|
+
readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
|
|
478
552
|
readonly tags?: ReadonlyArray<string>;
|
|
479
553
|
readonly type?: string;
|
|
480
554
|
readonly updatedAt?: SharedGtGteLt_d9a61361;
|
|
@@ -482,7 +556,7 @@ export type ClientOperationTypes = {
|
|
|
482
556
|
readonly output: {
|
|
483
557
|
readonly groups: ReadonlyArray<{
|
|
484
558
|
readonly count: number;
|
|
485
|
-
readonly key:
|
|
559
|
+
readonly key: string | null;
|
|
486
560
|
}>;
|
|
487
561
|
readonly total: number;
|
|
488
562
|
readonly truncated: boolean;
|
|
@@ -502,22 +576,22 @@ export type ClientOperationTypes = {
|
|
|
502
576
|
readonly workflowId: string;
|
|
503
577
|
};
|
|
504
578
|
readonly output: {
|
|
505
|
-
readonly ok:
|
|
579
|
+
readonly ok: true;
|
|
506
580
|
};
|
|
507
581
|
readonly faults: never;
|
|
508
582
|
};
|
|
509
583
|
'weft.workflows.bulk.cancel': {
|
|
510
|
-
readonly input:
|
|
584
|
+
readonly input: SharedAttributesBulkConcurrenc_0f0d07d6;
|
|
511
585
|
readonly output: unknown;
|
|
512
586
|
readonly faults: never;
|
|
513
587
|
};
|
|
514
588
|
'weft.workflows.bulk.delete': {
|
|
515
|
-
readonly input:
|
|
589
|
+
readonly input: SharedAttributesBulkConcurrenc_0f0d07d6;
|
|
516
590
|
readonly output: unknown;
|
|
517
591
|
readonly faults: 'Unprocessable';
|
|
518
592
|
};
|
|
519
593
|
'weft.workflows.bulk.retryfailed': {
|
|
520
|
-
readonly input:
|
|
594
|
+
readonly input: SharedAttributesBulkConcurrenc_0f0d07d6;
|
|
521
595
|
readonly output: unknown;
|
|
522
596
|
readonly faults: never;
|
|
523
597
|
};
|
|
@@ -529,7 +603,7 @@ export type ClientOperationTypes = {
|
|
|
529
603
|
readonly createdAt?: SharedGtGteLt_d9a61361;
|
|
530
604
|
readonly dryRun?: boolean;
|
|
531
605
|
readonly executionDeadline?: SharedGtGteLt_d9a61361;
|
|
532
|
-
readonly failureCategory?:
|
|
606
|
+
readonly failureCategory?: 'application' | 'timeout' | 'cancellation' | 'resource' | 'system' | ReadonlyArray<'application' | 'timeout' | 'cancellation' | 'resource' | 'system'>;
|
|
533
607
|
readonly idPrefix?: string;
|
|
534
608
|
readonly limit?: number;
|
|
535
609
|
readonly name: string;
|
|
@@ -539,7 +613,7 @@ export type ClientOperationTypes = {
|
|
|
539
613
|
readonly payload?: unknown;
|
|
540
614
|
readonly requestId?: string;
|
|
541
615
|
readonly scheduleId?: string;
|
|
542
|
-
readonly status?:
|
|
616
|
+
readonly status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended' | ReadonlyArray<'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended'>;
|
|
543
617
|
readonly tags?: ReadonlyArray<string>;
|
|
544
618
|
readonly type?: string;
|
|
545
619
|
readonly updatedAt?: SharedGtGteLt_d9a61361;
|
|
@@ -552,7 +626,7 @@ export type ClientOperationTypes = {
|
|
|
552
626
|
readonly bulkConcurrency?: number;
|
|
553
627
|
readonly confirmationToken?: string;
|
|
554
628
|
readonly dryRun?: boolean;
|
|
555
|
-
readonly filter?:
|
|
629
|
+
readonly filter?: SharedAttributesCreatedAtExecu_47f8e20e;
|
|
556
630
|
readonly operation: 'add' | 'remove';
|
|
557
631
|
readonly requestId?: string;
|
|
558
632
|
readonly tags: ReadonlyArray<string>;
|
|
@@ -618,15 +692,15 @@ export type ClientOperationTypes = {
|
|
|
618
692
|
readonly attributes?: ReadonlyArray<SharedGtGteKey_e658e64c>;
|
|
619
693
|
readonly createdAt?: SharedGtGteLt_d9a61361;
|
|
620
694
|
readonly executionDeadline?: SharedGtGteLt_d9a61361;
|
|
621
|
-
readonly failureCategory?:
|
|
695
|
+
readonly failureCategory?: string | ReadonlyArray<string>;
|
|
622
696
|
readonly idPrefix?: string;
|
|
623
|
-
readonly include?:
|
|
697
|
+
readonly include?: string | ReadonlyArray<string>;
|
|
624
698
|
readonly limit?: number;
|
|
625
699
|
readonly offset?: number;
|
|
626
700
|
readonly parentWorkflowExecutionToken?: string;
|
|
627
701
|
readonly parentWorkflowId?: string;
|
|
628
702
|
readonly scheduleId?: string;
|
|
629
|
-
readonly status?:
|
|
703
|
+
readonly status?: string | ReadonlyArray<string>;
|
|
630
704
|
readonly tags?: ReadonlyArray<string>;
|
|
631
705
|
readonly type?: string;
|
|
632
706
|
readonly updatedAt?: SharedGtGteLt_d9a61361;
|
|
@@ -635,7 +709,7 @@ export type ClientOperationTypes = {
|
|
|
635
709
|
readonly faults: 'Unprocessable';
|
|
636
710
|
};
|
|
637
711
|
'weft.workflows.purge': {
|
|
638
|
-
readonly input:
|
|
712
|
+
readonly input: SharedAttributesCreatedAtExecu_47f8e20e;
|
|
639
713
|
readonly output: unknown;
|
|
640
714
|
readonly faults: never;
|
|
641
715
|
};
|
|
@@ -650,7 +724,7 @@ export type ClientOperationTypes = {
|
|
|
650
724
|
};
|
|
651
725
|
'weft.workflows.replay': {
|
|
652
726
|
readonly input: {
|
|
653
|
-
readonly step:
|
|
727
|
+
readonly step: string | number;
|
|
654
728
|
readonly workflowId: string;
|
|
655
729
|
};
|
|
656
730
|
readonly output: unknown;
|
|
@@ -676,7 +750,10 @@ export type ClientOperationTypes = {
|
|
|
676
750
|
readonly input: {
|
|
677
751
|
readonly workflowId: string;
|
|
678
752
|
};
|
|
679
|
-
readonly output:
|
|
753
|
+
readonly output: {
|
|
754
|
+
readonly occurrence?: number;
|
|
755
|
+
readonly scheduleId: string;
|
|
756
|
+
} | null;
|
|
680
757
|
readonly faults: never;
|
|
681
758
|
};
|
|
682
759
|
'weft.workflows.signal': {
|
|
@@ -687,7 +764,7 @@ export type ClientOperationTypes = {
|
|
|
687
764
|
readonly workflowId: string;
|
|
688
765
|
};
|
|
689
766
|
readonly output: {
|
|
690
|
-
readonly ok:
|
|
767
|
+
readonly ok: true;
|
|
691
768
|
};
|
|
692
769
|
readonly faults: 'NotFound';
|
|
693
770
|
};
|
|
@@ -754,7 +831,7 @@ export type ClientOperationTypes = {
|
|
|
754
831
|
readonly workflowId: string;
|
|
755
832
|
};
|
|
756
833
|
readonly output: {
|
|
757
|
-
readonly ok:
|
|
834
|
+
readonly ok: true;
|
|
758
835
|
};
|
|
759
836
|
readonly faults: 'NotFound' | 'Unprocessable';
|
|
760
837
|
};
|
|
@@ -764,7 +841,7 @@ export type ClientOperationTypes = {
|
|
|
764
841
|
readonly workflowId: string;
|
|
765
842
|
};
|
|
766
843
|
readonly output: {
|
|
767
|
-
readonly ok:
|
|
844
|
+
readonly ok: true;
|
|
768
845
|
};
|
|
769
846
|
readonly faults: 'NotFound' | 'Unprocessable';
|
|
770
847
|
};
|
|
@@ -38,7 +38,7 @@ export function createHttpClientStorage(baseUrl, headers) {
|
|
|
38
38
|
await requestResponse(baseUrl, `/storage/${encodeURIComponent(key)}`, headers, {
|
|
39
39
|
method: "PUT",
|
|
40
40
|
headers: { "content-type": "application/octet-stream" },
|
|
41
|
-
body: new Blob([value])
|
|
41
|
+
body: new Blob([new Uint8Array(value)])
|
|
42
42
|
});
|
|
43
43
|
},
|
|
44
44
|
async delete(key) {
|
|
@@ -95,14 +95,14 @@ export declare function buildActivityReconciliationReference(workflowId: string,
|
|
|
95
95
|
export declare function resolveActivityIdempotencyKey(activity: ActivityReconciliationMetadata | undefined, operation: ActivityOperation): string | undefined;
|
|
96
96
|
export declare function readActivityReconciliationRecord(storage: Storage, key: string): Promise<ActivityReconciliationRecord | null>;
|
|
97
97
|
export declare function validateActivityResultForReconciliation(result: unknown, maxPayloadBytes: number | null): Uint8Array;
|
|
98
|
-
export declare function claimActivityReconciliationStart(
|
|
98
|
+
export declare function claimActivityReconciliationStart(internals: EngineInternals, workflowId: string, reference: ActivityReconciliationReference, record: ActivityReconciliationRecord): Promise<boolean>;
|
|
99
99
|
export declare function createCompletedActivityReconciliationRecord(startedRecord: ActivityReconciliationRecord, result: unknown, now: number): ActivityReconciliationRecord;
|
|
100
100
|
export declare function resolveStartedActivityReconciliationRecord(internals: EngineInternals, workflowId: string, operation: ActivityOperation, reference: ActivityReconciliationReference, activity: ActivityReconciliationMetadata | undefined, idempotencyKey: string, attempt: number): Promise<ActivityReconciliationRecord | {
|
|
101
101
|
completedResult: unknown;
|
|
102
102
|
}>;
|
|
103
103
|
export declare function writeActivityReconciliationTransition(storage: Storage, reference: ActivityReconciliationReference, expectedRecord: ActivityReconciliationRecord, nextRecord: ActivityReconciliationRecord): Promise<void>;
|
|
104
104
|
export declare function stageActivityReconciliationTransitionWithAtomicWorkflowCommit(internals: EngineInternals, workflowId: string, reference: ActivityReconciliationReference, expectedRecord: ActivityReconciliationRecord, nextRecord: ActivityReconciliationRecord): void;
|
|
105
|
-
export declare function commitActivityReconciliationTransitionWithFencedWrite(internals: EngineInternals, reference: ActivityReconciliationReference, expectedRecord: ActivityReconciliationRecord, nextRecord: ActivityReconciliationRecord): Promise<void>;
|
|
105
|
+
export declare function commitActivityReconciliationTransitionWithFencedWrite(internals: EngineInternals, workflowId: string, reference: ActivityReconciliationReference, expectedRecord: ActivityReconciliationRecord, nextRecord: ActivityReconciliationRecord): Promise<void>;
|
|
106
106
|
export declare function normalizePreDispatchVerificationResult(result: ActivityVerificationResult): 'not-completed' | 'completed-result-unavailable' | 'indeterminate' | {
|
|
107
107
|
result: unknown;
|
|
108
108
|
};
|
|
@@ -7,7 +7,10 @@ import { decode, encode } from "../codec.js";
|
|
|
7
7
|
import { assertPayloadWithinLimit } from "../payload-size.js";
|
|
8
8
|
import { WeftError } from "../weft-error.js";
|
|
9
9
|
import { stageAtomicWorkflowCommitSideEffects } from "./checkpoint-side-effects.js";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
commitFencedEngineWrite,
|
|
12
|
+
commitFencedEngineWriteAllowingPreconditionFailure
|
|
13
|
+
} from "./fenced-write.js";
|
|
11
14
|
|
|
12
15
|
export class ActivityReconciliationCapabilityError extends WeftError {
|
|
13
16
|
constructor() {
|
|
@@ -50,11 +53,12 @@ export function validateActivityResultForReconciliation(result, maxPayloadBytes)
|
|
|
50
53
|
assertPayloadWithinLimit(result, maxPayloadBytes, "activity result");
|
|
51
54
|
return encode(result);
|
|
52
55
|
}
|
|
53
|
-
export async function claimActivityReconciliationStart(
|
|
56
|
+
export async function claimActivityReconciliationStart(internals, workflowId, reference, record) {
|
|
57
|
+
const storage = internals.storage;
|
|
54
58
|
if (!storage.capabilities().conditionalBatch)
|
|
55
59
|
throw new ActivityReconciliationCapabilityError;
|
|
56
60
|
requireStorageCapability(storage, "conditionalBatch", "activity result reconciliation");
|
|
57
|
-
return
|
|
61
|
+
return commitFencedEngineWriteAllowingPreconditionFailure(internals, workflowId, [{ type: "put", key: reference.key, value: encode(record) }], [{ key: reference.key, expectedValue: null }]);
|
|
58
62
|
}
|
|
59
63
|
export function createCompletedActivityReconciliationRecord(startedRecord, result, now) {
|
|
60
64
|
return {
|
|
@@ -84,7 +88,7 @@ export async function resolveStartedActivityReconciliationRecord(internals, work
|
|
|
84
88
|
ownerId: crypto.randomUUID(),
|
|
85
89
|
updatedAt: internals.options.getNow()
|
|
86
90
|
};
|
|
87
|
-
await commitActivityReconciliationTransitionWithFencedWrite(internals, reference, record, nextRecord);
|
|
91
|
+
await commitActivityReconciliationTransitionWithFencedWrite(internals, workflowId, reference, record, nextRecord);
|
|
88
92
|
return nextRecord;
|
|
89
93
|
}
|
|
90
94
|
if (normalized === "completed-result-unavailable")
|
|
@@ -93,7 +97,7 @@ export async function resolveStartedActivityReconciliationRecord(internals, work
|
|
|
93
97
|
throw new ActivityReconciliationIndeterminateError(`Activity "${operation.activityName}" reconciliation is indeterminate.`);
|
|
94
98
|
validateActivityResultForReconciliation(normalized.result, internals.options.payloadSizePolicy.maxBytes);
|
|
95
99
|
const completedRecord = createCompletedActivityReconciliationRecord(record, normalized.result, internals.options.getNow());
|
|
96
|
-
await commitActivityReconciliationTransitionWithFencedWrite(internals, reference, record, completedRecord);
|
|
100
|
+
await commitActivityReconciliationTransitionWithFencedWrite(internals, workflowId, reference, record, completedRecord);
|
|
97
101
|
return { completedResult: normalized.result };
|
|
98
102
|
}
|
|
99
103
|
export async function writeActivityReconciliationTransition(storage, reference, expectedRecord, nextRecord) {
|
|
@@ -104,9 +108,9 @@ export async function writeActivityReconciliationTransition(storage, reference,
|
|
|
104
108
|
export function stageActivityReconciliationTransitionWithAtomicWorkflowCommit(internals, workflowId, reference, expectedRecord, nextRecord) {
|
|
105
109
|
stageAtomicWorkflowCommitSideEffects(internals, workflowId, buildActivityReconciliationTransitionSideEffects(reference, expectedRecord, nextRecord));
|
|
106
110
|
}
|
|
107
|
-
export async function commitActivityReconciliationTransitionWithFencedWrite(internals, reference, expectedRecord, nextRecord) {
|
|
111
|
+
export async function commitActivityReconciliationTransitionWithFencedWrite(internals, workflowId, reference, expectedRecord, nextRecord) {
|
|
108
112
|
const sideEffects = buildActivityReconciliationTransitionSideEffects(reference, expectedRecord, nextRecord);
|
|
109
|
-
await commitFencedEngineWrite(internals, sideEffects.operations, sideEffects.conditions, () => new ActivityReconciliationConflictError("Activity reconciliation completion lost compare-and-set ownership."));
|
|
113
|
+
await commitFencedEngineWrite(internals, workflowId, sideEffects.operations, sideEffects.conditions, () => new ActivityReconciliationConflictError("Activity reconciliation completion lost compare-and-set ownership."));
|
|
110
114
|
}
|
|
111
115
|
function buildActivityReconciliationTransitionSideEffects(reference, expectedRecord, nextRecord) {
|
|
112
116
|
return {
|
|
@@ -171,7 +175,7 @@ function createStartedRecord(workflowId, operation, reference, attempt, now) {
|
|
|
171
175
|
}
|
|
172
176
|
async function claimStartedRecord(internals, workflowId, operation, reference, attempt) {
|
|
173
177
|
const startedRecord = createStartedRecord(workflowId, operation, reference, attempt, internals.options.getNow());
|
|
174
|
-
if (await claimActivityReconciliationStart(internals
|
|
178
|
+
if (await claimActivityReconciliationStart(internals, workflowId, reference, startedRecord))
|
|
175
179
|
return { didClaim: !0, record: startedRecord };
|
|
176
180
|
const record = await readActivityReconciliationRecord(internals.storage, reference.key);
|
|
177
181
|
if (record === null)
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "./async-activity-records.js";
|
|
11
11
|
import { stageAtomicWorkflowCommitSideEffects } from "./checkpoint-side-effects.js";
|
|
12
12
|
import { commitFencedEngineWrite } from "./fenced-write.js";
|
|
13
|
+
import { confirmWakeOwnership } from "./wake-ownership-guard.js";
|
|
13
14
|
|
|
14
15
|
export class AsyncActivityDeferral extends Error {
|
|
15
16
|
token;
|
|
@@ -30,7 +31,7 @@ export class AsyncActivityTokenNotFoundError extends WeftError {
|
|
|
30
31
|
export async function parkDeferredAsyncActivity(internals, deferral, details, callbacks) {
|
|
31
32
|
const queuedResolution = takePendingAsyncActivityResolution(internals, details.workflowId, deferral.token);
|
|
32
33
|
if (queuedResolution !== void 0) {
|
|
33
|
-
deliverPendingAsyncActivityResolution(internals, details.workflowId, queuedResolution, callbacks);
|
|
34
|
+
await deliverPendingAsyncActivityResolution(internals, details.workflowId, queuedResolution, callbacks);
|
|
34
35
|
return new Promise(() => {});
|
|
35
36
|
}
|
|
36
37
|
await registerPendingAsyncActivity(internals, {
|
|
@@ -44,16 +45,23 @@ async function consumePendingAsyncActivity(internals, token, outcome) {
|
|
|
44
45
|
const pending = internals.pendingAsyncActivities.get(token);
|
|
45
46
|
if (!pending)
|
|
46
47
|
throw new AsyncActivityTokenNotFoundError(token);
|
|
48
|
+
const registry = internals.workflowClaimRegistry;
|
|
49
|
+
if (registry !== null && registry.currentEpoch(pending.workflowId) === null)
|
|
50
|
+
throw new AsyncActivityTokenNotFoundError(token);
|
|
47
51
|
internals.pendingAsyncActivities.delete(token);
|
|
48
52
|
try {
|
|
49
|
-
await commitFencedEngineWrite(internals, buildAsyncActivityAcknowledgementOperations(pending, outcome), [], () => Error(`Async activity acknowledgement for token "${token}" lost its precondition.`));
|
|
53
|
+
await commitFencedEngineWrite(internals, pending.workflowId, buildAsyncActivityAcknowledgementOperations(pending, outcome), [], () => Error(`Async activity acknowledgement for token "${token}" lost its precondition.`));
|
|
50
54
|
} catch (error) {
|
|
51
55
|
internals.pendingAsyncActivities.set(token, pending);
|
|
52
56
|
throw error;
|
|
53
57
|
}
|
|
54
58
|
return pending;
|
|
55
59
|
}
|
|
56
|
-
function deliverPendingAsyncActivityResolution(internals, workflowId, resolution, callbacks) {
|
|
60
|
+
async function deliverPendingAsyncActivityResolution(internals, workflowId, resolution, callbacks) {
|
|
61
|
+
if (internals.workflowClaimRegistry !== null) {
|
|
62
|
+
if (await confirmWakeOwnership(internals, workflowId, "async-activity") === "discard")
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
57
65
|
stageAtomicWorkflowCommitSideEffects(internals, workflowId, {
|
|
58
66
|
conditions: [],
|
|
59
67
|
operations: [
|
|
@@ -75,7 +83,7 @@ async function resolvePendingAsyncActivity(internals, token, outcome, callbacks,
|
|
|
75
83
|
queuePendingAsyncActivityResolution(internals, pending.workflowId, resolution);
|
|
76
84
|
return;
|
|
77
85
|
}
|
|
78
|
-
deliverPendingAsyncActivityResolution(internals, pending.workflowId, resolution, callbacks);
|
|
86
|
+
await deliverPendingAsyncActivityResolution(internals, pending.workflowId, resolution, callbacks);
|
|
79
87
|
}
|
|
80
88
|
export async function completeAsyncActivity(internals, token, result, callbacks) {
|
|
81
89
|
assertPayloadWithinLimit(result, internals.options.payloadSizePolicy.maxBytes, "activity result");
|
|
@@ -104,8 +104,18 @@ export declare function registerPendingAsyncActivity(internals: EngineInternals,
|
|
|
104
104
|
* before the recovered workflow has replayed far enough to re-register it —
|
|
105
105
|
* and so an acknowledged-but-not-yet-checkpointed resolution is redelivered
|
|
106
106
|
* when replay re-parks on the same deterministic token.
|
|
107
|
+
*
|
|
108
|
+
* Pass `workflowId` to reload just one workflow's records. ADR 0002's
|
|
109
|
+
* reclaim-driven resume needs this: a resolution acknowledged by an expired
|
|
110
|
+
* owner is discarded by that engine's `confirmWakeOwnership` check, leaving
|
|
111
|
+
* only the durable record. The engine that takes the workflow over finished
|
|
112
|
+
* its startup scan long ago, so without a per-workflow reload it never
|
|
113
|
+
* discovers a resolution written after that scan — the workflow re-parks and
|
|
114
|
+
* waits forever even though the completion caller was told it succeeded. The
|
|
115
|
+
* scan is bounded to {@link asyncActivityWorkflowPrefix}, so a takeover pays
|
|
116
|
+
* for one workflow rather than a store-wide sweep.
|
|
107
117
|
*/
|
|
108
|
-
export declare function recoverPendingAsyncActivities(internals: EngineInternals): Promise<void>;
|
|
118
|
+
export declare function recoverPendingAsyncActivities(internals: EngineInternals, workflowId?: string): Promise<void>;
|
|
109
119
|
/**
|
|
110
120
|
* True when a resolution cannot be delivered yet because inline replay has not
|
|
111
121
|
* adopted the workflow generator (the post-recovery window).
|
|
@@ -148,12 +148,13 @@ export function buildAsyncActivityAcknowledgementOperations(pending, outcome) {
|
|
|
148
148
|
export async function registerPendingAsyncActivity(internals, pending) {
|
|
149
149
|
const alreadyRegistered = internals.pendingAsyncActivities.has(pending.token);
|
|
150
150
|
internals.pendingAsyncActivities.set(pending.token, pending);
|
|
151
|
-
await commitFencedEngineWrite(internals, [buildPersistPendingAsyncActivityOperation(pending)], [], () => Error(`Async activity registration for token "${pending.token}" lost its precondition.`));
|
|
151
|
+
await commitFencedEngineWrite(internals, pending.workflowId, [buildPersistPendingAsyncActivityOperation(pending)], [], () => Error(`Async activity registration for token "${pending.token}" lost its precondition.`));
|
|
152
152
|
if (!alreadyRegistered)
|
|
153
153
|
internals.engine.dispatchEvent(new ActivityAsyncPendingEvent(pending.token, pending.operationId, pending.workflowId, pending.activityName, pending.attempt));
|
|
154
154
|
}
|
|
155
|
-
export async function recoverPendingAsyncActivities(internals) {
|
|
156
|
-
|
|
155
|
+
export async function recoverPendingAsyncActivities(internals, workflowId) {
|
|
156
|
+
const scanPrefix = workflowId === void 0 ? ASYNC_ACTIVITY_KEY_PREFIX : asyncActivityWorkflowPrefix(workflowId);
|
|
157
|
+
for await (const [, bytes] of internals.storage.scan(scanPrefix)) {
|
|
157
158
|
const decoded = decode(bytes);
|
|
158
159
|
if (isPersistedAsyncActivity(decoded)) {
|
|
159
160
|
internals.pendingAsyncActivities.set(decoded.token, {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { BatchOperation } from '../../storage/interface.ts';
|
|
2
2
|
import type { BulkTagResult, ListFilter, SearchAttributeValue, WorkflowState, WorkflowStatus } from '../types.ts';
|
|
3
3
|
import type { EngineInternals } from './internals.ts';
|
|
4
|
+
/**
|
|
5
|
+
* `updateWorkflowState`'s two callers commit very different transitions per
|
|
6
|
+
* ADR 0002: `failWorkflow` is a SELF-transition (this engine finishing its
|
|
7
|
+
* own workflow) while `terminateWorkflow` (cancel/timeout) is an EXTERNAL
|
|
8
|
+
* terminal transition (any engine may commit it, and it rotates the claim
|
|
9
|
+
* epoch under `ownership: 'workflow-lease'`). `category` is a REQUIRED
|
|
10
|
+
* positional parameter rather than an optional options field so a caller
|
|
11
|
+
* cannot silently default into the wrong fencing shape.
|
|
12
|
+
*/
|
|
13
|
+
export type WorkflowStateTransitionCategory = 'self' | 'external-terminal';
|
|
4
14
|
type WorkflowStateUpdateOptions = {
|
|
5
15
|
allowedStatuses?: readonly WorkflowStatus[];
|
|
6
16
|
buildAdditionalOperations?: (previousState: WorkflowState, updatedAt: number) => BatchOperation[];
|
|
@@ -21,7 +31,7 @@ export declare function writeRetainedTerminalSearchAttributes(internals: EngineI
|
|
|
21
31
|
/** Build secondary-index updates for terminal workflow state transitions. */
|
|
22
32
|
export declare function buildTerminalWorkflowIndexOperations(previousState: WorkflowState, nextState: WorkflowState): BatchOperation[];
|
|
23
33
|
/** Apply a serialized workflow-state update and return the previous state metadata. */
|
|
24
|
-
export declare function updateWorkflowState(internals: EngineInternals, workflowId: string, updates: Partial<WorkflowState>, options?: WorkflowStateUpdateOptions): Promise<WorkflowStateUpdateResult | null>;
|
|
34
|
+
export declare function updateWorkflowState(internals: EngineInternals, workflowId: string, updates: Partial<WorkflowState>, category: WorkflowStateTransitionCategory, options?: WorkflowStateUpdateOptions): Promise<WorkflowStateUpdateResult | null>;
|
|
25
35
|
/** Add or remove tags for a single workflow under the serialized state-write lock. */
|
|
26
36
|
export declare function mutateWorkflowTags(internals: EngineInternals, workflowId: string, tags: string[], mode: 'add' | 'remove'): Promise<boolean>;
|
|
27
37
|
/** Add or remove tags for every workflow selected by a scoped bulk filter. */
|