{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/Snapshot",
  "definitions": {
    "Snapshot": {
      "type": "object",
      "properties": {
        "motions": {
          "type": "object",
          "additionalProperties": {
            "not": {}
          }
        },
        "appliedForce": {
          "type": "number"
        },
        "objectJoints": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        },
        "episode": {
          "$ref": "#/definitions/EpisodeState"
        },
        "task": {
          "$ref": "#/definitions/TaskState"
        },
        "taskReward": {
          "$ref": "#/definitions/TaskRewardTrace"
        },
        "taskObservation": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "number"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "robots": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "qpos": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "ctrl": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              }
            },
            "required": [
              "qpos",
              "ctrl"
            ],
            "additionalProperties": false
          }
        },
        "logs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "time": {
                "type": "number"
              },
              "entity": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "time",
              "entity",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "debug": {
          "$ref": "#/definitions/DebugPause"
        },
        "render": {
          "$ref": "#/definitions/RenderOverrides",
          "description": "Render-only runtime component state (hidden meshes, runtime materials). Present only while such an edit is active, so the viewport and the recording frame drawn from this snapshot show exactly what the tick had."
        },
        "tick": {
          "type": "number"
        },
        "time": {
          "type": "number"
        },
        "lighting": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "Randomized area-light intensities in authored order, when randomization is active."
        },
        "contacts": {
          "type": "number"
        },
        "poses": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "joints": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "gripper": {
          "type": "number"
        },
        "tool": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "objectPositions": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "number"
            }
          }
        }
      },
      "required": [
        "tick",
        "time",
        "contacts",
        "poses",
        "joints",
        "gripper",
        "tool",
        "objectPositions"
      ],
      "additionalProperties": false
    },
    "EpisodeState": {
      "type": "object",
      "properties": {
        "seed": {
          "type": "number"
        },
        "status": {
          "type": "string",
          "enum": [
            "running",
            "succeeded",
            "failed"
          ]
        },
        "reason": {
          "type": "string"
        },
        "tick": {
          "type": "number"
        },
        "randomization": {
          "$ref": "#/definitions/RandomizationRecord",
          "description": "Seeded scene randomization applied this episode, if any (recorded metadata)."
        }
      },
      "required": [
        "seed",
        "status",
        "reason",
        "tick"
      ],
      "additionalProperties": false
    },
    "RandomizationRecord": {
      "type": "object",
      "properties": {
        "seed": {
          "type": "number"
        },
        "poses": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PoseSample"
          }
        },
        "mass": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/MassSample"
          }
        },
        "friction": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/FrictionSample"
          }
        },
        "lighting": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/LightingSample"
          }
        }
      },
      "required": [
        "seed"
      ],
      "additionalProperties": false,
      "description": "Author + randomized values for one episode, recorded in episode metadata."
    },
    "PoseSample": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "authored": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 3,
          "maxItems": 3,
          "description": "Authored world position [x, y, z]."
        },
        "randomized": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 3,
          "maxItems": 3,
          "description": "Randomized world position [x, y, z]."
        },
        "yaw": {
          "type": "number",
          "description": "Applied yaw delta in radians (0 when yaw was not configured)."
        },
        "authoredYaw": {
          "type": "number",
          "description": "Authored Euler-Z rotation, radians."
        }
      },
      "required": [
        "id",
        "name",
        "authored",
        "randomized",
        "yaw",
        "authoredYaw"
      ],
      "additionalProperties": false
    },
    "MassSample": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "authored": {
          "type": "number"
        },
        "randomized": {
          "type": "number"
        },
        "factor": {
          "type": "number"
        }
      },
      "required": [
        "id",
        "name",
        "authored",
        "randomized",
        "factor"
      ],
      "additionalProperties": false
    },
    "FrictionSample": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "authored": {
          "type": "number"
        },
        "randomized": {
          "type": "number"
        },
        "factor": {
          "type": "number"
        }
      },
      "required": [
        "id",
        "name",
        "authored",
        "randomized",
        "factor"
      ],
      "additionalProperties": false
    },
    "LightingSample": {
      "type": "object",
      "properties": {
        "index": {
          "type": "number"
        },
        "authored": {
          "type": "number"
        },
        "randomized": {
          "type": "number"
        },
        "factor": {
          "type": "number"
        }
      },
      "required": [
        "index",
        "authored",
        "randomized",
        "factor"
      ],
      "additionalProperties": false
    },
    "TaskState": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "stack",
            "pickPlace",
            "pickInto"
          ]
        },
        "phase": {
          "type": "string"
        },
        "order": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "placed": {
          "type": "number"
        },
        "total": {
          "type": "number"
        },
        "holding": {
          "type": "boolean"
        },
        "lifted": {
          "type": "boolean"
        }
      },
      "required": [
        "kind",
        "phase",
        "order",
        "placed",
        "total",
        "holding",
        "lifted"
      ],
      "additionalProperties": false
    },
    "TaskRewardTrace": {
      "type": "object",
      "properties": {
        "steps": {
          "type": "number",
          "description": "Physics steps the reward component has run so far."
        },
        "latest": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "The last validated per-step value."
        },
        "cumulative": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "Running element-wise sum of every per-step value."
        }
      },
      "required": [
        "steps",
        "latest",
        "cumulative"
      ],
      "additionalProperties": false,
      "description": "Per-episode reward trace sampled into the recorded dataset."
    },
    "DebugPause": {
      "type": "object",
      "properties": {
        "behaviorId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "line": {
          "type": "number"
        },
        "locals": {
          "$ref": "#/definitions/DebugLocals"
        },
        "ctx": {
          "$ref": "#/definitions/DebugCtxSnapshot"
        }
      },
      "required": [
        "behaviorId",
        "name",
        "line",
        "locals",
        "ctx"
      ],
      "additionalProperties": false,
      "description": "The observable state of a paused behavior."
    },
    "DebugLocals": {
      "type": "object",
      "additionalProperties": {},
      "description": "Script-level debugger support for the behavior runtime.\n\nQuickJS (via quickjs-emscripten) exposes no bytecode debugger, so breakpoints are implemented by source instrumentation: when a behavior has at least one breakpoint armed, its `start` and `update` lifecycle functions are converted to generators and a `yield __lucky_dbg(...)` statement is inserted immediately before the statement on each breakpoint line inside those functions. `yield` suspends the callback in place, so `Step` resumes after the stopped checkpoint without replaying already-executed side effects, and `Continue` finishes the paused tick before the next hit. The yielded value is a snapshot of the in-scope locals and `ctx`, which the host reads to populate the pause panel.\n\nWhen no breakpoints are armed the source is passed through unchanged, so normal playback, recording and the physics worker are byte-for-byte unaffected. `eval` is never used and the existing `globalThis.eval = undefined` sandbox property is preserved."
    },
    "DebugCtxSnapshot": {
      "type": "object",
      "properties": {
        "self": {
          "type": "string"
        },
        "dt": {
          "type": "number"
        },
        "time": {
          "type": "number"
        },
        "parameters": {
          "type": "object",
          "additionalProperties": {
            "type": [
              "number",
              "boolean",
              "string"
            ]
          }
        }
      },
      "required": [
        "self",
        "dt",
        "time",
        "parameters"
      ],
      "additionalProperties": false,
      "description": "A narrow, JSON-safe snapshot of the context at the breakpoint."
    },
    "RenderOverrides": {
      "type": "object",
      "properties": {
        "hidden": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "Geom indices whose visual is hidden (Mesh removed at run time)."
        },
        "materials": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "geom": {
                "type": "number"
              },
              "color": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "finish": {
                "$ref": "#/definitions/Finish"
              }
            },
            "required": [
              "geom"
            ],
            "additionalProperties": false
          },
          "description": "Runtime material assignments: color is sRGB [r, g, b] in 0…1."
        }
      },
      "required": [
        "hidden",
        "materials"
      ],
      "additionalProperties": false,
      "description": "Render-only runtime state carried in every snapshot so the viewport and the recording frame captured from it draw exactly the component set the physics tick had. Present only while at least one render-only edit is active."
    },
    "Finish": {
      "type": "string",
      "enum": [
        "matte",
        "satin",
        "metal",
        "gloss"
      ]
    }
  }
}
