{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://intelligentliving.art/schemas/identity/v1.json",
  "title": "Living Art Identity Manifest v1",
  "type": "object",
  "required": [
    "type",
    "version",
    "identityVersion",
    "lifecycle",
    "artwork",
    "authority",
    "resources",
    "revision"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "type": {
      "const": "https://intelligentliving.art/protocols/identity-manifest/v1.json"
    },
    "version": {
      "const": "1.0.0"
    },
    "identityVersion": {
      "type": "integer",
      "minimum": 1
    },
    "lifecycle": {
      "enum": [
        "active",
        "superseded",
        "withdrawn"
      ]
    },
    "artwork": {
      "type": "object",
      "required": [
        "name",
        "physicalPrimary",
        "token"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "physicalPrimary": {
          "const": true
        },
        "token": {
          "type": "string",
          "minLength": 1
        },
        "creator": {
          "type": "string"
        },
        "interpretationDisclosure": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "authority": {
      "type": "object",
      "required": [
        "identityController",
        "operationalController",
        "policy"
      ],
      "properties": {
        "identityController": {
          "const": "confirmed-creator"
        },
        "operationalController": {
          "const": "current-token-owner"
        },
        "policy": {
          "const": "creator-identity-owner-operations"
        }
      },
      "additionalProperties": false
    },
    "resources": {
      "type": "object",
      "required": [
        "canon",
        "sources",
        "inventory",
        "interaction",
        "replication"
      ],
      "properties": {
        "canon": {
          "$ref": "#/$defs/resource"
        },
        "sources": {
          "$ref": "#/$defs/resource"
        },
        "inventory": {
          "$ref": "#/$defs/resource"
        },
        "interaction": {
          "$ref": "#/$defs/resource"
        },
        "replication": {
          "$ref": "#/$defs/resource"
        }
      },
      "additionalProperties": false
    },
    "revision": {
      "type": "object",
      "required": [
        "issuedAt",
        "reason",
        "previous"
      ],
      "properties": {
        "issuedAt": {
          "type": "string",
          "format": "date-time"
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "previous": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "object",
              "required": [
                "uri",
                "sha256"
              ],
              "properties": {
                "uri": {
                  "type": "string",
                  "minLength": 1
                },
                "sha256": {
                  "$ref": "#/$defs/hash"
                }
              },
              "additionalProperties": false
            }
          ]
        }
      },
      "additionalProperties": false
    }
  },
  "$defs": {
    "hash": {
      "type": "string",
      "pattern": "^(0x)?[a-fA-F0-9]{64}$"
    },
    "resource": {
      "type": "object",
      "required": [
        "uri"
      ],
      "properties": {
        "uri": {
          "type": "string",
          "minLength": 1
        },
        "sha256": {
          "$ref": "#/$defs/hash"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
