{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raccoonflow.ai/scorecard.schema.json",
  "title": "Raccoon Flow Scorecard Schema",
  "description": "Public data contract for explaining a Raccoon Flow agent vault rating.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "scorecardId",
    "updatedAt",
    "methodologyVersion",
    "methodologyUrl",
    "ratingHistoryUrl",
    "profile",
    "agent",
    "owner",
    "rating",
    "dimensions",
    "capsApplied",
    "redFlags",
    "supportingEvidence",
    "openRequests",
    "upgradePath",
    "investorTakeaway"
  ],
  "properties": {
    "schema": {
      "const": "raccoonflow.scorecard.v0.1"
    },
    "scorecardId": {
      "type": "string",
      "pattern": "^rfsc_[a-z0-9_]+$"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "methodologyVersion": {
      "type": "string"
    },
    "methodologyUrl": {
      "type": "string",
      "format": "uri"
    },
    "ratingHistoryUrl": {
      "type": "string",
      "format": "uri"
    },
    "profile": {
      "type": "object",
      "additionalProperties": false,
      "required": ["profileId", "name", "profileUrl", "profileJson"],
      "properties": {
        "profileId": { "type": "string" },
        "name": { "type": "string" },
        "profileUrl": { "type": "string", "format": "uri" },
        "profileJson": { "type": "string", "format": "uri" }
      }
    },
    "agent": {
      "type": "object",
      "additionalProperties": false,
      "required": ["agentId", "name", "type", "passportUrl"],
      "properties": {
        "agentId": { "type": "string" },
        "name": { "type": "string" },
        "type": { "type": "string" },
        "passportUrl": { "type": "string", "format": "uri" }
      }
    },
    "owner": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ownerId", "name", "verificationStatus", "profileUrl"],
      "properties": {
        "ownerId": { "type": "string" },
        "name": { "type": "string" },
        "verificationStatus": { "type": "string" },
        "profileUrl": { "type": "string", "format": "uri" }
      }
    },
    "rating": {
      "type": "object",
      "additionalProperties": false,
      "required": ["score", "tier", "confidence", "reviewState", "summary"],
      "properties": {
        "score": { "type": "integer", "minimum": 0, "maximum": 100 },
        "tier": { "type": "string" },
        "confidence": { "type": "string", "enum": ["High", "Medium", "Low"] },
        "reviewState": { "type": "string" },
        "summary": { "type": "string" }
      }
    },
    "dimensions": {
      "type": "array",
      "minItems": 5,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "label", "score", "weight", "explanation", "evidenceIds", "blockers"],
        "properties": {
          "id": { "type": "string" },
          "label": { "type": "string" },
          "score": { "type": "integer", "minimum": 0, "maximum": 100 },
          "weight": { "type": "number", "minimum": 0, "maximum": 1 },
          "explanation": { "type": "string" },
          "evidenceIds": {
            "type": "array",
            "items": { "type": "string" }
          },
          "blockers": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      }
    },
    "capsApplied": {
      "type": "array",
      "items": { "type": "object" }
    },
    "redFlags": {
      "type": "array",
      "items": { "type": "object" }
    },
    "supportingEvidence": {
      "type": "array",
      "items": { "type": "string" }
    },
    "openRequests": {
      "type": "array",
      "items": { "type": "string" }
    },
    "upgradePath": {
      "type": "array",
      "items": { "type": "string" }
    },
    "investorTakeaway": {
      "type": "string"
    }
  }
}
