{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://siebly.io/.well-known/conformance/historical-live-data/v1/schema.json",
  "title": "Historical Backfill + Live Stream Workflow Fixture",
  "description": "JSON fixture projection for historical backfill plus live stream conformance. Runner expectations use partial object matching and array containment that consumes one observed item per expected item, with empty expected arrays requiring empty observed arrays.",
  "type": "object",
  "required": ["version", "fixtures"],
  "additionalProperties": false,
  "properties": {
    "version": {
      "type": "string",
      "const": "historical-live-data.workflow.v1"
    },
    "fixtures": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/fixture"
      }
    }
  },
  "$defs": {
    "fixture": {
      "type": "object",
      "required": ["name", "intent", "dataFamily", "scope", "initial", "steps", "expect"],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:_[a-z0-9]+)*$"
        },
        "intent": {
          "type": "string",
          "minLength": 1
        },
        "dataFamily": {
          "type": "string"
        },
        "requiredForProductionDataPipeline": {
          "type": "boolean",
          "default": true
        },
        "scope": {
          "$ref": "#/$defs/scope"
        },
        "initial": {
          "$ref": "#/$defs/initial"
        },
        "steps": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/step"
          }
        },
        "expect": {
          "$ref": "#/$defs/expectation"
        },
        "forbid": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "scope": {
      "type": "object",
      "required": ["exchange", "product", "symbol", "stream"],
      "additionalProperties": false,
      "properties": {
        "exchange": {
          "type": "string"
        },
        "product": {
          "type": "string"
        },
        "symbol": {
          "type": "string"
        },
        "stream": {
          "type": "string"
        },
        "interval": {
          "type": ["string", "null"]
        },
        "category": {
          "type": ["string", "null"]
        }
      }
    },
    "initial": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "config": {
          "type": "object",
          "additionalProperties": true
        },
        "readiness": {
          "type": "object",
          "additionalProperties": true
        },
        "store": {
          "type": "object",
          "additionalProperties": true
        },
        "bufferedEvents": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "clockMs": {
          "type": "integer"
        }
      }
    },
    "step": {
      "type": "object",
      "required": ["type"],
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "configure",
            "transport_open",
            "subscription_request",
            "subscription_ack",
            "rest_backfill",
            "websocket_event",
            "replay_buffer",
            "downstream_tick",
            "reconnect",
            "resync",
            "shutdown"
          ]
        },
        "atMs": {
          "type": "integer"
        },
        "payload": {
          "type": "object",
          "additionalProperties": true
        }
      }
    },
    "expectation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "readiness": {
          "type": "object",
          "additionalProperties": true
        },
        "store": {
          "type": "object",
          "additionalProperties": true
        },
        "bufferedEvents": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "downstreamEffects": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "resyncState": {
          "type": "object",
          "additionalProperties": true
        },
        "blocks": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "logs": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    }
  }
}
