/** * Memoria Storage Layer * * SQLite + FTS5 storage for Foundation's advanced memory system. * Provides 5-tier memory hierarchy with full-text search and BM25 ranking. */ import Database from 'better-sqlite3'; export type MemoryTier = 'session' | 'project' | 'global' | 'note' | 'observation'; export type LinkType = 'depends_on' | 'extends' | 'reverts' | 'related' | 'contradicts'; export interface Memory { id: string; tier: MemoryTier; content: string; tags: string[]; related_files: string[]; session_id?: string; project_path?: string; created_at: number; accessed_at: number; access_count: number; metadata?: Record; } export interface MemoryLink { link_id: string; from_memory_id: string; to_memory_id: string; link_type: LinkType; created_at: number; valid_from: number; invalidated_at: number | null; } export interface InvalidateLinkResult { success: boolean; link: MemoryLink; warning?: string; } export interface SearchResult { memory: Memory; score: number; relevance_score: number; recency_score: number; tier_score: number; proximity_score: number; frequency_score: number; } export interface SearchOptions { query: string; tiers?: MemoryTier[]; limit?: number; context?: { current_file?: string; project_path?: string; }; } export interface MemoriaStats { total_memories: number; by_tier: Record; total_links: number; total_size_mb: number; oldest_memory: number; newest_memory: number; } export interface RescueStats { total_memories: number; by_category: Record; } export declare class MemoriaStorage { private db; private dbPath; constructor(dbPath: string); private initSchema; /** * Idempotent migration: ensures the memory_links table has link_id, * valid_from, and invalidated_at columns. Safe to run on both fresh DBs * (where the table was just created with all columns) and existing DBs * (where these columns may be absent). */ private _migrateLinksSchema; saveMemory(input: Omit): Memory; getMemory(id: string): Memory | null; deleteMemory(id: string): { success: boolean; deleted_links: number; }; search(options: SearchOptions): SearchResult[]; createLink(link: Omit & { validFrom?: number; }): MemoryLink; invalidateLink(linkId: string, at?: number): InvalidateLinkResult; getLinks(memoryId: string, asOf?: number): Record; getStats(): MemoriaStats; getRecent(options?: { limit?: number; tiers?: MemoryTier[]; }): SearchResult[]; private _getRecentRescue; private get rescueDbPath(); private _mapRescueCategory; private _searchRescueDB; getRescueStats(): RescueStats | null; getAllMemories(): Memory[]; getAllLinks(): MemoryLink[]; private rowToMemoryLink; private rowToMemory; /** * Expose the underlying SQLite database handle. * Used by TranscriptIngester to create its auxiliary tables * (transcript_ingest_state, transcript_dedup) in the same database file * without opening a second connection. */ getInternalDb(): Database.Database; close(): void; } //# sourceMappingURL=storage.d.ts.map