{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/price-challenge-record-v1.json",
  "title": "Price Challenge Record Receipt, v1",
  "description": "Canonical schema for the Hive price challenge record, canonical type price.challenge. The instrument records one challenge against one published value as a fingerprint, the evidence fingerprints, whether a person reviewed it or an automatic reply went out, the deadline rule committed before the challenge opened, the computed deadline and on_time or late relation, the outcome, and a link to any correction.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_price[.]challenge_[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",
        "challenge_id",
        "challenged_value_fingerprint",
        "instrument_fingerprint",
        "salt_commitment",
        "challenger_commitment",
        "evidence",
        "handling",
        "deadline_rule",
        "opened_at",
        "responded_at",
        "deadline_at",
        "timeliness",
        "outcome",
        "correction",
        "recorded_at",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "price.challenge"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "challenge_id": {
          "type": "string",
          "pattern": "^chl_[0-9a-z][0-9a-z._-]{0,47}$"
        },
        "challenged_value_fingerprint": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 over the published value as challenged. The value itself is never carried here."
        },
        "instrument_fingerprint": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 over the instrument identifier the value was published for."
        },
        "salt_commitment": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "challenger_commitment": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Salted commitment over the descriptor of the party that raised the challenge."
        },
        "evidence": {
          "type": "object",
          "required": [
            "fingerprints",
            "count",
            "set_digest"
          ],
          "additionalProperties": false,
          "properties": {
            "fingerprints": {
              "type": "array",
              "minItems": 0,
              "maxItems": 10000,
              "items": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "description": "SHA-256 fingerprints of each evidence item, strictly ascending."
            },
            "count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000
            },
            "set_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "Digest over the ascending fingerprint list, recomputed by the verifier."
            }
          }
        },
        "handling": {
          "type": "object",
          "required": [
            "mode",
            "reviewer_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "mode": {
              "type": "string",
              "enum": [
                "person_review",
                "automatic_reply"
              ]
            },
            "reviewer_commitment": {
              "type": [
                "string",
                "null"
              ],
              "pattern": "^[0-9a-f]{64}$",
              "description": "Salted commitment over the reviewer descriptor when a person reviewed the challenge, null for an automatic reply."
            }
          }
        },
        "deadline_rule": {
          "type": "object",
          "required": [
            "rule_id",
            "rule_digest",
            "response_window_seconds",
            "committed_at"
          ],
          "additionalProperties": false,
          "properties": {
            "rule_id": {
              "type": "string",
              "pattern": "^rule_[0-9a-z][0-9a-z._-]{0,47}$"
            },
            "rule_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "SHA-256 over the published deadline rule text."
            },
            "response_window_seconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31536000
            },
            "committed_at": {
              "type": "object",
              "required": [
                "utc",
                "drift_seconds"
              ],
              "additionalProperties": false,
              "properties": {
                "utc": {
                  "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_seconds": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 86400
                }
              }
            }
          }
        },
        "opened_at": {
          "type": "object",
          "required": [
            "utc",
            "drift_seconds"
          ],
          "additionalProperties": false,
          "properties": {
            "utc": {
              "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_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400
            }
          }
        },
        "responded_at": {
          "type": "object",
          "required": [
            "utc",
            "drift_seconds"
          ],
          "additionalProperties": false,
          "properties": {
            "utc": {
              "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_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400
            }
          }
        },
        "deadline_at": {
          "type": "object",
          "required": [
            "utc",
            "drift_seconds"
          ],
          "additionalProperties": false,
          "properties": {
            "utc": {
              "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_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400
            }
          }
        },
        "timeliness": {
          "type": "string",
          "enum": [
            "on_time",
            "late",
            "timeliness_indeterminate"
          ]
        },
        "outcome": {
          "type": "string",
          "enum": [
            "value_affirmed",
            "value_corrected",
            "challenge_withdrawn"
          ]
        },
        "correction": {
          "type": [
            "object",
            "null"
          ],
          "required": [
            "correction_receipt_digest",
            "corrected_value_fingerprint"
          ],
          "additionalProperties": false,
          "properties": {
            "correction_receipt_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "SHA-256 over the canonical envelope of the correction receipt that superseded the value."
            },
            "corrected_value_fingerprint": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "recorded_at": {
          "type": "object",
          "required": [
            "utc",
            "drift_seconds"
          ],
          "additionalProperties": false,
          "properties": {
            "utc": {
              "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_seconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400
            }
          }
        },
        "boundary": {
          "type": "string",
          "minLength": 1,
          "const": "This receipt attests only that a party recorded a challenge against one published value, presented as a fingerprint, with the evidence fingerprints listed, the recorded handling mode, the recorded open and reply instants, and the recorded outcome, and that the deadline instant and the on_time or late relation were computed from a deadline rule whose commitment instant was settled before the open instant under the declared drift bounds. Hive records and checks; it does not decide, block, enforce or sit in the access path. It does not establish that the challenged value or any corrected value was correct, that the evidence was adequate or genuine, that the review was careful, or that the outcome was right. A receipt shows what was recorded and when, not that it was correct. The instants, handling mode and outcome are presented as reported by the recording party."
        }
      }
    }
  }
}