{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/math.numerical.ode.output.json",
  "title": "Ordinary differential equation — 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.numerical.ode"
    },
    "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": [
        "method",
        "rhs",
        "t0",
        "t1",
        "y0",
        "n",
        "h",
        "y",
        "exact",
        "abs_err",
        "formula",
        "diagnostics",
        "warnings"
      ],
      "properties": {
        "method": {
          "enum": [
            "euler",
            "rk4"
          ]
        },
        "rhs": {
          "enum": [
            "linear",
            "poly"
          ]
        },
        "t0": {
          "type": "number"
        },
        "t1": {
          "type": "number"
        },
        "y0": {
          "type": "number"
        },
        "n": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10000
        },
        "h": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "exact": {
          "type": "number"
        },
        "abs_err": {
          "type": "number"
        },
        "k": {
          "type": "number"
        },
        "formula": {
          "type": "string"
        },
        "coeffs": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 1,
          "maxItems": 9
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "severity",
              "detail",
              "suggestion"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "severity": {
                "const": "warning"
              },
              "detail": {
                "type": "string"
              },
              "suggestion": {
                "type": "string"
              }
            }
          }
        },
        "diagnostics": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "reference_kind",
            "signed_error",
            "absolute_error",
            "relative_error",
            "stability",
            "accuracy_status"
          ],
          "properties": {
            "reference_kind": {
              "const": "closed_form"
            },
            "signed_error": {
              "type": "number"
            },
            "absolute_error": {
              "type": "number",
              "minimum": 0
            },
            "relative_error": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0
            },
            "accuracy_status": {
              "const": "not_assessed",
              "description": "No user-requested tolerance or adaptive error acceptance was tested. Stable does not mean accurate."
            },
            "stability": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "status",
                "z",
                "amplification_factor"
              ],
              "properties": {
                "status": {
                  "enum": [
                    "not_applicable",
                    "stable",
                    "oscillatory",
                    "unstable"
                  ]
                },
                "z": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "amplification_factor": {
                  "type": [
                    "number",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "rhs": {
                "const": "linear"
              }
            }
          },
          "then": {
            "required": [
              "k"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "rhs": {
                "const": "poly"
              }
            }
          },
          "then": {
            "required": [
              "coeffs"
            ]
          }
        }
      ]
    },
    "result_detail": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value",
        "unit",
        "formatted"
      ],
      "properties": {
        "value": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "method",
            "rhs",
            "t0",
            "t1",
            "y0",
            "n",
            "h",
            "y",
            "exact",
            "abs_err",
            "formula",
            "diagnostics",
            "warnings"
          ],
          "properties": {
            "method": {
              "enum": [
                "euler",
                "rk4"
              ]
            },
            "rhs": {
              "enum": [
                "linear",
                "poly"
              ]
            },
            "t0": {
              "type": "number"
            },
            "t1": {
              "type": "number"
            },
            "y0": {
              "type": "number"
            },
            "n": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000
            },
            "h": {
              "type": "number"
            },
            "y": {
              "type": "number"
            },
            "exact": {
              "type": "number"
            },
            "abs_err": {
              "type": "number"
            },
            "k": {
              "type": "number"
            },
            "formula": {
              "type": "string"
            },
            "coeffs": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "minItems": 1,
              "maxItems": 9
            },
            "warnings": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "code",
                  "severity",
                  "detail",
                  "suggestion"
                ],
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "severity": {
                    "const": "warning"
                  },
                  "detail": {
                    "type": "string"
                  },
                  "suggestion": {
                    "type": "string"
                  }
                }
              }
            },
            "diagnostics": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "reference_kind",
                "signed_error",
                "absolute_error",
                "relative_error",
                "stability",
                "accuracy_status"
              ],
              "properties": {
                "reference_kind": {
                  "const": "closed_form"
                },
                "signed_error": {
                  "type": "number"
                },
                "absolute_error": {
                  "type": "number",
                  "minimum": 0
                },
                "relative_error": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "minimum": 0
                },
                "accuracy_status": {
                  "const": "not_assessed",
                  "description": "No user-requested tolerance or adaptive error acceptance was tested. Stable does not mean accurate."
                },
                "stability": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "status",
                    "z",
                    "amplification_factor"
                  ],
                  "properties": {
                    "status": {
                      "enum": [
                        "not_applicable",
                        "stable",
                        "oscillatory",
                        "unstable"
                      ]
                    },
                    "z": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "amplification_factor": {
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "rhs": {
                    "const": "linear"
                  }
                }
              },
              "then": {
                "required": [
                  "k"
                ]
              }
            },
            {
              "if": {
                "properties": {
                  "rhs": {
                    "const": "poly"
                  }
                }
              },
              "then": {
                "required": [
                  "coeffs"
                ]
              }
            }
          ]
        },
        "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": false,
      "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"
          ]
        },
        "citation_kind": {
          "type": "string"
        },
        "expert_review": {
          "type": "string"
        },
        "domain_review": {
          "type": "string"
        },
        "calculation_version": {
          "type": "string"
        },
        "calc_tests": {
          "type": [
            "string",
            "null"
          ]
        },
        "tests_passed": {
          "type": [
            "integer",
            "null"
          ]
        },
        "tests_total": {
          "type": [
            "integer",
            "null"
          ]
        },
        "artifact_contract": {
          "type": [
            "string",
            "null"
          ]
        },
        "trust_peek": {
          "type": [
            "string",
            "null"
          ]
        },
        "verification_revision": {
          "type": [
            "string",
            "null"
          ]
        },
        "verified_scope": {
          "type": [
            "string",
            "null"
          ]
        },
        "evidence_digest": {
          "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.1"
    },
    "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"
        }
      }
    },
    "cvp": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "calculation_version",
        "verification_revision",
        "verified_scope",
        "evidence_digest",
        "evidence",
        "verification_status",
        "production_freshness"
      ],
      "properties": {
        "calculation_version": {
          "type": [
            "string",
            "null"
          ]
        },
        "verification_revision": {
          "type": [
            "string",
            "null"
          ]
        },
        "verified_scope": {
          "type": [
            "string",
            "null"
          ]
        },
        "evidence_digest": {
          "type": [
            "string",
            "null"
          ]
        },
        "evidence": {
          "type": [
            "string",
            "null"
          ]
        },
        "verification_status": {
          "type": [
            "string",
            "null"
          ]
        },
        "production_freshness": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}
