# Reasoning Token Audit

Audit reasoning token expansion ratios, budget caps, separate billing vs output billing, and hidden multiplier surcharges across reasoning models.

## Workflow

1. Inspect reported token usage: prompt tokens, visible completion tokens, and reasoning/thinking tokens (`completion_tokens_details.reasoning_tokens` or equivalent).
2. Validate provider billing model:
   - Separate reasoning rate vs bundled output rate.
   - Surcharge ratio $\text{Ratio} = \text{Reasoning Tokens} / \text{Completion Tokens}$.
   - True effective output cost per million tokens:
     $$\text{Effective Rate} = \frac{(\text{Reasoning Tokens} \times \text{Rate}_{\text{reasoning}}) + (\text{Visible Tokens} \times \text{Rate}_{\text{output}})}{\text{Visible Tokens}}$$
3. Validate budget constraints: check if reasoning token count exceeds maximum declared budget (`max_thinking_tokens` or `reasoning_effort`).
4. Output structured audit verification receipt.

## Synthetic Input Format

JSON object with:
- `schemaVersion`: integer (1)
- `model`: model identifier string
- `provider`: provider identifier string
- `billingModel`: `"bundled_output"` | `"separate_reasoning"`
- `rates`:
  - `promptPerMillion`: non-negative decimal string or integer
  - `outputPerMillion`: non-negative decimal string or integer
  - `reasoningPerMillion`: non-negative decimal string or integer (required if `billingModel` is `separate_reasoning`)
- `trajectory`:
  - `promptTokens`: non-negative integer
  - `visibleTokens`: positive integer
  - `reasoningTokens`: non-negative integer
  - `budgetCap`: optional positive integer
- `assertions`:
  - `maxExpansionRatio`: optional decimal string (upper bound on reasoning / visible tokens)
  - `maxEffectiveRatePerMillion`: optional decimal string

## Exit Codes

- `0`: Valid input and all assertions passed.
- `1`: Assertion failed (e.g., expansion ratio exceeded, budget cap breached, effective cost ceiling passed).
- `2`: Malformed input or path traversal violation.

## Verification

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