Generative Safety and Prompt Mutation Audit Matrix Designer
Develop SQL audit queries to detect multimodal prompt injection bypasses and classifier performance across violation categories.
Use this template when auditing safety moderation filters and tracking adversarial prompt mutations in image generation APIs. It yields a defensive risk matrix with SQL-driven vulnerability telemetry.
Role: Senior Trust and Safety Data Engineer specializing in multimodal moderation architectures and adversarial prompt forensics.
Context
- Database Engine: {{moderation_db_flavor}}
- Audit Log View: {{audit_log_view}}
- Classifier Output Column: {{safety_classifier_score}}
- Policy Taxonomy: {{violation_categories}}
- Mutation Fingerprint Field: {{prompt_fingerprint_col}}
- Observation Window: {{evaluation_timeframe}}
Task
Design an advanced SQL safety audit matrix that identifies adversarial prompt mutation patterns, quantifies false-positive versus false-negative moderation triggers, and isolates vulnerability clusters across distinct policy violation categories.
Method
- Define time-series partitioning over {{audit_log_view}} constrained to {{evaluation_timeframe}} in {{moderation_db_flavor}}.
- Write a deterministic fuzzy-matching or string-similarity CTE based on {{prompt_fingerprint_col}} to cluster mutated prompts.
- Map safety scoring distributions from {{safety_classifier_score}} across predefined policy segments in {{violation_categories}}.
- Calculate classifier precision and recall estimations using windowed lead/lag triggers on post-generation manual reviews.
- Identify prompt evasion velocity by aggregating repeated prompt mutations that shift from flagged to unflagged status.
- Generate safety breach heat indicators based on sudden score drifts within clustered fingerprint groups.
- Structure aggregated findings into a high-density vulnerability audit matrix.
Constraints
- MUST implement recursive or self-joining CTEs efficiently without causing execution timeouts.
- MUST NOT expose raw toxic string literals in group names; use tokenized identifiers or taxonomy codes.
- Temporal windows MUST be parameterized cleanly using native intervals in {{moderation_db_flavor}}.
- Every metric calculation must explicitly account for null classification scores.
Output format
1. Forensics Methodology
Explanation of fingerprint clustering, time decay modeling, and mutation detection logic.
2. Hardened SQL Audit Suite
Syntactically complete, robust SQL script utilizing CTEs, windowing, and metric aggregations.
3. Policy Vulnerability and Mutation Matrix
Markdown matrix detailing Violation Category, Total Prompt Mutations, Classifier Evasion Rate, False-Positive Ratio, and Risk Tier.
Self-review
- Confirm all 6 variables ({{moderation_db_flavor}}, {{audit_log_view}}, {{safety_classifier_score}}, {{violation_categories}}, {{prompt_fingerprint_col}}, {{evaluation_timeframe}}) are correctly placed.
- Verify that temporal filters prevent unbounded data scanning.
- Ensure safety risk levels are mapped to consistent categorical tiers.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.