{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/capability-exercise-v1.json",
  "title": "Capability Exercise Receipt, v1",
  "description": "Canonical schema for the Hive capability exercise receipt, canonical type capability.exercise.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_capability\\.exercise_[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",
        "capability_exercise",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "capability.exercise"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "capability_exercise": {
          "type": "object",
          "required": [
            "exercise_id",
            "recorded_at",
            "capability",
            "committed_at",
            "contacted_at",
            "observed_at",
            "time_reference",
            "observed_drift_ms",
            "drift_class",
            "challenge_count",
            "challenge_commitments",
            "challenge_set_digest",
            "observed_output_digest",
            "invocation_class",
            "provider_participation",
            "exerciser",
            "provider_control_set_digest",
            "independence_class",
            "per_challenge_outcomes",
            "matched_count",
            "detection_rate_bp",
            "conformance_verdict",
            "exerciser_role",
            "evidence_access_class",
            "salt_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "exercise_id": {
              "type": "string",
              "pattern": "^cx_[0-9a-f]{16,64}$"
            },
            "recorded_at": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$"
            },
            "capability": {
              "type": "object",
              "required": [
                "capability_id",
                "capability_url",
                "capability_class",
                "published_claim_digest"
              ],
              "additionalProperties": false,
              "properties": {
                "capability_id": {
                  "type": "string",
                  "pattern": "^cp_[0-9a-z_]{1,48}$"
                },
                "capability_url": {
                  "type": "string",
                  "pattern": "^https://[A-Za-z0-9._~:/?#@!$&'()*+,;=%-]{3,512}$"
                },
                "capability_class": {
                  "type": "string",
                  "enum": [
                    "synthetic_media_detection",
                    "provenance_metadata_read",
                    "content_credential_verify",
                    "model_output_attribution",
                    "disclosure_retrieval"
                  ]
                },
                "published_claim_digest": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            },
            "committed_at": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$"
            },
            "contacted_at": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$"
            },
            "observed_at": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$"
            },
            "time_reference": {
              "type": "object",
              "required": [
                "reference_id",
                "reference_digest",
                "drift_bound_ms"
              ],
              "additionalProperties": false,
              "properties": {
                "reference_id": {
                  "type": "string",
                  "pattern": "^tr_[0-9a-z_]{1,48}$"
                },
                "reference_digest": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "drift_bound_ms": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 86400000
                }
              }
            },
            "observed_drift_ms": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400000
            },
            "drift_class": {
              "type": "string",
              "enum": [
                "within_declared_bound",
                "exceeds_declared_bound"
              ]
            },
            "challenge_count": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4096
            },
            "challenge_commitments": {
              "type": "array",
              "minItems": 1,
              "maxItems": 4096,
              "items": {
                "type": "object",
                "required": [
                  "input_commitment",
                  "expectation_commitment",
                  "transform_class"
                ],
                "additionalProperties": false,
                "properties": {
                  "input_commitment": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "expectation_commitment": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "transform_class": {
                    "type": "string",
                    "enum": [
                      "none",
                      "acoustic_rerecord",
                      "voice_conversion",
                      "tts_regeneration",
                      "lossy_transcode",
                      "time_stretch",
                      "additive_noise"
                    ]
                  }
                }
              }
            },
            "challenge_set_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "observed_output_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "invocation_class": {
              "type": "string",
              "enum": [
                "public_documented_interface",
                "provider_issued_credential",
                "out_of_band_grant",
                "no_interface_published"
              ]
            },
            "provider_participation": {
              "type": "string",
              "enum": [
                "none_recorded",
                "provider_supplied_sample",
                "provider_selected_challenge",
                "provider_assisted_invocation"
              ]
            },
            "exerciser": {
              "type": "object",
              "required": [
                "exerciser_id",
                "control_set_digest"
              ],
              "additionalProperties": false,
              "properties": {
                "exerciser_id": {
                  "type": "string",
                  "pattern": "^ex_[0-9a-z_]{1,48}$"
                },
                "control_set_digest": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            },
            "provider_control_set_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "independence_class": {
              "type": "string",
              "enum": [
                "unaffiliated",
                "shared_control",
                "undetermined"
              ]
            },
            "per_challenge_outcomes": {
              "type": "array",
              "minItems": 1,
              "maxItems": 4096,
              "items": {
                "type": "object",
                "required": [
                  "input_commitment",
                  "outcome_class"
                ],
                "additionalProperties": false,
                "properties": {
                  "input_commitment": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "outcome_class": {
                    "type": "string",
                    "enum": [
                      "matched_expectation",
                      "diverged_from_expectation",
                      "no_output_returned"
                    ]
                  }
                }
              }
            },
            "matched_count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 4096
            },
            "detection_rate_bp": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000
            },
            "conformance_verdict": {
              "type": "string",
              "enum": [
                "capability_exercised_conformant",
                "capability_exercised_nonconformant",
                "capability_unexercisable"
              ]
            },
            "exerciser_role": {
              "type": "string",
              "pattern": "^unaffiliated_exerciser$"
            },
            "evidence_access_class": {
              "type": "string",
              "enum": [
                "confidential_independent",
                "issuer_only",
                "public_commitment_only"
              ]
            },
            "salt_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "boundary": {
          "type": "string",
          "minLength": 1,
          "const": "This receipt attests only that a named exerciser, independent of the named provider by a recomputed control set comparison, committed a challenge set and a declared expectation for each challenge before the named capability was first contacted, then invoked that capability at the named URL through the stated invocation class at an instant placed against a declared external time reference with a declared drift bound, and that the per challenge outcomes, the detection rate, and the conformance verdict recorded here were recomputed by this service from the committed challenge set and the observed outputs rather than supplied by the caller. It does not attest that the capability is accurate, effective, or fit for any purpose. It does not attest that any marking scheme is robust. It does not attest that the provider complies with any law, regulation, or standard. It does not attest that the capability was available at any instant other than the one recorded. It does not attest that a different exerciser, network path, or challenge set would produce the same outputs. It does not attest that the provider's published claim is true or false beyond the declared expectation tested here. It does not attest that no equivalent capability exists anywhere else. It does not decide whether any content was generated by any system."
        }
      }
    }
  }
}
