{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "gno://schemas/impact@1.0",
  "title": "GNO Knowledge Impact",
  "type": "object",
  "required": ["schemaVersion", "root", "impacted", "meta"],
  "properties": {
    "schemaVersion": { "type": "string", "const": "1.0" },
    "root": { "$ref": "#/definitions/node" },
    "impacted": {
      "type": "array",
      "maxItems": 999,
      "items": {
        "type": "object",
        "required": ["document", "depth", "evidencePath"],
        "properties": {
          "document": { "$ref": "#/definitions/node" },
          "depth": { "type": "integer", "minimum": 1, "maximum": 6 },
          "evidencePath": {
            "type": "array",
            "minItems": 1,
            "maxItems": 6,
            "items": { "$ref": "#/definitions/step" }
          }
        },
        "additionalProperties": false
      }
    },
    "meta": {
      "type": "object",
      "required": [
        "maxDepth",
        "maxNodes",
        "maxEdges",
        "frontierLimit",
        "visitedLimit",
        "returnedNodes",
        "returnedEdges",
        "truncated",
        "warnings"
      ],
      "properties": {
        "maxDepth": { "type": "integer", "minimum": 1, "maximum": 6 },
        "maxNodes": { "type": "integer", "minimum": 1, "maximum": 1000 },
        "maxEdges": { "type": "integer", "minimum": 1, "maximum": 5000 },
        "frontierLimit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000
        },
        "visitedLimit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5000
        },
        "returnedNodes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000
        },
        "returnedEdges": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5000
        },
        "truncated": { "type": "boolean" },
        "warnings": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "definitions": {
    "node": {
      "type": "object",
      "required": ["id", "uri", "title", "collection", "relPath"],
      "properties": {
        "id": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
        "uri": { "type": "string", "pattern": "^gno://.+" },
        "title": { "type": ["string", "null"] },
        "collection": { "type": "string" },
        "relPath": { "type": "string" }
      },
      "additionalProperties": false
    },
    "endpoint": {
      "type": "object",
      "required": ["id", "uri"],
      "properties": {
        "id": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
        "uri": { "type": "string", "pattern": "^gno://.+" }
      },
      "additionalProperties": false
    },
    "step": {
      "type": "object",
      "required": [
        "source",
        "target",
        "edgeType",
        "relationType",
        "confidence",
        "edgeSource"
      ],
      "properties": {
        "source": { "$ref": "#/definitions/endpoint" },
        "target": { "$ref": "#/definitions/endpoint" },
        "edgeType": { "type": "string", "minLength": 1 },
        "relationType": { "type": "string", "minLength": 1 },
        "confidence": {
          "type": "string",
          "enum": ["parsed", "configured", "manual", "inferred"]
        },
        "edgeSource": {
          "type": "string",
          "enum": ["wikilink", "markdown-link", "frontmatter-relation"]
        }
      },
      "additionalProperties": false
    }
  }
}
