Skip to content

Back to the catalog

brain0
github.comrepo

brain0

brain0 is an open-source (Apache-2.0) passive observer that builds a decision graph linking git commits to the AI-agent prompts/sessions that produced them, by reading git history alongside Claude Code and Codex transcripts on disk. It reconciles what agents claim they changed against what actually changed (drift detection), flags sessions that read secrets like .env files or private keys before pushing (DLP audit), and computes a two-dimensional risk score per artifact, exposed via a local GUI, CLI, and an MCP server for agent queries.

TL;DR Open-source provenance/audit tool that traces AI-agent-written code back to prompts, flags secret reads, and scores risk of AI-generated changes.
Document

What it is

brain0 is a Rust-core CLI (npx brain0 up) that runs as a pure, read-only observer over a git repo and its coding-agent transcripts. The summary describes what it produces; the page adds how you run it, what it requires, and the trust limits of its DLP output.

How it works

A Rust core observer reads git history (the facts) and passively ingests Codex / Claude Code transcripts (the declared intents), extracts symbols and AST fingerprints via Tree-sitter, reconciles declared-vs-done to compute drift, and serves a PixiJS graph GUI at http://localhost:8787. Storage is pluggable behind one Storage trait: SQLite + sqlite-vec (local, open core) vs Postgres + pgvector (enterprise). It also exposes an MCP query channel so your agent can pull provenance-aware context by reference.

Preconditions

  • Node.js ≥ 20 is the only hard requirement. Repo id is inferred from the git remote; there is a no-git fallback (fs-watcher / checkpoint engine).
  • Offline-first with zero egress: works end-to-end with deterministic summaries and local feature-hash embeddings, no models installed.
  • Optional local Ollama models improve summaries/embeddings; summaries are content-cached in ~/.cache/brain0/, so rebuilds cost zero model calls.

What to do

npx brain0 up
brain0 today             # morning triage: riskiest first
brain0 report            # accountability report (add --md to share)
brain0 query "why did the parser break"

Optional local models:

ollama pull qwen3:4b
ollama pull qwen3-embedding:0.6b

Low-VRAM (~4 GB) first run:

BRAIN0_SUMMARIZER_MODEL=qwen3:1.7b npx brain0 up

Agent memory via MCP:

claude mcp add brain0 -- brain0 mcp

Model choices are overridable via BRAIN0_SUMMARIZER_{PROVIDER,MODEL,ENDPOINT}, BRAIN0_EMBED_{PROVIDER,MODEL,ENDPOINT,DIM}, BRAIN0_LLM_PROVIDER; a missing model degrades gracefully (embedder falls back to nomic-embed-text, then local).

Caveats

  • The DLP read-set is a lower bound, not proof. It derives from a single source — the transcript the agent harness writes (explicit Read calls, Grep results, shell reads like cat .env, subagent transcripts). Treat it as the minimum that may have reached a possibly-remote model, not the maximum.
  • Secret detection records paths and secret kinds only, never values.
  • MCP-based agent memory is not persistent by nature: "uninstalling brain0 makes it forget again."
  • Local models are positioned as strictly optional — they "make it better, never required."

Technologies named here

Techniques named here

  • Declared vs. done reconciliation / drift detection
  • DLP audit of agent reads
  • Two-dimensional risk scoring
  • Tamper-evident append-only audit log