Interview question
Contain and recover from a poisoned RAG index
Handles a poisoned retrieval corpus by freezing ingestion, tracing provenance, switching immutable index versions, rebuilding clean data, and proving recovery.
TL;DR
Handles a poisoned retrieval corpus by freezing ingestion, tracing provenance, switching immutable index versions, rebuilding clean data, and proving recovery.
Data provenance, immutable indexing, blast-radius analysis, containment, clean rebuilds, evaluation, alias promotion, and recurrence prevention.
Practice the problem like a real interview: restate, reason, implement, and test.
A compromised connector inserted plausible but false policy documents into the retrieval corpus. Answers citing those chunks reached users for several hours. Design containment, blast-radius analysis, clean recovery, and preventive controls. The index is large, so deleting suspicious rows in place would be faster but would destroy version consistency and make rollback difficult.
connector=shared-drive-v2, source_account=sync-bot-4, ingestion_run=run-983
poisoned document IDs share provenance but have already produced chunks in index build 2026-07-30.4
production alias policy-current -> build 2026-07-30.4
last attested clean build -> 2026-07-29.2.
async def recover_poisoned_index(incident: Incident):
await connectors.disable(incident.connector_id)
await credentials.revoke(incident.credential_id)
await indexes.freeze(incident.poisoned_build)
clean_build = await indexes.last_attested_clean_before(incident.started_at)
await aliases.compare_and_swap(
name="policy-current",
expected=incident.poisoned_build,
replacement=clean_build.id,
)
impact = await provenance.trace_ingestion_run(incident.ingestion_run_id)
restored_sources = await sources.restore_and_attest(impact.source_ids)
candidate = await indexes.build_new(restored_sources, immutable=True)
report = await evaluations.run(
candidate,
suites=["retrieval", "grounding", "poisoning_attacks", "tenant_isolation"],
)
if not report.release_gates_pass:
raise RecoveryGateFailed(report.id)
await aliases.canary_then_promote("policy-current", candidate.id)
return impact, report
Impact tracing is linear in affected provenance edges and derived artifacts. A full rebuild is expensive, but immutable versions make containment and rollback constant-time alias operations.
Next in AI Production Scenarios & Labs: Review managed AI architecture