{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "gno://schemas/graph-query@1.0",
  "title": "GNO Graph Query",
  "type": "object",
  "required": ["schemaVersion", "root", "nodes", "edges", "meta"],
  "properties": {
    "schemaVersion": { "type": "string", "const": "1.0" },
    "root": { "$ref": "#/definitions/node" },
    "nodes": {
      "type": "array",
      "items": { "$ref": "#/definitions/node" }
    },
    "edges": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "source",
          "target",
          "edgeType",
          "relationType",
          "confidence",
          "edgeSource",
          "depth"
        ],
        "properties": {
          "source": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
          "target": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
          "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"]
          },
          "depth": { "type": "integer", "minimum": 1 }
        },
        "additionalProperties": false
      }
    },
    "meta": {
      "type": "object",
      "required": [
        "direction",
        "edgeType",
        "maxDepth",
        "maxNodes",
        "frontierLimit",
        "visitedLimit",
        "returnedNodes",
        "returnedEdges",
        "truncated",
        "warnings"
      ],
      "properties": {
        "direction": { "type": "string", "enum": ["out", "in", "both"] },
        "edgeType": { "type": ["string", "null"] },
        "maxDepth": { "type": "integer", "minimum": 1 },
        "maxNodes": { "type": "integer", "minimum": 1 },
        "frontierLimit": { "type": "integer", "minimum": 1 },
        "visitedLimit": { "type": "integer", "minimum": 1 },
        "returnedNodes": { "type": "integer", "minimum": 1 },
        "returnedEdges": { "type": "integer", "minimum": 0 },
        "truncated": { "type": "boolean" },
        "warnings": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "definitions": {
    "node": {
      "type": "object",
      "required": [
        "id",
        "uri",
        "title",
        "collection",
        "relPath",
        "depth",
        "graphHints"
      ],
      "properties": {
        "id": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
        "uri": { "type": "string", "pattern": "^gno://.+" },
        "title": { "type": ["string", "null"] },
        "collection": { "type": "string" },
        "relPath": { "type": "string" },
        "depth": { "type": "integer", "minimum": 0 },
        "graphHints": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    }
  }
}
