{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["name", "phases"],
  "properties": {
    "name": {
      "type": "string",
      "description": "Name of the workflow"
    },
    "description": {
      "type": "string",
      "description": "Description of the workflow"
    },
    "outputPath": {
      "type": "string",
      "description": "Base path for workflow outputs"
    },
    "context": {
      "type": "object",
      "description": "Global context variables for the workflow",
      "additionalProperties": true
    },
    "phases": {
      "type": "array",
      "description": "Ordered list of phases to execute",
      "items": {
        "$ref": "#/definitions/phaseReference"
      }
    }
  },
  "definitions": {
    "phaseReference": {
      "type": "object",
      "required": ["usePhase"],
      "properties": {
        "usePhase": {
          "type": "string",
          "description": "Name of the phase to use"
        },
        "description": {
          "type": "string",
          "description": "Description of this phase instance"
        },
        "dependsOn": {
          "type": "array",
          "description": "List of phase names this phase depends on",
          "items": {
            "type": "string"
          }
        },
        "variables": {
          "type": "object",
          "description": "Variables to pass to the phase",
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\$phase\\.[^.]+\\.output\\['[^']+'\\]$",
                "description": "Reference to a phase output file"
              },
              {
                "type": ["string", "number", "boolean", "object", "array", "null"]
              }
            ]
          }
        },
        "iterations": {
          "type": "object",
          "description": "Configuration for iterative execution",
          "required": ["maxIterations"],
          "properties": {
            "maxIterations": {
              "type": "number",
              "description": "Maximum number of iterations",
              "minimum": 1
            },
            "convergenceTest": {
              "type": "string",
              "description": "Name of the convergence test to use"
            }
          }
        }
      }
    }
  }
} 