Enterprise RAG
Dual-Path RAG: Why Vector Search Cannot Add
Route arithmetic to governed SQL, keep prose on a hybrid document path, and reconcile figures to the ledger before they reach an answer. The dual-path RAG pattern for regulated data.
Vector search finds passages that resemble a question. It cannot compute a total. Ask a document-only assistant to “total the enterprise value of our Q3 sell-side mandates” and it does the only thing it can: it retrieves passages that mention enterprise values and lets the model add them up.
The reference case in my book is AegisFin Corp, a fictional regulated M&A advisory and wealth management firm. Every figure in this article comes from that case, except the public benchmark results, which are cited. AegisFin’s first assistant summed six enterprise values it found in pitch-book prose and reported a Q3 total of $1.84 billion. The deal ledger recorded $3.27 billion across eleven mandates. The figures the answer needed were never in the retrieved text, so no choice of model would have produced the right total.
My position is that numbers and prose need separate retrieval paths, scoped by the same identity and checked by the same release controls before anything reaches a user.
Both obvious approaches fail on numbers, for different reasons
The natural fix is to let a model write SQL. Public benchmarks show how far that falls short on enterprise schemas. In the Spider 2.0 paper (Lei et al., ICLR 2025), DAIL-SQL with GPT-4o reaches 86.6% execution accuracy on the original Spider benchmark and 5.68% on Spider 2.0-lite, the benchmark’s self-contained text-to-SQL setting built on enterprise databases. The authors’ strongest agent solves 21.3% of the full benchmark’s 632 tasks.
AegisFin’s own schema produced the same gap.
| Approach | Question | Reported | Ledger | Cause |
|---|---|---|---|---|
| Document-only RAG | Q3 total enterprise value, sell-side mandates | $1.84bn | $3.27bn | Model summed six values found in prose |
| Raw Text-to-SQL under row-level security | Q3 success fees | $47.9m across 14 mandates | $21.6m across 9 | Join repeated fees once per tranche; filter used the transaction date |
Source: AegisFin Corp reference case (fictional), Production-Grade Enterprise RAG Architecture, Vol. 1.
The second failure teaches more. The query was valid and correctly scoped by row-level security, and it was still wrong twice. Five of the nine mandates had closed in tranches, so the join counted their fees more than once, and the date filter pulled in fees from the previous quarter. Row-level security decides which rows a query may see. It has no say over whether the query computes the right figure.
Each question goes to the path that can prove its answer
Dual-path RAG routes each question by what its answer needs. The document path answers questions about language, such as clauses, memos and policies. It runs hybrid retrieval, with dense and lexical search fused and reranked, inside the caller’s authorized scope. The analytical path answers questions about numbers through certified metrics, executed under row-level security in the database.
Composite questions, such as “Q3 success fees, and the engagement letters that cap them”, use both. When the document question refers to the deals the figures cover, the document path waits for the analytical result and, once the Balance Guard has passed, searches only those deals inside the caller’s scope. Other composite plans run the two paths independently. Both paths run under one signed identity, and a small planner model routes between them in a loop with hard limits. The third hop is the last, and a Balance Guard block ends the loop at once, because replanning cannot repair a ledger mismatch.
Source: Author's diagram of the dual-path design in Production-Grade Enterprise RAG Architecture, Vol. 1.
The analytical path holds only under three constraints
- Certified metrics only. A schema retrieval step offers the planner a few certified metric cards, each described by its Finance data owner, and a plan may name only those. When no card matches with enough confidence, the analytical path abstains. A semantic layer that follows dbt MetricFlow conventions compiles the SQL and aggregates each metric on its own, so a fee total cannot fan out across tranche rows. The semantic layer never executes the SQL, and the planner can reach no tool that holds a warehouse credential.
- Scope enforced by the database engine. The application executes the compiled query under forced row-level security with the caller’s signed context, in one read-only snapshot that also holds the ledger controls, so a load in flight cannot split them.
- A Balance Guard before any model sees a figure. Four exact checks run on
Decimalvalues: the values are exact, they sit in the metric’s certified range, the fee total equals the revenue posted to the general ledger for the same scope and period, and debits equal credits in that ledger slice. Zero rows is reported as “no records in your scope” and never as $0.
At query time these controls cost little. In staging, SQL-only answers reached first token at 1.6 seconds p95. Composite answers took 2.4 seconds, and each extra planner hop of about 650 milliseconds pushed them past the 2.7 second budget for composite answers. A cached small planner cut a hop to about 280 milliseconds and a composite answer to 2.0 seconds.
The real cost is governance. In the reference case, modeling the ten most-queried tables took Finance and data engineering five weeks, and the Balance Guard can reconcile a metric only when a ledger control exists for it. Release gates for enterprise RAG shows what happened when one metric had none.
The document path needs as much engineering as the analytical one
Adding lexical search to a vector index is where hybrid retrieval starts. In the reference case, three decisions on the document path looked minor and turned out to be expensive.
| Decision | What happened | What fixed it |
|---|---|---|
| Widening context to fix recall | Raising the parent limit from 3 to 8 and the context budget to 12,000 tokens moved golden-set failures only from 9.4% to 8.8%, while time-to-first-token p95 rose from 3.6 s to 9.8 s, and abandonment from 4% to 23% | Hybrid recall with reranking and a token limit: failures at 2.6%, p95 at 2.1 s |
| Shrinking chunks | Dividing chunk size by four multiplies vectors, memory and serverless query cost by four | Parent-child retrieval: search children of up to 256 tokens, read parents of up to 1,500 |
| Off-the-shelf sparse encoder on a shared index | Each token mapped to a public hash; a red team reading a nightly backup named 96% of the token ids in a 10,000-point sample | Token ids keyed per tenant |
Source: AegisFin Corp reference case (fictional), Production-Grade Enterprise RAG Architecture, Vol. 1.
The third lesson is the easiest to miss. A sparse vector built on a public hash is a list of words in all but name. In the reference case it put back terms the design had deliberately removed from the stored payload, so the lexical index exposed what the rest of the design had been built to hide.
Citations make every figure traceable
Every sentence in the final answer cites its evidence: a chunk from the document path, or a verified figure from the analytical path. The model copies verified figures and does not calculate them. A sentence without a valid citation is blocked, and every number in a sentence must match its source. A hash-chained audit record of who asked and which evidence was used must commit before any sentence is released, and a second record holds exactly what was shown.
A citation check proves that a source exists and that the numbers match it. It cannot prove that the passage supports what the sentence claims, which is why the release gate adds a graded groundedness check.
When I review a dual-path design, I ask for three things: the metric catalog, showing which metrics have a ledger control, the gateway allowlist showing that no tool can execute SQL on the planner’s behalf, and the audit record that links each released sentence to its evidence.