{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Eskasia/agent-governance-starter/schemas/role-catalog.schema.json",
  "title": "Agent Governance Role Catalog",
  "description": "Neutral role metadata used for deterministic responsibility selection, never as an authority grant.",
  "type": "object",
  "required": [
    "schemaVersion",
    "catalogId",
    "catalogType",
    "source",
    "roles"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "catalogId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^(?:CAT-[A-Z0-9-]+|[a-z][a-z0-9-]*)$"
    },
    "catalogType": {
      "type": "string",
      "enum": [
        "governance-responsibility",
        "specialist"
      ]
    },
    "source": {
      "$ref": "#/$defs/source"
    },
    "roles": {
      "type": "array",
      "maxItems": 512,
      "items": {
        "$ref": "#/$defs/role"
      }
    }
  },
  "$defs": {
    "stringArray": {
      "type": "array",
      "maxItems": 256,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 256
      }
    },
    "source": {
      "type": "object",
      "required": [
        "sourceId",
        "repository",
        "revision",
        "license",
        "importedMode",
        "sha256"
      ],
      "properties": {
        "sourceId": {
          "type": "string",
          "pattern": "^SRC-[A-Z0-9-]+$"
        },
        "repository": {
          "type": "string",
          "minLength": 9,
          "maxLength": 2048,
          "pattern": "^https://"
        },
        "revision": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "license": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "importedMode": {
          "type": "string",
          "enum": [
            "metadata",
            "adapted",
            "copied"
          ]
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "additionalProperties": false
    },
    "role": {
      "type": "object",
      "required": [
        "roleId",
        "division",
        "title",
        "supportedResponsibilities",
        "supportedSurfaces",
        "requestedCapabilities"
      ],
      "properties": {
        "roleId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._/-]*$"
        },
        "roleType": {
          "type": "string",
          "enum": [
            "governance-responsibility",
            "specialist"
          ]
        },
        "division": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "sourceCatalog": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "supportedResponsibilities": {
          "$ref": "#/$defs/stringArray"
        },
        "supportedSurfaces": {
          "$ref": "#/$defs/stringArray"
        },
        "requestedCapabilities": {
          "$ref": "#/$defs/stringArray"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
