{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/philidor-io/json-schema/philidor-io-rating-dynamics-response-schema.json",
  "title": "RatingDynamicsResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/philidor-io-stats-api-openapi.yml#/components/schemas/RatingDynamicsResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "bucketStart": {
            "type": "string",
            "description": "Start of the bucket, UTC, ISO-8601."
          },
          "upgrades": {
            "type": "number",
            "description": "Vault tier moves to a better tier (toward Prime). Excludes methodology reclassifications and first ratings."
          },
          "downgrades": {
            "type": "number",
            "description": "Vault tier moves to a worse tier (toward Edge). Excludes methodology reclassifications."
          },
          "net": {
            "type": "number",
            "description": "upgrades - downgrades."
          },
          "newlyCovered": {
            "type": "number",
            "description": "Vaults receiving a first rating. Deliberately NOT counted as upgrades: there is no prior tier to have moved from, and counting them would let coverage growth read as improving credit quality."
          },
          "methodologyReclassifications": {
            "type": "number",
            "description": "Moves attributed to a methodology version change, reported separately and excluded from upgrades/downgrades. A methodology bump can move hundreds of vaults without any of them becoming riskier — the ruler changed, not the book."
          },
          "scoreOnlyChanges": {
            "type": "number",
            "description": "Score moves that did not cross a tier boundary."
          },
          "meanScoreDelta": {
            "type": [
              "number",
              "null"
            ],
            "description": "Mean (new_score - prev_score) over non-methodology moves carrying both scores. Null when the bucket has none."
          },
          "transitions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "from": {
                  "type": "string",
                  "enum": [
                    "Prime",
                    "Core",
                    "Edge"
                  ]
                },
                "to": {
                  "type": "string",
                  "enum": [
                    "Prime",
                    "Core",
                    "Edge"
                  ]
                },
                "count": {
                  "type": "number"
                }
              },
              "required": [
                "from",
                "to",
                "count"
              ]
            }
          }
        },
        "required": [
          "bucketStart",
          "upgrades",
          "downgrades",
          "net",
          "newlyCovered",
          "methodologyReclassifications",
          "scoreOnlyChanges",
          "meanScoreDelta",
          "transitions"
        ]
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "days": {
          "type": "number"
        },
        "grain": {
          "type": "string",
          "enum": [
            "day",
            "week"
          ]
        },
        "buckets": {
          "type": "number"
        },
        "upgrades": {
          "type": "number"
        },
        "downgrades": {
          "type": "number"
        },
        "net": {
          "type": "number"
        },
        "weighting": {
          "type": "string",
          "enum": [
            "vault_count"
          ],
          "description": "Counts of vaults, never TVL-weighted. rating_history stores no TVL, and weighting a historical move by today’s balance would produce a series that silently rewrites itself."
        }
      },
      "required": [
        "days",
        "grain",
        "buckets",
        "upgrades",
        "downgrades",
        "net",
        "weighting"
      ]
    }
  },
  "required": [
    "data",
    "meta"
  ]
}