{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/screening-attestation-v1.json",
  "title": "Screening Attestation Receipt, v1",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_screening\\.attestation_[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",
        "screening_id",
        "tenant_id",
        "attestation_kind",
        "subject_commitment",
        "counterparty_class",
        "list_ref",
        "screened_at",
        "anchor",
        "engine",
        "verdict",
        "jurisdiction_scope",
        "ttl_seconds",
        "countersign",
        "supersession_watch",
        "sequence",
        "evaluated_at",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "screening.attestation"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "screening_id": {
          "type": "string",
          "minLength": 3,
          "maxLength": 64,
          "pattern": "^s_[0-9a-z][0-9a-z_-]{0,62}$"
        },
        "tenant_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "attestation_kind": {
          "type": "string",
          "enum": [
            "initial",
            "rescreen",
            "supersession"
          ]
        },
        "subject_commitment": {
          "type": "object",
          "required": [
            "scheme",
            "value",
            "salt_id",
            "salt_epoch",
            "key_id",
            "domain_separator",
            "identifier_class"
          ],
          "additionalProperties": false,
          "properties": {
            "scheme": {
              "type": "string",
              "enum": [
                "hmac-sha256",
                "hmac-sha512-256"
              ]
            },
            "value": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "salt_id": {
              "type": "string",
              "pattern": "^salt_[0-9a-z]{8,32}$"
            },
            "salt_epoch": {
              "type": "integer",
              "minimum": 0
            },
            "key_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "domain_separator": {
              "type": "string",
              "const": "screening.attestation/subject/v1"
            },
            "identifier_class": {
              "type": "string",
              "enum": [
                "wallet_address",
                "legal_entity_identifier",
                "passport_number",
                "tax_identifier",
                "internal_account_id",
                "other"
              ]
            }
          }
        },
        "counterparty_class": {
          "type": "string",
          "enum": [
            "wallet",
            "natural_person",
            "legal_entity",
            "vessel",
            "aircraft",
            "undisclosed"
          ]
        },
        "list_ref": {
          "type": "object",
          "required": [
            "list_id",
            "list_version",
            "list_digest",
            "digest_method",
            "record_count",
            "supplemental_lists"
          ],
          "additionalProperties": false,
          "properties": {
            "list_id": {
              "type": "string",
              "pattern": "^[A-Z0-9][A-Z0-9_-]{1,63}$"
            },
            "list_version": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)?(\\|[0-9a-z._-]{1,32})?$"
            },
            "list_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "digest_method": {
              "type": "string",
              "enum": [
                "sorted_record_merkle_sha256",
                "sorted_record_concat_sha256"
              ]
            },
            "record_count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000000
            },
            "publisher_ref": {
              "type": "object",
              "required": [
                "receipt_id",
                "payload_sha256"
              ],
              "additionalProperties": false,
              "properties": {
                "receipt_id": {
                  "type": "string",
                  "pattern": "^r_[0-9a-z.]{1,48}_[0-9]{10,}_[0-9a-f]{12}$"
                },
                "payload_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            },
            "supplemental_lists": {
              "type": "array",
              "minItems": 0,
              "maxItems": 16,
              "items": {
                "type": "object",
                "required": [
                  "list_id",
                  "list_version",
                  "list_digest",
                  "digest_method"
                ],
                "additionalProperties": false,
                "properties": {
                  "list_id": {
                    "type": "string",
                    "pattern": "^[A-Z0-9][A-Z0-9_-]{1,63}$"
                  },
                  "list_version": {
                    "type": "string",
                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)?(\\|[0-9a-z._-]{1,32})?$"
                  },
                  "list_digest": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "digest_method": {
                    "type": "string",
                    "enum": [
                      "sorted_record_merkle_sha256",
                      "sorted_record_concat_sha256"
                    ]
                  }
                }
              }
            }
          }
        },
        "screened_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$"
        },
        "anchor": {
          "type": "object",
          "required": [
            "time_source",
            "anchor_time",
            "drift_bound_ms"
          ],
          "additionalProperties": false,
          "properties": {
            "time_source": {
              "type": "string",
              "enum": [
                "gnss_disciplined",
                "gnss_disciplined_ptp",
                "ntp_stratum_1",
                "external_timestamp_token",
                "unanchored"
              ]
            },
            "anchor_time": {
              "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$"
            },
            "drift_bound_ms": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400000
            }
          }
        },
        "engine": {
          "type": "object",
          "required": [
            "system_id",
            "ruleset_digest",
            "ruleset_version",
            "engine_key_id"
          ],
          "additionalProperties": false,
          "properties": {
            "system_id": {
              "type": "string",
              "pattern": "^[0-9a-z][0-9a-z._-]{1,63}$"
            },
            "ruleset_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "ruleset_version": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "engine_key_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        },
        "verdict": {
          "type": "string",
          "enum": [
            "clear",
            "match",
            "review",
            "indeterminate"
          ]
        },
        "adverse_detail": {
          "type": "object",
          "required": [
            "match_strength_class",
            "matched_list_id",
            "rationale_digest"
          ],
          "additionalProperties": false,
          "properties": {
            "match_strength_class": {
              "type": "string",
              "enum": [
                "exact",
                "strong",
                "weak",
                "manual_referral"
              ]
            },
            "matched_list_id": {
              "type": "string",
              "pattern": "^[A-Z0-9][A-Z0-9_-]{1,63}$"
            },
            "rationale_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "jurisdiction_scope": {
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": {
            "type": "string",
            "pattern": "^([A-Z]{2}|EU|GLOBAL)$"
          }
        },
        "ttl_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 2592000
        },
        "countersign": {
          "type": "object",
          "required": [
            "required_for",
            "required_count",
            "signed_count",
            "signers"
          ],
          "additionalProperties": false,
          "properties": {
            "required_for": {
              "type": "array",
              "minItems": 0,
              "maxItems": 4,
              "items": {
                "type": "string",
                "enum": [
                  "clear",
                  "match",
                  "review",
                  "indeterminate"
                ]
              }
            },
            "required_count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 8
            },
            "signed_count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 8
            },
            "signers": {
              "type": "array",
              "minItems": 0,
              "maxItems": 8,
              "items": {
                "type": "object",
                "required": [
                  "key_id",
                  "role",
                  "sig_b64u",
                  "signed_at"
                ],
                "additionalProperties": false,
                "properties": {
                  "key_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "compliance_officer",
                      "second_engine",
                      "supervisor",
                      "external_reviewer"
                    ]
                  },
                  "sig_b64u": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{43,512}$"
                  },
                  "signed_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$"
                  }
                }
              }
            }
          }
        },
        "supersession_watch": {
          "type": "boolean"
        },
        "supersession": {
          "type": "object",
          "required": [
            "reason",
            "prior_refs",
            "salt_continuity",
            "scan_completeness"
          ],
          "additionalProperties": false,
          "properties": {
            "reason": {
              "type": "string",
              "enum": [
                "list_version_update",
                "supplemental_list_update",
                "ruleset_update",
                "salt_rotation",
                "scheduled_sweep"
              ]
            },
            "prior_refs": {
              "type": "array",
              "minItems": 1,
              "maxItems": 256,
              "items": {
                "type": "object",
                "required": [
                  "receipt_id",
                  "payload_sha256",
                  "prior_subject_commitment",
                  "prior_list_version",
                  "prior_verdict"
                ],
                "additionalProperties": false,
                "properties": {
                  "receipt_id": {
                    "type": "string",
                    "pattern": "^r_screening\\.attestation_[0-9]{10,}_[0-9a-f]{12}$"
                  },
                  "payload_sha256": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "prior_subject_commitment": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "prior_list_version": {
                    "type": "string",
                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)?(\\|[0-9a-z._-]{1,32})?$"
                  },
                  "prior_verdict": {
                    "type": "string",
                    "enum": [
                      "clear",
                      "match",
                      "review",
                      "indeterminate"
                    ]
                  }
                }
              }
            },
            "salt_continuity": {
              "type": "string",
              "enum": [
                "same_salt",
                "rotated"
              ]
            },
            "salt_rotation_ref": {
              "type": "object",
              "required": [
                "receipt_id",
                "payload_sha256"
              ],
              "additionalProperties": false,
              "properties": {
                "receipt_id": {
                  "type": "string",
                  "pattern": "^r_[0-9a-z.]{1,48}_[0-9]{10,}_[0-9a-f]{12}$"
                },
                "payload_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            },
            "scan_completeness": {
              "type": "string",
              "enum": [
                "complete_for_watch_set",
                "partial",
                "unknown"
              ]
            }
          }
        },
        "sequence": {
          "type": "object",
          "required": [
            "prev_hash",
            "ledger_seq"
          ],
          "additionalProperties": false,
          "properties": {
            "prev_hash": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "ledger_seq": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "evaluated_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 a named screening engine, at a named ruleset version bound by a ruleset digest, evaluated a keyed commitment to a counterparty identifier against one named primary reference list at a named version bound by a digest over that version's contents, together with any named supplemental lists at their own named versions and digests, at a screening instant placed against a declared external time reference with a declared drift bound, and recorded the stated verdict under a recomputed signing authority requirement together with a declared validity period measured from that screening instant. It does not attest that the reference list itself is complete, accurate, current as published, or free of omission, and it does not attest that the publisher of that list acted correctly. It does not decide whether the counterparty is in fact a sanctioned, restricted or prohibited party, a false negative produced by an honest screening against a correctly bound list version remains a false negative that this receipt does not detect, does not correct and does not disclose, and no gate here detects an engine that reports a clear verdict where its own matching computation produced a match. It does not assess whether the screening program as a whole is adequate, whether the ruleset thresholds are appropriately calibrated, whether the set of lists screened is the correct set for any obligation, or whether the declared validity period is short enough for any purpose. It does not identify the counterparty, does not disclose any list record, does not disclose any match score, and does not confirm that the commitment key or the window salt has remained under the custody of any particular party. It does not authorize, block, freeze, reverse or settle any transaction, does not admit or reject any counterparty, does not constitute a report or notification to any authority, does not constitute legal, regulatory or compliance advice, and whether any obligation is satisfied by the screening it records is determined solely by the applicable law and by the parties' own arrangements."
        }
      }
    }
  }
}
