Retrieval-augmented generation (RAG) retrieves approved evidence at request time and asks a model to answer within that evidence. The production lifecycle includes identity, authorization, query handling, hybrid retrieval, reranking, context assembly, prompt policy, generation, citation validation, abstention, logging, evaluation, feedback, and deletion—not merely “put top-k chunks in a prompt.”
Each stage receives a deadline and emits a versioned trace identifier, safe reason codes, and metrics. Sensitive content is not automatically logged.
Prefer structured output such as:
The server validates that every cited chunk was in the authorized context and that citation links still resolve for the caller. A model-supplied chunk ID is untrusted until checked.
A fluent answer cannot compensate for missing evidence.
Build a trace for one request showing identity source, policy, query versions, retrieved IDs/scores, context IDs, model version, structured result, validation decision, and timing. Redact content. Test no-result, unauthorized, provider timeout, stale citation, prompt injection, and partial-stage failure.
Threat-model and instrument this RAG lifecycle [architecture]. Mark identities, trust boundaries, policy enforcement, data stores, external providers, deadlines, structured contracts, validation, abstention, logs, feedback, retention, and deletion. Produce stage-specific failure tests.
Verification contract: Every final claim must trace to an authorized context item or be explicitly labeled as non-source commentary under product policy.