import type { Card } from "../db/schema.js"; export interface SearchResult { card: Card; score: number; source: "semantic" | "keyword" | "both"; } /** * Checks the metrics table for a recent query whose embedding has cosine * similarity > 0.92 with the current query. If found, returns the same * cards that were served for that query (a semantic cache hit). */ export declare function checkCache(query: string): Promise; /** * Reciprocal Rank Fusion score across multiple retrieval lists. * Standard RRF formula: Σ 1/(k + rank_i), k=60 per Cormack et al. (2009). * A card appearing in two lists at rank 0 scores ~0.033 (vs 0.016 for one). */ export declare function computeRrfScore(ranks: number[], k?: number): number; /** * Score-weighted RRF: blends the standard rank-based RRF with normalized raw * scores (cosine similarity for semantic, normalized BM25 for keyword). * * Pure RRF ignores that rank-0 distance=0.05 is a much stronger match than * rank-0 distance=0.40. This blend adds a small score-proportional bonus * (weight=0.25) on top of the rank signal (weight=0.75), preserving the * rank ordering while rewarding strong confidence matches. * * @param ranks - 0-based rank positions from each retrieval list * @param normalizedScores - scores in [0,1] where 1 = best (cosine similarity or normalized BM25) */ export declare function computeWeightedRrfScore(ranks: number[], normalizedScores: number[], k?: number): number; /** * Runs semantic and keyword search in parallel, then fuses results with: * - Semantic weight: 0.7, keyword weight: 0.3 * - 1.2x boost for cards appearing in both result sets * - Card-type multiplier (hubs penalized at 0.4x) * - Usage-count logarithmic boost * - Specificity_score boost (populated after centroid computation) * - Repo-affinity multiplier (text signals + embedding-based classifier) * * @param semanticQuery - optional override for the query used in semantic * search only (BM25 always uses the original query). Used for prefix- * boosted embeddings in codeprism_context. */ export declare function hybridSearch(query: string, options?: { branch?: string; limit?: number; semanticQuery?: string; skipUsageUpdate?: boolean; }): Promise; //# sourceMappingURL=hybrid.d.ts.map