{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Issue Registry Schema",
  "description": "Global registry of all issues and their solutions",
  "type": "object",
  "properties": {
    "issues": {
      "type": "array",
      "description": "List of registered issues",
      "items": {
        "type": "object",
        "required": ["id", "title", "status", "created_at"],
        "properties": {
          "id": {
            "type": "string",
            "description": "Issue ID (e.g., GH-123, TEXT-xxx)"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["registered", "planning", "planned", "queued", "executing", "completed", "failed", "paused"],
            "default": "registered"
          },
          "priority": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "default": 3
          },
          "solution_count": {
            "type": "integer",
            "default": 0,
            "description": "Number of candidate solutions"
          },
          "bound_solution_id": {
            "type": "string",
            "description": "ID of the bound solution (null if none bound)"
          },
          "source": {
            "type": "string",
            "enum": ["github", "text", "file"],
            "description": "Source of the issue"
          },
          "source_url": {
            "type": "string",
            "description": "Original source URL (for GitHub issues)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "planned_at": {
            "type": "string",
            "format": "date-time"
          },
          "queued_at": {
            "type": "string",
            "format": "date-time"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "_metadata": {
      "type": "object",
      "properties": {
        "version": { "type": "string", "default": "1.0" },
        "total_issues": { "type": "integer" },
        "by_status": {
          "type": "object",
          "properties": {
            "registered": { "type": "integer" },
            "planning": { "type": "integer" },
            "planned": { "type": "integer" },
            "queued": { "type": "integer" },
            "executing": { "type": "integer" },
            "completed": { "type": "integer" },
            "failed": { "type": "integer" }
          }
        },
        "last_updated": { "type": "string", "format": "date-time" }
      }
    }
  }
}
