Saurabh Singh
All work

MemLore · in development Creator 2026

MemLore: Governed Context for Coding Agents over MCP

An engineering intelligence layer, in active development, that gives coding agents in Cursor, Claude Code, and Codex the team's current, evidenced decisions over MCP, instead of whatever text happens to be most similar.

Key outcomes

Stable MCP tools
10
Feature specifications
48
Lines of Go
51K

Problem

Coding agents read the repository but cannot tell which era of truth they are in. A large codebase holds superseded ADRs, obsolete comments, half-finished migrations, and agent-written notes side by side. Generic AI memory and vector search return all of them with equal weight, so agents confidently produce patches that violate decisions the team already made. Specs and ADRs capture intent well, but nothing ranks that intent, keeps it current, or fits it into a context window for the task at hand.

Before → after

  • Agent context

    BeforeSimilarity search returns the ADR, the stale comment, and the half-migrated PR

    AfterTask-sized context packet ranked by authority, time, and scope

  • Agent-written knowledge

    BeforeA model's note reads like policy in the next session

    AfterAgent inference stays unverified until a human accepts it

Why not generic AI memory

Engineering context is not generic text. It has a source (human, ADR, git, agent), a rank (verified beats inferred), a time (superseded should not win), and a scope (one team's folklore should not leak into another's service). It can also disagree with the code without half the story being erased.

MemLore treats each of those as data rather than hoping similarity search gets them right. Decisions are first-class objects with a question, choice, owner, scope, and lifecycle, and “why” queries return an honest empty answer rather than a fabricated one.

Stack

  • Go core: REST API, stdio MCP server, CLI, goose migrations, outbox worker, OIDC and RBAC.
  • PostgreSQL governance plane with sqlc-generated queries and a transactional outbox.
  • Python FastAPI graph-service on Graphiti and Neo4j for temporal and semantic retrieval.
  • GitHub App integration for PR ingest, context, and drift check runs.
  • GitHub Actions release pipeline for multi-arch binaries and container images.

Approach

  1. 01Split the system into two planes (ADR 0001): PostgreSQL owns governance - scopes, verification, authority, audit, and ingestion state - while a thin Python graph-service owns temporal and semantic retrieval on Graphiti and Neo4j.
  2. 02Kept the planes consistent without distributed transactions, using a transactional outbox and a Go worker that syncs writes asynchronously, so governance still answers when the graph is down.
  3. 03Rewrote the core from Python to Go (ADR 0005) as a single binary exposing REST, a stdio MCP server, and a CLI.
  4. 04Fixed the agent contract at ten stable MCP tools (ADR 0003), such as get_for_task, knowledge_search, explain, and supersede, adding new behaviour through intents instead of new tools.
  5. 05Built a context compiler that assembles a task-scoped packet under a token budget, with workflow profiles (code review, refactor, debug, onboarding) and a priority ladder that reports exactly what was dropped.
  6. 06Modelled authority explicitly: verified human decisions outrank inferred observations, superseded knowledge never wins by default, and agents cannot promote their own output to canon.
  7. 07Built every feature spec-first: 48 specifications to date, each with its own plan and test-driven implementation.

Outcome

  • Agents call one tool at session start and receive decisions, lore, and evidence scoped to the repository and task, with the reason each item was included.
  • Ingests git history, pull requests, ADRs, and docs into a human review queue, so extracted text never behaves like verified architecture until someone accepts it.
  • Architecture drift detection publishes a GitHub PR check when code diverges from recorded intent, and human corrections of agent behaviour feed back as reviewable observations.
  • Retrieval quality and context usefulness are measured from real agent usage, not assumed.
  • Ships as release binaries for Linux and macOS, container images on ghcr.io, and Docker Compose profiles from a minimal Postgres setup to the full graph stack.

Technologies

  • Go
  • MCP
  • AI Agents
  • PostgreSQL
  • Neo4j
  • Graphiti
  • Python
  • Transactional Outbox

References

Similar problem?

Facing a migration, reliability, or scale challenge like this one?

I take on staff and principal IC roles, engineering leadership, and focused consulting engagements.