{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "const": "autonym-export/1.0"
    },
    "exported_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
    },
    "origin_host": {
      "type": "string",
      "format": "uri"
    },
    "history_mode": {
      "type": "string",
      "enum": [
        "current",
        "all_retained"
      ]
    },
    "partitions": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096
          }
        },
        "required": [
          "id",
          "label"
        ],
        "additionalProperties": false
      }
    },
    "entries": {
      "maxItems": 100000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^ent_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "version": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "profile_id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "domain": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
          },
          "key": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
          },
          "value_type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "boolean",
              "enum",
              "list",
              "coded",
              "coded_list",
              "date",
              "date_range",
              "age_band",
              "person_ref",
              "structured",
              "credential"
            ]
          },
          "value": {
            "$ref": "#/$defs/__schema0"
          },
          "context_kind": {
            "type": "string",
            "enum": [
              "fact",
              "preference",
              "state"
            ]
          },
          "provenance": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "declared",
                  "observed",
                  "derived",
                  "attested"
                ]
              },
              "source_client_id": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "source_event_id": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "recorded_at": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "occurred_at": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "confidence": {
                "anyOf": [
                  {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "confirmed_at": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "evidence_refs": {
                "maxItems": 32,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                }
              },
              "derived_from": {
                "maxItems": 32,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "entry_id": {
                      "type": "string",
                      "pattern": "^ent_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
                    },
                    "version": {
                      "type": "integer",
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991
                    },
                    "level": {
                      "type": "string",
                      "enum": [
                        "L0",
                        "L1",
                        "L2",
                        "L3"
                      ]
                    },
                    "fields": {
                      "minItems": 1,
                      "maxItems": 64,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "maxLength": 256
                      }
                    }
                  },
                  "required": [
                    "entry_id",
                    "version",
                    "level",
                    "fields"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "kind",
              "source_client_id",
              "source_event_id",
              "recorded_at",
              "occurred_at",
              "confidence",
              "confirmed_at",
              "evidence_refs",
              "derived_from"
            ],
            "additionalProperties": false
          },
          "temporal": {
            "type": "object",
            "properties": {
              "valid_from": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "valid_until": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "valid_from",
              "valid_until"
            ],
            "additionalProperties": false
          },
          "overlay": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "target_entry_id": {
                    "type": "string",
                    "pattern": "^ent_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "selected": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "target_entry_id",
                  "enabled",
                  "selected"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "rendering_overrides": {
            "type": "object",
            "properties": {
              "L1": {
                "type": "string",
                "minLength": 1,
                "maxLength": 4096
              }
            },
            "additionalProperties": false
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "superseded",
              "archived"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "origin_host": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "id",
          "version",
          "profile_id",
          "domain",
          "key",
          "value_type",
          "value",
          "context_kind",
          "provenance",
          "temporal",
          "overlay",
          "rendering_overrides",
          "status",
          "created_at",
          "updated_at",
          "origin_host"
        ],
        "additionalProperties": false
      }
    },
    "tombstones": {
      "maxItems": 100000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^ent_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "version": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "profile_id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "domain": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
          },
          "key": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
          },
          "deleted_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          }
        },
        "required": [
          "id",
          "version",
          "profile_id",
          "domain",
          "key",
          "deleted_at"
        ],
        "additionalProperties": false
      }
    },
    "grants_history": {
      "maxItems": 100000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "profile_id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "grant": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^gr_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
                  },
                  "revision": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "handle": {
                    "type": "string",
                    "maxLength": 294,
                    "pattern": "^autonym:[a-z2-7]{32}@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$"
                  },
                  "client_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "purpose": {
                    "type": "object",
                    "properties": {
                      "category": {
                        "type": "string",
                        "enum": [
                          "booking",
                          "recommendation",
                          "safety",
                          "fulfilment",
                          "personalisation",
                          "research",
                          "care",
                          "medical",
                          "employment",
                          "advertising"
                        ]
                      },
                      "text": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 4096
                      }
                    },
                    "required": [
                      "category",
                      "text"
                    ],
                    "additionalProperties": false
                  },
                  "issued_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "revoked",
                      "expired"
                    ]
                  },
                  "kind": {
                    "type": "string",
                    "const": "read"
                  },
                  "read": {
                    "minItems": 1,
                    "maxItems": 32,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "domain": {
                          "anyOf": [
                            {
                              "type": "string",
                              "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                            },
                            {
                              "type": "string",
                              "const": "*"
                            }
                          ]
                        },
                        "keys": {
                          "anyOf": [
                            {
                              "minItems": 1,
                              "maxItems": 128,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "max_level": {
                          "type": "string",
                          "enum": [
                            "L0",
                            "L1",
                            "L2",
                            "L3"
                          ]
                        }
                      },
                      "required": [
                        "domain",
                        "keys",
                        "max_level"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "declared_only": {
                    "type": "boolean"
                  },
                  "min_confidence": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "max_reads": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 100000
                  },
                  "reads_used": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "persist_until": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "allow_delegation": {
                    "type": "boolean"
                  },
                  "onward_share": {
                    "type": "boolean",
                    "const": false
                  }
                },
                "required": [
                  "id",
                  "revision",
                  "handle",
                  "client_id",
                  "purpose",
                  "issued_at",
                  "expires_at",
                  "status",
                  "kind",
                  "read",
                  "declared_only",
                  "min_confidence",
                  "max_reads",
                  "reads_used",
                  "persist_until",
                  "allow_delegation",
                  "onward_share"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^gr_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
                  },
                  "revision": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "handle": {
                    "type": "string",
                    "maxLength": 294,
                    "pattern": "^autonym:[a-z2-7]{32}@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$"
                  },
                  "client_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "purpose": {
                    "type": "object",
                    "properties": {
                      "category": {
                        "type": "string",
                        "enum": [
                          "booking",
                          "recommendation",
                          "safety",
                          "fulfilment",
                          "personalisation",
                          "research",
                          "care",
                          "medical",
                          "employment",
                          "advertising"
                        ]
                      },
                      "text": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 4096
                      }
                    },
                    "required": [
                      "category",
                      "text"
                    ],
                    "additionalProperties": false
                  },
                  "issued_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "revoked",
                      "expired"
                    ]
                  },
                  "kind": {
                    "type": "string",
                    "const": "contribute"
                  },
                  "contribute": {
                    "minItems": 1,
                    "maxItems": 32,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "domain": {
                          "type": "string",
                          "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                        },
                        "keys": {
                          "minItems": 1,
                          "maxItems": 128,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                          }
                        }
                      },
                      "required": [
                        "domain",
                        "keys"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "max_events": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 100000
                  },
                  "events_used": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "allow_confirmation": {
                    "type": "boolean"
                  },
                  "stream_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$"
                  }
                },
                "required": [
                  "id",
                  "revision",
                  "handle",
                  "client_id",
                  "purpose",
                  "issued_at",
                  "expires_at",
                  "status",
                  "kind",
                  "contribute",
                  "max_events",
                  "events_used",
                  "allow_confirmation",
                  "stream_id"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "required": [
          "profile_id",
          "grant"
        ],
        "additionalProperties": false
      }
    },
    "receipts": {
      "maxItems": 100000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "profile_id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "receipt": {
            "type": "object",
            "properties": {
              "event_id": {
                "type": "string",
                "pattern": "^evt_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
              },
              "provider": {
                "type": "string",
                "format": "uri"
              },
              "read_id": {
                "type": "string",
                "pattern": "^rd_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
              },
              "grant_id": {
                "type": "string",
                "pattern": "^gr_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
              },
              "client_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048
              },
              "at": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "purpose": {
                "type": "string",
                "enum": [
                  "booking",
                  "recommendation",
                  "safety",
                  "fulfilment",
                  "personalisation",
                  "research",
                  "care",
                  "medical",
                  "employment",
                  "advertising"
                ]
              },
              "surface": {
                "type": "string",
                "enum": [
                  "rest",
                  "mcp_tool",
                  "mcp_resource",
                  "mcp_briefing"
                ]
              },
              "request": {
                "type": "object",
                "properties": {
                  "domains": {
                    "minItems": 1,
                    "maxItems": 32,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                    }
                  },
                  "max_level": {
                    "type": "string",
                    "enum": [
                      "L0",
                      "L1",
                      "L2",
                      "L3"
                    ]
                  },
                  "keys": {
                    "minItems": 1,
                    "maxItems": 128,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                    }
                  },
                  "declared_only": {
                    "type": "boolean"
                  },
                  "min_confidence": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "since": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  }
                },
                "required": [
                  "domains",
                  "max_level",
                  "declared_only",
                  "min_confidence"
                ],
                "additionalProperties": false
              },
              "returned": {
                "maxItems": 1000,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "entry_id": {
                      "type": "string",
                      "pattern": "^ent_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
                    },
                    "version": {
                      "type": "integer",
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991
                    },
                    "level": {
                      "type": "string",
                      "enum": [
                        "L0",
                        "L1",
                        "L2",
                        "L3"
                      ]
                    }
                  },
                  "required": [
                    "entry_id",
                    "version",
                    "level"
                  ],
                  "additionalProperties": false
                }
              },
              "response_hash": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$"
              },
              "prev_hash": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^sha256:[a-f0-9]{64}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "hash": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$"
              },
              "proof": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "jws"
                  },
                  "alg": {
                    "type": "string",
                    "const": "ES256"
                  },
                  "kid": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$"
                  },
                  "jws": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]+\\.\\.[A-Za-z0-9_-]+$"
                  }
                },
                "required": [
                  "type",
                  "alg",
                  "kid",
                  "jws"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "event_id",
              "provider",
              "read_id",
              "grant_id",
              "client_id",
              "at",
              "purpose",
              "surface",
              "request",
              "returned",
              "response_hash",
              "prev_hash",
              "hash",
              "proof"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "profile_id",
          "receipt"
        ],
        "additionalProperties": false
      }
    },
    "log_events": {
      "maxItems": 100000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "profile_id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "event": {
            "type": "object",
            "properties": {
              "event_id": {
                "type": "string",
                "pattern": "^evt_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
              },
              "at": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "grant_created",
                  "grant_revoked",
                  "grant_expired",
                  "rule_applied",
                  "delegation_redeemed",
                  "proposal_decided",
                  "overlay_enabled",
                  "overlay_disabled",
                  "overlay_selected",
                  "read_not_modified",
                  "purge_issued",
                  "purge_acknowledged",
                  "operator_action",
                  "migration_imported"
                ]
              },
              "actor_client_id": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "subject_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "details": {
                "type": "object",
                "properties": {
                  "decision": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "approved",
                          "rejected",
                          "enabled",
                          "disabled",
                          "selected",
                          "unchanged",
                          "completed",
                          "failed"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "ids": {
                    "maxItems": 32,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "response_hash": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^sha256:[a-f0-9]{64}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "decision",
                  "ids",
                  "response_hash"
                ],
                "additionalProperties": false
              },
              "prev_hash": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^sha256:[a-f0-9]{64}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "hash": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$"
              }
            },
            "required": [
              "event_id",
              "at",
              "kind",
              "actor_client_id",
              "subject_id",
              "details",
              "prev_hash",
              "hash"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "profile_id",
          "event"
        ],
        "additionalProperties": false
      }
    },
    "public_keys": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kty": {
            "type": "string",
            "const": "EC"
          },
          "crv": {
            "type": "string",
            "const": "P-256"
          },
          "x": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$"
          },
          "y": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$"
          },
          "kid": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$"
          },
          "alg": {
            "type": "string",
            "const": "ES256"
          },
          "use": {
            "type": "string",
            "const": "sig"
          },
          "exp": {
            "type": "integer",
            "minimum": 1,
            "maximum": 253402300799
          }
        },
        "required": [
          "kty",
          "crv",
          "x",
          "y",
          "kid",
          "alg",
          "use"
        ],
        "additionalProperties": false
      }
    },
    "policy_history": {
      "maxItems": 10000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "profile_id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "kind": {
            "type": "string",
            "enum": [
              "rule",
              "delegation"
            ]
          },
          "executable": {
            "type": "boolean",
            "const": false
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096
          },
          "related_grant_ids": {
            "maxItems": 1000,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^gr_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
            }
          }
        },
        "required": [
          "profile_id",
          "id",
          "kind",
          "executable",
          "description",
          "related_grant_ids"
        ],
        "additionalProperties": false
      }
    },
    "proposals": {
      "maxItems": 100000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "profile_id": {
            "type": "string",
            "pattern": "^prf_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
          },
          "source_client_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "event": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "event_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,128}$"
                  },
                  "occurred_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "stream_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$"
                  },
                  "domain": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                  },
                  "key": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                  },
                  "value_type": {
                    "type": "string",
                    "enum": [
                      "text",
                      "number",
                      "boolean",
                      "enum",
                      "list",
                      "coded",
                      "coded_list",
                      "date",
                      "date_range",
                      "age_band",
                      "person_ref",
                      "structured",
                      "credential"
                    ]
                  },
                  "value": {
                    "$ref": "#/$defs/__schema0"
                  },
                  "context_kind": {
                    "type": "string",
                    "enum": [
                      "fact",
                      "preference",
                      "state"
                    ]
                  },
                  "temporal": {
                    "type": "object",
                    "properties": {
                      "valid_from": {
                        "anyOf": [
                          {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "valid_until": {
                        "anyOf": [
                          {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "valid_from",
                      "valid_until"
                    ],
                    "additionalProperties": false
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "user_supplied",
                      "activity",
                      "observation",
                      "inference"
                    ]
                  },
                  "evidence_refs": {
                    "maxItems": 32,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "operation": {
                    "type": "string",
                    "const": "create"
                  }
                },
                "required": [
                  "event_id",
                  "occurred_at",
                  "stream_id",
                  "domain",
                  "key",
                  "value_type",
                  "value",
                  "context_kind",
                  "temporal",
                  "category",
                  "evidence_refs",
                  "operation"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "event_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,128}$"
                  },
                  "occurred_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "stream_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$"
                  },
                  "domain": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                  },
                  "key": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
                  },
                  "value_type": {
                    "type": "string",
                    "enum": [
                      "text",
                      "number",
                      "boolean",
                      "enum",
                      "list",
                      "coded",
                      "coded_list",
                      "date",
                      "date_range",
                      "age_band",
                      "person_ref",
                      "structured",
                      "credential"
                    ]
                  },
                  "value": {
                    "$ref": "#/$defs/__schema0"
                  },
                  "context_kind": {
                    "type": "string",
                    "enum": [
                      "fact",
                      "preference",
                      "state"
                    ]
                  },
                  "temporal": {
                    "type": "object",
                    "properties": {
                      "valid_from": {
                        "anyOf": [
                          {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "valid_until": {
                        "anyOf": [
                          {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "valid_from",
                      "valid_until"
                    ],
                    "additionalProperties": false
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "user_supplied",
                      "activity",
                      "observation",
                      "inference"
                    ]
                  },
                  "evidence_refs": {
                    "maxItems": 32,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "operation": {
                    "type": "string",
                    "const": "correct"
                  },
                  "predecessor_event_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,128}$"
                  }
                },
                "required": [
                  "event_id",
                  "occurred_at",
                  "stream_id",
                  "domain",
                  "key",
                  "value_type",
                  "value",
                  "context_kind",
                  "temporal",
                  "category",
                  "evidence_refs",
                  "operation",
                  "predecessor_event_id"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "event_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,128}$"
                  },
                  "occurred_at": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  "stream_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$"
                  },
                  "operation": {
                    "type": "string",
                    "const": "withdraw"
                  },
                  "predecessor_event_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,128}$"
                  }
                },
                "required": [
                  "event_id",
                  "occurred_at",
                  "stream_id",
                  "operation",
                  "predecessor_event_id"
                ],
                "additionalProperties": false
              }
            ]
          },
          "acknowledgement": {
            "type": "object",
            "properties": {
              "proposal_id": {
                "type": "string",
                "pattern": "^prp_[0-7][0-9A-HJKMNP-TV-Z]{25}(?![\\s\\S])"
              },
              "event_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "ingested_at": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "accepted",
                  "rejected",
                  "withdrawn"
                ]
              }
            },
            "required": [
              "proposal_id",
              "event_id",
              "ingested_at",
              "status"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "profile_id",
          "source_client_id",
          "event",
          "acknowledgement"
        ],
        "additionalProperties": false
      }
    },
    "unsupported": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "category": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096
          }
        },
        "required": [
          "category",
          "reason"
        ],
        "additionalProperties": false
      }
    },
    "proof": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "jws"
        },
        "alg": {
          "type": "string",
          "const": "ES256"
        },
        "kid": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$"
        },
        "jws": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+\\.\\.[A-Za-z0-9_-]+$"
        }
      },
      "required": [
        "type",
        "alg",
        "kid",
        "jws"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "format",
    "exported_at",
    "origin_host",
    "history_mode",
    "partitions",
    "entries",
    "tombstones",
    "grants_history",
    "receipts",
    "log_events",
    "public_keys",
    "policy_history",
    "proposals",
    "unsupported",
    "proof"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  }
}
