import { Database } from '../runtime/sqlite'; /** * Graph cache metadata structure stored in the metadata file */ export interface GraphCacheMetadata { projectId: string; cwd: string; createdAt: number; /** Timestamp of the last successful full scan */ lastIndexedAt?: number; /** Number of files indexed in the last successful full scan */ indexedFileCount?: number; /** Maximum mtime of indexed files in the last successful full scan */ indexedMaxMtimeMs?: number; /** Branch name at last successful index or branch switch */ lastBranch?: string; } /** * Opens a managed graph database with integrity verification. * If integrity check fails or opening throws a corruption error, deletes the corrupted DB files * and recreates a fresh database. * * @param dbPath - Path to the database file * @returns A fresh or recovered Database instance */ export declare function openGraphDatabase(dbPath: string): Database; /** * Opens the graph database in read-only mode for follower processes * (Phase 5 read-only fast path). Does NOT alter schema, does NOT run * integrity checks, does NOT delete the file on failure — the leader is * solely responsible for bootstrap and repair. If the file does not * exist, throws (callers must ensure the leader is up first). * * Readonly connections can safely coexist with the leader's write handle * under WAL mode: readers see a snapshot at the time they begin each * transaction (prepare/run), and never block or get blocked by writes. * * `busy_timeout` is still set so that a rare lock-file checkpoint from * the writer doesn't return SQLITE_BUSY instantly. */ export declare function openGraphDatabaseReadOnly(dbPath: string): Database; /** * Ensures the graph directory and metadata file exist, returning the database path. * Does NOT open a database connection — the worker thread is the sole DB owner. */ export declare function ensureGraphDirectory(projectId: string, dataDir: string, cwd?: string): string; /** * Initialize the graph database with the full schema * Database location: /graph//graph.db */ export declare function initializeGraphDatabase(projectId: string, dataDir: string, cwd?: string): Database; /** * Reads graph cache metadata from a graph directory. * * @param graphDir - The graph cache directory path * @returns The metadata object or null if not found/readable */ export declare function readGraphCacheMetadata(graphDir: string): GraphCacheMetadata | null; /** * Writes graph cache metadata to a graph directory. * Updates the metadata file with the provided fields, preserving existing data. * * @param graphDir - The graph cache directory path * @param metadata - The metadata fields to update * @returns true if successful, false otherwise */ export declare function writeGraphCacheMetadata(graphDir: string, metadata: Partial): boolean; /** * Close all graph database instances */ export declare function closeGraphDatabase(): void; //# sourceMappingURL=database.d.ts.map