Design an Enterprise RAG Assistant
In this article
- Sketch a staff assistant over internal documents on one page, from the moment a document is added to the moment an answer comes back.
- Explain why the access check belongs inside the search request, and what leaks when it runs later.
- Name, for each part of the design, the failure it prevents and one test that shows it works.
- Terms defined here: ACL leakage probe.
Overview
A company keeps thousands of internal documents, and its staff ask the same questions every day: what does this policy allow, who signs off on this. An assistant that searches those documents and answers from what it finds, a RAG assistant, sounds easy. The hard part is that not every employee may read every document, and quoting the wrong page to the wrong person is a security incident.
Brightline, a made-up home-internet provider, wants a staff assistant that answers employees from about 12,000 internal documents, some of which only some staff may read. This is not the smaller handbook assistant from the lesson Long Context and RAG, whose readers could all read all of it: this one covers the whole company and is open to contractors too, so who may read what becomes the design problem. By the end you can draw its design on one page, place the access check where it cannot leak, and say for every part what it protects and how you would test it.
Why search, and why not an agent
The documents are a staff handbook, billing policies and legal templates, about 12,000 of them, with edits every week. Every employee belongs to one or more of three access groups: support-staff, contractors and finance.
Retrieval over one long prompt follows the rule from Long Context and RAG: readers here differ, so each question needs passages picked for that caller.
The staff assistant is also not an agent. In a standard RAG pipeline the model never decides whether to search or which index to query; code runs the same fixed steps for every question: search, assemble the passages, call the model. [1] That fixed order lets you put a guard at one exact step and know it always runs.
Ingestion keeps who may read
The design has two halves, the same split Google's reference architecture names as the data ingestion subsystem and the serving subsystem. [3] Ingestion, the ingestion pipeline that turns documents into records the search can read, does its usual work: split each document into chunks, add metadata fields, compute what the search needs and store the chunks in the index. [1] Brightline adds two things.
First, it captures each document's ACL, the list of groups allowed to read it, and writes those groups onto every chunk as a metadata field, the kind of tag that filtering later matches on. [2] A chunk without groups is rejected, never stored as readable by everyone. Chunk handbook-fee-waivers#2, part of the handbook's page on waiving fees, carries support-staff; it does not carry contractors.
Second, every rebuild writes a new numbered index version, N, and keeps the previous one, N-1. The assistant reads from whichever version is marked live, so when a rebuild breaks something, moving that mark back to N-1 is one change instead of reprocessing 12,000 documents.
Where the access filter goes
There are three places to check access, and two of them are defects.
After generation. Search everything, let the model answer, then hide answers that came from a restricted page. Restricted text was already in the prompt, and the model may have blended it into a sentence that cites an allowed page.
After retrieval. Search everything, then drop the restricted chunks before building the prompt. This looks safe until the drop step fails: a bug, a missing group field, a new code path that skips it. Then restricted chunks flow straight into the prompt. A filter after retrieval is the leak this design exists to prevent.
Inside the query. The code takes the caller's groups from their signed-in identity and sends them as a filter in the search request itself; the search compares that filter with the group field on each chunk and only returns chunks those groups may read. Microsoft calls this filtering or security trimming, and its guidance is to apply it on every retrieval request, which means the signed-in user's identity has to travel all the way to that request. [2] When data for many readers shares one store, every request carries those filters, and they apply before any passage goes to the model. [2]
One question, two employees
A contractor asks the staff assistant: "When can I waive a fee for a customer?" Hybrid search is one of the standard options for a RAG search, beside vector and full-text search. [1] Brightline picks hybrid retrieval: it runs a keyword search and a meaning-based search for the same question and merges the two lists, so an exact policy term and a loosely worded question both find their page. It returns 50 candidates, a wide net so the right page is likely in it. A reranker, a second model that puts those candidates in a new order by how well each answers the question, keeps the top 3, so the prompt stays short.
Trace it for two callers on index version N.
- A
support-staffemployee asks. The filter allowssupport-staffchunks, sohandbook-fee-waivers#2is among the 50, the reranker puts it in the top 3, and the model answers with the chunk id beside the sentence it supports. - A contractor asks. The filter is built from
contractors. Search returns 50 chunks that contractors may read, andhandbook-fee-waivers#2is not one of them.
Before you read on: what does the contractor see?
The reranker never sees the fee-waiver chunk. The 3 chunks that reach the prompt are general billing pages: they mention fees but not when one may be waived, so the right reply is an abstention: the documents this person may use do not hold enough to answer, so the assistant says so and suggests asking a support lead, instead of guessing a rule. Every answer it does give stays grounded in the passages it was handed, and each sentence names the chunk it came from, so an employee can open the page and check. An answer with no chunk id counts as a failure.
Proving each part works
Brightline's evidence for a design review has four parts.
A baseline per stage. Each step deserves its own evaluation, while the end result is still what users experience. [1] Retrieval has its own evaluation methods, and the answer has its own measures, such as groundedness and completeness. [1] Brightline's eval keeps a retrieval score and an answer score for the same saved questions, never one blended number. The retrieval score is the share of saved questions whose known right chunk is in the top 3; the answer score grades the reply. The scores of the live version are the baseline each new version is compared with. When one blended score drops, you cannot tell whether search missed the page or the model ignored it; two scores name the stage to fix. The same baseline says whether the reranker earns its place: if the top-3 score is no better with it, it only adds delay.
The leakage probe. For each restricted document, the eval holds a question asked as a caller from a group that may not read it, and the test passes only if no chunk of that document comes back. For the fee-waiver question asked as a contractor, the probe expects zero chunks of handbook-fee-waivers among the 50. It runs on every new index version, because a rebuild is when a group field can go missing. That repeatable test is an ACL leakage probe. Microsoft notes that keeping the access logic in one layer is what makes it easier to validate and test. [2]
A freshness target. Freshness is the delay between a document changing and the assistant being able to find the new text; Brightline's target is 24 hours. Google's reference updates its index with streaming updates as new data is ingested, one way to keep that delay short. [3] A test edits a known document and checks that the new wording is searchable within 24 hours.
Rollback. If the new version fails its baselines or a single probe, it never goes live. A leak blocks the release even when the quality score went up.
The 5 s p95 limit for an answer, the time that 95 in 100 answers beat, is split into fixed shares, say 1 s for search and rerank together and 4 s for the model, and each stage also gets a cost per question. A reranker that adds delay or cost without a measured gain on the baseline is cut. To see which stage spent it, every request leaves a trace with the caller, the index version and each stage's timing, the observability record that lets you find a slow or wrong stage. Google's reference likewise lets you store and view logs of query and response activity in Cloud Logging. [3]
The design on one page
Read the table as the review checklist.
| part | failure it prevents | test |
|---|---|---|
| ACL captured on every chunk | a chunk readable by everyone by mistake | ingest a document with no groups; it is rejected |
| index versions N and N-1 | no way back after a bad update | switch to N-1 and replay the eval |
| group filter inside the query | restricted text in the prompt | leakage probe returns zero chunks |
| hybrid search 50, rerank to 3 | the right page missed or buried | retrieval baseline, with and without rerank |
| cited answer or abstention | invented rules, unverifiable answers | answer baseline; every claim has a chunk id |
| 24 h freshness target | answers from last week's policy | edit a document, search for the new text |
| trace per request | a slow or wrong stage you cannot find | each stage within its share of the 5 s p95 |
Common mistakes
- Trusting the prompt to keep secrets. Telling the model "do not reveal finance documents" leaves the text in its input. Remove it at the search, and prove it with the probe.
- Shipping on one score. A single quality number that went up can hide a retrieval drop the model papered over. Each step deserves its own evaluation, so keep a baseline per stage and read both. [1]
Sources
- Design and Develop a RAG Solution on Azure. Microsoft (Azure Architecture Center). Checked 21 Nov 2026.
- Design a Secure Multitenant RAG Inferencing Solution (Azure Architecture Center). Microsoft. Checked 21 Nov 2026.
- RAG infrastructure for generative AI using Agent Platform and Vector Search. Google Cloud. Checked 24 Oct 2026.
- LLM08:2025 Vector and Embedding Weaknesses. OWASP Gen AI Security Project. Checked 21 Nov 2026.
Check yourself
Check yourself
Question 1 of 13
You want 3 passages in the prompt, best first, from 50 candidates. What do you add?
Your first check counts towards your result.