/** * In-memory min-heap that tracks inflight task deadlines. * * Used by the visibility timeout scanner to avoid a full storage scan * on every tick. The scanner pops expired entries from the heap instead * of iterating all `op:inflight:*` records. * * Uses generation-based lazy deletion: each operation ID has a generation * counter. `remove()` bumps the generation in O(1), and heap entries with * an older generation are skipped during `popMin()` and `drainExpired()`. * * @module server/deadline-tracker */ /** A single tracked deadline entry. */ export type DeadlineEntry = { operationId: string; deadline: number; }; /** * Min-heap ordered by deadline with O(1) lazy removal. * * - `add`: O(log n) * - `remove`: O(1) — bumps generation counter * - `popMin`: O(log n) amortized — skips stale entries * - `drainExpired`: O(k log n) where k is the number of expired entries */ export declare class DeadlineTracker { #private; constructor(); /** Number of tracked deadlines (excludes stale entries). */ get size(): number; /** Peek at the earliest non-stale deadline. Returns `undefined` if empty. */ peekDeadline(): number | undefined; /** * Add a new deadline entry. Any previous entry for this operation ID * becomes stale and will be skipped during pop/drain. */ add(entry: DeadlineEntry): void; /** Remove and return the entry with the earliest deadline, or `undefined` if empty. */ popMin(): DeadlineEntry | undefined; /** Invalidate all entries for the given operation ID in O(1). */ remove(operationId: string): void; /** Drain all non-stale entries whose deadline is at or before `now`. */ drainExpired(now: number): DeadlineEntry[]; /** Remove all entries. */ clear(): void; }