/** * MartinLoop Memory Store * * Append-only, never-overwriting persistent memory. Records user consent * signals, preferences, behavioral patterns, and learning outcomes so * MartinLoop gets smarter with every session. * * Design principles: * - Append-only JSONL — entries are never deleted or overwritten * - Structured by kind — each memory entry has a type and a key * - Source-aware — distinguishes explicit user input from inferred patterns * - Confidence-scored — inferred memories degrade gracefully * * Storage: /_martin/memory.jsonl */ export type MemoryKind = "consent" | "preference" | "pattern" | "feedback" | "budget" | "model"; export interface MemoryEntry { /** ISO-8601 timestamp */ timestamp: string; /** What kind of memory this is */ kind: MemoryKind; /** Dot-notated key, e.g. "model.direct.claude", "budget.auth.usd", "gate.bypassed" */ key: string; /** The memory payload */ value: unknown; /** Did the user say it explicitly, or did Martin observe it? */ source: "explicit" | "inferred"; /** Confidence score 0-1 — inferred memories should be < 0.8 */ confidence: number; } export interface MemorySummary { totalEntries: number; byKind: Partial>; recentPreferences: MemoryEntry[]; recentConsents: MemoryEntry[]; recentFeedback: MemoryEntry[]; } /** * Append a memory entry. Never overwrites — always appends. */ export declare function appendMemory(runsRoot: string, entry: MemoryEntry): Promise; /** * Read all memory entries in order (oldest first). */ export declare function readMemoryEntries(runsRoot: string): Promise; /** * Get the most recent memory entry for a specific key. * Returns undefined if no entry exists for that key. */ export declare function getPreference(runsRoot: string, key: string): Promise; /** * Build a summary of memory entries for MCP resource and MartinLoop context injection. * Returns the top 20 most recent entries per kind. */ export declare function buildMemorySummary(entries: MemoryEntry[]): MemorySummary; /** * Record a preference from user input. */ export declare function recordPreference(runsRoot: string, key: string, value: unknown, source?: "explicit" | "inferred"): Promise; /** * Record a consent signal (user approved or denied a governance action). */ export declare function recordConsent(runsRoot: string, action: string, approved: boolean, context?: Record): Promise;