{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/conduct-record-v1.json",
  "title": "Conduct Record Receipt, v1",
  "description": "Canonical schema for the Hive conduct record receipt, canonical type conduct.record.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": { "type": "string", "pattern": "^r_conduct\\.record_[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",
        "conduct_record",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "conduct.record" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "conduct_record": {
          "type": "object",
          "required": [
            "record_id",
            "compiled_at",
            "window_start",
            "window_end",
            "operator_pseudonym",
            "pseudonym_algorithm",
            "pseudonym_scope",
            "receipt_set_digest",
            "considered_receipt_count",
            "counted_receipt_count",
            "outcome_buckets",
            "reported_outcome_count",
            "suppressed_bucket_count",
            "suppressed_outcome_count",
            "k_anonymity_floor",
            "coverage_class",
            "evidence_access_class",
            "salt_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "record_id": { "type": "string", "pattern": "^cr_[0-9a-f]{16,64}$" },
            "compiled_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
            "window_start": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
            "window_end": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
            "operator_pseudonym": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "pseudonym_algorithm": { "type": "string", "const": "hmac_sha256_v1" },
            "pseudonym_scope": { "type": "string", "const": "per_operator_per_window" },
            "receipt_set_digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "considered_receipt_count": { "type": "integer", "minimum": 0, "maximum": 100000 },
            "counted_receipt_count": { "type": "integer", "minimum": 0, "maximum": 100000 },
            "outcome_buckets": {
              "type": "array",
              "maxItems": 4,
              "items": {
                "type": "object",
                "required": ["outcome_class", "count"],
                "additionalProperties": false,
                "properties": {
                  "outcome_class": { "type": "string", "enum": ["single_party", "shared", "no_violation_found", "indeterminate"] },
                  "count": { "type": "integer", "minimum": 5, "maximum": 100000 }
                }
              }
            },
            "reported_outcome_count": { "type": "integer", "minimum": 0, "maximum": 100000 },
            "suppressed_bucket_count": { "type": "integer", "minimum": 0, "maximum": 4 },
            "suppressed_outcome_count": { "type": "integer", "minimum": 0, "maximum": 100000 },
            "k_anonymity_floor": { "type": "integer", "minimum": 5, "maximum": 1000 },
            "coverage_class": { "type": "string", "const": "supplied_set_only" },
            "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 observer verified the supplied fault attribution receipts, counted the ones that name one keyed operator pseudonym inside a committed window, and reported those counts by outcome class with no bucket below the stated floor. It does not attest that the supplied set is complete, that any omitted outcome does not exist, that the operator is well or badly run, that the record predicts anything, or that any registration, pricing, or admission decision is justified by it. It discloses no operator identity, no counterparty, and no amount."
        }
      }
    }
  }
}
