{
  "name": "validate_expanso_pipeline",
  "description": "Validate Benthos/Expanso pipeline YAML configurations against ground truth schema. Detects hallucinations including imagined components, wrong structure, invalid Bloblang syntax, and imagined fields. Returns detailed errors with severity levels and suggested corrections.",
  "version": "1.0.0",
  "inputSchema": {
    "type": "object",
    "properties": {
      "yaml": {
        "type": "string",
        "description": "The pipeline YAML configuration to validate"
      },
      "format": {
        "type": "boolean",
        "description": "Return formatted YAML in response",
        "default": false
      },
      "auto_correct": {
        "type": "boolean",
        "description": "Attempt to auto-correct common hallucinations",
        "default": false
      }
    },
    "required": [
      "yaml"
    ]
  },
  "outputSchema": {
    "type": "object",
    "properties": {
      "valid": {
        "type": "boolean",
        "description": "True if no ERROR-severity hallucinations were found"
      },
      "error_count": {
        "type": "integer",
        "description": "Number of ERROR-severity hallucinations"
      },
      "hallucinations": {
        "type": "array",
        "description": "List of detected hallucinations with category, severity, path, and suggested corrections",
        "items": {
          "type": "object",
          "properties": {
            "category": {
              "type": "string",
              "enum": [
                "IMAGINED_COMPONENT",
                "IMAGINED_FIELD",
                "IMAGINED_STRUCTURE",
                "IMAGINED_SYNTAX",
                "WRONG_TYPE",
                "DUPLICATE_LABEL",
                "UNDEFINED_RESOURCE",
                "POTENTIAL_LOOP",
                "UNREACHABLE_CODE",
                "UNKNOWN"
              ]
            },
            "severity": {
              "type": "string",
              "enum": [
                "ERROR",
                "WARNING",
                "INFO"
              ]
            },
            "path": {
              "type": "string",
              "description": "JSON path to the problematic element"
            },
            "hallucination": {
              "type": "string",
              "description": "The hallucinated/incorrect value"
            },
            "correction": {
              "type": "string",
              "nullable": true,
              "description": "Suggested correction"
            },
            "message": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "line": {
              "type": "integer",
              "nullable": true,
              "description": "Line number in YAML where issue occurs"
            },
            "context": {
              "type": "string",
              "nullable": true,
              "description": "Surrounding code context with line numbers"
            },
            "snippet_before": {
              "type": "string",
              "nullable": true,
              "description": "Code snippet before correction (for visual diff)"
            },
            "snippet_after": {
              "type": "string",
              "nullable": true,
              "description": "Code snippet after applying correction (for visual diff)"
            }
          }
        }
      },
      "corrected_yaml": {
        "type": "string",
        "description": "Auto-corrected YAML (if auto_correct=true)"
      }
    },
    "required": [
      "valid",
      "error_count",
      "hallucinations"
    ]
  },
  "hallucinationTaxonomy": {
    "categories": {
      "IMAGINED_COMPONENT": "Component name does not exist (e.g., kafak instead of kafka)",
      "IMAGINED_FIELD": "Field does not exist on the component (e.g., brokrs instead of brokers)",
      "IMAGINED_STRUCTURE": "Wrong configuration structure (e.g., Kubernetes wrappers, wrong nesting)",
      "IMAGINED_SYNTAX": "Invalid Bloblang syntax (e.g., JavaScript/Python patterns)",
      "WRONG_TYPE": "Incorrect value type for field",
      "DUPLICATE_LABEL": "Duplicate processor label within pipeline",
      "UNDEFINED_RESOURCE": "Reference to undefined resource (cache, rate_limit, etc.)",
      "POTENTIAL_LOOP": "Same resource for input and output (e.g., same Kafka topic, S3 bucket)",
      "UNKNOWN": "Unclassified validation error"
    },
    "severities": {
      "ERROR": "Critical issue that will cause pipeline failure",
      "WARNING": "Potential issue or deprecated usage",
      "INFO": "Informational suggestion for improvement"
    }
  },
  "endpoints": {
    "validate": {
      "method": "POST",
      "path": "/validate",
      "description": "Validate pipeline YAML"
    },
    "schema": {
      "method": "GET",
      "path": "/schema",
      "description": "Get component schema (ground truth)"
    },
    "openapi": {
      "method": "GET",
      "path": "/openapi.json",
      "description": "OpenAPI 3.1 specification"
    }
  }
}