{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/math.pythagorean/1.1.2/output.json",
  "title": "Pythagorean theorem — success output",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "status",
    "capability_id",
    "engine",
    "inputs",
    "result",
    "result_detail",
    "calculation_version",
    "verification"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Requested tool id"
    },
    "status": {
      "const": "success"
    },
    "capability_id": {
      "const": "math.pythagorean"
    },
    "tool": {
      "type": "string",
      "description": "Requested tool id"
    },
    "engine": {
      "type": "string"
    },
    "inputs": {
      "type": "object",
      "description": "Normalized calculation inputs (aliases resolved)"
    },
    "result": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "value"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "success",
            "invalid"
          ],
          "description": "Engine result status. Envelope status remains success when verify reports invalid."
        },
        "value": {
          "type": [
            "number",
            "null"
          ],
          "description": "Solved side length; null when verify fails",
          "x-quantity-kind": "length",
          "x-role": "solved_side",
          "x-dimension": "L"
        },
        "a": {
          "type": "number",
          "description": "Leg length a",
          "x-quantity-kind": "length",
          "x-role": "leg",
          "x-dimension": "L"
        },
        "b": {
          "type": "number",
          "description": "Leg length b",
          "x-quantity-kind": "length",
          "x-role": "leg",
          "x-dimension": "L"
        },
        "c": {
          "type": [
            "number",
            "null"
          ],
          "description": "Hypotenuse length c",
          "x-quantity-kind": "length",
          "x-role": "hypotenuse",
          "x-dimension": "L"
        },
        "area": {
          "type": [
            "number",
            "null"
          ],
          "description": "Triangle area ab/2; null when the product exceeds binary64",
          "x-quantity-kind": "area",
          "x-dimension": "L^2"
        },
        "perimeter": {
          "type": [
            "number",
            "null"
          ],
          "description": "Perimeter a+b+c; null when a side exceeds binary64",
          "x-quantity-kind": "length",
          "x-role": "perimeter",
          "x-dimension": "L"
        },
        "mode": {
          "type": "string",
          "enum": [
            "solve",
            "verify"
          ]
        },
        "valid": {
          "type": "boolean"
        },
        "solve_for": {
          "type": [
            "string",
            "null"
          ]
        },
        "mode_label": {
          "type": "string"
        },
        "formula": {
          "type": "string"
        },
        "heading": {
          "type": "string"
        },
        "message": {
          "type": [
            "string",
            "null"
          ]
        },
        "explainer": {
          "type": "string"
        },
        "inputs_summary": {
          "type": "string"
        },
        "steps": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "radicand": {
          "type": [
            "number",
            "null"
          ]
        },
        "exact": {
          "type": [
            "string",
            "null"
          ]
        },
        "calculation_version": {
          "type": "string"
        },
        "display": {
          "type": "object"
        },
        "triangle": {
          "type": "object"
        },
        "verify_evidence": {
          "type": "object"
        }
      }
    },
    "result_detail": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value",
        "unit",
        "formatted"
      ],
      "properties": {
        "value": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "value"
          ],
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "success",
                "invalid"
              ],
              "description": "Engine result status. Envelope status remains success when verify reports invalid."
            },
            "value": {
              "type": [
                "number",
                "null"
              ],
              "description": "Solved side length; null when verify fails",
              "x-quantity-kind": "length",
              "x-role": "solved_side",
              "x-dimension": "L"
            },
            "a": {
              "type": "number",
              "description": "Leg length a",
              "x-quantity-kind": "length",
              "x-role": "leg",
              "x-dimension": "L"
            },
            "b": {
              "type": "number",
              "description": "Leg length b",
              "x-quantity-kind": "length",
              "x-role": "leg",
              "x-dimension": "L"
            },
            "c": {
              "type": [
                "number",
                "null"
              ],
              "description": "Hypotenuse length c",
              "x-quantity-kind": "length",
              "x-role": "hypotenuse",
              "x-dimension": "L"
            },
            "area": {
              "type": [
                "number",
                "null"
              ],
              "description": "Triangle area ab/2; null when the product exceeds binary64",
              "x-quantity-kind": "area",
              "x-dimension": "L^2"
            },
            "perimeter": {
              "type": [
                "number",
                "null"
              ],
              "description": "Perimeter a+b+c; null when a side exceeds binary64",
              "x-quantity-kind": "length",
              "x-role": "perimeter",
              "x-dimension": "L"
            },
            "mode": {
              "type": "string",
              "enum": [
                "solve",
                "verify"
              ]
            },
            "valid": {
              "type": "boolean"
            },
            "solve_for": {
              "type": [
                "string",
                "null"
              ]
            },
            "mode_label": {
              "type": "string"
            },
            "formula": {
              "type": "string"
            },
            "heading": {
              "type": "string"
            },
            "message": {
              "type": [
                "string",
                "null"
              ]
            },
            "explainer": {
              "type": "string"
            },
            "inputs_summary": {
              "type": "string"
            },
            "steps": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "radicand": {
              "type": [
                "number",
                "null"
              ]
            },
            "exact": {
              "type": [
                "string",
                "null"
              ]
            },
            "calculation_version": {
              "type": "string"
            },
            "display": {
              "type": "object"
            },
            "triangle": {
              "type": "object"
            },
            "verify_evidence": {
              "type": "object"
            }
          }
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "formatted": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "formula": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "string"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "id": {
              "type": "string"
            },
            "expression": {
              "type": "string"
            },
            "label": {
              "type": "string"
            }
          }
        }
      ]
    },
    "assumptions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "severity": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "suggestion": {
            "type": "string"
          }
        }
      }
    },
    "verification": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "tier",
        "engine_tested",
        "expert_reviewed",
        "source_checked",
        "reviewed_by",
        "reviewer_role",
        "last_reviewed"
      ],
      "properties": {
        "tier": {
          "type": "string",
          "enum": [
            "candidate",
            "engine_tested",
            "internally_reviewed",
            "expert_verified"
          ]
        },
        "engine_tested": {
          "type": "boolean"
        },
        "expert_reviewed": {
          "type": "boolean"
        },
        "internally_reviewed": {
          "type": "boolean"
        },
        "review_kind": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_checked": {
          "type": "boolean"
        },
        "reviewed_by": {
          "type": [
            "string",
            "null"
          ]
        },
        "reviewer_role": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_reviewed": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "tier": {
                "const": "expert_verified"
              }
            },
            "required": [
              "tier"
            ]
          },
          "then": {
            "properties": {
              "engine_tested": {
                "const": true
              },
              "expert_reviewed": {
                "const": true
              },
              "source_checked": {
                "const": true
              },
              "reviewed_by": {
                "type": "string",
                "minLength": 1
              },
              "reviewer_role": {
                "type": "string",
                "minLength": 1
              },
              "last_reviewed": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "tier": {
                "const": "internally_reviewed"
              }
            },
            "required": [
              "tier"
            ]
          },
          "then": {
            "properties": {
              "engine_tested": {
                "const": true
              },
              "internally_reviewed": {
                "const": true
              },
              "source_checked": {
                "const": true
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "tier": {
                "const": "engine_tested"
              }
            },
            "required": [
              "tier"
            ]
          },
          "then": {
            "properties": {
              "engine_tested": {
                "const": true
              }
            }
          }
        }
      ]
    },
    "calculation_version": {
      "type": "string",
      "const": "1.1.2"
    },
    "api_version": {
      "type": "string"
    },
    "api_contract_version": {
      "type": "string"
    },
    "spec_version": {
      "type": "string"
    },
    "page": {
      "type": [
        "string",
        "null"
      ],
      "description": "Canonical calculator page URL"
    },
    "links": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "schema_input": {
          "type": "string",
          "format": "uri"
        },
        "schema_output": {
          "type": "string",
          "format": "uri"
        },
        "evidence": {
          "type": "string",
          "format": "uri"
        },
        "openapi": {
          "type": "string",
          "format": "uri"
        },
        "capabilities": {
          "type": "string",
          "format": "uri"
        },
        "mcp": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  }
}
