{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://simai.io/contracts/composition-recipe-v1/inputs.schema.json",
  "type": "object",
  "additionalProperties": false,
  "anyOf": [
    {
      "properties": {
        "schema": {
          "const": "simai.composition.inputs.v1"
        }
      }
    },
    {
      "required": [
        "schema_version"
      ]
    }
  ],
  "properties": {
    "schema": {
      "enum": [
        "simai.composition.inputs.v1",
        "simai.composition.inputs"
      ],
      "description": "The format: simai.composition.inputs with schema_version 1. The older label simai.composition.inputs.v1 is read until the change journal retires it (names carry no version, 2026-10-11; Recipe 1.1.0)."
    },
    "schema_version": {
      "const": 1
    },
    "scope": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "values": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$"
      },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "kind": {
                "enum": [
                  "parameter",
                  "setting",
                  "content"
                ]
              },
              "value": {
                "$ref": "https://simai.io/contracts/composition-recipe-v1/common.schema.json#/$defs/json"
              },
              "valueDigest": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$"
              },
              "origin": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "scope": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "owner": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "revision": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  }
                },
                "required": [
                  "scope",
                  "owner",
                  "ref",
                  "revision"
                ]
              },
              "extensions": {
                "type": "object",
                "propertyNames": {
                  "pattern": "^[a-z][a-z0-9.-]*:[a-z][a-z0-9._-]*$"
                }
              }
            },
            "required": [
              "kind",
              "value",
              "valueDigest"
            ],
            "allOf": [
              {
                "if": {
                  "properties": {
                    "kind": {
                      "enum": [
                        "setting",
                        "content"
                      ]
                    }
                  }
                },
                "then": {
                  "required": [
                    "origin"
                  ]
                }
              }
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "status": {
                "const": "missing"
              },
              "logicalSource": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "scope": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "owner": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "ref": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  }
                },
                "required": [
                  "scope",
                  "owner",
                  "ref"
                ]
              }
            },
            "required": [
              "status"
            ]
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "status": {
                "enum": [
                  "access_denied",
                  "source_error"
                ]
              }
            },
            "required": [
              "status"
            ]
          }
        ]
      },
      "maxProperties": 256
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9.-]*:[a-z][a-z0-9._-]*$"
      }
    }
  },
  "required": [
    "schema",
    "scope",
    "values"
  ]
}
