/** * Darwin — PostgreSQL Memory Provider * * Production-grade storage for experiments, prompt versions, learnings, and state. * Uses node-postgres (pg) with connection pooling. No ORM, no extra deps. * * Features over SQLite: * - Connection pooling (concurrent agents) * - Full-text search via tsvector (no FTS5 equivalent needed) * - JSONB for state (queryable, indexable) * - TIMESTAMPTZ for proper timezone handling * - Row-level locking for updateState() atomicity * * Requires: DARWIN_POSTGRES_URL or config.postgresUrl */ import type { DarwinExperiment, DarwinState, Learning, MemoryProvider, PromptVersion, DarwinConfig } from '../types.js'; export declare class PostgresMemoryProvider implements MemoryProvider { private pool; private readonly connectionString; private readonly dataDir; constructor(config: DarwinConfig); init(): Promise; close(): Promise; saveExperiment(exp: DarwinExperiment): Promise; loadExperiments(agentName: string, limit?: number): Promise; savePromptVersion(pv: PromptVersion): Promise; getActivePrompt(agentName: string): Promise; getAllPromptVersions(agentName: string): Promise; saveLearning(learning: Learning): Promise; searchLearnings(query: string, limit?: number): Promise; getState(): Promise; saveState(state: DarwinState): Promise; /** * Atomically read-modify-write the Darwin state. * Uses SELECT FOR UPDATE to acquire a row-level lock. */ updateState(fn: (state: DarwinState) => DarwinState): Promise; private getPool; private createTables; /** * Automatically migrate data from SQLite when: * 1. A SQLite DB file exists at {dataDir}/.darwin/darwin.db * 2. PostgreSQL has no prompt versions yet (fresh/empty) * * This prevents the data loss path where switching to postgres causes * the system to re-seed v1 and lose the v2→v3 prompt history. * * Migration is idempotent: if postgres already has data, it's a no-op. */ private autoMigrateFromSqlite; } //# sourceMappingURL=postgres-memory.d.ts.map