/** * Storage Abstraction Interfaces * * Enables CodeSeeker to work with either: * - Embedded storage (SQLite + graphology + lru-cache) - zero setup, default * - Server storage (PostgreSQL + Neo4j + Redis) - optional, for production * * All implementations support disk persistence for durability. */ export interface VectorDocument { id: string; projectId: string; filePath: string; content: string; embedding: number[]; metadata?: Record; createdAt: Date; updatedAt: Date; } export interface VectorSearchResult { document: VectorDocument; score: number; matchType: 'vector' | 'fts' | 'hybrid'; /** Debug info for verbose mode - score breakdown by source */ debug?: { vectorScore: number; textScore: number; pathMatch: boolean; matchSource: string; }; } export interface IVectorStore { /** Store or update a document with its embedding */ upsert(doc: Omit): Promise; /** Bulk upsert for efficiency */ upsertMany(docs: Array>): Promise; /** Search by vector similarity */ searchByVector(embedding: number[], projectId: string, limit?: number): Promise; /** Search by full-text query */ searchByText(query: string, projectId: string, limit?: number): Promise; /** Hybrid search (vector + FTS with RRF fusion) */ searchHybrid(query: string, embedding: number[], projectId: string, limit?: number): Promise; /** Delete documents for a project */ deleteByProject(projectId: string): Promise; /** Delete documents for specific files in a project (for incremental reindexing) */ deleteByFiles(projectId: string, filePaths: string[]): Promise; /** Delete a specific document */ delete(id: string): Promise; /** Get document/chunk count for a project */ count(projectId: string): Promise; /** Get unique file count for a project */ countFiles(projectId: string): Promise; /** Get stored file metadata for change detection (hash + mtime) */ getFileMetadata(projectId: string, filePath: string): Promise<{ fileHash: string; indexedAt: string; } | null>; /** Get all file hashes for a project (for incremental indexing) */ getFileHashes(projectId: string): Promise>; /** Get a single document by its ID (used by RAPTOR drift detection) */ getById(id: string): Promise; /** * Get embeddings grouped by file path for a set of files. * Returns a map of filePath → array of chunk embeddings (one per chunk). * Used by RaptorIndexingService to mean-pool directory embeddings. */ getFileEmbeddings(projectId: string, filePaths: string[]): Promise>; /** * Get all unique file paths indexed under a directory prefix. * Used by RAPTOR incremental update to discover current dir contents. * Excludes RAPTOR synthetic paths (those starting with '__raptor__/'). */ getFilePathsForDir(projectId: string, dirPath: string): Promise; /** * Delete all documents whose file_path starts with the given prefix. * Used to purge RAPTOR nodes before a full reindex. */ deleteByFilePathPrefix(projectId: string, prefix: string): Promise; /** Persist to disk (for embedded mode) */ flush(): Promise; /** Close connections and cleanup */ close(): Promise; } export interface GraphNode { id: string; type: 'file' | 'class' | 'function' | 'method' | 'variable' | 'import' | 'export'; name: string; filePath: string; projectId: string; properties?: Record; } export interface GraphEdge { id: string; source: string; target: string; type: 'imports' | 'exports' | 'calls' | 'extends' | 'implements' | 'contains' | 'uses' | 'depends_on'; properties?: Record; } export interface GraphQueryResult { nodes: GraphNode[]; edges: GraphEdge[]; } export interface IGraphStore { /** Add or update a node */ upsertNode(node: GraphNode): Promise; /** Add or update an edge */ upsertEdge(edge: GraphEdge): Promise; /** Bulk operations */ upsertNodes(nodes: GraphNode[]): Promise; upsertEdges(edges: GraphEdge[]): Promise; /** Find nodes by type and project */ findNodes(projectId: string, type?: GraphNode['type']): Promise; /** Find node by ID */ getNode(id: string): Promise; /** Get edges from/to a node */ getEdges(nodeId: string, direction?: 'in' | 'out' | 'both'): Promise; /** Find related nodes (1-hop neighbors) */ getNeighbors(nodeId: string, edgeType?: GraphEdge['type']): Promise; /** Find path between nodes */ findPath(sourceId: string, targetId: string, maxDepth?: number): Promise; /** Delete all nodes/edges for a project */ deleteByProject(projectId: string): Promise; /** Delete all nodes/edges for specific files in a project (incremental deletion) */ deleteByFilePaths(projectId: string, filePaths: string[]): Promise; /** Get node count for a project */ countNodes(projectId: string): Promise; /** Persist to disk (for embedded mode) */ flush(): Promise; /** Close and cleanup */ close(): Promise; } export interface CacheEntry { key: string; value: T; expiresAt?: Date; tags?: string[]; } export interface ICacheStore { /** Get a cached value */ get(key: string): Promise; /** Set a value with optional TTL (seconds) */ set(key: string, value: T, ttlSeconds?: number): Promise; /** Delete a cached value */ delete(key: string): Promise; /** Check if key exists */ has(key: string): Promise; /** Delete all keys matching a pattern */ deletePattern(pattern: string): Promise; /** Delete all keys with a specific tag */ deleteByTag(tag: string): Promise; /** Clear entire cache */ clear(): Promise; /** Get cache statistics */ stats(): Promise<{ size: number; hits: number; misses: number; }>; /** Persist to disk (for embedded mode) */ flush(): Promise; /** Close and cleanup */ close(): Promise; } export interface Project { id: string; name: string; path: string; createdAt: Date; updatedAt: Date; metadata?: Record; } export interface IProjectStore { /** Create or update a project */ upsert(project: Omit): Promise; /** Find project by path */ findByPath(path: string): Promise; /** Find project by ID */ findById(id: string): Promise; /** List all projects */ list(): Promise; /** Delete a project and all related data */ delete(id: string): Promise; /** Persist to disk */ flush(): Promise; /** Close and cleanup */ close(): Promise; } export interface TextDocument { id: string; projectId: string; filePath: string; content: string; metadata?: Record; } export interface TextSearchResult { document: TextDocument; score: number; matchedTerms: string[]; } export interface Synonym { term: string; synonyms: string[]; projectId?: string; } export interface ITextStore { /** Index a document for full-text search */ index(doc: TextDocument): Promise; /** Bulk index documents */ indexMany(docs: TextDocument[]): Promise; /** Search by text query with BM25 scoring */ search(query: string, projectId: string, limit?: number): Promise; /** Search with synonym expansion */ searchWithSynonyms(query: string, projectId: string, limit?: number): Promise; /** Remove a document from the index */ remove(id: string): Promise; /** Remove all documents for a project */ removeByProject(projectId: string): Promise; /** Add a synonym mapping */ addSynonym(term: string, synonyms: string[], projectId?: string): Promise; /** Remove a synonym mapping */ removeSynonym(term: string, projectId?: string): Promise; /** Get all synonyms */ getSynonyms(projectId?: string): Promise; /** Clear all synonyms */ clearSynonyms(projectId?: string): Promise; /** Get document count */ count(projectId: string): Promise; /** Persist to disk (for embedded mode) */ flush(): Promise; /** Close and cleanup */ close(): Promise; } export type StorageMode = 'embedded' | 'server'; export interface StorageConfig { mode: StorageMode; /** Directory for embedded storage files (default: ~/.codeseeker/data) */ dataDir?: string; /** Flush interval in seconds (default: 30) */ flushIntervalSeconds?: number; /** Server configuration (only used when mode === 'server') */ server?: { postgres?: { host: string; port: number; database: string; user: string; password: string; }; neo4j?: { uri: string; user: string; password: string; }; redis?: { host: string; port: number; password?: string; }; }; } export interface IStorageProvider { /** Get the vector store */ getVectorStore(): IVectorStore; /** Get the graph store */ getGraphStore(): IGraphStore; /** Get the cache store */ getCacheStore(): ICacheStore; /** Get the project store */ getProjectStore(): IProjectStore; /** Get the text store (full-text search) */ getTextStore(): ITextStore; /** Get current storage mode */ getMode(): StorageMode; /** Persist all stores to disk */ flushAll(): Promise; /** Close all connections */ closeAll(): Promise; /** Check if storage is healthy */ healthCheck(): Promise<{ healthy: boolean; details: Record; }>; } //# sourceMappingURL=interfaces.d.ts.map