{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "task-v3-schema",
  "title": "AIOX Task V3 Schema",
  "description": "Schema for AIOX task definitions with Auto-Claude patterns",
  "type": "object",
  "required": ["name", "description", "steps"],
  "properties": {
    "name": {
      "type": "string",
      "description": "Task identifier (e.g., spec-gather-requirements)"
    },
    "description": {
      "type": "string",
      "description": "What this task does"
    },
    "version": {
      "type": "string",
      "default": "1.0"
    },
    "agent": {
      "type": "string",
      "description": "Primary agent that executes this task",
      "enum": ["pm", "architect", "analyst", "qa", "dev", "devops", "sm", "po"]
    },
    "elicit": {
      "type": "boolean",
      "default": false,
      "description": "Whether task requires user interaction"
    },
    "execution_mode": {
      "type": "string",
      "enum": ["direct", "programmatic"],
      "default": "direct",
      "description": "Execution mode: 'direct' (standard tool calls) or 'programmatic' (PTC/batch — consolidate N tool calls into single Bash block, per ADR-3 native tools only). Tasks without this field default to 'direct' (backward compatible)."
    },
    "inputs": {
      "type": "object",
      "description": "Required inputs for task execution",
      "properties": {
        "required": {
          "type": "array",
          "items": { "type": "string" }
        },
        "optional": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "outputs": {
      "type": "object",
      "description": "Expected outputs from task execution",
      "properties": {
        "files": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": { "type": "string" },
              "description": { "type": "string" }
            }
          }
        },
        "artifacts": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "steps": {
      "type": "array",
      "description": "Ordered steps to execute",
      "items": {
        "type": "object",
        "required": ["id", "action"],
        "properties": {
          "id": { "type": "string" },
          "action": { "type": "string" },
          "description": { "type": "string" },
          "condition": { "type": "string" },
          "elicit": { "type": "boolean" },
          "blocking": { "type": "boolean" }
        }
      }
    },
    "validation": {
      "type": "object",
      "description": "Validation rules for task completion",
      "properties": {
        "schema": { "type": "string" },
        "rules": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "autoClaude": {
      "type": "object",
      "description": "Auto-Claude V3 metadata",
      "properties": {
        "version": { "type": "string", "const": "3.0" },
        "pipeline": {
          "type": "string",
          "description": "Which pipeline this task belongs to",
          "enum": ["spec", "execution", "recovery", "qa", "worktree", "migration"]
        },
        "phase": {
          "type": "string",
          "description": "Phase within the pipeline"
        },
        "skipConditions": {
          "type": "array",
          "description": "Conditions under which task can be skipped",
          "items": { "type": "string" }
        },
        "retryable": {
          "type": "boolean",
          "default": true
        },
        "maxRetries": {
          "type": "integer",
          "default": 3
        }
      }
    },
    "dependencies": {
      "type": "object",
      "properties": {
        "tasks": {
          "type": "array",
          "description": "Tasks that must complete before this one",
          "items": { "type": "string" }
        },
        "artifacts": {
          "type": "array",
          "description": "Artifacts that must exist",
          "items": { "type": "string" }
        }
      }
    },
    "errorHandling": {
      "type": "object",
      "properties": {
        "onFailure": {
          "type": "string",
          "enum": ["halt", "retry", "skip", "escalate"]
        },
        "escalateTo": { "type": "string" },
        "rollbackSteps": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    }
  }
}
