Jarvis: Agent Memory on Postgres

Jarvis: Agent Memory on Postgres

Jarvis is the Supabase Postgres store my Claude Code agents read their rules from. Memory files sync into a typed table, session hooks load the hard rules at startup, a read-only MCP server and OAuth 2.1 expose the graph, and CI rebuilds the schema from 24 migrations on every change.

  • supabase
  • PostgREST
  • nextjs
  • MCP
  • python
  • GitHub Actions

Every agent session I start has to know the same things: which rules are hard, what was decided last week, and which decisions were reversed. Jarvis keeps that in Postgres instead of in a model's context, so the same answer comes back in every session and on every machine.

What it does

  • Memory spine. Each memory file is one row in a typed memories table with a tier (hard, medium, soft), a type (rule, pointer, boundary, outcome, context), a project and a topic. Tier and type are enforced by NOT NULL and CHECK constraints, and a GIN full-text index serves search.
  • Sync on push. A pre-push hook upserts changed memory files through PostgREST, keyed on the source file, so a rerun changes nothing.
  • Startup read. A SessionStart hook loads up to 25 hard-tier rules for the current repo. I cut medium rules from startup after measuring them at 6,319 characters a session over 7 days.
  • Knowledge graph. Nodes and edges with a controlled vocabulary held in tables, 13 kinds and 12 relations, so a new kind is an insert and a typo is rejected. Guarded upsert functions merge duplicates, skip dangling edges, and write a provenance row for each change.
  • Line-level history. A trigger splits every memory into lines and links, and an append-only revisions table records who changed what.
  • Detection views. Views flag reasoning that rests on a reversed decision, graph hygiene problems, and nodes due for re-verification.
  • Read-only MCP server. Six tools over the graph, behind a bearer token or an OAuth 2.1 flow with PKCE, plus a graph widget that renders in Claude and ChatGPT.

How it stays correct

  • Row-level security is on with no anon or authenticated policies. Two scoped login roles separate the read-only CI user from the writer.
  • CI builds a fresh database from all 24 migrations, runs an 8-check acceptance test, and diffs the live schema against a committed contract snapshot. An unverified check fails the build.
  • A weekly vendor-doc staleness check opens an issue when a doc is due.

Where it stands

My agents use the memory spine and its line-level history every session. I retired the LLM extraction loop that grew the graph from transcripts once the spine covered what sessions needed, and the vector columns sit in the schema with nothing writing them yet, so search runs on the full-text index.

More projects

Get in touch

Working end to end across design, creative, and engineering, where creativity, collaboration, and ownership build toward the company's goals.

jeffkliu@gmail.com