{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/numeric-lineage-v1.json",
  "title": "Numeric Lineage Receipt, v1",
  "description": "Canonical schema for the Hive numeric lineage receipt, canonical type numeric.lineage. The record carries a bitwise divergence measurement taken over the emitted token identifier sequences of one identical request set transmitted to one serving endpoint at two or more batch occupancy levels induced by the measuring gateway, against a divergence bound whose digest was fixed before the first measured request was transmitted, together with the serving set change and the settlement withholding that the measurement caused. Every counted quantity is an integer. A fraction is carried as an integer numerator and an explicit decimal scale, so no floating point value enters a comparison at verification. Patent pending.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_numeric[._]lineage_[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",
        "lineage_id",
        "salt",
        "gateway_ref",
        "endpoint_ref",
        "bound_ref",
        "request_set",
        "levels",
        "divergence",
        "effect",
        "measured_at",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "numeric.lineage"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "lineage_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "salt": {
          "type": "object",
          "required": ["commitment_sha256"],
          "additionalProperties": false,
          "properties": {
            "commitment_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "gateway_ref": {
          "type": "object",
          "required": ["commitment"],
          "additionalProperties": false,
          "properties": {
            "commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "endpoint_ref": {
          "type": "object",
          "required": ["commitment", "declared_model_name"],
          "additionalProperties": false,
          "properties": {
            "commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "declared_model_name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        },
        "bound_ref": {
          "type": "object",
          "required": [
            "bound_digest_sha256",
            "committed_at",
            "max_differing_positions",
            "min_first_divergent_index",
            "max_distinct_sequences_per_level",
            "required_repetitions_per_level"
          ],
          "additionalProperties": false,
          "properties": {
            "bound_digest_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "committed_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$"
            },
            "max_differing_positions": {
              "type": "integer",
              "minimum": 0
            },
            "min_first_divergent_index": {
              "type": "integer",
              "minimum": 0
            },
            "max_distinct_sequences_per_level": {
              "type": "integer",
              "minimum": 1
            },
            "required_repetitions_per_level": {
              "type": "integer",
              "minimum": 2
            }
          }
        },
        "request_set": {
          "type": "object",
          "required": [
            "set_digest_sha256",
            "request_count",
            "declared_temperature_numerator",
            "declared_temperature_scale",
            "max_output_tokens"
          ],
          "additionalProperties": false,
          "properties": {
            "set_digest_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "request_count": {
              "type": "integer",
              "minimum": 1
            },
            "declared_temperature_numerator": {
              "type": "integer",
              "const": 0
            },
            "declared_temperature_scale": {
              "type": "integer",
              "minimum": 0
            },
            "max_output_tokens": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "levels": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "object",
            "required": [
              "level_index",
              "induced_concurrency",
              "observed_in_flight_at_accept",
              "observed_in_flight_at_complete",
              "repetitions",
              "distinct_sequence_count",
              "sequence_digest_sha256",
              "emitted_token_count",
              "accumulator_width_id",
              "operand_width_id",
              "reduction_split_count",
              "reduction_order_id",
              "page_layout_fixed_before_kernel",
              "parameter_region_id",
              "batch_invariant_declared"
            ],
            "additionalProperties": false,
            "properties": {
              "level_index": {
                "type": "integer",
                "minimum": 0
              },
              "induced_concurrency": {
                "type": "integer",
                "minimum": 0
              },
              "observed_in_flight_at_accept": {
                "type": "integer",
                "minimum": 0
              },
              "observed_in_flight_at_complete": {
                "type": "integer",
                "minimum": 0
              },
              "repetitions": {
                "type": "integer",
                "minimum": 2
              },
              "distinct_sequence_count": {
                "type": "integer",
                "minimum": 1
              },
              "sequence_digest_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "emitted_token_count": {
                "type": "integer",
                "minimum": 1
              },
              "accumulator_width_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "operand_width_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "reduction_split_count": {
                "type": "integer",
                "minimum": 1
              },
              "reduction_order_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "page_layout_fixed_before_kernel": {
                "type": "boolean"
              },
              "parameter_region_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "batch_invariant_declared": {
                "type": "boolean"
              }
            }
          }
        },
        "divergence": {
          "type": "object",
          "required": [
            "pair_low_level_index",
            "pair_high_level_index",
            "first_divergent_index",
            "differing_position_count",
            "compared_position_count",
            "fraction_numerator",
            "fraction_scale",
            "class"
          ],
          "additionalProperties": false,
          "properties": {
            "pair_low_level_index": {
              "type": "integer",
              "minimum": 0
            },
            "pair_high_level_index": {
              "type": "integer",
              "minimum": 0
            },
            "first_divergent_index": {
              "type": ["integer", "null"],
              "minimum": 0
            },
            "differing_position_count": {
              "type": "integer",
              "minimum": 0
            },
            "compared_position_count": {
              "type": "integer",
              "minimum": 1
            },
            "fraction_numerator": {
              "type": "integer",
              "minimum": 0
            },
            "fraction_scale": {
              "type": "integer",
              "minimum": 0
            },
            "class": {
              "type": "string",
              "enum": ["occupancy_invariant", "occupancy_coupled", "indeterminate"]
            }
          }
        },
        "effect": {
          "type": "object",
          "required": [
            "serving_set_action",
            "reroute_target_commitment",
            "reroute_target_batch_invariant_declared",
            "settlement_action",
            "refused_request_count",
            "effected_at"
          ],
          "additionalProperties": false,
          "properties": {
            "serving_set_action": {
              "type": "string",
              "enum": ["retained", "removed"]
            },
            "reroute_target_commitment": {
              "type": ["string", "null"],
              "pattern": "^[0-9a-f]{64}$"
            },
            "reroute_target_batch_invariant_declared": {
              "type": ["boolean", "null"]
            },
            "settlement_action": {
              "type": "string",
              "enum": ["authorized", "refused"]
            },
            "refused_request_count": {
              "type": "integer",
              "minimum": 0
            },
            "effected_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$"
            }
          }
        },
        "measured_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": "Numeric Lineage record. Attests that an identical request set declaring a temperature of zero was transmitted to one named serving endpoint at two or more batch occupancy levels induced by the measuring gateway, that the bitwise divergence of the emitted token sequence across those levels was measured against a divergence bound whose digest was fixed before the first measured request was transmitted, that the accumulator width identifier, the reduction split count, and the reduction order identifier reported for each level are recorded as signed fields, and that the recorded serving set change and the recorded withholding of settlement authorization were recomputed from the measurement rather than supplied. It does not attest that any emitted token sequence is correct, does not attest the numeric precision of the weights, does not attest a quantization level, does not attest the identity of the model served, and does not attest that any nondeterminism observed arose from batch occupancy rather than from another source the endpoint may have introduced."
        }
      }
    }
  }
}
