{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aiox.dev/schemas/service-registry.json",
  "title": "AIOX Service Registry Schema",
  "description": "Schema for the AIOX service registry containing workers, tasks, templates, and scripts",
  "type": "object",
  "required": ["version", "generated", "totalWorkers", "categories", "workers"],
  "properties": {
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "Semantic version of the registry"
    },
    "generated": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp when registry was generated"
    },
    "totalWorkers": {
      "type": "integer",
      "minimum": 97,
      "description": "Total count of workers in registry"
    },
    "categories": {
      "type": "object",
      "description": "Category summary with counts and subcategories",
      "additionalProperties": {
        "type": "object",
        "required": ["count"],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0,
            "description": "Number of workers in this category"
          },
          "subcategories": {
            "type": "array",
            "items": { "type": "string" },
            "description": "List of subcategories within this category"
          },
          "description": {
            "type": "string",
            "description": "Human-readable description of the category"
          }
        }
      }
    },
    "workers": {
      "type": "array",
      "minItems": 97,
      "items": { "$ref": "#/definitions/worker" },
      "description": "Array of all registered workers"
    }
  },
  "definitions": {
    "worker": {
      "type": "object",
      "required": ["id", "name", "description", "category", "path", "taskFormat"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$",
          "description": "Unique kebab-case identifier"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "description": "Human-readable display name"
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "description": "Brief description of worker purpose"
        },
        "category": {
          "type": "string",
          "enum": ["task", "template", "script", "checklist", "workflow", "data", "util"],
          "description": "Primary category of the worker"
        },
        "subcategory": {
          "type": "string",
          "description": "Subcategory for finer classification"
        },
        "inputs": {
          "type": "array",
          "items": { "type": "string" },
          "description": "List of input parameters with types"
        },
        "outputs": {
          "type": "array",
          "items": { "type": "string" },
          "description": "List of output parameters with types"
        },
        "tags": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Searchable tags for discovery"
        },
        "path": {
          "type": "string",
          "pattern": "^\\.aiox-core/",
          "description": "Relative path from project root"
        },
        "taskFormat": {
          "type": "string",
          "enum": ["TASK-FORMAT-V1", "TASK-FORMAT-V2", "SCRIPT", "TEMPLATE", "CHECKLIST", "WORKFLOW"],
          "description": "Format specification the worker follows"
        },
        "executorTypes": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["Worker", "Agent", "Script", "Task", "CLI", "API"]
          },
          "description": "Types of executors that can run this worker"
        },
        "performance": {
          "type": "object",
          "properties": {
            "avgDuration": {
              "type": "string",
              "pattern": "^\\d+(\\.\\d+)?(ms|s|m)$",
              "description": "Average execution duration"
            },
            "cacheable": {
              "type": "boolean",
              "description": "Whether results can be cached"
            },
            "parallelizable": {
              "type": "boolean",
              "description": "Whether worker can run in parallel"
            }
          }
        },
        "dependencies": {
          "type": "array",
          "items": { "type": "string" },
          "description": "IDs of other workers this depends on"
        },
        "agents": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Agent IDs that primarily use this worker"
        },
        "metadata": {
          "type": "object",
          "properties": {
            "source": {
              "type": "string",
              "description": "Module this worker originated from"
            },
            "addedVersion": {
              "type": "string",
              "description": "Version when worker was added"
            },
            "lastModified": {
              "type": "string",
              "format": "date-time",
              "description": "Last modification timestamp"
            }
          }
        }
      }
    }
  }
}
