import { type CatalogEntry } from "./compact-catalog-codec.ts";
import type { CompactContentStore, LeafId } from "./compact-content-store.ts";
import { type FrozenBytes } from "./compact-recovery-bytes.ts";
import { type ContentDigest, type ContentRef } from "./compact-recovery-ids.ts";
/** One component as a family adapter yields it: its stored leaves in order and the owner that keeps them pinned. */
export interface CatalogComponent {
    readonly kind: CatalogEntry["kind"];
    readonly id: CatalogEntry["id"];
    readonly leaves: readonly LeafId[];
    readonly owner: LeafId;
}
/** A built catalog: the root node, the head of its private pointer leaves and the one owner of the whole tree. */
export interface CatalogRoot {
    readonly ref: ContentRef;
    readonly node: LeafId;
    readonly side: LeafId;
    readonly sideDigest: ContentDigest;
    readonly owner: LeafId;
    readonly digest: ContentDigest;
    readonly length: number;
    readonly depth: number;
    readonly components: number;
    readonly nodes: number;
}
export type CatalogRead = {
    readonly kind: "node";
    readonly ref: ContentRef;
    readonly entries: readonly CatalogEntry[];
    readonly digest: ContentDigest;
    readonly length: number;
} | {
    readonly kind: "component";
    readonly ref: ContentRef;
    readonly entry: CatalogEntry;
    readonly bytes: FrozenBytes;
};
/** The byte source of a read that must be a component; a node under a page ref is `range`. */
export declare function componentBytes(read: CatalogRead): FrozenBytes;
/**
 * Builds and reads immutable catalog trees (R4.B1): nodes are packed bottom-up as components stream in, so at most
 * one open node per level is resident and no collection of every component exists. Every node is one store leaf
 * plus its pointer leaves, under one owner that shares the pinned content it describes; releasing the root owner
 * releases the tree. Every reference the build itself takes (a node or pointer leaf, a sealed node's owner, and a
 * level-0 component's owner from the moment it is placed) is in `held` from the call that creates it until a
 * parent owner takes it over, so a failure at any point, the root read included, releases all of them and reports
 * no root. A component's producer may drop its own reference once `build` has consumed the component.
 */
export declare class CompactRecoveryCatalog {
    private buffered;
    /** The most descriptors resident at once across builds; a test instrument for the X04 working-set bound. */
    peakBuffered: number;
    build(store: CompactContentStore, ref: ContentRef, components: Iterable<CatalogComponent> | AsyncIterable<CatalogComponent>, valid?: () => void): Promise<CatalogRoot>;
    /**
     * Verifies the stored bytes of every node on the path against its parent's digest before decoding it; a component
     * is verified the same way and returned as a byte source, never as its joined text (S11a, carry 43). `valid` runs
     * between the component's leaf reads; `signal` stops the component's verification (RULING-69 (2)).
     */
    read(store: CompactContentStore, root: CatalogRoot, ref: ContentRef, valid?: () => void, signal?: AbortSignal): Promise<CatalogRead>;
    release(store: CompactContentStore, root: CatalogRoot): void;
    /** Reads a leaf a stored pointer names: the tree owner keeps it alive, so a missing one is corruption. */
    private stored;
    private describe;
    private root;
}
//# sourceMappingURL=compact-recovery-catalog.d.ts.map