/** * Durable index storage backed by the bundled Node.js SQLite module. * * Uses `node:sqlite` (DatabaseSync) — a zero-dependency, synchronous, * transactional, cross-platform backend with crash recovery. Lexical search uses * FTS5 when the bundled SQLite provides it; otherwise a pure-JS inverted index * supplies equivalent semantics. */ import type { IndexedFileRecord, WorkspaceIndexGeneration } from "./types.js"; interface PreparedQuery { get(...parameters: unknown[]): unknown; all(...parameters: unknown[]): unknown[]; run(...parameters: unknown[]): unknown; } interface DatabaseSyncLike { prepare(query: string): PreparedQuery; exec(query: string): void; close(): void; } export interface LexicalRow { rowid: number; snippet?: string; } /** Detects FTS5 availability in the current Node SQLite build. */ export declare function detectFts5(db: DatabaseSyncLike): boolean; /** * A workspace index database handle. */ export declare class WorkspaceDb { readonly db: DatabaseSyncLike; readonly workspaceId: string; readonly directory: string; readonly fts5: boolean; private generationCache; constructor(directory: string, workspaceId: string, db: DatabaseSyncLike, fts5: boolean); /** Open (creating if needed) the workspace DB. */ static open(directory: string, workspaceId: string): WorkspaceDb; private migrate; private installSchema; insertGeneration(gen: WorkspaceIndexGeneration): void; updateGenerationStatus(generationId: string, status: WorkspaceIndexGeneration["status"], completedAt?: string): void; getGeneration(generationId: string): WorkspaceIndexGeneration | undefined; /** Most recent generation with status ready (validation authority). */ currentReadyGeneration(): WorkspaceIndexGeneration | undefined; currentBuildingGeneration(): WorkspaceIndexGeneration | undefined; listGenerations(): WorkspaceIndexGeneration[]; private rowToGeneration; insertFile(gen: string, f: { fileId: string; path: string; languageId?: string; classification: string; contentSha256: string; sizeBytes: number; lineCount: number; gitBlobId?: string; isTracked: boolean; isGenerated: boolean; isSensitive: boolean; indexedAt: string; }): void; insertChunk(gen: string, c: { chunkId: string; fileId: string; contentSha256: string; startLine: number; endLine: number; startByte?: number; endByte?: number; languageId?: string; symbolId?: string; chunkKind: string; textHash: string; embeddingStatus: string; text?: string; }): void; insertSymbol(gen: string, s: { symbolId: string; fileId: string; name: string; qualifiedName?: string; kind: string; languageId: string; startLine: number; startCharacter: number; endLine: number; endCharacter: number; signatureHash?: string; containerSymbolId?: string; }): void; insertRelation(gen: string, r: { relationId: string; sourceSymbolId: string; targetSymbolId?: string; relationType: string; source: string; confidence: number; }): void; insertGitMeta(gen: string, fileId: string, g: { lastCommit?: string; commitTime?: string; changeCount: number; }): void; getFile(gen: string, fileId: string): IndexedFileRecord | undefined; /** Map of path → contentSha256 for the given generation. */ fileManifest(gen: string): Map; fileIdByPath(gen: string, relPath: string): string | undefined; chunkById(gen: string, chunkId: string): { chunkId: string; fileId: string; startLine: number; endLine: number; text?: string; symbolId?: string; chunkKind: string; } | undefined; chunksForFile(gen: string, fileId: string): Array<{ chunkId: string; startLine: number; endLine: number; text?: string; }>; symbolsForFile(gen: string, fileId: string): Array<{ symbolId: string; name: string; kind: string; startLine: number; endLine: number; }>; counts(generationId: string): { files: number; chunks: number; symbols: number; embeddings: number; }; begin(): void; commit(): void; rollback(): void; close(): void; getMeta(key: string): string | undefined; setMeta(key: string, value: string): void; /** Compute a stable manifest hash over the ready generation's file set. */ fileManifestHash(generationId: string): string; } export declare function newGenerationId(): string; export {}; //# sourceMappingURL=storage.d.ts.map