{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://relgap.sasskovacs.dev/schemas/drift-v1.json",
  "title": "relgap drift --format json",
  "description": "The report-v1.json envelope with drift data: every resolved pin of the scanned repositories, grouped by tool, with the distinct versions they stand for.",
  "allOf": [{ "$ref": "report-v1.json" }],
  "properties": {
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repos", "tools"],
      "properties": {
        "repos": {
          "description": "Scanned repository directories, slash-separated.",
          "type": "array",
          "items": { "type": "string", "minLength": 1 }
        },
        "tools": {
          "description": "One entry per tool, sorted by tool.",
          "type": "array",
          "items": { "$ref": "#/$defs/tool" }
        }
      }
    }
  },
  "$defs": {
    "tool": {
      "type": "object",
      "additionalProperties": false,
      "required": ["tool", "drift", "versions", "pins"],
      "properties": {
        "tool": { "description": "The tool, as relgap digest accepts it.", "type": "string", "minLength": 1 },
        "drift": { "description": "The pins stand for more than one version.", "type": "boolean" },
        "reference": {
          "description": "The version the most repositories pin, the newest on a tie. Absent when no pin is compared.",
          "type": "string",
          "minLength": 1
        },
        "latest": { "description": "With --latest: the newest stable version.", "type": "string", "minLength": 1 },
        "note": { "description": "With --latest: why latest is missing.", "type": "string", "minLength": 1 },
        "versions": {
          "description": "Distinct versions the compared pins stand for, oldest first.",
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["version", "repos"],
            "properties": {
              "version": { "type": "string", "minLength": 1 },
              "repos": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } }
            }
          }
        },
        "pins": {
          "description": "Every pin of the tool, sorted by repo, file and line.",
          "type": "array",
          "items": { "$ref": "#/$defs/pin" }
        }
      }
    },
    "pin": {
      "type": "object",
      "additionalProperties": false,
      "required": ["location", "value", "match"],
      "properties": {
        "location": { "$ref": "pins-v1.json#/$defs/pin/properties/location" },
        "value": { "description": "The value as written.", "type": "string", "minLength": 1 },
        "match": { "$ref": "pins-v1.json#/$defs/pin/properties/match" },
        "version": {
          "description": "The version the pin counts as. Absent for prefix and channel pins, and for constraint pins with --drift-ignore-constraints or without a lower bound.",
          "type": "string",
          "minLength": 1
        },
        "via": {
          "description": "How a constraint pin became its version.",
          "enum": ["highest installed or locked version", "lower bound of the constraint"]
        }
      }
    }
  }
}
