{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/geniusdecision-app/json-schema/geniusdecision-app-choice-model-schema.json",
  "title": "ChoiceModel",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/geniusdecision-app-openapi.json#/components/schemas/ChoiceModel",
  "type": "object",
  "properties": {
    "context": {
      "type": "object",
      "properties": {
        "question": {
          "type": "string",
          "minLength": 1,
          "maxLength": 600
        },
        "category": {
          "enum": [
            "leisure",
            "personal_organization"
          ]
        },
        "horizon": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      },
      "required": [
        "question",
        "category",
        "horizon"
      ],
      "additionalProperties": false
    },
    "criteria": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_]{0,31}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "unit": {
            "type": "string",
            "minLength": 1,
            "maxLength": 30
          },
          "direction": {
            "enum": [
              "min",
              "max"
            ]
          },
          "limit": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^(?:0|[1-9][0-9]*)(?:\\.[0-9]+|/[1-9][0-9]*)?$",
            "maxLength": 32,
            "description": "Nonnegative exact quantity <= 1000000, denominator <= 1000000; null stays unknown."
          }
        },
        "required": [
          "id",
          "label",
          "unit",
          "direction",
          "limit"
        ],
        "additionalProperties": false
      }
    },
    "alternatives": {
      "type": "array",
      "minItems": 2,
      "maxItems": 8,
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_]{0,31}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "source": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "values": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ],
              "pattern": "^(?:0|[1-9][0-9]*)(?:\\.[0-9]+|/[1-9][0-9]*)?$",
              "maxLength": 32,
              "description": "Nonnegative exact quantity <= 1000000, denominator <= 1000000; null stays unknown."
            },
            "description": "Exactly one entry per declared criterion ID; same unit for every alternative."
          }
        },
        "required": [
          "id",
          "label",
          "source",
          "values"
        ],
        "additionalProperties": false
      }
    },
    "selection": {
      "type": "object",
      "properties": {
        "mode": {
          "enum": [
            "unique",
            "lexicographic"
          ]
        },
        "criteria_order": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_]{0,31}$"
          },
          "maxItems": 5,
          "uniqueItems": true,
          "description": "Empty for unique; permutation of all criteria for lexicographic."
        }
      },
      "required": [
        "mode",
        "criteria_order"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "context",
    "criteria",
    "alternatives",
    "selection"
  ],
  "additionalProperties": false
}