{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "normalized_query_v1",
  "title": "Normalized Query V1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "user_question_raw",
    "normalized_question",
    "intent_class",
    "business_problem_type",
    "domain_entities",
    "accounts_mentioned",
    "documents_mentioned",
    "registers_mentioned",
    "period_scope",
    "requires",
    "expected_output_shape",
    "route_hint",
    "ambiguities",
    "confidence"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "normalized_query_v1"
    },
    "user_question_raw": {
      "type": "string",
      "minLength": 1
    },
    "normalized_question": {
      "type": "string",
      "minLength": 1
    },
    "intent_class": {
      "type": "string",
      "enum": [
        "heavy_analytical",
        "cross_entity",
        "drilldown_explain",
        "rule_based_account_control",
        "anomaly_probe",
        "period_close_risk",
        "ambiguous_human_query",
        "simple_factual"
      ]
    },
    "business_problem_type": {
      "type": "string",
      "minLength": 1
    },
    "domain_entities": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "accounts_mentioned": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "documents_mentioned": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "registers_mentioned": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "period_scope": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "value", "confidence"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["explicit", "inferred", "missing"]
        },
        "value": {
          "type": ["string", "null"]
        },
        "confidence": {
          "type": "string",
          "enum": ["high", "medium", "low"]
        }
      }
    },
    "requires": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "needs_cross_entity_join",
        "needs_causal_chain",
        "needs_exact_object_trace",
        "needs_ranking",
        "needs_anomaly_summary",
        "needs_runtime_truth",
        "needs_period_cut",
        "needs_evidence"
      ],
      "properties": {
        "needs_cross_entity_join": { "type": "boolean" },
        "needs_causal_chain": { "type": "boolean" },
        "needs_exact_object_trace": { "type": "boolean" },
        "needs_ranking": { "type": "boolean" },
        "needs_anomaly_summary": { "type": "boolean" },
        "needs_runtime_truth": { "type": "boolean" },
        "needs_period_cut": { "type": "boolean" },
        "needs_evidence": { "type": "boolean" }
      }
    },
    "expected_output_shape": {
      "type": "string",
      "enum": [
        "ranked_list",
        "evidence_chain",
        "anomaly_summary",
        "point_answer",
        "reconciliation_report",
        "prioritized_review_list"
      ]
    },
    "route_hint": {
      "type": "string",
      "enum": [
        "store_canonical",
        "store_feature_risk",
        "hybrid_store_plus_live",
        "live_mcp_drilldown",
        "batch_refresh_then_store"
      ]
    },
    "ambiguities": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["field", "reason", "severity"],
        "properties": {
          "field": { "type": "string" },
          "reason": { "type": "string" },
          "severity": {
            "type": "string",
            "enum": ["low", "medium", "high"]
          }
        }
      }
    },
    "confidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["overall", "intent_class", "route_hint"],
      "properties": {
        "overall": {
          "type": "string",
          "enum": ["high", "medium", "low"]
        },
        "intent_class": {
          "type": "string",
          "enum": ["high", "medium", "low"]
        },
        "route_hint": {
          "type": "string",
          "enum": ["high", "medium", "low"]
        }
      }
    }
  }
}
