{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Issue Solution Schema",
  "description": "Schema for solution registered to an issue",
  "type": "object",
  "required": ["id", "issue_id", "tasks", "status", "created_at"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique solution identifier",
      "pattern": "^SOL-[0-9]+$"
    },
    "issue_id": {
      "type": "string",
      "description": "Parent issue ID"
    },
    "plan_session_id": {
      "type": "string",
      "description": "Planning session that created this solution"
    },
    "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"
          },
          "executor": {
            "type": "string",
            "enum": ["codex", "gemini", "agent", "auto"],
            "default": "auto"
          },
          "lifecycle_status": {
            "type": "object",
            "description": "Lifecycle phase tracking",
            "properties": {
              "implemented": { "type": "boolean" },
              "tested": { "type": "boolean" },
              "regression_passed": { "type": "boolean" },
              "accepted": { "type": "boolean" },
              "committed": { "type": "boolean" }
            }
          },
          "status": {
            "type": "string",
            "enum": ["pending", "ready", "executing", "completed", "failed", "blocked"],
            "default": "pending"
          },
          "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)"
    },
    "status": {
      "type": "string",
      "enum": ["draft", "candidate", "bound", "queued", "executing", "completed", "failed"],
      "default": "draft"
    },
    "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"
    }
  }
}
