@workflow/core 5.0.0-beta.41 → 5.0.0-beta.43
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/dist/create-hook.d.ts +9 -5
- package/dist/create-hook.d.ts.map +1 -1
- package/dist/create-hook.js +1 -1
- package/dist/events-consumer.d.ts +97 -0
- package/dist/events-consumer.d.ts.map +1 -1
- package/dist/events-consumer.js +147 -14
- package/dist/private.d.ts +31 -12
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +149 -26
- package/dist/runtime/constants.d.ts +62 -0
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +70 -1
- package/dist/runtime/helpers.d.ts +127 -93
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +149 -132
- package/dist/runtime/quickjs-entrypoint.d.ts +10 -9
- package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -1
- package/dist/runtime/quickjs-entrypoint.js +162 -38
- package/dist/runtime/replay-budget.d.ts +8 -0
- package/dist/runtime/replay-budget.d.ts.map +1 -1
- package/dist/runtime/replay-budget.js +3 -3
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +53 -13
- package/dist/runtime/resume-latency.d.ts +143 -0
- package/dist/runtime/resume-latency.d.ts.map +1 -0
- package/dist/runtime/resume-latency.js +153 -0
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +54 -29
- package/dist/runtime/step-executor.d.ts +76 -13
- package/dist/runtime/step-executor.d.ts.map +1 -1
- package/dist/runtime/step-executor.js +171 -19
- package/dist/runtime/step-latency.d.ts +6 -0
- package/dist/runtime/step-latency.d.ts.map +1 -1
- package/dist/runtime/step-latency.js +3 -1
- package/dist/runtime/suspension-handler.d.ts +119 -8
- package/dist/runtime/suspension-handler.d.ts.map +1 -1
- package/dist/runtime/suspension-handler.js +643 -46
- package/dist/runtime/world-compatibility.d.ts +6 -5
- package/dist/runtime/world-compatibility.d.ts.map +1 -1
- package/dist/runtime/world-compatibility.js +7 -6
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +583 -142
- package/dist/serialization/codec-devalue.d.ts.map +1 -1
- package/dist/serialization/codec-devalue.js +15 -4
- package/dist/serialization.d.ts +10 -2
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +55 -8
- package/dist/telemetry/semantic-conventions.d.ts +81 -0
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
- package/dist/telemetry/semantic-conventions.js +67 -1
- package/dist/telemetry.d.ts +6 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +22 -1
- package/dist/test-support/orchestrator-context.d.ts +25 -0
- package/dist/test-support/orchestrator-context.d.ts.map +1 -0
- package/dist/test-support/orchestrator-context.js +91 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/workflow/create-hook.js +2 -2
- package/dist/workflow/hook.js +3 -3
- package/dist/workflow.js +43 -2
- package/docs/foundations/hooks.mdx +2 -2
- package/docs/foundations/streaming.mdx +24 -0
- package/docs/how-it-works/event-sourcing.mdx +39 -1
- package/package.json +5 -5
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Event, SerializedData, World } from '@workflow/world';
|
|
1
|
+
import type { Event, SerializedData, StartedStep, World } from '@workflow/world';
|
|
2
2
|
import type { PayloadKey } from '../serialization/encryption.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type SlotSnapshotParams } from './helpers.js';
|
|
4
4
|
import { ReplayRecoveryReporter } from './replay-recovery-reporter.js';
|
|
5
|
+
import { type ResumeTtrTracking } from './resume-latency.js';
|
|
5
6
|
import { type StepLatencyTracking } from './step-latency.js';
|
|
6
7
|
export declare const DEFAULT_STEP_MAX_RETRIES = 3;
|
|
7
8
|
export interface StepExecutorParams {
|
|
@@ -11,6 +12,8 @@ export interface StepExecutorParams {
|
|
|
11
12
|
workflowDeploymentId?: string;
|
|
12
13
|
workflowName: string;
|
|
13
14
|
workflowStartedAt: number;
|
|
15
|
+
/** Request ID of the invocation executing this step, when provided by its queue. */
|
|
16
|
+
requestId?: string;
|
|
14
17
|
/** Root run id of this run's lineage, carried into the step context. */
|
|
15
18
|
rootRunId?: string;
|
|
16
19
|
stepId: string;
|
|
@@ -34,6 +37,17 @@ export interface StepExecutorParams {
|
|
|
34
37
|
* carries no payload (the legacy contract).
|
|
35
38
|
*/
|
|
36
39
|
lazyStepInput?: SerializedData;
|
|
40
|
+
/**
|
|
41
|
+
* Pre-claimed inline start: the suspension handler committed (or lost) this
|
|
42
|
+
* step's `step_created` + `step_started` pair inside its batched fan-out
|
|
43
|
+
* write, so the start this executor would otherwise send has already been
|
|
44
|
+
* decided. `owned: false` returns `{ type: 'skipped' }` before any write —
|
|
45
|
+
* the same outcome as losing the lazy claim's atomic create. `owned: true`
|
|
46
|
+
* skips both start paths (no start write at all) and runs the body against
|
|
47
|
+
* the claimed step. Mutually exclusive with `lazyStepInput`: the input
|
|
48
|
+
* already rode the pair's `step_created`, and the claimed step carries it.
|
|
49
|
+
*/
|
|
50
|
+
preclaimedStart?: PreclaimedInlineStart;
|
|
37
51
|
/**
|
|
38
52
|
* Inline step ownership: the queue message ID of the invocation this
|
|
39
53
|
* executeStep call runs in (from the queue handler's meta). When set, the
|
|
@@ -59,20 +73,25 @@ export interface StepExecutorParams {
|
|
|
59
73
|
*/
|
|
60
74
|
inlineDeltaSinceCursor?: string;
|
|
61
75
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* so
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
76
|
+
* How much of the run's log the caller's replay had loaded when it scheduled
|
|
77
|
+
* this step, as the highest slot that log occupies. Seeds the snapshot every
|
|
78
|
+
* write this executor makes carries; each committed event advances it to its
|
|
79
|
+
* own slot, so a later write never names a position that predates an earlier
|
|
80
|
+
* one from the same step.
|
|
81
|
+
*
|
|
82
|
+
* It matters most on the lazy inline path, where the `step_started` claim is
|
|
83
|
+
* the step's FIRST durable write (its `step_created` is deferred): without a
|
|
84
|
+
* seed the claim would name no position at all, and a replay working from a
|
|
85
|
+
* stale view could claim — and then commit — a step scheduled without
|
|
86
|
+
* observing an event it never loaded.
|
|
87
|
+
*
|
|
88
|
+
* A World that fences rejects a stale claim with `PreconditionFailedError`
|
|
69
89
|
* (412); executeStep does NOT translate that rejection (re-claiming in place
|
|
70
90
|
* would still commit the stale schedule), so it propagates for the caller to
|
|
71
|
-
* abandon the batch and restart its replay. Undefined
|
|
72
|
-
*
|
|
73
|
-
* ignore it.
|
|
91
|
+
* abandon the batch and restart its replay. Undefined for a caller with
|
|
92
|
+
* nothing loaded.
|
|
74
93
|
*/
|
|
75
|
-
|
|
94
|
+
slotSnapshot?: SlotSnapshotParams;
|
|
76
95
|
/**
|
|
77
96
|
* Suppress optimistic inline start for this step regardless of
|
|
78
97
|
* `WORKFLOW_OPTIMISTIC_INLINE_START` / `forceOptimisticStart`: take the
|
|
@@ -111,6 +130,15 @@ export interface StepExecutorParams {
|
|
|
111
130
|
* runtime/step-latency.ts.
|
|
112
131
|
*/
|
|
113
132
|
latencyTracking?: StepLatencyTracking;
|
|
133
|
+
/**
|
|
134
|
+
* Hook-resume TTR telemetry: the boundaries of a hook resumption whose next
|
|
135
|
+
* durable step is the one this call is about to execute. When set, the
|
|
136
|
+
* executor closes the measurement against the `step_started` claim and the
|
|
137
|
+
* wall clock taken immediately before user code, and attaches the total plus
|
|
138
|
+
* its phase breakdown to this step's `step.execute` span. Set by the runtime
|
|
139
|
+
* for exactly one step per resumption — see runtime/resume-latency.ts.
|
|
140
|
+
*/
|
|
141
|
+
resumeTracking?: ResumeTtrTracking;
|
|
114
142
|
/**
|
|
115
143
|
* Authoritative attempt number for this execution, used to bound retries
|
|
116
144
|
* against `maxRetries` BEFORE the body runs. In order to also catch
|
|
@@ -125,6 +153,41 @@ export interface StepExecutorParams {
|
|
|
125
153
|
/** One-shot recovery telemetry activated by the orchestrator replay. */
|
|
126
154
|
replayRecoveryReporter?: ReplayRecoveryReporter;
|
|
127
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* The settled outcome of a `step_created` + `step_started` pair the
|
|
158
|
+
* suspension handler folded into its batched fan-out write (see
|
|
159
|
+
* `SuspensionHandlerResult.inlineClaims`). Handed to executeStep as
|
|
160
|
+
* {@link StepExecutorParams.preclaimedStart} so the executor runs (or skips)
|
|
161
|
+
* the body off the batch's verdict instead of sending a start of its own.
|
|
162
|
+
*/
|
|
163
|
+
export type PreclaimedInlineStart = {
|
|
164
|
+
/** The pair committed: this execution owns the step and runs the body. */
|
|
165
|
+
owned: true;
|
|
166
|
+
/**
|
|
167
|
+
* The started step entity from the batch result, with the locally
|
|
168
|
+
* dehydrated input attached by the suspension handler (batch responses
|
|
169
|
+
* return refs lazily; the body's hydration wants the same bytes the
|
|
170
|
+
* pair's `step_created` carried).
|
|
171
|
+
*/
|
|
172
|
+
step: StartedStep;
|
|
173
|
+
/**
|
|
174
|
+
* `Date.now()` taken right before the batch POST that carried the pair
|
|
175
|
+
* — the claim's "start POST sent" instant, anchoring RSFS exactly like
|
|
176
|
+
* the lazy claim's own POST would.
|
|
177
|
+
*/
|
|
178
|
+
batchPostSentAtMs?: number;
|
|
179
|
+
/**
|
|
180
|
+
* `Date.now()` taken right after that batch POST returned — the
|
|
181
|
+
* claim's completion instant (T6 of the hook-resume TTR window).
|
|
182
|
+
*/
|
|
183
|
+
claimCompletedAtMs?: number;
|
|
184
|
+
} | {
|
|
185
|
+
/**
|
|
186
|
+
* The pair lost its atomic create-claim (per-event 409): a concurrent
|
|
187
|
+
* writer owns the step, so the body must not run here.
|
|
188
|
+
*/
|
|
189
|
+
owned: false;
|
|
190
|
+
};
|
|
128
191
|
/**
|
|
129
192
|
* Inline-delta returned by a step-terminal write when the caller passed
|
|
130
193
|
* {@link StepExecutorParams.inlineDeltaSinceCursor} and the World supports
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-executor.d.ts","sourceRoot":"","sources":["../../src/runtime/step-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"step-executor.d.ts","sourceRoot":"","sources":["../../src/runtime/step-executor.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGV,KAAK,EAEL,cAAc,EACd,WAAW,EACX,KAAK,EACN,MAAM,iBAAiB,CAAC;AAQzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAuBjE,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAuB1C,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH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