{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/analysis-replay-v1.json",
  "title": "Analysis Replay Receipt, v1",
  "description": "Canonical schema for the Hive analysis replay receipt, canonical type analysis.replay. The instrument answers whether a reported statistic is the output of the analysis script that was registered, run on the dataset snapshot that was frozen, before anyone could observe the outcome. A lock manifest signed before data access commits a snapshot root, a script hash, a parameter commitment, an environment measurement, a planned outputs commitment, and an embargoed column set. The attested runtime then signs a column access manifest recording which committed columns the execution actually read and when, so a verifier recomputes, rather than trusts, the claim that no embargoed column was read at or before the lock instant.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_analysis[.]replay_[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",
        "replay_id",
        "lock",
        "unblinding",
        "execution",
        "snapshot_disclosure",
        "column_manifest",
        "reported_outputs",
        "result_disclosure",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "analysis.replay"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "replay_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$"
        },
        "lock": {
          "type": "object",
          "required": [
            "manifest_digest",
            "salt_commitment",
            "snapshot_root",
            "snapshot_leaf_count",
            "script_hash",
            "parameter_commitment",
            "environment_measurement",
            "planned_outputs_commitment",
            "embargoed_column_commitment",
            "embargoed_columns",
            "max_disclosed_leaves",
            "permitted_disclosure_scope",
            "prior_receipt"
          ],
          "additionalProperties": false,
          "properties": {
            "manifest_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "salt_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "snapshot_root": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "snapshot_leaf_count": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000000
            },
            "script_hash": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "parameter_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "environment_measurement": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "planned_outputs_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "embargoed_column_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "embargoed_columns": {
              "type": "array",
              "minItems": 1,
              "maxItems": 64,
              "items": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            },
            "max_disclosed_leaves": {
              "type": "integer",
              "minimum": 1,
              "maximum": 64
            },
            "permitted_disclosure_scope": {
              "type": "string",
              "enum": [
                "committed_only",
                "planned_outputs",
                "planned_outputs_and_diagnostics"
              ]
            },
            "prior_receipt": {
              "type": "object",
              "required": [
                "receipt_id",
                "receipt_type",
                "envelope_sha256",
                "issuance_instant"
              ],
              "additionalProperties": false,
              "properties": {
                "receipt_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "receipt_type": {
                  "type": "string",
                  "const": "analysis.lock"
                },
                "envelope_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "issuance_instant": {
                  "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
                    }
                  }
                }
              }
            }
          }
        },
        "unblinding": {
          "type": "object",
          "required": [
            "instant"
          ],
          "additionalProperties": false,
          "properties": {
            "instant": {
              "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
                }
              }
            }
          }
        },
        "execution": {
          "type": "object",
          "required": [
            "script_hash",
            "parameter_commitment",
            "environment_measurement",
            "input_snapshot_root",
            "lock_envelope_sha256",
            "first_data_access_instant",
            "steps",
            "step_chain_head",
            "output_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "script_hash": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "parameter_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "environment_measurement": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "input_snapshot_root": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "lock_envelope_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "first_data_access_instant": {
              "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
                }
              }
            },
            "steps": {
              "type": "array",
              "minItems": 1,
              "maxItems": 512,
              "items": {
                "type": "object",
                "required": [
                  "index",
                  "step_digest"
                ],
                "additionalProperties": false,
                "properties": {
                  "index": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 511
                  },
                  "step_digest": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  }
                }
              }
            },
            "step_chain_head": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "output_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "snapshot_disclosure": {
          "type": "object",
          "required": [
            "disclosed_leaves"
          ],
          "additionalProperties": false,
          "properties": {
            "disclosed_leaves": {
              "type": "array",
              "minItems": 1,
              "maxItems": 64,
              "items": {
                "type": "object",
                "required": [
                  "index",
                  "leaf_hash",
                  "inclusion_path"
                ],
                "additionalProperties": false,
                "properties": {
                  "index": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 999999999
                  },
                  "leaf_hash": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "inclusion_path": {
                    "type": "array",
                    "minItems": 0,
                    "maxItems": 64,
                    "items": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{64}$"
                    }
                  }
                }
              }
            }
          }
        },
        "column_manifest": {
          "type": "object",
          "required": [
            "manifest_digest",
            "runtime_key_id",
            "runtime_sig_b64u",
            "reads"
          ],
          "additionalProperties": false,
          "properties": {
            "manifest_digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "runtime_key_id": {
              "type": "string",
              "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$"
            },
            "runtime_sig_b64u": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{86}$"
            },
            "reads": {
              "type": "array",
              "minItems": 1,
              "maxItems": 256,
              "items": {
                "type": "object",
                "required": [
                  "column_commitment",
                  "phase",
                  "first_read_instant",
                  "read_count"
                ],
                "additionalProperties": false,
                "properties": {
                  "column_commitment": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "phase": {
                    "type": "string",
                    "enum": [
                      "pre_lock",
                      "post_lock"
                    ]
                  },
                  "first_read_instant": {
                    "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
                      }
                    }
                  },
                  "read_count": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000000000
                  }
                }
              }
            }
          }
        },
        "reported_outputs": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "type": "object",
            "required": [
              "output_name_commitment",
              "value_commitment",
              "disclosed"
            ],
            "additionalProperties": false,
            "properties": {
              "output_name_commitment": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "value_commitment": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "disclosed": {
                "type": "boolean"
              }
            }
          }
        },
        "result_disclosure": {
          "type": "object",
          "required": [
            "exercised_scope",
            "diagnostic_count"
          ],
          "additionalProperties": false,
          "properties": {
            "exercised_scope": {
              "type": "string",
              "enum": [
                "committed_only",
                "planned_outputs",
                "planned_outputs_and_diagnostics"
              ]
            },
            "diagnostic_count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 4096
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "This receipt attests only that a lock manifest signed before data access, an execution record chained to that lock manifest, and a column access manifest signed by the attested runtime satisfy the stated deterministic replay procedure for the named reported outputs. It establishes only that the reported output commitments are the ones produced by the committed script hash, parameter commitment, and environment measurement over the committed dataset snapshot root, and that the runtime recorded no read of any embargoed column at or before the lock instant. It does not establish that the underlying records are authentic, complete, representative, or correctly collected, that the locked analysis plan was well designed, adequately powered, or free of defect, that the planned outputs commitment was specific enough to exclude any result, or that the analysis script computes what its authors intended. It does not establish that the attested runtime, the data custodian, or the analyst is honest, competent, or uncompromised, and it does not establish that no analysis was performed outside the recorded execution. This receipt decides no contractual, statutory, regulatory, evidentiary, scientific, or legal consequence, allocates no risk, fault, responsibility, liability, loss, or remedy, and authorizes no submission, publication, approval, payment, sanction, denial, or remedy."
        }
      }
    }
  }
}
