RAG and Vector Search · Exercise 5 of 5 Previous
Advanced
Triage an incident snapshot
Write triage(m) taking a dict with the keys cross_tenant_hits, index_docs, docs_expected, oldest_wait and cost_micro, and returning the list of alert names that apply, in this priority order:
1. "leak" when cross_tenant_hits is above 0. 2. "shrunken index" when index_docs * 2 is less than docs_expected. 3. "stale answers" when oldest_wait is above 48. 4. "cost spike" when cost_micro is above 2 * 1700. A healthy snapshot returns an empty list.
What Check tests
- Healthy snapshot has no alerts
- Empty index is a shrunken index
- Exactly half the documents is not shrunken
- A leak comes first
- Thresholds are strict
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.