/**
 * Streaming bitmap index builder with memory-bounded operation.
 *
 * Flushes bitmap data to storage when memory exceeds a threshold,
 * then merges multi-chunk shards at finalization. Delegates bitmap
 * accumulation to BitmapAccumulator.
 *
 * Shard format: plain CBOR via CodecPort. No envelopes, no checksums —
 * git-cas handles integrity at the storage layer.
 *
 * @module domain/services/index/StreamingBitmapIndexBuilder
 */
import type CodecPort from '../../../ports/CodecPort.ts';
import type LoggerPort from '../../../ports/LoggerPort.ts';
import type StreamingIndexStoragePort from '../../../ports/StreamingIndexStoragePort.ts';
export type FlushStats = {
    flushedBytes: number;
    totalFlushedBytes: number;
    flushCount: number;
};
export type BuilderOptions = {
    storage: StreamingIndexStoragePort;
    maxMemoryBytes?: number;
    onFlush?: (stats: FlushStats) => void;
    logger?: LoggerPort;
    codec?: CodecPort;
};
export default class StreamingBitmapIndexBuilder {
    private readonly _storage;
    private readonly _codec;
    private readonly _logger;
    private readonly _maxMemoryBytes;
    private readonly _onFlush;
    private readonly _accumulator;
    private readonly _flushedChunks;
    private _totalFlushedBytes;
    private _flushCount;
    constructor(options: BuilderOptions);
    private static _validate;
    private static _assertStorage;
    private static _assertMaxMemory;
    /** Registers a node and returns its numeric ID. */
    registerNode(sha: string): Promise<number>;
    /** Adds a directed edge. May trigger flush if memory threshold exceeded. */
    addEdge(srcSha: string, tgtSha: string): Promise<void>;
    /** Flushes in-memory bitmaps to storage as CBOR shard blobs. */
    flush(): Promise<void>;
    /** Returns current memory statistics for monitoring. */
    getMemoryStats(): {
        estimatedBitmapBytes: number;
        estimatedMappingBytes: number;
        totalFlushedBytes: number;
        flushCount: number;
        nodeCount: number;
        bitmapCount: number;
    };
    /**
     * Finalizes the index: flush remaining data, merge chunks, write tree.
     * Returns the OID of the Git tree containing the complete index.
     */
    finalize(options?: {
        signal?: AbortSignal;
        frontier?: Map<string, string>;
    }): Promise<string>;
    private _buildAllEntries;
    private _writeAndLogTree;
    private _writeShardsToStorage;
    private _writeMetaShards;
    private _processBitmapShards;
    private _chunkPath;
    private _writeFrontierEntries;
}
