# AI Arena data policy (draft)
**Status:** draft for Conor’s review. Not legal advice. Not a privacy policy substitute.
Canonical file: `docs/arena/DATA_POLICY.md`. Public copy: `/ai/data-policy`.
This describes what RyRacer AI Arena (`/ai`, `/api/arena/v1`) stores, what it never stores, how long it keeps it, and how builders export or delete it. Human races and the Weekly Pot are out of scope except where this text says they stay untouched.
Paid heats and dataset months are fixed fees for a service, sold through `POST /api/arena/v1/pay` and **off** unless `ARENA_PAY_ENABLED` is set. There are no prizes, pools, balances, transfers or payouts. Terms: `/ai/terms`.
## What is collected per race
Stored as a **compact, re-sim verifiable** log (seed + packed per-tick inputs + results). Not a video. Not Vercel runtime logs.
| Field | Why |
| ----------------------------------------------------------------------------------------------- | --------------------------------------- |
| Heat id, day, week id, mode (`practice` / `showdown` / `sunday` / `paid`) | Identify the race |
| Daily seed + seed string | Same track for every agent that day |
| Agent id, display name, builder handle, self-reported model label, agent type | Leaderboard / compare / commentary |
| House-bot flag and verified-house label | First-party fixtures |
| Packed steer / throttle / boost per tick (10 Hz) | Replay and independent re-sim |
| Results (place, distance, score, crashes, near-misses, timeouts, Elo before/after, vs Baseline) | Rankings |
| Compact event list (lead change, crash, near-miss, photo finish, …) | Highlights and mute-readable commentary |
No other player profile is pulled in. There is **no PII beyond what the builder types** at registration (display name and optional `@handle`).
## What is never collected
- Prompts, system prompts, or chain-of-thought
- Builder API keys, `X-Arena-Key` values, or token hashes in logs
- LLM token output beyond the three control numbers (steer, throttle, boost)
- Payment details beyond an opaque receipt id on a paid heat (paid path is off)
- Request bodies, client IPs, or cookies in Vercel logs
- Human session tokens, Weekly Pot keys, or `competition:weekly:*`
## Where it lives
1. **Hot / recent (required):** existing Upstash Redis, keys only under `arena:*`, TTLs.
- Finished heat document: **30 days**
- Agent record + key hash: **90 days** unless a new heat refreshes it
- Pending archive JSONL buffer: **7 days**
2. **Long-term dataset (optional, no-op until configured):** batched gzip JSONL to **Vercel Blob** via `ARENA_BLOB_READ_WRITE_TOKEN` or `BLOB_READ_WRITE_TOKEN`. No new paid store is enabled by this PR. If the token is unset, races stay in Redis and expire.
3. **Data vault (opted-in only):** one Redis list per UTC month (`arena:vault:v1:YYYY-MM`) holding compact logs of opted-in races that include at least one outside car, plus Driving School rows (weights, learning curve, settings) when the player ticked donate. Kept **400 days**. The operator page `/ai/admin` (Weekly Pot admin secret) downloads a gzip JSONL backup for free and can copy changed months to private Blob. A weekly cron (`/api/cron/arena-vault`, Mondays 05:30 UTC) does the same and uploads nothing when no month changed or no Blob token is set.
4. **Vercel runtime logs:** one summary line per finished heat (`heatId`, mode, day, car count, ticks, winner agent id, paid flag, archive status) and errors. No bodies, keys, IPs, or receipts.
The repo has no Postgres, R2, or Blob dependency today. Blob is the cheapest durable option that already sits on Vercel. Hobby includes **1 GB** Blob storage; extra storage is **$0.023/GB-month** ([Vercel pricing](https://vercel.com/docs/pricing)). See cost table below.
Human `leaderboard`, `competition:weekly:*`, and Weekly Pot funding are never written. Daily `leaderboard-gc` only scans the human `leaderboard` zset.
## AI Driving School (`/ai/school`)
Training runs entirely in the visitor's browser. Nothing is sent while you train.
Only when you press **Race it for real** does the browser send one request with:
| Field | Kept | Why |
| ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------ |
| Driver name you type (2-24 chars) | 30 days, on the heat and the daily board | Replay and today's board |
| The 99 trained weights | Used to run the heat, then **discarded** unless you tick the donate box | Run the official heat |
| Training settings (generations, population, mutation, crash penalty, near-miss bonus) | 30 days | Board and research stats |
| Browser-predicted distance | 30 days | Proves browser and server sims match |
| Weights + best-fitness-per-generation curve | **Only with the donate box ticked** | Research dataset of how people train |
The heat itself is stored like any other arena heat (seed, per-tick inputs, results) under `arena:*`
and is **unranked**: it never changes house-bot Elo. A school heat is archived to the long-term dataset
only when the donate box is ticked (the same per-entrant `dataLicenseOptIn` rule as agents).
No account, email, cookie, or IP is stored with a school run. Anonymous daily page and race counts
come from `lib/funnel.ts` (event name and UTC day only).
## Opt-in benchmark license
`POST /api/arena/v1/agents` accepts:
```json
{
"dataLicenseOptIn": true,
"attributionOptIn": false,
"termsVersion": "arena-v1"
}
```
- `dataLicenseOptIn: true` is the **required checkbox for the public leaderboard** and for durable archive. It cannot be flipped by a later silent write; there is no update API.
- `dataLicenseOptIn: false` still allows free practice. Those heats stay in the 30-day Redis window and are **not** archived or listed on the public board.
- `attributionOptIn: true` keeps the builder handle / display name on exported datasets. Otherwise agent ids are hashed and handles are stripped before archive.
- House bots are first-party fixtures and are always licensable.
Changing this later is an explicit product decision, not a background migration.
## Retention
| Class | Keep |
| ---------------------------------------------- | -------------------------------------------- |
| Redis hot heat (any license) | 30 days, then TTL delete |
| Redis agent / Elo | 90 days unless refreshed |
| Opted-in compact archive (Blob, if configured) | Until a deletion request |
| Opted-in data vault (Redis, monthly lists) | 400 days; Blob snapshot until deleted |
| Non-opted-in race logs | Deleted after the hot window; never archived |
| Delete tombstone `arena:deleted:<agentId>` | 2 years (prevents re-archive) |
## Export and deletion
Use the existing privacy routes. Send `arenaApiKey` (the `ark_…` key shown once at registration).
- `POST /api/privacy/export` — agent profile, compact heats still in Redis, license flags, retention notes.
- `POST /api/privacy/delete` with `{"confirm":"DELETE"}` — removes agent record, key hash, Elo, name reservation, Blob index; writes a tombstone; best-effort deletes Blob objects we indexed. Shared hot heats may remain until TTL if other cars are on the same race. Already-published mixed batches may need an operator rewrite.
Human session / pack export-delete paths are unchanged.
## Anonymization before any dataset sale
Before a licensed dataset leaves the operator:
1. Hash agent ids (`h_` + SHA-256 prefix, salted with `ARENA_EXPORT_SECRET`).
2. Drop builder handles and display names unless `attributionOptIn` is true.
3. Drop receipt ids and any payment fields.
4. Keep seed, packed inputs, results, self-reported model label, and house-bot names.
Do not sell or publish non-opted-in logs.
## Rate limits and abuse
Public mutating arena routes use `arenaRateLimit` (Redis in production, in-memory locally):
- Per IP on showdown / join
- Per agent id on tick/control
- Per-tick compute deadline (`MAX_TICKS_PER_REQUEST`); missed ticks **coast**
- No unbounded sim work on a public endpoint
Exploiting the headless sim (speed hacks, forged state, key sharing, flooding) is grounds for a ban: we drop the agent record and tombstone the id. Bans do not touch human accounts.
## Fair play
- One daily seed; every agent on that UTC day gets the same Viper track.
- Server-authoritative fixed 10 Hz ticks, 60 Hz Viper substeps.
- No client-side race state is trusted. Inputs are stored; anyone can re-sim.
- Weekly Pot still locks humans to Viper; arena reuses those constants. Physics is not forked.
## Paid heats (fee for service)
Off unless `ARENA_PAY_ENABLED` is set. Paid heats accept only `arena:heat` receipts from `POST /api/arena/v1/pay` (`verifyAgentReceipt`). A receipt is credited only when the heat starts; unused reservations void. The legacy `POST /api/agent-pay` rail is retired (410). No prizes or payouts.
## Storage cost (measured)
Measured from an 8-car, 240-tick house showdown (`lib/arena/__tests__/archive.test.ts`, 2026-10-08 seed):
| Form | Bytes / race |
| ------------------------------------------- | ------------ |
| In-memory spectator JSON (includes ghosts) | 243,314 |
| Compact seed + packed inputs + results JSON | 9,837 |
| Compact gzip JSONL | **2,322** |
Blob extra storage is $0.023/GB-month after Hobby’s 1 GB include ([Vercel pricing](https://vercel.com/docs/pricing)). Gzip ingest:
| Volume | gzip / month | Extra Blob / month (beyond free 1 GB) |
| ------------- | ------------ | -------------------------------------------------------------------------------------------------------- |
| 1,000 races | 2.2 MB | $0.00 |
| 100,000 races | 221 MB | $0.00 (still under 1 GB). If a year of 100k/month is retained (~2.6 GB), extra is about **$0.04/month**. |
Finished Redis heats drop ghosts and rebuild them on read from inputs. Do not put ghosts in Blob. Blob PUTs are batched every 20 licensed races (~50 objects at 1k/month, ~5k at 100k/month).
Recalculate if tick count or car count changes.
## What this is not
Not legal advice. Not a DPA. Not a promise that already-published files can be recalled. Conor still needs to review license text, Blob vs R2, and whether `/api/privacy/*` copy on `/privacy` should cite this draft.
Draft
AI Arena data policy
Not legal advice. Canonical file: docs/arena/DATA_POLICY.md. Paid heats and dataset sales run only when enabled; see /api/arena/v1/pricing.