/** Leased, cursor-checkpointed, bounded reconciliation worker orchestration. */ import { type DurableEffectStore, type EffectReconciliationFinding, type SagaReconciliationFinding, type SagaStore } from "./durable-execution.js"; export interface ReconciliationLease { readonly name: string; readonly owner: string; readonly token: string; readonly expiresAt: number; readonly cursor?: string; } export interface ReconciliationLeaseStore { readonly durability?: "memory" | "durable"; acquire(input: { readonly name: string; readonly owner: string; readonly now: number; readonly leaseMs: number; }): ReconciliationLease | undefined | Promise; renew(input: { readonly name: string; readonly owner: string; readonly token: string; readonly now: number; readonly leaseMs: number; }): boolean | Promise; checkpoint(input: { readonly name: string; readonly owner: string; readonly token: string; readonly cursor?: string; }): boolean | Promise; release(input: { readonly name: string; readonly owner: string; readonly token: string; }): boolean | Promise; } export type ReconciliationWorkerEvent = { readonly type: "acquired" | "released" | "lease-lost"; readonly name: string; } | { readonly type: "page" | "checkpoint"; readonly name: string; readonly scanned: number; readonly handled: number; } | { readonly type: "failed"; readonly name: string; readonly errorCode: "scan" | "handle"; }; export interface ReconciliationWorkerOptions { readonly name: string; readonly owner: string; readonly leases: ReconciliationLeaseStore; readonly leaseMs?: number; readonly batchSize?: number; readonly maxPages?: number; readonly concurrency?: number; readonly signal?: AbortSignal; readonly now?: () => number; readonly scan: (input: { readonly cursor?: string; readonly limit: number; readonly signal: AbortSignal; }) => { readonly findings: readonly Finding[]; readonly cursor?: string; } | Promise<{ readonly findings: readonly Finding[]; readonly cursor?: string; }>; readonly filter?: (finding: Finding) => boolean; readonly handle: (finding: Finding, signal: AbortSignal) => void | PromiseLike; readonly observe?: (event: ReconciliationWorkerEvent) => void; } export interface ReconciliationWorkerResult { readonly acquired: boolean; readonly pages: number; readonly scanned: number; readonly handled: number; } export declare function runReconciliationWorker(options: ReconciliationWorkerOptions): Promise; export declare class MemoryReconciliationLeaseStore implements ReconciliationLeaseStore { readonly durability: "memory"; private readonly records; acquire(input: Parameters[0]): ReconciliationLease | undefined; renew(input: Parameters[0]): boolean; checkpoint(input: Parameters[0]): boolean; release(input: Parameters[0]): boolean; } interface SpecializedWorkerOptions { readonly name: string; readonly owner: string; readonly leases: ReconciliationLeaseStore; readonly staleBefore: number; readonly leaseMs?: number; readonly batchSize?: number; readonly maxPages?: number; readonly concurrency?: number; readonly signal?: AbortSignal; readonly now?: () => number; readonly filter?: (finding: Finding) => boolean; readonly handle: (finding: Finding, signal: AbortSignal) => void | PromiseLike; readonly observe?: (event: ReconciliationWorkerEvent) => void; } export declare function runEffectReconciliationWorker(store: DurableEffectStore, options: SpecializedWorkerOptions): Promise; export declare function runSagaReconciliationWorker(store: SagaStore, options: SpecializedWorkerOptions): Promise; export {}; //# sourceMappingURL=reconciliation-worker.d.ts.map