Northwind: Architecture case: a permission-aware document assistant
Outcome. After this lesson, you can treat retrieval as a versioned, permissioned projection.
Hypothetical scenario. At Northwind, Priya must retrieve current policy without exposing restricted personnel records.
In short. Preserve evidence identity and permissions across every derived artifact. Invalidate derived evidence when permission changes.
The answer must belong to the reader
Hypothetical scenario. An organization wants a document assistant that answers questions from internal policies and engineering notes. A fluent answer is insufficient: its sources must be permitted for the requesting employee, current for the question and adequate to support the claims made.
This final case designs a bounded read-only assistant. It can retrieve, explain and cite; it cannot edit documents, send messages or make business commitments. Those action capabilities need separate authority and recovery contracts. The design combines the system-design course with the GenAI course's evidence and runtime lessons.
Define the initial product outcome as an answer supported by eligible source passages, or an explicit limitation when the available evidence is inadequate. Do not promise universal factual correctness, immediate synchronization from every source, or permission safety from a model instruction alone.
Nearest vectors are not the entire system
A vector index can select similar passages without establishing access, current version, deletion status or sufficient evidence. A model can then produce a persuasive answer from the wrong material. Improving similarity does not repair a missing authorization boundary.
Index ingestion also fails independently from query serving. A connector can miss updates, a parser can omit tables and an embedding change can mix incompatible vector spaces. The service needs source identity, versioned transformations and visibility into the freshness of each collection.
The retrieval-augmented generation paper by Lewis and colleagues combines parametric generation with retrieved external memory in a specific research architecture. Its results do not establish this application's permission, freshness or answer-quality contract. Those are system requirements to design and evaluate.
Connect source authority to answer evidence
Ingestion records source identity, version, access scope and deletion state before deriving chunks and embeddings. A complete index version identifies the parser, chunking policy and embedding space. Switch query routing only when the intended collection is ready and retain a supported rollback path.
Query handling authenticates the reader, establishes permitted scope, retrieves candidates and expands eligible source passages. Lexical retrieval can preserve exact identifiers while embeddings capture a different similarity signal. Combining their rankings requires a declared fusion and evaluation policy; raw scores from unrelated systems are not automatically comparable.
The generator receives a bounded evidence set with stable source references. Validate output structure, citation targets and claim support separately. A valid citation URL does not establish that the linked passage supports the claim. Preserve the selected versions for authorized investigation under an explicit retention policy.
Treat retrieval as a versioned, permissioned projection
Priya's policy assistant needs an answer that belongs to the current reader and points to current evidence. A vector index is a derived representation of source material. Embeddings, chunks, lexical indexes, reranker inputs and answer caches all carry consequences of source identity and access rules. A nearest-neighbor result is a candidate; it is not proof that the reader is entitled to see the document.
Use an illustrative collection of one hundred thousand source pages, each represented by four chunks. That produces 100,000 × 4 = 400,000 chunks before any later version or duplication is retained. If one thousand source pages change, the same four-chunk assumption gives 4,000 chunk replacements. The migration needs a rule for withdrawing the old versions and confirming that the new projection is complete. Indexing four thousand new chunks alone does not establish that obsolete chunks stopped being served.
The answer request should carry the authenticated reader context through each evidence-producing step. Filter or validate eligibility at the appropriate serving boundary, then preserve source version and chunk identity in the supplied context and citations. A cache key that includes the question but omits the authorization and evidence identity can return a previously valid answer to the wrong reader. Revocation and deletion are serving events, not merely background indexing work.
Separate the intervention from its evaluation. A new embedding model changes the representation space; a new chunking policy changes what evidence can be retrieved; a new prompt changes how that evidence is used. Compare the affected failure slices and preserve a rollback route with compatible artifacts. The complete design includes ingestion, retrieval, permission checks, generation, citations, operational budgets and evidence of accepted outcomes, rather than treating a successful demonstration answer as a release decision.
Derive storage, context and request demand
Hypothetical scenario. Choose 10,000 documents averaging 2,000 tokens of extracted content: 10,000 × 2,000 = 20 million source tokens. A simple chosen split uses 500-token chunks with no overlap, giving four chunks per document and 40,000 chunks. Real boundaries and overlap change that count.
Choose 768 coordinates per embedding and four bytes per coordinate. Raw vector payload is 40,000 × 768 × 4 = 122,880,000 bytes, or 122.88 MB. This excludes text, metadata, graph structures, quantization choices, replicas and index overhead. It is not a complete vector-store sizing result.
For one answer, choose six selected chunks of 500 tokens each: 6 × 500 = 3,000 evidence tokens. Add a chosen 1,000 tokens for instructions, question and retained conversation, plus a 1,000-token output allowance. The planned total is 3,000 + 1,000 + 1,000 = 5,000 tokens, before any additional serialization or tool content. Tokenization must be measured with the selected model's actual representation.
At a chosen 20 logical questions per second, input demand under this plan is 20 × 4,000 = 80,000 tokens per second, and maximum reserved output demand is 20 × 1,000 = 20,000 tokens per second. These are request budgets, not measured generation throughput or current provider pricing. Retries and evaluation calls add demand.
For a hypothetical 100-case review set, suppose 20 cases lack required eligible evidence, ten have adequate evidence but unsupported answers, and 70 meet the full rubric. The outcome is 70 ÷ 100 = 0.7 on this constructed set. It is not a claim of population accuracy. Overlapping failure categories would require different accounting, so these categories are explicitly disjoint.
In the wild: Treat retrieval as a versioned, permissioned projection
The primary reference establishes this concrete distinction: the RAG research paper describes a specific retrieval-generation architecture, not application permission guarantees.
Freshness and permission are serving decisions
A revoked document can remain in an old index or cache. Define a freshness objective for permission changes and decide whether source eligibility must be rechecked before passage expansion and answer delivery. If the permission service is unavailable, returning cached content may violate the contract even when retrieval latency looks healthy.
A useful answer cache includes identity, permitted scope, source versions and model or prompt version as relevant to its correctness. Semantic similarity between questions does not establish equivalent answers or equivalent access. Prefer an explicit miss over cross-scope reuse.
Rebuilding an embedding space requires compatible query and document representations. Run the new collection alongside the old, compare retrieval failures and switch atomically at the collection-routing boundary. Do not mix old and new vectors and assume their numerical dimensions make them comparable.
A stale index survives a permission change
Hypothetical scenario. A policy document becomes restricted, but the connector misses the permission update. A previously cached answer contains its content. A new reader asks a similar question, and the cache returns the earlier answer without evaluating current scope.
The failure is an authorization and derived-state problem, not simply a hallucination. Recheck permission-relevant eligibility, invalidate affected derivatives and record index freshness. Avoid placing sensitive retrieved text in unrestricted telemetry while investigating the incident.
Measure denied retrievals, stale source observations, ingestion lag and answer limitations separately from generic request success. Maintain a supported deletion and reindex procedure. A successful connector poll does not prove every source event was included.
Bring advanced capabilities under the same contract
Self-hosted generation introduces weights, request state, batching and admission constraints. Budget those resources as taught in the runtime lessons; raw embedding payload says nothing about generation memory. Quantization and parallelism are candidate implementation choices requiring quality and serving evidence.
An optional agent loop would add durable task state, authorized tools, stopping budgets and uncertain-action recovery. This read-only design does not inherit those capabilities by calling retrieval a tool. Anthropic's Building effective agents distinguishes predefined workflows from dynamically directed agents; use the simpler path when it satisfies the task.
Evaluation separates eligible retrieval, source support, answer usefulness, refusal behavior and permission failures. A model judge is an imperfect measurement instrument; calibrate it against a written rubric and human-reviewed cases. A single blended score can hide a serious failure category.
A gateway can enforce identity, budgets and routing, but cannot make model outputs safe by labeling them checked. A fallback model changes answer behavior and may require another evaluation. A gateway cache needs the same source and permission boundary as the primary path.
An expanded employee copilot would cross more source and action authorities. Add one capability at a time with its own contract. Do not promise arbitrary editing, multimodal interpretation or enterprise-wide permission synchronization merely because the read-only assistant has a complete diagram.
Follow the complete learning path for this same assistant: define acceptance, bound candidate fusion and reranking, compare outcomes, choose safe answer reuse, and reserve serving resources. Add durable action state only if the scope expands beyond answering. Each link develops a separate architectural decision rather than another competing version of the course.
Defend the release and rollback plan
Release a baseline that returns ranked source excerpts before adding generation. Evaluate whether synthesis improves the defined task and where it introduces unsupported claims. Compare changes on held-out cases and explicit permission and missing-evidence tests rather than only attractive demonstrations.
Retain versioned prompts, model configuration and index routing for rollback. Rollback cannot undo content already disclosed, so permission failures require immediate containment and investigation as well as configuration reversal. Bound retained evidence and restrict access to it.
Reject autonomous editing in the initial scope, unlimited history, cross-tenant semantic reuse and a universal answer-quality percentage. Estimate operating cost from actual request counts, measured token usage and verified prices when selecting a deployment; no price estimate here is presented as a current vendor quote.
Limits of this model
The collection and change counts are illustrative. Retrieval quality, source access, revocation propagation, model behavior and artifact compatibility require separate evidence. Permission filtering alone does not establish answer correctness, and a successful answer demonstration cannot certify the operated workflow.
Final exercise: review the assistant
A change raises answer usefulness but leaks a restricted passage in one evaluation case. Is the overall mean sufficient to approve it?
No. Permission is a separate required contract. Investigate and fix the eligibility path, assess disclosure and test the failure category explicitly. A favorable blended mean does not compensate for an unacceptable boundary violation.
A new embedding model has the same vector dimension. Can its query vectors search the old collection safely?
Equal dimension does not establish a compatible representation. Build and evaluate a compatible collection, retain versions and switch routing deliberately. Compare exact-identifier and semantic cases separately.
The product now wants the assistant to edit a policy after answering. What additional design is required?
Specify action authorization, argument and version validation, a durable task state, bounded execution, confirmation where required, operation identity and recovery from uncertain writes. Retrieved instructions cannot grant that authority. Re-evaluate the full workflow rather than treating editing as another output format.
Northwind decision log
Preserve evidence identity and permissions across every derived artifact.
Invalidate derived evidence when permission changes.
Test answer citations against their current source versions.
Go deeper: Treat retrieval as a versioned, permissioned projection
- Video lecture: System models — Martin Kleppmann. Name the trust and failure assumptions shared by ingestion and serving.
- Book chapter: AI-Powered Search, chapter 13: Semantic search with dense vectors — Trey Grainger, Doug Turnbull, Max Irwin. Read Semantic search with dense vectors while considering how to treat retrieval as a versioned, permissioned projection.
- Book chapter: Software Telemetry, chapter 15: Ensuring telemetry integrity — Jamie Riedesel. Read Ensuring telemetry integrity while considering how to treat retrieval as a versioned, permissioned projection.
- Primary source: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks — Lewis, Patrick; Perez, Ethan; Piktus, Aleksandra; Petroni, Fabio; Karpukhin, Vladimir; Goyal, Naman; Küttler, Heinrich; Lewis, Mike; Yih, Wen-tau; Rocktäschel, Tim; Riedel, Sebastian; Kiela, Douwe. Test answer citations against their current source versions.
Related blog: Tracing a wrong paragraph back through retrieval.