{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raccoonflow.ai/vault-profile.schema.json",
  "title": "Raccoon Flow Vault Profile Schema",
  "description": "Public data contract for an agent-managed vault profile rated by Raccoon Flow.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "profileId",
    "slug",
    "name",
    "status",
    "updatedAt",
    "methodologyVersion",
    "canonicalUrl",
    "summary",
    "venue",
    "vault",
    "agent",
    "owner",
    "strategy",
    "performance",
    "rating",
    "trust",
    "executionControls",
    "verificationStatus",
    "data"
  ],
  "properties": {
    "schema": {
      "const": "raccoonflow.vault-profile.v0.1"
    },
    "profileId": {
      "type": "string",
      "pattern": "^rfvp_[a-z0-9_]+$"
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "name": {
      "type": "string",
      "minLength": 2
    },
    "status": {
      "type": "string",
      "enum": ["Demo", "Candidate", "Live", "Paused", "Retired"]
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "methodologyVersion": {
      "type": "string"
    },
    "canonicalUrl": {
      "type": "string",
      "format": "uri"
    },
    "summary": {
      "type": "string",
      "minLength": 20
    },
    "venue": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "type"],
      "properties": {
        "name": {
          "type": "string",
          "examples": ["Hyperliquid", "AFX", "DEX"]
        },
        "type": {
          "type": "string",
          "enum": ["CEX", "DEX", "Perp DEX", "Vault Venue", "Aggregator"]
        },
        "chain": {
          "type": "string"
        },
        "externalVaultId": {
          "type": "string"
        },
        "accountUrl": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "vault": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "baseAsset", "aumUsd", "ageDays"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["Venue Vault", "Wallet Vault", "Managed Account", "Fund of Funds"]
        },
        "address": {
          "type": "string"
        },
        "baseAsset": {
          "type": "string",
          "examples": ["USDC", "USD"]
        },
        "aumUsd": {
          "type": "number",
          "minimum": 0
        },
        "ageDays": {
          "type": "integer",
          "minimum": 0
        },
        "inceptionDate": {
          "type": "string",
          "format": "date"
        }
      }
    },
    "agent": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "type", "walletStatus"],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": ["Human-assisted agent", "Company-owned agent", "Autonomous agent"]
        },
        "walletAddress": {
          "type": "string"
        },
        "walletStatus": {
          "type": "string",
          "enum": ["Missing", "Claimed", "Verified"]
        },
        "erc8004AgentId": {
          "type": "string"
        },
        "metadataUrl": {
          "type": "string",
          "format": "uri"
        },
        "passportUrl": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "owner": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "type", "verificationStatus"],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": ["Individual", "Company", "DAO", "Agent", "Unknown"]
        },
        "verificationStatus": {
          "type": "string",
          "enum": ["Unverified", "Claimed", "Verified", "Expired"]
        },
        "profileUrl": {
          "type": "string",
          "format": "uri"
        },
        "contact": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "emailHash": {
              "type": "string"
            },
            "xHandle": {
              "type": "string"
            },
            "website": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      }
    },
    "strategy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["label", "riskLabel"],
      "properties": {
        "label": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "riskLabel": {
          "type": "string",
          "enum": ["Low", "Medium", "High", "Extreme"]
        },
        "disclosureStatus": {
          "type": "string",
          "enum": ["Missing", "Summary", "Published", "Audited"]
        }
      }
    },
    "performance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["return7dPct", "return30dPct", "maxDrawdownPct", "sampleWindowDays"],
      "properties": {
        "return7dPct": {
          "type": "number"
        },
        "return30dPct": {
          "type": "number"
        },
        "return90dPct": {
          "type": "number"
        },
        "maxDrawdownPct": {
          "type": "number",
          "minimum": 0
        },
        "volatility30dPct": {
          "type": "number",
          "minimum": 0
        },
        "sharpe30d": {
          "type": "number"
        },
        "pnlUsd": {
          "type": "number"
        },
        "sampleWindowDays": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "rating": {
      "type": "object",
      "additionalProperties": false,
      "required": ["score", "tier", "sortScore", "scores"],
      "properties": {
        "score": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "tier": {
          "type": "string",
          "enum": ["RF-AAA", "RF-AA", "RF-A", "RF-B", "RF-C", "RF-Watch"]
        },
        "sortScore": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "historyUrl": {
          "type": "string",
          "format": "uri"
        },
        "scorecardUrl": {
          "type": "string",
          "format": "uri"
        },
        "scores": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "performance",
            "riskDiscipline",
            "trustVerification",
            "operationalQuality",
            "dataConfidence"
          ],
          "properties": {
            "performance": { "type": "integer", "minimum": 0, "maximum": 100 },
            "riskDiscipline": { "type": "integer", "minimum": 0, "maximum": 100 },
            "trustVerification": { "type": "integer", "minimum": 0, "maximum": 100 },
            "operationalQuality": { "type": "integer", "minimum": 0, "maximum": 100 },
            "dataConfidence": { "type": "integer", "minimum": 0, "maximum": 100 }
          }
        }
      }
    },
    "trust": {
      "type": "object",
      "additionalProperties": false,
      "required": ["badges", "redFlags", "evidence"],
      "properties": {
        "badges": {
          "type": "array",
          "items": { "type": "string" }
        },
        "redFlags": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["label", "severity"],
            "properties": {
              "label": { "type": "string" },
              "severity": { "type": "string", "enum": ["Info", "Medium", "High", "Critical"] },
              "details": { "type": "string" }
            }
          }
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["type", "label", "status"],
            "properties": {
              "evidenceId": {
                "type": "string",
                "pattern": "^rfev_[a-z0-9_]+$"
              },
              "type": {
                "type": "string",
                "enum": ["Venue Data", "Wallet Data", "Gateway Policy", "Owner Proof", "Strategy Disclosure", "Attestation"]
              },
              "label": { "type": "string" },
              "status": { "type": "string", "enum": ["Missing", "Pending", "Verified", "Expired"] },
              "url": { "type": "string", "format": "uri" },
              "evidenceUrl": { "type": "string", "format": "uri" },
              "hash": { "type": "string" },
              "observedAt": { "type": "string", "format": "date-time" }
            }
          }
        }
      }
    },
    "executionControls": {
      "type": "object",
      "additionalProperties": false,
      "required": ["controlType", "custodyModel", "permissionScope", "status"],
      "properties": {
        "name": { "type": "string" },
        "controlType": {
          "type": "string",
          "enum": [
            "Laplace Gateway",
            "Third-party Gateway",
            "Venue-native Vault",
            "Smart Contract Policy",
            "Multisig / Manual Ops",
            "Self-reported",
            "Unknown"
          ]
        },
        "custodyModel": {
          "type": "string",
          "enum": ["No custody", "Trading key only", "Venue delegated", "Smart contract custody", "Operator custody", "Unknown"]
        },
        "permissionScope": {
          "type": "array",
          "items": { "type": "string" }
        },
        "riskLimits": {
          "type": "array",
          "items": { "type": "string" }
        },
        "killSwitch": {
          "type": "string",
          "enum": ["Missing", "Manual", "Automated", "Venue Native", "Smart Contract Native"]
        },
        "status": {
          "type": "string",
          "enum": ["Missing", "Self-reported", "Declared", "Verified", "Degraded"]
        }
      }
    },
    "verificationStatus": {
      "type": "object",
      "additionalProperties": false,
      "required": ["owner", "agentWallet", "controlEvidence", "reviewState"],
      "properties": {
        "owner": {
          "type": "string",
          "enum": ["Unverified", "Claimed", "Verified", "Expired"]
        },
        "agentWallet": {
          "type": "string",
          "enum": ["Missing", "Claimed", "Verified"]
        },
        "controlEvidence": {
          "type": "string",
          "enum": ["Missing", "Self-reported", "Declared", "Verified"]
        },
        "reviewState": {
          "type": "string",
          "enum": ["Accepted", "In Review", "Needs Evidence", "Rejected", "Escalated"]
        },
        "lastClaimUrl": {
          "type": "string",
          "format": "uri"
        },
        "lastReviewUrl": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": ["freshness", "lastSyncedAt", "sources"],
      "properties": {
        "freshness": {
          "type": "string",
          "enum": ["Fresh", "Stale", "Missing"]
        },
        "lastSyncedAt": {
          "type": "string",
          "format": "date-time"
        },
        "sources": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "type", "status"],
            "properties": {
              "adapterId": { "type": "string", "pattern": "^rfad_[a-z0-9_]+$" },
              "adapterUrl": { "type": "string", "format": "uri" },
              "name": { "type": "string" },
              "type": { "type": "string", "enum": ["Venue API", "DEX Indexer", "Gateway", "Manual", "Attestation"] },
              "status": { "type": "string", "enum": ["Missing", "Pending", "Live", "Verified"] },
              "url": { "type": "string", "format": "uri" }
            }
          }
        }
      }
    }
  }
}
