{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pigi-finance/json-schema/pigi-finance-vault-risk-schema.json",
  "title": "VaultRisk",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pigi-finance-openapi.yml#/components/schemas/VaultRisk",
  "type": "object",
  "properties": {
    "strategy_id": {
      "type": "integer"
    },
    "assessed": {
      "type": "boolean",
      "description": "false = no published assessment; the other fields are then null / empty."
    },
    "band": {
      "type": [
        "string",
        "null"
      ],
      "description": "A (safest) .. F, displayed by pigi as A(rb) .. F(rb). Not a credit rating."
    },
    "score": {
      "type": [
        "number",
        "null"
      ],
      "description": "0-100, higher = safer."
    },
    "date": {
      "type": [
        "string",
        "null"
      ],
      "description": "Date of the latest published row."
    },
    "methodology_version": {
      "type": [
        "string",
        "null"
      ]
    },
    "bands": {
      "type": "array",
      "description": "Band thresholds under the current methodology, e.g. [[\"A\",85],[\"B\",70],...].",
      "items": {
        "type": "array",
        "items": {},
        "minItems": 2,
        "maxItems": 2
      }
    },
    "floors": {
      "type": "array",
      "description": "Binding hard floors on the latest row — the standing warning strip.",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      }
    },
    "range": {
      "type": "string"
    },
    "from": {
      "type": [
        "string",
        "null"
      ]
    },
    "to": {
      "type": [
        "string",
        "null"
      ]
    },
    "history": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string"
          },
          "band": {
            "type": [
              "string",
              "null"
            ]
          },
          "score": {
            "type": [
              "number",
              "null"
            ]
          },
          "methodology_version": {
            "type": "string"
          },
          "event_flags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string"
          },
          "event_type": {
            "type": "string",
            "enum": [
              "methodology_update",
              "overlay",
              "hard_floor",
              "band_transition",
              "contagion_flag"
            ]
          },
          "title": {
            "type": "string"
          },
          "is_global": {
            "type": "boolean"
          }
        }
      }
    },
    "full": {
      "nullable": true,
      "x-plan": "custom",
      "allOf": [
        {
          "$ref": "#/$defs/RiskFull"
        }
      ],
      "description": "CUSTOM. The decomposition; null below Custom (with plan_required)."
    },
    "plan_required": {
      "$ref": "#/$defs/PlanRequired"
    }
  },
  "$defs": {
    "Plan": {
      "type": "string",
      "enum": [
        "free",
        "pro",
        "custom"
      ],
      "description": "The caller's plan. Unknown values in the account record read as free."
    },
    "PlanRequired": {
      "type": "object",
      "description": "Present only when the caller's plan withholds fields of this response: each key is a field that came back null for that reason, its value the plan that unlocks it.\n",
      "additionalProperties": {
        "$ref": "#/$defs/Plan"
      }
    },
    "RiskFull": {
      "type": "object",
      "description": "The full decomposition behind the score, rebuilt from the published vector.",
      "properties": {
        "methodology_version": {
          "type": "string"
        },
        "raw_band": {
          "type": [
            "string",
            "null"
          ],
          "description": "Band the score sits in before dwell; may differ from the published band."
        },
        "blend": {
          "type": "object",
          "properties": {
            "rosette_weight": {
              "type": "number"
            },
            "anchor_weight": {
              "type": "number"
            }
          }
        },
        "rosette": {
          "type": "object",
          "properties": {
            "score": {
              "type": [
                "number",
                "null"
              ]
            },
            "dimensions": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "weight": {
                    "type": "number"
                  },
                  "score": {
                    "type": "number"
                  },
                  "points": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  },
                  "subscores": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        },
                        "position": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "points": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "max": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "applicable": {
                          "type": "boolean"
                        },
                        "precedent": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "anchor": {
          "type": "object",
          "properties": {
            "score": {
              "type": [
                "number",
                "null"
              ]
            },
            "points": {
              "type": [
                "number",
                "null"
              ]
            },
            "max": {
              "type": [
                "number",
                "null"
              ]
            },
            "inputs": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "value": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "unit": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "band": {
                    "type": "string"
                  },
                  "points": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "dependency_cap": {
          "type": "object",
          "properties": {
            "cap": {
              "type": [
                "number",
                "null"
              ]
            },
            "binding": {
              "type": "boolean"
            },
            "critical_dep_min": {
              "type": [
                "number",
                "null"
              ]
            },
            "slack": {
              "type": [
                "number",
                "null"
              ]
            },
            "critical_edges": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "edges": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "node_id": {
                    "type": "string"
                  },
                  "label": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "node_type": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "critical": {
                    "type": "boolean"
                  },
                  "rated": {
                    "type": "boolean"
                  },
                  "rating": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "unrated_reason": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        },
        "overlays": {
          "type": "object",
          "properties": {
            "clamp": {
              "type": [
                "number",
                "null"
              ]
            },
            "net": {
              "type": "number"
            },
            "applied": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "delta": {
                    "type": "number"
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "expires": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        },
        "floors": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "cap": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "applied_cap": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "binding": {
                "type": "boolean"
              }
            }
          }
        },
        "computation": {
          "type": "object",
          "properties": {
            "s_raw": {
              "type": [
                "number",
                "null"
              ]
            },
            "overlays_net": {
              "type": [
                "number",
                "null"
              ]
            },
            "cap_applied": {
              "type": [
                "number",
                "null"
              ]
            },
            "final": {
              "type": [
                "number",
                "null"
              ]
            }
          }
        },
        "history": {
          "type": "array",
          "description": "Per-day private series over the same window as the Basic history.",
          "items": {
            "type": "object",
            "properties": {
              "date": {
                "type": "string"
              },
              "anchor_score": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "rosette_score": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "dependency_cap": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          }
        }
      }
    }
  }
}