{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://medgauge.org/schemas/0.1.0/dataset.schema.json",
  "title": "dataset",
  "description": "A dataset card (dataset registry): type, provenance, quality checks, access tier, relation to benchmarks and maintainer.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^ds-[a-z0-9-]+$"
    },
    "name_zh": {
      "type": "string",
      "minLength": 1
    },
    "name_en": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "enum": [
        "pretrain",
        "eval",
        "sft",
        "preference",
        "trajectory",
        "augmentation",
        "environment",
        "rubric"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "proposed",
        "experimental",
        "deprecated",
        "retired",
        "planned"
      ]
    },
    "relation_to_benchmarks": {
      "type": "object",
      "properties": {
        "serves_capabilities": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[ABCDEX]\\.\\d+(\\.\\d+)?$"
          }
        },
        "isolated_from": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "similarity_check": {
          "type": "object",
          "properties": {
            "method": {
              "type": "string",
              "minLength": 1
            },
            "result": {
              "type": "string",
              "enum": [
                "pass",
                "fail",
                "not_run"
              ]
            },
            "date": {
              "type": "string",
              "format": "date"
            }
          },
          "required": [
            "method",
            "result"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "serves_capabilities",
        "isolated_from",
        "similarity_check"
      ],
      "additionalProperties": false
    },
    "provenance": {
      "type": "object",
      "properties": {
        "origin": {
          "type": "string",
          "enum": [
            "synthetic",
            "public_licensed",
            "institutional_deidentified"
          ]
        },
        "generator": {
          "type": "string"
        },
        "seed_policy": {
          "type": "string"
        },
        "deidentification": {
          "type": "string"
        },
        "license_of_sources": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "legal_status": {
          "type": "string",
          "enum": [
            "not_personal_information",
            "anonymized",
            "deidentified_personal_information"
          ]
        },
        "reidentification_risk_assessment": {
          "type": [
            "string",
            "null"
          ],
          "description": "Required for anonymised or de-identified data: path or DOI of the GB/T 42460 assessment"
        }
      },
      "required": [
        "origin",
        "legal_status"
      ],
      "additionalProperties": false
    },
    "size": {
      "type": "object",
      "properties": {
        "n_tasks": {
          "type": "integer",
          "minimum": 0
        },
        "n_trajectories": {
          "type": "integer",
          "minimum": 0
        },
        "tokens": {
          "type": "string"
        },
        "n_records": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "format": {
      "type": "object",
      "properties": {
        "task": {
          "type": "string"
        },
        "trajectory": {
          "type": "string"
        },
        "files": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "quality": {
      "type": "object",
      "properties": {
        "program_verified_ratio": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "expert_reviewed_sample": {
          "type": "object",
          "properties": {
            "n": {
              "type": "integer",
              "minimum": 0
            },
            "agreement": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "sampling": {
              "type": "string"
            }
          },
          "additionalProperties": false
        },
        "individual_identifiable_scan": {
          "type": "string",
          "enum": [
            "zero_hit",
            "not_run"
          ],
          "description": "Supporting evidence only: no hit within the scanner's coverage; not a conclusion that none exist"
        }
      },
      "required": [
        "individual_identifiable_scan"
      ],
      "additionalProperties": false
    },
    "access": {
      "type": "object",
      "properties": {
        "tier": {
          "type": "string",
          "enum": [
            "open",
            "research",
            "commercial"
          ]
        },
        "license": {
          "type": "object",
          "properties": {
            "open": {
              "type": "string"
            },
            "research": {
              "type": "string"
            },
            "commercial": {
              "type": "string"
            }
          },
          "additionalProperties": false
        },
        "apply_url": {
          "type": "string"
        },
        "doi": {
          "type": "string"
        },
        "croissant": {
          "type": "string"
        },
        "delivery": {
          "type": "string",
          "enum": [
            "download",
            "sandbox_only"
          ]
        }
      },
      "required": [
        "tier",
        "license"
      ],
      "additionalProperties": false
    },
    "datasheet": {
      "type": "object",
      "properties": {
        "motivation": {
          "type": "string"
        },
        "composition": {
          "type": "string"
        },
        "collection": {
          "type": "string"
        },
        "preprocessing": {
          "type": "string"
        },
        "uses": {
          "type": "string"
        },
        "distribution": {
          "type": "string"
        },
        "maintenance": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "citation": {
      "type": "string"
    },
    "maintainer": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    }
  },
  "required": [
    "id",
    "name_en",
    "type",
    "status",
    "relation_to_benchmarks",
    "provenance",
    "quality",
    "access",
    "maintainer",
    "version"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "provenance": {
            "properties": {
              "legal_status": {
                "enum": [
                  "anonymized",
                  "deidentified_personal_information"
                ]
              }
            }
          }
        }
      },
      "then": {
        "properties": {
          "provenance": {
            "properties": {
              "reidentification_risk_assessment": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "provenance": {
            "properties": {
              "legal_status": {
                "const": "deidentified_personal_information"
              }
            }
          }
        }
      },
      "then": {
        "properties": {
          "access": {
            "properties": {
              "delivery": {
                "const": "sandbox_only"
              }
            }
          }
        }
      }
    }
  ]
}
