{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oddpalette.com/style-recipe.schema.json",
  "title": "Odd Palette portable style document v2",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "schema",
    "formatVersion",
    "recipe",
    "promptCompiler",
    "provenance",
    "compatibility"
  ],
  "properties": {
    "$schema": {
      "const": "https://oddpalette.com/style-recipe.schema.json"
    },
    "schema": {
      "const": "odd-palette/style/v2"
    },
    "formatVersion": {
      "const": 2
    },
    "promptCompiler": {
      "enum": [
        "style-contract/2",
        "style-contract/3"
      ]
    },
    "recipe": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "palette",
        "texture",
        "rules",
        "avoid"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 100,
          "minLength": 1
        },
        "palette": {
          "type": "string",
          "maxLength": 5000
        },
        "texture": {
          "type": "string",
          "maxLength": 5000
        },
        "rules": {
          "type": "string",
          "maxLength": 5000
        },
        "avoid": {
          "type": "string",
          "maxLength": 5000
        }
      }
    },
    "provenance": {
      "type": "object",
      "description": "Saved exports include immutable version, SHA-256 of the separately supplied reference, and next-generation settings. An empty object is a draft with no verified source.",
      "additionalProperties": false,
      "properties": {
        "state": {
          "enum": [
            "saved",
            "draft"
          ]
        },
        "versionId": {
          "type": "string"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "exportedAt": {
          "type": "string",
          "format": "date-time"
        },
        "reference": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "sha256",
            "mime",
            "byteLength"
          ],
          "properties": {
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "mime": {
              "enum": [
                "image/png",
                "image/jpeg",
                "image/webp"
              ]
            },
            "byteLength": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "analysis": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": false,
          "properties": {
            "model": {
              "type": "string"
            },
            "createdAt": {
              "type": "string",
              "format": "date-time"
            }
          }
        },
        "generation": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "provider",
            "model",
            "size",
            "quality",
            "resolution",
            "promptTemplate",
            "settingsPurpose"
          ],
          "properties": {
            "provider": {
              "const": "xAI"
            },
            "model": {
              "type": "string"
            },
            "size": {
              "enum": [
                "1024x1024",
                "1024x1536",
                "1536x1024"
              ]
            },
            "quality": {
              "enum": [
                "low",
                "medium",
                "auto"
              ]
            },
            "resolution": {
              "const": "1k"
            },
            "promptTemplate": {
              "type": "string"
            },
            "settingsPurpose": {
              "type": "string"
            }
          }
        }
      }
    },
    "compatibility": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "native",
        "otherTools",
        "reference",
        "reproducibility"
      ],
      "properties": {
        "native": {
          "type": "string"
        },
        "otherTools": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "reproducibility": {
          "type": "string"
        }
      }
    }
  }
}
