百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

brain0

> AI 编程
开源

用于 AI 编写代码的黑盒。被动决策图将每个提交与其背后的代理提示相连:漂移检测、代理读取内容的 DLP 审计、

394 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

用于 AI 编写代码的黑盒。被动决策图将每个提交与其背后的代理提示相连:漂移检测、代理读取内容的 DLP 审计、


Coding agents now write most of the diff: continuously, in parallel, and opaquely. brain0 passively builds a decision graph of your repository: every commit linked to the agent intents behind it, down to the single function, with dated history, drift detection, a DLP audit of what agents read, and a two-dimensional risk score rendered green → red. No hooks, no agent cooperation, no code changes: it reads git and the transcripts your agents already write to disk.

Dogfooded from day one: brain0's own development is tracked by brain0.

Quickstart

bash
npx brain0 up

That's it. From any repo, up infers the repo id from your git remote, indexes the git history (the facts), passively ingests your coding-agent sessions (the intents, with Codex and Claude Code auto-discovered), and opens the GUI at http://localhost:8787: an explorable graph of your codebase, from repo to module, file and symbol, where clicking a commit reveals the prompts behind it, per-file diffs, and risk at a glance.

Then make it a habit:

bash
brain0 today             # morning triage: what agents did, riskiest first
brain0 report            # the accountability report (add --md to share it)
brain0 query "why did the parser break"   # root-cause debug over the graph

What you need

The only hard requirement is Node.js ≥ 20. brain0 is offline-first: with nothing else installed it still works end to end: deterministic summaries, local feature-hash embeddings, zero egress. Local models make it better, never required.

Piece Needed for Without it
Node.js ≥ 20 everything (npx brain0 up) (required)
git commit history (the facts side) filesystem checkpoint mode (brain0 watch)
A coding agent: Codex (~/.codex) or Claude Code (~/.claude/projects), auto-discovered the why layer: prompts, drift, reads/DLP graph of commits + code only
Ollama + models (below) model-written summaries · semantic search · GUI smart chat deterministic summaries · feature-hash embeddings · retrieval-only answers
ANTHROPIC_API_KEY / OPENAI_API_KEY (opt-in) a hosted LLM for the GUI smart chat local Ollama (default)

Recommended local models

bash
ollama pull qwen3:4b               # summarizer (default)
ollama pull qwen3-embedding:0.6b   # embeddings (default; nomic-embed-text is the auto-fallback)

Both run on modest hardware. On a small GPU (≈4 GB VRAM) use a lighter summarizer for the first, cache-populating run. Summaries are content-cached in ~/.cache/brain0/, so every later rebuild costs zero model calls (and even an interrupted run keeps its work):

bash
BRAIN0_SUMMARIZER_MODEL=qwen3:1.7b npx brain0 up

If a configured model is missing, brain0 tells you exactly what to pull and degrades gracefully (embedder falls back to nomic-embed-text, then local). Every choice is overridable: BRAIN0_SUMMARIZER_{PROVIDER,MODEL,ENDPOINT}, BRAIN0_EMBED_{PROVIDER,MODEL,ENDPOINT,DIM}, BRAIN0_LLM_PROVIDER. Details in docs/models.md.

The questions your repo can't answer today

  • Which prompt introduced this bug?
  • Who (agent or human) touched this function, when, and why?
  • The agent claimed it "changed little." Did it?
  • Did any session read .env or a private key before pushing code?
  • This change looked harmless. Did it later prove dangerous?

brain0 answers all five, by construction. Three of those answers exist nowhere else:

① Drift: declared vs. done

Agents narrate what they changed; git records what actually changed. brain0 reconciles the two and scores the gap. From brain0's own report:

drift — declared vs done (41)
  · [1.00] claude-code — changed but not declared: crates/brain0-cli/src/main.rs,
           packages/gui/src/main.ts … +12 more

② Sensitive reads: DLP for agent context

brain0 records which files each session read (paths and secret kinds only, never values): explicit Read calls, Grep results, shell reads such as cat .env or sed -n, and subagent transcripts, with the returned content scanned for secrets at ingest. The read set comes from one source (the transcript the agent harness writes), so read it as a lower bound of what reached a possibly-remote model, not a proof:

sensitive reads — DLP (7)
  · claude-code read crates/brain0-agentsrc/src/driver.rs [env_secret]
  · 8 read(s) outside the repo reached the model's context

③ Risk that learns: green → red

Every artifact carries an a-priori score (blast radius, churn, drift, diff size) fused with an a-posteriori score fed by evidence (reverts, immediate fixes). A change that looked safe but later proved dangerous is flagged as a gold signal: the pattern worth studying.

Give your agent the "why layer" (MCP)

The same graph is a query channel your coding agent can call before touching code: provenance-aware context, by reference, nothing heavy pushed through MCP.

bash
claude mcp add brain0 -- brain0 mcp
Tool What the agent learns
brain0_context a file/symbol's risk, recent history, and the intents (agent · model · drift) behind it
brain0_blame which intent wrote this line: file:line resolves to its symbol via live parsing
brain0_debug root-cause candidates for an issue, recency- and risk-aware
brain0_audit repo risk distribution, gold signals, riskiest nodes

Your agent stops re-breaking what it can't remember. Uninstalling brain0 makes it forget again.

How it works

brain0 is a pure observer: it never writes to your repository.

…

Principles that don't bend:

  1. Passive observation: never modifies your repo, never commits/checks out, never interferes with git.
  2. The magnifying glass: zooming descends into the same object (repo → module → file → symbol), never loads different nodes.
  3. No unjustified new nodes: an entity that evolves stays the same node (deterministic, cross-machine symbol identity with rename/move tracking), with a dated chain of versions.
  4. Light index, lazy heavy payload: the navigable graph is small and lasts for years; diffs, messages and summaries hydrate on demand.
  5. Open source and composable: bring your own database and your own LLM keys, or run fully offline.

How it compares

git blame Vendor dashboards¹ Git AI brain0
Who committed a line ✅ ✗ ✅ ✅
Which prompt/intent produced a change ✗ ✗ ✅ ✅
Cross-agent, vendor-neutral ✅ ✗ ✅ ✅
Drift: declared vs. actually done ✗ ✗ ✗ ✅
What the agent read (incl. secrets, DLP) ✗ ✗ ✗ ✅
Risk score per file/symbol, evidence-driven ✗ ✗ ✗ ✅
Explorable graph GUI with time travel ✗ ✗ ✗ ✅
Zero integration (no hooks in your agents) ✅ ✗ ✗ ✅
Local-first, offline by default ✅ ✗ ✅ ✅

¹ Copilot Metrics API, Cursor team analytics, Claude Code analytics: per-vendor aggregates (sessions, LoC accepted), no line/symbol-level provenance, no causality.

Commands

Command What it does
brain0 up index + observe + serve the GUI, one shot
brain0 today last-24h triage, attention first (--since 7d)
brain0 report drift · sensitive reads · top risk · agent footprint (--md)
brain0 query "" root-cause debug over the graph, by reference
brain0 mcp serve the query channel (context/blame/debug/audit) over stdio
brain0 ingest / observe / watch the underlying fact/intent observers
brain0 rewind restore the working tree from a recorded checkpoint (the watch safety net)
brain0 guard / preflight DLP: flag secret reads that reached a remote model · block them pre-commit/pre-run
brain0 provenance / attribution / attest / compliance AI provenance per commit · per-hunk attribution · signed (Ed25519, in-toto) attestations · auditor pack
brain0 verify / audit / purge / reembed integrity, audit log, crypto-shred, re-embedding

Building from source

Prerequisites: Rust (see rust-toolchain.toml), Node 20+, pnpm.

bash
cargo build && cargo test          # Rust core (14 crates)
pnpm install && pnpm -r build && pnpm -r test   # TS workspace (shared · agent · gui · server)
./scripts/e2e.sh                   # cross-language end-to-end check

# All-in-one dev loop (build → ingest → observe → server :8787 → GUI :5173)
pnpm dev --repo myorg/myrepo

The GUI's Refresh button re-runs the same passive observer and re-embeds, live; it is served same-origin on 127.0.0.1 only.

crates/      Rust core (model, parser, identity, storage, observer, reconcile, risk,
             agentsrc, crypto, models, policy, attest, mcp, cli)
packages/    TypeScript (shared, agent, gui, server, cli)
schema/      SQL DDL for the local SQLite backend
docs/        Documentation (agent-artifact schemas, security, models, open-core, governance)

Privacy & security, by default

  • Offline by default: no keys ⇒ local embeddings + local models (Ollama optional); nothing leaves the machine. Remote LLM/embeddings are an explicit opt-in, with context redacted before egress.
  • Secret scanning at ingest: transcripts are scanned and redacted (typed placeholders, never values) before anything is stored, summarized, or embedded; BRAIN0_EXCLUDE / BRAIN0_REDACT add your own rules. The raw prompt text is not persisted; only the model-generated summary.
  • Encrypted at rest: envelope-encrypted payload store (ChaCha20-Poly1305, KEK rotation, crypto-shred purge) with restrictive file permissions.
  • Append-only, content-addressed: the graph is tamper-evident (brain0 verify), with an append-only security audit log.
  • Reads are single-source, and pinned: git is an independent witness for what agents wrote; nothing plays that role for what they read, which comes only from the harness transcript. brain0 pins every ingested transcript range (BLAKE3 in the audit log) and brain0 verify re-checks it, so a transcript altered after ingest is caught; one altered before ingest is not. What a fact-side source would take: docs/governance.md.

Threat model and honest limitations: docs/security.md.

Open core

Everything in this repository is free and open source under Apache-2.0 and fully functional on its own, with no license checks, feature flags, or crippled code paths. Team/hosted capabilities (a PostgreSQL + pgvector backend implementing the same public brain0_storage::Storage trait, signed entitlements, a multi-tenant server) live in a separate brain0-enterprise repository (AGPLv3 + commercial). brain0 never depends on brain0-enterprise. Full boundary and rationale: docs/open-core.md.

Contributing

See CONTRIBUTING.md. By participating you agree to the Code of Conduct. Contributions are accepted under our CLA (see cla/), which keeps the open-core dual-licensing sustainable.

License

Apache-2.0 © The brain0 Authors.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustaiai-agentsattestationaudit

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.