{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.invalid/agentplaykit/report.schema.json",
  "title": "AgentPlay report (report.json, SPEC-013)",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "report_version",
    "logs",
    "skipped",
    "worlds"
  ],
  "properties": {
    "report_version": {
      "const": 1
    },
    "logs": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "skipped": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "log",
          "reason"
        ],
        "additionalProperties": false,
        "properties": {
          "log": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        }
      }
    },
    "worlds": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/world"
      }
    }
  },
  "$defs": {
    "interval": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "value",
        "low",
        "high"
      ],
      "additionalProperties": false,
      "properties": {
        "value": {
          "type": "number"
        },
        "low": {
          "type": "number"
        },
        "high": {
          "type": "number"
        }
      }
    },
    "world": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "world",
        "run_count",
        "rated_games",
        "solo",
        "scenarios",
        "judge_cost_usd",
        "roles",
        "competitors",
        "head_to_head",
        "notes",
        "runs"
      ],
      "properties": {
        "world": {
          "type": "object",
          "required": [
            "name",
            "version"
          ],
          "properties": {
            "name": {
              "type": "string"
            },
            "version": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "run_count": {
          "type": "integer",
          "minimum": 0
        },
        "rated_games": {
          "type": "integer",
          "minimum": 0
        },
        "solo": {
          "type": "boolean"
        },
        "scenarios": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "judge_cost_usd": {
          "type": "number"
        },
        "roles": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "required": [
              "games",
              "score_rate"
            ],
            "properties": {
              "games": {
                "type": "integer",
                "minimum": 0
              },
              "score_rate": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          }
        },
        "competitors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/competitor"
          }
        },
        "head_to_head": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/pair"
          }
        },
        "notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "runs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/run"
          }
        }
      }
    },
    "competitor": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "rank",
        "key",
        "use",
        "kind",
        "model",
        "runs",
        "rated_games",
        "wins",
        "draws",
        "losses",
        "score_rate",
        "rating",
        "provisional",
        "steps_mean",
        "cost_usd",
        "illegal_per_run",
        "forfeits",
        "errors",
        "evals",
        "tags"
      ],
      "properties": {
        "rank": {
          "type": "integer",
          "minimum": 1
        },
        "key": {
          "type": "string"
        },
        "use": {
          "type": [
            "string",
            "null"
          ]
        },
        "kind": {
          "type": [
            "string",
            "null"
          ]
        },
        "model": {
          "type": [
            "string",
            "null"
          ]
        },
        "runs": {
          "type": "integer",
          "minimum": 0
        },
        "rated_games": {
          "type": "integer",
          "minimum": 0
        },
        "wins": {
          "type": "integer",
          "minimum": 0
        },
        "draws": {
          "type": "integer",
          "minimum": 0
        },
        "losses": {
          "type": "integer",
          "minimum": 0
        },
        "score_rate": {
          "$ref": "#/$defs/interval"
        },
        "rating": {
          "$ref": "#/$defs/interval"
        },
        "provisional": {
          "type": "boolean"
        },
        "steps_mean": {
          "type": [
            "number",
            "null"
          ]
        },
        "cost_usd": {
          "type": "object",
          "required": [
            "mean",
            "total",
            "unknown_runs"
          ],
          "additionalProperties": false,
          "properties": {
            "mean": {
              "type": [
                "number",
                "null"
              ]
            },
            "total": {
              "type": "number"
            },
            "unknown_runs": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "illegal_per_run": {
          "type": "number"
        },
        "forfeits": {
          "type": "integer",
          "minimum": 0
        },
        "errors": {
          "type": "integer",
          "minimum": 0
        },
        "evals": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "required": [
              "judged",
              "passed",
              "pass_rate",
              "score_mean"
            ],
            "properties": {
              "judged": {
                "type": "integer",
                "minimum": 0
              },
              "passed": {
                "type": "integer",
                "minimum": 0
              },
              "pass_rate": {
                "$ref": "#/$defs/interval"
              },
              "score_mean": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          }
        },
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "required": [
              "count",
              "judged",
              "logs"
            ],
            "properties": {
              "count": {
                "type": "integer",
                "minimum": 0
              },
              "judged": {
                "type": "integer",
                "minimum": 0
              },
              "logs": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "pair": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "a",
        "b",
        "games",
        "wins",
        "draws",
        "losses",
        "score_rate",
        "by_seating"
      ],
      "properties": {
        "a": {
          "type": "string"
        },
        "b": {
          "type": "string"
        },
        "games": {
          "type": "integer",
          "minimum": 0
        },
        "wins": {
          "type": "integer",
          "minimum": 0
        },
        "draws": {
          "type": "integer",
          "minimum": 0
        },
        "losses": {
          "type": "integer",
          "minimum": 0
        },
        "score_rate": {
          "type": [
            "number",
            "null"
          ]
        },
        "by_seating": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "roles",
              "games",
              "score_rate"
            ],
            "properties": {
              "roles": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "games": {
                "type": "integer",
                "minimum": 0
              },
              "score_rate": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          }
        }
      },
      "description": "Results of a against b; score_rate is a's."
    },
    "run": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "log",
        "page",
        "seed",
        "scenario_sha256",
        "reason",
        "agents",
        "winners",
        "rated"
      ],
      "properties": {
        "log": {
          "type": "string"
        },
        "page": {
          "type": [
            "string",
            "null"
          ]
        },
        "seed": {
          "type": [
            "integer",
            "null"
          ]
        },
        "scenario_sha256": {
          "type": [
            "string",
            "null"
          ]
        },
        "reason": {
          "type": "string"
        },
        "agents": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "winners": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "rated": {
          "type": "boolean"
        }
      }
    }
  }
}
