{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/pr-reach.schema.json",
  "title": "Pull request reach",
  "description": "What GET /v1/prs/reach returns (`work-items.mjs reach`): for each open GitHub pull request (at most 20), how many files in the repository's own code graph depend on what it changes, widest first. Changed paths serve only as keys into the local graph and are never returned. A pull request that cannot be measured carries reach null and its reason.",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "depth", "items"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "depth": {
      "type": "integer",
      "minimum": 1,
      "description": "Reverse-dependency depth the count was taken at."
    },
    "items": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["source", "repo", "number", "project", "reach"],
        "properties": {
          "source": { "enum": ["github", "bitbucket"] },
          "repo": { "type": "string" },
          "number": { "type": "integer" },
          "project": {
            "type": ["string", "null"],
            "description": "The knowledge-folder project whose graph answered, or null."
          },
          "changed": {
            "type": "integer",
            "minimum": 0,
            "description": "Files the pull request changes."
          },
          "inGraph": {
            "type": "integer",
            "minimum": 0,
            "description": "Of those, files the graph knows."
          },
          "reach": {
            "type": ["integer", "null"],
            "minimum": 0,
            "description": "Files that depend on the changed ones, within depth. Null when not measured."
          },
          "reason": { "type": "string", "description": "Why reach is null." }
        }
      }
    }
  }
}
