{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://slopsift.dev/schemas/slopsift-result-v1.schema.json",
  "title": "SlopSift JSON output",
  "description": "Version 1 schema for the array emitted by slopsift --format json. Each JSON Lines record follows $defs.fileResult.",
  "type": "array",
  "items": {
    "$ref": "#/$defs/fileResult"
  },
  "$defs": {
    "fileResult": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "filePath",
        "rulesetVersion",
        "messages",
        "errorCount",
        "warningCount",
        "infoCount",
        "wordCount",
        "findingsPerThousandWords"
      ],
      "properties": {
        "filePath": {
          "type": "string"
        },
        "rulesetVersion": {
          "type": "string",
          "pattern": "^slopsift@[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$"
        },
        "messages": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/message"
          }
        },
        "errorCount": {
          "type": "integer",
          "minimum": 0
        },
        "warningCount": {
          "type": "integer",
          "minimum": 0
        },
        "infoCount": {
          "type": "integer",
          "minimum": 0
        },
        "wordCount": {
          "type": "integer",
          "minimum": 0
        },
        "findingsPerThousandWords": {
          "type": "number",
          "minimum": 0
        }
      }
    },
    "message": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "ruleId",
        "ruleUrl",
        "category",
        "severity",
        "level",
        "confidence",
        "start",
        "end",
        "text",
        "message",
        "line",
        "column",
        "endLine",
        "endColumn"
      ],
      "properties": {
        "ruleId": {
          "type": "string",
          "pattern": "^[a-z0-9-]+/[a-z0-9-]+$"
        },
        "ruleUrl": {
          "type": "string",
          "format": "uri"
        },
        "category": {
          "type": "string"
        },
        "severity": {
          "type": "integer",
          "minimum": 0,
          "maximum": 2
        },
        "level": {
          "enum": [
            "info",
            "warn",
            "error"
          ]
        },
        "confidence": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "start": {
          "type": "integer",
          "minimum": 0
        },
        "end": {
          "type": "integer",
          "minimum": 0
        },
        "text": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "line": {
          "type": "integer",
          "minimum": 1
        },
        "column": {
          "type": "integer",
          "minimum": 1
        },
        "endLine": {
          "type": "integer",
          "minimum": 1
        },
        "endColumn": {
          "type": "integer",
          "minimum": 1
        },
        "suggestion": {
          "type": "string"
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/evidence"
          }
        },
        "anchors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/anchor"
          }
        },
        "magnitude": {
          "$ref": "#/$defs/magnitude"
        },
        "fix": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "range",
            "text"
          ],
          "properties": {
            "range": {
              "type": "array",
              "prefixItems": [
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "integer",
                  "minimum": 0
                }
              ],
              "minItems": 2,
              "maxItems": 2
            },
            "text": {
              "type": "string"
            }
          }
        }
      }
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind"
      ],
      "properties": {
        "kind": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "span": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "start",
            "end"
          ],
          "properties": {
            "start": {
              "type": "integer",
              "minimum": 0
            },
            "end": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "data": {
          "type": "object",
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean",
              "null"
            ]
          }
        }
      }
    },
    "anchor": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "offset"
      ],
      "properties": {
        "kind": {
          "type": "string"
        },
        "offset": {
          "type": "integer",
          "minimum": 0
        },
        "label": {
          "type": "string"
        }
      }
    },
    "magnitude": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "metrics"
      ],
      "properties": {
        "metrics": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/magnitudeMetric"
          }
        }
      }
    },
    "magnitudeMetric": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "value",
        "unit"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "value": {
          "type": "number",
          "minimum": 0
        },
        "unit": {
          "type": "string"
        },
        "threshold": {
          "type": "number",
          "minimum": 0
        },
        "excess": {
          "type": "number",
          "minimum": 0
        }
      }
    }
  }
}
