@ewhauser/world-celld 0.3.0 → 0.3.2
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/CHANGELOG.md +23 -0
- package/README.md +49 -19
- package/celld-worker/README.md +5 -3
- package/celld-worker/worker.ts +9 -1
- package/celld-worker/wrangler.jsonc +13 -4
- package/dist/index.d.ts +168 -58
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +432 -124
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +47 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1988 -558
- package/dist/testing.js.map +1 -1
- package/dist/util-ya3V_FTA.js +558 -0
- package/dist/util-ya3V_FTA.js.map +1 -0
- package/dist/worker.d.ts +238 -108
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +2082 -520
- package/dist/worker.js.map +1 -1
- package/package.json +4 -2
- package/dist/retention-bLY1vcOu.js +0 -164
- package/dist/retention-bLY1vcOu.js.map +0 -1
package/dist/worker.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ interface DONamespaceLike {
|
|
|
12
12
|
interface WorkerEnv {
|
|
13
13
|
WORKFLOW_DB: DONamespaceLike;
|
|
14
14
|
WORKFLOW_STREAMS: DONamespaceLike;
|
|
15
|
-
|
|
15
|
+
WORKFLOW_RUN_CATALOG: DONamespaceLike;
|
|
16
|
+
WORKFLOW_HOOK_TOKENS: DONamespaceLike;
|
|
17
|
+
WORKFLOW_HOOK_IDS: DONamespaceLike;
|
|
16
18
|
WORKFLOW_QUEUE: DONamespaceLike;
|
|
17
19
|
WORLD_SECRET?: string;
|
|
18
20
|
}
|
|
@@ -30,6 +32,8 @@ interface CleanupRecord {
|
|
|
30
32
|
dueAt: Date;
|
|
31
33
|
queueShards: number;
|
|
32
34
|
phase: CleanupPhase;
|
|
35
|
+
/** Optimistic-concurrency token for alarm/RPC work that awaits another cell. */
|
|
36
|
+
generation: number;
|
|
33
37
|
attempts: number;
|
|
34
38
|
lastError?: string;
|
|
35
39
|
lastAttemptAt?: Date;
|
|
@@ -45,7 +49,10 @@ interface RunTombstone {
|
|
|
45
49
|
completedAt: Date;
|
|
46
50
|
expiredAt: Date;
|
|
47
51
|
tombstonedAt: Date;
|
|
52
|
+
/** Final cleanup accounting retained inside the single authoritative record. */
|
|
53
|
+
cleanup: CleanupRecord;
|
|
48
54
|
}
|
|
55
|
+
type RunLifecycleStatus = 'active' | 'terminal' | 'expired' | 'missing';
|
|
49
56
|
type RunReadOutcome<T> = {
|
|
50
57
|
ok: true;
|
|
51
58
|
value: T;
|
|
@@ -55,29 +62,43 @@ type RunReadOutcome<T> = {
|
|
|
55
62
|
message: string;
|
|
56
63
|
tombstone: RunTombstone;
|
|
57
64
|
};
|
|
58
|
-
interface HookIndexReference {
|
|
59
|
-
hookId: string;
|
|
60
|
-
token: string;
|
|
61
|
-
}
|
|
62
|
-
interface ExpireRunIndexesRequest {
|
|
63
|
-
runId: string;
|
|
64
|
-
keys: string[];
|
|
65
|
-
hooks: HookIndexReference[];
|
|
66
|
-
expiredAt: number;
|
|
67
|
-
}
|
|
68
65
|
interface ExpireRunIndexesResult {
|
|
69
66
|
deleted: number;
|
|
70
67
|
}
|
|
71
68
|
interface ExpireRunStreamsResult {
|
|
72
69
|
streams: string[];
|
|
73
70
|
}
|
|
71
|
+
interface FinalizeRunStreamsResult {
|
|
72
|
+
/** Cumulative registry entries removed for this run. */
|
|
73
|
+
deleted: number;
|
|
74
|
+
done: boolean;
|
|
75
|
+
}
|
|
74
76
|
interface ExpireStreamResult {
|
|
77
|
+
/** True only when this call installed the stream's expiration fence. */
|
|
75
78
|
deleted: boolean;
|
|
79
|
+
/** Chunk rows removed by this bounded call. */
|
|
76
80
|
chunks: number;
|
|
81
|
+
/** Payload bytes represented by the removed chunk rows. */
|
|
82
|
+
bytes: number;
|
|
83
|
+
done: boolean;
|
|
77
84
|
}
|
|
78
|
-
interface
|
|
85
|
+
interface QueueExpiryReceipt {
|
|
86
|
+
expiredAt: number;
|
|
79
87
|
deleted: number;
|
|
80
88
|
}
|
|
89
|
+
type ExpireQueueRunResult = {
|
|
90
|
+
/** Cumulative messages removed for this run in this queue shard. */
|
|
91
|
+
deleted: number;
|
|
92
|
+
} & ({
|
|
93
|
+
done: false;
|
|
94
|
+
} | {
|
|
95
|
+
done: true;
|
|
96
|
+
/** Durable receipt which the cleanup coordinator must acknowledge. */
|
|
97
|
+
receipt: QueueExpiryReceipt;
|
|
98
|
+
});
|
|
99
|
+
interface AcknowledgeQueueExpiryResult {
|
|
100
|
+
acknowledged: boolean;
|
|
101
|
+
}
|
|
81
102
|
interface ScheduleCleanupRequest {
|
|
82
103
|
retentionMs: number;
|
|
83
104
|
queueShards: number;
|
|
@@ -91,17 +112,19 @@ interface ApplyEventRequest {
|
|
|
91
112
|
/** Workflow 5 event-log position and preload options. */
|
|
92
113
|
params?: CreateEventParams;
|
|
93
114
|
/**
|
|
94
|
-
* Current holder of the hook token per the
|
|
115
|
+
* Current holder of the hook token per the sharded token-ownership index
|
|
95
116
|
* (hook_created only). `null` means the token is unclaimed.
|
|
96
117
|
*/
|
|
97
118
|
tokenHolder?: {
|
|
98
119
|
runId: string;
|
|
99
120
|
hookId: string;
|
|
100
121
|
} | null;
|
|
122
|
+
/** Exact token/ID reservation fenced on ambiguous-delivery resolution. */
|
|
123
|
+
hookClaimId?: string;
|
|
101
124
|
/** Internal world-celld retention policy captured with the event. */
|
|
102
125
|
cleanup?: ScheduleCleanupRequest;
|
|
103
126
|
}
|
|
104
|
-
type ApplyEventErrorCode = 'RUN_NOT_FOUND' | 'STEP_NOT_FOUND' | 'HOOK_NOT_FOUND' | 'WAIT_NOT_FOUND' | 'ENTITY_CONFLICT' | 'RUN_EXPIRED' | 'TOO_EARLY' | 'RUN_NOT_SUPPORTED';
|
|
127
|
+
type ApplyEventErrorCode = 'RUN_NOT_FOUND' | 'STEP_NOT_FOUND' | 'HOOK_NOT_FOUND' | 'WAIT_NOT_FOUND' | 'ENTITY_CONFLICT' | 'HOOK_CLAIM_CANCELLED' | 'RUN_EXPIRED' | 'TOO_EARLY' | 'RUN_NOT_SUPPORTED';
|
|
105
128
|
interface ApplyEventFailure {
|
|
106
129
|
ok: false;
|
|
107
130
|
code: ApplyEventErrorCode;
|
|
@@ -121,7 +144,7 @@ interface ApplyEventSuccess {
|
|
|
121
144
|
wait?: Wait;
|
|
122
145
|
/** True when a lazy step_started atomically created its step. */
|
|
123
146
|
stepCreated?: true;
|
|
124
|
-
/** Hooks whose
|
|
147
|
+
/** Hooks whose token and ID indexes must be released. */
|
|
125
148
|
releasedHooks: Array<{
|
|
126
149
|
hookId: string;
|
|
127
150
|
token: string;
|
|
@@ -131,7 +154,7 @@ interface ApplyEventSuccess {
|
|
|
131
154
|
workflowName: string;
|
|
132
155
|
createdAt: Date;
|
|
133
156
|
};
|
|
134
|
-
/** Set when the
|
|
157
|
+
/** Set when the sharded hook indexes must be (re)written. */
|
|
135
158
|
hookToIndex?: Hook;
|
|
136
159
|
/** All events (ascending), preloaded for run_started responses. */
|
|
137
160
|
events?: Event[];
|
|
@@ -140,9 +163,38 @@ interface ApplyEventSuccess {
|
|
|
140
163
|
hasMore?: boolean;
|
|
141
164
|
/** Server-owned event ceiling advertised on run lifecycle writes. */
|
|
142
165
|
maxEvents?: number;
|
|
166
|
+
/** Deadline for publishing this authoritative mutation to derivative indexes. */
|
|
167
|
+
indexPublicationExpiresAt?: number;
|
|
143
168
|
}
|
|
144
169
|
type ApplyEventOutcome = ApplyEventSuccess | ApplyEventFailure;
|
|
145
170
|
//#endregion
|
|
171
|
+
//#region src/stream-protocol.d.ts
|
|
172
|
+
type StreamTerminalState = 'open' | 'closed' | 'errored' | 'expired';
|
|
173
|
+
interface StreamErrorData {
|
|
174
|
+
name: string;
|
|
175
|
+
message: string;
|
|
176
|
+
}
|
|
177
|
+
interface StreamWriteResult {
|
|
178
|
+
startIndex: number;
|
|
179
|
+
count: number;
|
|
180
|
+
tailIndex: number;
|
|
181
|
+
}
|
|
182
|
+
interface StreamReadRequest {
|
|
183
|
+
runId: string;
|
|
184
|
+
startIndex: number;
|
|
185
|
+
maxChunks: number;
|
|
186
|
+
maxBytes: number;
|
|
187
|
+
waitMs: number;
|
|
188
|
+
}
|
|
189
|
+
interface StreamReadResult {
|
|
190
|
+
startIndex: number;
|
|
191
|
+
tailIndex: number;
|
|
192
|
+
chunks: Uint8Array[];
|
|
193
|
+
state: StreamTerminalState;
|
|
194
|
+
timedOut: boolean;
|
|
195
|
+
error?: StreamErrorData;
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
146
198
|
//#region src/queue.d.ts
|
|
147
199
|
type Pathname = 'flow';
|
|
148
200
|
/**
|
|
@@ -181,6 +233,29 @@ type EnqueueOutcome = {
|
|
|
181
233
|
message: string;
|
|
182
234
|
};
|
|
183
235
|
//#endregion
|
|
236
|
+
//#region src/indexes.d.ts
|
|
237
|
+
interface IndexListOptions {
|
|
238
|
+
prefix?: string;
|
|
239
|
+
cursor?: string;
|
|
240
|
+
limit?: number;
|
|
241
|
+
reverse?: boolean;
|
|
242
|
+
}
|
|
243
|
+
interface IndexListPage {
|
|
244
|
+
keys: Array<{
|
|
245
|
+
name: string;
|
|
246
|
+
value: string;
|
|
247
|
+
}>;
|
|
248
|
+
list_complete: boolean;
|
|
249
|
+
cursor?: string;
|
|
250
|
+
}
|
|
251
|
+
interface CellIdLike {
|
|
252
|
+
toString(): string;
|
|
253
|
+
}
|
|
254
|
+
interface CellNamespaceLike<T> {
|
|
255
|
+
idFromName(name: string): CellIdLike;
|
|
256
|
+
get(id: CellIdLike): T;
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
184
259
|
//#region src/config.d.ts
|
|
185
260
|
interface HookTokenOwner {
|
|
186
261
|
runId: string;
|
|
@@ -203,53 +278,68 @@ declare class DurableObject<TEnv = unknown> {
|
|
|
203
278
|
constructor(ctx: DurableObjectState, env: TEnv);
|
|
204
279
|
}
|
|
205
280
|
//#endregion
|
|
206
|
-
//#region src/worker/durable-objects/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
281
|
+
//#region src/worker/durable-objects/hook-index-shared.d.ts
|
|
282
|
+
interface RunLifecycleStub {
|
|
283
|
+
getLifecycleStatus(): Promise<RunLifecycleStatus>;
|
|
284
|
+
}
|
|
285
|
+
interface HookIndexEnv {
|
|
286
|
+
WORKFLOW_DB?: CellNamespaceLike<RunLifecycleStub>;
|
|
287
|
+
/** Test seam; celld deployments use Date.now(). */
|
|
288
|
+
clock?: () => number;
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/worker/durable-objects/HookIdDO.d.ts
|
|
292
|
+
/** Hook-ID ownership and lookup shard; every hook ID has one transaction domain. */
|
|
293
|
+
declare class HookIdDO extends DurableObject<HookIndexEnv> {
|
|
294
|
+
private now;
|
|
295
|
+
get(hookId: string): Promise<string | null>;
|
|
296
|
+
reserve(hookId: string, owner: HookTokenOwner, proposedClaimId: string): Promise<{
|
|
297
|
+
claimed: true;
|
|
298
|
+
claimId: string;
|
|
299
|
+
} | {
|
|
300
|
+
claimed: false;
|
|
301
|
+
holder: HookTokenOwner;
|
|
302
|
+
}>;
|
|
303
|
+
publish(hookId: string, serializedHook: string, owner: HookTokenOwner, claimId?: string): Promise<{
|
|
225
304
|
stored: boolean;
|
|
226
305
|
}>;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}): Promise<{
|
|
234
|
-
keys: Array<{
|
|
235
|
-
name: string;
|
|
236
|
-
}>;
|
|
237
|
-
list_complete: boolean;
|
|
238
|
-
cursor?: string;
|
|
306
|
+
releaseClaim(hookId: string, owner: HookTokenOwner, claimId: string): Promise<void>;
|
|
307
|
+
releaseBatch(hooks: Array<{
|
|
308
|
+
hookId: string;
|
|
309
|
+
owner: HookTokenOwner;
|
|
310
|
+
}>): Promise<{
|
|
311
|
+
deleted: number;
|
|
239
312
|
}>;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
313
|
+
alarm(): Promise<void>;
|
|
314
|
+
private armAtMost;
|
|
315
|
+
private compactClaims;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/worker/durable-objects/HookTokenDO.d.ts
|
|
319
|
+
/** Token-ownership shard. A token hashes to exactly one shard and transaction domain. */
|
|
320
|
+
declare class HookTokenDO extends DurableObject<HookIndexEnv> {
|
|
321
|
+
private now;
|
|
322
|
+
get(token: string): Promise<string | null>;
|
|
323
|
+
reserve(token: string, owner: HookTokenOwner, proposedClaimId: string): Promise<{
|
|
324
|
+
claimed: true;
|
|
325
|
+
claimId: string;
|
|
326
|
+
} | {
|
|
327
|
+
claimed: false;
|
|
328
|
+
holder: HookTokenOwner;
|
|
243
329
|
}>;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
330
|
+
finalize(token: string, serializedHook: string, owner: HookTokenOwner, claimId?: string): Promise<{
|
|
331
|
+
stored: boolean;
|
|
332
|
+
}>;
|
|
333
|
+
releaseClaim(token: string, owner: HookTokenOwner, claimId: string): Promise<void>;
|
|
334
|
+
releaseBatch(hooks: Array<{
|
|
335
|
+
token: string;
|
|
336
|
+
owner: HookTokenOwner;
|
|
337
|
+
}>): Promise<{
|
|
338
|
+
deleted: number;
|
|
339
|
+
}>;
|
|
340
|
+
alarm(): Promise<void>;
|
|
341
|
+
private armAtMost;
|
|
342
|
+
private compactClaims;
|
|
253
343
|
}
|
|
254
344
|
//#endregion
|
|
255
345
|
//#region src/worker/durable-objects/QueueDO.d.ts
|
|
@@ -265,11 +355,15 @@ declare class IndexDO extends DurableObject {
|
|
|
265
355
|
* cfg pinned QueueCellConfig (first-enqueue wins)
|
|
266
356
|
* msg:<messageId> MessageRow
|
|
267
357
|
* due:<paddedMs>:<messageId> schedule index -> messageId
|
|
268
|
-
* inflight:<messageId>
|
|
358
|
+
* inflight-deadline:<paddedMs>:<messageId>
|
|
359
|
+
* ordered crash-recovery index -> messageId
|
|
269
360
|
* key:<idempotencyKey> active dedup claim -> messageId
|
|
270
361
|
* dlq:<paddedMs>:<messageId> DeadLetterRow
|
|
271
362
|
* run:<runId>:<messageId> QueueRunReference for retention cleanup
|
|
272
|
-
* expired-run:<runId>
|
|
363
|
+
* expired-run:<runId> cumulative cleanup receipt; compactable only
|
|
364
|
+
* after RunDO acknowledgement
|
|
365
|
+
* expired-run-gc:<paddedMs>:<runId>
|
|
366
|
+
* ordered compaction deadline -> runId
|
|
273
367
|
*
|
|
274
368
|
* celld gotchas designed around:
|
|
275
369
|
* - celld#144 (alarm handlers can overlap): the storage-only claim phase runs
|
|
@@ -329,6 +423,7 @@ declare class QueueDO extends DurableObject {
|
|
|
329
423
|
}>;
|
|
330
424
|
purgeDeadLetters(): Promise<{
|
|
331
425
|
purged: number;
|
|
426
|
+
hasMore: boolean;
|
|
332
427
|
}>;
|
|
333
428
|
/**
|
|
334
429
|
* Recovery hatch for celld's six-failure alarm abandonment: derive the due
|
|
@@ -338,67 +433,76 @@ declare class QueueDO extends DurableObject {
|
|
|
338
433
|
alarmAt: number | null;
|
|
339
434
|
}>;
|
|
340
435
|
/** Fence a run and purge every live, inflight, and dead-letter message it owns. */
|
|
341
|
-
expireRun(runId: string, expiredAt: number
|
|
436
|
+
expireRun(runId: string, expiredAt: number, options?: {
|
|
437
|
+
limit?: number;
|
|
438
|
+
}): Promise<ExpireQueueRunResult>;
|
|
439
|
+
/** Acknowledge a final cleanup receipt before making its marker compactable. */
|
|
440
|
+
acknowledgeExpireRun(runId: string, receipt: QueueExpiryReceipt): Promise<AcknowledgeQueueExpiryResult>;
|
|
441
|
+
}
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/worker/durable-objects/RunCatalogDO.d.ts
|
|
444
|
+
/** One of a fixed set of run-catalog shards, routed by the stable run ID hash. */
|
|
445
|
+
declare class RunCatalogDO extends DurableObject {
|
|
446
|
+
private now;
|
|
447
|
+
upsertRun(runId: string, keys: string[], serializedMetadata: string, publicationExpiresAt: number): Promise<{
|
|
448
|
+
stored: boolean;
|
|
449
|
+
}>;
|
|
450
|
+
list(options?: IndexListOptions): Promise<IndexListPage>;
|
|
451
|
+
expireRun(runId: string, keys: string[], expiredAt: number): Promise<ExpireRunIndexesResult>;
|
|
452
|
+
alarm(): Promise<void>;
|
|
453
|
+
private armAtMost;
|
|
454
|
+
private compactExpiryFences;
|
|
342
455
|
}
|
|
343
456
|
//#endregion
|
|
344
457
|
//#region src/worker/durable-objects/StreamDO.d.ts
|
|
345
458
|
/**
|
|
346
459
|
* Durable Object backing workflow streams.
|
|
347
460
|
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* each chunk its index; one chunk per storage key.
|
|
352
|
-
* - `run-streams:<runId>`: registry of stream names owned by a run,
|
|
353
|
-
* powering `listStreamsByRunId`.
|
|
461
|
+
* Stream cells persist binary chunks under monotonic offset keys. Public
|
|
462
|
+
* reads are bounded long polls, and writes append a bounded ordered batch in
|
|
463
|
+
* one storage transaction. Per-run registry cells retain their existing role.
|
|
354
464
|
*/
|
|
355
465
|
declare class StreamDO extends DurableObject {
|
|
466
|
+
private meta;
|
|
467
|
+
private metaLoad;
|
|
468
|
+
private mutationTail;
|
|
469
|
+
private changeVersion;
|
|
470
|
+
private readonly waiters;
|
|
356
471
|
private getMeta;
|
|
357
472
|
private assertOwner;
|
|
473
|
+
private assertWritable;
|
|
474
|
+
private runMutation;
|
|
475
|
+
private wakeReaders;
|
|
476
|
+
private waitForChange;
|
|
477
|
+
private readSnapshot;
|
|
478
|
+
/** Append one bounded binary batch with contiguous indexes. */
|
|
479
|
+
writeChunks(runId: string, chunks: Uint8Array[]): Promise<StreamWriteResult>;
|
|
358
480
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*/
|
|
362
|
-
writeChunk(runId: string, data: Uint8Array): Promise<number>;
|
|
363
|
-
/**
|
|
364
|
-
* Close the stream (idempotent). Readers observe `done: true` once all
|
|
365
|
-
* previously written chunks have been consumed.
|
|
481
|
+
* Return available binary chunks and terminal metadata in one bounded
|
|
482
|
+
* operation, waiting at most waitMs when the requested offset is idle.
|
|
366
483
|
*/
|
|
484
|
+
readChunks(request: StreamReadRequest, signal?: AbortSignal): Promise<StreamReadResult>;
|
|
485
|
+
/** Close idempotently; the first terminal state wins. */
|
|
367
486
|
closeStream(runId: string): Promise<void>;
|
|
368
|
-
/**
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
getChunks(params: {
|
|
372
|
-
startIndex: number;
|
|
373
|
-
limit: number;
|
|
374
|
-
}): Promise<{
|
|
375
|
-
chunks: Uint8Array[];
|
|
376
|
-
/** Whether the stream is closed. */
|
|
377
|
-
done: boolean;
|
|
378
|
-
/** Index of the last written chunk, -1 when empty. */
|
|
379
|
-
tailIndex: number;
|
|
380
|
-
}>;
|
|
381
|
-
/**
|
|
382
|
-
* Lightweight stream metadata: last chunk index and completion flag.
|
|
383
|
-
*/
|
|
384
|
-
getInfo(): Promise<{
|
|
385
|
-
tailIndex: number;
|
|
386
|
-
done: boolean;
|
|
387
|
-
}>;
|
|
388
|
-
/**
|
|
389
|
-
* Register a stream name against this per-run registry instance.
|
|
390
|
-
*/
|
|
487
|
+
/** Persist a terminal stream failure and wake every pending reader. */
|
|
488
|
+
failStream(runId: string, error: StreamErrorData | string): Promise<void>;
|
|
489
|
+
/** Register a stream name against this per-run registry instance. */
|
|
391
490
|
registerStream(runId: string, name: string): Promise<void>;
|
|
392
|
-
/**
|
|
393
|
-
* List stream names registered against this per-run registry instance.
|
|
394
|
-
*/
|
|
395
491
|
listStreams(): Promise<string[]>;
|
|
396
492
|
/** Fence a run's registry before any stream cells are removed. */
|
|
397
|
-
expireRegistry(runId: string, expiredAt: number
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
|
|
493
|
+
expireRegistry(runId: string, expiredAt: number, options?: {
|
|
494
|
+
limit?: number;
|
|
495
|
+
}): Promise<ExpireRunStreamsResult>;
|
|
496
|
+
/** Remove completed registry entries in a bounded, retry-safe batch. */
|
|
497
|
+
finalizeRegistry(runId: string, streams: string[]): Promise<FinalizeRunStreamsResult>;
|
|
498
|
+
/**
|
|
499
|
+
* Fence the stream and delete one bounded page. Listing size keys avoids
|
|
500
|
+
* loading payloads, and the transaction makes a crash retry resume safely.
|
|
501
|
+
*/
|
|
502
|
+
expireStream(runId: string, expiredAt: number, options?: {
|
|
503
|
+
limit?: number;
|
|
504
|
+
byteLimit?: number;
|
|
505
|
+
}): Promise<ExpireStreamResult>;
|
|
402
506
|
}
|
|
403
507
|
//#endregion
|
|
404
508
|
//#region src/worker/durable-objects/WorkflowRunDO.d.ts
|
|
@@ -414,11 +518,27 @@ declare class StreamDO extends DurableObject {
|
|
|
414
518
|
*/
|
|
415
519
|
declare class WorkflowRunDO extends DurableObject {
|
|
416
520
|
private now;
|
|
417
|
-
private
|
|
521
|
+
private tombstoneFrom;
|
|
522
|
+
private retentionState;
|
|
418
523
|
private read;
|
|
524
|
+
private readKey;
|
|
419
525
|
/** Apply an event and capture all retention metadata in the same transaction. */
|
|
420
526
|
applyEvent(request: ApplyEventRequest): Promise<ApplyEventOutcome>;
|
|
527
|
+
/**
|
|
528
|
+
* Resolve an ambiguous hook-creation RPC in the same serialization domain as
|
|
529
|
+
* applyEvent. If the hook is absent, the exact reservation is durably fenced
|
|
530
|
+
* before the caller releases its token and hook-ID claims.
|
|
531
|
+
*/
|
|
532
|
+
resolveHookTokenClaim(request: {
|
|
533
|
+
hookId: string;
|
|
534
|
+
token: string;
|
|
535
|
+
claimId: string;
|
|
536
|
+
}): Promise<{
|
|
537
|
+
committed: boolean;
|
|
538
|
+
}>;
|
|
421
539
|
getRun(): Promise<RunReadOutcome<WorkflowRun | null>>;
|
|
540
|
+
/** Single authoritative lifecycle answer used after derivative compaction. */
|
|
541
|
+
getLifecycleStatus(): Promise<RunLifecycleStatus>;
|
|
422
542
|
getStep(stepId: string): Promise<RunReadOutcome<Step | null>>;
|
|
423
543
|
listSteps(params?: {
|
|
424
544
|
limit?: number;
|
|
@@ -455,10 +575,20 @@ declare class WorkflowRunDO extends DurableObject {
|
|
|
455
575
|
rearmCleanup(): Promise<CleanupRecord | null>;
|
|
456
576
|
alarm(): Promise<void>;
|
|
457
577
|
private namespace;
|
|
578
|
+
private workflowIndex;
|
|
458
579
|
private setCleanupPhase;
|
|
580
|
+
private executeScheduledCleanupPage;
|
|
459
581
|
private executeCleanup;
|
|
582
|
+
private executeTerminalCleanup;
|
|
583
|
+
private deleteTerminalHookPage;
|
|
584
|
+
private deleteTerminalHookMarkerPage;
|
|
585
|
+
private deleteTerminalWaitPage;
|
|
586
|
+
private deleteIndexPage;
|
|
587
|
+
private deleteStreamPage;
|
|
588
|
+
private deleteQueuePage;
|
|
460
589
|
private deletePayloadBatch;
|
|
461
590
|
private recordCleanupFailure;
|
|
591
|
+
private recordTerminalCleanupFailure;
|
|
462
592
|
claimInflight(params: {
|
|
463
593
|
messageId: string;
|
|
464
594
|
staleMs: number;
|
|
@@ -473,5 +603,5 @@ declare const _default: {
|
|
|
473
603
|
fetch(request: Request, env: WorkerEnv): Promise<Response>;
|
|
474
604
|
};
|
|
475
605
|
//#endregion
|
|
476
|
-
export {
|
|
606
|
+
export { HookIdDO, HookTokenDO, QueueDO, RunCatalogDO, StreamDO, type WorkerEnv, WorkflowRunDO, createRouter, _default as default };
|
|
477
607
|
//# sourceMappingURL=worker.d.ts.map
|
package/dist/worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","names":[],"sources":["../src/worker/router.ts","../src/retention.ts","../src/apply-event.ts","../src/queue.ts","../src/config.ts","../src/worker/do-base.ts","../src/worker/durable-objects/
|
|
1
|
+
{"version":3,"file":"worker.d.ts","names":[],"sources":["../src/worker/router.ts","../src/retention.ts","../src/apply-event.ts","../src/stream-protocol.ts","../src/queue.ts","../src/indexes.ts","../src/config.ts","../src/worker/do-base.ts","../src/worker/durable-objects/hook-index-shared.ts","../src/worker/durable-objects/HookIdDO.ts","../src/worker/durable-objects/HookTokenDO.ts","../src/worker/durable-objects/QueueDO.ts","../src/worker/durable-objects/RunCatalogDO.ts","../src/worker/durable-objects/StreamDO.ts","../src/worker/durable-objects/WorkflowRunDO.ts","../src/worker/worker.ts"],"mappings":";;;UA8CiB;EACf,WAAW;IAAiB;;EAC5B,IAAI;IAAM;;;UAGK;EACf,aAAa;EACb,kBAAkB;EAClB,sBAAsB;EACtB,sBAAsB;EACtB,mBAAmB;EACnB,gBAAgB;EAChB;;iBA8Ic,aAAa,KAAK,aAAS,SAClB,YAAU,QAAQ;;;KClM/B;UAEK;EACf;EACA;EACA;EACA,WAAW;EACX,aAAa;EACb,gBAAgB;EAChB,OAAO;EACP;EACA,OAAO;;EAEP;EACA;EACA;EACA,gBAAgB;EAChB,eAAe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA,gBAAgB;EAChB,aAAa;EACb,WAAW;EACX,cAAc;;EAEd,SAAS;;KAGC;KAEA,eAAe;EACrB;EAAU,OAAO;;EACjB;EAAW;EAAqB;EAAiB,WAAW;;UAiCjD;EACf;;UAGe;EACf;;UAGe;;EAEf;EACA;;UAGe;;EAEf;;EAEA;;EAEA;EACA;;UAGe;EACf;EACA;;KAGU;;EAEV;;EAEI;;EAEA;;EAEA,SAAS;;UAIE;EACf;;UAGe;EACf;EACA;;;;UCyBe;;EAEf;EACA,MAAM,qBAAqB;;EAE3B,SAAS;;;;;EAKT;IAAgB;IAAe;;;EAE/B;;EAEA,UAAU;;KAGA;UAWK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