{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:vercy:enterprise-action-requests:0.1.0:reference-shapes",
  "oneOf": [
    {
      "$ref": "#/$defs/ActionDefinition"
    },
    {
      "$ref": "#/$defs/Intent"
    },
    {
      "$ref": "#/$defs/ActionRequestSnapshot"
    },
    {
      "$ref": "#/$defs/Event"
    },
    {
      "$ref": "#/$defs/Policy"
    }
  ],
  "$defs": {
    "Pin": {
      "type": "object",
      "properties": {
        "uri": {
          "type": "string",
          "pattern": "^(urn:|https://)[!-~]+$",
          "maxLength": 512
        },
        "revision": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "uri",
        "revision",
        "sha256"
      ],
      "additionalProperties": false
    },
    "DefinitionRef": {
      "type": "object",
      "properties": {
        "definitionId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "definitionId",
        "version",
        "sha256"
      ],
      "additionalProperties": false
    },
    "Scope": {
      "type": "object",
      "properties": {
        "dimensionId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "definition": {
          "type": "object",
          "properties": {
            "definitionId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "version": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          "required": [
            "definitionId",
            "version",
            "sha256"
          ],
          "additionalProperties": false
        },
        "resourceId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "purpose": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "audience": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "actions": {
          "type": "array",
          "items": {
            "enum": [
              "submit",
              "execute",
              "read",
              "cancel",
              "observe"
            ]
          },
          "minItems": 0,
          "maxItems": 5,
          "uniqueItems": true
        },
        "validFrom": {
          "type": "integer",
          "minimum": 946684800,
          "maximum": 4102444800
        },
        "validUntil": {
          "type": "integer",
          "minimum": 946684800,
          "maximum": 4102444800
        }
      },
      "required": [
        "dimensionId",
        "definition",
        "resourceId",
        "purpose",
        "audience",
        "actions",
        "validFrom",
        "validUntil"
      ],
      "additionalProperties": false
    },
    "Rule": {
      "type": "object",
      "properties": {
        "actorId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "principalId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "mode": {
          "enum": [
            "self",
            "direct-representation"
          ]
        },
        "issuerId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "issuerStanding": {
          "type": "object",
          "properties": {
            "uri": {
              "type": "string",
              "pattern": "^(urn:|https://)[!-~]+$",
              "maxLength": 512
            },
            "revision": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          "required": [
            "uri",
            "revision",
            "sha256"
          ],
          "additionalProperties": false
        },
        "basis": {
          "type": "object",
          "properties": {
            "uri": {
              "type": "string",
              "pattern": "^(urn:|https://)[!-~]+$",
              "maxLength": 512
            },
            "revision": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          "required": [
            "uri",
            "revision",
            "sha256"
          ],
          "additionalProperties": false
        },
        "principalScope": {
          "type": "object",
          "properties": {
            "dimensionId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "definition": {
              "type": "object",
              "properties": {
                "definitionId": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                },
                "version": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "definitionId",
                "version",
                "sha256"
              ],
              "additionalProperties": false
            },
            "resourceId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "purpose": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "audience": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "actions": {
              "type": "array",
              "items": {
                "enum": [
                  "submit",
                  "execute",
                  "read",
                  "cancel",
                  "observe"
                ]
              },
              "minItems": 0,
              "maxItems": 5,
              "uniqueItems": true
            },
            "validFrom": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "validUntil": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            }
          },
          "required": [
            "dimensionId",
            "definition",
            "resourceId",
            "purpose",
            "audience",
            "actions",
            "validFrom",
            "validUntil"
          ],
          "additionalProperties": false
        },
        "delegateScope": {
          "type": "object",
          "properties": {
            "dimensionId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "definition": {
              "type": "object",
              "properties": {
                "definitionId": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                },
                "version": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "definitionId",
                "version",
                "sha256"
              ],
              "additionalProperties": false
            },
            "resourceId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "purpose": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "audience": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "actions": {
              "type": "array",
              "items": {
                "enum": [
                  "submit",
                  "execute",
                  "read",
                  "cancel",
                  "observe"
                ]
              },
              "minItems": 0,
              "maxItems": 5,
              "uniqueItems": true
            },
            "validFrom": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "validUntil": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            }
          },
          "required": [
            "dimensionId",
            "definition",
            "resourceId",
            "purpose",
            "audience",
            "actions",
            "validFrom",
            "validUntil"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "actorId",
        "principalId",
        "mode",
        "issuerId",
        "issuerStanding",
        "basis",
        "principalScope",
        "delegateScope"
      ],
      "additionalProperties": false
    },
    "Policy": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "actorId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
          },
          "principalId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
          },
          "mode": {
            "enum": [
              "self",
              "direct-representation"
            ]
          },
          "issuerId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
          },
          "issuerStanding": {
            "type": "object",
            "properties": {
              "uri": {
                "type": "string",
                "pattern": "^(urn:|https://)[!-~]+$",
                "maxLength": 512
              },
              "revision": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "uri",
              "revision",
              "sha256"
            ],
            "additionalProperties": false
          },
          "basis": {
            "type": "object",
            "properties": {
              "uri": {
                "type": "string",
                "pattern": "^(urn:|https://)[!-~]+$",
                "maxLength": 512
              },
              "revision": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "uri",
              "revision",
              "sha256"
            ],
            "additionalProperties": false
          },
          "principalScope": {
            "type": "object",
            "properties": {
              "dimensionId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
              },
              "definition": {
                "type": "object",
                "properties": {
                  "definitionId": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                  },
                  "version": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                  },
                  "sha256": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "required": [
                  "definitionId",
                  "version",
                  "sha256"
                ],
                "additionalProperties": false
              },
              "resourceId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
              },
              "purpose": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
              },
              "audience": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
              },
              "actions": {
                "type": "array",
                "items": {
                  "enum": [
                    "submit",
                    "execute",
                    "read",
                    "cancel",
                    "observe"
                  ]
                },
                "minItems": 0,
                "maxItems": 5,
                "uniqueItems": true
              },
              "validFrom": {
                "type": "integer",
                "minimum": 946684800,
                "maximum": 4102444800
              },
              "validUntil": {
                "type": "integer",
                "minimum": 946684800,
                "maximum": 4102444800
              }
            },
            "required": [
              "dimensionId",
              "definition",
              "resourceId",
              "purpose",
              "audience",
              "actions",
              "validFrom",
              "validUntil"
            ],
            "additionalProperties": false
          },
          "delegateScope": {
            "type": "object",
            "properties": {
              "dimensionId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
              },
              "definition": {
                "type": "object",
                "properties": {
                  "definitionId": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                  },
                  "version": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                  },
                  "sha256": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "required": [
                  "definitionId",
                  "version",
                  "sha256"
                ],
                "additionalProperties": false
              },
              "resourceId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
              },
              "purpose": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
              },
              "audience": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
              },
              "actions": {
                "type": "array",
                "items": {
                  "enum": [
                    "submit",
                    "execute",
                    "read",
                    "cancel",
                    "observe"
                  ]
                },
                "minItems": 0,
                "maxItems": 5,
                "uniqueItems": true
              },
              "validFrom": {
                "type": "integer",
                "minimum": 946684800,
                "maximum": 4102444800
              },
              "validUntil": {
                "type": "integer",
                "minimum": 946684800,
                "maximum": 4102444800
              }
            },
            "required": [
              "dimensionId",
              "definition",
              "resourceId",
              "purpose",
              "audience",
              "actions",
              "validFrom",
              "validUntil"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "actorId",
          "principalId",
          "mode",
          "issuerId",
          "issuerStanding",
          "basis",
          "principalScope",
          "delegateScope"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "maxItems": 128
    },
    "ActionDefinition": {
      "type": "object",
      "properties": {
        "format": {
          "enum": [
            "enterprise-action-definition/0.1.0"
          ]
        },
        "definitionId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "version": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "mode": {
          "enum": [
            "synthetic-executable",
            "descriptive-only"
          ]
        },
        "parameterContract": {
          "anyOf": [
            {
              "enum": [
                "ordered-label-list/1"
              ]
            },
            {
              "type": "object",
              "properties": {
                "uri": {
                  "type": "string",
                  "pattern": "^(urn:|https://)[!-~]+$",
                  "maxLength": 512
                },
                "revision": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "uri",
                "revision",
                "sha256"
              ],
              "additionalProperties": false
            }
          ]
        },
        "targetType": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "precondition": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "effectBoundary": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "adapter": {
          "enum": [
            "local-sqlite-ordered-labels/1",
            "none"
          ]
        },
        "validFrom": {
          "type": "integer",
          "minimum": 946684800,
          "maximum": 4102444800
        },
        "validUntil": {
          "type": "integer",
          "minimum": 946684800,
          "maximum": 4102444800
        },
        "purposes": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
          },
          "minItems": 1,
          "maxItems": 16,
          "uniqueItems": true
        },
        "authorityRequirement": {
          "enum": [
            "current-exact-principal-and-actor-scope"
          ]
        },
        "compensation": {
          "enum": [
            "new-request-restores-before-labels-at-exact-after-revision",
            "external-unspecified"
          ]
        },
        "stewardId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "masterId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "legacyCrosswalk": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "uri": {
                  "type": "string",
                  "pattern": "^(urn:|https://)[!-~]+$",
                  "maxLength": 512
                },
                "revision": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "uri",
                "revision",
                "sha256"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "format",
        "definitionId",
        "version",
        "name",
        "description",
        "mode",
        "parameterContract",
        "targetType",
        "precondition",
        "effectBoundary",
        "adapter",
        "validFrom",
        "validUntil",
        "purposes",
        "authorityRequirement",
        "compensation",
        "stewardId",
        "masterId",
        "legacyCrosswalk"
      ],
      "additionalProperties": false
    },
    "Intent": {
      "type": "object",
      "properties": {
        "format": {
          "enum": [
            "enterprise-action-intent/0.1.0"
          ]
        },
        "dimensionId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "definition": {
          "type": "object",
          "properties": {
            "definitionId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "version": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          "required": [
            "definitionId",
            "version",
            "sha256"
          ],
          "additionalProperties": false
        },
        "resourceId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "expectedRevision": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "parameters": {
          "type": "object",
          "properties": {
            "labels": {
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 200
              },
              "minItems": 0,
              "maxItems": 32
            }
          },
          "required": [
            "labels"
          ],
          "additionalProperties": false
        },
        "actorId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "principalId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "purpose": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
        },
        "audience": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "expiresAt": {
          "type": "integer",
          "minimum": 946684800,
          "maximum": 4102444800
        },
        "compensatesReceiptId": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "format",
        "dimensionId",
        "definition",
        "resourceId",
        "expectedRevision",
        "parameters",
        "actorId",
        "principalId",
        "purpose",
        "audience",
        "expiresAt",
        "compensatesReceiptId"
      ],
      "additionalProperties": false
    },
    "ActionRequestSnapshot": {
      "type": "object",
      "properties": {
        "requestId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "keyHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "intentDigest": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "intent": {
          "type": "object",
          "properties": {
            "format": {
              "enum": [
                "enterprise-action-intent/0.1.0"
              ]
            },
            "dimensionId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "definition": {
              "type": "object",
              "properties": {
                "definitionId": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                },
                "version": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "definitionId",
                "version",
                "sha256"
              ],
              "additionalProperties": false
            },
            "resourceId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "expectedRevision": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "parameters": {
              "type": "object",
              "properties": {
                "labels": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "minItems": 0,
                  "maxItems": 32
                }
              },
              "required": [
                "labels"
              ],
              "additionalProperties": false
            },
            "actorId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "principalId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "purpose": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
            },
            "audience": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "expiresAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "compensatesReceiptId": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "format",
            "dimensionId",
            "definition",
            "resourceId",
            "expectedRevision",
            "parameters",
            "actorId",
            "principalId",
            "purpose",
            "audience",
            "expiresAt",
            "compensatesReceiptId"
          ],
          "additionalProperties": false
        },
        "submittedAt": {
          "type": "integer",
          "minimum": 946684800,
          "maximum": 4102444800
        },
        "submissionEventId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
        },
        "state": {
          "enum": [
            "pending",
            "committed",
            "cancelled",
            "expired",
            "rejected-precondition"
          ]
        },
        "receiptId": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "keyRetired": {
          "type": "boolean"
        }
      },
      "required": [
        "requestId",
        "keyHash",
        "intentDigest",
        "intent",
        "submittedAt",
        "submissionEventId",
        "state",
        "receiptId",
        "keyRetired"
      ],
      "additionalProperties": false
    },
    "Event": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "controlSequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "enum": [
                "submission"
              ]
            },
            "requestId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "recordedAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "issuerId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "payload": {
              "type": "object",
              "properties": {
                "intentDigest": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "intentDigest"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "eventId",
            "sequence",
            "controlSequence",
            "kind",
            "requestId",
            "recordedAt",
            "issuerId",
            "payload"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "controlSequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "enum": [
                "delivery"
              ]
            },
            "requestId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "recordedAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "issuerId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "payload": {
              "type": "object",
              "properties": {
                "intentDigest": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "intentDigest"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "eventId",
            "sequence",
            "controlSequence",
            "kind",
            "requestId",
            "recordedAt",
            "issuerId",
            "payload"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "controlSequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "enum": [
                "try"
              ]
            },
            "requestId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "recordedAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "issuerId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "payload": {
              "type": "object",
              "properties": {
                "decision": {
                  "type": "object",
                  "properties": {
                    "action": {
                      "enum": [
                        "execute",
                        "cancel",
                        "observe"
                      ]
                    },
                    "policyRevision": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "allowed": {
                      "type": "boolean"
                    },
                    "matchedRuleDigests": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "minItems": 0,
                      "maxItems": 128,
                      "uniqueItems": true
                    },
                    "definitionAvailable": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "action",
                    "policyRevision",
                    "allowed",
                    "matchedRuleDigests",
                    "definitionAvailable"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "decision"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "eventId",
            "sequence",
            "controlSequence",
            "kind",
            "requestId",
            "recordedAt",
            "issuerId",
            "payload"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "controlSequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "enum": [
                "receipt"
              ]
            },
            "requestId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "recordedAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "issuerId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "payload": {
              "type": "object",
              "properties": {
                "definition": {
                  "type": "object",
                  "properties": {
                    "definitionId": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                    },
                    "version": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                    },
                    "sha256": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{64}$"
                    }
                  },
                  "required": [
                    "definitionId",
                    "version",
                    "sha256"
                  ],
                  "additionalProperties": false
                },
                "resourceId": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                },
                "beforeRevision": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "afterRevision": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "beforeLabels": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "minItems": 0,
                  "maxItems": 32
                },
                "afterLabels": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "minItems": 0,
                  "maxItems": 32
                },
                "compensatesReceiptId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "tryEventId": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                }
              },
              "required": [
                "definition",
                "resourceId",
                "beforeRevision",
                "afterRevision",
                "beforeLabels",
                "afterLabels",
                "compensatesReceiptId",
                "tryEventId"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "eventId",
            "sequence",
            "controlSequence",
            "kind",
            "requestId",
            "recordedAt",
            "issuerId",
            "payload"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "controlSequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "enum": [
                "disposition"
              ]
            },
            "requestId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "recordedAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "issuerId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "payload": {
              "type": "object",
              "properties": {
                "from": {
                  "enum": [
                    "pending"
                  ]
                },
                "to": {
                  "enum": [
                    "cancelled",
                    "expired",
                    "rejected-precondition"
                  ]
                },
                "reason": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
                },
                "tryEventId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "from",
                "to",
                "reason",
                "tryEventId"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "eventId",
            "sequence",
            "controlSequence",
            "kind",
            "requestId",
            "recordedAt",
            "issuerId",
            "payload"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "controlSequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "enum": [
                "observation"
              ]
            },
            "requestId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "recordedAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "issuerId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "payload": {
              "type": "object",
              "properties": {
                "observerId": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                },
                "claim": {
                  "enum": [
                    "caller-unknown",
                    "caller-observed-success",
                    "caller-observed-failure"
                  ]
                },
                "reason": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 2048
                },
                "correctsEventId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "tryEventId": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
                }
              },
              "required": [
                "observerId",
                "claim",
                "reason",
                "correctsEventId",
                "tryEventId"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "eventId",
            "sequence",
            "controlSequence",
            "kind",
            "requestId",
            "recordedAt",
            "issuerId",
            "payload"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "sequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "controlSequence": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "enum": [
                "key-retirement"
              ]
            },
            "requestId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "recordedAt": {
              "type": "integer",
              "minimum": 946684800,
              "maximum": 4102444800
            },
            "issuerId": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{2,127}$"
            },
            "payload": {
              "type": "object",
              "properties": {
                "retained": {
                  "enum": [
                    true
                  ]
                }
              },
              "required": [
                "retained"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "eventId",
            "sequence",
            "controlSequence",
            "kind",
            "requestId",
            "recordedAt",
            "issuerId",
            "payload"
          ],
          "additionalProperties": false
        }
      ]
    },
    "Labels": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 200
      },
      "minItems": 0,
      "maxItems": 32
    }
  }
}
