{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openvisual.org/schema/session/1.0",
  "title": "OVS Session Document",
  "description": "A complete OVS observation session. Contains one or more symptom observations and an optional wellbeing block.",
  "type": "object",
  "required": ["ovs_version", "session_id", "recorded_at", "symptoms"],
  "properties": {
    "ovs_version": { "type": "string", "const": "1.0" },
    "session_id":  { "type": "string", "format": "uuid", "description": "UUID v4 unique identifier for this session" },
    "recorded_at": { "type": "string", "format": "date-time", "description": "ISO 8601 UTC timestamp" },
    "profile":     { "type": "string", "description": "Condition profile identifier, e.g. ovs-profile:vss" },
    "subject_id":  { "type": "string", "description": "Anonymized subject identifier, e.g. VS-3A7F21" },

    "symptoms": {
      "type": "array",
      "minItems": 1,
      "items": {
        "allOf": [
          { "$ref": "https://openvisual.org/schema/symptom-base/1.0" }
        ]
      },
      "description": "Array of OVS symptom observations for this session. Each item must conform to ovs:symptom-base and its declared ovs_type extension."
    },

    "wellbeing": {
      "type": "object",
      "description": "Patient self-reported state for this session",
      "properties": {
        "anxiety":     { "$ref": "#/$defs/scale_10" },
        "energy":      { "$ref": "#/$defs/scale_10" },
        "depression":  { "$ref": "#/$defs/scale_10" },
        "stress":      { "$ref": "#/$defs/scale_10" },
        "sleep_hours": { "type": "number", "minimum": 0, "maximum": 24, "description": "Hours of sleep in the preceding period" },
        "note":        { "type": "string", "description": "Free-text patient note" }
      }
    },

    "eeg": {
      "type": "object",
      "description": "Reference to an EEG recording associated with this session",
      "properties": {
        "session_timestamp": { "type": "integer", "description": "Epoch ms — links to eeg_index.json" },
        "board_name":        { "type": "string" },
        "alpha_mean":        { "type": "number", "description": "Mean alpha band power" },
        "alpha_gamma_ratio": { "type": "number", "description": "Alpha/gamma ratio — hyperexcitability indicator" }
      }
    }
  },

  "$defs": {
    "scale_10": {
      "type": "object",
      "required": ["value", "scale"],
      "properties": {
        "value": { "type": "integer", "minimum": 0 },
        "scale": { "type": "integer", "const": 10 }
      }
    }
  }
}
