Reading tools and contents
Retrieval-Augmented Generation

Chapter 10 of 10

Operate RAG and prove mastery

Production and capstone

About 5 minutes · includes examples, an exercise, and references

Chapter at a glance

  • A RAG release pins the complete source-to-claim version tuple.
  • Freshness, deletion, authorization, claim support, and cost require end-to-end SLOs.
  • Rollouts use fixed evaluation, shadowing, canaries, security gates, and coherent rollback.

Production RAG is a continuously changing evidence service. Sources publish revisions, permissions change, index generations roll, models drift, queries shift, and incidents expose unknown failure modes. Operations must preserve a chain from authoritative source to returned claim while meeting latency, cost, availability, privacy, and security objectives. A fluent answer is only one artifact of that chain.

Partition the architecture into owned services. Source connectors and parsers build evidence units. Index builders publish lexical and vector generations. A query service resolves policy and retrieves candidates. A context service constructs packets. A generation service invokes models without ambient authority. A verifier assesses claims and citations. An evidence store retains governed run artifacts. Each boundary has authenticated identities, schemas, deadlines, and owners. Smaller systems may combine deployments, but should preserve logical contracts.

Version the complete release tuple: source watermarks, parser, chunking, analyzers, embedding model and input, vector index, lexical index, query planner, fusion, reranker, context policy, generator, prompt policy, output schema, verifier, and evaluator. A response records the tuple or a release ID that resolves to it. This is the minimum information needed to compare behavior and investigate regressions.

Rollouts begin offline on fixed corpora and cases, then shadow on protected production-like traffic, canary by low-risk slice, and expand through gates. Compare baseline and candidate on critical invariants, retrieval and claim metrics, abstention, security tests, p95 and p99 latency, cost, and error reasons. Model upgrades can change citation behavior even when retrieval is identical. Index and model rollouts should be independently reversible unless their versions are coupled.

Freshness and deletion need source-to-answer SLOs. Track source event time, ingestion, parsing, embedding, index promotion, replica watermark, cache invalidation, and query visibility. Urgent permission revocation takes a fast masking path and later physical cleanup. Test that a deleted unit cannot appear in candidates, packets, responses, caches, or new evaluation artifacts. Historical evidence retention follows legal and incident policy rather than ordinary search availability.

Observe stages with traces, metrics, and protected logs. A run trace records request and release identity, policy decision reference, plan branches, adapter statuses, candidate counts and IDs under controlled access, context selection, model call metadata, claim validation, terminal reason, cost, and latency. OpenTelemetry semantic conventions provide a consistent base, but avoid unbounded metric labels and raw sensitive content. Sample full traces by risk, anomaly, and consent policy.

Define SLOs beyond uptime: authorized-answer rate, verified-answer rate, correct-abstention rate, corpus freshness, urgent-revocation latency, index coverage, retrieval candidate recall on probes, claim-support rate on sampled cases, unknown-citation count, degraded-route rate, cost per verified answer, and cleanup completeness. Some quality measures arrive slowly. Use canary probes and leading indicators without claiming they replace judgments.

Capacity budgets include embedding throughput, index build headroom, vector memory, search fan-out, reranker batches, context tokens, generator throughput, verifier calls, evidence storage, and evaluation capacity. Admission control should reject or queue work before deadlines become impossible. Cache query embeddings and safe retrieval stages with complete scope keys. Do not cache final answers across changing evidence or policy without generation-aware validation.

Prepare runbooks for source compromise, poisoned generation, stale permissions, index corruption, embedding regression, generator outage, verifier outage, provider data-policy change, runaway adaptive loops, and unsupported-claim reports. Kill switches should disable an external corpus, model, query route, or generation. Recovery includes fixed probes, policy tests, citation resolution, and trace inspection. Run game days and convert discoveries into tests.

The mastery capstone is an ontology-aware technical-support agent over a versioned corpus. Build deterministic ingestion with lineage and access tags; lexical and dense retrieval with fusion; context coverage and token budgets; structured claims and citations; bounded corrective retrieval; independent verification; and a harness that records evidence, budgets, and faults. The ontology should define product, version, component, symptom, cause, and remediation relations and be used for scope or facet coverage without replacing textual evidence.

Evaluate the capstone on direct facts, paraphrases, identifiers, multi-hop dependencies, version conflicts, missing evidence, restricted evidence, stale content, injected instructions, poisoned passages, and service faults. Report corpus, candidate, context, claim, abstention, security, latency, and cost metrics. Include exact-versus-ANN tests where applicable and multiple generation trials. Demonstrate a deletion, a model rollback, a retrieval timeout fallback, and a failed citation.

Acceptance evidence should let an independent reviewer replay the deterministic stages from an immutable fixture, inspect every returned claim’s sources, verify that budgets and policies held, and reproduce evaluation. Document remaining limitations: unsupported languages, source gaps, judge uncertainty, model-provider dependencies, and residual injection risk. Do not claim production readiness from a polished demonstration.

Operational maturity means the system can say what it knew, why it retrieved it, which evidence reached the model, which claims were supported, what it declined, and how the release behaved under failure. That transparency enables improvement and accountable use.

Key points

  • A RAG release pins the complete source-to-claim version tuple.
  • Freshness, deletion, authorization, claim support, and cost require end-to-end SLOs.
  • Rollouts use fixed evaluation, shadowing, canaries, security gates, and coherent rollback.
  • Mastery is demonstrated through reproducible evidence and failure tests, not a fluent demo.

Worked examples

Toy

Replayable release fixture

A three-document corpus and deterministic retriever reproduce a cited answer.

Pin corpus and policy versions, run the query, save candidates and packet, validate citation handles, then replay after changing only the generator fixture.

  • Deterministic stage outputs match.
  • Generation variance is isolated.
  • The release tuple is complete.

Application

Versioned support assistant rollout

A new embedding and generator are introduced to a live documentation assistant.

Build dual indexes, run fixed and shadow evaluations, canary low-risk tenants, monitor claim and operational gates, then promote or roll back components coherently.

  • Exact identifiers remain a critical slice.
  • Citation changes are measured.
  • Urgent revocation works in both generations.

System

Poisoning incident response

A compromised source revision targets a common remediation query.

Quarantine the source and generation, purge scoped caches, identify affected runs by evidence ID, restore a verified generation, replay probes, and add a protected adversarial fixture.

  • Containment is source- and generation-specific.
  • Affected claims can be enumerated.
  • Recovery verifies policy and support, not only uptime.

Exercise

Deliver the mastery capstone

Build, evaluate, and operate an ontology-aware, versioned support RAG system.

  1. Implement the complete source-to-claim evidence chain with policies and budgets.
  2. Run relevance, claim, abstention, security, fault, deletion, load, and rollback tests.
  3. Produce a release manifest, evaluation report, incident runbook, and limitations statement.

Success criteria

  • An independent reviewer can replay deterministic stages and resolve every citation.
  • Unsupported, conflicting, restricted, and injected cases reach safe terminal outcomes.
  • The system demonstrates coherent canary, rollback, revocation, and evidence scoping.

Reflect: Which remaining uncertainty is most important to communicate before real users rely on the system?

References and further reading