{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pipelinexlab.com/contracts/document-compute-request.v1.schema.json",
  "title": "Document compute request V1",
  "description": "Shape only. Core normalizes BCP 47 tags and language sets, validates strictly increasing page indices and different translation languages, and owns canonical request identity. Runtime verifies exact source, installed processor and current authority.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "kind",
    "source",
    "processor",
    "operation"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "kind": {
      "const": "document-compute"
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "target",
        "contentRef",
        "size"
      ],
      "properties": {
        "target": {
          "$ref": "https://pipelinexlab.com/contracts/document-application-snapshot.v1.schema.json#/properties/target"
        },
        "contentRef": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        }
      }
    },
    "processor": {
      "$ref": "https://pipelinexlab.com/contracts/document-analysis.v1.schema.json#/$defs/analysis/properties/processor"
    },
    "operation": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "pages",
            "languages"
          ],
          "properties": {
            "kind": {
              "const": "extract"
            },
            "pages": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "integer",
                "minimum": 0,
                "maximum": 4294967295
              }
            },
            "languages": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "pages",
            "analysisRef",
            "sourceLanguage",
            "targetLanguage"
          ],
          "properties": {
            "kind": {
              "const": "translate"
            },
            "pages": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "integer",
                "minimum": 0,
                "maximum": 4294967295
              }
            },
            "analysisRef": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "sourceLanguage": {
              "type": "string",
              "minLength": 1
            },
            "targetLanguage": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      ]
    }
  }
}
