@yieldstar/core 0.4.6 → 0.6.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/dist/base/durable-value.d.ts +71 -0
- package/dist/base/durable-value.d.ts.map +1 -0
- package/dist/base/durable-value.test.d.ts +2 -0
- package/dist/base/durable-value.test.d.ts.map +1 -0
- package/dist/base/effect.d.ts +136 -0
- package/dist/base/effect.d.ts.map +1 -0
- package/dist/base/errors.d.ts +23 -0
- package/dist/base/errors.d.ts.map +1 -0
- package/dist/base/errors.test.d.ts +2 -0
- package/dist/base/errors.test.d.ts.map +1 -0
- package/dist/base/event.d.ts +6 -1
- package/dist/base/event.d.ts.map +1 -1
- package/dist/base/execution.d.ts +244 -0
- package/dist/base/execution.d.ts.map +1 -0
- package/dist/base/heap.d.ts +15 -3
- package/dist/base/heap.d.ts.map +1 -1
- package/dist/base/invoker.d.ts +47 -2
- package/dist/base/invoker.d.ts.map +1 -1
- package/dist/base/runtime.d.ts +27 -4
- package/dist/base/runtime.d.ts.map +1 -1
- package/dist/base/step.d.ts +26 -5
- package/dist/base/step.d.ts.map +1 -1
- package/dist/base/store.d.ts +431 -0
- package/dist/base/store.d.ts.map +1 -0
- package/dist/base/store.test.d.ts +2 -0
- package/dist/base/store.test.d.ts.map +1 -0
- package/dist/base/workflow.d.ts +17 -0
- package/dist/base/workflow.d.ts.map +1 -1
- package/dist/index.d.ts +24 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1986 -111
- package/dist/lib/effect-state.d.ts +78 -0
- package/dist/lib/effect-state.d.ts.map +1 -0
- package/dist/lib/execution-dispatcher.d.ts +102 -0
- package/dist/lib/execution-dispatcher.d.ts.map +1 -0
- package/dist/lib/execution-state.d.ts +248 -0
- package/dist/lib/execution-state.d.ts.map +1 -0
- package/dist/lib/execution-state.test.d.ts +2 -0
- package/dist/lib/execution-state.test.d.ts.map +1 -0
- package/dist/lib/wait-for-outcome.d.ts +15 -0
- package/dist/lib/wait-for-outcome.d.ts.map +1 -0
- package/dist/lib/workflow-runner.d.ts +14 -7
- package/dist/lib/workflow-runner.d.ts.map +1 -1
- package/dist/utils/map.d.ts +1 -1
- package/dist/utils/map.d.ts.map +1 -1
- package/package.json +13 -3
- package/src/base/durable-value.test.ts +285 -0
- package/src/base/durable-value.ts +442 -0
- package/src/base/effect.ts +165 -0
- package/src/base/errors.test.ts +210 -0
- package/src/base/errors.ts +72 -0
- package/src/base/event.ts +6 -1
- package/src/base/execution.ts +303 -0
- package/src/base/heap.ts +17 -3
- package/src/base/invoker.ts +60 -2
- package/src/base/runtime.ts +28 -7
- package/src/base/step.ts +37 -7
- package/src/base/store.test.ts +176 -0
- package/src/base/store.ts +1123 -0
- package/src/base/workflow.ts +17 -0
- package/src/index.ts +174 -3
- package/src/lib/effect-state.ts +254 -0
- package/src/lib/execution-dispatcher.ts +393 -0
- package/src/lib/execution-state.test.ts +249 -0
- package/src/lib/execution-state.ts +650 -0
- package/src/lib/wait-for-outcome.ts +40 -0
- package/src/lib/workflow-runner.ts +78 -34
- package/src/utils/map.test.ts +1 -1
- package/src/utils/map.ts +8 -2
- package/dist/base/map.d.ts +0 -21
- package/dist/base/map.d.ts.map +0 -1
- package/dist/base/map.test.d.ts +0 -2
- package/dist/base/map.test.d.ts.map +0 -1
- package/dist/base/schedule.d.ts +0 -71
- package/dist/base/schedule.d.ts.map +0 -1
- package/dist/base/types.d.ts +0 -24
- package/dist/base/types.d.ts.map +0 -1
- package/src/base/scheduler.ts +0 -8
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { EffectClientInvariantError, type EffectBeginRequest, type EffectBeginResult, type EffectRecord, type EffectSettleRequest, type EffectSettleResult, type EffectWatchRequest } from "../base/effect";
|
|
2
|
+
/**
|
|
3
|
+
* An effect as runtime adapters store it. `input`, `result` and the values of
|
|
4
|
+
* each conflict report are canonical `durableValueCodec` encodings, so equal
|
|
5
|
+
* values compare as equal strings.
|
|
6
|
+
*/
|
|
7
|
+
export type EffectState = {
|
|
8
|
+
effectId: string;
|
|
9
|
+
operation: string;
|
|
10
|
+
input: string;
|
|
11
|
+
status: "pending" | "settled";
|
|
12
|
+
result?: string;
|
|
13
|
+
conflicts: EffectConflictState[];
|
|
14
|
+
};
|
|
15
|
+
export type EffectConflictState = {
|
|
16
|
+
result: string;
|
|
17
|
+
conflictingResult: string;
|
|
18
|
+
reportedAt: number;
|
|
19
|
+
};
|
|
20
|
+
export type PreparedEffectBegin = {
|
|
21
|
+
effectId: string;
|
|
22
|
+
operation: string;
|
|
23
|
+
/** The canonical input. */
|
|
24
|
+
input: string;
|
|
25
|
+
executionId: string;
|
|
26
|
+
stepKey: string;
|
|
27
|
+
};
|
|
28
|
+
export type PreparedEffectSettle = {
|
|
29
|
+
effectId: string;
|
|
30
|
+
operation: string;
|
|
31
|
+
/** The canonical result. */
|
|
32
|
+
result: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Checks the values `step.effect` passes to `begin`, and returns a message
|
|
36
|
+
* naming the first invalid one. The driver rejects these requests with
|
|
37
|
+
* `INVALID_EFFECT_REQUEST` before calling the client.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateEffectRequest(request: {
|
|
40
|
+
effectId: unknown;
|
|
41
|
+
operation: unknown;
|
|
42
|
+
input: unknown;
|
|
43
|
+
}): {
|
|
44
|
+
ok: true;
|
|
45
|
+
input: string;
|
|
46
|
+
} | {
|
|
47
|
+
ok: false;
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Validates a `begin` request and encodes its input canonically. Adapters call
|
|
52
|
+
* this before touching storage; it throws `EffectClientInvariantError` for a
|
|
53
|
+
* request the driver should have rejected.
|
|
54
|
+
*/
|
|
55
|
+
export declare function prepareEffectBegin(request: EffectBeginRequest): PreparedEffectBegin;
|
|
56
|
+
/** Validates a `settle` request and encodes its result canonically. */
|
|
57
|
+
export declare function prepareEffectSettle(request: EffectSettleRequest): PreparedEffectSettle;
|
|
58
|
+
/** Validates a `watch` request. */
|
|
59
|
+
export declare function prepareEffectWatch(request: EffectWatchRequest): EffectWatchRequest;
|
|
60
|
+
/** The pending effect a `begin` that finds no effect creates. */
|
|
61
|
+
export declare function createEffectState(begin: PreparedEffectBegin): EffectState;
|
|
62
|
+
/** Answers a `begin` for an effect that already exists. */
|
|
63
|
+
export declare function matchEffectBegin(state: EffectState, begin: PreparedEffectBegin): EffectBeginResult;
|
|
64
|
+
/**
|
|
65
|
+
* Applies a settlement. `wake` is true only when this settlement moved the
|
|
66
|
+
* effect from pending to settled: adapters then wake every waiter in the same
|
|
67
|
+
* write. `state` is the input object when nothing changed. Throws
|
|
68
|
+
* `EffectClientInvariantError` when the operation differs from the effect's,
|
|
69
|
+
* which `begin` would have rejected.
|
|
70
|
+
*/
|
|
71
|
+
export declare function settleEffect(state: EffectState, settle: PreparedEffectSettle, now: number): {
|
|
72
|
+
state: EffectState;
|
|
73
|
+
result: EffectSettleResult;
|
|
74
|
+
wake: boolean;
|
|
75
|
+
};
|
|
76
|
+
export declare function toEffectRecord(state: EffectState): EffectRecord;
|
|
77
|
+
export declare function effectNotFound(effectId: string): EffectClientInvariantError;
|
|
78
|
+
//# sourceMappingURL=effect-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect-state.d.ts","sourceRoot":"","sources":["../../src/lib/effect-state.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,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BAAmB,GAAG,WAAW,CAQzE;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,mBAAmB,GACzB,iBAAiB,CAMnB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,oBAAoB,EAC5B,GAAG,EAAE,MAAM,GACV;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAoCnE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAc/D;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,0BAA0B,CAE3E"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Logger } from "pino";
|
|
2
|
+
import type { WorkflowInvoker } from "../base/invoker";
|
|
3
|
+
import type { Runtime } from "../base/runtime";
|
|
4
|
+
export declare const DEFAULT_DISPATCHER_CONCURRENCY = 10;
|
|
5
|
+
export declare const DEFAULT_ABORT_GRACE_PERIOD = 1000;
|
|
6
|
+
export interface DispatcherOptions {
|
|
7
|
+
invoker: WorkflowInvoker;
|
|
8
|
+
logger: Logger;
|
|
9
|
+
/** The maximum number of deliveries this dispatcher runs at once. @default 10 */
|
|
10
|
+
concurrency?: number;
|
|
11
|
+
/** Milliseconds between claims when nothing is due. @default 10 */
|
|
12
|
+
pollInterval?: number;
|
|
13
|
+
/** Whether the dispatcher's timers keep the process alive. @default true */
|
|
14
|
+
keepAlive?: boolean;
|
|
15
|
+
/** How long each lease lasts unless renewed, in milliseconds. @default 30_000 */
|
|
16
|
+
leaseDuration?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Milliseconds between renewals of a delivery's lease, measured on the
|
|
19
|
+
* process's timers. Must be shorter than `leaseDuration`.
|
|
20
|
+
* @default leaseDuration / 3
|
|
21
|
+
*/
|
|
22
|
+
renewInterval?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Milliseconds to keep waiting for a delivery after its lease is lost and
|
|
25
|
+
* its signal aborts. After that the dispatcher abandons the delivery and
|
|
26
|
+
* frees its slot, even if the invoker cannot stop a step function that is
|
|
27
|
+
* still running.
|
|
28
|
+
* @default 1_000
|
|
29
|
+
*/
|
|
30
|
+
abortGracePeriod?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The only component that delivers executions. It leases due executions, reads
|
|
34
|
+
* each event from its record, hands it to the invoker, and acknowledges the
|
|
35
|
+
* outcome under the delivery's lease.
|
|
36
|
+
*
|
|
37
|
+
* - Up to `concurrency` deliveries run at once. The dispatcher claims new
|
|
38
|
+
* executions as slots free up, without waiting for earlier deliveries.
|
|
39
|
+
* - It renews each lease every `renewInterval` while the delivery runs. If a
|
|
40
|
+
* renewal returns `lost`, another claim has taken over: the dispatcher stops
|
|
41
|
+
* renewing, aborts the delivery's signal so it runs no more workflow code,
|
|
42
|
+
* and neither acknowledges nor releases. If the delivery has not settled
|
|
43
|
+
* `abortGracePeriod` after the abort, the dispatcher abandons it and frees
|
|
44
|
+
* its slot. An abandoned delivery may keep running a step function, but its
|
|
45
|
+
* signal and lease token stop every write it attempts.
|
|
46
|
+
* - A delivery that rejects is not acknowledged. If the worker exited before
|
|
47
|
+
* replying, the lease is left to expire; any other rejection is a retry
|
|
48
|
+
* reply, and the lease is released. Either way the wakes stay pending and the
|
|
49
|
+
* execution is delivered again after the redelivery delay.
|
|
50
|
+
* - If reading the record, acknowledging or releasing throws, the lease is
|
|
51
|
+
* left to expire rather than released.
|
|
52
|
+
*/
|
|
53
|
+
export declare class ExecutionDispatcher {
|
|
54
|
+
private runtime;
|
|
55
|
+
private invoker;
|
|
56
|
+
private logger;
|
|
57
|
+
private pollInterval;
|
|
58
|
+
private keepAlive;
|
|
59
|
+
private concurrency;
|
|
60
|
+
private leaseDuration;
|
|
61
|
+
private renewInterval;
|
|
62
|
+
private abortGracePeriod;
|
|
63
|
+
private running;
|
|
64
|
+
private looping;
|
|
65
|
+
private timer;
|
|
66
|
+
private inFlight;
|
|
67
|
+
/** Slots reserved by claims that have not returned yet. */
|
|
68
|
+
private claiming;
|
|
69
|
+
constructor(runtime: Runtime, options: DispatcherOptions);
|
|
70
|
+
start(): void;
|
|
71
|
+
/** Stops claiming and waits for in-flight deliveries to settle. */
|
|
72
|
+
stop(): Promise<void>;
|
|
73
|
+
get activeDeliveries(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Leases due executions, up to the free delivery slots, and starts
|
|
76
|
+
* delivering them. Resolves with the number of deliveries claimed; it does
|
|
77
|
+
* not wait for them to finish.
|
|
78
|
+
*/
|
|
79
|
+
tick(): Promise<number>;
|
|
80
|
+
/** Waits for every delivery started so far to settle. */
|
|
81
|
+
drain(): Promise<void>;
|
|
82
|
+
private schedule;
|
|
83
|
+
private loop;
|
|
84
|
+
private dispatch;
|
|
85
|
+
/**
|
|
86
|
+
* Settles with `delivery`, or with `ABANDONED` once `abortGracePeriod` has
|
|
87
|
+
* passed since `signal` aborted. An abandoned delivery's late outcome or
|
|
88
|
+
* rejection is logged and otherwise ignored, so it is never acknowledged or
|
|
89
|
+
* released and never surfaces as an unhandled rejection.
|
|
90
|
+
*/
|
|
91
|
+
private abandonAfterAbort;
|
|
92
|
+
/**
|
|
93
|
+
* Renews `lease` every `renewInterval` until stopped. `signal` aborts, with
|
|
94
|
+
* a `LeaseLostError`, once a renewal returns `lost`. `stop` waits for any
|
|
95
|
+
* renewal in flight and resolves with the latest lease, or `undefined` once
|
|
96
|
+
* a renewal has returned `lost`.
|
|
97
|
+
*/
|
|
98
|
+
private renew;
|
|
99
|
+
private warnLost;
|
|
100
|
+
private emit;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=execution-dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-dispatcher.d.ts","sourceRoot":"","sources":["../../src/lib/execution-dispat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;IAwBxD,KAAK;IAML,mEAAmE;IAC7D,IAAI;IAOV,IAAI,gBAAgB,WAEnB;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAwB7B,yDAAyD;IACnD,KAAK;IAMX,OAAO,CAAC,QAAQ;YASF,IAAI;YAiBJ,QAAQ;IAiFtB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAiDzB;;;;;OAKG;IACH,OAAO,CAAC,KAAK;IAiDb,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,IAAI;CAOb"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { EventContext, EventParams } from "../base/event";
|
|
2
|
+
import type { ExecutionAcknowledgeResult, ExecutionLease, ExecutionOutcome, ExecutionParent, ExecutionRecord, ExecutionReleaseResult, ExecutionRenewResult, ExecutionStartRequest, ExecutionStartResult, ExecutionStatus, WorkflowRunOutcome } from "../base/execution";
|
|
3
|
+
/**
|
|
4
|
+
* Storage-neutral state of one execution record, with the event and outcome
|
|
5
|
+
* already encoded. Runtime adapters persist these fields however they like and
|
|
6
|
+
* apply the transitions below inside one atomic write, so every adapter keeps
|
|
7
|
+
* the same lease, wake and acknowledgement semantics.
|
|
8
|
+
*
|
|
9
|
+
* Lease transitions (claim, renew, release) do not change `updatedAt`.
|
|
10
|
+
*/
|
|
11
|
+
export type ExecutionState = {
|
|
12
|
+
executionId: string;
|
|
13
|
+
workflowId: string;
|
|
14
|
+
params: string;
|
|
15
|
+
context: string;
|
|
16
|
+
/**
|
|
17
|
+
* The status the execution rests in when it has no live lease. The record's
|
|
18
|
+
* `running` status is derived from the lease and the clock by
|
|
19
|
+
* `executionStatusAt`, so an expired lease reads as ended without a write.
|
|
20
|
+
*/
|
|
21
|
+
status: Exclude<ExecutionStatus, "running">;
|
|
22
|
+
outcome: string | null;
|
|
23
|
+
admittedAt: number;
|
|
24
|
+
updatedAt: number;
|
|
25
|
+
/** The earliest of the wakes not covered by a lease. */
|
|
26
|
+
dueAt: number | null;
|
|
27
|
+
/**
|
|
28
|
+
* The wakes the current lease covers. They stay pending until that lease is
|
|
29
|
+
* acknowledged, so a lease that is released or expires leaves them due.
|
|
30
|
+
*/
|
|
31
|
+
claimedDueAt: number | null;
|
|
32
|
+
/** The highest token issued for this execution (0 before the first claim). */
|
|
33
|
+
leaseToken: number;
|
|
34
|
+
/**
|
|
35
|
+
* Non-null while the lease with `leaseToken` is held, that is, claimed and
|
|
36
|
+
* not yet released or acknowledged. A held lease stays current after it
|
|
37
|
+
* expires, until a later claim issues a higher token.
|
|
38
|
+
*/
|
|
39
|
+
leaseExpiresAt: number | null;
|
|
40
|
+
/**
|
|
41
|
+
* Consecutive leases that ended by release or by expiry and a later claim.
|
|
42
|
+
* It does not include a held lease that has expired;
|
|
43
|
+
* `unacknowledgedDeliveryCountAt` adds that one.
|
|
44
|
+
*/
|
|
45
|
+
unacknowledgedDeliveryCount: number;
|
|
46
|
+
/**
|
|
47
|
+
* When a released execution may be claimed again. A held lease's delay is
|
|
48
|
+
* measured from `leaseExpiresAt` instead.
|
|
49
|
+
*/
|
|
50
|
+
redeliverAt: number | null;
|
|
51
|
+
/** Set at admission by `start`, and never changed. */
|
|
52
|
+
parent: ExecutionParent | null;
|
|
53
|
+
};
|
|
54
|
+
export declare const DEFAULT_LEASE_DURATION = 30000;
|
|
55
|
+
/** The redelivery delay after one unacknowledged delivery. */
|
|
56
|
+
export declare const REDELIVERY_DELAY_BASE = 1000;
|
|
57
|
+
export declare const REDELIVERY_DELAY_MAX = 300000;
|
|
58
|
+
/**
|
|
59
|
+
* How long an execution waits after a delivery ends unacknowledged before it
|
|
60
|
+
* can be claimed again. Starts at `REDELIVERY_DELAY_BASE` and doubles with
|
|
61
|
+
* each consecutive unacknowledged delivery, up to `REDELIVERY_DELAY_MAX`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function redeliveryDelay(unacknowledgedDeliveryCount: number): number;
|
|
64
|
+
export declare class ExecutionEventEncodingError extends Error {
|
|
65
|
+
constructor(message: string);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Encodes `params` with the durable value codec and `context` as its entries,
|
|
69
|
+
* so that decoding returns exactly what was admitted. Context keys must be
|
|
70
|
+
* strings. Throws `ExecutionEventEncodingError` for any value the codec
|
|
71
|
+
* rejects.
|
|
72
|
+
*/
|
|
73
|
+
export declare function encodeExecutionEvent(event: {
|
|
74
|
+
params: EventParams;
|
|
75
|
+
context: EventContext | undefined;
|
|
76
|
+
}): {
|
|
77
|
+
params: string;
|
|
78
|
+
context: string;
|
|
79
|
+
};
|
|
80
|
+
export declare function decodeExecutionEvent(encoded: {
|
|
81
|
+
params: string;
|
|
82
|
+
context: string;
|
|
83
|
+
}): {
|
|
84
|
+
params: EventParams;
|
|
85
|
+
context: EventContext;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Encodes a terminal outcome. A completed result the codec rejects is recorded
|
|
89
|
+
* as a failed outcome with `WorkflowValueError` (`INVALID_STEP_VALUE`), and a
|
|
90
|
+
* failure that is not an error is recorded as `Error(String(value))`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function encodeExecutionOutcome(outcome: ExecutionOutcome): string;
|
|
93
|
+
export declare function decodeExecutionOutcome(encoded: string): ExecutionOutcome;
|
|
94
|
+
export declare function createExecutionState(params: {
|
|
95
|
+
executionId: string;
|
|
96
|
+
workflowId: string;
|
|
97
|
+
encoded: {
|
|
98
|
+
params: string;
|
|
99
|
+
context: string;
|
|
100
|
+
};
|
|
101
|
+
now: number;
|
|
102
|
+
parent?: ExecutionParent;
|
|
103
|
+
}): ExecutionState;
|
|
104
|
+
/** The record's status at `now`: `running` while a lease is live. */
|
|
105
|
+
export declare function executionStatusAt(state: ExecutionState, now: number): ExecutionStatus;
|
|
106
|
+
/**
|
|
107
|
+
* Consecutive unacknowledged deliveries at `now`, counting a held lease that
|
|
108
|
+
* has expired as ended.
|
|
109
|
+
*/
|
|
110
|
+
export declare function unacknowledgedDeliveryCountAt(state: ExecutionState, now: number): number;
|
|
111
|
+
export declare function toExecutionRecord(state: ExecutionState, now: number): ExecutionRecord;
|
|
112
|
+
/**
|
|
113
|
+
* The earliest time `claimDue` may return this execution, or null when it has
|
|
114
|
+
* nothing pending. It depends only on the state, not on the clock, so
|
|
115
|
+
* adapters can persist and index it to find due executions.
|
|
116
|
+
*/
|
|
117
|
+
export declare function nextClaimAt(state: ExecutionState): number | null;
|
|
118
|
+
export declare function isExecutionClaimable(state: ExecutionState, now: number): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Whether `lease` is the execution's current lease: its token is the highest
|
|
121
|
+
* issued and the lease has not been released or acknowledged. Expiry alone
|
|
122
|
+
* does not end it. Adapters check this in the same atomic write as every
|
|
123
|
+
* fenced write.
|
|
124
|
+
*/
|
|
125
|
+
export declare function isLeaseCurrent(state: ExecutionState, lease: ExecutionLease): boolean;
|
|
126
|
+
/** Returns null when the execution is terminal and the wake is ignored. */
|
|
127
|
+
export declare function requestExecutionWake(state: ExecutionState, wakeAt: number, now: number): ExecutionState | null;
|
|
128
|
+
/**
|
|
129
|
+
* Leases a claimable execution with the next token. Adapters check
|
|
130
|
+
* `isExecutionClaimable` first, in the same atomic write.
|
|
131
|
+
*/
|
|
132
|
+
export declare function claimExecution(state: ExecutionState, params: {
|
|
133
|
+
now: number;
|
|
134
|
+
duration: number;
|
|
135
|
+
}): {
|
|
136
|
+
state: ExecutionState;
|
|
137
|
+
lease: ExecutionLease;
|
|
138
|
+
};
|
|
139
|
+
export declare function renewExecutionLease(state: ExecutionState, params: {
|
|
140
|
+
lease: ExecutionLease;
|
|
141
|
+
duration: number;
|
|
142
|
+
now: number;
|
|
143
|
+
}): {
|
|
144
|
+
state: ExecutionState;
|
|
145
|
+
result: ExecutionRenewResult;
|
|
146
|
+
};
|
|
147
|
+
export declare function releaseExecutionLease(state: ExecutionState, params: {
|
|
148
|
+
lease: ExecutionLease;
|
|
149
|
+
now: number;
|
|
150
|
+
}): {
|
|
151
|
+
state: ExecutionState;
|
|
152
|
+
result: ExecutionReleaseResult;
|
|
153
|
+
};
|
|
154
|
+
export declare function acknowledgeExecution(state: ExecutionState, params: {
|
|
155
|
+
lease: ExecutionLease;
|
|
156
|
+
outcome: WorkflowRunOutcome;
|
|
157
|
+
now: number;
|
|
158
|
+
}): {
|
|
159
|
+
state: ExecutionState;
|
|
160
|
+
result: ExecutionAcknowledgeResult;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Validates an admission request and encodes its event. Adapters call this
|
|
164
|
+
* before their atomic insert, then reject with `EXECUTION_ID_CONFLICT` if the
|
|
165
|
+
* ID is already in use.
|
|
166
|
+
*/
|
|
167
|
+
export declare function prepareExecutionAdmission(request: {
|
|
168
|
+
executionId?: string;
|
|
169
|
+
workflowId: string;
|
|
170
|
+
params: EventParams;
|
|
171
|
+
context: EventContext;
|
|
172
|
+
}): {
|
|
173
|
+
ok: true;
|
|
174
|
+
executionId: string;
|
|
175
|
+
encoded: {
|
|
176
|
+
params: string;
|
|
177
|
+
context: string;
|
|
178
|
+
};
|
|
179
|
+
} | {
|
|
180
|
+
ok: false;
|
|
181
|
+
code: "INVALID_EXECUTION_EVENT";
|
|
182
|
+
message: string;
|
|
183
|
+
};
|
|
184
|
+
export declare function executionIdConflict(executionId: string): {
|
|
185
|
+
status: "rejected";
|
|
186
|
+
code: "EXECUTION_ID_CONFLICT";
|
|
187
|
+
message: string;
|
|
188
|
+
};
|
|
189
|
+
export declare function executionNotFound(executionId: string): {
|
|
190
|
+
status: "rejected";
|
|
191
|
+
code: "EXECUTION_NOT_FOUND";
|
|
192
|
+
message: string;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* A recorded start request, keyed by `callerExecutionId` and `stepKey`.
|
|
196
|
+
* `executionId` is the target it admitted. Adapters keep it until the caller
|
|
197
|
+
* is pruned, including after the target is terminal.
|
|
198
|
+
*/
|
|
199
|
+
export type StartRequestState = {
|
|
200
|
+
callerExecutionId: string;
|
|
201
|
+
stepKey: string;
|
|
202
|
+
workflowId: string;
|
|
203
|
+
/** The canonical params, or null when the request had none. */
|
|
204
|
+
params: string | null;
|
|
205
|
+
executionId: string;
|
|
206
|
+
};
|
|
207
|
+
export type PreparedExecutionStart = {
|
|
208
|
+
callerExecutionId: string;
|
|
209
|
+
stepKey: string;
|
|
210
|
+
workflowId: string;
|
|
211
|
+
params: string | null;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Validates a start request and encodes its params canonically. Adapters call
|
|
215
|
+
* this before touching storage and return the rejection as is.
|
|
216
|
+
*/
|
|
217
|
+
export declare function prepareExecutionStart(request: ExecutionStartRequest): {
|
|
218
|
+
ok: true;
|
|
219
|
+
start: PreparedExecutionStart;
|
|
220
|
+
} | {
|
|
221
|
+
ok: false;
|
|
222
|
+
result: Extract<ExecutionStartResult, {
|
|
223
|
+
status: "rejected";
|
|
224
|
+
}>;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Answers a repeated start request from its record: the first target's ID when
|
|
228
|
+
* the workflow ID and canonical params match, and `START_REQUEST_MISMATCH`
|
|
229
|
+
* otherwise. The target's status does not matter.
|
|
230
|
+
*/
|
|
231
|
+
export declare function matchStartRequest(recorded: StartRequestState, start: PreparedExecutionStart): ExecutionStartResult;
|
|
232
|
+
/**
|
|
233
|
+
* Builds a new start's target state and start-request record. The target
|
|
234
|
+
* inherits the caller's encoded context and links to the caller as its parent.
|
|
235
|
+
* Adapters insert both in one atomic write, after finding no recorded request
|
|
236
|
+
* for the same ID. `executionId` defaults to a random UUID; if it is already in
|
|
237
|
+
* use, adapters must not reuse it.
|
|
238
|
+
*/
|
|
239
|
+
export declare function createStartedExecution(params: {
|
|
240
|
+
start: PreparedExecutionStart;
|
|
241
|
+
caller: ExecutionState;
|
|
242
|
+
now: number;
|
|
243
|
+
executionId?: string;
|
|
244
|
+
}): {
|
|
245
|
+
target: ExecutionState;
|
|
246
|
+
startRequest: StartRequestState;
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=execution-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-state.d.ts","sourceRoot":"","sources":["../../src/lib/execution-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EACV,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EAEf,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAY3B;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC5C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,sDAAsD;IACtD,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,8DAA8D;AAC9D,eAAO,MAAM,qBAAqB,OAAQ,C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GAE5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,sBAAsB,CAAA;CAAE,GAC3C;IACE,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,OAAO,CAAC,oBAAoB,EAAE;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;CAC/D,CAgCJ;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,sBAAsB,GAC5B,oBAAoB,CAYtB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,YAAY,EAAE,iBAAiB,CAAA;CAAE,CAuB9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-state.test.d.ts","sourceRoot":"","sources":["../../src/lib/execution-state.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EventEmitter } from "node:events";
|
|
2
|
+
import type { ExecutionClient, ExecutionOutcome } from "../base/execution";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves with an execution's outcome once its record is terminal, or with
|
|
5
|
+
* undefined if no record exists. The record is the source of truth, so this
|
|
6
|
+
* settles even if the process that ran the execution restarted. An optional
|
|
7
|
+
* `emitter` (the invoker's deprecated `workflowEndEmitter`) only nudges an
|
|
8
|
+
* early re-read.
|
|
9
|
+
*/
|
|
10
|
+
export declare function waitForExecutionOutcome(executions: Pick<ExecutionClient, "get">, executionId: string, options?: {
|
|
11
|
+
emitter?: EventEmitter;
|
|
12
|
+
pollInterval?: number;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}): Promise<ExecutionOutcome | undefined>;
|
|
15
|
+
//# sourceMappingURL=wait-for-outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-for-outcome.d.ts","sourceRoot":"","sources":["../../src/lib/wait-for-outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG3E;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,EACxC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,YAAY,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAChF,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAwBvC"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
|
-
import type { WorkflowGenerator,
|
|
2
|
+
import type { WorkflowGenerator, WorkflowEvent, WorkflowRunOutcome } from "..";
|
|
3
|
+
import type { Runtime } from "../base/runtime";
|
|
4
|
+
import type { DeliveryOptions } from "../base/invoker";
|
|
3
5
|
export declare class WorkflowRunner<Router extends Record<string, WorkflowGenerator<any, any, any>>> {
|
|
4
|
-
private
|
|
5
|
-
private schedulerClient;
|
|
6
|
+
private runtime;
|
|
6
7
|
private router;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
schedulerClient: SchedulerClient;
|
|
8
|
+
private logger;
|
|
9
|
+
constructor(runtime: Runtime, options: {
|
|
10
10
|
router: Router;
|
|
11
11
|
logger: Logger;
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Runs one delivery under `options.lease` and resolves with its outcome.
|
|
15
|
+
* Rejects only with an infrastructure error, which must not be acknowledged
|
|
16
|
+
* as an outcome; a lost lease is one, and so is an aborted `options.signal`.
|
|
17
|
+
*/
|
|
18
|
+
run: (event: WorkflowEvent, options: DeliveryOptions & {
|
|
19
|
+
logger?: Logger;
|
|
20
|
+
}) => Promise<WorkflowRunOutcome>;
|
|
14
21
|
private runWorkflows;
|
|
15
22
|
}
|
|
16
23
|
//# sourceMappingURL=workflow-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/lib/workflow-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/lib/workflow-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EAGb,kBAAkB,EACnB,MAAM,IAAI,CAAC;AAQZ,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,qBAAa,cAAc,CACzB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAMzE;;;;OAIG;IACH,GAAG,GACD,OAAO,aAAa,EACpB,SAAS,eAAe,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAC7C,OAAO,CAAC,kBAAkB,CAAC,CAsC5B;YAEY,YAAY;CAmD3B"}
|
package/dist/utils/map.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class ReadOnlyMap<K, V> implements ReadonlyMap<K, V> {
|
|
2
2
|
private sourceMap;
|
|
3
|
-
constructor(sourceMap: Map<K, V>);
|
|
3
|
+
constructor(sourceMap: Map<K, V> | Record<any, any> | undefined);
|
|
4
4
|
get(key: K): V | undefined;
|
|
5
5
|
has(key: K): boolean;
|
|
6
6
|
get size(): number;
|
package/dist/utils/map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/utils/map.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,SAAS,CAAY;gBAEjB,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/utils/map.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,SAAS,CAAY;gBAEjB,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;IAU/D,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAI1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9B,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAItB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAIxB,OAAO,CACL,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EACtD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAIP,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAGzC;AAED,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,CAAS;IAEvB,MAAM,IAAI,IAAI;IAId,QAAQ,IAAI,OAAO;IAInB,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAQ3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAQvB,KAAK,IAAI,IAAI;CAOd"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yieldstar/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Daniel Grant",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/notationlabs/yieldstar.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
4
11
|
"type": "module",
|
|
5
12
|
"main": "dist/index.js",
|
|
6
13
|
"types": "dist/index.d.ts",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@standard-schema/spec": "^1.1.0"
|
|
16
|
+
},
|
|
7
17
|
"devDependencies": {
|
|
8
|
-
"@types/
|
|
18
|
+
"@types/node": "^22.18.0",
|
|
9
19
|
"pino": "^9.9.0"
|
|
10
20
|
},
|
|
11
21
|
"scripts": {
|
|
12
|
-
"build": "bun build src/index.ts --outfile dist/index.js --target
|
|
22
|
+
"build": "bun build src/index.ts --outfile dist/index.js --target node --packages=external"
|
|
13
23
|
}
|
|
14
24
|
}
|