Five guard recipes and their checks
Production versions use your store's filter instead of a list comprehension and a proper HTML or Markdown escaper for your renderer. The checks stay the same.
Five small recipes to copy into any RAG project: a fail-closed access filter, an untrusted-text wrapper, a redactor, a deletion audit and a tenant-safe cache key, each with a check, plus the checklist to run before you ship.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Add output_ok(answer, sent_ids) to the recipes and print ok or FAIL for a cited answer and for the bare answer banana.
Write registry_complete(stores, registry) that returns the names in stores that are missing from registry, so a new store cannot be added without being added to the delete and the audit.
Explain it without notes
Walk through the pre-ship checklist and say what incident each line prevents.
Why should the access filter, the redactor and the audit live in one module that every code path uses?
How does row-level security improve a shared-index multi-tenant design?
What should a CI security test for a RAG system include?
Expected output
ok acl: no groups sees nothing
ok acl: public sees only C1
ok wrap: a passage cannot close the tag
ok redact: email and card removed
ok audit: finds the cache
ok key: tenants differ, case does not