AskDocs with access labels, quarantine, redaction and delete
AskDocs after Phase 10. The retrieval inside is still the word-overlap scorer from Phase 0 so that every guard's effect is easy to read. Swap in any retriever from Phases 1 to 6 behind the same function.
AskDocs gets four guards: access labels enforced inside retrieve, a quarantine and wrapper for untrusted text, a redactor at ingestion, and a delete that reaches every store and is checked by an audit.
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 a groups check to a minimal retrieve: given CHUNKS = [("C1", "public"), ("C2", "staff")] return the ids visible to a set of groups. Print the result for {"public"} and for set().
Write cache_key(question, groups) that returns the sorted groups joined by commas, a bar, and the lower-case words of the question joined by spaces. Print the keys for {"staff", "public"} and {"public"}.
Explain it without notes
List the four guards added to AskDocs and the threat each one answers.
Why does the cache key include the user's groups?
Why is the delete followed by an audit, and what does the audit in this topic check?
How does this step fit into the earlier retrieval interface without changing it much?
Expected output
stored S1: Staff get a 30 percent discount on the monthly pass. Questions go to [EMAIL].
Q (public): How do I get the staff discount on the monthly pass?
sources: D8 (3) quarantined: X1
answer: The monthly pass costs 25 dollars and includes unlimited rides of up to 45 minutes. [D8]
Q (public+staff): How do I get the staff discount on the monthly pass?
sources: S1 (7), D8 (3)
answer: Staff get a 30 percent discount on the monthly pass. [S1]
Q (public): When do shops close on public holidays?
sources: D2 (5) quarantined: X1
answer: Shops open at 7 am and close at 9 pm every day. [D2]
left after deleting D2: 0
Q (public): When do shops close on public holidays?
sources: none quarantined: X1
answer: I can't find that in the handbook.