{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://dss.overbits.luz.uy/schemas/workflows.schema.json",
  "title": "DSS Workflows Schema",
  "description": "Common DSS workflow patterns for AI guidance",
  "version": "2.0.0",
  "x-immutable-notice": {
    "protected": true,
    "reason": "Workflow definitions - ensures consistent AI-guided operations",
    "lastModified": "2025-12-09",
    "bypassMethod": "Use 'DSS_IMMUTABLE_BYPASS=1 git commit' or commit message '[IMMUTABLE-UPDATE] reason'"
  },
  "type": "object",
  "properties": {
    "workflows": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/workflow"
      }
    }
  },
  "definitions": {
    "workflow": {
      "type": "object",
      "required": ["name", "description", "steps"],
      "properties": {
        "name": {
          "type": "string",
          "description": "Workflow identifier"
        },
        "description": {
          "type": "string",
          "description": "What this workflow accomplishes"
        },
        "category": {
          "type": "string",
          "enum": ["setup", "token-management", "component-analysis", "theme-generation", "integration"],
          "description": "Workflow category"
        },
        "steps": {
          "type": "array",
          "description": "Ordered workflow steps",
          "items": {
            "type": "object",
            "required": ["tool", "description"],
            "properties": {
              "step": {
                "type": "integer",
                "description": "Step number"
              },
              "tool": {
                "type": "string",
                "description": "DSS tool to use"
              },
              "description": {
                "type": "string",
                "description": "What this step does"
              },
              "parameters": {
                "type": "object",
                "description": "Typical parameters for this step"
              },
              "optional": {
                "type": "boolean",
                "default": false,
                "description": "Whether this step can be skipped"
              },
              "conditions": {
                "type": "array",
                "description": "Conditions for executing this step",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "prerequisites": {
          "type": "array",
          "description": "Requirements before starting workflow",
          "items": {
            "type": "string"
          }
        },
        "expectedOutcome": {
          "type": "string",
          "description": "What success looks like"
        },
        "commonErrors": {
          "type": "array",
          "description": "Common failure scenarios and solutions",
          "items": {
            "type": "object",
            "properties": {
              "error": {"type": "string"},
              "solution": {"type": "string"}
            }
          }
        }
      }
    }
  }
}
