/** * SqliteCortexStore — local SQLite-backed implementation of CortexStore. * * Uses better-sqlite3 for synchronous SQLite access wrapped in async interface. * Vector search uses brute-force cosine similarity (sufficient for <10k memories). * Dates stored as ISO-8601 strings. Arrays stored as JSON text. */ import type { CortexStore, StoreCapabilities } from '../core/store.js'; import type { Memory, Observation, Edge, OpsEntry, OpsFilters, Signal, BeliefEntry, SearchResult, FSRSData, QueryFilter } from '../core/types.js'; export declare class SqliteCortexStore implements CortexStore { private db; private ns; private txnQueue; private inTransaction; constructor(dbPath: string, namespace?: string); private t; private createTables; /** Add columns introduced after initial schema. Safe to run repeatedly (no-ops on new DBs). */ private migrateSchema; putMemory(memory: Omit): Promise; getMemory(id: string): Promise; updateMemory(id: string, updates: Partial>): Promise; findNearest(embedding: number[], limit: number): Promise; touchMemory(id: string, fsrsUpdates: Partial): Promise; getAllMemories(): Promise; getRecentMemories(days: number, limit: number): Promise; putObservation(obs: Omit): Promise; getUnprocessedObservations(limit: number): Promise; markObservationProcessed(id: string): Promise; putEdge(edge: Omit): Promise; getEdgesFrom(memoryId: string): Promise; getEdgesForMemories(memoryIds: string[]): Promise; appendOps(entry: Omit): Promise; queryOps(filters: OpsFilters): Promise; updateOps(id: string, updates: Partial>): Promise; putSignal(signal: Omit): Promise; putBelief(entry: Omit): Promise; getBeliefHistory(conceptId: string): Promise; put(collection: string, doc: Record): Promise; get(collection: string, id: string): Promise | null>; update(collection: string, id: string, updates: Record): Promise; query(collection: string, filters: QueryFilter[], options?: { limit?: number; orderBy?: string; orderDir?: 'asc' | 'desc'; }): Promise[]>; countDocuments(collection: string, filters?: QueryFilter[]): Promise; delete(collection: string, id: string): Promise; /** * Manual BEGIN IMMEDIATE / COMMIT / ROLLBACK rather than better-sqlite3's * db.transaction() wrapper. The wrapper is purely synchronous and commits * the moment the sync callback returns — it cannot survive an await * suspension inside an async user closure, and refuses outright if the * closure returns a Promise. Manual statements let the closure await store * ops correctly. * * Concurrent calls are serialized through a Promise-chained queue: only * one transaction is in flight at a time per store instance. Without this, * two parallel BEGINs would race and the second would throw SQLITE_ERROR * "cannot start a transaction within a transaction". * * Hard constraint on fn: avoid awaits to external systems (LLM, network). * They hold the transaction open and block every other writer through the * queue. Store ops are fine — they are sync under their async wrapper. * * Nested calls on the same store are forbidden and rejected explicitly. * See docs/concurrency.md. */ withTransaction(fn: (txn: CortexStore) => Promise): Promise; upsertMemory(memory: Memory): Promise; upsertObservation(obs: Observation): Promise; upsertEdge(edge: Edge): Promise; upsertOpsEntry(entry: OpsEntry): Promise; upsertSignal(signal: Signal): Promise; upsertBelief(belief: BeliefEntry): Promise; getCapabilities(): Promise; } //# sourceMappingURL=sqlite.d.ts.map