{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/philidor-io/json-schema/philidor-io-vault-scores-response-schema.json",
  "title": "VaultScoresResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/philidor-io-vaults-api-openapi.yml#/components/schemas/VaultScoresResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/VaultScore"
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "page": {
          "type": "number",
          "description": "The page parameter as received. Under offset paging (offset supplied) the offset takes precedence and meta.offset reports the row offset applied."
        },
        "limit": {
          "type": "number"
        },
        "total": {
          "type": "number"
        },
        "totalPages": {
          "type": "number"
        },
        "offset": {
          "type": "number",
          "description": "Present only when the request paged by offset: the row offset applied."
        }
      },
      "required": [
        "page",
        "limit",
        "total",
        "totalPages"
      ]
    }
  },
  "required": [
    "data",
    "meta"
  ],
  "$defs": {
    "VaultScore": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "chain_id": {
          "type": "number"
        },
        "chain_name": {
          "type": "string"
        },
        "protocol_id": {
          "type": "string"
        },
        "asset_symbol": {
          "type": [
            "string",
            "null"
          ]
        },
        "tvl_usd": {
          "type": "number"
        },
        "tvl_semantics": {
          "type": "string",
          "enum": [
            "overlapping_position_value"
          ],
          "description": "Gross value of indexed PT and LP positions. PT supply includes tokens held in LP reserves, so these values overlap and are not unique capital."
        },
        "apr_net": {
          "type": [
            "number",
            "null"
          ]
        },
        "available_liquidity_usd": {
          "type": [
            "number",
            "null"
          ],
          "description": "Estimated immediately available lending liquidity in USD. Same null-propagating point-in-time metric as the full vault response."
        },
        "liquidity_deficit_usd": {
          "type": [
            "number",
            "null"
          ],
          "description": "Estimated liquidity deficit in USD. Same metric as the full vault response."
        },
        "liquidity_status": {
          "type": "string",
          "enum": [
            "available",
            "exhausted",
            "deficit",
            "unknown"
          ],
          "description": "Liquidity interpretation. Same enum as the full vault response."
        },
        "total_score": {
          "type": [
            "number",
            "null"
          ]
        },
        "risk_tier": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "Prime",
            "Core",
            "Edge",
            null
          ],
          "description": "Published tier (hysteresis-stabilized). May briefly differ from a naive derivation from risk_score while a boundary move is dwelling."
        },
        "capped_by": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "asset": {
              "type": "string",
              "description": "Symbol of the collateral that explains the cap."
            },
            "address": {
              "type": "string",
              "description": "Address of that collateral on the exposure chain."
            },
            "reason": {
              "type": "string",
              "enum": [
                "unevaluated_collateral"
              ],
              "description": "The cap is explained by collateral that is still provisional or unreviewed. total_score and risk_tier are unchanged."
            },
            "label": {
              "type": "string",
              "description": "French badge text for the product UI. Render this string; do not recompute the tier from it."
            }
          },
          "required": [
            "asset",
            "address",
            "reason",
            "label"
          ],
          "description": "Set when asset-quality drag or the unreviewed-collateral rule is binding because of an unevaluated collateral exposure at weight ≥ 5%. Null when the vault is not capped that way, or when the weakest significant collateral is a reviewed judgment. Does not change total_score or risk_tier."
        },
        "is_active": {
          "type": "boolean"
        },
        "last_synced_at": {
          "type": "string"
        },
        "score_run_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Id of the risk scoring run that produced total_score and risk_tier (PHI-286). Null until the vault has been scored. Rows sharing a run were scored under one methodology pass; compare runs across rows to detect a partially applied recalculation."
        },
        "risk_score_run_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Score run provenance (alias of score_run_id)"
        },
        "scored_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "Completion time of the score run (alias of score_computed_at)"
        },
        "as_of": {
          "type": "string",
          "description": "Time at which freshness_seconds was measured; preserved on cache replay"
        },
        "score_computed_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "When the scoring run that produced this row completed (ISO 8601). Null until scored. Independent of last_synced_at: a fresh sync can carry an older score."
        },
        "score_updated_at": {
          "type": [
            "string",
            "null"
          ],
          "description": "When the published score or tier last changed VALUE (ISO 8601); unchanged by a run that re-confirms the score (0.05 deadband). Drives ?changed=score on /v1/vaults/changes."
        },
        "freshness_seconds": {
          "type": [
            "number",
            "null"
          ],
          "description": "Seconds since last_synced_at measured at as_of; null when never synced."
        },
        "needs_risk_review": {
          "type": "boolean",
          "description": "True while a data-quality quarantine is active on the vault (a reward-APR reconciliation mismatch, or a non-finite supply APY observation); the score is provisional until it clears."
        },
        "is_high_confidence": {
          "type": "boolean",
          "description": "Curated shortlist flag, not a confidence interval: total_score at least 7.5 AND net APR between 3% and 10%."
        },
        "tvl_status": {
          "type": "string",
          "enum": [
            "observed",
            "unavailable"
          ],
          "description": "observed: tvl_usd is a read value; unavailable: the TVL read failed and tvl_usd is served as 0 for compatibility."
        }
      },
      "required": [
        "id",
        "address",
        "chain_id",
        "chain_name",
        "protocol_id",
        "asset_symbol",
        "tvl_usd",
        "apr_net",
        "available_liquidity_usd",
        "liquidity_deficit_usd",
        "liquidity_status",
        "total_score",
        "risk_tier",
        "capped_by",
        "is_active",
        "last_synced_at"
      ]
    }
  }
}