/** * BRAIN Search — Layer 1 compact search + budget-aware hybrid retrieval. * * Provides two search entry points: * - searchBrainCompact: token-efficient index-level search (~50 tokens/hit) * - retrieveWithBudget: multi-strategy (FTS5 + vector + graph) within a token budget * * @task T5131 * @epic T5149 */ import type { BudgetedResult, BudgetedRetrievalOptions, SearchBrainCompactParams, SearchBrainCompactResult } from '@cleocode/contracts'; export type { BudgetedEntry, BudgetedResult, BudgetedRetrievalOptions } from '@cleocode/contracts'; /** * Token-efficient compact search across BRAIN tables. * Returns index-level hits (~50 tokens per result). * * Delegates to searchBrain() from brain-search.ts for FTS5/LIKE search, * then projects results to a compact format with optional date filtering. * * @param projectRoot - Project root directory * @param params - Search parameters * @returns Compact search results with token estimate * * @example * ```ts * // Search for observations related to authentication decisions. * // Returns compact hits (~50 tokens each) from BRAIN tables. * const result = await searchBrainCompact('/path/to/project', { * query: 'authentication decisions', * limit: 5, * tables: ['decisions', 'observations'], * }); * * // Result shape: { results: BrainCompactHit[], total: number, tokensEstimated: number } * console.assert(typeof result.total === 'number', 'total is a number'); * console.assert(Array.isArray(result.results), 'results is an array'); * console.assert(typeof result.tokensEstimated === 'number', 'tokensEstimated present'); * ``` */ export declare function searchBrainCompact(projectRoot: string, params: SearchBrainCompactParams): Promise; /** * Budget-aware hybrid retrieval combining FTS5, vector KNN, and graph neighbor scores. * * Strategy (parallel where possible): * A. FTS5 BM25 search (always) — keyword precision (50% weight) * B. Vector KNN search (optional) — semantic recall (40% weight, skipped if no embeddings) * C. Graph neighbors (optional) — associative context (10% weight, skipped if graph empty) * * Score fusion: final = (fts*0.50 + vec*0.40 + graph*0.10) × qualityScore * Recency boost: +0.05 for entries updated in last 7 days. * Type priority: procedural entries get +0.10 (always-useful rules). * * Budget enforcement: * - Rank top-50 candidates by fused score. * - Walk list, accumulate token cost (≈ textLen/4), stop at budget. * - Episodic entries dropped first when budget is tight. * * Citation tracking: increments citationCount for returned entries in background (setImmediate). * * @param projectRoot - Project root directory * @param query - Text to search for * @param tokenBudget - Maximum tokens to spend on results (default 500) * @param options - Optional filters (types, tiers, verified) * @returns Retrieved entries within budget with token accounting */ export declare function retrieveWithBudget(projectRoot: string, query: string, tokenBudget?: number, options?: BudgetedRetrievalOptions): Promise; //# sourceMappingURL=search.d.ts.map