import type { SymbolGraphFilePayload, SymbolGraphMeta, SymbolRef } from "../types.js";
export declare class LRUCache<K, V> {
    private readonly capacity;
    private map;
    constructor(capacity: number);
    get(key: K): V | undefined;
    set(key: K, value: V): void;
    delete(key: K): boolean;
    has(key: K): boolean;
    clear(): void;
    get size(): number;
    keys(): IterableIterator<K>;
}
export interface SymbolGraphCacheStats {
    fileLruSize: number;
    fileLruHits: number;
    fileLruMisses: number;
    nameIndexLoaded: boolean;
    reverseIndexLoaded: boolean;
}
export type SymbolGraphReaderToken = symbol;
export type SymbolGraphReaderRelease = (() => void) & {
    readonly token: SymbolGraphReaderToken;
};
export declare class SymbolGraphCache {
    readonly projectId: string;
    meta: SymbolGraphMeta;
    /** name → list of symbol refs (lazy-loaded as a whole) */
    private nameIndex;
    /** calleeSymbolId → set of caller symbol IDs (lazy-loaded as a whole) */
    private reverseSymbolIndex;
    /** calleeFile → set of caller files (derived from reverseSymbolIndex) */
    private reverseFileIndex;
    /** lazy per-file payloads, LRU-bounded */
    fileDataLru: LRUCache<string, SymbolGraphFilePayload>;
    private stats;
    private activeReaders;
    private readonly activeReaderTokens;
    constructor(projectId: string, meta: SymbolGraphMeta, lruCapacity?: number);
    /**
     * Acquire a reader lease for this cache instance.
     * While any reader lease is held, the generation backing this cache cannot be cleaned up.
     */
    acquireReader(operationToken?: SymbolGraphReaderToken): SymbolGraphReaderRelease;
    get activeReaderCount(): number;
    /** Get the full name index, loading all shards on first access. */
    getNameIndex(operationToken?: SymbolGraphReaderToken): Promise<Map<string, SymbolRef[]>>;
    /** Get the full reverse symbol index (calleeSymbolId -> Set<callerSymbolId>), loading all shards on first access. */
    getReverseSymbolIndex(operationToken?: SymbolGraphReaderToken): Promise<Map<string, Set<string>>>;
    /** Get the full reverse-call file index, derived from reverseSymbolIndex. */
    getReverseFileIndex(operationToken?: SymbolGraphReaderToken): Promise<Map<string, Set<string>>>;
    /** Get a per-file payload, hitting the LRU first then Qdrant. */
    getFilePayload(relativePath: string, operationToken?: SymbolGraphReaderToken): Promise<SymbolGraphFilePayload | null>;
    /** Invalidate cached state for a file (called by watcher on file changes). */
    invalidateFile(relativePath: string): void;
    /** Patch the in-memory name index for an updated file payload. */
    patchNameIndexForFile(oldPayload: SymbolGraphFilePayload | null, newPayload: SymbolGraphFilePayload): void;
    /** Patch the in-memory reverse-symbol and reverse-file indices for an updated file payload. */
    patchReverseFileIndexForFile(oldPayload: SymbolGraphFilePayload | null, newPayload: SymbolGraphFilePayload): void;
    /** Replace the cached payload for a file (used after rebuild of one file). */
    setFilePayload(payload: SymbolGraphFilePayload): void;
    getStats(): SymbolGraphCacheStats;
}
/** Extract the file portion from a SymbolNode.id (`file::qname#line`). */
export declare function symbolIdToFile(id: string): string | null;
/** Get or build the cache for a project (loads meta from Qdrant lazily). */
export declare function getSymbolGraphCache(projectId: string): Promise<SymbolGraphCache | null>;
/** Replace (or insert) the cache for a project — used after a fresh rebuild. */
export declare function setSymbolGraphCache(cache: SymbolGraphCache): void;
/** Remove a cached generation only if it is still the registry entry. */
export declare function dropSymbolGraphCacheGeneration(projectId: string, generation?: string): void;
/** Remove a project's cache from the registry. */
export declare function dropSymbolGraphCache(projectId: string): void;
/** Reset all caches (testing only). */
export declare function resetSymbolGraphCacheRegistry(): void;
//# sourceMappingURL=symbol-graph-cache.d.ts.map