{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://discoverphysics.github.io/schema/result.schema.json",
  "title": "DiscoverPhysics result entry",
  "description": "Schema for one model's results in data/results.json. Generated by build_data.py from the .txt summaries in model-results/.",
  "type": "object",
  "required": [
    "model",
    "n_trials",
    "passed",
    "passed_total",
    "explanation_score",
    "normalized_mse",
    "pass_at_k",
    "per_world"
  ],
  "additionalProperties": false,
  "properties": {
    "model": {
      "type": "string",
      "description": "Canonical model identifier (provider prefix stripped).",
      "minLength": 1
    },
    "n_trials": { "type": "integer", "minimum": 0 },
    "passed": { "type": "integer", "minimum": 0 },
    "passed_total": { "type": "integer", "minimum": 0 },
    "explanation_score": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mean"],
      "properties": {
        "mean": { "type": "number", "minimum": 0, "maximum": 1 },
        "se": { "type": ["number", "null"], "minimum": 0 }
      }
    },
    "normalized_mse": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mean"],
      "description": "Geometric mean of normalized MSE across trials, with asymmetric SE bounds in log space.",
      "properties": {
        "mean": { "type": "number", "minimum": 0 },
        "up": { "type": ["number", "null"], "minimum": 0 },
        "down": { "type": ["number", "null"], "minimum": 0 }
      }
    },
    "pass_at_k": {
      "type": "object",
      "required": ["1", "2", "3", "4", "5"],
      "additionalProperties": false,
      "patternProperties": {
        "^[1-9][0-9]*$": {
          "type": "object",
          "additionalProperties": false,
          "required": ["mean"],
          "properties": {
            "mean": { "type": "number", "minimum": 0, "maximum": 100 },
            "se": { "type": ["number", "null"], "minimum": 0 },
            "raw": {
              "type": "string",
              "description": "Raw count string from the summary, e.g. '3/11'.",
              "pattern": "^\\d+/\\d+$"
            }
          }
        }
      }
    },
    "per_world": {
      "type": "object",
      "description": "Per-world breakdown. Keys must match the world ids in data/worlds.json.",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": ["n", "explanation_score", "geom_pos_err"],
        "properties": {
          "n": { "type": "integer", "minimum": 0 },
          "explanation_score": {
            "type": "object",
            "additionalProperties": false,
            "required": ["mean"],
            "properties": {
              "mean": { "type": "number", "minimum": 0, "maximum": 1 },
              "se": { "type": ["number", "null"], "minimum": 0 }
            }
          },
          "geom_pos_err": {
            "type": "object",
            "additionalProperties": false,
            "required": ["mean"],
            "properties": {
              "mean": { "type": ["number", "null"], "minimum": 0 },
              "up": { "type": ["number", "null"], "minimum": 0 },
              "down": { "type": ["number", "null"], "minimum": 0 }
            }
          }
        }
      }
    }
  }
}
