Objective
The hard 80% of a coding agent isn't the model call — it's state and retrieval: remembering the codebase and past decisions, finding code by meaning, reasoning over how code connects, and proving what the agent did. Build that the usual way and you're running a vector DB + a graph DB + SQL + an audit store — four systems, network hops between every lookup, and your customers' source code scattered across four vendors' clouds.
This recipe stands up all four on one self-hosted SynapCores instance your agent talks to over MCP (or SDK, or plain SQL). The LLM reasoning stays in your agent; SynapCores is its brain — memory, code search, an impact graph, and an unforgeable decision log.
Runs on CPU, out of the box. No completion model, no GPU — only the embedding model (
all-minilm), auto-pulled on firstEMBED. Every query below returns in seconds.
Step 1: Project memory — what the agent must not forget
Store decisions and conventions once; recall them by meaning before the agent acts.
SELECT MEMORY_STORE('proj_acme', 'Auth hashes passwords with argon2 — never bcrypt (decided in PR #412).');
SELECT MEMORY_STORE('proj_acme', 'Rate limiting is a token bucket, 30 req/min per IP, in middleware/limiter.rs.');
SELECT MEMORY_STORE('proj_acme', 'All timestamps are stored UTC; never local time.');
Now recall by meaning — the agent asks a question, not a keyword:
SELECT content, similarity
FROM MEMORY_RECALL('proj_acme', 'how do we hash passwords', 2);
The argon2 decision comes back on top, ranked by semantic similarity — the agent loads the right convention before it touches auth code, instead of re-deciding it.
Step 2: Semantic code search (RAG)
Index code chunks with a vector column, then search by intent.
CREATE TABLE code_chunks (
id INTEGER PRIMARY KEY,
path TEXT,
symbol TEXT,
body TEXT,
embedding VECTOR(384)
);
INSERT INTO code_chunks (id, path, symbol, body) VALUES
(1, 'auth/password.rs', 'hash_password', 'argon2 hash of the user password'),
(2, 'auth/token.rs', 'validate_token', 'verify and decode the jwt access token'),
(3, 'middleware/limiter.rs', 'rate_limit', 'token bucket, 30 requests per minute per ip');
-- Embed each chunk once (the embedding model auto-pulls on first call).
UPDATE code_chunks SET embedding = EMBED(symbol || ': ' || body);
"Where is JWT verified?" — by meaning, not grep:
SELECT path, symbol,
COSINE_SIMILARITY(embedding, EMBED('where is the jwt verified')) AS score
FROM code_chunks
ORDER BY score DESC
LIMIT 2;
auth/token.rs :: validate_token ranks first — the agent gets the right file
even though the query never says "token" or "jwt" literally the way the code does.
Step 3: The code knowledge graph — reason over how code connects
A coding agent's scariest question is "what breaks if I change this?" Vector search can't answer it — the answer follows the call structure, not text similarity. So model the call graph in the native graph engine, in the same instance, with Cypher.
Build the graph — nodes are functions, edges are calls (MERGE is idempotent, so
re-running is safe):
MERGE (login:Fn {name: 'handle_login'})
MERGE (refresh:Fn {name: 'refresh_session'})
MERGE (validate:Fn {name: 'validate_token'})
MERGE (decode:Fn {name: 'decode_jwt'})
MERGE (login)-[:CALLS]->(validate)
MERGE (refresh)-[:CALLS]->(validate)
MERGE (validate)-[:CALLS]->(decode);
Direct callers of a function:
MATCH (caller:Fn)-[:CALLS]->(:Fn {name: 'validate_token'})
RETURN caller.name AS caller;
GraphRAG — semantic seed, then graph walk. This is the combination pure vector RAG
can't do: Step 2's search found the entry symbol by meaning (validate_token); now
walk the graph from it to assemble the connected path — who reaches decode_jwt
through validate_token, i.e. the callers that break if you touch the JWT decoder:
MATCH (caller:Fn)-[:CALLS]->(:Fn {name: 'validate_token'})-[:CALLS]->(:Fn {name: 'decode_jwt'})
RETURN caller.name AS must_review;
Returns handle_login and refresh_session — the blast radius, discovered by
structure. The agent found where to start by meaning (vectors) and what connects
by walking edges (graph) — GraphRAG, one engine, no separate graph database. (For bigger
graphs the same engine has PageRank/Louvain to rank critical functions and detect
subsystems.)
Tidy the graph up:
MATCH (n:Fn) DETACH DELETE n;