import { type SessionTreeEntry } from "../harness/types.js"; /** * The SINGLE invariant gate for cross-backend session IMPORT (2c session-sync, service [266]②), as a STREAMING * online validator — feed entries oldest-first via {@link step}, then {@link finish}. The 2c NDJSON path imports * entries as a stream (keyset pages, no whole-array buffer), so the gate must be incremental; the array form * {@link validateEntriesForImport} is a thin wrapper over this (ONE source of truth — fork/tests keep the array * API). Fail-CLOSED: the first violation throws `SessionError("invalid_session")` and the caller writes nothing. * * Invariants enforced (the session-tree contract — see `storage-base.ts` getPathToRoot/appendEntry): * 1. Unique entry ids. * 2. Append order = parent-before-child: every non-null `parentId` MUST reference an entry stepped EARLIER. This * is also the floor-truncation tripwire — if the export silently dropped pre-floor entries (the `getEntries()` * tail-only bug), a tail entry's parent would be absent → throw, instead of a broken headless tree. * 3. Exactly one root (a single `parentId === null` entry) for a non-empty log — checked at `finish`. * 4. The derived leaf (after the last entry) resolves to a stepped entry — checked at `finish`. * * The validator NEVER rewrites entries — ids/parents/timestamps are preserved verbatim (the caller re-stamps only * the owner). It is single-use: `step` after `finish`, or a second `finish`, throws. */ export declare class StreamingImportValidator { private readonly seen; private rootCount; private runningLeaf; private done; /** Validate ONE entry, in oldest-first order. Throws `SessionError("invalid_session")` on the first violation * (duplicate id, or a parent/structural reference not stepped before this entry). */ step(entry: SessionTreeEntry): void; /** Finalize the stream: exactly one root (for a non-empty log) + the derived leaf resolves to a stepped entry. * Returns the resolved leaf id (null for an empty session). Throws on violation; single-use. */ finish(): { leafId: string | null; }; } /** * Validate a verbatim session-entry log for cross-backend IMPORT (2c session-sync, service [266]②). The ARRAY * form of {@link StreamingImportValidator} (ONE source of truth — this just drives step()/finish() over the * array, kept for `fork`/tests that already hold the whole log). Fail-CLOSED: any violation throws * `SessionError("invalid_session")` and nothing is written. * * Returns the entries VERBATIM (validated, never rewritten — ids/parents/timestamps preserved so the imported * session is byte-identical to the source; only the owner is re-stamped by the caller, not here). */ export declare function validateEntriesForImport(entries: SessionTreeEntry[]): SessionTreeEntry[]; //# sourceMappingURL=import-validate.d.ts.map