{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fermihdi.dev/schemas/hd_sdk_config.json",
  "title": "FermiHDI SDK Dynamic Configuration",
  "description": "Schema for the dynamic configuration payload received by the HD SDK from the Control Plane (Proxy/DMS).",
  "type": "object",
  "properties": {
    "scc_targets": {
      "type": "object",
      "description": "Routing bindings for direct Storage Controller communication.",
      "properties": {
        "primary_cluster": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9.]+:[0-9]+$",
            "description": "IP:Port of an SCC node."
          }
        },
        "failover_cluster": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9.]+:[0-9]+$"
          }
        }
      },
      "required": ["primary_cluster"]
    },
    "observability": {
      "type": "object",
      "properties": {
        "log_level": {
          "type": "string",
          "enum": ["DEBUG", "INFO", "WARN", "ERROR"],
          "default": "INFO"
        },
        "tracing_enabled": {
          "type": "boolean",
          "default": true
        },
        "metrics_interval_seconds": {
          "type": "integer",
          "minimum": 1,
          "default": 10
        }
      }
    },
    "transport": {
      "type": "object",
      "properties": {
        "batch_timeout_ms": {
          "type": "integer",
          "minimum": 0,
          "default": 100
        },
        "max_inflight_batches": {
          "type": "integer",
          "minimum": 1,
          "default": 1024
        },
        "jumbo_frames": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "datasets": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "record_len": { "type": "integer" },
          "time_index_interval": { "type": "integer" },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "type": { "type": "string" },
                "first_byte_position": { "type": "integer" },
                "last_byte_position": { "type": "integer" }
              },
              "required": ["name", "type", "first_byte_position", "last_byte_position"]
            }
          }
        },
        "required": ["name", "record_len", "fields"]
      }
    }
  },
  "required": ["scc_targets"]
}
