{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xcathletes.org/contract/schemas/training-block.json",
  "title": "training_block",
  "description": "One entry of training_session.blocks[]. Not independently addressable: a session write carrying `blocks` replaces the whole set (WR-06). Response schema, PRIN-04 open.",
  "type": "object",
  "additionalProperties": true,
  "required": ["position", "reps", "duration_seconds", "zone"],
  "properties": {
    "position": { "type": "integer", "minimum": 0, "description": "Wire order within the session's blocks array." },
    "reps": { "type": "integer", "minimum": 1 },
    "duration_seconds": { "type": ["integer", "null"], "minimum": 0, "description": "ENT-02: integer seconds. null on a legacy row this migration has not backfilled, which the ENT-05 computed formula treats as zero." },
    "zone": {
      "type": ["string", "null"],
      "enum": ["L1", "L2", "L3", "L4", "L5", null],
      "description": "ENT-03: the lactate-turn-point zone; null for strength and spenst blocks. An unrecognized value falls back to null (treat as unzoned)."
    }
  },
  "$defs": {
    "writeItem": {
      "title": "training_block write item",
      "description": "One entry of a training-session create/update request's `blocks` array (WR-06). Request schema, PRIN-04 strict.",
      "type": "object",
      "additionalProperties": false,
      "required": ["reps", "duration_seconds", "zone"],
      "properties": {
        "reps": { "type": "integer", "minimum": 1 },
        "duration_seconds": { "type": "integer", "minimum": 1, "maximum": 86400 },
        "zone": { "type": ["string", "null"], "enum": ["L1", "L2", "L3", "L4", "L5", null], "description": "ENT-03: the lactate-turn-point zone; null for strength and spenst blocks. An unrecognized value falls back to null (treat as unzoned)." }
      }
    }
  }
}
