{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "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,
  "$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"
          }
        }
      ]
    }
  }
}
