@dudousxd/nestjs-durable-core 0.72.1 → 0.74.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/index.d.ts CHANGED
@@ -919,6 +919,17 @@ interface StateStore {
919
919
  * module's `autoSchema` is on. Optional: stores that need no setup (in-memory) omit it.
920
920
  */
921
921
  ensureSchema?(): Promise<void>;
922
+ /**
923
+ * Atomically read active runs sharing workflow/tag in this store's read scope, preserve durable
924
+ * admitted holders, and claim a free slot for an eligible FIFO waiter. The claim persists the
925
+ * reserved SINGLETON_ADMITTED_TAG in tags. Execution lease expiry never releases a slot; terminal
926
+ * status does. Optional for general stores, required when using singleton workflows. Implement
927
+ * with a database transaction that serializes competing claims BEFORE reading; list/update alone
928
+ * is unsafe across engine instances. If retryWakeAt is supplied, denial must atomically suspend
929
+ * the still-active candidate with that wakeAt while the same locks are held. Never overwrite a
930
+ * cancelling or terminal run on denial. Return false for missing/terminal/out-of-scope runs.
931
+ */
932
+ tryAdmitSingleton?(runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number): Promise<boolean>;
922
933
  createRun(run: WorkflowRun): Promise<void>;
923
934
  updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
924
935
  getRun(runId: string): Promise<WorkflowRun | null>;
@@ -984,6 +995,45 @@ interface StateStore {
984
995
  takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
985
996
  /** List waiters whose `token` starts with `prefix` — used to fan out an event to its subscribers. */
986
997
  listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
998
+ /**
999
+ * Whether run `runId` still has at least one waiter whose `token` starts with `tokenPrefix` (an
1000
+ * exact prefix: `%`/`_` in the prefix are literal characters, not wildcards). The `ctx.all` join
1001
+ * barrier asks this after each child settles, so it must stay O(1)-ish however many siblings are
1002
+ * still waiting — answer it with a bounded lookup, never by listing the whole group.
1003
+ *
1004
+ * Optional: a store without it keeps `ctx.all` correct, but the parent replays once per settled
1005
+ * child instead of once per fan.
1006
+ */
1007
+ hasSignalWaiter?(runId: string, tokenPrefix: string): Promise<boolean>;
1008
+ /**
1009
+ * The waiters of the given runs. Lets the engine and the dashboard read what a page of runs (or
1010
+ * one run's children) is waiting on without scanning every waiter in the store, which a wide fan
1011
+ * fills with one row per running child. Callers pass ids in bounded batches.
1012
+ *
1013
+ * Optional: without it those reads fall back to {@link listSignalWaiters} over every waiter.
1014
+ */
1015
+ listSignalWaitersByRun?(runIds: string[]): Promise<SignalWaiter[]>;
1016
+ /**
1017
+ * Register a batch of awaited children: for each entry, put `waiter` and upsert `checkpoint` (the
1018
+ * parent's `running` placeholder for that child). `ctx.all` calls it once per chunk of a fan, so a
1019
+ * wide fan costs a handful of round trips instead of two per child.
1020
+ *
1021
+ * Every entry's waiter must be durable no later than its checkpoint: the engine reads an existing
1022
+ * placeholder as proof the waiter was put, and never re-puts it. Writing both in one transaction
1023
+ * satisfies that.
1024
+ *
1025
+ * Optional: without it the engine puts each waiter, then saves each checkpoint.
1026
+ */
1027
+ registerChildWaits?(entries: ChildWait[]): Promise<void>;
1028
+ /**
1029
+ * Atomically replace run `runId`'s checkpoints with `seq` in `[fromSeq, toSeq]` by the single
1030
+ * checkpoint `into`, whose `seq` lies in that range. `ctx.all` folds a settled group of children
1031
+ * into one checkpoint this way, so every later turn of the parent loads one row instead of one per
1032
+ * child. A delete over a contiguous seq range, served by the `(runId, seq)` primary key.
1033
+ *
1034
+ * Optional: without it a settled fan keeps one checkpoint per child.
1035
+ */
1036
+ compactCheckpoints?(runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint): Promise<void>;
987
1037
  /**
988
1038
  * Delete the EXACT waiter row — `token` AND `runId` AND `seq` must all match — no-op if absent.
989
1039
  * Unlike {@link takeSignalWaiter}, which deletes ANY row for `token` (fine when the caller just won
@@ -1410,6 +1460,26 @@ interface StoreTransaction {
1410
1460
  saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
1411
1461
  }
1412
1462
  /** Binds an external signal `token` to the suspended run/step position waiting for it. */
1463
+ /** Options for {@link WorkflowCtx.all}. */
1464
+ interface AllOptions {
1465
+ /** `waitAll` (default) or `failFast` — see {@link WorkflowCtx.all}. */
1466
+ mode?: 'waitAll' | 'failFast';
1467
+ /**
1468
+ * The most children running at once. Unset sends the whole fan immediately. When set, children go
1469
+ * out in waves of `floor(concurrency / 2)`, two at a time (an odd limit runs one child under it):
1470
+ * a new wave starts as soon as an earlier one settles, so one slow child does not idle the rest of
1471
+ * the window. Each settled wave costs the parent one turn.
1472
+ *
1473
+ * Part of the fan's identity: child ids carry the wave, so changing it for an in-flight run is a
1474
+ * non-deterministic change like changing `inputs`.
1475
+ */
1476
+ concurrency?: number;
1477
+ }
1478
+ /** One child of a fan as {@link StateStore.registerChildWaits} writes it. */
1479
+ interface ChildWait {
1480
+ waiter: SignalWaiter;
1481
+ checkpoint: StepCheckpoint;
1482
+ }
1413
1483
  interface SignalWaiter {
1414
1484
  token: string;
1415
1485
  runId: string;
@@ -2276,13 +2346,11 @@ interface WorkflowCtx<A extends SearchAttributes = SearchAttributes> {
2276
2346
  * so a fast sibling can still slip through and complete). Empty `inputs` returns `[]` with no side
2277
2347
  * effects. The wait-all / fan-out counterpart to {@link child}; parity with the Python SDK's
2278
2348
  * `gather_children`.
2349
+ *
2350
+ * `concurrency` caps how many children run at once (see {@link AllOptions.concurrency}).
2279
2351
  */
2280
- all<C extends WorkflowClass>(workflow: C, inputs: WorkflowInputOf<C>[], opts?: {
2281
- mode?: 'waitAll' | 'failFast';
2282
- }): Promise<WorkflowOutputOf<C>[]>;
2283
- all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: {
2284
- mode?: 'waitAll' | 'failFast';
2285
- }): Promise<TOutput[]>;
2352
+ all<C extends WorkflowClass>(workflow: C, inputs: WorkflowInputOf<C>[], opts?: AllOptions): Promise<WorkflowOutputOf<C>[]>;
2353
+ all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: AllOptions): Promise<TOutput[]>;
2286
2354
  /**
2287
2355
  * Pause the run at this point until a human resumes it from the dashboard (or
2288
2356
  * `engine.continue(runId)`). Records a visible `pending` checkpoint so the breakpoint shows up
@@ -2405,9 +2473,7 @@ interface DynamicWorkflowCtx<A extends SearchAttributes = SearchAttributes> exte
2405
2473
  /** {@link WorkflowCtx.startChild} by workflow name. */
2406
2474
  startChild(workflow: string, input: unknown, options?: string | ChildCallOptions): Promise<string>;
2407
2475
  /** {@link WorkflowCtx.all} by workflow name. */
2408
- all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: {
2409
- mode?: 'waitAll' | 'failFast';
2410
- }): Promise<TOutput[]>;
2476
+ all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: AllOptions): Promise<TOutput[]>;
2411
2477
  }
2412
2478
  /** Result of executing or resuming a workflow run. */
2413
2479
  interface RunResult {
@@ -3441,8 +3507,8 @@ interface StartOptions {
3441
3507
  /**
3442
3508
  * Serialize runs of a workflow that share a key — a durable, FIFO mutex (e.g. one pipeline per base).
3443
3509
  * Excess runs are admitted in creation order, `limit` at a time; the rest wait (suspended) and retry
3444
- * admission on a timer until a slot frees. Race-free on a consistent store (admission order is the
3445
- * same `(createdAt, id)` view for every instance).
3510
+ * admission on a timer until a slot frees. The store atomically reserves durable slots before
3511
+ * ordering unadmitted waiters by `(createdAt, id)`, so later starts cannot displace a holder.
3446
3512
  */
3447
3513
  interface SingletonConfig {
3448
3514
  /** Derive the serialization key from the workflow input. */
@@ -3453,7 +3519,7 @@ interface SingletonConfig {
3453
3519
  * Max GATED (waiting-for-admission) runs allowed to queue behind the `limit` in-flight ones. When
3454
3520
  * set, `start` rejects with {@link SingletonQueueFullError} once in-flight + gated reaches
3455
3521
  * `limit + maxQueueDepth` — back-pressure against an unbounded same-key backlog. Omit for the
3456
- * default unbounded queue. Counts `pending`/`running`/`suspended` runs sharing the key.
3522
+ * default unbounded queue. Counts pending/running/suspended/blocked/cancelling runs sharing the key.
3457
3523
  */
3458
3524
  maxQueueDepth?: number;
3459
3525
  }
@@ -4188,6 +4254,32 @@ declare class WorkflowEngine {
4188
4254
  * same way.
4189
4255
  */
4190
4256
  private deliverSignal;
4257
+ /**
4258
+ * The `ctx.all` join barrier: true when `waiter` was one child of a fan (or of one wave of it)
4259
+ * whose siblings are still out, so waking the parent now would only replay the fan and re-suspend.
4260
+ * Skipping that wake is what keeps a fan of N children at O(N) work instead of N replays of N items.
4261
+ *
4262
+ * Safe because the LAST sibling to settle always wakes the parent: each child consumes its own
4263
+ * waiter before it asks, so whichever asks last sees none left. A failed child of a failFast fan
4264
+ * always wakes it. Anything that is not a `ctx.all` waiter, or a store that cannot answer the
4265
+ * question cheaply, wakes the parent as before.
4266
+ */
4267
+ private fanStillWaiting;
4268
+ /**
4269
+ * Re-drive a run that just suspended on awaited children (a `ctx.all` fan or wave, a `ctx.child`)
4270
+ * which, by now, have settled.
4271
+ *
4272
+ * {@link execute} drops a wake that finds the run's lease held. So if a child settles while the
4273
+ * parent is still executing (the turn that dispatched it, or one woken by an earlier child), that
4274
+ * wake is spent, and the turn suspends on a snapshot that predates the child. With the `ctx.all`
4275
+ * barrier that wake was the only one the fan would get. Nothing would wake the run until the
4276
+ * `reconcileMs` sweep, minutes later.
4277
+ *
4278
+ * Called after the turn released its lease, so any child that settles from here on wakes the run
4279
+ * itself. Only re-drives for a group with no waiter left whose checkpoints are all settled, which
4280
+ * the next turn is then guaranteed to see — so it cannot loop.
4281
+ */
4282
+ private redriveSettledChildren;
4191
4283
  /**
4192
4284
  * Deliver an external signal to the run waiting on `token`, resume it with `payload`, and return
4193
4285
  * the run result — or null if no run is (or ends up) waiting for it.
@@ -4344,8 +4436,11 @@ declare class WorkflowEngine {
4344
4436
  * so a completed parent (or a completed awaited child) would otherwise drop out of the tree. The
4345
4437
  * `signal:child:<id>` checkpoint (the placeholder written when the parent first awaits the child,
4346
4438
  * overwritten as completed/failed when it settles) persists across completion, so we read both and
4347
- * dedupe — the edge stays stable for a finished run, not just a live one.
4439
+ * dedupe — the edge stays stable for a finished run, not just a live one. A settled `ctx.all`
4440
+ * group folded into one `fan:` checkpoint stands for every child in it.
4348
4441
  */
4442
+ /** The children `parentRunId` is awaiting right now, read off its own live `child:` waiters. */
4443
+ private awaitedChildIds;
4349
4444
  getRunChildren(parentRunId: string): Promise<string[]>;
4350
4445
  /** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
4351
4446
  * `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
@@ -4427,6 +4522,8 @@ declare class WorkflowEngine {
4427
4522
  private completeStep;
4428
4523
  /** Checkpoint a step that failed terminally, so the failure point is visible (not just the run). */
4429
4524
  private failStep;
4525
+ /** Admission persists the wait atomically; never overwrite a cancellation after it returns. */
4526
+ private singletonWaitResult;
4430
4527
  private execute;
4431
4528
  /**
4432
4529
  * Advance a remote (cross-SDK) workflow one turn: hand its history to the executor (which dispatches
@@ -4966,9 +5063,24 @@ declare class GatherError extends Error {
4966
5063
  declare class WorkflowSuspended extends Error {
4967
5064
  /** Epoch ms to auto-resume (durable sleep), or undefined when waiting on an external signal. */
4968
5065
  readonly wakeAt?: number | undefined;
5066
+ /** Set when awaited children are what the run is waiting on — see {@link FanJoin}. */
5067
+ readonly fan?: FanJoin | undefined;
4969
5068
  /** Marks this as a control-flow signal — see {@link isWorkflowControlFlowSignal}. */
4970
5069
  readonly [CONTROL_FLOW_SIGNAL] = true;
4971
- constructor(wakeAt?: number);
5070
+ constructor(wakeAt?: number, fan?: FanJoin);
5071
+ }
5072
+ /**
5073
+ * What a run suspended on when it awaits children (`ctx.all`, `ctx.child`). For each group of
5074
+ * children, every waiter token starts with `waiterPrefix` and every `signal:child:` checkpoint name
5075
+ * with `checkpointPrefix`, so the engine can tell whether the group has settled without knowing the
5076
+ * children's ids.
5077
+ */
5078
+ interface FanJoin {
5079
+ waits: FanWait[];
5080
+ }
5081
+ interface FanWait {
5082
+ waiterPrefix: string;
5083
+ checkpointPrefix: string;
4972
5084
  }
4973
5085
  /**
4974
5086
  * Thrown by `ctx.continueAsNew(input)` to end the current run and hand off to a fresh execution of
@@ -5302,10 +5414,23 @@ declare function classifyWaiterToken(token: string): RunWaiting;
5302
5414
  * state (no-worker, singleton, running) on top — none of which can be told apart from `wakeAt` alone.
5303
5415
  */
5304
5416
  declare function resolveRunWaiting(run: WorkflowRun, waiterByRun: ReadonlyMap<string, SignalWaiter>): RunWaiting | undefined;
5417
+ /**
5418
+ * The signal waiters of `runIds`: through the store's {@link StateStore.listSignalWaitersByRun} in
5419
+ * bounded batches, or, for a store without it, one scan of every waiter filtered to those runs.
5420
+ */
5421
+ declare function listSignalWaitersOfRuns(store: StateStore, runIds: readonly string[]): Promise<SignalWaiter[]>;
5305
5422
  /** Index signal waiters by `runId`, keeping the first seen per run (a run parks on one waiter at a
5306
5423
  * time in the sequential case; the earliest is the one it's blocked on). */
5307
5424
  declare function indexWaitersByRun(waiters: readonly SignalWaiter[]): Map<string, SignalWaiter>;
5308
5425
 
5426
+ /**
5427
+ * The parent of a child run whose id the engine minted: a `ctx.all` child
5428
+ * (`<parent>.all.<seq>.<i>`, or `.w<k>.<i>` under a `concurrency` limit) or a `ctx.child` /
5429
+ * `ctx.startChild` child without an explicit id (`<parent>.child.<seq>`). Undefined for any other
5430
+ * run, including a child started with a caller-chosen id.
5431
+ */
5432
+ declare function parentRunIdOf(runId: string): string | undefined;
5433
+
5309
5434
  /**
5310
5435
  * Transforms a payload value as it crosses the store boundary — e.g. encrypt-at-rest, compress, or
5311
5436
  * redact PII. `decode` must be the exact inverse of `encode`. Both are synchronous (use a local
@@ -5328,6 +5453,8 @@ interface PayloadCodec {
5328
5453
  declare class CodecStateStore implements StateStore {
5329
5454
  private readonly inner;
5330
5455
  private readonly codec;
5456
+ /** Atomic claims touch only searchable metadata and bypass payload encoding. */
5457
+ readonly tryAdmitSingleton?: (runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number) => Promise<boolean>;
5331
5458
  /**
5332
5459
  * Forwarded verbatim — a facet cell counts `status`/`origin`, neither of which the codec touches
5333
5460
  * (it encodes payloads: input/output/error). Bound as a PROPERTY, and only when the inner store
@@ -5350,6 +5477,14 @@ declare class CodecStateStore implements StateStore {
5350
5477
  /** Forwarded verbatim — a count reads no payload. Bound only when the inner store counts, so the
5351
5478
  * engine's facet/listing fallback still applies through the wrapper. */
5352
5479
  readonly countRuns?: (query: Omit<RunQuery, 'limit' | 'offset'>) => Promise<number>;
5480
+ /** The placeholder checkpoints are encoded like any other checkpoint. */
5481
+ readonly registerChildWaits?: (entries: ChildWait[]) => Promise<void>;
5482
+ /** The folded checkpoint carries the children's outputs, so it is encoded. */
5483
+ readonly compactCheckpoints?: (runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint) => Promise<void>;
5484
+ /** Forwarded verbatim — a waiter carries no payload. */
5485
+ readonly listSignalWaitersByRun?: (runIds: string[]) => Promise<SignalWaiter[]>;
5486
+ /** Forwarded verbatim — a waiter carries no payload. */
5487
+ readonly hasSignalWaiter?: (runId: string, tokenPrefix: string) => Promise<boolean>;
5353
5488
  /** Schedules persist their run `input` inside `spec` — encoded like any other payload. Bound only
5354
5489
  * when the inner store persists schedules, so `engine.schedules` reports absence faithfully. */
5355
5490
  readonly saveSchedule?: (record: ScheduleRecord) => Promise<void>;
@@ -5796,8 +5931,9 @@ declare class InMemoryStateStore implements StateStore {
5796
5931
  private key;
5797
5932
  /** Drop then re-add a run's normalized attribute rows so the index tracks its current attributes. */
5798
5933
  private reindexAttributes;
5934
+ tryAdmitSingleton(runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number): Promise<boolean>;
5799
5935
  createRun(run: WorkflowRun): Promise<void>;
5800
- updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
5936
+ updateRun(runId: string, inputPatch: Partial<WorkflowRun>): Promise<void>;
5801
5937
  getRun(runId: string): Promise<WorkflowRun | null>;
5802
5938
  deleteRun(runId: string): Promise<void>;
5803
5939
  deleteRuns(runIds: string[]): Promise<void>;
@@ -5813,6 +5949,10 @@ declare class InMemoryStateStore implements StateStore {
5813
5949
  putSignalWaiter(waiter: SignalWaiter): Promise<void>;
5814
5950
  takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
5815
5951
  listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
5952
+ registerChildWaits(entries: ChildWait[]): Promise<void>;
5953
+ compactCheckpoints(runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint): Promise<void>;
5954
+ listSignalWaitersByRun(runIds: string[]): Promise<SignalWaiter[]>;
5955
+ hasSignalWaiter(runId: string, tokenPrefix: string): Promise<boolean>;
5816
5956
  removeSignalWaiter(waiter: SignalWaiter): Promise<void>;
5817
5957
  transaction<T>(work: (tx: {
5818
5958
  raw: unknown;
@@ -5891,4 +6031,18 @@ declare class InMemoryTransport implements Transport, ControlPlane {
5891
6031
  onControl(handler: (msg: ControlMessage) => void): void;
5892
6032
  }
5893
6033
 
5894
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, STATE_STORE, STATE_STORE_CANONICAL, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, classifyWaiterToken, clearDurableExecutionWrappers, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, tenantGroup, useDurableExecution, warn, workflowName };
6034
+ /** Reserved engine metadata: a durable singleton slot, independent of the execution lease. */
6035
+ declare const SINGLETON_ADMITTED_TAG = "durable:singleton:admitted";
6036
+ declare const SINGLETON_ACTIVE_STATUSES: RunStatus[];
6037
+ /** Call only inside a store's atomic admission transaction/critical section. */
6038
+ declare function singletonAdmissionTags(runs: WorkflowRun[], runId: string, tag: string, workflow: string, limit: number): string[] | null;
6039
+ /** Terminal runs release admission, including when later resumed directly rather than requeued. */
6040
+ declare function clearTerminalSingletonAdmission(runId: string, patch: Partial<WorkflowRun>, getRun: (id: string) => Promise<WorkflowRun | null>): Promise<Partial<WorkflowRun>>;
6041
+ /** Persist denial while admission locks are held; a cancelling/terminal run must never revive. */
6042
+ declare function singletonAdmissionDenialPatch(runs: WorkflowRun[], runId: string, tag: string, workflow: string, retryWakeAt?: number): {
6043
+ status: 'suspended';
6044
+ wakeAt: number;
6045
+ updatedAt: Date;
6046
+ } | undefined;
6047
+
6048
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, type ChildWait, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, type FanJoin, type FanWait, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, listSignalWaitersOfRuns, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, parentRunIdOf, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, tenantGroup, useDurableExecution, warn, workflowName };