{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/evar-v1.json",
  "title": "EvAR v1, evaluation attestation receipt",
  "description": "Canonical schema for the Hive evaluation attestation receipt, canonical type eval.attestation. Binds the evaluated system, the rubric, the dataset commitment, the evaluation method, the scored item commitment and aggregate result, the evaluator identity, the evaluation window, and the contamination check status into one Ed25519 signature over a recomputable payload_sha256. The receipt attests to the integrity of the evaluation record. It does not attest that the evaluated system is correct and it does not assert that any certificate or accreditation is valid.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_eval\\.attestation_[0-9]{10,}_[0-9a-f]{12}$",
      "description": "Receipt identifier, r_eval.attestation_<unix_seconds>_<12 hex chars>."
    },
    "payload_sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Lowercase hex SHA-256 over the canonical serialisation of signed_body. Canonical form is JSON with keys sorted and no whitespace, encoded UTF-8."
    },
    "sig_b64u": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{86}$",
      "description": "Base64url Ed25519 signature, no padding, over the ASCII string 'hive-receipt <receipt_id> <payload_sha256> <ts>'."
    },
    "key_id": {
      "type": "string",
      "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$",
      "description": "Decentralised identifier of the signing key."
    },
    "algorithm": {
      "type": "string",
      "const": "Ed25519",
      "description": "Signature algorithm. Ed25519 for this schema version."
    },
    "ts": {
      "type": "integer",
      "minimum": 1000000000,
      "description": "Unix seconds at issuance. Covered by the signature."
    },
    "signed_body": {
      "type": "object",
      "description": "The signed evaluation record. Every field here is covered by payload_sha256.",
      "required": [
        "receipt_type",
        "schema",
        "eval_id",
        "tenant_id",
        "subject",
        "rubric",
        "dataset",
        "method",
        "results",
        "evaluator",
        "window",
        "contamination_check",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "eval.attestation"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "eval_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Caller assigned identifier for this evaluation run."
        },
        "tenant_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "subject": {
          "type": "object",
          "description": "The model or system that was evaluated.",
          "required": ["system_id", "model_id", "provider"],
          "additionalProperties": false,
          "properties": {
            "system_id": { "type": "string", "minLength": 1, "maxLength": 256 },
            "model_id": { "type": "string", "minLength": 1, "maxLength": 256 },
            "provider": { "type": "string", "minLength": 1, "maxLength": 128 },
            "build_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "Optional build or weights digest as reported by the provider. This is a relayed provider assertion, not a hardware attestation."
            }
          }
        },
        "rubric": {
          "type": "object",
          "required": ["rubric_id", "rubric_sha256"],
          "additionalProperties": false,
          "properties": {
            "rubric_id": { "type": "string", "minLength": 1, "maxLength": 256 },
            "rubric_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
          }
        },
        "dataset": {
          "type": "object",
          "description": "Dataset commitment. The digest commits to the dataset without requiring it to be published.",
          "required": ["dataset_id", "dataset_sha256", "item_count"],
          "additionalProperties": false,
          "properties": {
            "dataset_id": { "type": "string", "minLength": 1, "maxLength": 256 },
            "dataset_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "item_count": { "type": "integer", "minimum": 1 }
          }
        },
        "method": {
          "type": "object",
          "required": ["method_id", "description"],
          "additionalProperties": false,
          "properties": {
            "method_id": { "type": "string", "minLength": 1, "maxLength": 256 },
            "description": { "type": "string", "minLength": 1, "maxLength": 2048 },
            "harness_version": { "type": "string", "minLength": 1, "maxLength": 128 }
          }
        },
        "results": {
          "type": "object",
          "required": ["scored_item_commitment", "scored_item_count", "aggregate"],
          "additionalProperties": false,
          "properties": {
            "scored_item_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "Commitment over the per item scores, for example a Merkle root or a digest of the canonical score list."
            },
            "scored_item_count": { "type": "integer", "minimum": 1 },
            "aggregate": {
              "type": "object",
              "required": ["metric", "value"],
              "additionalProperties": false,
              "properties": {
                "metric": { "type": "string", "minLength": 1, "maxLength": 128 },
                "value": { "type": "number" },
                "unit": { "type": "string", "minLength": 1, "maxLength": 64 }
              }
            }
          }
        },
        "evaluator": {
          "type": "object",
          "required": ["kid", "role"],
          "additionalProperties": false,
          "properties": {
            "kid": {
              "type": "string",
              "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$"
            },
            "role": {
              "type": "string",
              "enum": ["first_party", "second_party", "third_party"],
              "description": "first_party means the team that built the system ran the evaluation. third_party means an independent evaluator ran it."
            },
            "name": { "type": "string", "minLength": 1, "maxLength": 256 }
          }
        },
        "window": {
          "type": "object",
          "description": "When the evaluation ran. ended_at must not precede started_at.",
          "required": ["started_at", "ended_at"],
          "additionalProperties": false,
          "properties": {
            "started_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$"
            },
            "ended_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$"
            }
          }
        },
        "contamination_check": {
          "type": "object",
          "description": "Status of the check for overlap between the evaluation dataset and the training data. A status of passed records that the declared check ran and returned clean. It is not proof that no contamination exists. A status other than not_run requires a non empty method.",
          "required": ["status"],
          "additionalProperties": false,
          "properties": {
            "status": {
              "type": "string",
              "enum": ["not_run", "passed", "failed", "inconclusive"]
            },
            "method": { "type": "string", "minLength": 1, "maxLength": 512 },
            "evidence_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "Optional commitment to the contamination check output."
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "This receipt attests to the integrity of the evaluation record in signed_body. It does not attest that the evaluated system is correct, that the evaluation method is adequate, or that any certificate or accreditation is valid. A contamination_check status of passed records that the declared check ran and returned clean, and is not proof that the dataset is free of contamination."
        }
      }
    }
  }
}
