{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nexatron-io/json-schema/nexatron-io-app-schemas-query-query-response-schema.json",
  "title": "QueryResponse",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nexatron-io-openapi.json#/components/schemas/app__schemas__query__QueryResponse",
  "properties": {
    "answer_contract": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Answer Contract"
    },
    "confidence_breakdown": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Confidence Breakdown"
    },
    "confidence_score": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Confidence Score"
    },
    "content": {
      "title": "Content",
      "type": "string"
    },
    "conversation_id": {
      "format": "uuid",
      "title": "Conversation Id",
      "type": "string"
    },
    "core_evidence": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Core Evidence"
    },
    "freshness": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Freshness"
    },
    "generated_sql": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Generated Sql"
    },
    "governance": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Governance"
    },
    "latency_ms": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Latency Ms"
    },
    "message_id": {
      "format": "uuid",
      "title": "Message Id",
      "type": "string"
    },
    "reasoning": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Reasoning"
    },
    "refusal": {
      "anyOf": [
        {
          "$ref": "#/$defs/GovernanceRefusal"
        },
        {
          "type": "null"
        }
      ]
    },
    "result_chart": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Result Chart"
    },
    "result_data": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Result Data"
    },
    "source_routing": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Source Routing"
    },
    "sources": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "items": {},
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Sources"
    },
    "stage_metrics": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Stage Metrics"
    },
    "total_cost_usd": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Total Cost Usd"
    },
    "total_tokens": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Total Tokens"
    }
  },
  "required": [
    "message_id",
    "conversation_id",
    "content"
  ],
  "type": "object",
  "$defs": {
    "GovernanceRefusal": {
      "additionalProperties": false,
      "description": "A governed answer the platform withheld, as a typed body rather than prose.\n\nNexatron withholds an answer when an approved metric's owner declared something\nthe requested shape contradicts, such as a grain finer than the metric allows or\na filter it cannot honour. Clients should read the typed state and code rather\nthan parsing prose, and should not re-ask a question that was refused.\n\n``clarification_required`` / ``sql_generation_declined`` means Nexatron declined\nto write a query. It is not a policy decision or proof of missing data.\n\n``generation_failed`` / ``sql_generation_failed`` means the question was accepted\nand no query could be produced. It is a failure of this platform, not a\nstatement about the question: present it as retryable, and don't prompt the\nperson for a definition. It carries no number, no rows and no SQL, because\nnothing was measured.",
      "properties": {
        "code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Code"
        },
        "governance_state": {
          "title": "Governance State",
          "type": "string"
        },
        "metric": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Metric"
        },
        "reason": {
          "title": "Reason",
          "type": "string"
        },
        "suggestions": {
          "items": {
            "type": "string"
          },
          "title": "Suggestions",
          "type": "array"
        }
      },
      "required": [
        "reason",
        "governance_state"
      ],
      "title": "GovernanceRefusal",
      "type": "object"
    }
  }
}