# Concurrency Cliff Audit

Audit inference throughput degradation, queue build-up, and throughput cliff saturation as concurrency scales from single-user (concurrency = 1) to multi-tenant workloads (e.g. 5, 20, 50, 100 concurrent streams).

## Workflow

1. Ingest throughput observations across concurrency levels:
   - Concurrency level ($C$)
   - Aggregate tokens per second ($T_{\text{agg}}$)
   - Per-stream tokens per second ($T_{\text{stream}} = T_{\text{agg}} / C$)
   - Error / drop rate percentage ($E$)
2. Detect saturation cliff:
   - Identify the concurrency point where aggregate throughput flattens or declines while per-stream latency surges.
3. Validate SLA requirements:
   - Enforce minimum per-stream token generation rate (e.g. $\ge 15.0$ tokens/sec for interactive UX).
   - Enforce zero dropped requests ($E = 0\%$).

## Synthetic Input Format

JSON object with:
- `schemaVersion`: 1
- `endpoint`: string
- `model`: string
- `concurrencySteps`: list of objects, each containing:
  - `concurrency`: positive integer
  - `aggregateTokensPerSec`: positive decimal string or number
  - `errorRatePercent`: non-negative decimal string or number
- `assertions`:
  - `minStreamTokensPerSec`: optional decimal string (e.g. "12.0")
  - `maxErrorRatePercent`: optional decimal string (e.g. "0.0")

## Exit Codes

- `0`: Valid observations and all assertions satisfied.
- `1`: Assertion failed (stream throughput dropped below minimum or error rate exceeded).
- `2`: Invalid input format or safety violation.

## Verification

```sh
python3 scripts/check.py examples/synthetic.json
```
