{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aiwg.io/schemas/decision/ConformalFrozenOpenData.v2.schema.json",
  "title": "Conformal frozen open-data sample v2",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "issue",
    "retrievalDate",
    "license",
    "preregistrationHash",
    "samplePolicy",
    "sourceFiles",
    "tasks",
    "splitHashes",
    "splits",
    "liveSubsets",
    "sampleDigest"
  ],
  "properties": {
    "schemaVersion": {
      "const": "conformal-open-data-frozen/v2"
    },
    "issue": {
      "const": 2613
    },
    "retrievalDate": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "license": {
      "const": "mixed: CLINC150 CC-BY-3.0; Banking77 CC-BY-4.0"
    },
    "preregistrationHash": {
      "$ref": "#/$defs/sha"
    },
    "sampleDigest": {
      "$ref": "#/$defs/sha"
    },
    "samplePolicy": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "seed",
        "maxItems"
      ],
      "properties": {
        "seed": {
          "type": "string",
          "minLength": 1
        },
        "maxItems": {
          "type": "integer",
          "minimum": 1,
          "maximum": 3000
        }
      }
    },
    "sourceFiles": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "dataset",
          "url",
          "license",
          "licenseUrl",
          "licenseSha256",
          "retrievalDate",
          "sha256",
          "bytes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "dataset": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "license": {
            "enum": [
              "CC-BY-3.0",
              "CC-BY-4.0"
            ]
          },
          "licenseUrl": {
            "type": "string",
            "format": "uri"
          },
          "licenseSha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "retrievalDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "bytes": {
            "type": "integer",
            "minimum": 1
          }
        }
      }
    },
    "tasks": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "primitive",
          "labels",
          "datasetPopulation",
          "definitionVersion"
        ],
        "properties": {
          "primitive": {
            "const": "choice"
          },
          "labels": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "datasetPopulation": {
            "type": "string",
            "minLength": 1
          },
          "definitionVersion": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "splitHashes": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "train",
        "calibration",
        "finalTest",
        "shift"
      ],
      "properties": {
        "train": {
          "$ref": "#/$defs/sha"
        },
        "calibration": {
          "$ref": "#/$defs/sha"
        },
        "finalTest": {
          "$ref": "#/$defs/sha"
        },
        "shift": {
          "$ref": "#/$defs/sha"
        }
      }
    },
    "splits": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "train",
        "calibration",
        "finalTest",
        "shift"
      ],
      "properties": {
        "train": {
          "$ref": "#/$defs/rows"
        },
        "calibration": {
          "$ref": "#/$defs/rows"
        },
        "finalTest": {
          "$ref": "#/$defs/rows"
        },
        "shift": {
          "$ref": "#/$defs/rows"
        }
      }
    },
    "liveSubsets": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "policy",
        "ids",
        "hashes"
      ],
      "properties": {
        "policy": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "tasks",
            "selection"
          ],
          "properties": {
            "tasks": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "selection": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "ids": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "calibration",
            "finalTest",
            "shift"
          ],
          "properties": {
            "calibration": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "finalTest": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "shift": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        "hashes": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "calibration",
            "finalTest",
            "shift"
          ],
          "properties": {
            "calibration": {
              "$ref": "#/$defs/sha"
            },
            "finalTest": {
              "$ref": "#/$defs/sha"
            },
            "shift": {
              "$ref": "#/$defs/sha"
            }
          }
        }
      }
    }
  },
  "$defs": {
    "sha": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    },
    "rows": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "task",
          "sourceDataset",
          "canonicalSplit",
          "sourceId",
          "split",
          "text",
          "label",
          "labelIndex",
          "slice"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "task": {
            "type": "string",
            "minLength": 1
          },
          "sourceDataset": {
            "enum": [
              "CLINC150",
              "Banking77"
            ]
          },
          "canonicalSplit": {
            "type": "string",
            "minLength": 1
          },
          "sourceId": {
            "type": "string",
            "minLength": 1
          },
          "split": {
            "enum": [
              "train",
              "calibration",
              "finalTest",
              "shift"
            ]
          },
          "text": {
            "type": "string",
            "minLength": 1
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "labelIndex": {
            "type": "integer",
            "minimum": 0
          },
          "slice": {
            "enum": [
              "nominal",
              "controlled-oos",
              "nominal-heldout"
            ]
          }
        }
      }
    }
  }
}
