/** * Shared snapshot diff computation for session memory history. * * Compare two MemoryHistorySnapshot states to derive what changed between them. * Because persistence is snapshot-based (not event-sourced), each snapshot * represents the complete memory state at that point in time. * * This diff is derived from adjacent real persisted snapshots and is NOT * a true operation log — it cannot tell you which specific add/update/delete * operation produced a given change. */ import type { MemoryHistorySnapshot } from "./memory.js"; /** A key present only in the current snapshot (added) */ export interface DiffAdded { type: "added"; key: string; value: string; } /** A key present only in the previous snapshot (removed) */ export interface DiffRemoved { type: "removed"; key: string; value: string; } /** A key present in both snapshots, but with different values */ export interface DiffChanged { type: "changed"; key: string; previousValue: string; currentValue: string; } /** Result of comparing two memory snapshots */ export interface MemorySnapshotDiff { /** Keys that exist only in the current snapshot */ added: DiffAdded[]; /** Keys that exist only in the previous snapshot */ removed: DiffRemoved[]; /** Keys that exist in both snapshots but have different values */ changed: DiffChanged[]; /** True when previous was undefined (current is the initial/earliest snapshot) */ isInitialSnapshot: boolean; } /** * Compute the diff between two memory snapshots. * * Semantics: * - `added`: key only in current (not in previous) * - `removed`: key only in previous (not in current) * - `changed`: key in both, value strings differ * - Unchanged keys are omitted from the result * * If `previous` is undefined (initial snapshot / nothing to diff against), * all current keys are treated as added and `isInitialSnapshot` is set to true. * * @param previous - The earlier snapshot (or undefined for initial state) * @param current - The later snapshot */ export declare function computeMemorySnapshotDiff(previous: MemoryHistorySnapshot | undefined, current: MemoryHistorySnapshot): MemorySnapshotDiff; //# sourceMappingURL=memory-diff.d.ts.map