/**
 * The content-addressed session store.
 *
 * History is kept as an immutable DAG: each {@link SessionNode} carries one turn
 * and points at its parent by hash, so a node's `id` is a content hash of its
 * turn plus its lineage. Branching is just two nodes sharing a parent; the
 * linear context for a model call is the path from a leaf back to the root,
 * reversed. A {@link SessionHead} names the current leaf of a session, and a
 * {@link Migrator} upgrades stored records across schema versions.
 */
import type { Turn } from "../../llmgateway/contract";
/** One immutable node in the session DAG. */
export interface SessionNode {
    /** Content hash of this node (over its turn and parent), serving as its id. */
    readonly id: string;
    /** The hash of the parent node, or `null` for a root. */
    readonly parent: string | null;
    /** The conversation turn this node carries. */
    readonly turn: Turn;
    /** Wall-clock creation time, in epoch milliseconds. */
    readonly createdAt: number;
}
/** Names the current tip of a session within the store. */
export interface SessionHead {
    /** The session this head belongs to. */
    readonly sessionId: string;
    /** The hash of the leaf node the session currently points at. */
    readonly leaf: string;
}
/**
 * A single schema-upgrade step.
 *
 * Migrators are composed in sequence: each takes a raw record at version N and
 * returns it shaped for version N+1. `id` identifies the step for logging and
 * idempotency.
 */
export interface Migrator {
    /** Stable identifier for this migration step. */
    readonly id: string;
    /** Transform one raw stored record forward by one schema version. */
    upgrade(raw: unknown): unknown;
}
