{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://zim.one/schemas/validator-receipt-v3.schema.json",
  "title": "ZIM.ONE Stakewiz Index Receipt v3",
  "description": "A browser-compiled Stakewiz index and native point-history record with independent observation clocks. Not an RPC, Votor or atomic network observation.",
  "type": "object",
  "required": [
    "schema_version",
    "kind",
    "compiled_at",
    "operator",
    "network",
    "accounts",
    "epoch",
    "observed_at",
    "source_mode",
    "metrics",
    "score_trace",
    "seal",
    "signature",
    "sources",
    "manifest",
    "disclosure",
    "integrity",
    "$schema",
    "observation_scope",
    "metrics_source"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri",
      "pattern": "/schemas/validator-receipt-v3\\.schema\\.json$"
    },
    "schema_version": {
      "const": "3.0.0"
    },
    "kind": {
      "const": "validator_epoch_receipt"
    },
    "compiled_at": {
      "type": "string",
      "format": "date-time"
    },
    "operator": {
      "const": "ZIM.ONE"
    },
    "network": {
      "const": "solana-mainnet-beta"
    },
    "accounts": {
      "type": "object",
      "required": [
        "validator_identity",
        "vote_account"
      ],
      "properties": {
        "validator_identity": {
          "const": "2zykwzzo1pd3H2oSj5j5SRLTvmpa9Nr2S2Bh8tTVd5Tq"
        },
        "vote_account": {
          "const": "Hmq1oALENff8DejgYhJxB4njb6pyCtuMKKxotdZicB4n"
        }
      },
      "additionalProperties": false
    },
    "epoch": {
      "type": "integer",
      "minimum": 0
    },
    "observed_at": {
      "type": "string",
      "format": "date-time",
      "description": "Observation time of the metrics/index record, independent of the history clock."
    },
    "source_mode": {
      "enum": [
        "live",
        "snapshot"
      ]
    },
    "metrics": {
      "type": "object",
      "required": [
        "active_stake_sol",
        "vote_success_percent",
        "uptime_percent",
        "commission_percent",
        "client_version",
        "rank",
        "delinquent"
      ],
      "properties": {
        "active_stake_sol": {
          "type": "number",
          "minimum": 0
        },
        "vote_success_percent": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "uptime_percent": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "commission_percent": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "client_version": {
          "type": "string"
        },
        "rank": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1
        },
        "delinquent": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "score_trace": {
      "type": "object",
      "required": [
        "source_mode",
        "coverage",
        "samples",
        "unit",
        "source",
        "observed_at"
      ],
      "properties": {
        "source_mode": {
          "enum": [
            "live",
            "snapshot"
          ]
        },
        "coverage": {
          "const": "recent_source_observations"
        },
        "samples": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "object",
            "required": [
              "observed_at",
              "validator_score_points",
              "cluster_baseline_points"
            ],
            "properties": {
              "observed_at": {
                "type": "string",
                "format": "date-time"
              },
              "validator_score_points": {
                "type": "number",
                "description": "Native Stakewiz points; not a percentage."
              },
              "cluster_baseline_points": {
                "type": "number",
                "description": "Native Stakewiz baseline points; not a percentage."
              }
            },
            "additionalProperties": false
          },
          "maxItems": 10000
        },
        "unit": {
          "const": "stakewiz_native_points"
        },
        "source": {
          "type": "string",
          "format": "uri"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time",
          "description": "Exact observation time of the final trace sample, independent of metrics and compilation."
        }
      },
      "additionalProperties": false
    },
    "seal": {
      "type": "object",
      "required": [
        "engine",
        "source",
        "threshold",
        "symmetry",
        "grammar",
        "topology",
        "active_cells",
        "visual_checksum"
      ],
      "properties": {
        "engine": {
          "enum": [
            "zim-photo-d4-v3",
            "zim-photo-d4-root-v1"
          ]
        },
        "source": {
          "enum": [
            "root",
            "identity",
            "epoch",
            "monad"
          ]
        },
        "threshold": {
          "type": "integer",
          "minimum": 0,
          "maximum": 255
        },
        "symmetry": {
          "type": "boolean"
        },
        "grammar": {
          "enum": [
            "stitch",
            "pcb",
            "pixel"
          ]
        },
        "topology": {
          "enum": [
            "single",
            "quad"
          ]
        },
        "active_cells": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1156
        },
        "visual_checksum": {
          "type": "string",
          "pattern": "^[a-f0-9]{8}$"
        },
        "variant_seed": {
          "type": "string",
          "pattern": "^[a-f0-9]{16}$"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "engine": {
                "const": "zim-photo-d4-root-v1"
              }
            },
            "required": [
              "engine"
            ]
          },
          "then": {
            "required": [
              "variant_seed"
            ],
            "properties": {
              "source": {
                "const": "root"
              }
            },
            "allOf": [
              {
                "if": {
                  "properties": {
                    "topology": {
                      "const": "single"
                    }
                  },
                  "required": [
                    "topology"
                  ]
                },
                "then": {
                  "properties": {
                    "grammar": {
                      "const": "pixel"
                    },
                    "active_cells": {
                      "maximum": 289
                    }
                  }
                }
              }
            ]
          },
          "else": {
            "not": {
              "required": [
                "variant_seed"
              ]
            }
          }
        }
      ],
      "additionalProperties": false
    },
    "signature": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "enum": [
            "unsigned",
            "signed"
          ]
        },
        "reason": {
          "type": "string"
        },
        "key_id": {
          "type": "string"
        },
        "public_key": {
          "type": "string"
        },
        "algorithm": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "const": "signed"
              }
            }
          },
          "then": {
            "required": [
              "key_id",
              "public_key",
              "algorithm",
              "value"
            ]
          },
          "else": {
            "required": [
              "reason"
            ]
          }
        }
      ],
      "additionalProperties": false
    },
    "previous_receipt_digest": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^[a-f0-9]{64}$"
    },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "format": "uri"
      }
    },
    "manifest": {
      "type": "string",
      "format": "uri"
    },
    "disclosure": {
      "type": "string",
      "minLength": 1
    },
    "integrity": {
      "type": "object",
      "required": [
        "algorithm",
        "canonicalization",
        "scope",
        "digest"
      ],
      "properties": {
        "algorithm": {
          "const": "SHA-256"
        },
        "canonicalization": {
          "const": "sorted-json-v1"
        },
        "scope": {
          "const": "document_without_integrity"
        },
        "digest": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "additionalProperties": false
    },
    "observation_scope": {
      "const": "stakewiz_index_and_native_score_history"
    },
    "metrics_source": {
      "type": "string",
      "format": "uri"
    }
  },
  "additionalProperties": false
}
