import type CodecPort from "../../../ports/CodecPort.ts";
import { type default as DirtyPageSet } from "./DirtyPageSet.ts";
import FlushResult from "./FlushResult.ts";
import type TrieStorePort from "./TrieStorePort.ts";
/**
 * Initializer for {@link TrieFlusher}.
 */
export interface TrieFlusherInit {
    readonly store: TrieStorePort;
    readonly codec: CodecPort;
}
/**
 * Persists a {@link DirtyPageSet} produced by `TrieCursor` into
 * the trie store, returning a new root OID and a summary of what
 * was written.
 *
 * The flusher is stateless between calls: every invocation takes
 * a fresh snapshot, walks it deterministically bottom-up, writes
 * leaves and branches via `TrieStorePort`, and returns a frozen
 * `FlushResult`. There is no partial-flush recovery; the caller
 * retries.
 *
 * ## Structural sharing
 *
 * A branch's child-OID map may point at:
 *
 * 1. A freshly-written OID from this flush (the common case for
 *    any dirty path).
 * 2. A clean-child OID recorded by the cursor during descent —
 *    the subtree was visited but not modified, so its OID is
 *    reused verbatim.
 * 3. An OID present on the branch itself that is not a `pending:`
 *    sentinel — the cursor rebuilt this branch for some other
 *    nibble but left the original child entry unchanged.
 *
 * ## Pending-OID resolution
 *
 * The cursor inserts `pending:<path-key>` sentinels when it
 * creates or rebinds a child slot it has not yet written. The
 * flusher must replace every sentinel before calling
 * `store.writeBranch`; any sentinel still present after the
 * walk raises `E_TRIE_FLUSH_UNRESOLVED`.
 *
 * ## Failure model
 *
 * Every failure surfaces as `TrieFlushError` with a typed code.
 * Store faults become `E_TRIE_FLUSH_STORE`; codec faults become
 * `E_TRIE_FLUSH_ENCODE`; resolution bugs become
 * `E_TRIE_FLUSH_UNRESOLVED`; anything else the flusher cannot
 * classify becomes `E_TRIE_FLUSH_STRUCTURE`.
 */
export default class TrieFlusher {
    #private;
    constructor(init: TrieFlusherInit);
    flush(dirty: DirtyPageSet): Promise<FlushResult>;
}
