import { SessionError, type ReplayLoss } from "../harness/types.js";
export type { ReplayLoss };
/** The fork point a store copies up to: `{}` is the whole log, `{ entryId, position: "at" }` the path from the root down to that entry. It is the answer
 *  `settledForkOptions` gives, and the question `selectForkRows` takes. */
export interface ForkPoint {
    entryId?: string;
    position?: "at";
}
/** How the walk reads a log: the row an id names (`undefined` = the log holds none), a row's own id, and the id of its parent (`null` or `undefined` = it has none). */
export interface ParentLinks<T> {
    read(id: string): T | undefined;
    idOf(row: T): string;
    parentOf(row: T): string | null | undefined;
}
/** The one sentence of a {@link ReplayLoss}, for every refusal and notice that states it. */
export declare function replayLossText(loss: ReplayLoss): string;
/**
 * The refusal of a walk that met a parent the log does not hold: `childId` names `missingParentId` as its parent. The stored log does not hold
 * together, so it is `corrupt_session`; it says where it broke, and `replayLoss` — what the replay that loaded the log dropped, when it dropped
 * any — is the evidence that the missing parent may be one of the records the replay could not read.
 */
export declare class LineageBreak extends SessionError {
    readonly missingParentId: string;
    readonly childId: string;
    readonly replayLoss?: ReplayLoss | undefined;
    constructor(missingParentId: string, childId: string, replayLoss?: ReplayLoss | undefined);
}
/**
 * The one walk up a log's parent chain: the rows from the root down to `start`, root first. The chain ends at a row with no parent, or at `floorId`
 * (a bounded window's root — its parent is not required to exist). A parent the log does not hold is a {@link LineageBreak} naming it, a chain that
 * returns to a row it already stood on is refused by the shared guard — both `corrupt_session`; neither is followed.
 */
export declare function pathToRoot<T>(start: T, links: ParentLinks<T>, floorId?: string | null): T[];
/** How a log row is read by `selectForkRows`: its entry id and its parent's (`null` = a root). */
export interface ForkRowShape<R> {
    idOf(row: R): string;
    parentOf(row: R): string | null;
}
/**
 * Picks the rows a fork copies out of a whole log (oldest first) and the new session's leaf — for a store that moves rows as bytes and has no
 * `SessionRepo.fork` to hand the answer to. `point` is `settledForkOptions`' answer: `{}` copies every row (other branches too) and keeps
 * `sourceLeafId`; `{ entryId, position: "at" }` copies the rows on the path from the root to that entry (the path, not a prefix of the log: other
 * branches stay behind) and the leaf is that entry. The rows keep their order.
 *
 * Refusals are the engine's, word for word: a fork point the log does not hold is `invalid_fork_target`, a parent missing part-way up the path (an empty
 * parent id included) or a chain that returns to a row it stood on is `corrupt_session` (the sentence `getPathToRoot` gives), and a fork point that
 * names an entry with a `position` other than `at` is refused `invalid_fork_target` — rows are copied only for the point the judge answers. A point with
 * no entry id is the whole-log form whatever else it carries, as `getEntriesToFork` reads it.
 */
export declare function selectForkRows<R>(rows: readonly R[], sourceLeafId: string | null, point: ForkPoint, shape: ForkRowShape<R>): {
    rows: R[];
    leafId: string | null;
};
