# Benchmark-Anything — Agent Skill Specification

> **Service:** Benchmark-Anything (`https://benchmark.fastmesh.dev`)
> **Purpose:** Live multi-protocol endpoint benchmarking across DoH DNS, REST JSON, Web Extraction, MCP JSON-RPC 2.0, and OpenAI-compatible BYOK gateways with anti-fake-200 verification, `P50 / P95 / P99` latency percentiles, `effective_cost_per_verified_hit_usd` economics, and tamper-evident SHA-256 Verified Benchmark Cards.
> **Contact:** `benchmark@fastmesh.dev` | Ops: `ops@fastmesh.dev`

## Discovery & Machine Endpoints

- **Health Check:** `GET https://benchmark.fastmesh.dev/health`
- **OpenAPI 3.1 Schema:** `GET https://benchmark.fastmesh.dev/openapi.json`
- **AI Crawler Index:** `GET https://benchmark.fastmesh.dev/llms.txt`
- **XML Sitemap:** `GET https://benchmark.fastmesh.dev/sitemap.xml`
- **Verified Leaderboard Hub:** `GET https://benchmark.fastmesh.dev/seo_geo/`
- **Stored Leaderboards API:** `GET https://benchmark.fastmesh.dev/v1/leaderboards?limit=20&track=doh_dns`
- **MCP JSON-RPC 2.0 Endpoint:** `POST https://benchmark.fastmesh.dev/mcp`

## Supported Benchmark Protocols (5 Tracks)

1. `doh_dns` — Public DNS-over-HTTPS JSON resolvers (`Accept: application/dns-json`); validates `Status == 0` and non-empty `Answer` records.
2. `rest_json` — Public REST JSON APIs; validates `expected_keys`, non-empty payloads, and rejects soft-error HTTP 200 JSON bodies.
3. `web_extract` — Public HTML/text/Markdown extraction endpoints; detects Cloudflare interstitials, captcha walls, login walls, and empty stubs returned with HTTP 200, plus `expected_text` verification.
4. `mcp_jsonrpc` — Standard MCP JSON-RPC 2.0 Streamable HTTP servers (`initialize`, `tools/list`, optional `tools/call`), supporting both raw `application/json` and SSE `text/event-stream` (`data: {...}`) responses while flagging JSON-RPC `"error"` and `isError: true` soft failures.
5. `openai_compat` — OpenAI-compatible `/v1/chat/completions` and `/v1/models` BYOK endpoints; passes caller credentials strictly in memory with full redaction across all logs, traces, receipts, and signed cards.

## REST API Quickstart

### 1. Run a Live Benchmark (`POST /v1/benchmark/run`)

Accepted top-level parameters:
- `targets` (required, array of `1..12` target objects; each requires `protocol` and public `url`, plus optional `id`, `name`, `method`, `headers`, `body`, `expected_keys`, `expected_text`, `listed_price_usd`, `bills_on_failure`, `query_name`, `query_type`, `mcp_tool_name`, `mcp_tool_args`, `model`)
- `title` (optional string)
- `track` (optional string: `doh_dns`, `rest_json`, `web_extract`, `mcp_jsonrpc`, `openai_compat`)
- `tenant_id` (optional string, default `"public_demo"`)
- `samples_per_target` (integer clamped `1..25`, default `3`)
- `concurrency` (integer clamped `1..8`, default `4`)
- `timeout_s` (number clamped `1..15`, default `8`)
- `no_cache` (boolean, default `false`)
- `render_leaderboard` (boolean, default `false`)
- `byok_headers` / `byok_api_key` (optional pass-through credentials, strictly redacted everywhere)

```bash
curl -sS -X POST https://benchmark.fastmesh.dev/v1/benchmark/run \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Public DoH DNS Resolvers 2026",
    "track": "doh_dns",
    "samples_per_target": 5,
    "concurrency": 3,
    "timeout_s": 8,
    "render_leaderboard": false,
    "targets": [
      {
        "id": "doh_cloudflare_public",
        "name": "Cloudflare Public DoH (1.1.1.1)",
        "protocol": "doh_dns",
        "url": "https://cloudflare-dns.com/dns-query?name=example.com&type=A",
        "query_name": "example.com",
        "query_type": "A",
        "listed_price_usd": 0.0000004,
        "bills_on_failure": false
      },
      {
        "id": "doh_google_public",
        "name": "Google Public DNS DoH (8.8.8.8)",
        "protocol": "doh_dns",
        "url": "https://dns.google/resolve?name=example.com&type=A",
        "query_name": "example.com",
        "query_type": "A",
        "listed_price_usd": 0.0000004,
        "bills_on_failure": false
      }
    ]
  }'
```

Key response fields:
- `card`: Tamper-evident `VerifiedBenchmarkCard` containing `card_id`, `card_sha256`, `measured_at_utc`, `summary`, `zero_resale_pledge`, and per-target metrics (`total_probes`, `verified_hits`, `fake_200_count`, `schema_pass_count`, `error_count`, `success_rate`, `fake_200_rate`, `schema_pass_rate`, `error_rate`, `p50_ms`, `p95_ms`, `p99_ms`, `mean_ms`, `listed_price_usd`, `bills_on_failure`, `effective_cost_per_verified_hit_usd`, `effective_cost_status`, `rank`).
- `billing` / `charged_micros`: Transparent billing receipt (`charged_micros == 0` on `422` invalid input, SSRF blocks, or when all targets yield `0` verified hits; repeat-tenant `ArchiveCache` hits bill `10%`).

### 2. Compile a Publishable Leaderboard (`POST /v1/leaderboard/render`)

Pass either `card` (a `VerifiedBenchmarkCard` object) or `card_id` (a saved card ID), plus optional `title`, `category`, and `canonical_url` to receive HTML, Markdown, and JSON-LD `Dataset` + `FAQPage` output.

```bash
curl -sS -X POST https://benchmark.fastmesh.dev/v1/leaderboard/render \
  -H "Content-Type: application/json" \
  -d '{
    "card_id": "<card_id_from_benchmark_run>",
    "title": "Best Public DoH DNS Resolvers 2026",
    "canonical_url": "https://benchmark.fastmesh.dev/seo_geo/best-doh-dns-resolvers-2026.html"
  }'
```

## MCP JSON-RPC 2.0 Integration (`POST /mcp`)

Supported JSON-RPC 2.0 methods: `initialize`, `notifications/initialized`, `ping`, `tools/list`, `tools/call`.

### Discover Tools (`tools/list`)

```bash
curl -sS -X POST https://benchmark.fastmesh.dev/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
```

Exposed MCP tools:
1. `benchmark_run` — Execute live multi-target probes (`targets`, `title`, `track`, `samples_per_target`, `concurrency`, `timeout_s`, `no_cache`, `render_leaderboard`) and return a SHA-256 `VerifiedBenchmarkCard`.
2. `benchmark_verify_card` — Verify the canonical SHA-256 signature of a `VerifiedBenchmarkCard` in constant time (`{"card": {...}}`).
3. `leaderboard_list` — List persisted verified benchmark cards (`limit`, `track`).
4. `leaderboard_render` — Compile a `VerifiedBenchmarkCard` or `card_id` into HTML, Markdown, and JSON-LD `Dataset` + `FAQPage`.

### Example `tools/call` (`benchmark_run`)

```bash
curl -sS -X POST https://benchmark.fastmesh.dev/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "benchmark_run",
      "arguments": {
        "title": "Remote MCP Server Handshake Check",
        "track": "mcp_jsonrpc",
        "samples_per_target": 3,
        "targets": [
          {
            "id": "mcp_cloudflare_docs",
            "name": "Cloudflare Docs Remote MCP",
            "protocol": "mcp_jsonrpc",
            "url": "https://docs.mcp.cloudflare.com/mcp",
            "headers": {"Accept": "application/json, text/event-stream"}
          }
        ]
      }
    }
  }'
```

## Alternative Agent & Marketplace Bridges

- **1-Line `treg hub` Call (`$0.15` verified run, `$0` on failure or `0` verified hits):**
  ```bash
  treg call benchmark-anything --data '{"title":"Public DoH 2026","track":"doh_dns","samples_per_target":3,"targets_json":"[{\"id\":\"cf\",\"name\":\"Cloudflare DoH\",\"protocol\":\"doh_dns\",\"url\":\"https://cloudflare-dns.com/dns-query\",\"query_name\":\"example.com\",\"query_type\":\"A\"}]"}'
  ```
- **Causal Bazaar Public Paid Hand:** `hand_b04_benchmark_anything_v1` (`$0.15` / `150000` micros per fresh verified run; `15000` micros repeat cache hit; `$0` on failure or invalid input; `zero_prompt_resale: true`).

## Guardrails, Privacy & Prepaid Packs

- **Strict SSRF Protection:** Only public `http`/`https` hostnames are allowed. `localhost`, `127.0.0.1`, `::1`, RFC 1918 private ranges, `169.254.169.254` metadata hosts, raw numeric IPs, `.internal`/`.local` hostnames, and non-HTTP schemes are rejected with HTTP `422` and `$0` charge.
- **Zero-Charge Invariant:** HTTP `422` invalid payloads, SSRF blocks, and runs where all targets produce `0` verified hits strictly bill `charged_micros == 0`.
- **Zero BYOK Key & Test-Log Resale Pledge:** Caller BYOK credentials, custom headers, request payloads, and benchmark test logs are strictly redacted in memory and are never resold, shared with third parties, or used for model training.
- **Fixed-Fee Prepaid Creem Credit Packs (`https://benchmark.fastmesh.dev/#pricing`):**
  - **Starter Pack (`sku_b04_starter_19`):** `$19` one-time flat fee — 250 non-expiring runs (`$0.076`/run)
  - **Growth Pack (`sku_b04_growth_79`):** `$79` one-time flat fee — 1,500 non-expiring runs (`$0.0527`/run)
  - **Scale Pack (`sku_b04_scale_249`):** `$249` one-time flat fee — 6,500 non-expiring runs (`$0.0383`/run)
  - Independent engineering software (fixed non-contingent prepaid packs, zero percentage split).
