import type { EngineInternals } from './internals.ts'; /** * Thrown by `query()` when this engine has no live local execution context for * `workflowId` AND a durable `ownership: 'workflow-lease'` claim shows another * engine currently holds it — distinguishing "not owned here, retry against * the owner" from a query handler that legitimately resolved to `undefined`. * A workflow that is simply terminal, purged, or never existed still resolves * to plain `undefined`, unchanged — this error fires only when a live holder * record names a DIFFERENT engine. * * Not a public `WeftError`: ADR 0002 § Open questions leaves the cross-engine * query/update ROUTING mechanism open (forward to the true owner vs. surface * a retry-elsewhere error to the caller); this is the smaller, non-speculative * fix for the silent-`undefined` bug alone, reusing the same "untyped `Error`" * shape Gate 1 (`requireStorageCapability`) already ships for a similarly * not-yet-typed diagnostic rather than adding a new public error code and its * full registration surface for a routing question ADR 0002 has not settled. * `query()` has no durable fallback path the way `update()`'s coordinated * path does (see `updates.ts`), so surfacing an error here — rather than a * value indistinguishable from a real `undefined` result — is the only * correct option. */ export declare class WorkflowNotLocallyOwnedError extends Error { readonly workflowId: string; constructor(workflowId: string); } /** * Cheap, read-only check for whether `workflowId` is durably claimed by a * DIFFERENT engine under `ownership: 'workflow-lease'` — a * `wakeOwnershipCheck`-style storage read (one `storage.get`, no * `conditionalBatch`), not the actual safety mechanism. Always `false` * (inert) under `ownership: 'none'`/`'lease'`, where no claim registry is * installed. * * Always re-reads the durable holder rather than trusting this engine's own * cached `registry.currentEpoch(workflowId)`: after a takeover elsewhere, * this engine's local claim entry stays populated (and its cached epoch * stale) until its next renewal CAS independently detects the loss — a * `registry.currentEpoch(workflowId) !== null` shortcut would let a stale * engine keep answering `false` (and so keep serving queries/updates from a * deposed context) for up to a full renewal interval. Deciding by the * durable holder's `engineId` alone — not epoch — is sufficient here: this * engine reacquiring the same workflow at a new epoch after a release still * means the holder names THIS engine, correctly answering `false`. */ export declare function isWorkflowClaimedByAnotherEngine(internals: EngineInternals, workflowId: string): Promise; /** * `true` when `workflowId`'s persisted `WorkflowState` is missing (never * existed, or already purged) or terminal. Used to ignore a durably stale * `wf-owner-holder:` record: a normal owner-side complete/fail commit is * fenced but does not delete the holder record (only an explicit `release` * — graceful shutdown or the reclaim scan's redrive-detects-terminal path — * or a `takeover`/rotation does), so a contextless query for an already- * terminal workflow can otherwise see a holder record naming a DIFFERENT * engine and incorrectly throw `WorkflowNotLocallyOwnedError` for a workflow * every engine agrees has already finished. Documented behavior is that * terminal, purged, or unknown workflows keep resolving to plain * `undefined` — this check restores that for the `workflow-lease` claim * path specifically. */ export declare function isWorkflowLocallyTerminalOrMissing(internals: EngineInternals, workflowId: string): Promise; /** * `internals.workflowClaimRegistry !== null && (await isWorkflowClaimedByAnotherEngine(...))`, * factored out so every "revalidate before serving a possibly-stale live * Context" call site — `query()` below and `tryInlineUpdateHandler` in * `updates.ts` — shares the exact same registry-gated short-circuit. The * registry-null check is a plain property read, not an unconditional await, * so `ownership: 'none'`/`'lease'` stay exactly as synchronous as they are * today; only `'workflow-lease'` pays for the cheap durable read. */ export declare function isLiveContextStale(internals: EngineInternals, workflowId: string): boolean | Promise; /** Resolve a workflow query from built-in progress state or exposed inline accessors. */ export declare function query(internals: EngineInternals, workflowId: string, name: string, input?: unknown): Promise;