/** * Semantic Search Orchestrator Service * Single Responsibility: Coordinate semantic search operations * * STORAGE MODES: * - Embedded (default): Uses SQLite for vectors + MiniSearch for text search * - Server: Uses PostgreSQL with pgvector for production deployments * * HYBRID SEARCH STRATEGY: * Combines multiple search methods and fuses results using Reciprocal Rank Fusion (RRF): * * 1. Vector Similarity - Semantic understanding of concepts * 2. MiniSearch Text Search - BM25 scoring with synonym expansion and CamelCase tokenization * 3. File Path Matching - Directory/filename pattern matching * * The hybrid approach solves the problem where: * - "command handler" doesn't match "controller" semantically * - But text search with synonym expansion (handler → controller) catches it * * NO FILE FALLBACK: If storage is unavailable or has no results, returns empty array. * Claude handles file discovery natively - we don't duplicate that functionality. */ export interface SemanticResult { file: string; type: string; similarity: number; content: string; lineStart?: number; lineEnd?: number; /** Debug info for verbose mode - score breakdown by source */ debug?: { vectorScore: number; textScore: number; pathMatch: boolean; matchSource: string; }; } export declare class SemanticSearchOrchestrator { private logger; private projectId?; private embeddingGenerator; private storageManager; private useEmbedded; private vectorStore?; private projectStore?; private graphStore?; /** Current query — set at the start of performSemanticSearch, used for symbol-name boosting */ private currentQuery; constructor(); /** * Initialize storage - checks if we should use embedded or server mode */ private initStorage; /** * Set project ID for scoped searches */ setProjectId(projectId: string): void; /** * Resolve project ID from storage by project path */ private resolveProjectId; /** * Perform HYBRID semantic search * Uses storage interface abstraction for both embedded and server modes * Combines vector similarity with keyword/synonym matching for better recall * Returns empty array if storage unavailable or no results - Claude handles file discovery natively */ performSemanticSearch(query: string, projectPath: string, searchType?: 'hybrid' | 'vector' | 'fts' | 'graph'): Promise; /** Minimum L2 RAPTOR node score to trust its directory hint */ private l2Threshold; /** Minimum number of results cascade must produce to skip fallback */ private cascadeMinResults; /** Minimum top-result score cascade must produce to skip fallback */ private cascadeTopScore; /** Override RAPTOR cascade thresholds — useful for tuning experiments. */ setRaptorConfig(config: { l2Threshold?: number; cascadeMinResults?: number; cascadeTopScore?: number; }): void; /** * Depth of graph neighbor expansion after hybrid search. * 0 = disabled, 1 = 1-hop (default), 2 = 2-hop (cross-file chains) */ private graphExpansionDepth; /** Configure graph expansion depth. 0 disables expansion entirely. */ setGraphExpansionDepth(depth: number): void; /** * Perform hybrid search using the storage interface abstraction. * Works for both embedded (SQLite + MiniSearch) and server (PostgreSQL + pgvector) modes. * * RAPTOR Cascade (post-processing): * 1. Run wide searchHybrid (one call, always happens) * 2. Extract RAPTOR L2 nodes from raw results * 3. If a high-confidence L2 node exists, post-filter real files to its dir(s) * 4. If the filtered set is thin or low-confidence, fall back to full wide results */ private performHybridSearchViaInterface; /** * Apply RAPTOR cascade post-filter. * Returns filtered SemanticResult[] when cascade is confident, null when falling back. */ private applyCascadeFilter; /** * Perform vector-only semantic search (pure embedding similarity, no BM25/path matching) */ private performVectorOnlySearch; /** * Perform text/FTS-only search (BM25 + synonyms, no vector similarity) */ private performTextOnlySearch; /** * Deduplicate raw VectorSearchResults by file path, apply multi-chunk boost, and map to SemanticResult[]. * Shared by all search modes (vector, fts, hybrid, graph) to ensure consistent scoring behaviour. */ private processRawResults; /** * Graph RAG: expand hybrid search results by following code relationship edges. * For each of the top-5 result files, lookup its graph node and collect neighbours * (files connected via imports/calls/extends). Appends new files at a discounted score. * @param depth 1 = 1-hop, 2 = 2-hop (follows neighbors of neighbors for cross-file chains) */ private expandWithGraphNeighbors; /** * Check if string is valid UUID */ private isValidUUID; /** * Format content from database with metadata */ private formatContent; /** * Determine file type based on path and name */ private determineFileType; } //# sourceMappingURL=semantic-search-orchestrator.d.ts.map