Dual-Graph-RAG for legacy codebases.
Deterministic code and documentation analysis with Apache Lucene. No LLM entity extraction, no graph database, no context-window stuffing — just two graphs in one embedded index.
Large, grown software estates combine strict syntactic dependencies across millions of lines of source code with unstructured, often fragmented domain documentation. Existing Graph-RAG approaches try to capture these relationships through costly LLM entity extraction and pass large subgraphs into the context window.
prjxp takes a different route: a fully deterministic code and index path, locally operable on a single embedded Apache Lucene engine that acts as a Multi-Project Intelligence Hub. It combines a structural AST graph for hard code dependencies with a vector-based semantic neighbourhood graph for code and documentation across many repositories and live workspaces. Both graphs are clustered with Leiden and signed with c-TF-IDF — with zero LLM cost. A progressive-disclosure interface hands the LLM condensed structural references first and lets it navigate autonomously with project-scoped tools.
Two failure modes, one gap
Providing legacy systems to modern AI tooling fails for two opposing reasons: the syntactic blind flight of classic vector search and the extraction and context explosion of modern Graph-RAG frameworks.
Pure vector RAG
Embeddings capture semantic similarity but ignore directed call chains, inheritance and interface implementations. Two tightly coupled classes with different identifiers end up far apart in vector space.
structural blind flightLLM-extracting Graph-RAG
Entity extraction through an LLM is expensive, slow and non-deterministic. It produces duplicate nodes, requires entity resolution and triggers hours-to-days runtimes on millions of lines of code.
extraction explosionBoth lose in a different dimension
Vector RAG loses structure. Graph-RAG restores it but pays with compute, latency and context. prjxp's claim is that structural precision does not require an LLM in the index path — and that the right index can keep the context window small.
Four principles, two graphs
Dual-graph topology, automatic community clustering, statistical term signatures and progressive disclosure. The code and index path is deterministic throughout.
▸ Structural AST graph
An abstract syntax tree is created for the source. Nodes are classes and methods; typed fields are edges. Directed edges capture hard syntax relationships.
- CALL
- IMPLEMENTS
- EXTENDS
- IMPORT
- FIELD
- PARAM
- RETURN
- CONTAINS
- GENERIC_ARG
- ANNOTATION
▸ Semantic vector graph
All chunks are stored as vector embeddings in an HNSW index. The resulting neighbourhood graph connects domain documentation with the technical implementation.
- HNSW
- KNN
- Doc ↔ Code
Dual-graph topology
Hard code dependencies on one level, semantic neighbourhoods on the other. Both are queryable through the same index.
AST + HNSWCommunity clustering
The Leiden algorithm decomposes both graphs into disjoint clusters: coupled modules and thematically related knowledge.
LeidenStatistical signatures
TF-IDF scores terms per chunk; class-based c-TF-IDF produces precise semantic signatures per cluster.
c-TF-IDFProgressive disclosure
The LLM first receives compact references, then navigates to neighbours or exact source only when needed.
pointers → toolsTF-IDF · chunk level
Rarest significant terms make each chunk specific — the micro signature.
c-TF-IDF · cluster level
Top terms per Leiden cluster provide the macro context without an LLM summary.
Progressive disclosure instead of raw text
A compact reference schema first. The model then requests only the content it actually needs, through specialized graph and read tools.
POINTERS · the compact reference
Project, chunk ID, file, score — plus on-demand metadata: cluster ID, c-TF-IDF cluster keywords, TF-IDF chunk keywords, and graph neighbours. No source text yet.
Graph navigation
graphCluster / semanticGraphCluster give a cluster overview. graphNode / graphSearch traverse the AST for callers, implementations and dependency depth.
Exact source escalation
readChunks(ids) loads chunks and neighbours. readFile and readBySignature escalate to a complete file, class or method — reconstructed exactly from the index.
The hub exposes a 16-tool MCP surface. Tools are strictly project-scoped; the index is shared across projects.
One index for the whole system landscape
As a central Multi-Project Intelligence Hub, prjxp links arbitrarily many repositories and live workspaces across departmental boundaries.
Static archives
Drop a tar archive or mount a frozen project. It is chunked and embedded in-process, then stamped with its own project ID.
Live workspaces
Mount active projects with a prjxp.yaml marker or a CI drop-in directory. The LLM always works on the real build state.
Deterministic indexing
No LLM in the code/index path means a full reindex of 991 files takes four to five minutes, and an atomic swap is a matter of seconds.
Dual-graph Lucene RAG vs. classic Graph-RAG
| Dimension | Classic Graph-RAG | Dual-graph Lucene RAG (hub) |
|---|---|---|
| Index construction | Probabilistic LLM extraction; high cost. | 100% deterministic in the code/index path (AST, HNSW, Leiden, c-TF-IDF); document conversion optionally uses a vision LLM. |
| Maintenance & updates | Elaborate entity resolution on code changes. | Atomic swap in seconds; full reindex of 991 files in 4–5 min. |
| Retrieval pattern | Rigid top-k or massive subgraph dumps. | Metadata-first triage with TF-IDF signatures and tool calls. |
| Infrastructure | Distributed stack (vector DB + graph DB). | Single-engine embedded architecture (Apache Lucene). |
Highest quality, smallest context
Four pure arms on a frozen corpus, nine stratified questions, three runs per cell, the same model and the same budget. Score is coverage × precision.
| Rank | Arm | Coverage | Precision | Score | QPM | QEI | Tokens eff. | Peak | Duration |
|---|---|---|---|---|---|---|---|---|---|
| 1 | P | 0.63 | 1.00 | 0.63 | 21.9 | 2.02 | 29,138 | 11,768 | 33.2 s |
| 2 | N | 0.60 | 1.00 | 0.60 | 15.6 | 1.45 | 39,330 | 13,485 | 44.0 s |
| 3 | G | 0.41 | 0.99 | 0.41 | 11.7 | 1.11 | 29,098 | 13,328 | 46.2 s |
| 4 | V | 0.38 | 0.94 | 0.36 | 7.3 | 0.70 | 52,313 | 17,676 | 51.6 s |
Four-arm run: P from the final run of 15 Nov, N/G/V from the main run of 14 Nov. Same corpus commit, model, seed and judge.
Same run, two corpora — including the inconvenient result
To address the mixed-run weakness, N and P were measured again in a single run on both the prjxp corpus and a real legacy project. The score advantage holds; the cost leadership does not survive the grown tool schema.
| Corpus | Arm | Coverage | Precision | Score | QPM | QEI | Tokens eff. | Peak | Duration |
|---|---|---|---|---|---|---|---|---|---|
| prjxp | N | 0.620 | 1.000 | 0.620 | 17.1 | 1.76 | 33,158 | 12,041 | 37.5 s |
| prjxp | P | 0.647 | 0.981 | 0.639 | 21.9 | 1.81 | 27,960 | 13,583 | 44.9 s |
| Legacy | N | 0.434 | 0.967 | 0.430 | 9.3 | 1.03 | 41,524 | 14,107 | 41.7 s |
| Legacy | P | 0.459 | 0.992 | 0.459 | 11.7 | 1.13 | 30,497 | 14,228 | 54.0 s |
The robust statement
At equal or better answer coverage, the hub needs substantially less retrieval context — 22,055 instead of 30,128 tokens on prjxp and 23,850 instead of 38,615 on the legacy corpus. The score advantage holds on both corpora.
The price: tool-schema overhead
With 16 tools the static schema grows to ~3,018 tokens per turn. Peak context and runtime are therefore no longer below the naive arm. The next lever is schema size, not retrieval.
What the paper does not claim
The benchmark is honest about its scope. Contrary results and regressions stay visible instead of being smoothed over.
- One commit, two corpora. Results hold for prjxp at commit
2870c6aand one anonymised legacy project — a sample, not all legacy code. - Runs are not byte-identical. The P arm was developed further between runs; statements are comparative within a run.
- Counter-check is N/P-only. G and V were not re-measured and remain the four-arm reference.
- G is not the full GraphRAG paradigm. It ran code-only, without LLM entity extraction.
- V is deliberately naive. Standard 1000/100 chunking is not code-aware, so the gap also measures chunking quality.
- Tool sets are not equivalent. Different granularity complicates causal attribution of individual percentage points.
- Judge and arm share the model. The judge is blind to arm assignment but a self-evaluation bias remains possible.
- Stage B is stochastic. The protocol is reproducible, not the individual answer — hence medians, min/max and IQR.
Also openly reported: the regressions
In the 15 November run, F7 costs 10,139 more retrieval tokens and F8 4,291 more; F6 loses 0.15 coverage. The median is eleven tool calls, above the budget of eight. On the algorithmics question F8, P falls back to 0.39 while the naive arm reaches 0.72.
Next: from retrieval to the product
These are deliberately not current functionality. They are conceptually prepared or concern extensions outside the measured code/index path.
Cross-project contracts
Detect an interface change in project A, locate its consumers in project B and check for breaking changes automatically. Today all tools are strictly project-scoped.
Global clustering
Leiden across all projects, bundling domain-related artifacts into shared topic clusters without overloading the context window. Today cluster IDs are project-local.
Extended tools
A dedicated readChapter tool and relation/scope filters for AST traversal. Reference metadata is already stored and can be rendered on demand.
Deterministic docs pipeline
The code/index path is deterministic; PDF/image conversion and docpipe still use an LLM. An LLM-free documentation pipeline is a separate extension.
CI & AST extensions
A generic CI drop-in directory exists; Jenkins-specific integration is open. Fields as AST nodes and explicit HNSW configuration (m, beamWidth) are likewise open.
More measurement
Tenant separation, permissions, incremental updates, multi-project search, cold start and parallel load are separate product measurements.
Read it, run it, break it.
The architecture and the full benchmark are laid out above. Try prjxp on your own legacy codebase and see how it performs.