{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/engineering.tolerance.stackup.input.json",
  "title": "Tolerance stack-up — input",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "mode": {
      "type": "string",
      "enum": [
        "rss",
        "worst_case"
      ]
    },
    "tol": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "description": "Basic mode: tolerance contributions (preferred). Same unit for all entries."
    },
    "tol1": {
      "type": "number"
    },
    "tol2": {
      "type": "number"
    },
    "tol3": {
      "type": "number"
    },
    "tol4": {
      "type": "number"
    },
    "tol5": {
      "type": "number"
    },
    "tol6": {
      "type": "number"
    },
    "tol7": {
      "type": "number"
    },
    "tol8": {
      "type": "number"
    },
    "dimensions": {
      "type": "array",
      "minItems": 1,
      "description": "Engineering mode: named dimensions with nominal, asymmetric ±tol, direction, and statistical_basis (legacy: distribution).",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          },
          "nom": {
            "type": "number"
          },
          "tol": {
            "type": "number",
            "description": "Symmetric shortcut: sets both tol_plus and tol_minus to |tol|"
          },
          "tol_plus": {
            "type": "number",
            "minimum": 0
          },
          "tol_minus": {
            "type": "number",
            "minimum": 0
          },
          "direction": {
            "description": "Stack sense: '+' / 1 adds; '−' / -1 subtracts",
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "+",
                  "-"
                ]
              },
              {
                "type": "integer",
                "enum": [
                  1,
                  -1
                ]
              }
            ]
          },
          "sense": {
            "type": "integer",
            "enum": [
              1,
              -1
            ],
            "description": "Legacy alias of direction"
          },
          "statistical_basis": {
            "type": "string",
            "description": "How bilateral half-range a=(T++T−)/2 maps into the RSS contributor. Default magnitude implies no coverage probability. Prefer this over distribution.",
            "enum": [
              "magnitude",
              "1sigma",
              "3sigma",
              "uniform"
            ],
            "default": "magnitude"
          },
          "distribution": {
            "type": "string",
            "deprecated": true,
            "description": "Deprecated alias of statistical_basis. Prefer statistical_basis. Legacy values (normal→1sigma, unknown→magnitude, rectangular→uniform) are still accepted by the engine.",
            "enum": [
              "magnitude",
              "1sigma",
              "3sigma",
              "uniform",
              "unspecified",
              "unknown",
              "normal",
              "gaussian",
              "rectangular",
              "rect",
              "rss_magnitude"
            ]
          }
        },
        "anyOf": [
          {
            "required": [
              "tol"
            ]
          },
          {
            "required": [
              "tol_plus",
              "tol_minus"
            ]
          },
          {
            "required": [
              "tol_plus"
            ]
          },
          {
            "required": [
              "tol_minus"
            ]
          }
        ]
      }
    }
  },
  "anyOf": [
    {
      "required": [
        "tol"
      ]
    },
    {
      "required": [
        "tol1"
      ]
    },
    {
      "required": [
        "dimensions"
      ]
    }
  ],
  "description": "1-D RSS or worst-case tolerance stack — Basic tol list or Engineering dimensions (nominal, ±tol, direction). (calculation_version 1.4.0)"
}
