Spaces:
Running
Sentinel β how a request flows
Every stage, in order, with what it checks and what it can return. Cheapest checks run first and a STOP short-circuits the rest, so the expensive semantic work only ever sees prompts that survived everything cheap.
β
NEW marks what V2 added. All new tiers ship switched off behind an env flag.
The whole path
βββββββββββββββββββββββββββ
β USER TYPES A PROMPT β
ββββββββββββββ¬βββββββββββββ
βΌ
βββββββββββββββββββββββββββ
β PEP INGRESS β
β POST /v1/chat β
ββββββββββββββ¬βββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β INPUT PIPELINE (cheapest first) β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β β
β βββββββββββββββββββββββββββββββββ β
β β 1 Β· NORMALIZE <1ms β whitespace, zero-width, homoglyphs β
β βββββββββββββββββ¬ββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββ β
β β 2 Β· IDENTITY <1ms β role/tenant/owned_services from β
β βββββββββββββββββ¬ββββββββββββββββ EIM TOKEN β never from prompt text β
β βΌ β
β βββββββββββββββββββββββββββββββββ β
β β 3 Β· CEDAR AUTHZ O(1) βββββ not permitted βββΊ STOP R-AUTH β
β βββββββββββββββββ¬ββββββββββββββββ β
β βΌ permitted β
β βββββββββββββββββββββββββββββββββ β
β β 4 Β· SECRETS regex βββββ hit βββββββββββββΊ STOP R-07 β
β βββββββββββββββββ¬ββββββββββββββββ db URIs, AWS keys, tokens β
β βΌ β
β βββββββββββββββββββββββββββββββββ β
β β 5 Β· INJECTION (phrases) βββββ hit βββββββββββββΊ STOP R-06 β
β βββββββββββββββββ¬ββββββββββββββββ ~40 literal jailbreak phrases β
β βΌ β
β βββββββββββββββββββββββββββββββββ β
β β 6 Β· PII regex βββββ hit βββββββββββββΊ STOP R-01 β
β βββββββββββββββββ¬ββββββββββββββββ TFN passport Medicare licence β
β βΌ name+DOB address PAN Aadhaar β
β IBAN SWIFT SSN card email β
β βββββββββββββββββββββββββββββββββ β
β β 7 Β· COMPLIANCE RULES βββββ hit βββββββββββββΊ STOP / ESCALATE β
β βββββββββββββββββ¬ββββββββββββββββ verb + object must BOTH match β
β βΌ R-02 R-03 R-04 R-05 R-09 β
β βββββββββββββββββββββββββββββββββ β
β β 8 Β· SEMANTIC LAYER β
NEW β ~40ms Β· 52ms p95 β
β β (expanded below) β ββββ hit βββββββββββββΊ STOP / ESCALATE β
β βββββββββββββββββ¬ββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββ β
β β 9 Β· DESTRUCTIVE OPS βββββ hit βββββββββββββΊ ESCALATE R-21 β
β βββββββββββββββββ¬ββββββββββββββββ delete/drop + customers/records β
β βΌ β
β βββββββββββββββββββββββββββββββββ β
β β 10 Β· BEHAVIOUR β
NEW β looks ACROSS requests: β
β β β ββββ anomaly βββββββββΊ ESCALATE R-22 β
β βββββββββββββββββ¬ββββββββββββββββ queries/hr Β· distinct customers Β· β
β β off-owned svc Β· off-hours Β· streak β
ββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
ββββββββββββββββββββββββ
β COMBINE β strictest wins = max()
β ALLOW=0 ESC=1 STOP=2β empty set β ESCALATE (fail-closed)
ββββββββββββ¬ββββββββββββ
β
ββββββββββββββΌβββββββββββββ
βΌ βΌ βΌ
ββββββββ βββββββββββ βββββββββ
β STOP β βESCALATE β β ALLOW β
βββββ¬βββ ββββββ¬βββββ βββββ¬ββββ
β β βΌ
β β ββββββββββββββββββββ
β β β BACK-END AI β
β β β generate(prompt, β
β β β ctx) β
β β ββββββββββ¬ββββββββββ
β β βΌ
β β ββββββββββββββββββββββββββββββββββββββββ
β β β OUTPUT SCANNER β
β β β O1 normalize β
β β β O2 PII / secrets leak β
β β β O3 unsafe code (bypass, exploit) β
β β β O4 alignment (sys-prompt, DAN) β
β β β O5 EXCHANGE β
NEW answer vs prompt β
β β ββββββββββββββββ¬ββββββββββββββββββββββββ
β β β
β β ββββββββββββΌβββββββββββ
β β βΌ βΌ βΌ
β β BLOCK REDACT PASS
β β β β β
β β β ββββββ¬ββββββ
β β β βΌ
β β β βββββββββββββββββββ
β β β β ANSWER DELIVEREDβ
β β β ββββββββββ¬βββββββββ
βΌ βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β AUDIT LOG β
β decision Β· rule_triggered Β· policy_triggeredβ
β reason Β· prompt_hash(sha256) Β· user_id β
β role Β· service Β· latency_ms Β· signals β
β policy_version Β· timestamp Β· request_id β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ (ESCALATE only)
ββββββββββββββββββββββββββββββββββββββββββββββββ
β HUMAN REVIEWER βββΊ labelled example β
β β² β β
β β βΌ β
β βββββββ΄βββββββ ββββββββββββββββββ β
β β Stage 8 ββββββββ€ RETRAIN (39KB) β β
β ββββββββββββββ ββββββββββ²ββββββββ β
β β β
β catalog.yaml βββΊ generate βββΊ mutate βββΊ spot-check
ββββββββββββββββββββββββββββββββββββββββββββββββ
THE FLYWHEEL: rules become training data
Fail-closed everywhere. Unknown user β STOP. A stage throws β ESCALATE. No verdicts at all β ESCALATE. Audit unreachable β ESCALATE. Silence is never treated as approval.
Stage 8 expanded β embed once, use twice
The expensive part is turning the prompt into numbers. Do it once, cache it, and both consumers read the same vector β which is why the second one is nearly free.
prompt survived stages 1-7
β
βΌ
βββββββββββββββββββββββββββββββββββββ
β EMBED ONCE β
β MiniLM β 384 numbers Β· memoized β ~40ms
βββββββββββββ¬ββββββββββββ¬ββββββββββββ
β β (same cached vector)
βββββββββββββ βββββββββββββ
βΌ βΌ
βββββββββββββββββββββ ββββββββββββββββββββββββ
β kNN SIMILARITY β β INTENT CLASSIFIER β
β vs 584 attacks β β softmax(WΒ·x+b) β
βββββββββββ¬ββββββββββ ββββββββββββ¬ββββββββββββ
β β ~0ms extra
βββββββ΄ββββββ¬βββββββββββ βββββββ΄ββββββ¬βββββββββββ
βΌ βΌ βΌ βΌ βΌ βΌ
β₯0.80 0.72-0.80 <0.72 β₯0.70 0.45-0.70 benign
β β β β β <0.45
βΌ βββββββ¬βββββ βΌ βΌ βΌ
STOP β rule's own ESCALATE pass
cites β level: (softened)
attack β R-02/03/09
ID βΌ β STOP
ββββββββββββββββββββββββ R-05
β DeBERTa RECHECK β β ESCALATE
β ON by default ~340ms β
β β₯0.90 STOP β
β β₯0.50 ESCALATE β
ββββββββββββββββββββββββ
Why the recheck. Similarity only recognises paraphrases of attacks already in the bank, so "far from every known attack" is not evidence of being benign β it is the gap novel wording walks through. Everything the kNN tier does not STOP outright, band or apparent-pass alike, gets a second opinion from DeBERTa. Only a tier-1 STOP skips it, so in practice nearly every surviving prompt pays the ~340ms: recall bought with latency.
Ceiling rule. Similarity says which attack; the catalog says how strict it is. A perfect 1.00 match to an ESCALATE-class rule (R-05 bulk, R-08 cross-org) still only escalates β never STOP.
Why cite a neighbour. A match reports "0.94 similar to known attack RT-04" β a sentence an auditor can follow. A bare confidence score of 0.87 explains nothing.
New attack on Monday β add one bank entry β protected that afternoon. No retraining, no redeploy.
The three verdicts
| Verdict | Value | What happens | Does the AI see the prompt? |
|---|---|---|---|
| ALLOW | 0 | passes through to the assistant | yes |
| ESCALATE | 1 | held for a human; becomes a labelled example | not yet |
| STOP | 2 | refused, rule + policy cited | never |
Higher number = stricter, so combining is a plain max() and can't be got wrong.
Stage reference
| # | Stage | Catches | Emits | Cost |
|---|---|---|---|---|
| 1 | normalize | obfuscation | β | <1ms |
| 2 | identity | β | β | <1ms |
| 3 | Cedar authz | unpermitted identity | STOP R-AUTH | O(1) bitmask |
| 4 | secrets | connection strings, AWS keys, tokens | STOP R-07 | regex |
| 5 | injection (phrase) | literal jailbreak phrases | STOP R-06 | Aho-Corasick |
| 6 | PII | AU IDs + PAN, Aadhaar, IBAN, SWIFT, SSN, card, email | STOP R-01 | regex |
| 7 | compliance rules | SMR/TTR, bypass, attack, bulk, audit-manip | STOP/ESCALATE | two-part match |
| 8 | semantic β | paraphrased attacks | STOP/ESCALATE | ~40ms, 52ms p95 |
| 9 | destructive ops | delete/drop + customer objects | ESCALATE R-21 | regex |
| 10 | behaviour β | patterns across requests | ESCALATE R-22 | in-memory |
Order is load-bearing: a pasted password STOPs at stage 4 in microseconds and never reaches the 40ms semantic layer.
Running it
./run_v2.sh demo # see it catch bulk assembly + a paraphrased bypass
./run_v2.sh gate # 13-prompt red-team gate, all tiers on
./run_v2.sh eval # the adversarial numbers
./run_v2.sh serve # API + web UI on localhost:8000
./run_v2.sh test # full suite (tiers off, like CI)
Flags: KNN_ENABLED Β· INTENT_ML_ENABLED Β· BEHAVIOUR_ENABLED default false;
ML_DETECTOR_ENABLED defaults true (the DeBERTa recheck; set it false for the fast
deterministic path β the deploy image does). Measured results in v2_eval_results.md.