# Adversarial suffix detection audit

## Description
Check a perplexity-ratio assertion and a supplied anomaly threshold over local numeric input. A threshold flag is a heuristic signal for review, not proof of a GCG suffix, prompt injection, or an actual attack.

## Category
`evaluation`

## Tags
`evaluation`, `security`, `jailbreak`, `gcg`, `perplexity`

## When to Use
Review a proposed perplexity threshold against supplied observations before deciding what further model or security evaluation is needed.

## Operational Limitations
The checker does not measure perplexity, inspect prompts, execute a target model, or establish detector accuracy. It recomputes a ratio from the supplied numbers; their provenance and a threshold's suitability remain unverified. The compatibility field `attack_detected` means only that the unrounded ratio exceeded the supplied threshold. It is not attack attribution or a security verdict.

## Input Contract
Supply a JSON object containing these four numeric fields (JSON numbers or decimal strings):

- `prompt_perplexity`: finite and non-negative.
- `baseline_normal_perplexity`: finite and strictly positive.
- `anomaly_ratio`: the asserted quotient `prompt_perplexity / baseline_normal_perplexity`, rounded to two decimal places using half-up rounding.
- `max_allowed_anomaly_ratio`: a finite, non-negative threshold.

Boolean, missing, nonnumeric, nonfinite and negative values are invalid. The reported ratio and threshold must fit finite JSON numbers. Threshold comparison uses the exact, unrounded quotient: equality passes, and any value above the threshold flags even if the displayed two-decimal ratio equals the threshold. A mismatched `anomaly_ratio` assertion also requires review; it cannot hide a threshold breach.

## Verification Script
Run the deterministic verification checker:
```bash
python3 scripts/check.py examples/synthetic.json
```
The supplied example intentionally exceeds its threshold and returns **1** with `status: FLAGGED`. Its quotient is `245.8 / 32.4`, whose two-decimal half-up assertion is `7.59`.

Exit codes:
- `0`: Valid input, a matching ratio assertion and a ratio at or below the threshold.
- `1`: Threshold breach or ratio-assertion mismatch; review the structured `issues`.
- `2`: Schema error, unreadable input or invalid usage; see the structured error.
