{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trajectory/json-schema/trajectory-aperture-run-stream-schema.json",
  "title": "ApertureRunStream",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trajectory-aperture-api-openapi.yml#/components/schemas/ApertureRunStream",
  "properties": {
    "samples": {
      "items": {
        "$ref": "#/$defs/ApertureStreamSample"
      },
      "type": "array",
      "title": "Samples"
    },
    "total": {
      "type": "integer",
      "title": "Total"
    },
    "counts": {
      "$ref": "#/$defs/ApertureStreamCounts"
    },
    "batches": {
      "items": {
        "$ref": "#/$defs/ApertureStreamBatch"
      },
      "type": "array",
      "title": "Batches"
    },
    "checkpoints": {
      "items": {
        "$ref": "#/$defs/ApertureStreamCheckpoint"
      },
      "type": "array",
      "title": "Checkpoints"
    },
    "next": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Next"
    },
    "source": {
      "type": "string",
      "enum": [
        "samples",
        "trajectories",
        "firestore"
      ],
      "title": "Source"
    },
    "order": {
      "type": "string",
      "enum": [
        "received",
        "created",
        "id"
      ],
      "title": "Order"
    }
  },
  "type": "object",
  "required": [
    "samples",
    "total",
    "counts",
    "batches",
    "checkpoints",
    "next",
    "source",
    "order"
  ],
  "$defs": {
    "ApertureStreamBatch": {
      "properties": {
        "step": {
          "type": "integer",
          "title": "Step"
        },
        "count": {
          "type": "integer",
          "title": "Count"
        }
      },
      "type": "object",
      "required": [
        "step",
        "count"
      ],
      "title": "ApertureStreamBatch"
    },
    "ApertureStreamCheckpoint": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "step": {
          "type": "integer",
          "title": "Step"
        },
        "createdAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Createdat"
        },
        "updateStartedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Updatestartedat"
        },
        "updateEndedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Updateendedat"
        }
      },
      "type": "object",
      "required": [
        "id",
        "step",
        "createdAt"
      ],
      "title": "ApertureStreamCheckpoint"
    },
    "ApertureStreamCounts": {
      "properties": {
        "pending": {
          "type": "integer",
          "title": "Pending",
          "default": 0
        },
        "selected": {
          "type": "integer",
          "title": "Selected",
          "default": 0
        },
        "trained": {
          "type": "integer",
          "title": "Trained",
          "default": 0
        },
        "rejected": {
          "type": "integer",
          "title": "Rejected",
          "default": 0
        },
        "collected": {
          "type": "integer",
          "title": "Collected",
          "default": 0
        }
      },
      "type": "object",
      "title": "ApertureStreamCounts"
    },
    "ApertureStreamSample": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "tid": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tid"
        },
        "uid": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Uid"
        },
        "sourceXid": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Sourcexid"
        },
        "trajectoryIndex": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Trajectoryindex"
        },
        "policyStep": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Policystep"
        },
        "collectedStep": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Collectedstep"
        },
        "trainedStep": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Trainedstep"
        },
        "state": {
          "type": "string",
          "enum": [
            "pending",
            "selected",
            "trained",
            "rejected",
            "collected"
          ],
          "title": "State"
        },
        "rejection": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Rejection"
        },
        "reward": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reward"
        },
        "receivedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Receivedat"
        },
        "createdAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Createdat"
        },
        "duration": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Duration"
        },
        "endedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Endedat"
        },
        "tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tokens"
        },
        "task": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Task"
        }
      },
      "type": "object",
      "required": [
        "id",
        "tid",
        "uid",
        "sourceXid",
        "trajectoryIndex",
        "policyStep",
        "collectedStep",
        "trainedStep",
        "state",
        "rejection",
        "reward",
        "receivedAt",
        "createdAt",
        "duration",
        "tokens",
        "task"
      ],
      "title": "ApertureStreamSample"
    }
  }
}