import { type MemoryControlObjectKind, type MemoryGovernanceDocName, type MemoryGovernanceStore } from "./types.js";
/** The carrier records a replica control plane still holds. */
export interface ReplicaControlPlaneStrays {
    /** The governance documents with a file (or a journal) in the replica. */
    readonly docs: readonly MemoryGovernanceDocName[];
    /** How many entries stand in each kind's directory of the replica (kinds with none are absent): the control objects, and whatever
     *  else stands where an object's record belongs — adoption refuses each of those by name, never skips it. */
    readonly objects: Readonly<Partial<Record<MemoryControlObjectKind, number>>>;
}
/** One record adoption handled: a document (`doc:<name>`) or an object (`<kind>/<name>`). */
export interface AdoptedControlRecord {
    readonly record: string;
    /** What the carrier holds now, never what became of the replica's copy: `"written"` ⇔ the carrier lacked the record
     *  and now holds the same value; `"converged"` ⇔ it already held the same value. */
    readonly outcome: "written" | "converged";
    /** sha-256 of the record as the replica held it: an object's bytes, a document's committed JSON value. */
    readonly digest: string;
}
/** {@link adoptReplicaControlPlane}'s answer. */
export interface ControlPlaneAdoptionReport {
    /** Records the carrier now holds with the replica's value. When `refused` is empty, the replica's copies of these are
     *  removed; otherwise the replica keeps every copy. */
    readonly adopted: readonly AdoptedControlRecord[];
    /** Records whose adoption did not complete, each with why — a different value already in the carrier, a record that
     *  could not be read or verified, a receipt row that could not be written (then the carrier may already hold the
     *  value, and a re-run converges it), or a replica copy that could not be removed once the carrier held it. */
    readonly refused: readonly {
        readonly record: string;
        readonly reason: string;
    }[];
}
/** The replica's body-less record of which of its records the carrier holds with the same value (one row per record and digest). */
export declare const CONTROL_PLANE_ADOPTION_FILE = "control-plane-adoption.json";
/** The carrier records `controlDir` holds — documents with a file or journal, objects by kind. An enumeration that
 *  fails throws `ControlPlaneCorruptError` (never an empty answer). */
export declare function replicaControlPlaneStrays(controlDir: string): ReplicaControlPlaneStrays;
/**
 * Hand the replica control plane's carrier records to `carrier` (see the module note). Answers what the carrier now
 * holds with the replica's value and what was refused; the replica's copies are removed only when nothing was refused.
 * When `carrier` is the File store over `controlDir` itself there is nothing to hand over and the answer is empty. A
 * `controlDir` that does not exist is refused (`ControlPlaneCorruptError`): the call is an operator's, over a path they
 * named, and a wrong path must not read as "nothing to adopt".
 */
export declare function adoptReplicaControlPlane(controlDir: string, carrier: MemoryGovernanceStore, opts?: {
    readonly now?: () => number;
}): Promise<ControlPlaneAdoptionReport>;
/** The replica's adoption receipt: one body-less row per adopted record (what, the digest of its bytes, when). */
export declare function readControlPlaneAdoptionReceipt(controlDir: string): ReadonlyArray<{
    readonly record: string;
    readonly digest: string;
    readonly at: number;
}>;
