{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Prompt Injection Scanner API Contract",
  "version": "1.0.0",
  "description": "Stable JSON contract for prompt injection scan results",
  "type": "object",
  "required": ["success", "analysis"],
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Whether the scan completed successfully"
    },
    "analysis": {
      "type": "object",
      "required": ["score", "severity", "categories", "advisories"],
      "properties": {
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 100,
          "description": "Risk score (0-100)"
        },
        "severity": {
          "type": "string",
          "enum": ["low", "medium", "high", "critical"],
          "description": "Overall severity classification"
        },
        "categories": {
          "type": "array",
          "description": "Categories of detected issues",
          "items": {
            "type": "string"
          }
        },
        "advisories": {
          "type": "array",
          "description": "Specific advisory items",
          "items": {
            "type": "object",
            "required": ["ruleId", "description", "severity", "rationale"],
            "properties": {
              "ruleId": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "severity": {
                "type": "string",
                "enum": ["low", "medium", "high", "critical"]
              },
              "rationale": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "inputHash": {
          "type": "string",
          "description": "HMAC hash of input (for correlation only)"
        },
        "inputLength": {
          "type": "number"
        },
        "rulesVersion": {
          "type": "string"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "error": {
      "type": "string",
      "description": "Error message if success is false"
    }
  }
}
