{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://grids365.dev/corpus/evaluation/training-inventory.schema.json",
  "title": "Grid model training-data inventory",
  "type": "object",
  "required": [
    "schemaVersion",
    "inventoryId",
    "createdAt",
    "frozenAt",
    "files",
    "sourceFamilies"
  ],
  "properties": {
    "schemaVersion": { "const": 1 },
    "inventoryId": { "$ref": "#/$defs/opaqueId" },
    "createdAt": { "type": "string", "format": "date-time" },
    "frozenAt": { "type": "string", "format": "date-time" },
    "files": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "path",
          "split",
          "mediaType",
          "sha256",
          "bytes",
          "records",
          "recordSourceFamilyIds"
        ],
        "properties": {
          "path": { "$ref": "#/$defs/relativePath" },
          "split": { "const": "train" },
          "mediaType": {
            "enum": [
              "application/json",
              "application/x-ndjson",
              "text/markdown",
              "text/plain",
              "text/x-grid"
            ]
          },
          "sha256": { "$ref": "#/$defs/sha256" },
          "bytes": { "type": "integer", "minimum": 1 },
          "records": { "type": "integer", "minimum": 1 },
          "recordSourceFamilyIds": {
            "type": "array",
            "minItems": 1,
            "items": { "$ref": "#/$defs/opaqueId" }
          }
        },
        "additionalProperties": false
      }
    },
    "sourceFamilies": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["id", "split"],
        "properties": {
          "id": { "$ref": "#/$defs/opaqueId" },
          "split": { "const": "train" }
        },
        "additionalProperties": false
      },
      "uniqueItems": true
    }
  },
  "$defs": {
    "opaqueId": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "relativePath": {
      "type": "string",
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*(?:^|/)\\.(?:/|$))[^\\\\\\u0000]+$"
    }
  },
  "additionalProperties": false
}
