export interface BridgeTurnJournalEntry { turnId: string; dispatchAttempt?: number; /** Wall-clock millis of the original mark — restored verbatim so the * send-marker window and the split cutoff keep their original bounds. */ markTimeMs: number; fingerprint?: string; contentNormalized?: string; /** Transcript file the mark was armed against. Restore is scoped to the * SAME file — a rotation between generations makes attribution unsafe. */ jsonlPath: string; /** Consumed transcript offset when the mark was armed. The turn's user * line can only exist at/after this byte, so restore re-drains from here * instead of re-reading the whole file. Always a line boundary. */ offsetAtMark: number; } /** Entries older than this are dropped at restore instead of re-marked: a * partial answer from days ago posted into a thread that has long moved on * is noise, not recovery. */ export declare const BRIDGE_TURN_RESTORE_MAX_AGE_MS: number; export declare function readBridgeTurnJournal(path: string): BridgeTurnJournalEntry[]; export declare function writeBridgeTurnJournal(path: string, pending: BridgeTurnJournalEntry[]): void; export declare function appendBridgeTurnJournalEntry(path: string, entry: BridgeTurnJournalEntry): void; export declare function removeBridgeTurnJournalEntry(path: string, turnId: string, dispatchAttempt?: number): void; export declare function clearBridgeTurnJournal(path: string): void; /** Pure restore filter: which journal entries may be re-marked on this * worker generation? Scoped to the same transcript file (rotation between * generations makes offset+fingerprint attribution unsafe) and bounded by * age (stale partials are noise). */ export declare function selectRestorableBridgeTurns(entries: readonly BridgeTurnJournalEntry[], opts: { currentJsonlPath: string; nowMs?: number; maxAgeMs?: number; }): BridgeTurnJournalEntry[]; /** * One-shot latch that confines journal restore to a worker process's FIRST * bridge baseline. Extracted from worker.ts (like InflightInputTracker) so the * "restore at most once, only on the first baseline" rule is unit-testable. * * Why it exists: the journal recovers a plain-IM turn orphaned by a * CROSS-process death (daemon restart / worker crash) — there the whole worker * is new and no other recovery owner survives. But an IN-worker CLI restart * (crash-respawn / cwd-move / durable lease expiry) keeps the process alive, so * its InflightInputTracker carryover ALREADY re-delivers the interrupted plain * IM input as a full fresh answer. If the journal ALSO restored that turn on the * post-restart baseline, the recovered partial and the fresh answer — same * turnId, different lastUuid — would both reach Lark (the daemon dedupe can't * collapse them). The worker arms this latch on every watcher teardown, so only * the first baseline (the one with no competing recovery owner) may restore. */ export declare class BridgeRestoreGate { private consumed; /** True only on the first call after construction — the process's first * baseline. Every later call (a post-restart baseline) returns false. Does * NOT itself consume the latch: an empty-journal first baseline must still * arm it via markGenerationRetired so a later restart can't restore. */ mayRestoreOnThisBaseline(): boolean; /** Arm the latch: a CLI generation has ended (watcher torn down), so any * future baseline is an in-worker restart, never first-baseline recovery. * Idempotent. */ markGenerationRetired(): void; } //# sourceMappingURL=bridge-turn-journal.d.ts.map