{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/eddiethedean/strixonomy/docs/lsp-protocol.schema.json",
  "title": "Strixonomy LSP protocol (v0.24)",
  "description": "JSON Schema for strixonomy/* custom LSP method payloads (v0.24). Method routing is documented in lsp-api.md. Standard LSP textDocument/semanticTokens/full is documented in lsp-api.md but not duplicated here.",
  "definitions": {
    "EntityKind": {
      "type": "string",
      "enum": [
        "class",
        "object_property",
        "data_property",
        "annotation_property",
        "individual",
        "ontology",
        "other"
      ]
    },
    "PatchEntityKind": {
      "type": "string",
      "enum": [
        "class",
        "object_property",
        "data_property",
        "annotation_property",
        "individual"
      ]
    },
    "PatchOp": {
      "type": "object",
      "required": ["op"],
      "properties": {
        "op": { "type": "string" },
        "entity_iri": { "type": "string" },
        "kind": { "$ref": "#/definitions/PatchEntityKind" },
        "value": { "type": "string" },
        "parent_iri": { "type": "string" },
        "manchester": { "type": "string" }
      },
      "additionalProperties": true
    },
    "EntityAxiomSummary": {
      "type": "object",
      "required": ["kind", "display", "editable"],
      "properties": {
        "kind": { "type": "string" },
        "display": { "type": "string" },
        "manchester": { "type": ["string", "null"] },
        "parent_iri": { "type": ["string", "null"] },
        "editable": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "TabularQueryResult": {
      "type": "object",
      "required": ["columns", "rows"],
      "properties": {
        "columns": {
          "type": "array",
          "items": { "type": "string" }
        },
        "rows": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": { "type": "string" }
          }
        },
        "truncated": { "type": ["boolean", "null"] }
      },
      "additionalProperties": false
    },
    "QueryParams": {
      "type": "object",
      "required": ["sql"],
      "properties": {
        "sql": { "type": "string" }
      },
      "additionalProperties": false
    },
    "SparqlParams": {
      "type": "object",
      "required": ["query"],
      "properties": {
        "query": { "type": "string" }
      },
      "additionalProperties": false
    },
    "ManchesterCompletions": {
      "type": "object",
      "required": ["classes", "object_properties", "data_properties", "datatypes"],
      "properties": {
        "classes": { "type": "array", "items": { "type": "string" } },
        "object_properties": { "type": "array", "items": { "type": "string" } },
        "data_properties": { "type": "array", "items": { "type": "string" } },
        "datatypes": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "ParseManchesterParams": {
      "type": "object",
      "required": ["expression", "axiom_kind"],
      "properties": {
        "expression": { "type": "string" },
        "axiom_kind": { "type": "string" },
        "entity_iri": { "type": ["string", "null"] },
        "document_uri": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "ParseManchesterResult": {
      "type": "object",
      "required": ["normalized", "turtle_fragment", "tree", "diagnostics", "completions"],
      "properties": {
        "normalized": { "type": "string" },
        "turtle_fragment": { "type": "string" },
        "tree": {},
        "diagnostics": { "type": "array" },
        "completions": { "$ref": "#/definitions/ManchesterCompletions" }
      },
      "additionalProperties": false
    },
    "ApplyAxiomPatchParams": {
      "type": "object",
      "required": ["document_uri", "patches"],
      "properties": {
        "document_uri": { "type": "string" },
        "patches": {
          "type": "array",
          "items": { "$ref": "#/definitions/PatchOp" }
        },
        "preview_only": { "type": "boolean", "default": false }
      },
      "additionalProperties": false
    },
    "SubclassEdge": {
      "type": "object",
      "required": ["child", "parent"],
      "properties": {
        "child": { "type": "string" },
        "parent": { "type": "string" }
      },
      "additionalProperties": false
    },
    "ReasonerWarning": {
      "type": "object",
      "required": ["code", "message"],
      "properties": {
        "code": { "type": "string" },
        "message": { "type": "string" },
        "suggested_profile": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "InferredHierarchy": {
      "type": "object",
      "required": ["edges", "unsatisfiable", "combined"],
      "properties": {
        "edges": {
          "type": "array",
          "items": { "$ref": "#/definitions/SubclassEdge" }
        },
        "unsatisfiable": {
          "type": "array",
          "items": { "type": "string" }
        },
        "combined": { "type": "object" }
      },
      "additionalProperties": false
    },
    "ReasonerSnapshot": {
      "type": "object",
      "required": [
        "profile_used",
        "consistent",
        "unsatisfiable",
        "inferred",
        "new_inferences",
        "warnings",
        "duration_ms",
        "classified_at"
      ],
      "properties": {
        "profile_used": { "type": "string" },
        "consistent": { "type": "boolean" },
        "unsatisfiable": {
          "type": "array",
          "items": { "type": "string" }
        },
        "inferred": { "$ref": "#/definitions/InferredHierarchy" },
        "new_inferences": {
          "type": "array",
          "items": { "$ref": "#/definitions/SubclassEdge" }
        },
        "warnings": {
          "type": "array",
          "items": { "$ref": "#/definitions/ReasonerWarning" }
        },
        "duration_ms": { "type": "integer" },
        "classified_at": { "type": "integer" }
      },
      "additionalProperties": false
    },
    "DlQueryParams": {
      "type": "object",
      "required": ["expression"],
      "properties": {
        "expression": { "type": "string" },
        "profile": { "type": "string", "default": "dl" },
        "mode": { "type": "string", "enum": ["inferred", "asserted"], "default": "inferred" },
        "document_uri": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "DlQueryResult": {
      "type": "object",
      "required": [
        "expression",
        "normalized",
        "query_class_iri",
        "subclasses",
        "superclasses",
        "equivalents",
        "instances",
        "profile",
        "mode",
        "duration_ms"
      ],
      "properties": {
        "expression": { "type": "string" },
        "normalized": { "type": "string" },
        "query_class_iri": { "type": "string" },
        "subclasses": { "type": "array", "items": { "type": "string" } },
        "superclasses": { "type": "array", "items": { "type": "string" } },
        "equivalents": { "type": "array", "items": { "type": "string" } },
        "instances": { "type": "array", "items": { "type": "string" } },
        "profile": { "type": "string" },
        "mode": { "type": "string" },
        "duration_ms": { "type": "integer" },
        "warnings": { "type": "array", "items": { "type": "string" } },
        "diagnostics": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "SearchParams": {
      "type": "object",
      "required": ["query"],
      "properties": {
        "query": { "type": "string" },
        "limit": { "type": ["integer", "null"] }
      },
      "additionalProperties": false
    },
    "EntityDetail": {
      "type": "object",
      "required": ["iri", "kind", "short_name"],
      "properties": {
        "iri": { "type": "string" },
        "kind": { "$ref": "#/definitions/EntityKind" },
        "short_name": { "type": "string" },
        "label": { "type": ["string", "null"] },
        "obo_id": { "type": ["string", "null"] },
        "ontology_id": { "type": "string" }
      },
      "additionalProperties": true
    },
    "SearchResult": {
      "type": "object",
      "required": ["entities"],
      "properties": {
        "entities": {
          "type": "array",
          "items": { "$ref": "#/definitions/EntityDetail" }
        }
      },
      "additionalProperties": false
    },
    "CheckInstanceParams": {
      "type": "object",
      "required": ["individual_iri", "class_iri"],
      "properties": {
        "individual_iri": { "type": "string" },
        "class_iri": { "type": "string" },
        "profile": { "type": "string", "default": "rl" }
      },
      "additionalProperties": false
    },
    "CheckInstanceResult": {
      "type": "object",
      "required": ["individual_iri", "class_iri", "entailed", "profile_used", "duration_ms"],
      "properties": {
        "individual_iri": { "type": "string" },
        "class_iri": { "type": "string" },
        "entailed": { "type": "boolean" },
        "profile_used": { "type": "string" },
        "duration_ms": { "type": "integer" }
      },
      "additionalProperties": false
    },
    "RunReasonerParams": {
      "type": "object",
      "properties": {
        "profile": { "type": "string", "default": "el" },
        "auto_detect": { "type": "boolean", "default": true }
      },
      "additionalProperties": false
    },
    "RunReasonerResult": {
      "type": "object",
      "required": [
        "profile_used",
        "consistent",
        "unsatisfiable",
        "inferred_edge_count",
        "new_inferences",
        "warnings",
        "duration_ms",
        "snapshot"
      ],
      "properties": {
        "profile_used": { "type": "string" },
        "consistent": { "type": "boolean" },
        "unsatisfiable": {
          "type": "array",
          "items": { "type": "string" }
        },
        "inferred_edge_count": { "type": "integer" },
        "new_inferences": {
          "type": "array",
          "items": { "$ref": "#/definitions/SubclassEdge" }
        },
        "warnings": {
          "type": "array",
          "items": { "$ref": "#/definitions/ReasonerWarning" }
        },
        "duration_ms": { "type": "integer" },
        "snapshot": { "$ref": "#/definitions/ReasonerSnapshot" }
      },
      "additionalProperties": false
    },
    "GetExplanationParams": {
      "type": "object",
      "required": ["class_iri"],
      "properties": {
        "class_iri": { "type": "string" },
        "profile": { "type": "string", "default": "el" }
      },
      "additionalProperties": false
    },
    "ExplanationStep": {
      "type": "object",
      "required": ["index", "rule", "display"],
      "properties": {
        "index": { "type": "integer" },
        "rule": { "type": "string" },
        "display": { "type": "string" },
        "subject_iri": { "type": ["string", "null"] },
        "object_iri": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "ExplanationResult": {
      "type": "object",
      "required": ["steps", "text"],
      "properties": {
        "steps": {
          "type": "array",
          "items": { "$ref": "#/definitions/ExplanationStep" }
        },
        "text": { "type": "string" }
      },
      "additionalProperties": false
    },
    "GetExplanationResult": {
      "type": "object",
      "required": ["class_iri", "steps", "text", "indexed_at", "content_hash"],
      "properties": {
        "class_iri": { "type": "string" },
        "steps": {
          "type": "array",
          "items": { "$ref": "#/definitions/ExplanationStep" }
        },
        "text": { "type": "string" },
        "alternatives": {
          "type": "array",
          "items": { "$ref": "#/definitions/ExplanationResult" }
        },
        "indexed_at": { "type": "integer" },
        "content_hash": { "type": "string" }
      },
      "additionalProperties": false
    },
    "DiagnosticSummary": {
      "type": "object",
      "required": ["code", "severity", "message", "file"],
      "properties": {
        "code": { "type": "string" },
        "severity": { "type": "string", "enum": ["error", "warning", "info"] },
        "message": { "type": "string" },
        "file": { "type": "string" },
        "line": { "type": ["integer", "null"] },
        "column": { "type": ["integer", "null"] },
        "entity_iri": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "CatalogSnapshot": {
      "type": "object",
      "required": ["documents", "entities", "hierarchy", "diagnostics"],
      "properties": {
        "documents": { "type": "array" },
        "entities": { "type": "array" },
        "hierarchy": { "type": "object" },
        "diagnostics": {
          "type": "array",
          "items": { "$ref": "#/definitions/DiagnosticSummary" }
        },
        "reasoner": { "$ref": "#/definitions/ReasonerSnapshot" }
      },
      "additionalProperties": true
    },
    "IndexWorkspaceParams": {
      "type": "object",
      "properties": {
        "workspace_uri": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "GetEntityParams": {
      "type": "object",
      "required": ["iri"],
      "properties": {
        "iri": { "type": "string" }
      },
      "additionalProperties": false
    },
    "LspErrorPayload": {
      "type": "object",
      "required": ["code", "message", "recoverable"],
      "properties": {
        "code": { "type": "string" },
        "message": { "type": "string" },
        "recoverable": { "type": "boolean" },
        "user_action": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "UsageSummary": {
      "type": "object",
      "required": ["iri", "referenced_iri", "file", "kind", "context"],
      "properties": {
        "iri": { "type": "string" },
        "referenced_iri": { "type": "string" },
        "file": { "type": "string" },
        "line": { "type": ["integer", "null"] },
        "column": { "type": ["integer", "null"] },
        "kind": { "type": "string" },
        "context": { "type": "string" }
      },
      "additionalProperties": false
    },
    "FindUsagesResult": {
      "type": "object",
      "required": ["usages"],
      "properties": {
        "usages": {
          "type": "array",
          "items": { "$ref": "#/definitions/UsageSummary" }
        }
      },
      "additionalProperties": false
    },
    "RefactorFileChange": {
      "type": "object",
      "required": ["path", "preview_text", "original_text", "hunks"],
      "properties": {
        "path": { "type": "string" },
        "preview_text": { "type": "string" },
        "original_text": { "type": "string" },
        "hunks": { "type": "array" }
      },
      "additionalProperties": true
    },
    "RefactorPlan": {
      "type": "object",
      "required": ["changes"],
      "properties": {
        "changes": {
          "type": "array",
          "items": { "$ref": "#/definitions/RefactorFileChange" }
        },
        "warnings": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "additionalProperties": false
    },
    "ApplyRefactorResult": {
      "type": "object",
      "required": ["files_written"],
      "properties": {
        "files_written": { "type": "integer" },
        "reindex_warning": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "RefactorRequest": {
      "oneOf": [
        {
          "type": "object",
          "required": ["kind", "from_iri", "to_iri"],
          "properties": {
            "kind": { "const": "rename_iri" },
            "from_iri": { "type": "string" },
            "to_iri": { "type": "string" }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "keep_iri", "merge_iri"],
          "properties": {
            "kind": { "const": "merge_entities" },
            "keep_iri": { "type": "string" },
            "merge_iri": { "type": "string" }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "from_iri", "to_iri"],
          "properties": {
            "kind": { "const": "replace_entity" },
            "from_iri": { "type": "string" },
            "to_iri": { "type": "string" }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "from_base", "to_base"],
          "properties": {
            "kind": { "const": "migrate_namespace" },
            "from_base": { "type": "string" },
            "to_base": { "type": "string" }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "entity_iri", "target_file"],
          "properties": {
            "kind": { "const": "move_entity" },
            "entity_iri": { "type": "string" },
            "target_file": { "type": "string" }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "entity_iris", "output_file"],
          "properties": {
            "kind": { "const": "extract_module" },
            "entity_iris": { "type": "array", "items": { "type": "string" } },
            "output_file": { "type": "string" },
            "leave_stub": { "type": "boolean", "default": false },
            "locality": { "type": "boolean", "default": false }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "entity_iri", "target_file"],
          "properties": {
            "kind": { "const": "move_axioms" },
            "entity_iri": { "type": "string" },
            "target_file": { "type": "string" },
            "statement_indexes": {
              "type": "array",
              "items": { "type": "integer", "minimum": 0 }
            },
            "exclude_primary": { "type": "boolean", "default": true }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "source_paths", "target_file"],
          "properties": {
            "kind": { "const": "merge_ontologies" },
            "source_paths": { "type": "array", "items": { "type": "string" } },
            "target_file": { "type": "string" }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "ontology_file"],
          "properties": {
            "kind": { "const": "flatten_imports" },
            "ontology_file": { "type": "string" }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["kind", "ontology_file"],
          "properties": {
            "kind": { "const": "cleanup_imports" },
            "ontology_file": { "type": "string" }
          },
          "additionalProperties": false
        }
      ]
    },
    "GetGraphParams": {
      "type": "object",
      "required": ["graph_kind"],
      "properties": {
        "graph_kind": {
          "type": "string",
          "enum": ["class", "property", "import", "neighborhood"]
        },
        "root_iri": { "type": ["string", "null"] },
        "depth": { "type": "integer", "default": 2 },
        "include_inferred": { "type": "boolean", "default": false },
        "filters": {
          "type": "object",
          "properties": {
            "hide_deprecated": { "type": "boolean", "default": false }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": false
    },
    "GraphNode": {
      "type": "object",
      "required": ["id", "label", "kind"],
      "properties": {
        "id": { "type": "string" },
        "label": { "type": "string" },
        "kind": { "type": "string" }
      },
      "additionalProperties": false
    },
    "GraphEdge": {
      "type": "object",
      "required": ["source", "target", "kind", "inferred"],
      "properties": {
        "source": { "type": "string" },
        "target": { "type": "string" },
        "kind": { "type": "string" },
        "inferred": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "GraphPayload": {
      "type": "object",
      "required": ["nodes", "edges", "truncated", "graph_kind"],
      "properties": {
        "nodes": {
          "type": "array",
          "items": { "$ref": "#/definitions/GraphNode" }
        },
        "edges": {
          "type": "array",
          "items": { "$ref": "#/definitions/GraphEdge" }
        },
        "truncated": { "type": "boolean" },
        "graph_kind": { "type": "string" }
      },
      "additionalProperties": false
    },
    "GetGraphResult": {
      "type": "object",
      "required": ["graph"],
      "properties": {
        "graph": { "$ref": "#/definitions/GraphPayload" }
      },
      "additionalProperties": false
    },
    "SemanticDiffParams": {
      "type": "object",
      "properties": {
        "left_ref": { "type": ["string", "null"] },
        "right_ref": { "type": ["string", "null"] },
        "left_path": { "type": ["string", "null"] },
        "right_path": { "type": ["string", "null"] },
        "reasoner": { "type": "boolean", "default": false },
        "format": {
          "type": ["string", "null"],
          "description": "When set to pr-summary, result includes formatted Markdown string (v0.13+)."
        }
      },
      "additionalProperties": false
    },
    "SemanticDiffResult": {
      "type": "object",
      "required": ["diff"],
      "properties": {
        "diff": { "type": "object", "additionalProperties": true },
        "formatted": {
          "type": "string",
          "description": "PR-ready Markdown when format is pr-summary (v0.13+)."
        }
      },
      "additionalProperties": false
    },
    "SqlColumnSchema": {
      "type": "object",
      "required": ["name", "type"],
      "properties": {
        "name": { "type": "string" },
        "type": { "type": "string" }
      },
      "additionalProperties": false
    },
    "SqlTableSchema": {
      "type": "object",
      "required": ["name", "columns"],
      "properties": {
        "name": { "type": "string" },
        "columns": {
          "type": "array",
          "items": { "$ref": "#/definitions/SqlColumnSchema" }
        }
      },
      "additionalProperties": false
    },
    "ListSqlSchemaResult": {
      "type": "object",
      "required": ["tables"],
      "properties": {
        "tables": {
          "type": "array",
          "items": { "$ref": "#/definitions/SqlTableSchema" }
        }
      },
      "additionalProperties": false
    },
    "RunRobotParams": {
      "type": "object",
      "required": ["subcommand"],
      "properties": {
        "subcommand": { "type": "string" },
        "args": { "type": "array", "items": { "type": "string" }, "default": [] },
        "robot_path": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "RunRobotResult": {
      "type": "object",
      "required": ["exit_code", "stdout", "stderr"],
      "properties": {
        "exit_code": { "type": "integer" },
        "stdout": { "type": "string" },
        "stderr": { "type": "string" }
      },
      "additionalProperties": false
    },
    "PluginCapabilities": {
      "type": "object",
      "properties": {
        "build": { "type": "boolean" },
        "validate": { "type": "boolean" },
        "release": { "type": "boolean" },
        "diagnostics": { "type": "boolean" },
        "export": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "PluginUiCommand": {
      "type": "object",
      "required": ["id", "title"],
      "properties": {
        "id": { "type": "string" },
        "title": { "type": "string" },
        "scope": { "type": "string" }
      },
      "additionalProperties": false
    },
    "PluginInspectorCard": {
      "type": "object",
      "required": ["id", "title", "applies_to"],
      "properties": {
        "id": { "type": "string" },
        "title": { "type": "string" },
        "applies_to": { "type": "string" },
        "command": { "type": "string" }
      },
      "additionalProperties": false
    },
    "PluginUiView": {
      "type": "object",
      "required": ["id", "title"],
      "properties": {
        "id": { "type": "string" },
        "title": { "type": "string" }
      },
      "additionalProperties": false
    },
    "PluginUiContributions": {
      "type": "object",
      "properties": {
        "commands": { "type": "array", "items": { "$ref": "#/definitions/PluginUiCommand" } },
        "views": { "type": "array", "items": { "$ref": "#/definitions/PluginUiView" } },
        "inspector_cards": { "type": "array", "items": { "$ref": "#/definitions/PluginInspectorCard" } }
      },
      "additionalProperties": false
    },
    "PluginDescriptor": {
      "type": "object",
      "required": ["id", "name", "version", "kind", "manifest_path", "capabilities", "ui", "in_process"],
      "properties": {
        "id": { "type": "string" },
        "name": { "type": "string" },
        "version": { "type": "string" },
        "kind": { "type": "string" },
        "api_version": { "type": ["string", "null"] },
        "permissions": {
          "type": "array",
          "items": { "type": "string", "enum": ["workspace.read", "workspace.write", "external_process"] }
        },
        "manifest_path": { "type": "string" },
        "capabilities": { "$ref": "#/definitions/PluginCapabilities" },
        "ui": { "$ref": "#/definitions/PluginUiContributions" },
        "in_process": { "type": "boolean" },
        "disabled": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "ListPluginsResult": {
      "type": "object",
      "required": ["plugins"],
      "properties": {
        "plugins": { "type": "array", "items": { "$ref": "#/definitions/PluginDescriptor" } }
      },
      "additionalProperties": false
    },
    "RunPluginParams": {
      "type": "object",
      "required": ["plugin_id"],
      "properties": {
        "plugin_id": { "type": "string" },
        "action": { "type": "string" },
        "step": { "type": "string" },
        "view_id": { "type": "string" }
      },
      "additionalProperties": false
    },
    "RunPluginResult": {
      "type": "object",
      "required": ["diagnostics", "output_paths", "success"],
      "properties": {
        "diagnostics": { "type": "array", "items": { "$ref": "#/definitions/DiagnosticSummary" } },
        "output_paths": { "type": "array", "items": { "type": "string" } },
        "logs": { "type": ["string", "null"] },
        "view_html": { "type": ["string", "null"] },
        "success": { "type": "boolean" }
      },
      "additionalProperties": false
    }
  }
}
