{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://github.com/kesslerio/vibe-check-mcp/data/pattern_schema.json",
  "title": "Anti-Pattern Definition Schema",
  "description": "JSON schema for anti-pattern definitions used by the Vibe Check MCP detection system",
  "type": "object",
  "required": ["schema_version", "data_version"],
  "properties": {
    "schema_version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "Semantic version of the JSON schema (affects validation logic)"
    },
    "data_version": {
      "type": "string", 
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "Semantic version of the pattern data (affects detection behavior)"
    }
  },
  "patternProperties": {
    "^[a-z][a-z0-9_]*[a-z0-9]$": {
      "type": "object",
      "description": "An anti-pattern definition",
      "required": ["id", "name", "description", "detection_threshold", "indicators"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*[a-z0-9]$",
          "description": "Unique identifier for the pattern (snake_case, matches property key)"
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$",
          "default": "1.0.0",
          "description": "Semantic version of this specific pattern definition"
        },
        "name": {
          "type": "string",
          "minLength": 3,
          "maxLength": 100,
          "description": "Human-readable name for the pattern (Title Case)"
        },
        "description": {
          "type": "string",
          "minLength": 10,
          "maxLength": 500,
          "description": "Clear description of what the anti-pattern represents"
        },
        "severity": {
          "type": "string",
          "enum": ["low", "medium", "high", "critical"],
          "default": "medium",
          "description": "Impact severity level of this anti-pattern"
        },
        "category": {
          "type": "string",
          "enum": ["architectural", "process", "design", "security", "performance"],
          "default": "process",
          "description": "Category classification for the anti-pattern"
        },
        "detection_threshold": {
          "type": "number",
          "minimum": 0.1,
          "maximum": 1.0,
          "description": "Minimum confidence score (0.1-1.0) required to trigger detection"
        },
        "indicators": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "description": "Positive indicators that suggest the presence of this anti-pattern",
          "items": {
            "$ref": "#/definitions/indicator"
          }
        },
        "negative_indicators": {
          "type": "array",
          "maxItems": 10,
          "description": "Negative indicators that reduce confidence in pattern detection",
          "items": {
            "$ref": "#/definitions/negative_indicator"
          }
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "definitions": {
    "indicator": {
      "type": "object",
      "required": ["regex", "description", "weight", "text"],
      "properties": {
        "regex": {
          "type": "string",
          "minLength": 3,
          "description": "Regular expression pattern to match in text (case-insensitive matching)"
        },
        "description": {
          "type": "string",
          "minLength": 5,
          "maxLength": 200,
          "description": "Human-readable description of what this indicator detects"
        },
        "weight": {
          "type": "number",
          "minimum": 0.1,
          "maximum": 0.5,
          "description": "Confidence contribution (0.1-0.5) when this indicator matches"
        },
        "text": {
          "type": "string",
          "minLength": 2,
          "maxLength": 50,
          "description": "Short label for this indicator type"
        }
      },
      "additionalProperties": false
    },
    "negative_indicator": {
      "type": "object",
      "required": ["regex", "description", "weight"],
      "properties": {
        "regex": {
          "type": "string",
          "minLength": 3,
          "description": "Regular expression pattern to match in text (case-insensitive matching)"
        },
        "description": {
          "type": "string",
          "minLength": 5,
          "maxLength": 200,
          "description": "Human-readable description of what this negative indicator detects"
        },
        "weight": {
          "type": "number",
          "minimum": -0.5,
          "maximum": -0.1,
          "description": "Negative confidence contribution (-0.5 to -0.1) when this indicator matches"
        }
      },
      "additionalProperties": false
    }
  }
}