{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "recordType",
    "candidateId",
    "subjectOrganizationId",
    "partnerOrganizationId",
    "requiredFunctions",
    "channels",
    "channelReusePolicy"
  ],
  "properties": {
    "schemaVersion": {
      "const": "2.0.0"
    },
    "recordType": {
      "const": "controlled-contact-matrix"
    },
    "candidateId": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "subjectOrganizationId": {
      "type": "string",
      "pattern": "^organization:[0-9a-f]{64}$"
    },
    "partnerOrganizationId": {
      "type": "string",
      "pattern": "^organization:[0-9a-f]{64}$"
    },
    "requiredFunctions": {
      "const": [
        "change",
        "commercial",
        "incident",
        "partner-escalation",
        "privacy",
        "security",
        "support"
      ]
    },
    "channels": {
      "type": "array",
      "minItems": 7,
      "maxItems": 7,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "function",
          "roleId",
          "identityId",
          "organizationId",
          "channelId",
          "channelType",
          "controlTested",
          "reachabilityTestPath",
          "reachabilityTestSha256"
        ],
        "properties": {
          "function": {
            "enum": [
              "change",
              "commercial",
              "incident",
              "partner-escalation",
              "privacy",
              "security",
              "support"
            ]
          },
          "roleId": {
            "enum": [
              "change-approver",
              "commercial-owner",
              "incident-commander",
              "partner-authorized-signatory",
              "privacy-reviewer",
              "security-contact",
              "support-owner"
            ]
          },
          "identityId": {
            "type": "string",
            "pattern": "^identity:[0-9a-f]{64}$"
          },
          "organizationId": {
            "type": "string",
            "pattern": "^organization:[0-9a-f]{64}$"
          },
          "channelId": {
            "type": "string",
            "pattern": "^channel:[0-9a-f]{64}$"
          },
          "channelType": {
            "enum": [
              "email-alias",
              "paging-route",
              "secure-portal",
              "ticket-queue"
            ]
          },
          "controlTested": {
            "const": true
          },
          "reachabilityTestSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "reachabilityTestPath": {
            "type": "string",
            "pattern": "^pr10/partner-package/evidence/organizational/contact-tests/[a-z0-9-]+\\.json$"
          }
        }
      }
    },
    "channelReusePolicy": {
      "const": "prohibited-across-required-functions"
    }
  }
}
