/**
 * Index node operations for incremental bitmap index updates.
 *
 * Handles node add/remove/purge against mutable WorkingMetaShard
 * and EdgeShardData caches. Stateless — all state is owned by
 * the IncrementalIndexUpdater orchestrator.
 *
 * @module domain/services/index/IndexNodeUpdater
 */
import type { WorkingMetaShard, EdgeShardData } from './types.ts';
/** Context for purging edge bitmaps of a dead node. */
export type PurgeContext = {
    readonly fwdCache: Map<string, EdgeShardData>;
    readonly revCache: Map<string, EdgeShardData>;
    readonly getOrLoadMeta: (shardKey: string) => WorkingMetaShard;
    readonly getOrLoadEdgeShard: (cache: Map<string, EdgeShardData>, dir: string, shardKey: string) => EdgeShardData;
};
/**
 * Handles node-level index mutations: add, remove, and edge purge.
 */
export default class IndexNodeUpdater {
    /**
     * Allocates or reactivates a globalId for a node and sets the alive bit.
     *
     * If the node already has a globalId (re-add), the existing ID is reused
     * and the alive bit is set. Otherwise a new globalId is allocated.
     *
     * @throws {ShardIdOverflowError} If the shard exceeds 2^24 local IDs.
     */
    handleNodeAdd(nodeId: string, shardKey: string, meta: WorkingMetaShard): void;
    /**
     * Clears the alive bit for a node but keeps its globalId stable.
     */
    handleNodeRemove(nodeId: string, meta: WorkingMetaShard): void;
    /**
     * Purges all edge bitmap entries that reference a removed node.
     *
     * When a node is removed, edges touching it become invisible even if
     * the edge itself is alive in the ORSet. Scans forward and reverse
     * shards, zeroing the dead node's bitmaps and removing it from peers.
     */
    purgeNodeEdges(deadNodeId: string, ctx: PurgeContext): void;
    /**
     * Looks up a globalId for a nodeId via the O(1) forward map.
     */
    findGlobalId(meta: WorkingMetaShard, nodeId: string): number | undefined;
    /**
     * Reverse-looks up a nodeId from a globalId using the shard byte encoding.
     */
    findNodeIdByGlobal(globalId: number, getOrLoadMeta: (shardKey: string) => WorkingMetaShard): string | undefined;
    /**
     * Purges edge bitmaps in one direction for a dead node, and removes
     * the dead node's globalId from the opposite direction's peer bitmaps.
     */
    private _purgeDirection;
    /**
     * Clears a bitmap entry for the dead node and returns the peer globalIds.
     */
    private _clearBitmapAndCollectPeers;
    /**
     * Removes deadGid from each peer's bitmap in the opposite direction.
     */
    private _removePeerReferences;
}
