{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aiwg.io/schemas/decision/DecisionDefinition.v1alpha1.schema.json",
  "type": "object",
  "properties": {
    "apiVersion": {
      "const": "decision.aiwg.io/v1alpha1"
    },
    "kind": {
      "const": "DecisionDefinition"
    },
    "metadata": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$"
        },
        "description": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "id",
        "version",
        "description"
      ],
      "additionalProperties": false
    },
    "spec": {
      "type": "object",
      "properties": {
        "purpose": {
          "type": "string",
          "minLength": 1
        },
        "inputSchema": {
          "type": "object"
        },
        "question": {
          "type": "string",
          "minLength": 1
        },
        "answer": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "choice"
                },
                "options": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "description": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "id",
                      "description"
                    ],
                    "additionalProperties": false
                  },
                  "minItems": 2,
                  "maxItems": 255
                }
              },
              "required": [
                "kind",
                "options"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "ordinal-score"
                },
                "levels": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  },
                  "minItems": 2,
                  "maxItems": 10
                }
              },
              "required": [
                "kind",
                "levels"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "truth-probability"
                },
                "trueDescription": {
                  "type": "string",
                  "minLength": 1
                },
                "falseDescription": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "kind",
                "trueDescription",
                "falseDescription"
              ],
              "additionalProperties": false
            }
          ]
        },
        "requiredCapabilities": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        }
      },
      "required": [
        "purpose",
        "inputSchema",
        "question",
        "answer",
        "requiredCapabilities"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "spec"
  ],
  "additionalProperties": false
}
