{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bioatlas.bayespharma.com/bep-2.0.schema.json",
  "title": "BioAtlas Evidence Protocol 2.0",
  "type": "object",
  "additionalProperties": false,
  "required": ["protocolVersion", "id", "objectType", "schemaVersion", "payload", "provenance"],
  "properties": {
    "@context": { "type": ["string", "object", "array"] },
    "protocolVersion": { "const": "2.0" },
    "conformsTo": { "type": "array", "items": { "type": "string" } },
    "id": { "type": "string", "minLength": 1 },
    "objectType": { "$ref": "#/$defs/objectType" },
    "schemaVersion": { "type": "string", "minLength": 1 },
    "payload": { "type": "object" },
    "links": { "type": "array", "items": { "$ref": "#/$defs/link" } },
    "provenance": { "$ref": "#/$defs/provenance" },
    "uncertainty": { "type": ["object", "null"] },
    "contextOfUse": { "type": ["object", "string", "null"] },
    "crateEntities": { "type": "array", "items": { "$ref": "#/$defs/crateEntity" } }
  },
  "$defs": {
    "objectType": {
      "enum": ["claim", "evidence", "dataset", "analysis", "model", "artifact", "uncertainty", "contradiction", "decision", "review", "snapshot", "scientific-test", "failure", "reproduction-certificate", "agent-trajectory", "review-assignment", "deviation", "capa", "qualification"]
    },
    "link": {
      "type": "object",
      "additionalProperties": false,
      "required": ["relation", "target"],
      "properties": {
        "relation": { "type": "string", "minLength": 1 },
        "target": { "type": "string", "minLength": 1 },
        "evidenceIds": { "type": "array", "items": { "type": "string" } }
      }
    },
    "crateEntity": {
      "type": "object",
      "required": ["id", "type"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "type": { "type": "string", "minLength": 1 },
        "name": { "type": ["string", "null"] },
        "contentHash": { "type": ["string", "null"], "pattern": "^[a-fA-F0-9]{64}$" }
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["createdAt"],
      "properties": {
        "createdAt": { "type": "string", "format": "date-time" },
        "sourceIds": { "type": "array", "items": { "type": "string" } },
        "parentIds": { "type": "array", "items": { "type": "string" } },
        "contentHash": { "type": ["string", "null"], "pattern": "^[a-fA-F0-9]{64}$" },
        "softwareVersion": { "type": ["string", "null"] },
        "activityId": { "type": ["string", "null"] },
        "agentId": { "type": ["string", "null"] }
      }
    }
  }
}