# Tool Schema Tax Audit

Calculate the hidden static token overhead ("tool schema tax") imposed by injecting JSON schema and OpenAPI tool definitions into prompt payloads on every single interaction turn.

## Workflow

1. Ingest registered tool schemas and invocation profile:
   - Tool count ($M$)
   - Total tool schema token footprint ($S$)
   - Average user prompt tokens ($U$)
   - Total turns in session ($K$)
   - Cache status: is the tool schema cached or re-tokenized each turn?
2. Compute schema overhead proportion:
   $$\text{Schema Tax Ratio} = \frac{S}{S + U}$$
3. Compute monthly financial impact across user traffic volume:
   - Cost of transmitting schema definitions vs cost of actual conversation tokens.
4. Recommend schema compaction optimizations:
   - Stripping verbose descriptions.
   - Dynamic tool pruning (retrieving only relevant tool schemas per turn).

## Synthetic Input Format

JSON object with:
- `schemaVersion`: 1
- `agentProfile`: string
- `tools`: list of objects, each containing:
  - `name`: string
  - `schemaTokens`: positive integer
- `sessionProfile`:
  - `turnsPerSession`: positive integer
  - `userPromptTokensPerTurn`: positive integer
  - `monthlySessions`: positive integer
  - `isSchemaCached`: boolean
  - `promptRatePerMillion`: non-negative decimal string
  - `cacheReadRatePerMillion`: optional non-negative decimal string
- `assertions`:
  - `maxSchemaTaxRatio`: optional decimal string (e.g. "0.6000")

## Exit Codes

- `0`: Valid calculation and tax ratio within threshold.
- `1`: Schema tax ratio exceeds allowable limit.
- `2`: Malformed input or safety violation.

## Verification

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