{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://slopvac.github.io/slopvac/schemas/v3/plugin-protocol.schema.json",
  "title": "slopvac plugin protocol v1",
  "description": "One JSON-RPC 2.0 message of plugin protocol v1, as carried in the body of a Content-Length frame. The root validates a whole message: a request or notification is dispatched on method, a response is checked as a success or an error. Result shapes are separate $defs because a response names no method; validate one against the def of the method it answers. No object here sets additionalProperties false: a reader ignores unknown fields, and keys with the prefix x- never carry meaning. Semantics are in docs/contract/plugin-protocol.md. Owner: slopvac-8l4.2.6.",
  "type": "object",
  "properties": {
    "jsonrpc": {
      "const": "2.0"
    }
  },
  "required": [
    "jsonrpc"
  ],
  "allOf": [
    {
      "if": {
        "required": [
          "method"
        ]
      },
      "then": {
        "$ref": "#/$defs/Call"
      },
      "else": {
        "$ref": "#/$defs/Response"
      }
    }
  ],
  "$defs": {
    "RequestId": {
      "description": "Request id. Integers from 1 to 2^53-1, unique among the requests of one connection and never reused after completion or cancellation. Strings, null, fractions and larger values are invalid in v1.",
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "HookKind": {
      "description": "Hook point name. The v1 kinds are tagger, extractor, binary-extractor, reporter, fixer, scorer, provider and recipe. A reader ignores a kind it does not know, so the schema fixes only the form.",
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])"
    },
    "HookId": {
      "description": "Plugin-local hook identifier. The host qualifies it with the plugin name. Each hook kind has its own id space.",
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])"
    },
    "FeatureName": {
      "description": "Optional capability name. The v1 registry holds one name, document-path. A name with the prefix x- is a private extension and a reader ignores it unless it understands it.",
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])|^x-[a-z0-9-]+(?![\\s\\S])"
    },
    "ProtocolVersion": {
      "description": "Protocol version. Same value space as ApiVersion in common.schema.json.",
      "$ref": "common.schema.json#/$defs/ApiVersion"
    },
    "Name": {
      "description": "Program name and version of the host or the plugin. For logs only; never branch on it.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "name",
        "version"
      ]
    },
    "ErrorObject": {
      "description": "JSON-RPC error. code follows docs/contract/plugin-protocol.md, section Error codes. data.slopvac_code is the stable kebab-case string code that policies.md section 3.5 requires. A code from -32099 to -32000 is slopvac-defined.",
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "message": {
          "type": "string"
        },
        "data": {
          "type": "object",
          "properties": {
            "slopvac_code": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*(?![\\s\\S])"
            }
          },
          "required": [
            "slopvac_code"
          ]
        }
      },
      "required": [
        "code",
        "message",
        "data"
      ]
    },
    "ErrorResponse": {
      "description": "Response that carries an error. id is null only when the sender could not read the request id, for example after a parse error.",
      "type": "object",
      "properties": {
        "jsonrpc": {
          "const": "2.0"
        },
        "id": {
          "oneOf": [
            {
              "$ref": "#/$defs/RequestId"
            },
            {
              "type": "null"
            }
          ]
        },
        "error": {
          "$ref": "#/$defs/ErrorObject"
        }
      },
      "required": [
        "jsonrpc",
        "id",
        "error"
      ],
      "not": {
        "required": [
          "result"
        ]
      }
    },
    "SuccessResponse": {
      "description": "Response that carries a result. The shape of result depends on the method of the request with the same id.",
      "type": "object",
      "properties": {
        "jsonrpc": {
          "const": "2.0"
        },
        "id": {
          "$ref": "#/$defs/RequestId"
        },
        "result": {}
      },
      "required": [
        "jsonrpc",
        "id",
        "result"
      ],
      "not": {
        "required": [
          "error"
        ]
      }
    },
    "Response": {
      "description": "Success or error response.",
      "if": {
        "required": [
          "error"
        ]
      },
      "then": {
        "$ref": "#/$defs/ErrorResponse"
      },
      "else": {
        "$ref": "#/$defs/SuccessResponse"
      }
    },
    "PluginDocument": {
      "description": "One document in a batch. text is the full UTF-8 source. Every span in a result is a byte range into this text. path is present only when the plugin requested the document-path feature and the host granted it. It is relative to the project root, or <stdin>, or <external>/<file name>. It is never absolute.",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "text": {
          "type": "string"
        },
        "media_type": {
          "type": "string"
        },
        "path": {
          "type": "string",
          "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!(.*/)?\\.\\.(/|(?![\\s\\S]))).+(?![\\s\\S])"
        }
      },
      "required": [
        "id",
        "text"
      ]
    },
    "Documents": {
      "description": "Batch of documents for one request. The host splits a batch to stay under the limits agreed in initialize. Ids are unique within the array.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/PluginDocument"
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "PluginFinding": {
      "description": "A finding as passed to fixers and scorers. Spans index the text of the document that carries the finding.",
      "type": "object",
      "properties": {
        "rule": {
          "$ref": "common.schema.json#/$defs/RuleId"
        },
        "severity": {
          "$ref": "common.schema.json#/$defs/Severity"
        },
        "span": {
          "$ref": "common.schema.json#/$defs/Span"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "rule",
        "severity",
        "span",
        "message"
      ]
    },
    "DocumentResult": {
      "description": "Fields shared by every per-document result. document echoes a Document id. error marks only this document as failed; the host reports the run as incomplete (exit 2) and keeps the other documents.",
      "type": "object",
      "properties": {
        "document": {
          "type": "string",
          "minLength": 1
        },
        "error": {
          "$ref": "#/$defs/ErrorObject"
        }
      },
      "required": [
        "document"
      ]
    },
    "InitializeParams": {
      "description": "First request, from host to plugin. protocolVersion is the highest version the host speaks and minProtocolVersion the lowest (default 1). hooks lists the kinds the host can call. features lists optional capabilities the host offers. offline is true when sticky offline mode is on. limits are the host's ceilings.",
      "type": "object",
      "properties": {
        "protocolVersion": {
          "$ref": "#/$defs/ProtocolVersion"
        },
        "minProtocolVersion": {
          "$ref": "#/$defs/ProtocolVersion"
        },
        "hostInfo": {
          "$ref": "#/$defs/Name"
        },
        "capabilities": {
          "type": "object",
          "properties": {
            "hooks": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/HookKind"
              },
              "uniqueItems": true
            },
            "features": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/FeatureName"
              },
              "uniqueItems": true
            }
          },
          "required": [
            "hooks",
            "features"
          ]
        },
        "offline": {
          "type": "boolean"
        },
        "limits": {
          "type": "object",
          "properties": {
            "maxMessageBytes": {
              "type": "integer",
              "minimum": 65536
            },
            "maxBatchDocuments": {
              "type": "integer",
              "minimum": 1
            }
          },
          "required": [
            "maxMessageBytes",
            "maxBatchDocuments"
          ]
        }
      },
      "required": [
        "protocolVersion",
        "hostInfo",
        "capabilities",
        "offline",
        "limits"
      ]
    },
    "HookDecl": {
      "description": "One hook a plugin implements. The host calls only declared hooks. A binary-extractor hook must list the formats it reads, at least one and without duplicates. For other kinds formats is an unknown field and a reader ignores it.",
      "type": "object",
      "properties": {
        "kind": {
          "$ref": "#/$defs/HookKind"
        },
        "id": {
          "$ref": "#/$defs/HookId"
        }
      },
      "required": [
        "kind",
        "id"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "kind": {
                "const": "binary-extractor"
              }
            },
            "required": [
              "kind"
            ]
          },
          "then": {
            "properties": {
              "formats": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/BinaryFormat"
                },
                "minItems": 1,
                "uniqueItems": true
              }
            },
            "required": [
              "formats"
            ]
          }
        }
      ]
    },
    "InitializeResult": {
      "description": "Reply to initialize. protocolVersion is the negotiated version: the highest version both sides support. It must lie in the host's range. capabilities repeat the pre-spawn declaration: the host compares them with the manifest and rejects the reply, with plugin-declaration-mismatch, when requiresNetwork differs, a hook is absent from the manifest, or a required feature is absent from it. features.required names features the plugin cannot work without; the host stops the load if it lacks one. limits.maxMessageBytes, maxBatchDocuments and maxInFlight may lower the host ceilings but not raise them; a higher value is plugin-output-invalid.",
      "type": "object",
      "properties": {
        "protocolVersion": {
          "$ref": "#/$defs/ProtocolVersion"
        },
        "pluginInfo": {
          "$ref": "#/$defs/Name"
        },
        "capabilities": {
          "type": "object",
          "properties": {
            "hooks": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/HookDecl"
              }
            },
            "features": {
              "type": "object",
              "properties": {
                "required": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/FeatureName"
                  },
                  "uniqueItems": true
                },
                "optional": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/FeatureName"
                  },
                  "uniqueItems": true
                }
              },
              "required": [
                "required",
                "optional"
              ]
            },
            "requiresNetwork": {
              "type": "boolean",
              "description": "Must equal PluginDeclaration.network. It informs and cannot grant anything."
            }
          },
          "required": [
            "hooks",
            "features",
            "requiresNetwork"
          ]
        },
        "limits": {
          "type": "object",
          "properties": {
            "maxMessageBytes": {
              "type": "integer",
              "minimum": 65536
            },
            "maxBatchDocuments": {
              "type": "integer",
              "minimum": 1
            },
            "maxInFlight": {
              "type": "integer",
              "minimum": 1
            }
          },
          "required": [
            "maxMessageBytes",
            "maxBatchDocuments",
            "maxInFlight"
          ]
        }
      },
      "required": [
        "protocolVersion",
        "pluginInfo",
        "capabilities",
        "limits"
      ]
    },
    "CancelParams": {
      "description": "Parameters of $/cancelRequest. id names a request the sender no longer wants answered.",
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/RequestId"
        }
      },
      "required": [
        "id"
      ]
    },
    "Tag": {
      "description": "A context tag: kind, span, confidence and evidence, as the plan defines for taggers.",
      "type": "object",
      "properties": {
        "kind": {
          "$ref": "common.schema.json#/$defs/ContextTag"
        },
        "span": {
          "$ref": "common.schema.json#/$defs/Span"
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "evidence": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "span",
        "confidence",
        "evidence"
      ]
    },
    "TagParams": {
      "description": "tagger/tag. Run the named tagger over each document.",
      "type": "object",
      "properties": {
        "tagger": {
          "$ref": "#/$defs/HookId"
        },
        "documents": {
          "$ref": "#/$defs/Documents"
        }
      },
      "required": [
        "tagger",
        "documents"
      ]
    },
    "TagResult": {
      "description": "One entry per requested document. Tags may overlap and may arrive in any order.",
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/DocumentResult"
              },
              {
                "type": "object",
                "properties": {
                  "tags": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/Tag"
                    }
                  }
                }
              }
            ]
          }
        }
      },
      "required": [
        "results"
      ]
    },
    "Segment": {
      "description": "A region of prose that the extractor hands to the rules. span is the source range it came from. text is the converted text when it differs from the source bytes in span; a finding in converted text maps to the whole span. context labels the region, for example prose or code.",
      "type": "object",
      "properties": {
        "span": {
          "$ref": "common.schema.json#/$defs/Span"
        },
        "context": {
          "$ref": "common.schema.json#/$defs/ContextTag"
        },
        "text": {
          "type": "string"
        }
      },
      "required": [
        "span",
        "context"
      ]
    },
    "ExtractParams": {
      "description": "extractor/extract. Split each document into segments.",
      "type": "object",
      "properties": {
        "extractor": {
          "$ref": "#/$defs/HookId"
        },
        "documents": {
          "$ref": "#/$defs/Documents"
        }
      },
      "required": [
        "extractor",
        "documents"
      ]
    },
    "ExtractResult": {
      "description": "One entry per requested document. Segments are in source order and do not overlap.",
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/DocumentResult"
              },
              {
                "type": "object",
                "properties": {
                  "segments": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/Segment"
                    }
                  }
                }
              }
            ]
          }
        }
      },
      "required": [
        "results"
      ]
    },
    "BinaryFormat": {
      "description": "Format id of a binary document, from the 3.0 list in docs/contract/plugin-protocol.md section 5.5.1. The enum is extensible (x-slopvac-extensible): a later release may add ids without a new protocol version. A plugin or reader that receives an id it does not know declines that document with binary-input-declined, reason unknown-format, and does not fail the request. Manifest validation applies the list strictly: the host refuses a manifest that declares an id outside its own list.",
      "x-slopvac-extensible": true,
      "enum": [
        "docx",
        "docm",
        "dotx",
        "dotm",
        "pptx",
        "pptm",
        "ppsx",
        "ppsm",
        "potx",
        "potm",
        "xlsx",
        "xlsm",
        "xltx",
        "xltm",
        "odt",
        "odp",
        "ods",
        "drawio-png",
        "excalidraw-png",
        "plantuml-png"
      ]
    },
    "BinaryDocument": {
      "description": "One binary document in a batch. bytes is the whole file in standard base64 (RFC 4648 section 4) with padding and no line breaks; byte_length is the decoded length. format is the id the host detected. path follows PluginDocument.path and the document-path feature. Every BinarySpan in the result indexes the decoded bytes.",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "format": {
          "$ref": "#/$defs/BinaryFormat"
        },
        "media_type": {
          "type": "string"
        },
        "byte_length": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "bytes": {
          "type": "string",
          "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?(?![\\s\\S])"
        },
        "path": {
          "type": "string",
          "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!(.*/)?\\.\\.(/|(?![\\s\\S]))).+(?![\\s\\S])"
        }
      },
      "required": [
        "id",
        "format",
        "byte_length",
        "bytes"
      ]
    },
    "BinarySpan": {
      "description": "Physical provenance of a segment: a half-open range [start, end) of byte offsets into the decoded bytes of the document, with start at most end and end at most byte_length. The host checks the bounds. It has no character-boundary rule, and unlike common Span it is an open object (plugin-protocol.md section 9). Matching and rendered positions never use it; they use offsets into the segment text.",
      "type": "object",
      "properties": {
        "start": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "end": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "start",
        "end"
      ]
    },
    "BinarySegment": {
      "description": "A region of prose that a binary extractor hands to the rules. part names the container member, locator the place inside it; together they identify the segment and are unique within one document result. Both hold 1 to 1024 characters with no control or bidirectional-control characters. The 1024-character bound is a fixed host cap: the host reports a longer value as extract-budget, and the pattern bound is a backstop for other readers. span is physical provenance only. text is the extracted UTF-8 prose that rules match; findings use offsets into it. context is a context tag. role is the structural role, from an extensible set (plugin-protocol.md section 5.5.3).",
      "type": "object",
      "properties": {
        "part": {
          "type": "string",
          "pattern": "^[^\\u0000-\\u001F\\u007F-\\u009F\\u202A-\\u202E\\u2066-\\u2069]{1,1024}(?![\\s\\S])"
        },
        "locator": {
          "type": "string",
          "pattern": "^[^\\u0000-\\u001F\\u007F-\\u009F\\u202A-\\u202E\\u2066-\\u2069]{1,1024}(?![\\s\\S])"
        },
        "span": {
          "$ref": "#/$defs/BinarySpan"
        },
        "text": {
          "type": "string",
          "minLength": 1
        },
        "context": {
          "$ref": "common.schema.json#/$defs/ContextTag"
        },
        "role": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])"
        }
      },
      "required": [
        "part",
        "locator",
        "span",
        "text",
        "context",
        "role"
      ]
    },
    "BinaryUnsupported": {
      "description": "Content that a binary extractor skipped inside a document it reads, such as an embedded object or a part type it does not handle. part names the container member and locator, when present, the place inside it; both follow the BinarySegment rules. media_type is the content type the container declares for it, when it declares one. The host reports each entry as an info notice extract-unsupported in the root notices of the lint report, and the run still exits 0 (plugin-protocol.md section 5.5.4). Entries count against the segments budget.",
      "type": "object",
      "properties": {
        "part": {
          "type": "string",
          "pattern": "^[^\\u0000-\\u001F\\u007F-\\u009F\\u202A-\\u202E\\u2066-\\u2069]{1,1024}(?![\\s\\S])"
        },
        "locator": {
          "type": "string",
          "pattern": "^[^\\u0000-\\u001F\\u007F-\\u009F\\u202A-\\u202E\\u2066-\\u2069]{1,1024}(?![\\s\\S])"
        },
        "media_type": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "part"
      ]
    },
    "BinaryBudget": {
      "description": "The budget an extract-budget error names in data.budget. This def is the one list of allowed values; docs/contract/plugin-protocol.md section 5.5.5 gives each value its limit, which an extract-budget error carries in data.limit in the unit of that table. The enum is extensible (x-slopvac-extensible): a reader keeps a value it does not know.",
      "x-slopvac-extensible": true,
      "enum": [
        "segments",
        "part",
        "locator",
        "text",
        "in-flight"
      ]
    },
    "BinaryDeclineReason": {
      "description": "Why a binary extractor declines a whole document with binary-input-declined (-32008), carried in data.reason. unknown-format: the format id is not one the extractor knows (plugin-protocol.md section 5.5.1). variant-unsupported: the format is one it lists, but this variant is one it does not handle. The enum is closed: any other value is a protocol violation (plugin-output-invalid). The host renders its own description for each reason and never shows the plugin's string. A new reason is a contract change.",
      "enum": [
        "unknown-format",
        "variant-unsupported"
      ]
    },
    "BinaryExtractParams": {
      "description": "binary-extractor/extract. Extract the prose of each binary document. The host admits a request by a length preflight before it reads or encodes the file, holds it against the in-flight budget, and sends it only when the exact serialized size fits the negotiated maxMessageBytes (plugin-protocol.md section 5.5.6).",
      "type": "object",
      "properties": {
        "extractor": {
          "$ref": "#/$defs/HookId"
        },
        "documents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BinaryDocument"
          },
          "minItems": 1,
          "uniqueItems": true
        }
      },
      "required": [
        "extractor",
        "documents"
      ]
    },
    "BinaryExtractResult": {
      "description": "One entry per requested document. Each entry carries exactly one of outcome or error. outcome extracted carries one or more segments in reading order; empty and no-source carry none. An entry with an outcome may list skipped content in unsupported, which the host reports as extract-unsupported notices; an entry with an error may not. extract-unsupported is never a per-document error. A document the extractor declines, an encrypted container, a malformed file and a budget breach travel as a per-document error: binary-input-declined (-32008) with data.reason, binary-encrypted (-32011), extract-malformed (-32009) and extract-budget (-32010) with data.budget and data.limit. A reader never parses these fields from the message. The reply must fit maxMessageBytes; a document whose segments do not fit gets the error message-too-large instead.",
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/DocumentResult"
              },
              {
                "type": "object",
                "properties": {
                  "outcome": {
                    "enum": [
                      "extracted",
                      "empty",
                      "no-source"
                    ]
                  },
                  "segments": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/BinarySegment"
                    }
                  },
                  "unsupported": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/BinaryUnsupported"
                    },
                    "minItems": 1
                  }
                },
                "oneOf": [
                  {
                    "required": [
                      "outcome"
                    ],
                    "not": {
                      "required": [
                        "error"
                      ]
                    }
                  },
                  {
                    "required": [
                      "error"
                    ],
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "outcome"
                          ]
                        },
                        {
                          "required": [
                            "segments"
                          ]
                        },
                        {
                          "required": [
                            "unsupported"
                          ]
                        }
                      ]
                    }
                  }
                ],
                "allOf": [
                  {
                    "if": {
                      "properties": {
                        "outcome": {
                          "const": "extracted"
                        }
                      },
                      "required": [
                        "outcome"
                      ]
                    },
                    "then": {
                      "properties": {
                        "segments": {
                          "minItems": 1
                        }
                      },
                      "required": [
                        "segments"
                      ]
                    }
                  },
                  {
                    "if": {
                      "properties": {
                        "outcome": {
                          "enum": [
                            "empty",
                            "no-source"
                          ]
                        }
                      },
                      "required": [
                        "outcome"
                      ]
                    },
                    "then": {
                      "properties": {
                        "segments": {
                          "maxItems": 0
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "properties": {
                        "outcome": {
                          "const": "no-source"
                        }
                      },
                      "required": [
                        "outcome"
                      ]
                    },
                    "then": {
                      "properties": {
                        "unsupported": {
                          "maxItems": 0
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "properties": {
                        "error": {
                          "properties": {
                            "data": {
                              "properties": {
                                "slopvac_code": {
                                  "const": "extract-budget"
                                }
                              },
                              "required": [
                                "slopvac_code"
                              ]
                            }
                          },
                          "required": [
                            "data"
                          ]
                        }
                      },
                      "required": [
                        "error"
                      ]
                    },
                    "then": {
                      "properties": {
                        "error": {
                          "properties": {
                            "data": {
                              "properties": {
                                "budget": {
                                  "$ref": "#/$defs/BinaryBudget"
                                },
                                "limit": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": [
                                "budget",
                                "limit"
                              ]
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "properties": {
                        "error": {
                          "properties": {
                            "data": {
                              "properties": {
                                "slopvac_code": {
                                  "const": "binary-input-declined"
                                }
                              },
                              "required": [
                                "slopvac_code"
                              ]
                            }
                          },
                          "required": [
                            "data"
                          ]
                        }
                      },
                      "required": [
                        "error"
                      ]
                    },
                    "then": {
                      "properties": {
                        "error": {
                          "properties": {
                            "data": {
                              "properties": {
                                "reason": {
                                  "$ref": "#/$defs/BinaryDeclineReason"
                                }
                              },
                              "required": [
                                "reason"
                              ]
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "properties": {
                      "error": {
                        "properties": {
                          "data": {
                            "properties": {
                              "slopvac_code": {
                                "not": {
                                  "const": "extract-unsupported"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              }
            ]
          }
        }
      },
      "required": [
        "results"
      ]
    },
    "RenderParams": {
      "description": "reporter/render. report is one lint report with schema_version 3. Its shape is the lint-report schema; this schema checks only the version so that the two schemas can evolve apart. options holds reporter-specific settings from the config.",
      "type": "object",
      "properties": {
        "reporter": {
          "$ref": "#/$defs/HookId"
        },
        "report": {
          "type": "object",
          "properties": {
            "schema_version": {
              "$ref": "common.schema.json#/$defs/SchemaVersion"
            }
          },
          "required": [
            "schema_version"
          ]
        },
        "options": {
          "type": "object"
        }
      },
      "required": [
        "reporter",
        "report"
      ]
    },
    "RenderResult": {
      "description": "Rendered text. The host writes it to stdout or to the file the user named. The host strips terminal control characters other than newline and tab before it writes to a terminal.",
      "type": "object",
      "properties": {
        "output": {
          "type": "string"
        },
        "media_type": {
          "type": "string"
        }
      },
      "required": [
        "output",
        "media_type"
      ]
    },
    "FixParams": {
      "description": "fixer/fix. Propose edits for the selected findings of each document. findings holds only the findings the user selected to fix. They define the envelope of what edits may touch.",
      "type": "object",
      "properties": {
        "fixer": {
          "$ref": "#/$defs/HookId"
        },
        "documents": {
          "type": "array",
          "minItems": 1,
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/PluginDocument"
              },
              {
                "type": "object",
                "properties": {
                  "findings": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/PluginFinding"
                    }
                  }
                },
                "required": [
                  "findings"
                ]
              }
            ]
          }
        }
      },
      "required": [
        "fixer",
        "documents"
      ]
    },
    "FixResult": {
      "description": "One entry per requested document. Each edit names the selected finding that authorizes it. The host rejects every edit of a document, and reports that document as failed with plugin-output-invalid, when any edit lies outside its finding span, names no valid finding, or overlaps another edit. v1 has no approval path for broader edits. Edits apply to the text the host sent.",
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/DocumentResult"
              },
              {
                "type": "object",
                "properties": {
                  "edits": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/FixEdit"
                    }
                  }
                }
              }
            ]
          }
        }
      },
      "required": [
        "results"
      ]
    },
    "ScoreParams": {
      "description": "scorer/score. Compute a score for each document from its findings. The scorer may also read the text.",
      "type": "object",
      "properties": {
        "scorer": {
          "$ref": "#/$defs/HookId"
        },
        "documents": {
          "type": "array",
          "minItems": 1,
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/PluginDocument"
              },
              {
                "type": "object",
                "properties": {
                  "findings": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/PluginFinding"
                    }
                  }
                },
                "required": [
                  "findings"
                ]
              }
            ]
          }
        }
      },
      "required": [
        "scorer",
        "documents"
      ]
    },
    "ScoreResult": {
      "description": "One entry per requested document. score is finite and at least 0. The scale belongs to the scorer; the host applies the gate thresholds from the config.",
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/DocumentResult"
              },
              {
                "type": "object",
                "properties": {
                  "score": {
                    "type": "number",
                    "minimum": 0
                  }
                }
              }
            ]
          }
        }
      },
      "required": [
        "results"
      ]
    },
    "CompleteParams": {
      "description": "provider/complete. Ask a model provider about each item. task names the review type. The host sends only the text the task needs. model is the model name from the config. A provider that cannot use it answers with an error.",
      "type": "object",
      "properties": {
        "provider": {
          "$ref": "#/$defs/HookId"
        },
        "task": {
          "enum": [
            "fact-check",
            "update",
            "rewrite"
          ]
        },
        "model": {
          "type": "string",
          "minLength": 1
        },
        "items": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1
              },
              "text": {
                "type": "string"
              },
              "instruction": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "text"
            ]
          }
        }
      },
      "required": [
        "provider",
        "task",
        "model",
        "items"
      ]
    },
    "CompleteResult": {
      "description": "One entry per requested item. model is the model name the provider reports. The host compares it with the author model, as policies.md section 1.5 requires.",
      "type": "object",
      "properties": {
        "results": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "item": {
                "type": "string",
                "minLength": 1
              },
              "text": {
                "type": "string"
              },
              "model": {
                "type": "string",
                "minLength": 1
              },
              "error": {
                "$ref": "#/$defs/ErrorObject"
              }
            },
            "required": [
              "item"
            ],
            "if": {
              "not": {
                "required": [
                  "error"
                ]
              }
            },
            "then": {
              "required": [
                "text",
                "model"
              ]
            }
          }
        }
      },
      "required": [
        "results"
      ]
    },
    "RecipeParams": {
      "description": "recipe/plan. Plan the files that set up one agent harness. The plugin writes nothing; the host applies the plan. options holds the flags of the setup command.",
      "type": "object",
      "properties": {
        "recipe": {
          "$ref": "#/$defs/HookId"
        },
        "harness": {
          "type": "string",
          "minLength": 1
        },
        "options": {
          "type": "object"
        }
      },
      "required": [
        "recipe",
        "harness"
      ]
    },
    "RecipeFile": {
      "description": "One planned file operation. path is relative to the project root, with no .. segment, no drive letter and no backslash. write creates or replaces the file. merge replaces a block that carries a slopvac marker and creates the file otherwise. remove deletes the file or the block. content is required for write and merge.",
      "type": "object",
      "properties": {
        "path": {
          "type": "string",
          "pattern": "^(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!(.*/)?\\.\\.(/|(?![\\s\\S]))).+(?![\\s\\S])"
        },
        "action": {
          "enum": [
            "write",
            "merge",
            "remove"
          ]
        },
        "content": {
          "type": "string"
        }
      },
      "required": [
        "path",
        "action"
      ],
      "if": {
        "properties": {
          "action": {
            "enum": [
              "write",
              "merge"
            ]
          }
        }
      },
      "then": {
        "required": [
          "content"
        ]
      }
    },
    "RecipeResult": {
      "description": "The plan. The host shows it, checks every path against the project root after symlink resolution, and applies it only when the command allows writes.",
      "type": "object",
      "properties": {
        "files": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RecipeFile"
          }
        }
      },
      "required": [
        "files"
      ]
    },
    "Call": {
      "description": "A request or notification, dispatched on method. A request carries an id and a notification does not. An unknown method is not a schema error: a reader answers -32601 to a request and drops a notification.",
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "method"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "method": {
                "const": "initialize"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/InitializeParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "initialized"
              }
            }
          },
          "then": {
            "not": {
              "required": [
                "id"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "shutdown"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              }
            },
            "required": [
              "id"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "exit"
              }
            }
          },
          "then": {
            "not": {
              "required": [
                "id"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "$/cancelRequest"
              }
            }
          },
          "then": {
            "properties": {
              "params": {
                "$ref": "#/$defs/CancelParams"
              }
            },
            "required": [
              "params"
            ],
            "not": {
              "required": [
                "id"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "tagger/tag"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/TagParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "extractor/extract"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/ExtractParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "reporter/render"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/RenderParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "fixer/fix"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/FixParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "scorer/score"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/ScoreParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "provider/complete"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/CompleteParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "recipe/plan"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/RecipeParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "method": {
                "const": "binary-extractor/extract"
              }
            }
          },
          "then": {
            "properties": {
              "id": {
                "$ref": "#/$defs/RequestId"
              },
              "params": {
                "$ref": "#/$defs/BinaryExtractParams"
              }
            },
            "required": [
              "id",
              "params"
            ]
          }
        }
      ]
    },
    "PluginDeclaration": {
      "description": "Pre-spawn declaration. The plugin manifest embeds it, and the manifest is part of the content that `slopvac plugins trust` hashes (plugin-manifest schema, owner slopvac-8l4.2.4). The host decides whether to spawn from this declaration, never from the initialize reply. network true allows the plugin to open connections, and the host does not spawn it in offline mode. hooks lists every hook the plugin may offer. features lists the features it may require or request. The initialize reply must stay inside the declaration.",
      "type": "object",
      "properties": {
        "network": {
          "type": "boolean"
        },
        "hooks": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/HookDecl"
          }
        },
        "features": {
          "type": "object",
          "properties": {
            "required": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/FeatureName"
              },
              "uniqueItems": true
            },
            "optional": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/FeatureName"
              },
              "uniqueItems": true
            }
          },
          "required": [
            "required",
            "optional"
          ]
        }
      },
      "required": [
        "network",
        "hooks",
        "features"
      ]
    },
    "FixEdit": {
      "description": "An edit with the finding that authorizes it. finding is the zero-based index into the findings array of the same document in the request. The host accepts the edit only when span lies inside the span of that finding, endpoints included. A zero-width span is an insertion and follows the same rule.",
      "type": "object",
      "properties": {
        "finding": {
          "type": "integer",
          "minimum": 0
        },
        "span": {
          "$ref": "common.schema.json#/$defs/Span"
        },
        "text": {
          "type": "string"
        }
      },
      "required": [
        "finding",
        "span",
        "text"
      ]
    }
  }
}
