{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "meta": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": ["string", "null"]
        },
        "updated_at": {
          "type": ["string", "null"]
        },
        "deleted_at": {
          "type": ["string", "null"]
        },
        "legacy_ref": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "table": {
                  "type": "string"
                },
                "key": {
                  "type": ["string", "number"]
                },
                "row": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": ["table", "key", "row"],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "dataset": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^x-[a-z0-9]+-[a-z0-9-]+$"
      },
      "additionalProperties": {
        "$ref": "#/$defs/__schema0"
      }
    },
    "title": {
      "type": "string"
    },
    "workout": {
      "type": "object",
      "properties": {
        "record": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        }
      },
      "required": ["record"],
      "additionalProperties": false
    },
    "version": {
      "type": "object",
      "properties": {
        "record": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        }
      },
      "required": ["record"],
      "additionalProperties": false
    },
    "status": {
      "type": "string",
      "enum": ["active", "paused", "completed", "abandoned"]
    },
    "started_at": {
      "type": "string"
    },
    "ended_at": {
      "type": "string"
    },
    "timezone": {
      "type": "string"
    },
    "local_date": {
      "type": "string",
      "format": "date",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
    },
    "time_confidence": {
      "type": "string",
      "enum": ["captured", "legacy_local", "unknown"]
    },
    "active_duration_ms": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "pause": {
      "type": "object",
      "properties": {
        "elapsed_ms": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "paused_at": {
          "type": "string"
        }
      },
      "required": ["elapsed_ms"],
      "additionalProperties": false
    },
    "execution": {
      "type": "object",
      "properties": {
        "rest_deadline": {
          "type": "string"
        },
        "focused_set": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
        },
        "focused_slot": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
        },
        "timer_started_at": {
          "type": "string"
        },
        "timer_elapsed_ms": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "timer_mode": {
          "type": "string"
        },
        "recovery_needs_review": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "installation": {
      "type": "string"
    },
    "notes": {
      "type": "string"
    },
    "occurrences": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "created_at": {
                "type": ["string", "null"]
              },
              "updated_at": {
                "type": ["string", "null"]
              },
              "deleted_at": {
                "type": ["string", "null"]
              },
              "legacy_ref": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "table": {
                        "type": "string"
                      },
                      "key": {
                        "type": ["string", "number"]
                      },
                      "row": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": ["table", "key", "row"],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "dataset": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "extensions": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^x-[a-z0-9]+-[a-z0-9-]+$"
            },
            "additionalProperties": {
              "$ref": "#/$defs/__schema0"
            }
          },
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
          },
          "source_order": {
            "type": "number"
          },
          "slot": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
          },
          "block_path": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
            }
          },
          "exercise": {
            "type": "object",
            "properties": {
              "record": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "catalog": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "catalog_rev": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              "provider_ref": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "snapshot": {
                    "$ref": "#/$defs/__schema0"
                  }
                },
                "required": ["provider", "id", "snapshot"],
                "additionalProperties": false
              },
              "name": {
                "type": "string"
              },
              "match": {
                "type": "string",
                "enum": ["exact", "synonym", "fuzzy", "llm", "user", "unresolved"]
              },
              "snapshot": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "tracking_profile": {
                    "type": "string"
                  },
                  "equipment": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "category": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "record": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        },
                        "required": ["record"],
                        "additionalProperties": false
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": ["title", "tracking_profile", "equipment", "category"],
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "variant": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "ref": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                  },
                  "catalog_key": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "attributes": {
                    "type": "object",
                    "properties": {
                      "grip": {
                        "type": "string"
                      },
                      "hand_position": {
                        "type": "string"
                      },
                      "attachment": {
                        "type": "string"
                      },
                      "stance": {
                        "type": "string"
                      },
                      "equipment": {
                        "type": "string",
                        "enum": ["band", "dumbbell", "barbell", "cable", "machine", "kettlebell", "bodyweight", "other"]
                      },
                      "support": {
                        "type": "string",
                        "enum": ["back", "chest", "none"]
                      },
                      "body_position": {
                        "type": "string",
                        "enum": ["seated", "standing", "kneeling"]
                      },
                      "laterality": {
                        "type": "string",
                        "enum": ["bilateral", "unilateral", "alternating"]
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": ["label", "attributes"],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": ["planned", "performed", "skipped", "substituted"]
          },
          "substitutes": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
          },
          "prescription_snapshot": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "meta": {
                  "type": "object",
                  "properties": {
                    "created_at": {
                      "type": ["string", "null"]
                    },
                    "updated_at": {
                      "type": ["string", "null"]
                    },
                    "deleted_at": {
                      "type": ["string", "null"]
                    },
                    "legacy_ref": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "table": {
                              "type": "string"
                            },
                            "key": {
                              "type": ["string", "number"]
                            },
                            "row": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": ["table", "key", "row"],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dataset": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                },
                "extensions": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string",
                    "pattern": "^x-[a-z0-9]+-[a-z0-9-]+$"
                  },
                  "additionalProperties": {
                    "$ref": "#/$defs/__schema0"
                  }
                },
                "id": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                },
                "source_order": {
                  "type": "number"
                },
                "raw": {
                  "type": "string"
                },
                "evidence": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "raw": {
                        "type": "string"
                      },
                      "stream": {
                        "type": "string"
                      },
                      "span": {
                        "type": "array",
                        "prefixItems": [
                          {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          }
                        ],
                        "items": false,
                        "minItems": 2,
                        "maxItems": 2
                      },
                      "node_key": {
                        "type": "string"
                      },
                      "location": {
                        "type": "string"
                      }
                    },
                    "required": ["raw"],
                    "additionalProperties": false
                  },
                  "atomic": true
                },
                "role": {
                  "type": "string"
                },
                "repeat": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "reps": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "number",
                      "minimum": 0
                    },
                    "max": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false
                },
                "amrap": {
                  "type": "boolean"
                },
                "duration_ms": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "number",
                      "minimum": 0
                    },
                    "max": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false
                },
                "distance_mm": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "number",
                      "minimum": 0
                    },
                    "max": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false
                },
                "load": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "mass"
                        },
                        "value": {
                          "type": "string",
                          "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
                        },
                        "unit": {
                          "type": "string",
                          "enum": ["kg", "lb"]
                        },
                        "basis": {
                          "type": "string"
                        },
                        "mode": {
                          "type": "string"
                        }
                      },
                      "required": ["type", "value", "unit"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "bodyweight"
                        },
                        "added": {
                          "type": "object",
                          "properties": {
                            "value": {
                              "type": "string",
                              "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
                            },
                            "unit": {
                              "type": "string",
                              "enum": ["kg", "lb"]
                            }
                          },
                          "required": ["value", "unit"],
                          "additionalProperties": false
                        }
                      },
                      "required": ["type"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "percent_1rm"
                        },
                        "percent": {
                          "type": "number"
                        },
                        "reference": {
                          "type": "string"
                        }
                      },
                      "required": ["type", "percent"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "percent_tm"
                        },
                        "percent": {
                          "type": "number"
                        }
                      },
                      "required": ["type", "percent"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "rpe_based"
                        }
                      },
                      "required": ["type"],
                      "additionalProperties": false
                    }
                  ]
                },
                "rpe": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 10
                },
                "rir": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 10
                },
                "effort_source": {
                  "type": "string",
                  "enum": ["phase", "slot"]
                },
                "tempo": {
                  "type": "object",
                  "properties": {
                    "eccentric_s": {
                      "type": "number",
                      "minimum": 0
                    },
                    "bottom_pause_s": {
                      "type": "number",
                      "minimum": 0
                    },
                    "concentric_s": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": 0
                        },
                        {
                          "type": "string",
                          "const": "X"
                        }
                      ]
                    },
                    "top_pause_s": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "required": ["eccentric_s", "bottom_pause_s", "concentric_s", "top_pause_s"],
                  "additionalProperties": false
                },
                "rest_before_ms": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "rest_after_ms": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "intensity": {
                  "type": "object",
                  "properties": {
                    "metric": {
                      "type": "string"
                    },
                    "min": {
                      "type": "number",
                      "minimum": 0
                    },
                    "max": {
                      "type": "number",
                      "minimum": 0
                    },
                    "zone_system": {
                      "type": "string"
                    }
                  },
                  "required": ["metric", "min"],
                  "additionalProperties": false
                },
                "until": {
                  "type": "string"
                },
                "modifiers": {
                  "maxItems": 8,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                      },
                      "builtin_key": {
                        "type": "string"
                      },
                      "label": {
                        "type": "string"
                      }
                    },
                    "required": ["id", "label"],
                    "additionalProperties": false
                  },
                  "atomic": true
                },
                "notes": {
                  "type": "string"
                },
                "source": {
                  "type": "string",
                  "enum": ["manual", "program", "progression"]
                }
              },
              "required": ["id"],
              "additionalProperties": false
            },
            "atomic": true
          },
          "plan": {
            "type": "object",
            "properties": {
              "meta": {
                "type": "object",
                "properties": {
                  "created_at": {
                    "type": ["string", "null"]
                  },
                  "updated_at": {
                    "type": ["string", "null"]
                  },
                  "deleted_at": {
                    "type": ["string", "null"]
                  },
                  "legacy_ref": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "table": {
                            "type": "string"
                          },
                          "key": {
                            "type": ["string", "number"]
                          },
                          "row": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["table", "key", "row"],
                        "additionalProperties": false
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dataset": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              "extensions": {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "pattern": "^x-[a-z0-9]+-[a-z0-9-]+$"
                },
                "additionalProperties": {
                  "$ref": "#/$defs/__schema0"
                }
              },
              "planned_session": {
                "type": "object",
                "properties": {
                  "record": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "part": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                  }
                },
                "required": ["record"],
                "additionalProperties": false
              },
              "rule": {
                "type": "object",
                "properties": {
                  "record": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "part": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                  }
                },
                "required": ["record"],
                "additionalProperties": false
              },
              "rule_revision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              "week_index": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "occurrence_offset": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "deload": {
                "type": "boolean"
              },
              "targets": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "reps": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "mass": {
                      "type": "object",
                      "properties": {
                        "value": {
                          "type": "string",
                          "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
                        },
                        "unit": {
                          "type": "string",
                          "enum": ["kg", "lb"]
                        }
                      },
                      "required": ["value", "unit"],
                      "additionalProperties": false
                    },
                    "mass_kg": {
                      "type": "string",
                      "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
                    },
                    "load_mode": {
                      "type": "string",
                      "enum": ["external", "bodyweight", "assistance", "none"]
                    },
                    "load_basis": {
                      "type": "string",
                      "enum": ["total", "per_hand", "added", "assistance"]
                    },
                    "implement_count": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991
                    },
                    "side": {
                      "type": "string"
                    },
                    "rep_basis": {
                      "type": "string"
                    },
                    "duration_ms": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "distance_mm": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "rpe": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 10
                    },
                    "rir": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 10
                    },
                    "comparison": {
                      "type": "object",
                      "properties": {
                        "effective_exercise": {
                          "type": "object",
                          "properties": {
                            "record": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            }
                          },
                          "required": ["record"],
                          "additionalProperties": false
                        },
                        "variant": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "ref": {
                                  "type": "string",
                                  "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                                },
                                "catalog_key": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "attributes": {
                                  "type": "object",
                                  "properties": {
                                    "grip": {
                                      "type": "string"
                                    },
                                    "hand_position": {
                                      "type": "string"
                                    },
                                    "attachment": {
                                      "type": "string"
                                    },
                                    "stance": {
                                      "type": "string"
                                    },
                                    "equipment": {
                                      "type": "string",
                                      "enum": [
                                        "band",
                                        "dumbbell",
                                        "barbell",
                                        "cable",
                                        "machine",
                                        "kettlebell",
                                        "bodyweight",
                                        "other"
                                      ]
                                    },
                                    "support": {
                                      "type": "string",
                                      "enum": ["back", "chest", "none"]
                                    },
                                    "body_position": {
                                      "type": "string",
                                      "enum": ["seated", "standing", "kneeling"]
                                    },
                                    "laterality": {
                                      "type": "string",
                                      "enum": ["bilateral", "unilateral", "alternating"]
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": ["label", "attributes"],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "modifiers": {
                          "maxItems": 8,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                              },
                              "builtin_key": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": ["id", "label"],
                            "additionalProperties": false
                          },
                          "atomic": true
                        },
                        "benchmark_key": {
                          "type": "string"
                        },
                        "policy_generation": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": ["effective_exercise", "variant", "modifiers", "benchmark_key", "policy_generation"],
                      "additionalProperties": false
                    },
                    "reps_max": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "amrap": {
                      "type": "boolean"
                    }
                  },
                  "required": ["load_mode", "side", "rep_basis", "amrap"],
                  "additionalProperties": false
                },
                "atomic": true
              },
              "decision": {
                "$ref": "#/$defs/__schema0"
              }
            },
            "required": ["planned_session", "occurrence_offset", "deload", "targets", "decision"],
            "additionalProperties": false
          },
          "notes": {
            "type": "string"
          },
          "sets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "meta": {
                  "type": "object",
                  "properties": {
                    "created_at": {
                      "type": ["string", "null"]
                    },
                    "updated_at": {
                      "type": ["string", "null"]
                    },
                    "deleted_at": {
                      "type": ["string", "null"]
                    },
                    "legacy_ref": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "table": {
                              "type": "string"
                            },
                            "key": {
                              "type": ["string", "number"]
                            },
                            "row": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": ["table", "key", "row"],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dataset": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                },
                "extensions": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string",
                    "pattern": "^x-[a-z0-9]+-[a-z0-9-]+$"
                  },
                  "additionalProperties": {
                    "$ref": "#/$defs/__schema0"
                  }
                },
                "id": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                },
                "source_order": {
                  "type": "number"
                },
                "reps": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "mass": {
                  "type": "object",
                  "properties": {
                    "value": {
                      "type": "string",
                      "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
                    },
                    "unit": {
                      "type": "string",
                      "enum": ["kg", "lb"]
                    }
                  },
                  "required": ["value", "unit"],
                  "additionalProperties": false
                },
                "mass_kg": {
                  "type": "string",
                  "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
                },
                "load_mode": {
                  "type": "string",
                  "enum": ["external", "bodyweight", "assistance", "none"]
                },
                "load_basis": {
                  "type": "string",
                  "enum": ["total", "per_hand", "added", "assistance"]
                },
                "implement_count": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "side": {
                  "type": "string"
                },
                "rep_basis": {
                  "type": "string"
                },
                "duration_ms": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "distance_mm": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "rpe": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 10
                },
                "rir": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 10
                },
                "prescription": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                },
                "role": {
                  "type": "string"
                },
                "state": {
                  "type": "string",
                  "enum": ["draft", "completed", "skipped"]
                },
                "rest_before_ms": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "round_index": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "visit_index": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "repeat_index": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "segment_index": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "parent_set": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                },
                "started_at": {
                  "type": "string"
                },
                "completed_at": {
                  "type": "string"
                },
                "confirmed_unmeasured": {
                  "type": "boolean"
                },
                "exclude_from_charts": {
                  "type": "boolean"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "meta": {
                        "type": "object",
                        "properties": {
                          "created_at": {
                            "type": ["string", "null"]
                          },
                          "updated_at": {
                            "type": ["string", "null"]
                          },
                          "deleted_at": {
                            "type": ["string", "null"]
                          },
                          "legacy_ref": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "table": {
                                    "type": "string"
                                  },
                                  "key": {
                                    "type": ["string", "number"]
                                  },
                                  "row": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  }
                                },
                                "required": ["table", "key", "row"],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "dataset": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      },
                      "extensions": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "pattern": "^x-[a-z0-9]+-[a-z0-9-]+$"
                        },
                        "additionalProperties": {
                          "$ref": "#/$defs/__schema0"
                        }
                      },
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
                      },
                      "source_order": {
                        "type": "number"
                      },
                      "tag": {
                        "type": "object",
                        "properties": {
                          "record": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        },
                        "required": ["record"],
                        "additionalProperties": false
                      }
                    },
                    "required": ["id", "tag"],
                    "additionalProperties": false
                  }
                },
                "notes": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "load_mode",
                "side",
                "rep_basis",
                "state",
                "confirmed_unmeasured",
                "exclude_from_charts",
                "tags"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": ["id", "block_path", "exercise", "prescription_snapshot", "sets"],
        "additionalProperties": false
      }
    }
  },
  "required": ["title", "status", "time_confidence", "active_duration_ms", "pause", "occurrences"],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  },
  "$id": "https://sendtopigeon.com/schemas/session@1.schema.json",
  "title": "Pigeon Open Data: session@1",
  "$comment": "Apache-2.0. Structural schema; use Zod/parseRecord for semantic invariants. This published schema URL is immutable.",
  "examples": [
    {
      "title": "demo",
      "status": "active",
      "time_confidence": "unknown",
      "active_duration_ms": 0,
      "pause": {
        "elapsed_ms": 0
      },
      "occurrences": []
    }
  ]
}
