# Bootwatch agent proof API

Automated bots and AI agents (CI runners, benchmark harnesses, assistants) are welcome to submit stage
proofs for tracked projects. **Every submission, human or automated, is manually verified before it moves
the public bar: agent proofs are never auto-approved.**

- Base URL: `https://bootwatch.fun`
- Auth: `Authorization: Bearer bw_agent_<40 chars>` (staff-issued) or `Bearer bw_proj_<40 chars>` (self-serve via `https://bootwatch.fun/developers` `.bootwatch` default-branch verification; max 2 active keys per project; only its SHA-256 hash is stored)
- Self-serve key endpoints: `POST /api/v1/agent/keys/verify-start` and `POST /api/v1/agent/keys/verify-complete`
- Quota: per key, default 10 proofs/hour (HTTP 429 with `Retry-After` when exceeded)
- Rubric: v1.1.0, 37 criteria (ids from `/api/v1/rubric.json`, e.g. `EXEC-001`, `EXEC-002`, `EXEC-003`, `KERN-001`, `KERN-002`, `KERN-003`)

## Stage rubric (console parity)

The web Submit Proof modal, the homepage stage bar, and the moderators all use this rubric.

| Stage | stage_claimed | Evidence must show | Does not qualify |
| --- | --- | --- | --- |
| Opens | `opens` | A visible console or terminal log showing real runtime initialization, or an actual game window or splash screen. | Task Manager process or RAM screenshots on their own. |
| Menus | `menus` | The graphics device initializes. The title screen and settings render. Input navigates the menus without freezing. | A splash screen or loading screen with no working menus. |
| In-World | `loads_map` | Loads into 3D Leonida and renders the world. | - |
| Playable | `playable` | ~30 native FPS in open-world driving or combat. Working audio, saves and missions. Usable lighting (badged RT On or RT Off). Stable 30+ minute sessions on consumer hardware. | Frame Generation or Lossless Scaling framerates. Indoor-only tests, pitch-black or broken lighting, missing audio, or short crashes (these are In-World). |
| Smooth 60 | `smooth_60` | Sustained 60+ native FPS in open-world driving or action. Working lighting / RTGI. Clean frametimes: 99th percentile <= 33 ms. | Frame Generation or Lossless Scaling framerates. |

- **Task Manager-only screenshots are rejected for every stage, including Opens. Task Manager or HWiNFO screenshots are accepted only as supporting telemetry next to a real game clip or screenshot.**
- Playable and Smooth 60 require native rendered framerates. Frame Generation and Lossless Scaling do not qualify.
- Playable means console parity: ~30 native FPS in open-world driving or combat, usable lighting
  (badged RT On or RT Off), working audio, saves and missions, and stable 30+ minute sessions.
- `stage_claimed` also accepts `in_world` as an alias of `loads_map` (the In-World stage).

## What you must never send

Game binaries, executables, keys, save files, extracted RPF or other game assets, or links to them.
Proofs that do are rejected and the key is revoked.

## Mandatory visual evidence

A text-only submission is rejected with `400 visual_required`. Include **at least one** of:

1. `visual_urls[]` (max 3): direct links on an allowlisted host:
   - YouTube video or unlisted clip (`youtube.com/watch?v=`, `youtu.be/`, `/shorts/`)
   - Streamable clip, Medal.tv clip
   - Rumble video (`rumble.com/v4abcde-title.html` or `rumble.com/embed/v4abcde/`)
   - Odysee video (`odysee.com/@channel:c/video-name:a`)
   - A **single** Imgur image (albums `/a/` and `/gallery/` are blocked)
   - GitHub issue/PR/release/commit/attachment, GitLab issue/MR/release/commit
   - Blocked: URL shorteners, file lockers (Drive, Mega, Dropbox, ...), Discord CDN links
2. `staging_object_keys[]` (max 3): frames you uploaded through the presigned flow below.

### Frame image rules

- PNG or WebP only, verified by magic bytes (the declared type is not trusted)
- At most 4 MB per frame, at most 3 frames per proof
- Raw in-game frames: no overlays covering the scene, no collages
- Staged frames sit in a **private** bucket. They are never published. After a moderator approves the
  proof, a re-encoded, metadata-stripped WebP snapshot (max 1280 px) is the only thing made public.

### Blank-frame rejection criteria

media-inspector flags a frame (proof status `flagged`, a moderator decides) when any of these hold:

| Check | Threshold |
| --- | --- |
| Dominant colour ratio (4-bit quantised) | > 0.95 (solid black, solid green, loading screens) |
| Luma Shannon entropy | < 1 bits |
| Magic bytes | not PNG/WebP |
| SHA-256 | exact match with a redacted frame |
| dHash | Hamming distance <= 6 from a redacted frame |

## Step 1 (optional): request upload URLs

`POST /api/v1/agent/proof/upload-url`

```json
{ "frames": [ { "content_type": "image/png", "content_length": 1843921 } ] }
```

Response `201`: `uploads[]` with `object_key`, `upload_url` (expires in 5 minutes), and
`required_headers`. PUT the exact bytes with exactly those headers (Content-Type and Content-Length are signed).

## Step 2: submit the proof

`POST /api/v1/agent/proof` (`application/json`, unknown keys are rejected)

| Field | Type | Rules |
| --- | --- | --- |
| `project_slug` | string | a tracked project slug; or send `unlisted_project` instead |
| `unlisted_project` | object | `{ "repo_url_or_name": string, "is_private": boolean }` |
| `visibility` | enum | `public_repo` or `private_off_github` |
| `commit_sha` | string | 7-40 hex chars of the tested build |
| `console_target` | enum | `xbox-series-s`, `xbox-series-x`, `ps5`, `ps5-pro` |
| `stage_claimed` | enum | `opens`, `menus`, `loads_map` (In-World; `in_world` also accepted), `playable`, `smooth_60` |
| `gpu_name` | string | e.g. `NVIDIA GeForce RTX 4070` |
| `vram_gb` | number | 1-96 |
| `ram_gb` | number | 4-1024 |
| `avg_fps` | number | 1-1000 |
| `p99_ms` | number | 99th percentile frame time; must be >= 1000 / avg_fps |
| `frame_range` | string | optional, e.g. `"1200-1260"` |
| `scene_type` | enum | optional, `indoors` or `open_world` (In-World, Playable, Smooth 60 only) |
| `rt_enabled` | boolean | optional, `true` (RT On) or `false` (RT Off); shown as a badge on approved gameplay proofs |
| `native_fps` | number | optional, 1-1000, **native** rendered FPS (no Frame Generation / Lossless Scaling) |
| `rubric_criteria_claimed` | string[] | optional, each must be a Rubric v1.1.0 id |
| `notes` | string | optional, max 400 chars |
| `visual_urls` | string[] | see above |
| `staging_object_keys` | string[] | keys from step 1 |
| `submitted_by_handle` | string | optional community tester handle forwarded by a federated bot relay |
| `source_platform` | enum | optional, `automated_agent` (default), `discord_bot`, or `fluxer_bot` |
| `project_mod_triaged` | boolean | optional; when `true` from a mod-approved Discord/Fluxer relay (`MOD_ROLE_IDS`), `commit_sha` and frame telemetry become optional. Never auto-approves public stages. |

Visibility rules: `private_off_github` proofs can prove their own project page (`private_verified`) but only
approved `public_repo` proofs (`public_verified`) advance the homepage public verified bar. A project that
came from a private nomination is always treated as private.

Response `202`: `{ "id", "receipt_short_id", "status": "sanitizing" | "in_review", "visibility", "reproducibility" }`.

Errors: `400 invalid_request | visual_required | visual_not_allowlisted | physics_check_failed`,
`401 unauthorized`, `403` (project scope), `404` (unknown project), `409 duplicate_media`, `429 quota_exceeded`.

## Examples

### curl

```bash
curl -sS -X POST https://bootwatch.fun/api/v1/agent/proof \
  -H "Authorization: Bearer $BOOTWATCH_AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project_slug": "example-project",
    "visibility": "public_repo",
    "commit_sha": "9f2a1c3",
    "console_target": "xbox-series-x",
    "stage_claimed": "playable",
    "gpu_name": "NVIDIA GeForce RTX 4070",
    "vram_gb": 12, "ram_gb": 32,
    "avg_fps": 31.2, "p99_ms": 41.5,
    "scene_type": "open_world", "rt_enabled": false, "native_fps": 31.2,
    "visual_urls": ["https://www.youtube.com/watch?v=AAAAAAAAAAA"]
  }'
```

### PowerShell

```powershell
$body = @{
  project_slug = 'example-project'; visibility = 'public_repo'; commit_sha = '9f2a1c3'
  console_target = 'xbox-series-x'; stage_claimed = 'menus'; gpu_name = 'NVIDIA GeForce RTX 4070'
  vram_gb = 12; ram_gb = 32; avg_fps = 58.4; p99_ms = 24.1
  visual_urls = @('https://www.youtube.com/watch?v=AAAAAAAAAAA')
} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri 'https://bootwatch.fun/api/v1/agent/proof' `
  -Headers @{ Authorization = "Bearer $env:BOOTWATCH_AGENT_KEY" } `
  -ContentType 'application/json' -Body $body
```

### Python (staged frame)

```python
import os, pathlib, requests

base = "https://bootwatch.fun"
auth = {"Authorization": f"Bearer {os.environ['BOOTWATCH_AGENT_KEY']}"}
frame = pathlib.Path("frame-1200.png").read_bytes()

up = requests.post(f"{base}/api/v1/agent/proof/upload-url", headers=auth, timeout=15,
                   json={"frames": [{"content_type": "image/png", "content_length": len(frame)}]})
up.raise_for_status()
slot = up.json()["uploads"][0]
requests.put(slot["upload_url"], data=frame, headers=slot["required_headers"], timeout=30).raise_for_status()

proof = requests.post(f"{base}/api/v1/agent/proof", headers=auth, timeout=15, json={
    "project_slug": "example-project", "visibility": "public_repo", "commit_sha": "9f2a1c3",
    "console_target": "ps5", "stage_claimed": "loads_map", "gpu_name": "AMD Radeon RX 7800 XT",
    "vram_gb": 16, "ram_gb": 32, "avg_fps": 61.0, "p99_ms": 21.7, "frame_range": "1200-1260",
    "staging_object_keys": [slot["object_key"]],
})
print(proof.status_code, proof.json())
```

---

## Non-Invasive Telemetry Flight Recorder (`bw-run` & `bootwatch-run-v1`)

Use the open-source MIT Rust CLI ([BootW/bootwatch/bw-run](https://github.com/BootW/bootwatch/tree/main/bw-run), full agent reference in [bw-run/AGENTS.md](https://github.com/BootW/bootwatch/blob/main/bw-run/AGENTS.md) — zero DLL injection, Authenticode-verified Intel PresentMon 2.6 + client-cropped WGC frames) for automated CI/agent benchmarks:

```bash
bw-run --agent --active-duration 60s --max-total 15m --upload -- ./emulator.exe
```

### Deterministic `bw-run --agent` Exit Codes

| Exit Code | Outcome | Meaning |
| --- | --- | --- |
| `0` | `completed` | Active rendering achieved (>= 2.0 native FPS) and at least 1 non-blank frame verified |
| `10` | `crash_warmup` | Process exited/crashed during shader warmup before active rendering |
| `11` | `blank_swapchain` | Swapchain presented frames, but all captured frames failed the blank/solid-color entropy guard |
| `12` | `timeout_warmup` | Exceeded `--max-total` while still in shader warmup |
| `13` | `crash_active` | Crashed during active gameplay after rendering frames |

### Two-Step `bootwatch-run-v1` Upload Flow

1. `POST https://bootwatch.fun/api/v1/runs/init` — optional `Authorization: Bearer bw_agent_...` / `bw_proj_...` (sets `trust_tier = agent_key_verified`; anonymous CLI runs are rate-limited to 5/hour per salted IP hash + /24). Body: `{ "frame_count": 0..3, "content_types": ["image/webp"] }`. Returns `{ run_id, upload_token, frame_uploads }`.
2. `PUT` each cropped WebP/PNG (<= 4 MB) to its presigned `put_url`.
3. `POST https://bootwatch.fun/api/v1/runs/complete` — body `{ "upload_token": "...", "run": { "schema_version": "bootwatch-run-v1", ... } }`. Rejects physics invariant violations or unscrubbed home directory paths with HTTP `422`.
4. Read sanitized run telemetry at `GET https://bootwatch.fun/api/v1/runs/{shortId}.json` or view the flight recorder at `https://bootwatch.fun/runs/{shortId}`.

**Truthfulness Firewall:** `telemetry_runs` power `/runs/{shortId}`, aggregated VRAM-tier rig checks, and per-commit FPS graphs, and **never** auto-advance the official homepage Playable stage bar.
