{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/shruwd-io/json-schema/shruwd-io-visibility-series-across-engines-schema.json",
  "title": "VisibilitySeriesAcrossEngines",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/shruwd-io-openapi.json#/components/schemas/VisibilitySeriesAcrossEngines",
  "type": "object",
  "required": [
    "brand",
    "engine",
    "windowDays",
    "range",
    "historyFrom",
    "points",
    "engineSets",
    "entities",
    "engineSetChanges",
    "modelChanges"
  ],
  "properties": {
    "brand": {
      "type": "object",
      "required": [
        "brandId",
        "name",
        "timezone"
      ],
      "properties": {
        "brandId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "timezone": {
          "type": "string"
        }
      }
    },
    "engine": {
      "type": "string",
      "const": "all"
    },
    "windowDays": {
      "type": "integer",
      "enum": [
        7,
        30,
        90
      ]
    },
    "range": {
      "type": "object",
      "required": [
        "from",
        "to"
      ],
      "properties": {
        "from": {
          "type": "string",
          "format": "date"
        },
        "to": {
          "type": "string",
          "format": "date"
        }
      }
    },
    "historyFrom": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "points": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "date"
      },
      "description": "Cycle-close days in the range on any measured engine, ascending."
    },
    "engineSets": {
      "type": "array",
      "items": {
        "type": "array",
        "items": {
          "$ref": "#/$defs/Engine"
        }
      },
      "description": "The engines in the cross-engine rate at each point, index-aligned with `points`."
    },
    "entities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "entityId",
          "canonicalName",
          "isSelf",
          "series"
        ],
        "properties": {
          "entityId": {
            "type": "string"
          },
          "canonicalName": {
            "type": "string"
          },
          "isSelf": {
            "type": "boolean"
          },
          "series": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/$defs/AcrossSeriesPoint"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "One entry per `points` day; null when no engine has a row for the entity on that close."
          }
        }
      }
    },
    "engineSetChanges": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/EngineSetChange"
      },
      "description": "Points whose engine set differs from the previous point's. The line breaks before each; drawn across one, the change of mix reads as movement."
    },
    "modelChanges": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ModelChange"
      },
      "description": "Model changes on the engines in the set at that close, each naming its engine."
    }
  },
  "$defs": {
    "AcrossEnginesMetric": {
      "description": "A metric across engines (`metrics.md` §3.7): the equal-weight mean of\neach engine's own rate over the engines that answered through the whole\nwindow, with an interval that averages their bounds. Shown only when\nevery one of those engines has ten answers of its own; otherwise\n`insufficient_data` names the engine holding it back, and its `n` and\n`needed` are that engine's. `engine` is null when no engine qualifies.\nNever a blended score: one measure, mention rate, beside each engine's.\n",
      "oneOf": [
        {
          "type": "object",
          "required": [
            "state",
            "point",
            "lo",
            "hi",
            "n"
          ],
          "properties": {
            "state": {
              "type": "string",
              "const": "ok"
            },
            "point": {
              "type": "number",
              "description": "Mean of the engines' rates, in [0, 1]."
            },
            "lo": {
              "type": "number",
              "description": "Mean of the engines' lower bounds."
            },
            "hi": {
              "type": "number",
              "description": "Mean of the engines' upper bounds."
            },
            "n": {
              "type": "integer",
              "description": "Answers behind it, summed over the engines."
            }
          }
        },
        {
          "type": "object",
          "required": [
            "state",
            "n",
            "needed",
            "engine"
          ],
          "properties": {
            "state": {
              "type": "string",
              "const": "insufficient_data"
            },
            "n": {
              "type": "integer",
              "description": "The short engine's answers."
            },
            "needed": {
              "type": "integer",
              "description": "How many more it needs to cross the floor of ten."
            },
            "engine": {
              "oneOf": [
                {
                  "$ref": "#/$defs/Engine"
                },
                {
                  "type": "null"
                }
              ]
            }
          }
        },
        {
          "type": "object",
          "required": [
            "state",
            "n",
            "reason",
            "engine"
          ],
          "properties": {
            "state": {
              "type": "string",
              "const": "undefined"
            },
            "n": {
              "type": "integer"
            },
            "reason": {
              "type": "string"
            },
            "engine": {
              "$ref": "#/$defs/Engine"
            }
          }
        }
      ]
    },
    "AcrossSeriesPoint": {
      "type": "object",
      "required": [
        "asOf",
        "mentionRate",
        "byEngine"
      ],
      "properties": {
        "asOf": {
          "type": "string",
          "format": "date"
        },
        "mentionRate": {
          "$ref": "#/$defs/AcrossEnginesMetric"
        },
        "byEngine": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/DisplayableMetric"
          },
          "description": "Each measured engine's mention rate at this close, keyed by engine."
        }
      }
    },
    "DisplayableMetric": {
      "description": "A metric that can be shown. Never a bare number: either a point\nestimate with its 95% interval and `n`, or an explicit reason there is\nno number. `insufficient_data` is **not** zero.\n",
      "oneOf": [
        {
          "type": "object",
          "required": [
            "state",
            "point",
            "lo",
            "hi",
            "n"
          ],
          "properties": {
            "state": {
              "type": "string",
              "const": "ok"
            },
            "point": {
              "type": "number",
              "description": "Proportion in [0, 1]."
            },
            "lo": {
              "type": "number",
              "description": "Lower bound of the 95% interval."
            },
            "hi": {
              "type": "number",
              "description": "Upper bound of the 95% interval."
            },
            "n": {
              "type": "integer",
              "description": "Responses the estimate rests on."
            }
          }
        },
        {
          "type": "object",
          "required": [
            "state",
            "n",
            "needed"
          ],
          "properties": {
            "state": {
              "type": "string",
              "const": "insufficient_data"
            },
            "n": {
              "type": "integer"
            },
            "needed": {
              "type": "integer",
              "description": "How many more responses would cross the floor of ten."
            }
          }
        },
        {
          "type": "object",
          "required": [
            "state",
            "n",
            "reason"
          ],
          "properties": {
            "state": {
              "type": "string",
              "const": "undefined"
            },
            "n": {
              "type": "integer"
            },
            "reason": {
              "type": "string"
            }
          }
        }
      ]
    },
    "Engine": {
      "type": "string",
      "enum": [
        "google_aio",
        "google_ai_mode",
        "chatgpt",
        "gemini",
        "perplexity"
      ],
      "description": "`google_aio` — Google AI Overviews. `google_ai_mode` — Google AI Mode, tracked since 2026-10-15. `chatgpt` — ChatGPT. `gemini` — Gemini, tracked since 2026-11-10. `perplexity` — Perplexity, asked through its Sonar API, tracked since 2026-11-11."
    },
    "EngineSetChange": {
      "type": "object",
      "required": [
        "asOf",
        "from",
        "to"
      ],
      "properties": {
        "asOf": {
          "type": "string",
          "format": "date"
        },
        "from": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Engine"
          }
        },
        "to": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Engine"
          }
        }
      }
    },
    "ModelChange": {
      "type": "object",
      "required": [
        "asOf",
        "engine",
        "from",
        "to"
      ],
      "properties": {
        "asOf": {
          "type": "string",
          "format": "date"
        },
        "engine": {
          "$ref": "#/$defs/Engine"
        },
        "from": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "to": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}