{
  "type": "object",
  "properties": {
    "schema_version": {
      "type": "string"
    },
    "request_id": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "decided",
        "abstained",
        "error"
      ]
    },
    "decision": {
      "type": [
        "string",
        "null"
      ]
    },
    "confidence": {
      "type": [
        "number",
        "null"
      ]
    },
    "rationale": {
      "type": [
        "string",
        "null"
      ]
    },
    "provider": {
      "type": [
        "string",
        "null"
      ]
    },
    "probabilities": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "number"
      },
      "description": "Per-answer probabilities, when the provider reports them."
    },
    "calibrated": {
      "type": "boolean",
      "description": "True when a fitted temperature was applied to probabilities and confidence."
    },
    "latency_ms": {
      "type": "integer"
    },
    "attempts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "ok",
              "abstained",
              "timeout",
              "error",
              "malformed"
            ]
          },
          "latency_ms": {
            "type": "integer"
          },
          "detail": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "error": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "invalid_request",
            "config_error",
            "provider_timeout",
            "provider_error",
            "malformed_response"
          ]
        },
        "message": {
          "type": "string"
        }
      }
    }
  },
  "required": [
    "schema_version",
    "request_id",
    "status",
    "latency_ms",
    "attempts",
    "error"
  ]
}
