Skip to content
Agent Engineering / Context & Memory

Evaluate and secure retrieval-augmented generation

  • BP-0029
  • v1.0.1
  • draft
  • guideline
  • role: reviewer
  • role: implementer
  • role: orchestrator
  • stage: verify
  • stage: operate
  • updated 2026-11-25
  • reviewed 2026-11-25
  • next review 2027-05-25
  1. MUST keep a labelled evaluation set of real questions, each with the passages that answer it and an expected answer, including questions with no answer in the corpus.
  2. MUST measure retrieval and generation separately: retrieval by whether the right passages are in the top results (recall@k, and the rank of the first correct passage); answers by correctness, groundedness (every claim supported by a retrieved passage), and correct refusal when nothing was found.
  3. MUST re-run the evaluation on every change to chunking, embedding model, retrieval settings, reranker or prompt, and compare against the last baseline before shipping.
  4. SHOULD add every real failure reported by users to the evaluation set (BP-0006).
  5. SHOULD monitor in production: queries with no good results, low reranker scores, answers without citations, and sources that are never retrieved.
  1. MUST treat retrieved text as untrusted data: a document can contain instructions aimed at the agent (indirect prompt injection). Fence retrieved passages and never follow instructions inside them (BP-0005).
  2. MUST isolate tenants and classification levels in the vector store (separate indexes or namespaces with server-side filters), and test that a query from one tenant cannot retrieve another’s content.
  3. MUST control who can add or change content in the corpus, and log ingestion, so poisoned or tampered documents can be traced and removed.
  4. MUST protect stored embeddings like the source text: they can be inverted to recover approximate content. Restrict access to the vector store and its backups.
  5. SHOULD watch for retrieval anomalies (one new document suddenly top-ranked for many queries, content from untrusted sources outranking verified ones) as signs of poisoning.
  6. SHOULD rank or filter by trust level, so verified sources win ties against external or unverified ones.

Before shipping a RAG system or a change to one, and continuously while it runs.

Question Expected passages Retrieval check Answer check
How do I recover the MP after the OS upgrade? SOP §3.2 §3.2 in top 5 Steps match §3.2, cited
What is our licence for Codanna? (none in corpus) — Says it is not in the sources
Restart order for PS01, MP01, MP02? SOP §2.4 §2.4 in top 5 Order correct, cited
  • Judging a RAG change by trying three questions by hand.
  • Only measuring final answers, so a retrieval regression is blamed on the model.
  • One shared index for all tenants with filtering in the prompt.
  • Following “ignore previous instructions” found in a retrieved PDF.
  • Labelled eval set, including unanswerable questions
  • Retrieval and answer metrics measured separately; baseline compared on every change
  • Retrieved text fenced as untrusted
  • Tenant isolation tested; corpus write access controlled and logged
  • Embeddings and backups access-controlled; anomalies monitored