{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xecores.com/api/v1/result.schema.json",
  "title": "XeCores benchmark submission v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "challenge", "runner", "engine", "hardware", "model", "profile", "aggregate", "samples", "credit"],
  "properties": {
    "schema_version": { "const": "1.0" },
    "challenge": {
      "type": "object", "additionalProperties": false, "required": ["id", "token"],
      "properties": { "id": { "type": "string", "format": "uuid" }, "token": { "type": "string", "minLength": 32, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" } }
    },
    "runner": {
      "type": "object", "additionalProperties": false, "required": ["name", "version", "run_id", "started_at", "duration_s"],
      "properties": {
        "name": { "const": "xecores-runner" }, "version": { "type": "string", "maxLength": 32 }, "run_id": { "type": "string", "format": "uuid" },
        "started_at": { "type": "string", "format": "date-time" }, "duration_s": { "type": "number", "minimum": 0.001, "maximum": 86400 }
      }
    },
    "engine": {
      "type": "object", "additionalProperties": false, "required": ["name", "version", "api"],
      "properties": { "name": { "enum": ["vllm", "sglang", "llama.cpp"] }, "version": { "type": "string", "maxLength": 120 }, "api": { "const": "openai-completions" } }
    },
    "hardware": {
      "type": "object", "additionalProperties": false,
      "required": ["gpu_vendor", "gpu_model", "gpu_count", "vram_gib_per_gpu", "driver", "kernel", "os", "cpu", "ram_gib", "power_limit_w"],
      "properties": {
        "gpu_vendor": { "const": "Intel" }, "gpu_model": { "type": "string", "minLength": 2, "maxLength": 120 }, "gpu_count": { "type": "integer", "minimum": 1, "maximum": 16 },
        "vram_gib_per_gpu": { "type": "number", "minimum": 1, "maximum": 256 }, "driver": { "type": "string", "maxLength": 120 }, "kernel": { "type": "string", "maxLength": 120 },
        "os": { "type": "string", "maxLength": 120 }, "cpu": { "type": "string", "maxLength": 160 }, "ram_gib": { "type": "number", "minimum": 1, "maximum": 4096 },
        "power_limit_w": { "type": ["number", "null"], "minimum": 1, "maximum": 2000 }
      }
    },
    "model": {
      "type": "object", "additionalProperties": false, "required": ["id", "revision", "quantization", "dtype"],
      "properties": { "id": { "type": "string", "minLength": 1, "maxLength": 240 }, "revision": { "type": "string", "maxLength": 120 }, "quantization": { "type": "string", "maxLength": 80 }, "dtype": { "type": "string", "maxLength": 40 } }
    },
    "profile": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "mode", "concurrency", "prompt_target_tokens", "output_target_tokens", "warmup_requests", "measured_requests", "stream", "temperature", "seed"],
      "properties": {
        "id": { "type": "string", "pattern": "^p[0-9]+-g[0-9]+-c(?:1|2|4|8|16|32)-v1$" }, "mode": { "const": "closed-loop" },
        "concurrency": { "enum": [1, 2, 4, 8, 16, 32] }, "prompt_target_tokens": { "type": "integer", "minimum": 1, "maximum": 131072 },
        "output_target_tokens": { "type": "integer", "minimum": 1, "maximum": 8192 }, "warmup_requests": { "type": "integer", "minimum": 0, "maximum": 128 },
        "measured_requests": { "type": "integer", "minimum": 1, "maximum": 256 }, "stream": { "const": true }, "temperature": { "type": "number", "minimum": 0, "maximum": 2 }, "seed": { "type": "integer" }
      }
    },
    "aggregate": {
      "type": "object", "additionalProperties": false,
      "required": ["successful_requests", "failed_requests", "wall_time_s", "request_throughput_rps", "input_tokens_per_s", "output_tokens_per_s", "total_tokens_per_s", "ttft_ms", "tpot_ms", "e2e_ms", "inter_token_latency_ms"],
      "properties": {
        "successful_requests": { "type": "integer", "minimum": 0, "maximum": 256 }, "failed_requests": { "type": "integer", "minimum": 0, "maximum": 256 },
        "wall_time_s": { "type": "number", "minimum": 0, "maximum": 86400 }, "request_throughput_rps": { "type": "number", "minimum": 0 },
        "input_tokens_per_s": { "type": "number", "minimum": 0 }, "output_tokens_per_s": { "type": "number", "minimum": 0 }, "total_tokens_per_s": { "type": "number", "minimum": 0 },
        "ttft_ms": { "$ref": "#/$defs/metricPair" }, "tpot_ms": { "$ref": "#/$defs/metricPair" }, "e2e_ms": { "$ref": "#/$defs/metricPair" }, "inter_token_latency_ms": { "$ref": "#/$defs/metricPair" }
      }
    },
    "samples": { "type": "array", "minItems": 1, "maxItems": 256, "items": { "$ref": "#/$defs/sample" } },
    "credit": {
      "oneOf": [
        { "type": "null" },
        { "type": "object", "additionalProperties": false, "required": ["display_name", "url"], "properties": { "display_name": { "type": "string", "minLength": 1, "maxLength": 80 }, "url": { "type": ["string", "null"], "format": "uri", "maxLength": 240 } } }
      ]
    }
  },
  "$defs": {
    "metricPair": {
      "type": "object", "additionalProperties": false, "required": ["p50", "p95"],
      "properties": { "p50": { "type": ["number", "null"], "minimum": 0 }, "p95": { "type": ["number", "null"], "minimum": 0 } }
    },
    "sample": {
      "type": "object", "additionalProperties": false,
      "required": ["index", "prompt_tokens", "output_tokens", "ttft_ms", "e2e_ms", "tpot_ms", "inter_token_latency_ms", "error"],
      "properties": {
        "index": { "type": "integer", "minimum": 0, "maximum": 255 }, "prompt_tokens": { "type": "integer", "minimum": 0, "maximum": 131072 }, "output_tokens": { "type": "integer", "minimum": 0, "maximum": 8192 },
        "ttft_ms": { "type": ["number", "null"], "minimum": 0 }, "e2e_ms": { "type": ["number", "null"], "minimum": 0 }, "tpot_ms": { "type": ["number", "null"], "minimum": 0 },
        "inter_token_latency_ms": { "type": ["number", "null"], "minimum": 0 }, "error": { "type": ["string", "null"], "maxLength": 120 }
      }
    }
  }
}
