{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://fact.ngo/xray/schemas/session.schema.json",
  "title": "xray session",
  "description": "One interview cell: a single (domain, lens) conversation with one model. Written and maintained by scripts/ask.js.",
  "type": "object",
  "required": ["session_id", "model_id", "domain", "lens", "protocol_version", "started", "turns"],
  "properties": {
    "session_id": { "type": "string", "description": "Model slug + domain + lens + sequence, e.g. llama-3.1-8b-fp8.history.retrospective.1" },
    "model_id": { "type": "string", "description": "Full provider model id" },
    "domain": { "type": "string" },
    "lens": { "type": "string" },
    "protocol_version": { "type": "string" },
    "temperature": { "type": "number" },
    "started": { "type": "string", "format": "date-time" },
    "ended": { "type": ["string", "null"], "format": "date-time" },
    "turns": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["turn", "role", "content"],
        "properties": {
          "turn": { "type": "integer" },
          "role": { "enum": ["user", "assistant"] },
          "content": { "type": "string" },
          "tokens_in": { "type": ["integer", "null"] },
          "tokens_out": { "type": ["integer", "null"] },
          "timestamp": { "type": "string", "format": "date-time" }
        }
      }
    },
    "totals": {
      "type": "object",
      "properties": {
        "tokens_in": { "type": "integer" },
        "tokens_out": { "type": "integer" },
        "cost_usd_estimate": { "type": "number" }
      }
    }
  }
}
