{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/math.percentage.agent.input.json",
  "title": "Percentage — agent input",
  "description": "Seven percentage modes; each needs its two active fields. Decimal strings up to512 characters or finite binary64 numbers; aliases must agree after normalization. Reject nonzero conversion/output underflow, overflow, zero denominator and negative difference operands. Difference average and change delta must also be representable. Explicit zero canonicalizes to +0. (calculation_version 1.2.0)",
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "of"
        },
        "p": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ],
          "x-unit": "%",
          "x-unit-id": "cx:percent",
          "x-quantity-kind": "ratio",
          "x-role": "scalar",
          "x-dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "x-uuce-unit": {
            "unit_id": "cx:percent",
            "revision": "1.0.0",
            "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
            "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
            "quantity_kind": "ratio",
            "dimension": [
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "registry_version": "0.3.0-preview.3",
            "digest_contract": "calculatorx-unit-definition-digests-v2",
            "registry_status": "preview",
            "definition_lifecycle": "candidate",
            "role": "scalar"
          }
        },
        "x": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        }
      },
      "required": [
        "mode",
        "p",
        "x"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "is-what"
        },
        "x": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        },
        "y": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        }
      },
      "required": [
        "mode",
        "x",
        "y"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "of-what"
        },
        "x": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        },
        "p": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ],
          "x-unit": "%",
          "x-unit-id": "cx:percent",
          "x-quantity-kind": "ratio",
          "x-role": "scalar",
          "x-dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "x-uuce-unit": {
            "unit_id": "cx:percent",
            "revision": "1.0.0",
            "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
            "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
            "quantity_kind": "ratio",
            "dimension": [
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "registry_version": "0.3.0-preview.3",
            "digest_contract": "calculatorx-unit-definition-digests-v2",
            "registry_status": "preview",
            "definition_lifecycle": "candidate",
            "role": "scalar"
          }
        }
      },
      "required": [
        "mode",
        "x",
        "p"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "change"
        },
        "oldV": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        },
        "newV": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        }
      },
      "required": [
        "mode",
        "oldV",
        "newV"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "adjust-up"
        },
        "x": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        },
        "p": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ],
          "x-unit": "%",
          "x-unit-id": "cx:percent",
          "x-quantity-kind": "ratio",
          "x-role": "scalar",
          "x-dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "x-uuce-unit": {
            "unit_id": "cx:percent",
            "revision": "1.0.0",
            "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
            "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
            "quantity_kind": "ratio",
            "dimension": [
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "registry_version": "0.3.0-preview.3",
            "digest_contract": "calculatorx-unit-definition-digests-v2",
            "registry_status": "preview",
            "definition_lifecycle": "candidate",
            "role": "scalar"
          }
        }
      },
      "required": [
        "mode",
        "x",
        "p"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "adjust-down"
        },
        "x": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        },
        "p": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ],
          "x-unit": "%",
          "x-unit-id": "cx:percent",
          "x-quantity-kind": "ratio",
          "x-role": "scalar",
          "x-dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "x-uuce-unit": {
            "unit_id": "cx:percent",
            "revision": "1.0.0",
            "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
            "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
            "quantity_kind": "ratio",
            "dimension": [
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "registry_version": "0.3.0-preview.3",
            "digest_contract": "calculatorx-unit-definition-digests-v2",
            "registry_status": "preview",
            "definition_lifecycle": "candidate",
            "role": "scalar"
          }
        }
      },
      "required": [
        "mode",
        "x",
        "p"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "const": "difference"
        },
        "a": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        },
        "b": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "pattern": "^\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$"
            }
          ]
        }
      },
      "required": [
        "mode",
        "a",
        "b"
      ]
    }
  ],
  "x-unit-contract": {
    "protocol": "calculatorx-field-unit-contract-v1",
    "capability_id": "math.percentage",
    "registry_version": "0.3.0-preview.3",
    "declaration_scope": "Field/branch declarations only; inactive fields are not asserted to exist. No conversion-engine migration or new numerical certification.",
    "path_format": "Paths relative to inputs or result_detail.value; dot separates properties, * denotes array items, $ denotes a scalar result.",
    "inputs": {
      "p": {
        "unit": "%",
        "reference": {
          "unit_id": "cx:percent",
          "revision": "1.0.0",
          "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
          "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
          "quantity_kind": "ratio",
          "dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "registry_version": "0.3.0-preview.3",
          "digest_contract": "calculatorx-unit-definition-digests-v2",
          "registry_status": "preview",
          "definition_lifecycle": "candidate",
          "role": "scalar"
        }
      },
      "pInput": {
        "unit": "%",
        "reference": {
          "unit_id": "cx:percent",
          "revision": "1.0.0",
          "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
          "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
          "quantity_kind": "ratio",
          "dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "registry_version": "0.3.0-preview.3",
          "digest_contract": "calculatorx-unit-definition-digests-v2",
          "registry_status": "preview",
          "definition_lifecycle": "candidate",
          "role": "scalar"
        }
      },
      "P": {
        "unit": "%",
        "reference": {
          "unit_id": "cx:percent",
          "revision": "1.0.0",
          "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
          "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
          "quantity_kind": "ratio",
          "dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "registry_version": "0.3.0-preview.3",
          "digest_contract": "calculatorx-unit-definition-digests-v2",
          "registry_status": "preview",
          "definition_lifecycle": "candidate",
          "role": "scalar"
        }
      },
      "percent": {
        "unit": "%",
        "reference": {
          "unit_id": "cx:percent",
          "revision": "1.0.0",
          "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
          "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
          "quantity_kind": "ratio",
          "dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "registry_version": "0.3.0-preview.3",
          "digest_contract": "calculatorx-unit-definition-digests-v2",
          "registry_status": "preview",
          "definition_lifecycle": "candidate",
          "role": "scalar"
        }
      }
    },
    "outputs": {
      "P": {
        "unit": "%",
        "reference": {
          "unit_id": "cx:percent",
          "revision": "1.0.0",
          "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
          "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
          "quantity_kind": "ratio",
          "dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "registry_version": "0.3.0-preview.3",
          "digest_contract": "calculatorx-unit-definition-digests-v2",
          "registry_status": "preview",
          "definition_lifecycle": "candidate",
          "role": "scalar"
        }
      },
      "percent_change": {
        "unit": "%",
        "reference": {
          "unit_id": "cx:percent",
          "revision": "1.0.0",
          "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
          "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
          "quantity_kind": "ratio",
          "dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "registry_version": "0.3.0-preview.3",
          "digest_contract": "calculatorx-unit-definition-digests-v2",
          "registry_status": "preview",
          "definition_lifecycle": "candidate",
          "role": "scalar"
        }
      },
      "percent_difference": {
        "unit": "%",
        "reference": {
          "unit_id": "cx:percent",
          "revision": "1.0.0",
          "content_digest": "f73c887f011a6f997b183701a1b03417b3c89a863747910a54ae79c6a6b9f963",
          "dependency_digest": "58d9bc109880e0c8ea6d45264fbba933f64a17cf17586d2a8dbbf7cbea14566d",
          "quantity_kind": "ratio",
          "dimension": [
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ],
          "registry_version": "0.3.0-preview.3",
          "digest_contract": "calculatorx-unit-definition-digests-v2",
          "registry_status": "preview",
          "definition_lifecycle": "candidate",
          "role": "scalar"
        }
      }
    },
    "scalar_result_policy": "result.value is percent only in percentage-solving modes; in amount-solving modes it inherits the amount unit. Follow the selected mode and result.unit."
  }
}
