import type { ServeOptions, TaskDispatch } from '../index.ts'; import { type RemoteTaskBase, type RemoteTaskLeased } from '../task-ledger.ts'; import type { ServerContext } from './context.ts'; interface ManualTaskReconciliationForTesting { readonly options: ServeOptions; scanAt(operationId: string, trackedDeadline: number, now: number): Promise; } /** @internal Restricts manual reconciliation to explicitly marked test options. */ export declare function useManualTaskReconciliationForTesting(options: ServeOptions): ManualTaskReconciliationForTesting; /** @internal Installs the narrow one-shot test controller before a server starts. */ export declare function consumeManualTaskReconciliationForTesting(options: ServeOptions, context: ServerContext, cleanupWorkflowIndex: (operationId: string) => void): boolean; /** * Given a leased ledger record whose visibility deadline has passed, either * permanently fail the task (retry attempts exhausted) or requeue it with * backoff for redispatch. Both the worker-disconnect handler and the * visibility-timeout scanner share this logic. A single attempt, no retry — * a lost compare-and-swap here means a concurrent heartbeat renewed the * lease or another actor already resolved this attempt, and retrying the * identical transition cannot change that outcome. */ export declare function reassignOrExpireTask(context: ServerContext, options: ServeOptions, operationId: string, record: RemoteTaskLeased, reason?: string): Promise; /** * Reconstruct the `TaskDispatch` a fresh dispatch of this operation would * have used, from the durable envelope alone. Shared by expired-lease * redispatch ({@link reassignOrExpireTask}) and startup recovery's * `queued`-record redispatch (`task-ledger-recovery.ts`) — both cases hand a * record back to `dispatchTaskImpl` with no original caller-supplied * `TaskDispatch` still in memory. Every `RemoteTaskBase` field * `buildRoutingOptions`/`resolveTaskPriority` read at dispatch time * (`priority`, `fairShareKey`, sticky affinity) must round-trip here too, or * a requeued or recovered task silently loses its original routing intent. */ export declare function taskDispatchFromLedgerRecord(record: RemoteTaskBase): TaskDispatch; /** * Drain expired entries from the in-memory deadline heap and reassign * their tasks. Only touches storage for the specific operations whose * deadlines have actually passed — no full ledger scan. */ export declare function scanExpiredTasks(context: ServerContext, options: ServeOptions, cleanupWorkflowIndex: (operationId: string) => void, now?: number): Promise; /** * Periodic full-ledger safety net (WFT-23), independent of the in-memory * deadline heap `scanExpiredTasks` drains: catches `leased` records whose * expiry was never tracked in the heap (written by a peer, or lost to a * restart), `queued` records whose durable `availableAt` has elapsed but * whose `scheduleDelayedDispatch` timer never fired (same causes), and * (WFT-24) adopted `terminal` records old enough to reap under * {@link ServeOptions.taskRetentionWindowMs}. `completing`, `cancelling`, * and `deadLettered` are left untouched — resolving those is either the * worker's redelivered result (`completing`) or explicitly out of this * slice's scope. */ export declare function reconcileOrphanedRecords(context: ServerContext, options: ServeOptions, cleanupWorkflowIndex: (operationId: string) => void): Promise; export {};