{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "RONIQ ingestion batches 1.1.6",
  "oneOf": [
    {
      "$ref": "#/$defs/StateBatch"
    },
    {
      "$ref": "#/$defs/TelemetryBatch"
    },
    {
      "$ref": "#/$defs/EventBatch"
    },
    {
      "$ref": "#/$defs/MissionBatch"
    }
  ],
  "$defs": {
    "StateBatch": {
      "type": "object",
      "description": "최대500항목/1MiB. 원자 검증·내구성 저장 후 접수. 부분 성공 없음.",
      "properties": {
        "connectorId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "sourceGeneration": {
          "type": "integer",
          "description": "등록된 출처 세대. 철회 세대 거절.",
          "example": 1,
          "minimum": 1
        },
        "synthetic": {
          "type": "boolean",
          "description": "등록 연결과 일치하는 합성 여부.",
          "example": true
        },
        "items": {
          "type": "array",
          "description": "항목.",
          "minItems": 1,
          "maxItems": 500,
          "items": {
            "$ref": "#/$defs/IngestState"
          }
        }
      },
      "required": [
        "connectorId",
        "sourceGeneration",
        "synthetic",
        "items"
      ],
      "additionalProperties": false
    },
    "IngestState": {
      "type": "object",
      "description": "동일 시각 sequence로 current state 갱신 판단.",
      "properties": {
        "eventId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "robotExternalId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "observedAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "Z$",
          "description": "UTC RFC3339 시각. 사이트 시간대는 화면 표시에서 적용.",
          "example": "2026-09-26T08:00:00Z"
        },
        "sequence": {
          "type": "integer",
          "description": "원본 sequence.",
          "example": 1,
          "minimum": 0
        },
        "connectivity": {
          "type": "string",
          "description": "연결 상태.",
          "minLength": 1,
          "maxLength": 200,
          "example": "ONLINE",
          "enum": [
            "ONLINE",
            "OFFLINE",
            "UNKNOWN"
          ]
        },
        "operation": {
          "type": "string",
          "description": "운용 상태.",
          "minLength": 1,
          "maxLength": 200,
          "example": "IDLE",
          "enum": [
            "IDLE",
            "RUNNING",
            "CHARGING",
            "ERROR",
            "UNKNOWN"
          ]
        },
        "batterySoc": {
          "description": "원본 출처가 보고한 배터리 잔량 SOC(%). 0~100 범위의 값이며 관측값이 없으면 null이다.",
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "maximum": 100,
              "description": "SOC(%).",
              "example": 75
            },
            {
              "type": "null"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/SourceMetadata"
        },
        "rawPayload": {
          "$ref": "#/$defs/RawPayload"
        },
        "extensions": {
          "type": "object",
          "description": "Vendor 확장 scalar map. 복잡한 원문은 rawPayload에 보존. ext.vendor.field 명명,최대100개.",
          "maxProperties": 100,
          "propertyNames": {
            "pattern": "^ext\\.[a-z0-9_]+\\.[A-Za-z0-9_.-]+$"
          },
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean",
              "null"
            ]
          },
          "example": {
            "ext.sim.source": "SIMULATOR"
          }
        },
        "mission": {
          "description": "상태 관측과 함께 전달하는 외부 미션 자료. 선택 필드로, 미션 자료가 없으면 생략하거나 null을 사용할 수 있다.",
          "anyOf": [
            {
              "$ref": "#/$defs/IngestMission"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "eventId",
        "robotExternalId",
        "observedAt",
        "sequence",
        "connectivity",
        "operation",
        "batterySoc",
        "source",
        "rawPayload",
        "extensions"
      ],
      "additionalProperties": false
    },
    "SourceMetadata": {
      "type": "object",
      "description": "인증 Connector와 일치하는 출처. 임의 고객 확대 금지.",
      "additionalProperties": false,
      "properties": {
        "sourceId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "mappingVersion": {
          "type": "string",
          "description": "적용매핑 불변 버전.",
          "minLength": 1,
          "maxLength": 200,
          "example": "mapping-1"
        },
        "sourceQuality": {
          "type": "string",
          "description": "원본 품질.",
          "minLength": 1,
          "maxLength": 200,
          "example": "VALID",
          "enum": [
            "VALID",
            "INVALID",
            "UNKNOWN"
          ]
        },
        "freshnessSeconds": {
          "type": "integer",
          "description": "관측 후 전송까지 경과초. 서버수신시각으로 대사.",
          "minimum": 0,
          "example": 0
        }
      },
      "required": [
        "sourceId",
        "mappingVersion",
        "sourceQuality",
        "freshnessSeconds"
      ]
    },
    "RawPayload": {
      "type": "object",
      "description": "Agent가 받은 원본bytes의base64. batch전체1MiB 제한. checksum은전송중무결성확인이지 Vendor진위서명증명이아님. raw전용암호화저장,업무응답/로그비노출.",
      "additionalProperties": false,
      "properties": {
        "mediaType": {
          "type": "string",
          "description": "원본 형식.",
          "minLength": 1,
          "maxLength": 200,
          "example": "application/json",
          "enum": [
            "application/json",
            "text/plain",
            "application/octet-stream"
          ]
        },
        "body": {
          "type": "string",
          "contentEncoding": "base64",
          "description": "원본bytes base64. decoded최대512KiB, batch전체1MiB서버검증.",
          "maxLength": 699052,
          "minLength": 1,
          "example": "eyJiYXR0ZXJ5Ijo3NX0="
        },
        "sha256": {
          "type": "string",
          "description": "원문 UTF-8 bytes SHA-256 소문자hex.",
          "pattern": "^[0-9a-f]{64}$",
          "example": "9aeb4c95009ce0a818a5fe6689aae08319fc3da935c76959fae860dd680e4f26"
        }
      },
      "required": [
        "mediaType",
        "body",
        "sha256"
      ]
    },
    "IngestMission": {
      "type": "object",
      "description": "외부 미션 조회자료 수집. planner/원격실행 아님.",
      "additionalProperties": false,
      "properties": {
        "eventId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "robotExternalId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "externalId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "observedAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "Z$",
          "description": "UTC RFC3339 시각. 사이트 시간대는 화면 표시에서 적용.",
          "example": "2026-09-26T08:00:00Z"
        },
        "sequence": {
          "type": "integer",
          "description": "출처 순서.",
          "minimum": 0,
          "example": 1
        },
        "type": {
          "type": "string",
          "description": "미션 종류.",
          "minLength": 1,
          "maxLength": 200,
          "example": "DELIVERY"
        },
        "status": {
          "type": "string",
          "description": "상태.",
          "minLength": 1,
          "maxLength": 200,
          "example": "QUEUED",
          "enum": [
            "QUEUED",
            "RUNNING",
            "COMPLETED",
            "FAILED",
            "CANCELLED",
            "UNKNOWN"
          ]
        },
        "startedAt": {
          "description": "원본 출처의 미션 시작 시각(UTC RFC3339). 시작 시각이 제공되지 않으면 null이다.",
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "Z$",
              "description": "UTC RFC3339 시각. 사이트 시간대는 화면 표시에서 적용.",
              "example": "2026-09-26T08:00:00Z"
            },
            {
              "type": "null"
            }
          ]
        },
        "endedAt": {
          "description": "원본 출처의 미션 종료 시각(UTC RFC3339). 종료 시각이 제공되지 않으면 null이다.",
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "Z$",
              "description": "UTC RFC3339 시각. 사이트 시간대는 화면 표시에서 적용.",
              "example": "2026-09-26T08:00:00Z"
            },
            {
              "type": "null"
            }
          ]
        },
        "durationSeconds": {
          "description": "원본 출처가 제공한 미션 경과 시간(초). 값이 없으면 null을 보내며 0초와 구분한다.",
          "anyOf": [
            {
              "type": "integer",
              "description": "미션 경과초.",
              "minimum": 0,
              "example": 10
            },
            {
              "type": "null"
            }
          ]
        },
        "distanceMeters": {
          "description": "원본 출처가 제공한 미션 이동 거리(m). 값이 없으면 null을 보내며 0m와 구분한다.",
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "example": 12.5,
              "description": "거리m."
            },
            {
              "type": "null"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/SourceMetadata"
        },
        "rawPayload": {
          "$ref": "#/$defs/RawPayload"
        },
        "extensions": {
          "type": "object",
          "description": "Vendor 확장 scalar map. 복잡한 원문은 rawPayload에 보존. ext.vendor.field 명명,최대100개.",
          "maxProperties": 100,
          "propertyNames": {
            "pattern": "^ext\\.[a-z0-9_]+\\.[A-Za-z0-9_.-]+$"
          },
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean",
              "null"
            ]
          },
          "example": {
            "ext.sim.source": "SIMULATOR"
          }
        }
      },
      "required": [
        "eventId",
        "robotExternalId",
        "externalId",
        "observedAt",
        "sequence",
        "type",
        "status",
        "startedAt",
        "endedAt",
        "durationSeconds",
        "distanceMeters",
        "source",
        "rawPayload",
        "extensions"
      ]
    },
    "TelemetryBatch": {
      "type": "object",
      "description": "최대500항목/1MiB. 원자 검증·내구성 저장 후 접수. 부분 성공 없음.",
      "properties": {
        "connectorId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "sourceGeneration": {
          "type": "integer",
          "description": "등록된 출처 세대. 철회 세대 거절.",
          "example": 1,
          "minimum": 1
        },
        "synthetic": {
          "type": "boolean",
          "description": "등록 연결과 일치하는 합성 여부.",
          "example": true
        },
        "items": {
          "type": "array",
          "description": "항목.",
          "minItems": 1,
          "maxItems": 500,
          "items": {
            "$ref": "#/$defs/IngestTelemetry"
          }
        }
      },
      "required": [
        "connectorId",
        "sourceGeneration",
        "synthetic",
        "items"
      ],
      "additionalProperties": false
    },
    "IngestTelemetry": {
      "type": "object",
      "description": "numericValue/stringValue 정확히 하나 non-null.",
      "properties": {
        "eventId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "robotExternalId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "observedAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "Z$",
          "description": "UTC RFC3339 시각. 사이트 시간대는 화면 표시에서 적용.",
          "example": "2026-09-26T08:00:00Z"
        },
        "sequence": {
          "type": "integer",
          "description": "원본 sequence.",
          "example": 1,
          "minimum": 0
        },
        "metric": {
          "type": "string",
          "description": "계측명.",
          "minLength": 1,
          "maxLength": 200,
          "example": "battery.soc"
        },
        "numericValue": {
          "description": "숫자 형태의 계측값. 숫자 계측이면 이 값만 non-null로 보내고 stringValue는 null이어야 한다.",
          "anyOf": [
            {
              "type": "number",
              "description": "숫자값.",
              "example": 75
            },
            {
              "type": "null"
            }
          ]
        },
        "stringValue": {
          "description": "문자열 형태의 계측값. 문자열 계측이면 이 값만 non-null로 보내고 numericValue는 null이어야 한다.",
          "anyOf": [
            {
              "type": "string",
              "description": "문자값.",
              "minLength": 1,
              "maxLength": 200,
              "example": "IDLE"
            },
            {
              "type": "null"
            }
          ]
        },
        "unit": {
          "type": "string",
          "description": "단위.",
          "minLength": 1,
          "maxLength": 32,
          "example": "%"
        },
        "source": {
          "$ref": "#/$defs/SourceMetadata"
        },
        "rawPayload": {
          "$ref": "#/$defs/RawPayload"
        },
        "extensions": {
          "type": "object",
          "description": "Vendor 확장 scalar map. 복잡한 원문은 rawPayload에 보존. ext.vendor.field 명명,최대100개.",
          "maxProperties": 100,
          "propertyNames": {
            "pattern": "^ext\\.[a-z0-9_]+\\.[A-Za-z0-9_.-]+$"
          },
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean",
              "null"
            ]
          },
          "example": {
            "ext.sim.source": "SIMULATOR"
          }
        }
      },
      "required": [
        "eventId",
        "robotExternalId",
        "observedAt",
        "sequence",
        "metric",
        "numericValue",
        "stringValue",
        "unit",
        "source",
        "rawPayload",
        "extensions"
      ],
      "additionalProperties": false,
      "oneOf": [
        {
          "properties": {
            "numericValue": {
              "description": "숫자 계측 분기에서 사용하는 숫자 값.",
              "type": "number"
            },
            "stringValue": {
              "description": "숫자 계측 분기에서는 문자열 값을 사용하지 않으므로 null이다.",
              "type": "null"
            }
          }
        },
        {
          "properties": {
            "numericValue": {
              "description": "문자열 계측 분기에서는 숫자 값을 사용하지 않으므로 null이다.",
              "type": "null"
            },
            "stringValue": {
              "description": "문자열 계측 분기에서 사용하는 문자열 값.",
              "type": "string"
            }
          }
        }
      ]
    },
    "EventBatch": {
      "type": "object",
      "description": "최대500항목/1MiB. 원자 검증·내구성 저장 후 접수. 부분 성공 없음.",
      "properties": {
        "connectorId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "sourceGeneration": {
          "type": "integer",
          "description": "등록된 출처 세대. 철회 세대 거절.",
          "example": 1,
          "minimum": 1
        },
        "synthetic": {
          "type": "boolean",
          "description": "등록 연결과 일치하는 합성 여부.",
          "example": true
        },
        "items": {
          "type": "array",
          "description": "항목.",
          "minItems": 1,
          "maxItems": 500,
          "items": {
            "$ref": "#/$defs/IngestEvent"
          }
        }
      },
      "required": [
        "connectorId",
        "sourceGeneration",
        "synthetic",
        "items"
      ],
      "additionalProperties": false
    },
    "IngestEvent": {
      "type": "object",
      "description": "observedAt 90일 이상 과거/미래5분 초과 거절. 삭제·철회된 source generation 차단.",
      "properties": {
        "eventId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "robotExternalId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "observedAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "Z$",
          "description": "UTC RFC3339 시각. 사이트 시간대는 화면 표시에서 적용.",
          "example": "2026-09-26T08:00:00Z"
        },
        "sequence": {
          "type": "integer",
          "description": "원본 sequence.",
          "example": 1,
          "minimum": 0
        },
        "vendorCode": {
          "type": "string",
          "description": "Vendor 코드.",
          "minLength": 1,
          "maxLength": 200,
          "example": "SIM_OFFLINE"
        },
        "category": {
          "type": "string",
          "description": "범주.",
          "minLength": 1,
          "maxLength": 200,
          "example": "CONNECTIVITY"
        },
        "severity": {
          "type": "string",
          "description": "심각도.",
          "minLength": 1,
          "maxLength": 200,
          "example": "INFO",
          "enum": [
            "INFO",
            "WARNING",
            "CRITICAL"
          ]
        },
        "source": {
          "$ref": "#/$defs/SourceMetadata"
        },
        "rawPayload": {
          "$ref": "#/$defs/RawPayload"
        },
        "extensions": {
          "type": "object",
          "description": "Vendor 확장 scalar map. 복잡한 원문은 rawPayload에 보존. ext.vendor.field 명명,최대100개.",
          "maxProperties": 100,
          "propertyNames": {
            "pattern": "^ext\\.[a-z0-9_]+\\.[A-Za-z0-9_.-]+$"
          },
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean",
              "null"
            ]
          },
          "example": {
            "ext.sim.source": "SIMULATOR"
          }
        }
      },
      "required": [
        "eventId",
        "robotExternalId",
        "observedAt",
        "sequence",
        "vendorCode",
        "category",
        "severity",
        "source",
        "rawPayload",
        "extensions"
      ],
      "additionalProperties": false
    },
    "MissionBatch": {
      "type": "object",
      "description": "미션관측 최대500항목/1MiB 원자수집. 내부planner 없음.",
      "properties": {
        "connectorId": {
          "type": "string",
          "description": "서버 불투명 식별자. 인증 범위 밖 자원 존재 여부를 노출하지 않는다.",
          "minLength": 1,
          "maxLength": 128,
          "example": "sample_id"
        },
        "sourceGeneration": {
          "type": "integer",
          "description": "등록된 출처 세대. 철회 세대 거절.",
          "example": 1,
          "minimum": 1
        },
        "synthetic": {
          "type": "boolean",
          "description": "등록 연결과 일치하는 합성 여부.",
          "example": true
        },
        "items": {
          "type": "array",
          "description": "항목.",
          "minItems": 1,
          "maxItems": 500,
          "items": {
            "$ref": "#/$defs/IngestMission"
          }
        }
      },
      "required": [
        "connectorId",
        "sourceGeneration",
        "synthetic",
        "items"
      ],
      "additionalProperties": false
    }
  }
}
