ProjectA PII firewall for LLM apps · Before you start · part 1 of 9
Part 1 · Before you start

Before you start

6 min read·12 Oct 2026

Twenty minutes that decide whether the next ten hours are a build or a struggle. Answer the six questions below honestly, check what you will have at the end against what you want, set up the folder, and read how this guide holds back on purpose.

Readiness check

Answer each one in your head, then open the answer. Score yourself: five or six right, start now. Three or four, start, but open the linked kit when the milestone named next to the question arrives. Two or fewer, read the linked kit first; this project assumes those ideas and does not teach them.

1. A detector flags 100 strings as Aadhaar numbers. 90 really are; it missed 30 others. What are its precision and recall, and which one would a privacy officer complain about first? (milestone 1, AI Security kit)

Precision 90 of 100, 0.90. Recall 90 of 120, 0.75. The privacy officer complains about recall: every miss is an identifier that reached the model and the logs. False positives cost you a masked word; false negatives cost you a breach report. A firewall favours recall, and milestone 3 is about paying for that with as little precision as possible.

2. Your RAG app masks the user's message before the prompt. Name two other places the raw identifier still ends up. (milestone 5, LLMOps kit, RAG course)

The trace or log line written by your observability layer, which usually records the request body before your code ran; and the retrieved documents, which may themselves contain identifiers that were never masked at ingestion. A third: the model's answer, which can repeat the identifier from the context. The firewall in milestone 5 covers the prompt, the answer and the logs; the retrieval side is an extension.

3. Why can a 12-digit number be rejected as an Aadhaar without a database lookup, and why can a PAN not be rejected the same way? (milestone 2)

Aadhaar's last digit is a Verhoeff check digit computed from the other eleven, so nine out of ten random 12-digit strings fail the check. PAN is five letters, four digits and a letter with no check digit; the only structural test is the format and the fourth letter, which encodes the holder type (P for a person, C for a company, and so on). A valid-looking PAN is not evidence of a real one, and your README will have to say so.

4. What does the DPDP Act, 2023 call the organisation that decides why and how personal data is processed, and name two things it owes the person. (milestone 7, Finance RAG and Agents kit, Healthcare RAG and Agents kit)

The Data Fiduciary. Among what it owes the Data Principal: reasonable security safeguards to prevent a breach, intimation of a breach to the Data Protection Board and to the affected people, and erasure once the purpose is served or consent is withdrawn. The Rules notified in November 2025 add specifics, including masking and tokenisation among the named safeguards and a time limit for the detailed breach report. In milestone 7 you cite the exact sections and rules from the Gazette text, not from memory.

5. Write a regex that matches a 10-digit Indian mobile number starting with 6 to 9, optionally preceded by +91 or 0, but not when it is part of a longer digit run. (milestone 2, Python course)

One working shape: (?<!\d)(?:\+91[\s-]?|0)?([6-9]\d{9})(?!\d). The lookbehind and lookahead stop it matching the middle of an Aadhaar or an account number. If you wrote something close, good. If the lookarounds are new to you, the Python course's regex part is a 40-minute read and milestone 2 will go faster for it.

6. A model-based name detector costs 40 ms per message and catches 20 points more recall on names than your regex. The app handles 2 million messages a month. Is it worth it? (milestone 7)

You cannot answer without two more numbers: what a missed name costs you, and what 40 ms does to your p95. That is the point of the question. Milestone 7 makes you produce the latency table and the INR per 10,000 messages so that this becomes a decision with numbers rather than a preference.

What you will have at the end

A repository you own, built from an empty folder, with:

  • data/messages.jsonl: 300 synthetic support chats, KYC notes and clinic notes with span labels for six entity types. Generated by a script you are given, never real data.
  • piiwall/: a package with a scorer, five pattern recognisers, a context scorer, an optional model-assisted name detector, a token vault and a guard() function that wraps any OpenAI-compatible chat call.
  • reports/: a per-entity precision, recall and F1 table for each detector version; an evasion table with recall before and after the fix; a p50/p95 latency and INR-per-10k table.
  • README.md written as a product spec: problem, what it does, results, failure cases, decisions, a DPDP mapping table, limitations.

The measure of done is the README's results table with your own numbers in it and a limitations section that says what the firewall cannot catch. The wrap-up tells you how to talk about it in an interview and how to submit it.

Set up

Create the folder and check the two commands below before milestone 1. Nothing to clone: this project starts from empty.

bash
mkdir pii-firewall && cd pii-firewall
git init
python3 --version          # 3.11 or newer
python3 -m venv .venv && source .venv/bin/activate
pip install pytest
mkdir -p piiwall data reports tests scripts
touch piiwall/__init__.py

You should see Python 3.11 or newer and a clean pytest run that collects zero tests:

text
$ pytest -q
no tests ran in 0.01s

Milestone 4 adds presidio-analyzer, presidio-anonymizer and a spaCy model. Milestone 5 needs any OpenAI-compatible endpoint; a local Ollama with qwen2.5:7b is enough, and the milestone says what to do if you have none.

How this guide works

Each milestone opens with Try first: the task in plain words before any code. Attempt it. Then read Build, which gives you less each time. Milestone 1 gives you most of the code with gaps. Milestones 2 to 4 give you a spec and the tests to satisfy. Milestones 5 to 7 give you requirements and a rubric, and the code is yours.

Every milestone has a Checkpoint with the output you should see, three Common failures with the fix, three Hints you can open one at a time, and a Reference solution to open after your checkpoint passes, not before. Finish with the Self-check boxes.

We do not explain what a regex is, what precision is, or what the DPDP Act is. The readiness check above told you where those live. We do explain every decision that is specific to this build, under Why we chose this, so that when an interviewer asks why Verhoeff and not a lookup, or why tokens and not masks, you have an answer that is yours.