{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["name"],
  "properties": {
    "name": {
      "type": "string",
      "description": "Name of the phase"
    },
    "description": {
      "type": "string",
      "description": "Description of the phase"
    },
    "execution": {
      "type": "string",
      "enum": ["sequential", "parallel"],
      "description": "Mode of execution for this phase"
    },
    "outputs": {
      "type": "object",
      "description": "DEPRECATED: Use requiredInput and requiredOutput instead. Output file declarations.",
      "properties": {
        "provides": {
          "type": "array",
          "description": "DEPRECATED: Use requiredOutput instead. List of output files this phase provides",
          "items": {
            "type": "string"
          }
        },
        "requires": {
          "type": "array",
          "description": "DEPRECATED: Use requiredInput instead. List of output files this phase requires from other phases",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "requiredInput": {
      "type": "array",
      "description": "List of context variables required as input for this phase",
      "items": {
        "type": "string"
      }
    },
    "requiredOutput": {
      "type": "array",
      "description": "List of context variables this phase must produce as output",
      "items": {
        "type": "string"
      }
    },
    "tasks": {
      "type": "array",
      "description": "List of tasks to execute",
      "items": {
        "$ref": "#/definitions/taskReference"
      }
    },
    "set": {
      "type": "array",
      "description": "List of sets to execute",
      "items": {
        "$ref": "#/definitions/setReference"
      }
    },
    "variables": {
      "type": "object",
      "description": "Default variables for the phase",
      "additionalProperties": true
    },
    "humanInputRequired": {
      "type": "array",
      "description": "List of files requiring human review before this phase can start",
      "items": {
        "type": "string"
      }
    },
    "dependsOn": {
      "type": "array",
      "description": "List of phases this phase depends on",
      "items": {
        "type": "string"
      }
    }
  },
  "definitions": {
    "taskReference": {
      "type": "object",
      "required": ["useTask"],
      "properties": {
        "useTask": {
          "type": "string",
          "description": "Name of the task to use"
        },
        "description": {
          "type": "string",
          "description": "Description of this task instance"
        },
        "variables": {
          "type": "object",
          "description": "Variables to pass to the task",
          "additionalProperties": true
        }
      }
    },
    "setReference": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string",
          "description": "Description of this set"
        },
        "useSet": {
          "type": "string",
          "description": "Name of the set template to use"
        },
        "execution": {
          "type": "string",
          "enum": ["sequential", "parallel"],
          "description": "Mode of execution for this set"
        },
        "itemForEach": {
          "type": "string",
          "description": "Context variable to iterate over"
        },
        "variables": {
          "type": "object",
          "description": "Variables to pass to the set",
          "additionalProperties": true
        },
        "requiredInput": {
          "type": "array",
          "description": "List of context variables required as input for this set",
          "items": {
            "type": "string"
          }
        },
        "requiredOutput": {
          "type": "array",
          "description": "List of context variables this set must produce as output",
          "items": {
            "type": "string"
          }
        },
        "set": {
          "type": "array",
          "description": "Nested sets to execute",
          "items": {
            "$ref": "#/definitions/setReference"
          }
        },
        "tasks": {
          "type": "array",
          "description": "Tasks to execute in this set",
          "items": {
            "$ref": "#/definitions/taskReference"
          }
        }
      }
    }
  }
} 