{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "overseas_theme_evidence.v1.schema.json",
  "type": "object",
  "required": [
    "schema_version",
    "study_id",
    "generated_at_utc",
    "source_revision",
    "decision_time_local",
    "decision_timezone",
    "evidence_status",
    "historical_pit_certified",
    "sample_start",
    "sample_end",
    "source_sha256",
    "sources",
    "comparisons",
    "limitations"
  ],
  "properties": {
    "schema_version": {
      "const": "overseas_theme_evidence.v1"
    },
    "decision_time_local": {
      "const": "08:45"
    },
    "decision_timezone": {
      "const": "Asia/Shanghai"
    },
    "evidence_status": {
      "const": "retrospective_exploratory"
    },
    "historical_pit_certified": {
      "const": false
    },
    "study_id": {
      "type": "string",
      "minLength": 1
    },
    "generated_at_utc": {
      "type": "string",
      "format": "date-time",
      "pattern": "(Z|\\+00:00)$"
    },
    "source_revision": {
      "type": "string",
      "pattern": "^[0-9a-f]{40}$"
    },
    "sample_start": {
      "type": "string",
      "format": "date"
    },
    "sample_end": {
      "type": "string",
      "format": "date"
    },
    "source_sha256": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "string",
        "pattern": "^[0-9a-f]{64}$"
      }
    },
    "sources": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "object",
        "required": [
          "url",
          "sha256"
        ],
        "properties": {
          "url": {
            "type": "string",
            "pattern": "^https?://"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        },
        "additionalProperties": false
      }
    },
    "comparisons": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "evidence_id",
          "source_ids",
          "target",
          "outcome",
          "lag_sessions",
          "n",
          "baseline",
          "augmented",
          "mse_gain",
          "mse_gain_ci95"
        ],
        "properties": {
          "evidence_id": {
            "type": "string",
            "minLength": 1
          },
          "target": {
            "type": "string",
            "minLength": 1
          },
          "outcome": {
            "type": "string",
            "minLength": 1
          },
          "baseline": {
            "type": "string",
            "minLength": 1
          },
          "augmented": {
            "type": "string",
            "minLength": 1
          },
          "source_ids": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "lag_sessions": {
            "type": "integer",
            "minimum": 0
          },
          "n": {
            "type": "integer",
            "minimum": 1
          },
          "mse_gain": {
            "type": "number"
          },
          "mse_gain_ci95": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "number"
            }
          },
          "first": {
            "type": "string",
            "format": "date"
          },
          "last": {
            "type": "string",
            "format": "date"
          },
          "baseline_rmse_bp": {
            "type": "number"
          },
          "augmented_rmse_bp": {
            "type": "number"
          },
          "baseline_hit": {
            "type": "number"
          },
          "augmented_hit": {
            "type": "number"
          }
        },
        "additionalProperties": false
      }
    },
    "limitations": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "additionalProperties": false
}
