{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "field_replay.raw_sample.v1",
  "oneOf": [
    {
      "type": "object",
      "required": ["schema", "sample_type", "session_id", "agent_id", "peer_agent_id", "stream_id", "seq", "send_mono_ns", "timeout"],
      "properties": {
        "schema": {"const": "field_replay.raw_sample.v1"},
        "sample_type": {"const": "echo_rtt"},
        "session_id": {"type": "string"},
        "agent_id": {"type": "integer"},
        "peer_agent_id": {"type": "integer"},
        "stream_id": {"type": "integer"},
        "seq": {"type": "integer"},
        "send_mono_ns": {"type": "integer"},
        "recv_mono_ns": {"type": ["integer", "null"]},
        "rtt_ns": {"type": ["integer", "null"]},
        "payload_size_bytes": {"type": "integer"},        "timeout": {"type": "boolean"},
        "wall_unix_ns": {"type": "integer"}
      }
    },
    {
      "type": "object",
      "required": ["schema", "sample_type", "session_id", "receiver_agent_id", "sender_agent_id", "stream_id", "seq", "receiver_recv_mono_ns"],
      "properties": {
        "schema": {"const": "field_replay.raw_sample.v1"},
        "sample_type": {"const": "stream_rx"},
        "session_id": {"type": "string"},
        "receiver_agent_id": {"type": "integer"},
        "sender_agent_id": {"type": "integer"},
        "stream_id": {"type": "integer"},
        "seq": {"type": "integer"},
        "sender_send_mono_ns": {"type": "integer"},
        "receiver_recv_mono_ns": {"type": "integer"},
        "receiver_wall_unix_ns": {"type": "integer"},
        "payload_size_bytes": {"type": "integer"},        "payload_crc_ok": {"type": "boolean"},
        "duplicate": {"type": "boolean"},
        "reordered": {"type": "boolean"}
      }
    },
    {
      "type": "object",
      "required": ["schema", "sample_type", "session_id", "agent_id", "expected_send_mono_ns", "actual_send_mono_ns", "lag_ns"],
      "properties": {
        "schema": {"const": "field_replay.raw_sample.v1"},
        "sample_type": {"const": "scheduler_lag"},
        "session_id": {"type": "string"},
        "agent_id": {"type": "integer"},
        "expected_send_mono_ns": {"type": "integer"},
        "actual_send_mono_ns": {"type": "integer"},
        "lag_ns": {"type": "integer"}
      }
    },
    {
      "type": "object",
      "required": ["schema", "sample_type", "session_id", "agent_id", "peer_agent_id", "stream_id", "seq", "message_type", "error"],
      "properties": {
        "schema": {"const": "field_replay.raw_sample.v1"},
        "sample_type": {"const": "send_error"},
        "session_id": {"type": "string"},
        "agent_id": {"type": "integer"},
        "peer_agent_id": {"type": "integer"},
        "peer_host": {"type": "string"},
        "peer_port": {"type": "integer"},
        "stream_id": {"type": "integer"},
        "seq": {"type": "integer"},
        "message_type": {"type": "string"},
        "payload_size_bytes": {"type": "integer"},
        "error": {"type": "string"},
        "wall_unix_ns": {"type": "integer"}
      }
    },
    {
      "type": "object",
      "required": ["schema", "sample_type", "session_id", "sender_agent_id", "receiver_agent_id", "stream_id", "sent_count"],
      "properties": {
        "schema": {"const": "field_replay.raw_sample.v1"},
        "sample_type": {"const": "stream_tx_summary"},
        "session_id": {"type": "string"},
        "sender_agent_id": {"type": "integer"},
        "receiver_agent_id": {"type": "integer"},
        "stream_id": {"type": "integer"},
        "sent_count": {"type": "integer"}
      }
    }
  ]
}
