/** * Opaque, well-formed Unicode text, returned exactly, code unit for code unit. * A driver never parses, trims, normalizes or re-encodes it. Tea writes JSON * text into it; a driver must not rely on that. */ type EncodedRecord = string; type JournalEntry = { readonly seq: number; readonly record: EncodedRecord; }; type JournalRefusal = { readonly _tag: "journal_io"; readonly operation: "read" | "append"; readonly message: string; readonly uncertain: boolean; } | { readonly _tag: "journal_corrupt"; readonly message: string; }; type JournalConflict = { readonly _tag: "journal_conflict"; readonly expected: number; readonly head: number; }; type JournalRead = { readonly _tag: "read"; readonly head: number; readonly entries: readonly JournalEntry[]; }; type JournalAppend = { readonly _tag: "appended"; readonly head: number; readonly entries: readonly JournalEntry[]; }; /** * Ordered storage of opaque text. One active writer per stream is required. * An append stores the entire nonempty batch or none of it. * `read(stream, after)` returns every stored entry whose `seq` is greater than `after`, in order, for ANY number; it never refuses a position. * After an uncertain append, reopen and read; * the refusal does not authorize blindly retrying the batch. */ interface Journal { read(stream: string, after: number): Promise; append(stream: string, records: readonly [EncodedRecord, ...EncodedRecord[]]): Promise; close(): Promise; } /** Methods beside the base methods, matching FencedStore's widening pattern. */ interface FencedJournal extends Journal { readonly fenced: true; appendFenced(stream: string, records: readonly [EncodedRecord, ...EncodedRecord[]], expected: number): Promise; } /** In-process storage; opt into atomic expected-head comparison explicitly. */ declare function memoryJournal(options: { readonly fenced: true; }): FencedJournal; declare function memoryJournal(options?: { readonly fenced?: false; }): Journal; export { type EncodedRecord as E, type FencedJournal as F, type Journal as J, type JournalAppend as a, type JournalConflict as b, type JournalEntry as c, type JournalRead as d, type JournalRefusal as e, memoryJournal as m };