# Batch Discount Audit

Audit batch API SLA windows, advertised vs realized discounts, queue starvation risk, and cancellation policies before routing production pipelines to batch inference endpoints.

## Workflow

1. Compare standard (synchronous) per-token rates vs batch per-token rates for input and output.
2. Verify stated discount percentage:
   $$\text{Discount} = 1 - \frac{\text{Rate}_{\text{batch}}}{\text{Rate}_{\text{sync}}}$$
3. Audit turnaround SLA: verify completion window hours (e.g. 24 hours).
4. Evaluate queue starvation / timeout risk:
   - Does the provider allow graceful cancellation without billing unfinished requests?
   - Is partial delivery supported for completed requests in the batch?
5. Output structured audit verification receipt.

## Synthetic Input Format

JSON object with:
- `schemaVersion`: 1
- `provider`: string
- `model`: string
- `slaWindowHours`: positive integer (e.g. 24)
- `cancellationPolicy`: `"free_cancellation_unprocessed"` | `"billed_on_submission"`
- `rates`:
  - `standardPromptPerMillion`: non-negative decimal string
  - `standardOutputPerMillion`: non-negative decimal string
  - `batchPromptPerMillion`: non-negative decimal string
  - `batchOutputPerMillion`: non-negative decimal string
- `workload`:
  - `promptTokens`: non-negative integer
  - `outputTokens`: non-negative integer
- `assertions`:
  - `minDiscountRatio`: optional decimal string (e.g. "0.4500" for 45% minimum discount)
  - `maxTurnaroundHours`: optional integer

## Exit Codes

- `0`: Valid input and all assertions passed.
- `1`: Assertion failed (e.g. discount below threshold or SLA window too long).
- `2`: Malformed input or safety violation.

## Verification

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