{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ver.cy/models/wm-xct-001-ownership-stewardship/profiles/enterprise-fact-authority/0.1.0/authority.schema.json",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "format",
    "version",
    "dimension",
    "authorities",
    "observations"
  ],
  "properties": {
    "format": {
      "const": "vercy-fact-authority"
    },
    "version": {
      "const": "0.1.0"
    },
    "dimension": {
      "type": "string",
      "format": "uri",
      "maxLength": 500
    },
    "authorities": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/authority"
      },
      "minItems": 0,
      "maxItems": 10000,
      "uniqueItems": true
    },
    "observations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/observation"
      },
      "minItems": 0,
      "maxItems": 10000,
      "uniqueItems": true
    }
  },
  "$defs": {
    "stewardship": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "party",
        "duties",
        "validFrom",
        "validUntil",
        "evidence"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "party": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "duties": {
          "type": "array",
          "items": {
            "enum": [
              "maintain-quality",
              "resolve-conflict",
              "coordinate-transfer"
            ]
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "validFrom": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        }
      }
    },
    "rule": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "source",
        "priority",
        "validFrom",
        "validUntil",
        "evidence"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "source": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "priority": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000
        },
        "validFrom": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        }
      }
    },
    "writeGrant": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "source",
        "writers",
        "validFrom",
        "validUntil",
        "evidence"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "source": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "writers": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "validFrom": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        }
      }
    },
    "authority": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "dimension",
        "scope",
        "predicate",
        "change",
        "revision",
        "previousDigest",
        "recordedAt",
        "validFrom",
        "validUntil",
        "evidence",
        "governs",
        "definitionAuthorityRef",
        "issuedBy",
        "accountable",
        "state",
        "stewardships",
        "rules",
        "writeGrants"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "dimension": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "scope": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "predicate": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "change": {
          "enum": [
            "genesis",
            "correction",
            "closure",
            "retraction"
          ]
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "previousDigest": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          ]
        },
        "recordedAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validFrom": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "governs": {
          "const": "values"
        },
        "definitionAuthorityRef": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "issuedBy": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "accountable": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "state": {
          "enum": [
            "active",
            "retracted"
          ]
        },
        "stewardships": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/stewardship"
          },
          "minItems": 0,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "rules": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/rule"
          },
          "minItems": 0,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "writeGrants": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/writeGrant"
          },
          "minItems": 0,
          "maxItems": 10000,
          "uniqueItems": true
        }
      }
    },
    "value": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "datatype",
        "lexical"
      ],
      "properties": {
        "datatype": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "lexical": {
          "type": "string",
          "maxLength": 10000
        }
      }
    },
    "observation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "dimension",
        "scope",
        "predicate",
        "change",
        "revision",
        "previousDigest",
        "recordedAt",
        "validFrom",
        "validUntil",
        "evidence",
        "subject",
        "source",
        "writer",
        "state",
        "value"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "dimension": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "scope": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "predicate": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "change": {
          "enum": [
            "genesis",
            "correction",
            "closure",
            "retraction"
          ]
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "previousDigest": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          ]
        },
        "recordedAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validFrom": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "subject": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "source": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "writer": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "state": {
          "enum": [
            "asserted",
            "retracted"
          ]
        },
        "value": {
          "$ref": "#/$defs/value"
        }
      }
    },
    "config": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "dimension",
        "validFrom",
        "validUntil",
        "governors",
        "readers",
        "purposes"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "dimension": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "validFrom": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "governors": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "actor",
              "scope",
              "predicate"
            ],
            "properties": {
              "actor": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              },
              "scope": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              },
              "predicate": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              }
            }
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "readers": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "purposes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1,
          "maxItems": 10000,
          "uniqueItems": true
        }
      }
    },
    "ledger": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "format",
        "version",
        "dimension",
        "authorities",
        "observations"
      ],
      "properties": {
        "format": {
          "const": "vercy-fact-authority"
        },
        "version": {
          "const": "0.1.0"
        },
        "dimension": {
          "type": "string",
          "format": "uri",
          "maxLength": 500
        },
        "authorities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/authority"
          },
          "minItems": 0,
          "maxItems": 10000,
          "uniqueItems": true
        },
        "observations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/observation"
          },
          "minItems": 0,
          "maxItems": 10000,
          "uniqueItems": true
        }
      }
    }
  }
}
