{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://quarka.org/schema/assistant/definitions/qal-query.schema.json",
  "title": "QAL native query",
  "description": "QAL query. Intentionally loose (additionalProperties: true) — detailed column/material validation is delegated to the Runtime QAL Executor (R7). Only the required top-level shape is enforced here.",
  "type": "object",
  "additionalProperties": true,
  "required": ["tracking_id", "materials", "time", "make", "result"],
  "properties": {
    "tracking_id": { "type": "string", "minLength": 1 },
    "materials": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["name"],
        "properties": { "name": { "type": "string", "minLength": 1 } }
      }
    },
    "time": {
      "type": "object",
      "required": ["start", "end", "tz"],
      "properties": {
        "start": { "type": "string", "minLength": 1 },
        "end": { "type": "string", "minLength": 1 },
        "tz": { "type": "string", "minLength": 1 }
      }
    },
    "make": { "type": "object", "minProperties": 1 },
    "result": {
      "type": "object",
      "required": ["use"],
      "properties": {
        "use": { "type": "string", "minLength": 1 },
        "limit": { "type": "integer", "minimum": 1 },
        "count_only": { "type": "boolean" }
      }
    }
  }
}
