Summary
Engram currently uses SQLite for everything (storage, FTS5, sqlite-vec). This works great for single-process and embedded use cases, but teams running multiple agent instances need a shared database.
A PostgreSQL adapter would enable multi-process and distributed deployments.
Design considerations
- The
MemoryStore class in src/store/store.ts is the abstraction boundary. A PG adapter should implement the same interface.
- PostgreSQL has
tsvector for full-text search (replaces FTS5)
- PostgreSQL has
pgvector extension for vector similarity search (replaces sqlite-vec)
- Migrations should be separate from SQLite migrations
- The adapter should be an optional dependency (don't break the zero-dependency SQLite default)
Suggested approach
- Extract a
StorageAdapter interface from the current MemoryStore methods
- Keep existing SQLite implementation as the default
- Add a new
pg-store.ts that implements the same interface using pg + pgvector
- Let users choose via config:
{ adapter: 'sqlite' | 'postgres', connectionString: '...' }
This is a significant contribution
This is a larger piece of work suited for someone comfortable with both SQLite and PostgreSQL. Happy to pair on the interface design before implementation starts — open a draft PR or comment here.
Acceptance criteria
Summary
Engram currently uses SQLite for everything (storage, FTS5, sqlite-vec). This works great for single-process and embedded use cases, but teams running multiple agent instances need a shared database.
A PostgreSQL adapter would enable multi-process and distributed deployments.
Design considerations
MemoryStoreclass insrc/store/store.tsis the abstraction boundary. A PG adapter should implement the same interface.tsvectorfor full-text search (replaces FTS5)pgvectorextension for vector similarity search (replaces sqlite-vec)Suggested approach
StorageAdapterinterface from the currentMemoryStoremethodspg-store.tsthat implements the same interface usingpg+pgvector{ adapter: 'sqlite' | 'postgres', connectionString: '...' }This is a significant contribution
This is a larger piece of work suited for someone comfortable with both SQLite and PostgreSQL. Happy to pair on the interface design before implementation starts — open a draft PR or comment here.
Acceptance criteria