import { type Entry } from './log.js'; export type HistoryLayout = { base?: HistoryLayout; parent: number; branch: number; }; type Segment = { directory: string; generation: string; file: 'events.jsonl' | 'actions.jsonl' | 'origin.jsonl'; start: number; count: number; digest: string; }; export type HistoryOrigin = { at: string; directory: string; generation: string; view: string; position: number; remoteView?: string; depth: number; incomplete?: boolean; }; export type HistoryView = { version: 1; owner: { directory: string; generation: string; }; layout: HistoryLayout; segments: Segment[]; origin?: HistoryOrigin; }; export type HistoryReference = { view: string; position: number; }; export declare function validateHistoryOrigin(origin: HistoryOrigin, layout?: HistoryLayout): void; export declare const historyEntryTime: (entry: Entry) => number; export declare const historyDigest: (value: unknown) => string; export declare function historyLength(layout: HistoryLayout, depth?: number): number; /** The layout of a view's first `at` entries: historyPrefix's, without the segment digests a prefix view carries (a * fold reads only the layout, and a partial segment's digest re-reads and hashes its log). */ export declare function historyLayoutAt(layout: HistoryLayout, at: number): HistoryLayout; export declare function readHistoryView(directory: string, id: string): HistoryView; export declare function historyEntries(view: HistoryView): Entry[]; export declare function historyPrefix(view: HistoryView, at: number): HistoryView; export declare function saveHistoryView(directory: string, view: HistoryView): string; /** What an inherited history's content stands on, as file facts: every segment file the view names * (and the view document itself) and each named directory's ancestry record (its generation). A read cache keyed by this sees an * ancestor's retained history truncated, replaced or its directory re-created, which the full read * refuses (`historyEntries`), instead of serving a tree folded from the history it replaced. */ export declare function inheritedHistoryKey(service: string, root?: string, meta?: string | null): string; export declare function inheritedHistory(service: string, root?: string): HistoryView | undefined; /** Capture under the directory's history lock, as appends and complete observation batches are made. */ export declare function captureHistory(service: string, root?: string): { view: string; position: number; descriptor: HistoryView; }; export declare function originHead(service: string, root?: string): { view: string; remoteView: string; } | null; /** A complete remote view shares cached rows by content, never by mutable offsets or entry ID. */ export declare function publishOriginHistory(service: string, root: string, remoteView: string, layout: HistoryLayout, entries: Entry[]): { view: string; appended: number; }; /** A changeset binds the complete inherited view, including this root's observations. */ export declare function captureParentHistory(service: string, root?: string): HistoryReference; /** Compare evaluated views, so removals, reordered rows and layout changes count as drift. */ export declare function historyChanges(service: string, before: HistoryView, after: HistoryView): Entry[]; /** Which of a history's entries had occurred by `stamp` (ms), each layer's count of them, and those entries in order: a * contiguous observation batch is one indivisible look, kept whole when any of it is. Reads and writes nothing. */ export declare function historyKeptAt(entries: Entry[], layout: HistoryLayout, stamp: number): { keep: boolean[]; layout: HistoryLayout; entries: Entry[]; }; /** A timestamp can select across layers; represent it as a view, never a misleading offset. */ export declare function historyAtInstant(service: string, instant: string, root?: string, selectedView?: string): HistoryReference; /** Replace only the tracked origin layer; inherited local layers keep their exact projection order. */ export declare function replaceHistoryOrigin(previous: HistoryView, origin: HistoryOrigin, next: HistoryOrigin): HistoryView; export {};