{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://grey-chimp.dev/schemas/eve-sota-evaluation-cohort.v1.json",
  "title": "Eve evaluation cohort lock or result manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "kind",
    "cohortId",
    "familyId",
    "designDigestSha256",
    "lockedAt",
    "firstResultObservedAt",
    "status",
    "humanAssessment",
    "primaryCases",
    "denominators",
    "continuousPilotAnalyses",
    "amendments",
    "results",
    "lockDigestSha256"
  ],
  "properties": {
    "schemaVersion": { "const": "eve-sota-evaluation-cohort.v1" },
    "kind": { "enum": ["cohort-lock", "cohort-results"] },
    "cohortId": { "type": "string", "minLength": 1 },
    "familyId": { "type": "string", "minLength": 1 },
    "designDigestSha256": { "$ref": "#/$defs/sha256" },
    "lockedAt": { "type": "string", "minLength": 20 },
    "firstResultObservedAt": { "type": ["string", "null"] },
    "status": { "enum": ["locked-unmeasured", "evaluated-incomplete", "family-closed"] },
    "humanAssessment": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ownerRole", "modelMayReplaceLabels", "assessorRoster"],
      "properties": {
        "ownerRole": { "type": "string", "minLength": 1 },
        "modelMayReplaceLabels": { "const": false },
        "assessorRoster": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["assessorId", "ownerType", "independentOfModelUnderEvaluation"],
            "properties": {
              "assessorId": { "type": "string", "minLength": 1 },
              "ownerType": { "const": "human" },
              "independentOfModelUnderEvaluation": { "const": true }
            }
          }
        }
      }
    },
    "primaryCases": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "caseClassId", "executionMode", "seedIds", "stratumRefs"],
        "properties": {
          "id": { "type": "string", "minLength": 1 },
          "caseClassId": { "type": "string", "minLength": 1 },
          "executionMode": { "enum": ["pure", "model"] },
          "seedIds": { "type": "array", "items": { "type": "string", "minLength": 1 } },
          "stratumRefs": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 }
          }
        }
      }
    },
    "denominators": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["denominatorId", "plannedIndependentN", "primaryCaseIds"],
        "properties": {
          "denominatorId": { "type": "string", "minLength": 1 },
          "plannedIndependentN": { "type": "integer", "minimum": 1 },
          "primaryCaseIds": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 }
          }
        }
      }
    },
    "continuousPilotAnalyses": { "type": "array", "items": { "type": "object" } },
    "amendments": { "type": "array", "items": { "type": "object" } },
    "results": { "type": ["array", "null"] },
    "lockDigestSha256": { "$ref": "#/$defs/sha256" }
  },
  "if": { "properties": { "kind": { "const": "cohort-lock" } } },
  "then": {
    "properties": {
      "firstResultObservedAt": { "type": "null" },
      "status": { "const": "locked-unmeasured" },
      "results": { "type": "null" }
    }
  },
  "$defs": {
    "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
  }
}
