{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/perception-to/json-schema/perception-to-index-portfolio-response-schema.json",
  "title": "IndexPortfolioResponse",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/perception-to-openapi.json#/components/schemas/IndexPortfolioResponse",
  "type": "object",
  "required": [
    "schemaVersion",
    "asset",
    "generatedAt",
    "sourceMaxDate",
    "metrics",
    "attribution"
  ],
  "properties": {
    "schemaVersion": {
      "type": "integer",
      "enum": [
        1
      ]
    },
    "asset": {
      "type": "string",
      "enum": [
        "bitcoin"
      ]
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "sourceMaxDate": {
      "type": "string",
      "format": "date"
    },
    "calculationDurationMs": {
      "type": "number",
      "minimum": 0
    },
    "errors": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "metrics": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "$ref": "#/$defs/IndexMetricReading"
      }
    },
    "attribution": {
      "type": "string"
    }
  },
  "$defs": {
    "IndexHistoryPoint": {
      "type": "object",
      "required": [
        "date",
        "value"
      ],
      "properties": {
        "date": {
          "type": "string",
          "format": "date"
        },
        "value": {
          "type": "number"
        },
        "btcPrice": {
          "type": [
            "number",
            "null"
          ]
        }
      }
    },
    "IndexMetricReading": {
      "type": "object",
      "required": [
        "id",
        "name",
        "methodologyVersion",
        "unit",
        "current",
        "change",
        "confidence",
        "observedItems",
        "windowStart",
        "windowEnd",
        "updatedAt",
        "frequency"
      ],
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "perception",
            "bitcoin_discourse_dominance",
            "narrative_cost_basis",
            "cohort_conviction_gap",
            "perception_breadth"
          ]
        },
        "name": {
          "type": "string"
        },
        "methodologyVersion": {
          "type": "string"
        },
        "unit": {
          "type": "string",
          "enum": [
            "score",
            "percent",
            "usd"
          ]
        },
        "current": {
          "type": [
            "number",
            "null"
          ]
        },
        "secondary": {
          "type": "object",
          "required": [
            "label",
            "value",
            "unit"
          ],
          "properties": {
            "label": {
              "type": "string"
            },
            "value": {
              "type": "number"
            },
            "unit": {
              "type": "string",
              "enum": [
                "percent",
                "usd"
              ]
            }
          }
        },
        "change": {
          "type": [
            "number",
            "null"
          ]
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "observedItems": {
          "type": "integer",
          "minimum": 0
        },
        "windowStart": {
          "type": "string",
          "format": "date"
        },
        "windowEnd": {
          "type": "string",
          "format": "date"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "frequency": {
          "type": "string",
          "enum": [
            "realtime",
            "daily",
            "weekly"
          ]
        },
        "history": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/IndexHistoryPoint"
          }
        },
        "breakdown": {
          "type": "object",
          "additionalProperties": true
        },
        "provenance": {
          "type": "object",
          "additionalProperties": true
        },
        "methodology": {
          "type": "object",
          "required": [
            "summary",
            "minimumCoverage",
            "sourceTables"
          ],
          "properties": {
            "summary": {
              "type": "string"
            },
            "minimumCoverage": {
              "type": "string"
            },
            "sourceTables": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}