Skip to main content
braincore — cover

Featured work

braincore getbraincore.com

Local-first cognitive memory for AI coding agents. Attention, decision graph, the right to say I don't know.

  • Go 1.25
  • SQLite
  • MCP
  • tree-sitter
  • internal git
  • pluggable LLM

The problem

total-agent-memory is a Python service. That’s fine for a research stack, terrible for a binary I want to ship to friendlies. braincore is the same idea rebuilt in Go: 21 MB stripped, pure Go, zero CGO, one artefact.

What’s inside

  • Memory pillars — episodic, skills, intents, workflow, reflection.
  • Cognitive bridge — associations, analogies (Dempster-Shafer fusion), contradictions, temporal queries.
  • Code-graph — Go AST + tree-sitter + a regex universal parser covering 13+ languages.
  • Agent runtime sandbox — read-only adapter plus a safe side-effect execution pipeline: the agent dry-runs effects first, then commits.
  • Long-horizon goals — a dedicated memory layer for long-running goals, not just short-lived episodes.
  • Pluggable LLM — None / Ollama / Anthropic / OpenAI / Groq / Gemini / DeepSeek / OpenRouter with auto-routing, swap by config.

Storage

Internal git versioning over JSON snapshots is the source of truth. SQLite + FTS5 is the derived speed-cache. braincore checkout HEAD~3 and you see what the agent believed three sessions ago — no drift.

Implementation highlights

  • Activation spreadingconcepts.Spread(seeds) walks the unified graph (code edges + triples + decision-code refs) with configurable decay, hops, threshold, and per-relation weights.
  • Self-correcting factskg_invalidate_fact plus auto valid_from/valid_to lets the agent change its mind without losing history.
  • Cross-project analogiesanalogize(query, exclude_project) does Jaccard + Trigram + FTS rank + triples overlap, fused via Dempster-Shafer, returns belief-weighted matches.
  • Self-improvement loops — recurring error patterns (≥3 occurrences) auto-promote into behavioural rules.
  • Self-updatebraincore update with a signed manifest and update feed, atomic rename, ed25519 verification.

Status and numbers

Private beta (v0.163.0-beta.4), dogfooded daily. Verified from the CI battery, not marketing:

  • 15 CI gates green — retrieval, stress (70.3 s / 120 s budget), dogfood (5 repos + MCP), codegraph-multilang, runtime-soak, LLM-provider-matrix, thinking-golden.
  • Retrieval R@5 = 0.95, bench p95 ≈ 22 ms; targeted fetch ×11 faster than full scan (53.2 ms → 4.77 ms, ×510 less data moved).
  • Entity discrimination 16/20; grounding guard precision 30/30, recall 30/30; design path 8/8 grounded with citations.
  • Real-world scale: 125,462 memories migrated into one ~/.braincore/memory.db across 130+ projects.

Lessons

  • A binary you can drop into someone’s ~/bin removes 95 % of adoption friction.
  • Pure Go is liberating — every reach for CGO ended up biting me eventually.
  • Memory is not state. State is what an agent has in front of it. Memory is what it knows it has.