What it does
corpus-brain is the long-term memory behind Maxwell's AI agents. Every session an agent runs, every repository he has built and every decision and lesson along the way goes into one index. When a new session starts, the agent is briefed from that index before it touches anything: which past projects are relevant to the folder it is in, what was tried before, what was decided and what went wrong. Its one rule is that every result it surfaces carries a citation that resolves to something real, a session turn, a file and line, or a repository, or the result is not shown. A memory that cannot be trusted is worse than none.
What it indexes
- Every Claude Code transcript on the machine, preserved in three layers by a daily job: a mirror that never deletes, a write-once content-addressed store where each file is kept under its own fingerprint and made read-only, and a manifest of every run. Citations pin to the exact preserved version of a transcript, so a citation still resolves after the original file is gone. The index holds the only surviving copy of 1,830 transcripts (38,979 chunks) that no longer exist anywhere else on the machine.
- Every repository across six GitHub owners, his own account and the organizations of his client work, plus his local development folders, a mirror of his GitHub repositories and an external network share whose catalogue is snapshotted so it stays searchable when the share is offline. The sweep filters forks, tags legacy repositories and stops on a name collision between owners instead of merging two projects.
- A record of each project, built from its source: identity, name, source and status are derived by code, and an AI model proposes only the summary and maturity fields, after every secret has been stripped from what it sees. Repositories not cloned locally get a metadata record with no model call.
- Open decisions, ingested as citable records, and techniques recorded only where code analysis finds real occurrences at a file and line.
How it finds what is relevant
- Recall over transcripts: text is cut into 1,100-character chunks with 150-character overlap and embedded locally (BGE, 384 dimensions). All vectors sit in one memory-mapped matrix, so a search is a single matrix product answered in 0.011 seconds. The index refreshes incrementally, skips machine-generated text posing as the operator, and re-embeds a transcript when the code that reads it changes.
- Ranking priors: three sources are fused (semantic similarity, word overlap and structure from per-repository code graphs, 79 of them), legacy projects are dropped, a cross-encoder re-ranks the top results, and a relevance policy (a floor of 0.30, the top 5, a margin of 0.15) returns either a set of priors or an honest "no match."
- Code recall:
where_implementedanswers where in his repositories something has already been built, by file and line, from the code graphs.
The citation gate and redaction
- Every surface passes through one display gate. A code citation must resolve to a real file and line; a session citation must decode to a real turn of a real transcript, located by its file and never by a pattern match; a repository citation must name a real repository. Anything that fails is withheld.
- Strength is counted, not claimed: a technique seen once is shown as "used once, here," never as battle-tested.
- Confidential projects stay in their own context: a confidential project's details are withheld everywhere outside that project, and when the active project is unknown the gate fails closed.
- Secrets are redacted at ingest and again at read time by a shape-based redactor covering private keys, cloud access keys, AI-provider keys, GitHub, Google and Slack tokens, signed tokens and assigned secrets, with a gitleaks pass at the file boundary. Every AI call made by the system goes through one guarded wrapper that pins its settings, refuses to re-enter itself and runs one at a time.
The append-only store
The audit trail and hardened lessons are protected by database triggers that abort any update or delete. Forgetting is deliberate and recorded: forget_session and forget_project_root remove chunks from the index and write an audited tombstone. Backups are consistent snapshots taken with SQLite's online-backup interface and restore fail-closed. Database files are owner-only on an encrypted disk, and extracted text is treated as data, never executed.
How agents and Maxwell use it
- Every session starts briefed. A session-start hook calls
orient, which returns a warm-start envelope of at most 3 KB: the projects relevant to the current folder, recent hardened lessons and the operating doctrine. It never indexes during a session and degrades rather than failing. The agents' standing instruction is to recall before they search. - 30 MCP tools on five servers. The memory:
recall,where_implemented,find_priors,browse(lessons, decisions, patterns),find_systems,list_systemsandget_system. The store:list_projects,get_project,list_lessons,list_decisions,record_decision,keep_lesson,pin_lessonandrecent_audit. Orientation:orient. A build-harness pair adds its own orientation and 13 tools over findings, decisions, recorded traps and audit events. - Eleven skills: ask the memory, carry an idea forward, review lessons, a morning grounding built from his timesheet and the corpus, and status; and six build skills that take an idea through a new project, a plan, a plan review, implementation, review and verification.
- Eleven commands: a one-command bring-up, a doctor that proves each guard fails closed, a health report, the reindex, hook registration, the trust audit, and the showcase commands that prepare and publish portfolio generations.
The pipelines on top of the memory
- Lesson capture: an AI extractor proposes lessons from sessions, a validator checks each one against the exact text span it came from, and a lesson is hardened only when Maxwell keeps or pins it.
- Idea to build: an idea is matched to its priors, turned into a plan and stamped as a new project from The Forge's Python frame.
- The agent-episode record: an append-only ledger that joins what agents said, what they did, the code they touched and the commits they produced, reconstructed as runs, task threads, behavioral episodes and events, with eight recovery detectors (such as a helper dispatched, or a helper caught being wrong) and every link labelled as directly observed, deterministically derived or inferred. No model calls.
- Operations and capabilities: transcripts are segmented into the operations Maxwell ran and rolled up into demonstrated capabilities, the AI proposing and a pure verifier deciding; one roll-up gathered 195 operations into 8 capabilities.
- Capability discovery: a census of 6,424 sources and 26,490 raw records feeds a code graph, evidence packets, pattern runs, a citation verifier and digests, under 12 locked design decisions such as "the graph routes; the raw sources decide."
- Showcase generation: each project gets one canonical record from which its manifest and engineering record are rendered by code. Packages are sealed into an immutable generation, indexed by word and meaning, and switched on atomically. The active generation holds 3,903 systems across 90 projects, feeding the agents that write his portfolio and applications.
- Career record building: a clean-room portrait builder working from 13,602 direct sources (6,608 current transcripts, 6,599 archived, 143 repositories and 61 timesheet days), 1,728 accomplishment records and 36,030 session-day observations.
- The trust audit: checks the real corpus end to end for secrets, citations, attribution, overstatement and append-only integrity.
Built with: Python 3.12, SQLite with FTS5, fastembed (BGE embeddings and an MS MARCO cross-encoder), graphify code graphs, the MCP protocol, launchd, gitleaks and ast-grep.
What it achieved
- An index of his whole working record: 499,050 chunks over 14,296 files.
- Search made instant: one query across 437,584 vectors fell from about 16 seconds to 0.011 seconds.
- The only surviving copy of 1,830 transcripts, kept because the index refuses to purge primary evidence.
- A memory every agent starts from, briefing each session in 3 KB and answering 30 tools, with nothing shown that cannot be cited.
- The evidence base for his portfolio: 3,903 systems recorded across 90 projects and 94 showcase records, each traceable to its source.
- Size: 75,943 lines of application code in 366 files (29,517 in the product's
src/), 38,875 lines of tests in 249 files with 1,738 test cases, 53 data tables, 6 database changes, 30 MCP tools, 11 commands, 11 skills and 349 commits.
The problem it solves
Maxwell runs thousands of AI sessions across more than a hundred projects. Each new session starts with no memory of the last one, so agents re-solve problems already solved, repeat mistakes already corrected and ask questions already answered. Ordinary AI memory makes it worse: it surfaces confident recollections with nothing behind them, and an agent acting on a false memory does more damage than one starting fresh. Transcripts also disappear under retention rules, taking the record with them.
corpus-brain keeps the whole record and makes it usable on one condition: everything it says can be checked. Each prior points to the exact turn, file and line or repository it came from, secrets never leave the store, and the record of what happened cannot be rewritten.
How he built it
Maxwell stamped corpus-brain from The Forge's Python frame, so illegal states do not type-check: frozen data classes, closed unions, branded identifiers minted in one place, exhaustive matching, and no Any, blanket ignores or casts under strict type checking. A proof file holds 66 illegal states the type checker must reject, and a command fails if any of them compiles.
The Forge's control kit runs inside the repository: 11 fail-closed controls, each with must-block and must-allow contracts and a meta-test that every control has one. They refuse escape hatches, skipped git hooks, shell writes to source, edits to the controls, settings or environment, and any source edit before an approved plan or outside the approved scope, on every tool call, session start, stop and helper stop. The harness has logged 116,326 hook decisions.
One gate decides done: lint, lane and operations checks, a maintainability check on the showcase builder, an audit check (tests, ruff, strict mypy, pip-audit, gitleaks and probes that confirm the sandbox has no network), the full test suite and the illegal-state proofs, stamped to a file. CI runs the gate, the doctor and an 80% coverage floor on every push and pull request and weekly. The tests are layered: 779 unit, 303 integration, 190 lane and 14 end-to-end tests in the product, 207 harness tests, 66 career-record tests and property-based tests in four files.
The work ran from written specifications: six specifications (the memory itself, the episode record, the capability portfolio, capability discovery as a 12-document blueprint, and showcase generation) and a 34-phase plan, under four doctrine files that also feed the orientation each agent receives. Hard failure modes are designed out: every AI call goes through the single guarded wrapper, which refuses to re-enter itself, so a hook-spawned call can never replicate and burn through a budget; and session citations resolve by exact file, never by a pattern match, so every part of the corpus can be displayed.