{
  "$defs": {
    "DimSpec": {
      "additionalProperties": false,
      "properties": {
        "freq": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Freq"
        },
        "kind": {
          "default": "categorical",
          "enum": [
            "categorical",
            "time",
            "integer",
            "float",
            "index"
          ],
          "title": "Kind",
          "type": "string"
        },
        "policy": {
          "default": "fixed",
          "enum": [
            "fixed",
            "extend",
            "new_levels"
          ],
          "title": "Policy",
          "type": "string"
        }
      },
      "title": "DimSpec",
      "type": "object"
    },
    "InputVar": {
      "additionalProperties": false,
      "description": "A variable the workflow reads. ``required: false`` makes it optional: absent gives a warning.",
      "properties": {
        "dims": {
          "items": {
            "type": "string"
          },
          "title": "Dims",
          "type": "array"
        },
        "dtype": {
          "default": "float64",
          "title": "Dtype",
          "type": "string"
        },
        "missing": {
          "default": "forbid",
          "enum": [
            "forbid",
            "allow",
            "mask"
          ],
          "title": "Missing",
          "type": "string"
        },
        "required": {
          "default": true,
          "title": "Required",
          "type": "boolean"
        },
        "role": {
          "default": "covariate",
          "enum": [
            "target",
            "covariate",
            "media",
            "spend",
            "control",
            "index",
            "mask",
            "constant",
            "weight",
            "exposure"
          ],
          "title": "Role",
          "type": "string"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Units"
        }
      },
      "title": "InputVar",
      "type": "object"
    },
    "LevelSet": {
      "additionalProperties": false,
      "description": "A categorical column's levels without the values: the sha256 (hex) of the canonical JSON of the sorted\nunique non-null level values (as strings), their count, and the sorted sha256 of each level's canonical JSON\n(empty in contracts written before per-level hashes; the check then compares the set hash and count only).",
      "properties": {
        "count": {
          "minimum": 0,
          "title": "Count",
          "type": "integer"
        },
        "hashes": {
          "description": "sha256 (hex) of each level's canonical JSON string, sorted; never values.",
          "items": {
            "pattern": "^[0-9a-f]{64}$",
            "type": "string"
          },
          "title": "Hashes",
          "type": "array"
        },
        "sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Sha256",
          "type": "string"
        }
      },
      "required": [
        "sha256",
        "count"
      ],
      "title": "LevelSet",
      "type": "object"
    }
  },
  "$id": "https://schemas.ump.dev/v1/input-contract.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "What new input must look like for a saved workflow to rerun on it.",
  "properties": {
    "dims": {
      "additionalProperties": {
        "$ref": "#/$defs/DimSpec"
      },
      "title": "Dims",
      "type": "object"
    },
    "extra": {
      "default": "drop",
      "description": "Columns the contract does not name: drop (info note) or allow (passed silently). Never a failure.",
      "enum": [
        "allow",
        "drop"
      ],
      "title": "Extra",
      "type": "string"
    },
    "key": {
      "description": "Columns that identify a row (each one required); empty means the time column plus the categorical dims.",
      "items": {
        "type": "string"
      },
      "title": "Key",
      "type": "array"
    },
    "level_sets": {
      "additionalProperties": {
        "$ref": "#/$defs/LevelSet"
      },
      "description": "Trained level set per fixed categorical dim (hash and count, never values).",
      "title": "Level Sets",
      "type": "object"
    },
    "min_rows": {
      "anyOf": [
        {
          "minimum": 0,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Fewest rows the workflow expects (proposed; below it is a warning).",
      "title": "Min Rows"
    },
    "schema_version": {
      "default": "ump.input_contract/0.1",
      "title": "Schema Version",
      "type": "string"
    },
    "target": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The target column; required to refit, not to score.",
      "title": "Target"
    },
    "target_dtype": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The target's dtype; on a refit the target must cast to it and have no missing values.",
      "title": "Target Dtype"
    },
    "time": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The time column, if any; its dim (policy, freq) is in dims.",
      "title": "Time"
    },
    "vars": {
      "additionalProperties": {
        "$ref": "#/$defs/InputVar"
      },
      "title": "Vars",
      "type": "object"
    }
  },
  "title": "InputContract",
  "type": "object"
}
