/** * RAPTOR Hierarchical Indexing Service * * A code-native variant of RAPTOR (Recursive Abstractive Processing for * Tree-Organized Retrieval) that exploits the natural hierarchy of source code: * * chunk (file segment) → file → L2 (directory node) → L3 (root node) * * L2 nodes are created by mean-pooling the embeddings of all chunks within a * directory, placing the node at the semantic centroid of that directory's content. * No Claude CLI calls are needed — the centroid is computed from embeddings that * already exist in the vector store. * * L3 is the mean of all L2 embeddings, representing the entire project. * * During search, L2/L3 nodes live in the same vector store as regular chunks. * They surface naturally for abstract queries ("what does the auth package do?") * and are invisible for concrete queries ("find the JWT refresh function"). * * Incremental drift detection (used during sync): * 1. Structural hash (sha256 of sorted child file paths) — detects file additions/deletions * 2. Cosine distance between new pooled mean and stored RAPTOR embedding — * skips the update when drift is below DRIFT_SKIP_THRESHOLD */ import type { IVectorStore } from '../../../storage/interfaces'; export declare const RAPTOR_FILE_PREFIX = "__raptor__/"; export interface RaptorGenerationResult { l2NodesCreated: number; l3Created: boolean; durationMs: number; } export interface RaptorUpdateResult { updatedDirs: string[]; skippedDirs: string[]; l3Updated: boolean; } export declare class RaptorIndexingService { private logger; /** * Generate all RAPTOR nodes for a project immediately after file indexing. * Reads embeddings back from the vector store and mean-pools per directory. * Old RAPTOR nodes are purged first (idempotent on full reindex). */ generateForProject(projectPath: string, projectId: string, indexedFiles: string[], vectorStore: IVectorStore): Promise; /** * Incrementally update RAPTOR nodes after a set of file changes. * Uses structural hash + cosine drift to skip unnecessary regeneration. * * @param changedFiles Relative file paths that were created/modified/deleted * @param deletedFiles Relative file paths that were deleted (subset of changedFiles) */ updateForChanges(projectPath: string, projectId: string, changedFiles: string[], deletedFiles: string[], vectorStore: IVectorStore): Promise; private maybeUpdateL2Node; /** * Recompute the L3 root node by mean-pooling all current L2 embeddings. * Called only when at least one L2 node changed. */ private maybeUpdateL3Node; /** * Return synthetic filePaths of all current L2 nodes (excludes the L3 root). * Uses getFilePathsForDir with the __raptor__ prefix directory as root. */ private getRaptorL2Paths; private groupByDirectory; /** sha256 of the sorted file paths — cheap O(n log n), no parsing */ private computeStructuralHash; private meanPool; private cosineSimilarity; private buildL2Content; private buildL3Content; /** Deterministic ID for an L2 (directory) RAPTOR node */ makeL2Id(projectId: string, dirPath: string): string; /** Deterministic ID for the L3 (project root) RAPTOR node */ makeL3Id(projectId: string): string; /** * Utility: check whether a filePath represents a RAPTOR synthetic node. * Import and call this in the search layer to distinguish RAPTOR hits. */ static isRaptorPath(filePath: string): boolean; /** Strip the RAPTOR prefix, returning the real directory/root path */ static realPath(filePath: string): string; } //# sourceMappingURL=raptor-indexing-service.d.ts.map