Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 10.6 — Deleting for Real
RAG and Vector Search · Example 1 of 1

Delete one document from four stores, and audit

In production the stores are a database, a vector store, a cache server and a log system. The shape is the same: find by document id, remove, audit.

When a document is removed from the source, or a person asks to be forgotten, its text must leave the chunks, the vectors, the caches, the logs and the backups. Deleting from one table is not deleting, and only an audit proves it.

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.

01

Write delete_prefix(store, prefix) that removes every key starting with the prefix from a dict and returns how many were removed. Test it on a dict with ids D5#1, D5#2, D6#1.

02

Write audit_phrase(stores, phrase) where stores maps store name to a list of strings, returning the names of stores containing the phrase (case-insensitive). Test it with one clean and one dirty store.

Explain it without notes

01

Name the derived copies a RAG system makes of a document, and say why deleting the source file is not enough.

02

How do you make sure a deletion in the source reaches the index?

03

What is a tombstone, and how does it solve the backup problem?

04

How do you prove a deletion happened, and what do you record?

Delete one document from four stores, and audit
Sign in to run this example in your browser.

Expected output

before:             chunks:D5#1, chunks:D5#2, vectors:D5#1, vectors:D5#2, cache:what if my bike is damaged, logs:1, logs:3
chunks only:        vectors:D5#1, vectors:D5#2, cache:what if my bike is damaged, logs:1, logs:3
everywhere:         nothing left
backup restored:    3 chunks, 1 after replaying tombstones