Execution Lifecycle

How PromptGuard Works

PromptGuard acts as a pre-execution security barrier, ensuring no untrusted prompt reaches downstream language models without comprehensive threat analysis.

01
Ingestion Trigger

Step 1: User submits prompt

A user submits a prompt via web frontend, mobile application, API endpoint, or agent retrieval pipeline.

HTTP POST /api/analyze
02
Edge Boundary Ingestion

Step 2: PromptGuard receives the input

FastAPI gateway intercepts the request. Enforces CORS, rate-limiting, and 1 MB payload size constraints before payload enters memory buffers.

SecurityHeaders & RateLimiter
03
Multi-Stage Inspection

Step 3: Six-layer detection engine analyses prompt

Input is evaluated across Unicode normalization, 9 threat rule signatures, instruction hierarchy boundaries, Base64/Hex obfuscation, behavioral intent, and semantic proximity.

L1 through L6 Execution
04
10-Factor Heuristic Synthesis

Step 4: Adaptive risk engine calculates risk score

Detection signals are multiplied by calibrated risk weights. The final synthesized score is strictly bounded from 0 to 100 with zero mathematical overflow.

0.0 <= RiskScore <= 100.0
05
Policy Decision Engine

Step 5: Policy engine determines appropriate action

The risk score is evaluated against configured organizational thresholds (ALLOW, FLAG, ISOLATE, BLOCK).

Threshold Evaluation Matrix
06
Zero-Trust Dispatch

Step 6: Result is processed & enforced

Clean prompts reach downstream LLMs; flagged prompts receive defensive system delimiters; high/critical threats are terminated at the boundary with zero tokens dispatched.

Zero LLM Token Leakage
Enforcement Matrix • Step 6 Decision Branches

Automated Downstream Actions

When Step 5 determines policy, the PromptGuard engine dispatches one of four deterministic actions:

SAFE (0 – 29)ALLOW

Forward to LLM

The prompt is validated clean. Transmitted to downstream provider (OpenAI, Gemini, Claude, or Local Simulator) without alteration.

SUSPICIOUS (30 – 59)FLAG

Apply Safeguards

Prompt has elevated risk markers. Encapsulated in strict defensive boundary delimiters before LLM processing to prevent instruction escape.

HIGH (60 – 79)ISOLATE

Isolate from Model

High-confidence adversarial intent. Kept away from production model execution and routed to the forensic review buffer.

CRITICAL (80 – 100)BLOCK

Hard Cutoff

Execution stopped immediately. Zero tokens reach the downstream model. Incident logged to SQLite audit database with alert telemetry.

Explore Technical Architecture

Read the complete system architecture, REST API reference, and database ERD.