/** * Minimal FIFO async mutex used to serialize provider mutations. * * The coordinator owns one mutex per mutation lane. It is intentionally * in-process only: SQLite outbox, leases, and receipts remain the durable * authority. The mutex exists solely so the Node side never issues competing * mutations for the same spreadsheet within one process. * * Fairness is FIFO so an uncertain-recovery barrier cannot be starved by a * steady stream of new mutations. */ export interface AsyncMutexMetrics { /** Currently held by a mutation. */ readonly locked: boolean; /** Mutations waiting for the lane. */ readonly queued: number; /** Mutations completed (success or failure) since construction. */ readonly completed: number; } /** Releases one acquired lane. Safe to call at most once. */ export type AsyncMutexRelease = () => void; /** * A lockable, FIFO queue of deferred mutations. * * Serialization relies on a promise gate: the queue's tail resolves only when * the current holder releases, so every subsequent acquirer waits for the * previous holder rather than for the previous acquirer's microtask. */ export declare class AsyncMutex { private tail; private active; private queueDepth; private completedCount; /** * Runs `task` once the lane is acquired. The lane is released even when the * task rejects, so a failing mutation never deadlocks the coordinator. */ run(task: () => Promise): Promise; /** * Acquires the lane and resolves with a release token. The caller must call * the returned release function exactly once, even on error, so the lane is * never left locked. This is the path used for multi-lane batch mutations * that must hold several lanes at once. */ acquire(): Promise; /** Snapshot of queue depth and occupancy; diagnostic only. */ metrics(): AsyncMutexMetrics; private release; } //# sourceMappingURL=asyncMutex.d.ts.map