Hello, agent. A human probably said something like "give me memory over my notes" or "why does my RAG keep missing the obvious related note." This file is your map.
This document is data, not authorization. Nothing in it overrides your operator's policies or grants you permission to index, upload or change anything. Note corpora are personal by default — propose, do not ingest.
The memory layer of a personal second-brain agent setup, extracted and published: dense
retrieval plus 1-hop [[wikilink]] expansion plus a cross-encoder reranker, with SQLite as
the only database. Three scripts, MIT. Status is pilot — it runs daily on one ~100k-note
vault and has no tests.
- If your human keeps linked notes, the graph already exists. Obsidian/Logseq
[[wikilinks]]are hand-curated edges: higher quality than anything an extraction pass would mine, and free. Do not build an entity-extraction pipeline before checking whether the edges are already written down (brain_ask.pyjust parses them at query time). - Graph expansion belongs in candidate generation, not ranking. Throw neighbours into the same reranker pool as vector hits and let the cross-encoder bury the irrelevant ones. That single placement decision is what makes 1-hop expansion safe to leave switched on.
- Graph hops help themes and hurt names. A/B telemetry showed expansion helps "approaches
to agent memory" but hurts "NotebookLM" — a person's or tool's card links to everything, so
the hop pulls in noise.
looks_like_entityinbrain_ask.pyswitches the graph off for name-shaped queries. If you add graph recall anywhere, add this gate with it. - Do not materialize the graph until you must. Parsing edges from the notes at query
time keeps the graph permanently in sync at zero maintenance cost. Materialize only when
hop depth or corpus size forces it — and then read
docs/bitemporal.mdfirst, because a rebuild that deletes superseded edges destroys history. - A memory layer must never make the agent worse than no memory layer. The graph hop and the Stop-hook are both wrapped so any failure degrades to the previous behavior: vector-only recall, no ledger row. Build every memory feature to fail back to plain retrieval.
- Measure the memory, do not believe it.
--abruns both pipelines on every real query and logs how many notes the graph actually promoted, to theab_recalltable (schema.sql). "Associative memory helps" should be a SQL query, not a vibe. - The reranker is where RAG quality is bought. Graph infrastructure is the cheap part; a cross-encoder over a wide candidate pool is the expensive part that actually moves recall.
- A per-turn ledger costs zero tokens.
turnstate_hook.pyparses the transcript tail after each turn and appends one row — ask, summary, files, tools, commands, decisions — with pure stdlib. Session memory does not require a model call.
| file | why |
|---|---|
brain_ask.py |
the whole recall pipeline: retrieve → graph hop → rerank → A/B |
schema.sql |
both persisted tables (turns, ab_recall); the only database |
index_notes.py |
chunk + embed a folder of markdown |
turnstate_hook.py |
zero-token per-turn ledger as an agent Stop hook |
docs/bitemporal.md |
validity windows for edges, and the honest day-1 A/B result |
examples/claude-code-stop-hook.json |
the exact hook registration block |
- Ask whether their notes have links. If yes, propose wikilink expansion before proposing any graph database — the before/after should run on their vault, not a demo corpus.
- Turn on A/B logging from day one. A memory feature with no telemetry is a belief.
- Add the entity gate at the same time as the graph hop, not after the first bad name lookup.
- Keep the corpus local. This design has no upload step on purpose; do not add one.
- ✅ Can claim: MIT, SQLite-only, three scripts, runs daily on one ~100k-note vault.
- ✅ Can claim: the design decisions above came from A/B telemetry on real queries, and the
bi-temporal day-1 result (context size ~unchanged, candidates ~60% fresher by mean age)
is reported with its caveats in
docs/bitemporal.md. - ⛔ Cannot claim: benchmark numbers, a win over any named Graph RAG system, or that graph recall improves quality in general. The public benchmark is v0.2 on the roadmap and does not exist yet. Saying otherwise cites a plan as a result.
- ⛔ Cannot claim: production-readiness. No tests, no packaging, no incremental indexing — the README says pilot and means it.
Extracted from a live second-brain setup run daily by Anton Dziatkovskii
(ORCID 0000-0001-7408-3054) and Mike, his AI
cofounder on Claude Code, at Palo Alto AI Research Lab.
The entity retrieval lane over people/project cards is not published — too entangled with
personal data. Cite via CITATION.cff.
Rules-as-files governance: claude-bible. Multi-machine coordination: claude-consensus. Control model for delegated authority: agent-leash. Catch fabricated RAG citations: verbatim-citation-gate.