/** * Temporal memory database for InkOS truth files. * * Uses Node.js built-in SQLite (node:sqlite, Node 22+). * Stores facts with temporal validity (valid_from/valid_until chapter numbers), * enabling precise queries like "what did character X know in chapter 5?" * * Backward compatible: existing markdown truth files are still the primary * persistence layer. MemoryDB is an acceleration index built alongside them. */ export interface Fact { readonly id?: number; readonly subject: string; readonly predicate: string; readonly object: string; readonly validFromChapter: number; readonly validUntilChapter: number | null; readonly sourceChapter: number; } export interface StoredSummary { readonly chapter: number; readonly title: string; readonly characters: string; readonly events: string; readonly stateChanges: string; readonly hookActivity: string; readonly mood: string; readonly chapterType: string; } export interface StoredHook { readonly hookId: string; readonly startChapter: number; readonly type: string; readonly status: string; readonly lastAdvancedChapter: number; readonly expectedPayoff: string; readonly payoffTiming?: string; readonly notes: string; } export declare class MemoryDB { private db; constructor(bookDir: string); private migrate; private ensureColumn; /** Add a new fact. */ addFact(fact: Omit): number; /** Invalidate a fact (set valid_until). */ invalidateFact(id: number, untilChapter: number): void; /** Get all currently valid facts (valid_until is null). */ getCurrentFacts(): ReadonlyArray; /** Get facts about a specific subject that are valid at a given chapter. */ getFactsAt(subject: string, chapter: number): ReadonlyArray; /** Get all facts about a subject (including historical). */ getFactHistory(subject: string): ReadonlyArray; /** Search facts by predicate (e.g., all "location" facts). */ getFactsByPredicate(predicate: string): ReadonlyArray; /** Get facts relevant to a set of character names. */ getFactsForCharacters(names: ReadonlyArray): ReadonlyArray; replaceCurrentFacts(facts: ReadonlyArray>): void; resetFacts(): void; /** Upsert a chapter summary. */ upsertSummary(summary: StoredSummary): void; replaceSummaries(summaries: ReadonlyArray): void; /** Get summaries for a range of chapters. */ getSummaries(fromChapter: number, toChapter: number): ReadonlyArray; /** Get summaries matching any of the given character names. */ getSummariesByCharacters(names: ReadonlyArray): ReadonlyArray; /** Get total chapter count. */ getChapterCount(): number; /** Get the most recent N summaries. */ getRecentSummaries(count: number): ReadonlyArray; upsertHook(hook: StoredHook): void; replaceHooks(hooks: ReadonlyArray): void; getActiveHooks(): ReadonlyArray; close(): void; } //# sourceMappingURL=memory-db.d.ts.map