{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/causal-path-v1.json",
  "title": "Causal Path Binding 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_causal\\.path_[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",
        "path_id",
        "tenant_id",
        "origin_ref",
        "terminus_ref",
        "steps",
        "claimed_effect",
        "continuity",
        "evaluated_at",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "causal.path"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "path_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "tenant_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "origin_ref": {
          "type": "object",
          "required": [
            "receipt_id",
            "payload_sha256",
            "receipt_type"
          ],
          "additionalProperties": false,
          "properties": {
            "receipt_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "payload_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "receipt_type": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        },
        "terminus_ref": {
          "type": "object",
          "required": [
            "receipt_id",
            "payload_sha256",
            "receipt_type"
          ],
          "additionalProperties": false,
          "properties": {
            "receipt_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "payload_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "receipt_type": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        },
        "steps": {
          "type": "array",
          "minItems": 0,
          "maxItems": 64,
          "items": {
            "type": "object",
            "required": [
              "index",
              "receipt_id",
              "payload_sha256",
              "receipt_type",
              "input_digest_sha256",
              "output_digest_sha256",
              "occurred_at"
            ],
            "additionalProperties": false,
            "properties": {
              "index": {
                "type": "integer",
                "minimum": 0
              },
              "receipt_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "payload_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "receipt_type": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "input_digest_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "output_digest_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "occurred_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$"
              }
            }
          }
        },
        "claimed_effect": {
          "type": "object",
          "required": [
            "descriptor_sha256",
            "category",
            "occurred_at"
          ],
          "additionalProperties": false,
          "properties": {
            "descriptor_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "category": {
              "type": "string",
              "enum": [
                "financial_loss",
                "denial_of_service_to_person",
                "incorrect_disbursement",
                "regulatory_finding",
                "physical_harm",
                "other"
              ]
            },
            "occurred_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$"
            }
          }
        },
        "continuity": {
          "type": "string",
          "enum": [
            "unbroken",
            "broken",
            "empty"
          ]
        },
        "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 sequence of receipts forms a digest continuous chain from one origin receipt to one terminus receipt with no unreceipted gap between them, that each step's declared input digest equals the prior step's declared output digest, that the recorded times do not run backwards, and that the continuity finding was recomputed by this service rather than supplied by the caller. Digest continuity is not causation. This receipt does not attest that the origin caused the terminus, that the terminus caused the claimed effect, that the claimed effect occurred at all, or that any harm was suffered by anyone, and this service never receives the description of the claimed effect. It does not attest that the chain presented is the only chain, that no parallel or intervening cause existed outside it, or that the steps chosen are the ones a court, regulator, or investigator would consider relevant. It establishes no legal liability and is not an expert opinion on causation."
        }
      }
    }
  }
}
