{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://botlandscape.com/result-intervals.schema.json",
  "title": "Bot Landscape result intervals projection",
  "description": "Cited policy results with trial counts, Beta posterior intervals and compact-letter tiers, generated by scripts/result_intervals.py from catalogue/result-ledger.json and site-reproduced results. Rows on different boards are never compared.",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "schema_version", "method", "boards", "rows"],
  "properties": {
    "$schema": {"const": "https://botlandscape.com/result-intervals.schema.json"},
    "schema_version": {"const": 1},
    "method": {
      "type": "object",
      "additionalProperties": false,
      "required": ["version", "prior", "interval", "k", "comparison", "letters", "scope"],
      "properties": {
        "version": {"type": "string", "pattern": "^result-intervals/[0-9]+$"},
        "prior": {"type": "string", "minLength": 1},
        "interval": {"type": "string", "minLength": 1},
        "k": {"type": "string", "minLength": 1},
        "comparison": {"type": "string", "minLength": 1},
        "letters": {"type": "string", "minLength": 1},
        "scope": {"type": "string", "minLength": 1}
      }
    },
    "boards": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "benchmark", "split", "condition", "metric", "protocol", "medium", "pairwise_threshold", "letter_groups", "rows", "comparisons"],
        "properties": {
          "id": {"type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"},
          "benchmark": {"type": "string", "minLength": 1},
          "split": {"type": "string", "minLength": 1},
          "condition": {"type": "string", "minLength": 1},
          "metric": {"type": "string", "minLength": 1},
          "protocol": {"type": "string", "minLength": 1},
          "medium": {"type": "array", "minItems": 1, "items": {"enum": ["sim", "real"]}},
          "pairwise_threshold": {"type": "number", "minimum": 0},
          "letter_groups": {"type": "integer", "minimum": 0, "description": "Letter groups on this board. Above 26, names continue aa, ab, ... and each row's letters are comma-separated."},
          "rows": {"type": "array", "minItems": 1, "items": {"type": "string"}},
          "comparisons": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["a", "b", "p_a_greater", "separated"],
              "properties": {
                "a": {"type": "string"},
                "b": {"type": "string"},
                "p_a_greater": {"type": "number", "minimum": 0},
                "separated": {"type": "boolean"}
              }
            }
          }
        }
      }
    },
    "rows": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id", "board", "benchmark", "split", "condition", "policy", "metric", "protocol",
          "value_percent", "n_trials", "n_basis", "seeds", "medium", "evaluator", "source_url", "locator", "note",
          "k", "k_exact", "posterior_mean", "interval_low", "interval_high", "interval_width", "letters"
        ],
        "properties": {
          "id": {"type": "string", "pattern": "^[a-z0-9]+(?:[-.][a-z0-9]+)*$"},
          "board": {"type": "string", "minLength": 1},
          "benchmark": {"type": "string", "minLength": 1},
          "split": {"type": "string", "minLength": 1},
          "condition": {"type": "string", "minLength": 1},
          "policy": {"type": "string", "minLength": 1},
          "metric": {"type": "string", "minLength": 1},
          "protocol": {"type": "string", "minLength": 1},
          "value_percent": {"type": "number", "minimum": 0},
          "n_trials": {"type": ["integer", "null"], "minimum": 1},
          "n_basis": {"enum": ["stated", "derived", "site", null]},
          "seeds": {"type": ["integer", "null"], "minimum": 1},
          "medium": {"enum": ["sim", "real"]},
          "evaluator": {"enum": ["self", "third-party", "challenge", "site"]},
          "source_url": {"type": "string", "pattern": "^(https://|/)"},
          "locator": {"type": "string", "minLength": 1},
          "quote": {"type": "string"},
          "reported_in": {"type": "string"},
          "note": {"type": "string"},
          "k": {"type": ["integer", "null"], "minimum": 0},
          "k_exact": {"type": ["boolean", "null"]},
          "posterior_mean": {"type": ["number", "null"], "minimum": 0},
          "interval_low": {"type": ["number", "null"], "minimum": 0},
          "interval_high": {"type": ["number", "null"], "minimum": 0},
          "interval_width": {"type": ["number", "null"], "minimum": 0},
          "letters": {"type": ["string", "null"], "pattern": "^(?:[a-z]*|[a-z]+(?:,[a-z]+)+)$"}
        }
      }
    }
  }
}
