{
  "$defs": {
    "acceptedOutcome": {
      "additionalProperties": false,
      "properties": {
        "model": {
          "$ref": "#/$defs/model"
        },
        "status": {
          "const": "accepted"
        }
      },
      "required": [
        "status",
        "model"
      ],
      "type": "object"
    },
    "diagnostic": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "pattern": "^[A-Z]{2}[0-9]{4}$",
          "type": "string"
        },
        "graphPath": {
          "oneOf": [
            {
              "items": {
                "maxLength": 4096,
                "minLength": 1,
                "type": "string",
                "x-eqiora-maxUtf8Bytes": 4096
              },
              "maxItems": 256,
              "type": "array"
            },
            {
              "type": "null"
            }
          ]
        },
        "message": {
          "maxLength": 1048576,
          "minLength": 1,
          "type": "string",
          "x-eqiora-maxUtf8Bytes": 1048576
        },
        "patch": {
          "oneOf": [
            {
              "$ref": "#/$defs/patch"
            },
            {
              "type": "null"
            }
          ]
        },
        "severity": {
          "enum": [
            "error",
            "warning",
            "note"
          ]
        },
        "source": {
          "enum": [
            "control",
            "kernel"
          ]
        },
        "span": {
          "oneOf": [
            {
              "$ref": "#/$defs/sourceSpan"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "source",
        "severity",
        "code",
        "message",
        "graphPath",
        "span",
        "patch"
      ],
      "type": "object"
    },
    "model": {
      "additionalProperties": false,
      "properties": {
        "digest": {
          "pattern": "^[0-9a-f]{64}$",
          "type": "string"
        },
        "modelId": {
          "maxLength": 128,
          "minLength": 1,
          "type": "string"
        },
        "schema": {
          "const": "eqiora.model-envelope/v8"
        },
        "semanticRevision": {
          "minimum": 0,
          "type": "integer"
        },
        "transactionSchema": {
          "const": "eqiora.model-transaction-envelope/v8"
        }
      },
      "required": [
        "schema",
        "transactionSchema",
        "digest",
        "modelId",
        "semanticRevision"
      ],
      "type": "object"
    },
    "patch": {
      "additionalProperties": false,
      "properties": {
        "summary": {
          "maxLength": 4096,
          "minLength": 1,
          "type": "string",
          "x-eqiora-maxUtf8Bytes": 4096
        }
      },
      "required": [
        "summary"
      ],
      "type": "object"
    },
    "rejectedOutcome": {
      "additionalProperties": false,
      "properties": {
        "diagnostics": {
          "items": {
            "$ref": "#/$defs/diagnostic"
          },
          "maxItems": 1024,
          "minItems": 1,
          "type": "array"
        },
        "status": {
          "const": "rejected"
        }
      },
      "required": [
        "status",
        "diagnostics"
      ],
      "type": "object"
    },
    "request": {
      "additionalProperties": false,
      "properties": {
        "command": {
          "const": "model.compile-check/v1"
        },
        "filename": {
          "maxLength": 4096,
          "minLength": 1,
          "type": "string",
          "x-eqiora-maxUtf8Bytes": 4096
        },
        "protocol": {
          "const": "eqiora.control/v2"
        },
        "requestId": {
          "$ref": "#/$defs/requestId"
        },
        "source": {
          "maxLength": 8388608,
          "type": "string",
          "x-eqiora-maxUtf8Bytes": 8388608
        }
      },
      "required": [
        "protocol",
        "command",
        "requestId",
        "filename",
        "source"
      ],
      "type": "object",
      "x-eqiora-maxEncodedUtf8Bytes": 8404992
    },
    "requestId": {
      "maxLength": 128,
      "minLength": 1,
      "pattern": "^[A-Za-z0-9._:-]+$",
      "type": "string"
    },
    "response": {
      "additionalProperties": false,
      "properties": {
        "command": {
          "const": "model.compile-check/v1"
        },
        "outcome": {
          "oneOf": [
            {
              "$ref": "#/$defs/acceptedOutcome"
            },
            {
              "$ref": "#/$defs/rejectedOutcome"
            }
          ]
        },
        "protocol": {
          "const": "eqiora.control/v2"
        },
        "requestId": {
          "$ref": "#/$defs/requestId"
        }
      },
      "required": [
        "protocol",
        "command",
        "requestId",
        "outcome"
      ],
      "type": "object",
      "x-eqiora-maxEncodedUtf8Bytes": 8404992
    },
    "sourceSpan": {
      "additionalProperties": false,
      "properties": {
        "end": {
          "maximum": 4294967295,
          "minimum": 0,
          "type": "integer"
        },
        "file": {
          "maxLength": 4096,
          "type": "string",
          "x-eqiora-maxUtf8Bytes": 4096
        },
        "start": {
          "maximum": 4294967295,
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "file",
        "start",
        "end"
      ],
      "type": "object"
    }
  },
  "$id": "urn:eqiora:schema:control:compile-v2",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Closed control-plane request and response. Scientific arrays, meshes, Fields, and trajectories are excluded.",
  "oneOf": [
    {
      "$ref": "#/$defs/request"
    },
    {
      "$ref": "#/$defs/response"
    }
  ],
  "title": "Eqiora compile/check control protocol v2"
}
