{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://intelligentliving.art/schemas/resolution/v1.json",
  "title": "Living Art Resolution v1",
  "type": "object",
  "required": [
    "type",
    "version",
    "resolvedAt",
    "reference",
    "name",
    "discovery",
    "authority",
    "identity",
    "resources"
  ],
  "properties": {
    "type": {
      "const": "https://intelligentliving.art/protocols/resolution/v1.json"
    },
    "version": {
      "const": "1.0.0"
    },
    "resolvedAt": {
      "type": "string",
      "format": "date-time"
    },
    "reference": {
      "type": "string",
      "minLength": 1
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "identityKind": {
      "enum": [
        "physical-artwork",
        "historical-interpretation",
        "digital-artwork",
        "installation",
        "other"
      ]
    },
    "disclosure": {
      "type": "string"
    },
    "discovery": {
      "type": "object",
      "required": [
        "method"
      ],
      "properties": {
        "method": {
          "enum": [
            "prototype-catalog",
            "direct-manifest",
            "erc-8004-registration",
            "artwork-nft"
          ]
        },
        "prototype": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "erc8004": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "authority": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "minLength": 1
        },
        "reason": {
          "type": "string"
        },
        "creator": {
          "type": "string"
        },
        "owner": {
          "type": "string"
        },
        "identityHash": {
          "$ref": "#/$defs/hash"
        },
        "operationalManifestHash": {
          "$ref": "#/$defs/hash"
        }
      },
      "additionalProperties": true
    },
    "identity": {
      "type": "object",
      "required": [
        "status",
        "version",
        "lifecycle"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "version": {
          "type": "integer",
          "minimum": 1
        },
        "lifecycle": {
          "enum": [
            "active",
            "superseded",
            "withdrawn"
          ]
        },
        "controller": {
          "type": "string"
        },
        "operationalController": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "resources": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/resource"
      }
    },
    "interaction": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "required": [
            "protocol",
            "endpoint",
            "canonical",
            "grounding",
            "memory",
            "speech"
          ],
          "properties": {
            "protocol": {
              "const": "living-art-conversation/1.0"
            },
            "endpoint": {
              "type": "string"
            },
            "canonical": {
              "type": "boolean"
            },
            "grounding": {
              "type": "string"
            },
            "memory": {
              "type": "string"
            },
            "speech": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "image": {
              "type": "string"
            }
          },
          "additionalProperties": false
        }
      ]
    }
  },
  "$defs": {
    "hash": {
      "type": "string",
      "pattern": "^[a-fA-F0-9]{64}$"
    },
    "resource": {
      "type": "object",
      "required": [
        "uri",
        "status"
      ],
      "properties": {
        "uri": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "enum": [
            "declared",
            "available",
            "unavailable",
            "invalid"
          ]
        },
        "hashStatus": {
          "enum": [
            "verified",
            "mismatch",
            "not-declared"
          ]
        },
        "expectedHash": {
          "$ref": "#/$defs/hash"
        },
        "actualHash": {
          "$ref": "#/$defs/hash"
        },
        "error": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
