{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Issue Solution Schema",
  "description": "Schema for solution registered to an issue",
  "type": "object",
  "required": ["id", "tasks", "is_bound", "created_at"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique solution identifier: SOL-{issue-id}-{4-char-uid} where uid is 4 alphanumeric chars",
      "pattern": "^SOL-.+-[a-z0-9]{4}$",
      "examples": ["SOL-GH-123-a7x9", "SOL-ISS-20251229-001-b2k4"]
    },
    "description": {
      "type": "string",
      "description": "High-level summary of the solution"
    },
    "approach": {
      "type": "string",
      "description": "Technical approach or strategy"
    },
    "tasks": {
      "type": "array",
      "description": "Task breakdown for this solution",
      "items": {
        "type": "object",
        "required": ["id", "title", "scope", "action", "implementation", "acceptance"],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^T[0-9]+$"
          },
          "title": {
            "type": "string",
            "description": "Action verb + target"
          },
          "scope": {
            "type": "string",
            "description": "Module path or feature area"
          },
          "action": {
            "type": "string",
            "enum": ["Create", "Update", "Implement", "Refactor", "Add", "Delete", "Configure", "Test", "Fix"]
          },
          "description": {
            "type": "string",
            "description": "1-2 sentences describing what to implement"
          },
          "modification_points": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "file": { "type": "string" },
                "target": { "type": "string" },
                "change": { "type": "string" }
              }
            }
          },
          "implementation": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Step-by-step implementation guide"
          },
          "test": {
            "type": "object",
            "description": "Test requirements",
            "properties": {
              "unit": { "type": "array", "items": { "type": "string" } },
              "integration": { "type": "array", "items": { "type": "string" } },
              "commands": { "type": "array", "items": { "type": "string" } },
              "coverage_target": { "type": "number" }
            }
          },
          "regression": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Regression check points"
          },
          "acceptance": {
            "type": "object",
            "description": "Acceptance criteria & verification",
            "required": ["criteria", "verification"],
            "properties": {
              "criteria": { "type": "array", "items": { "type": "string" } },
              "verification": { "type": "array", "items": { "type": "string" } },
              "manual_checks": { "type": "array", "items": { "type": "string" } }
            }
          },
          "commit": {
            "type": "object",
            "description": "Commit specification",
            "properties": {
              "type": { "type": "string", "enum": ["feat", "fix", "refactor", "test", "docs", "chore"] },
              "scope": { "type": "string" },
              "message_template": { "type": "string" },
              "breaking": { "type": "boolean" }
            }
          },
          "depends_on": {
            "type": "array",
            "items": { "type": "string" },
            "default": [],
            "description": "Task IDs this task depends on"
          },
          "estimated_minutes": {
            "type": "integer",
            "description": "Estimated time to complete"
          },
          "status": {
            "type": "string",
            "description": "Task status (optional, for tracking)"
          },
          "priority": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "default": 3
          }
        }
      }
    },
    "exploration_context": {
      "type": "object",
      "description": "ACE exploration results",
      "properties": {
        "project_structure": { "type": "string" },
        "relevant_files": {
          "type": "array",
          "items": { "type": "string" }
        },
        "patterns": { "type": "string" },
        "integration_points": { "type": "string" }
      }
    },
    "analysis": {
      "type": "object",
      "description": "Solution risk assessment",
      "properties": {
        "risk": { "type": "string", "enum": ["low", "medium", "high"] },
        "impact": { "type": "string", "enum": ["low", "medium", "high"] },
        "complexity": { "type": "string", "enum": ["low", "medium", "high"] }
      }
    },
    "score": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Solution quality score (0.0-1.0)"
    },
    "is_bound": {
      "type": "boolean",
      "default": false,
      "description": "Whether this solution is bound to the issue"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "bound_at": {
      "type": "string",
      "format": "date-time",
      "description": "When this solution was bound to the issue"
    }
  }
}
