{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/binding-uncertainty-v1.json",
  "title": "Table Binding Uncertainty v1",
  "description": "Table Binding Uncertainty receipt. A number lifted out of a table can be read perfectly and still be wrong, because the header it was attached to was guessed, so this receipt carries cell commitments, the header edges that give those cells meaning with a confidence on each edge, and the reading order, and it reports an uncertain binding separately from and at the same time as the value. The service confirms every edge points at a cell that is present, confirms the reading order is a permutation of the committed cells, and counts the edges whose confidence falls below the committed threshold. It does not read the table and does not attest that any cell value or any header attachment is correct; table_read_by_service is fixed to false.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_binding\\.uncertainty_[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",
        "table_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "render_profile_digest_sha256",
        "cells",
        "binding_edges",
        "reading_order",
        "uncertainty_threshold"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "binding.uncertainty"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "table_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9._:-]{1,256}$"
        },
        "evidence_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the caller-held evidence bundle this receipt attests was recorded. The service never receives or inspects the underlying evidence, only its digest."
        },
        "recorded_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$"
        },
        "verdict": {
          "type": "object",
          "description": "Service-computed honesty boundary fields. Never caller overridable; recomputed and checked at verify time.",
          "required": [
            "table_read_by_service",
            "value_verdict_independent_of_binding_verdict",
            "cell_count",
            "edge_count",
            "every_edge_resolves_to_a_committed_cell",
            "reading_order_is_a_permutation_of_cells",
            "uncertain_binding_edge_count",
            "binding_uncertain"
          ],
          "additionalProperties": false,
          "properties": {
            "table_read_by_service": {
              "type": "boolean",
              "const": false
            },
            "value_verdict_independent_of_binding_verdict": {
              "type": "boolean",
              "const": true
            },
            "cell_count": {
              "type": "integer",
              "minimum": 0
            },
            "edge_count": {
              "type": "integer",
              "minimum": 0
            },
            "every_edge_resolves_to_a_committed_cell": {
              "type": "boolean"
            },
            "reading_order_is_a_permutation_of_cells": {
              "type": "boolean"
            },
            "uncertain_binding_edge_count": {
              "type": "integer",
              "minimum": 0
            },
            "binding_uncertain": {
              "type": "boolean"
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Table Binding Uncertainty receipt. A number lifted out of a table can be read perfectly and still be wrong, because the header it was attached to was guessed, so this receipt carries cell commitments, the header edges that give those cells meaning with a confidence on each edge, and the reading order, and it reports an uncertain binding separately from and at the same time as the value. The service confirms every edge points at a cell that is present, confirms the reading order is a permutation of the committed cells, and counts the edges whose confidence falls below the committed threshold. It does not read the table and does not attest that any cell value or any header attachment is correct; table_read_by_service is fixed to false."
        },
        "render_profile_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Profile the cell scopes are expressed against."
        },
        "cells": {
          "type": "array",
          "minItems": 1,
          "maxItems": 512,
          "items": {
            "type": "object",
            "required": [
              "cell_id",
              "scope_ref",
              "value_commitment_sha256",
              "merge_span"
            ],
            "additionalProperties": false,
            "properties": {
              "cell_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[A-Za-z0-9._:-]{1,64}$"
              },
              "scope_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Scope of the page this cell occupies, in profile pixel space."
              },
              "value_commitment_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$",
                "description": "Salted commitment to the cell value."
              },
              "merge_span": {
                "type": "integer",
                "minimum": 1,
                "maximum": 64,
                "description": "How many grid positions this cell spans, so a merged cell is not silently one cell."
              }
            }
          }
        },
        "binding_edges": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1024,
          "items": {
            "type": "object",
            "required": [
              "edge_id",
              "cell_id",
              "header_cell_id",
              "edge_kind",
              "confidence",
              "confidence_scale_ref",
              "method_ref",
              "method_version"
            ],
            "additionalProperties": false,
            "properties": {
              "edge_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[A-Za-z0-9._:-]{1,64}$"
              },
              "cell_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[A-Za-z0-9._:-]{1,64}$"
              },
              "header_cell_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[A-Za-z0-9._:-]{1,64}$"
              },
              "edge_kind": {
                "type": "string",
                "enum": [
                  "row_header",
                  "column_header",
                  "section_header",
                  "unit_header"
                ]
              },
              "confidence": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Confidence that this cell really is bound to that header."
              },
              "confidence_scale_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Named and versioned scale for that confidence."
              },
              "method_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Method that produced the edge."
              },
              "method_version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Version of that method."
              }
            }
          }
        },
        "reading_order": {
          "type": "array",
          "minItems": 1,
          "maxItems": 512,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9._:-]{1,64}$"
          },
          "description": "Order the cells were read in. Must be a permutation of the committed cell identifiers."
        },
        "reading_order_confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Optional. Confidence in the reading order itself."
        },
        "uncertainty_threshold": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Edge confidence at or below which a binding is reported uncertain."
        }
      }
    }
  }
}
