Inspiration
What it does
How we built it
Challenges we ran into
Accomplishments that we're proud of
What we learned
What's next for Sage Garden Graph
Inspiration
Ask an LLM "I keep comparing myself to my classmates and freeze when they get ahead — who should I read?" and you get a plausible list: Marcus Aurelius, maybe Epictetus. The list is fluent and unfalsifiable. Nothing tells you why those names belong together, and nothing stops the model from inventing a quotation to make the recommendation feel earned.
Retrieval doesn't fix this. RAG returns chunks that are individually similar to the question. But the interesting claim — "Zhuangzi and Epictetus are answering the same question" — is not in any single chunk. It lives in the relations between chunks. That is a graph question, not a vector question.
What it does
You type the situation you're stuck in. Three agents work over one embedded graph:
1. Locator maps your free text to themes (bilingual lexicon with word-boundary stem matching), then ranks sages by ADDRESSES hits, keyword overlap and graph degree. A diversity rule caps it at two sages per tradition, so a question about self-worth doesn't return three Daoists.
2. Bridge proves the chosen sages belong together. It runs shortestPath over INFLUENCED and DIALOGUES_WITH edges only, returns the chain with the written evidence attached to each hop, and sorts cross-tradition links first — the point is connecting thinkers who never met.
Zhuangzi → Huineng → Wang Yangming → Mencius, 3 hops
lineage — Chan Buddhism borrowed heavily from Zhuangzi's vocabulary of 'no-mind' and 'naturalness' — an influence, not a lineage.
3. Composer writes the answer — deterministic by default, or via any OpenAI-compatible endpoint you paste in (BYOK, never stored). Whatever the model emits goes through the citation gate: each quote is checked as a substring against the Sage record it claims to come from, and the sage must have been in the dossier the model was given. Failing citations are removed, and the UI shows what was blocked and why. A "try forging a quote" button takes a real Socrates line, alters one word, and shows the gate refusing it.
Memory. Every question is written back as (:Session)-[:ASKED]->(:Question)-[:ABOUT]->(:Theme) and -[:CITED]->(:Sage). Ask a second question that touches the same ground and the answer ends with "You asked … before; both run on Self."
How we built it
- Relate by Neo4j (
@relate/relate) is the whole store: one embedded file (data/sages.rl), no server.Database.open()→connect()→conn.query(cypher)inside the Node process; the seed writes 143 nodes / 241 relationships in about 70 ms. - Plain Node 20 + Express for the API; a dependency-free canvas force layout for the graph view; everything else is vanilla JS.
- The graph: 36 sages from six traditions (Daoism, Confucianism, Chan, Stoicism, early-modern Europe, contemporary operators), 9 themes, 88
ADDRESSESlinks, 21INFLUENCEDedges (documented: Laozi → Zhuangzi, Xunzi → Han Fei, Huineng → Wang Yangming…) and 24DIALOGUES_WITHedges explicitly typedkind: 'comparative'— the app never presents a comparison as a historical influence. Every edge carries its evidence in Chinese and English. npm testruns a mock OpenAI endpoint that returns one true quote, one silently altered quote, and one quote from a sage outside the dossier; the gate must keep 1 and refuse 2.
Challenges we ran into
shortestPathover an unrestricted relationship type happily routes throughThemenodes and produces nonsense. The path has to be constrained to the intellectual edges — and that constraint is also the semantics.- Three candidates from three traditions were often five hops apart; the answer read as a chain of coincidences. A greedy set-selection step now picks candidates that are provable near each other, cross-tradition hops weighted cheaper.
- Matching English:
comparingdoesn't matchcompare, andreadmatchesalready. Word-boundary stem matching fixed both. - The gate initially only checked quote text; a model could cite a sage that was never in its dossier. Provenance is now checked too.
Accomplishments that we're proud of
- The proof panel: a recommendation is never "these texts are similar" — it is a chain with per-hop evidence you can go and check.
- The gate catches the subtle case, not just the obvious one: a quote with one word changed is refused.
- Zero infrastructure:
npm install && npm run seed && npm startand it runs, offline, in about two seconds.
What we learned
- Citation verification is the right place to put a hard gate — it is cheap, it is exact, and it turns "trust me" into "check this".
- Edge typing matters. Separating
historicalfromcomparativeis what keeps a comparative claim honest. - An embedded graph database changes the shape of the project: the whole knowledge base is a 196 KB file you can ship, diff and open read-only.
What's next
- Expand the graph: more traditions, edges with page-level citations.
- Let the Composer propose new edges from the user's situation, written as
kind: 'user'so the graph grows with use and the claim stays traceable. - A Relate CLI mode so the same agents run as a tool inside a coding agent.
Built With
- ai-agents
- cypher
- express.js
- graph-database
- javascript
- neo4j
- node.js
- relate