{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "schema": {
      "type": "string",
      "const": "receipt/v1"
    },
    "iss": {
      "type": "string"
    },
    "iat": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "as_of": {
      "type": "string"
    },
    "action": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      },
      "required": [
        "type",
        "digest"
      ],
      "additionalProperties": false
    },
    "facts_digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "jurisdictions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "decision": {
      "type": "string",
      "enum": [
        "clear",
        "flag",
        "hold",
        "block"
      ]
    },
    "rules": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "result": {
            "type": "string",
            "enum": [
              "passed",
              "fired",
              "indeterminate",
              "not_applied",
              "pending_verification",
              "skipped:dominated"
            ]
          },
          "approved_by": {
            "type": "string"
          },
          "citations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "provision_expr_id": {
                  "type": "string"
                },
                "source_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "quote_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "quote_match": {
                  "type": "string",
                  "enum": [
                    "exact"
                  ]
                },
                "version_current": {
                  "type": "boolean"
                }
              },
              "required": [
                "provision_expr_id",
                "source_sha256",
                "quote_sha256",
                "quote_match",
                "version_current"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "version",
          "result",
          "citations"
        ],
        "additionalProperties": false
      }
    },
    "pack": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "ver": {
          "type": "string"
        },
        "manifest_sha256": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "signers": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "id",
        "ver",
        "manifest_sha256",
        "signers"
      ],
      "additionalProperties": false
    },
    "decision_digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "review": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string"
        },
        "level": {
          "type": "string"
        },
        "human": {
          "type": "boolean"
        },
        "firm": {
          "type": "string"
        },
        "by": {
          "type": "string"
        },
        "outcome": {
          "type": "string"
        },
        "panel": {
          "type": "object",
          "properties": {
            "passes": {
              "type": "number"
            },
            "unanimous": {
              "type": "boolean"
            },
            "critic_objection": {
              "type": "boolean"
            },
            "bound_ok": {
              "type": "boolean"
            }
          },
          "required": [
            "passes",
            "unanimous",
            "critic_objection",
            "bound_ok"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "mode"
      ],
      "additionalProperties": false
    },
    "coverage_ack": {},
    "approver_of_record": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "person"
            },
            "org_id": {
              "type": "string"
            },
            "user_id": {
              "type": "string"
            },
            "at": {
              "type": "string"
            },
            "aal": {
              "type": "string",
              "enum": [
                "aal1",
                "aal2"
              ]
            }
          },
          "required": [
            "kind",
            "org_id",
            "user_id",
            "at",
            "aal"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "standing_policy"
            },
            "org_id": {
              "type": "string"
            },
            "policy_id": {
              "type": "string"
            },
            "version": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "body_sha256": {
              "type": "string"
            },
            "accepted_by": {
              "type": "string"
            },
            "accepted_at": {
              "type": "string"
            },
            "applied_at": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "org_id",
            "policy_id",
            "version",
            "body_sha256",
            "accepted_by",
            "accepted_at",
            "applied_at"
          ],
          "additionalProperties": false
        }
      ]
    },
    "recommended_by": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "platform",
            "counsel"
          ]
        },
        "staff_or_member_id": {
          "type": "string"
        },
        "firm": {
          "type": "string"
        },
        "recommendation_id": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "staff_or_member_id",
        "recommendation_id"
      ],
      "additionalProperties": false
    },
    "relied_on": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "const": "qualification"
          },
          "type": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "tier": {
            "anyOf": [
              {
                "type": "number",
                "const": 0
              },
              {
                "type": "number",
                "const": 1
              },
              {
                "type": "number",
                "const": 2
              }
            ]
          },
          "issuer": {
            "type": "string"
          },
          "valid_until": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "type",
          "id",
          "tier",
          "issuer"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "schema",
    "iss",
    "iat",
    "as_of",
    "action",
    "facts_digest",
    "jurisdictions",
    "decision",
    "rules",
    "pack",
    "decision_digest"
  ],
  "additionalProperties": false
}
