{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/sigr-consensus-v1.json",
  "title": "SiGR Consensus v1, signed multi-model panel receipt",
  "description": "Canonical schema for the Hive SiGR Consensus receipt, canonical type sigr.consensus. Binds a panel of independently scored model outputs (each a member's output digest and score) into one Ed25519 signature over a recomputable payload_sha256 and a service computed winning member and agreement statistic. The receipt attests that winner_seq and agreement_bp recompute exactly from the recorded members array under the declared method. It does not attest that any member output is correct, that the scoring method is well designed, or that the panel membership is complete.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_sigr\\.consensus_[0-9]{10,}_[0-9a-f]{12}$"
    },
    "payload_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "sig_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" },
    "key_id": { "type": "string", "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$" },
    "algorithm": { "type": "string", "const": "Ed25519" },
    "ts": { "type": "integer", "minimum": 1000000000 },
    "signed_body": {
      "type": "object",
      "required": [
        "receipt_type",
        "schema",
        "panel_id",
        "tenant_id",
        "method",
        "members",
        "winner_seq",
        "agreement_bp",
        "convened_at",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "sigr.consensus" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "panel_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "tenant_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "method": {
          "type": "string",
          "enum": ["highest_score", "majority_digest"],
          "description": "highest_score selects the member with the greatest score. majority_digest selects the member whose output_digest is shared by the largest number of members, ties broken by lowest seq."
        },
        "members": {
          "type": "array",
          "minItems": 2,
          "maxItems": 64,
          "description": "Ordered by seq. Each member reports one model's output digest and score for this panel.",
          "items": {
            "type": "object",
            "required": ["seq", "model_id", "output_digest_sha256", "score_bp"],
            "additionalProperties": false,
            "properties": {
              "seq": { "type": "integer", "minimum": 0, "maximum": 63 },
              "model_id": { "type": "string", "minLength": 1, "maxLength": 256 },
              "output_digest_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
              "score_bp": {
                "type": "integer",
                "minimum": 0,
                "maximum": 10000,
                "description": "Score in basis points, 0 to 10000, caller supplied and not independently checked by the signer."
              }
            }
          }
        },
        "winner_seq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 63,
          "description": "Recomputed by the verifier from members and method. Never accepted as a caller supplied verdict."
        },
        "agreement_bp": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10000,
          "description": "Recomputed by the verifier: the fraction of members, in basis points, whose output_digest_sha256 matches the winning member's output_digest_sha256."
        },
        "convened_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
        },
        "boundary": {
          "type": "string",
          "const": "This receipt attests that winner_seq and agreement_bp recompute exactly from the recorded members array under the declared method. It does not attest that any member output is correct, that the scoring method is well designed, or that the panel membership recorded here is complete."
        }
      }
    }
  }
}
