import type { Entity, Relationship, Contradiction, FileRecord, Project, EntityQuery, GraphStats, IntegrityResult, GraphStore } from '@cortex/core'; export interface FileStatusBreakdown { ingested: number; failed: number; skipped: number; pending: number; } export interface FailedFile { path: string; relativePath: string; parseError: string; } export interface EntityBreakdown { type: string; count: number; avgConfidence: number; } export interface RelationshipBreakdown { type: string; count: number; } export interface ContradictionBreakdown { active: number; resolved: number; dismissed: number; highSeverity: number; mediumSeverity: number; lowSeverity: number; } export interface TopContradiction { id: string; severity: string; description: string; entityA: string; entityB: string; } export interface ReportData { generatedAt: string; fileStatus: FileStatusBreakdown; failedFiles: FailedFile[]; entityBreakdown: EntityBreakdown[]; supersededCount: number; relationshipBreakdown: RelationshipBreakdown[]; contradictions: ContradictionBreakdown; topContradictions: TopContradiction[]; tokenEstimate: { totalInput: number; totalOutput: number; }; } export interface SQLiteStoreOptions { dbPath?: string; walMode?: boolean; backupOnStartup?: boolean; } export declare class SQLiteStore implements GraphStore { private db; private dbPath; constructor(options?: SQLiteStoreOptions); private migrate; private backupSync; close(): void; transaction(fn: () => T): T; createEntitySync(entity: Omit): Entity; createEntity(entity: Omit): Promise; private _createEntity; getEntity(id: string): Promise; updateEntity(id: string, updates: Partial): Promise; deleteEntity(id: string, soft?: boolean): Promise; findEntities(query: EntityQuery): Promise; createRelationship(rel: Omit): Promise; getRelationship(id: string): Promise; getRelationshipsForEntity(entityId: string, direction?: 'in' | 'out' | 'both', limit?: number): Promise; getRelationshipsForEntities(entityIds: string[]): Promise; deleteRelationship(id: string): Promise; /** * Delete all entities (and their relationships + FTS entries) for a specific source file. * Used during re-ingestion to replace stale entities atomically. */ deleteEntitiesBySourceFile(sourceFile: string): { deletedEntities: number; deletedRelationships: number; }; /** * Atomically try to acquire a processing lock for a file path. * Returns true if lock acquired (status set to 'processing'), false if already locked. * Uses SQLite's atomic UPDATE to prevent races between concurrent processes. * projectId is required for new files (foreign key constraint on files table). */ tryAcquireFileLock(filePath: string, projectId: string): boolean; /** * Release a file processing lock (called after ingestion completes or fails). * The upsertFile() call at the end of ingestion will set the final status. */ releaseFileLock(filePath: string): void; deleteBySourcePath(pathPrefix: string): { deletedEntities: number; deletedRelationships: number; deletedFiles: number; }; resetDatabase(): void; pruneSoftDeleted(): { deletedEntities: number; deletedRelationships: number; }; upsertFile(file: Omit): Promise; /** * Check if a file has already been ingested with the given content hash. * Synchronous for use in cost estimation without async overhead. */ isFileCached(filePath: string, contentHash: string): boolean; getFile(path: string): Promise; getFilesByProject(projectId: string): Promise; getRecentFiles(sinceDays?: number, limit?: number): Promise; createProject(project: Omit): Promise; getProject(id: string): Promise; listProjects(): Promise; getProjectByName(name: string): Promise; deleteProject(id: string): Promise; createContradiction(contradiction: Omit): Promise; findContradictions(query?: { status?: Contradiction['status']; entityId?: string; limit?: number; }): Promise; updateContradiction(id: string, update: { status: Contradiction['status']; resolvedAction?: Contradiction['resolvedAction']; resolvedAt?: string; }): Promise; searchEntities(text: string, limit?: number): Promise; semanticSearch(_embedding: Float32Array, _limit?: number): Promise; getStats(): Promise; getReportData(): ReportData; backup(): Promise; integrityCheck(): Promise; insertTokenUsage(record: { id: string; requestId: string; task: string; provider: string; model: string; inputTokens: number; outputTokens: number; estimatedCostUsd: number; latencyMs: number; timestamp: string; }): void; getTokenUsage(since?: string): Array<{ id: string; request_id: string; task: string; provider: string; model: string; input_tokens: number; output_tokens: number; estimated_cost_usd: number; latency_ms: number; timestamp: string; }>; getTokenUsageSummary(since?: string): { totalCostUsd: number; totalInputTokens: number; totalOutputTokens: number; requestCount: number; }; getGraphData(options?: { projectId?: string; limit?: number; }): { nodes: Array<{ id: string; name: string; type: string; confidence: number; sourceFile: string; }>; edges: Array<{ id: string; source: string; target: string; type: string; confidence: number; }>; }; } //# sourceMappingURL=sqlite-store.d.ts.map