promptdojo_

The data firewall — no employee data in prompts, as code — step 7 of 8

Write prompt_gate(payload) — the check every prompt payload passes before anything is sent.

payload is a dict: {"id": str, "source": str, "text": str}.

Build a reasons list in this order:

  1. Provenance first: if payload["source"] is not in APPROVED, append "unapproved source: {source}".
  2. Then the phrase scan: lowercase the text, then for each category in NEVER (dict order) and each phrase in its list (list order), append "{category}: {phrase}" for every phrase found as a substring.

Return ("BLOCK", reasons) if reasons is non-empty, else ("ALLOW", []).

Four payloads run through the report loop (provided). Expected output:

P1: ALLOW
P2: BLOCK — unapproved source: hris-export
P3: BLOCK — medical: diagnosis; medical: accommodation
P4: BLOCK — unapproved source: er-notes; er: grievance

full-screen editor opens — close anytime to keep reading.