{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "schema": {
          "const": "varexis-declared-evidence/1"
        },
        "evaluated_on": {
          "type": "string",
          "format": "date"
        },
        "policy_id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
        },
        "artifacts": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "captured_on": {
                "type": "string",
                "format": "date"
              },
              "kind": {
                "enum": [
                  "identity",
                  "authority",
                  "delegation",
                  "configuration",
                  "source_applicability",
                  "event",
                  "export",
                  "retention",
                  "recovery",
                  "redaction"
                ]
              }
            },
            "required": [
              "id",
              "sha256",
              "captured_on",
              "kind"
            ]
          },
          "maxItems": 1000,
          "minItems": 0,
          "uniqueItems": true
        },
        "profile": {
          "const": "admission"
        },
        "declarations": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "connectors": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "tool": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "variant": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "authentication": {
                    "enum": [
                      "oauth",
                      "pat",
                      "browser_session",
                      "unknown"
                    ]
                  },
                  "principal": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "identity_ref": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "authority_ref": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "authority_expires_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "delegated": {
                    "oneOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "delegation_ref": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "delegation_scope_bound": {
                    "oneOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "configuration_ref": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "source_applicability_ref": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "allowed": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "action": {
                          "enum": [
                            "read",
                            "write",
                            "delete",
                            "admin"
                          ]
                        },
                        "resource": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        },
                        "recipient": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        }
                      },
                      "required": [
                        "action",
                        "resource",
                        "recipient"
                      ]
                    },
                    "maxItems": 100,
                    "minItems": 0,
                    "uniqueItems": true
                  },
                  "declared": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "action": {
                          "enum": [
                            "read",
                            "write",
                            "delete",
                            "admin"
                          ]
                        },
                        "resource": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        },
                        "recipient": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        }
                      },
                      "required": [
                        "action",
                        "resource",
                        "recipient"
                      ]
                    },
                    "maxItems": 100,
                    "minItems": 0,
                    "uniqueItems": true
                  },
                  "requested": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "action": {
                          "enum": [
                            "read",
                            "write",
                            "delete",
                            "admin"
                          ]
                        },
                        "resource": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        },
                        "recipient": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        }
                      },
                      "required": [
                        "action",
                        "resource",
                        "recipient"
                      ]
                    },
                    "maxItems": 100,
                    "minItems": 1,
                    "uniqueItems": true
                  }
                },
                "required": [
                  "id",
                  "tool",
                  "variant",
                  "authentication",
                  "principal",
                  "identity_ref",
                  "authority_ref",
                  "authority_expires_on",
                  "delegated",
                  "delegation_ref",
                  "delegation_scope_bound",
                  "configuration_ref",
                  "source_applicability_ref",
                  "allowed",
                  "declared",
                  "requested"
                ]
              },
              "maxItems": 20,
              "minItems": 1,
              "uniqueItems": true
            },
            "previous": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "declared": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "action": {
                          "enum": [
                            "read",
                            "write",
                            "delete",
                            "admin"
                          ]
                        },
                        "resource": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        },
                        "recipient": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                        }
                      },
                      "required": [
                        "action",
                        "resource",
                        "recipient"
                      ]
                    },
                    "maxItems": 100,
                    "minItems": 0,
                    "uniqueItems": true
                  }
                },
                "required": [
                  "id",
                  "declared"
                ]
              },
              "maxItems": 20,
              "minItems": 0,
              "uniqueItems": true
            }
          },
          "required": [
            "connectors",
            "previous"
          ]
        }
      },
      "required": [
        "schema",
        "evaluated_on",
        "policy_id",
        "artifacts",
        "profile",
        "declarations"
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "schema": {
          "const": "varexis-declared-evidence/1"
        },
        "evaluated_on": {
          "type": "string",
          "format": "date"
        },
        "policy_id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
        },
        "artifacts": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "captured_on": {
                "type": "string",
                "format": "date"
              },
              "kind": {
                "enum": [
                  "identity",
                  "authority",
                  "delegation",
                  "configuration",
                  "source_applicability",
                  "event",
                  "export",
                  "retention",
                  "recovery",
                  "redaction"
                ]
              }
            },
            "required": [
              "id",
              "sha256",
              "captured_on",
              "kind"
            ]
          },
          "maxItems": 1000,
          "minItems": 0,
          "uniqueItems": true
        },
        "profile": {
          "const": "audit"
        },
        "declarations": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "source_profile": {
              "enum": [
                "github_audit",
                "slack_export",
                "cloudflare_logpush",
                "unknown"
              ]
            },
            "start": {
              "type": "string",
              "format": "date"
            },
            "end": {
              "type": "string",
              "format": "date"
            },
            "required_retention_days": {
              "type": "integer",
              "minimum": 1,
              "maximum": 3650
            },
            "invocations": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "principal": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "tool": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "resource": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  }
                },
                "required": [
                  "id",
                  "principal",
                  "tool",
                  "resource"
                ]
              },
              "maxItems": 100,
              "minItems": 1,
              "uniqueItems": true
            },
            "events": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "invocation": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "kind": {
                    "enum": [
                      "identity",
                      "authorization",
                      "tool_action",
                      "outcome"
                    ]
                  },
                  "principal": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "tool": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "resource": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                  },
                  "occurred_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "artifact_ref": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "decision": {
                    "enum": [
                      "allow",
                      "deny",
                      "not_applicable"
                    ]
                  },
                  "outcome": {
                    "enum": [
                      "success",
                      "failure",
                      "unknown",
                      "not_applicable"
                    ]
                  },
                  "parent": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "id",
                  "invocation",
                  "kind",
                  "principal",
                  "tool",
                  "resource",
                  "occurred_on",
                  "artifact_ref",
                  "decision",
                  "outcome",
                  "parent"
                ]
              },
              "maxItems": 1000,
              "minItems": 0,
              "uniqueItems": true
            },
            "coverage": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "scope_ref": {
                  "oneOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "export_ref": {
                  "oneOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "retention_ref": {
                  "oneOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "recovery_ref": {
                  "oneOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "redaction_ref": {
                  "oneOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "retention_days": {
                  "oneOf": [
                    {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 3650
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "gaps": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "start": {
                        "type": "string",
                        "format": "date"
                      },
                      "end": {
                        "type": "string",
                        "format": "date"
                      }
                    },
                    "required": [
                      "start",
                      "end"
                    ]
                  },
                  "maxItems": 100,
                  "minItems": 0,
                  "uniqueItems": true
                },
                "export_complete": {
                  "oneOf": [
                    {
                      "type": "boolean"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "correlation_complete": {
                  "oneOf": [
                    {
                      "type": "boolean"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "scope_ref",
                "export_ref",
                "retention_ref",
                "recovery_ref",
                "redaction_ref",
                "retention_days",
                "gaps",
                "export_complete",
                "correlation_complete"
              ]
            }
          },
          "required": [
            "source_profile",
            "start",
            "end",
            "required_retention_days",
            "invocations",
            "events",
            "coverage"
          ]
        }
      },
      "required": [
        "schema",
        "evaluated_on",
        "policy_id",
        "artifacts",
        "profile",
        "declarations"
      ]
    }
  ]
}
