{
  "$comment": "SPDX-License-Identifier: MIT",
  "$id": "https://spec.vaultfire.local/v3-open/1.0.0/bond-definition.v1.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "additionalProperties": false,
      "properties": {
        "activePeriodEnd": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "activePeriodStart": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "aiCompany": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        },
        "bondId": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "chainId": {
          "enum": [
            "8453",
            "84532"
          ]
        },
        "challengeWindow": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "companyStake": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "consent": {
          "additionalProperties": false,
          "properties": {
            "explicit": {
              "const": true
            },
            "parties": {
              "items": {
                "pattern": "^0x[0-9a-f]{40}$",
                "type": "string"
              },
              "maxItems": 2,
              "minItems": 2,
              "type": "array",
              "uniqueItems": true
            }
          },
          "required": [
            "explicit",
            "parties"
          ],
          "type": "object"
        },
        "counterparty": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        },
        "createdAt": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "decisionInputs": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "class": {
                "const": "objective-protocol"
              },
              "containsPersonalData": {
                "const": false
              },
              "containsSurveillanceData": {
                "const": false
              },
              "decisionInfluence": {
                "const": "bounded-objective-rule"
              },
              "evidenceDigest": {
                "pattern": "^0x[0-9a-f]{64}$",
                "type": "string"
              },
              "provenance": {
                "const": "canonical-source"
              }
            },
            "required": [
              "class",
              "provenance",
              "decisionInfluence",
              "containsPersonalData",
              "containsSurveillanceData",
              "evidenceDigest"
            ],
            "type": "object"
          },
          "maxItems": 8,
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "enforcement": {
          "additionalProperties": false,
          "properties": {
            "adjudicatorSetHash": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "adjudicatorThreshold": {
              "const": 0
            },
            "attesterSetHash": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "attesterThreshold": {
              "const": 0
            },
            "canonicalSource": {
              "pattern": "^0x[0-9a-f]{40}$",
              "type": "string"
            },
            "canonicalSourceCodehash": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "canonicalSourceId": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "challengeWindow": {
              "pattern": "^(0|[1-9][0-9]*)$",
              "type": "string"
            },
            "configHash": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "decisionWindow": {
              "pattern": "^(0|[1-9][0-9]*)$",
              "type": "string"
            },
            "evidenceSchemaHash": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "maximumSlash": {
              "pattern": "^(0|[1-9][0-9]*)$",
              "type": "string"
            },
            "obligationId": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "privacyExclusionsHash": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "requiredBy": {
              "pattern": "^(0|[1-9][0-9]*)$",
              "type": "string"
            },
            "responseWindow": {
              "pattern": "^(0|[1-9][0-9]*)$",
              "type": "string"
            },
            "timeoutPolicy": {
              "additionalProperties": false,
              "properties": {
                "acceptedLiabilityTimeout": {
                  "const": "settle-if-current-breach-otherwise-full-refund"
                },
                "boundary": {
                  "const": "activePeriodEnd"
                },
                "callableWhilePaused": {
                  "const": true
                },
                "canonicalRevalidation": {
                  "const": "same-timestamp-before-settlement"
                },
                "genericDisputeSelectors": {
                  "const": "retired"
                }
              },
              "required": [
                "canonicalRevalidation",
                "acceptedLiabilityTimeout",
                "callableWhilePaused",
                "boundary",
                "genericDisputeSelectors"
              ],
              "type": "object"
            }
          },
          "required": [
            "canonicalSource",
            "canonicalSourceCodehash",
            "canonicalSourceId",
            "obligationId",
            "requiredBy",
            "responseWindow",
            "challengeWindow",
            "decisionWindow",
            "maximumSlash",
            "evidenceSchemaHash",
            "privacyExclusionsHash",
            "attesterSetHash",
            "adjudicatorSetHash",
            "attesterThreshold",
            "adjudicatorThreshold",
            "configHash",
            "timeoutPolicy"
          ],
          "type": "object"
        },
        "extensions": {
          "additionalProperties": {
            "additionalProperties": false,
            "properties": {
              "decisionInfluence": {
                "const": "none"
              },
              "securityCritical": {
                "const": false
              },
              "value": {
                "maxLength": 256,
                "type": [
                  "string",
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "securityCritical",
              "decisionInfluence",
              "value"
            ],
            "type": "object"
          },
          "maxProperties": 16,
          "propertyNames": {
            "pattern": "^x-[a-z0-9]+(?:-[a-z0-9]+)*$",
            "type": "string"
          },
          "type": "object"
        },
        "invariants": {
          "additionalProperties": false,
          "properties": {
            "boundedPauseSafeExitRequired": {
              "const": true
            },
            "explicitConsentRequired": {
              "const": true
            },
            "flourishingCanSlashPrincipal": {
              "const": false
            },
            "rewardsCanConsumeCollateral": {
              "const": false
            },
            "surveillancePermittedForProtectedDecisions": {
              "const": false
            }
          },
          "required": [
            "flourishingCanSlashPrincipal",
            "rewardsCanConsumeCollateral",
            "surveillancePermittedForProtectedDecisions",
            "explicitConsentRequired",
            "boundedPauseSafeExitRequired"
          ],
          "type": "object"
        },
        "kind": {
          "const": "accountability"
        },
        "nonce": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "objectiveRuleClass": {
          "const": 1
        },
        "objectiveRuleHash": {
          "pattern": "^0x[0-9a-f]{64}$",
          "type": "string"
        },
        "objectiveRuleSchemaVersion": {
          "const": 1
        },
        "portability": {
          "additionalProperties": false,
          "properties": {
            "authorizationDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "chainSpecificAuthorizationRequired": {
              "const": true
            },
            "destinationChainId": {
              "pattern": "^[1-9][0-9]*$",
              "type": "string"
            },
            "explicitConsent": {
              "const": true
            },
            "historyDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "personalDataIncluded": {
              "const": false
            },
            "purpose": {
              "pattern": "^[a-z][a-z0-9-]{2,63}$",
              "type": "string"
            },
            "recipient": {
              "pattern": "^0x[0-9a-f]{40}$",
              "type": "string"
            },
            "revocable": {
              "const": true
            },
            "sourceChainId": {
              "pattern": "^[1-9][0-9]*$",
              "type": "string"
            },
            "surveillanceDataIncluded": {
              "const": false
            },
            "validUntil": {
              "pattern": "^(0|[1-9][0-9]*)$",
              "type": "string"
            }
          },
          "required": [
            "historyDigest",
            "sourceChainId",
            "destinationChainId",
            "personalDataIncluded",
            "surveillanceDataIncluded",
            "explicitConsent",
            "chainSpecificAuthorizationRequired",
            "purpose",
            "recipient",
            "validUntil",
            "authorizationDigest",
            "revocable"
          ],
          "type": "object"
        },
        "protocolVersion": {
          "const": "3.0.0"
        },
        "provenanceGraph": {
          "additionalProperties": false,
          "properties": {
            "authorizationDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "authorizationVerified": {
              "const": false
            },
            "graphDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "nodes": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "containsPersonalData": {
                    "const": false
                  },
                  "containsSurveillanceData": {
                    "const": false
                  },
                  "derivation": {
                    "additionalProperties": false,
                    "properties": {
                      "algorithm": {
                        "enum": [
                          "none",
                          "sha256-rfc8785"
                        ]
                      },
                      "kind": {
                        "enum": [
                          "root-canonical",
                          "canonical-transform"
                        ]
                      },
                      "parametersDigest": {
                        "pattern": "^0x[0-9a-f]{64}$",
                        "type": "string"
                      }
                    },
                    "required": [
                      "kind",
                      "algorithm",
                      "parametersDigest"
                    ],
                    "type": "object"
                  },
                  "digest": {
                    "pattern": "^0x[0-9a-f]{64}$",
                    "type": "string"
                  },
                  "parentDigests": {
                    "items": {
                      "pattern": "^0x[0-9a-f]{64}$",
                      "type": "string"
                    },
                    "maxItems": 16,
                    "type": "array",
                    "uniqueItems": true
                  },
                  "sourceBinding": {
                    "additionalProperties": false,
                    "properties": {
                      "chainId": {
                        "enum": [
                          "8453",
                          "84532"
                        ]
                      },
                      "contentDigest": {
                        "pattern": "^0x[0-9a-f]{64}$",
                        "type": "string"
                      },
                      "sourceIdentifier": {
                        "pattern": "^0x[0-9a-f]{64}$",
                        "type": "string"
                      },
                      "verifyingContract": {
                        "pattern": "^0x[0-9a-f]{40}$",
                        "type": "string"
                      }
                    },
                    "required": [
                      "chainId",
                      "verifyingContract",
                      "sourceIdentifier",
                      "contentDigest"
                    ],
                    "type": "object"
                  },
                  "sourceClass": {
                    "enum": [
                      "canonical-contract-state",
                      "canonical-contract-event"
                    ]
                  }
                },
                "required": [
                  "digest",
                  "sourceClass",
                  "parentDigests",
                  "containsPersonalData",
                  "containsSurveillanceData",
                  "sourceBinding",
                  "derivation"
                ],
                "type": "object"
              },
              "maxItems": 64,
              "minItems": 1,
              "type": "array",
              "uniqueItems": true
            }
          },
          "required": [
            "nodes",
            "graphDigest",
            "authorizationDigest",
            "authorizationVerified"
          ],
          "type": "object"
        },
        "schema": {
          "const": "vaultfire.v3.open.bond-definition.v1"
        },
        "schemaVersion": {
          "const": "1.0.0"
        },
        "stakeAsset": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        },
        "verifyingContract": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        }
      },
      "required": [
        "schema",
        "schemaVersion",
        "protocolVersion",
        "kind",
        "chainId",
        "verifyingContract",
        "bondId",
        "createdAt",
        "stakeAsset",
        "activePeriodStart",
        "activePeriodEnd",
        "challengeWindow",
        "nonce",
        "consent",
        "invariants",
        "decisionInputs",
        "extensions",
        "portability",
        "aiCompany",
        "counterparty",
        "companyStake",
        "objectiveRuleHash",
        "objectiveRuleClass",
        "objectiveRuleSchemaVersion",
        "enforcement",
        "provenanceGraph"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "properties": {
        "activePeriodEnd": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "activePeriodStart": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "bondId": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "chainId": {
          "enum": [
            "8453",
            "84532"
          ]
        },
        "challengeWindow": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "consent": {
          "additionalProperties": false,
          "properties": {
            "explicit": {
              "const": true
            },
            "parties": {
              "items": {
                "pattern": "^0x[0-9a-f]{40}$",
                "type": "string"
              },
              "maxItems": 2,
              "minItems": 2,
              "type": "array",
              "uniqueItems": true
            }
          },
          "required": [
            "explicit",
            "parties"
          ],
          "type": "object"
        },
        "createdAt": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "decisionInputs": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "class": {
                "const": "objective-protocol"
              },
              "containsPersonalData": {
                "const": false
              },
              "containsSurveillanceData": {
                "const": false
              },
              "decisionInfluence": {
                "const": "bounded-objective-rule"
              },
              "evidenceDigest": {
                "pattern": "^0x[0-9a-f]{64}$",
                "type": "string"
              },
              "provenance": {
                "const": "canonical-source"
              }
            },
            "required": [
              "class",
              "provenance",
              "decisionInfluence",
              "containsPersonalData",
              "containsSurveillanceData",
              "evidenceDigest"
            ],
            "type": "object"
          },
          "maxItems": 8,
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "extensions": {
          "additionalProperties": {
            "additionalProperties": false,
            "properties": {
              "decisionInfluence": {
                "const": "none"
              },
              "securityCritical": {
                "const": false
              },
              "value": {
                "maxLength": 256,
                "type": [
                  "string",
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "securityCritical",
              "decisionInfluence",
              "value"
            ],
            "type": "object"
          },
          "maxProperties": 16,
          "propertyNames": {
            "pattern": "^x-[a-z0-9]+(?:-[a-z0-9]+)*$",
            "type": "string"
          },
          "type": "object"
        },
        "invariants": {
          "additionalProperties": false,
          "properties": {
            "boundedPauseSafeExitRequired": {
              "const": true
            },
            "explicitConsentRequired": {
              "const": true
            },
            "flourishingCanSlashPrincipal": {
              "const": false
            },
            "rewardsCanConsumeCollateral": {
              "const": false
            },
            "surveillancePermittedForProtectedDecisions": {
              "const": false
            }
          },
          "required": [
            "flourishingCanSlashPrincipal",
            "rewardsCanConsumeCollateral",
            "surveillancePermittedForProtectedDecisions",
            "explicitConsentRequired",
            "boundedPauseSafeExitRequired"
          ],
          "type": "object"
        },
        "kind": {
          "const": "partnership"
        },
        "nonce": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "objectiveRuleClass": {
          "const": 0
        },
        "objectiveRuleSchemaVersion": {
          "const": 0
        },
        "partnershipType": {
          "pattern": "^0x[0-9a-f]{64}$",
          "type": "string"
        },
        "partyA": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        },
        "partyAStake": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "partyB": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        },
        "partyBStake": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "portability": {
          "additionalProperties": false,
          "properties": {
            "authorizationDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "chainSpecificAuthorizationRequired": {
              "const": true
            },
            "destinationChainId": {
              "pattern": "^[1-9][0-9]*$",
              "type": "string"
            },
            "explicitConsent": {
              "const": true
            },
            "historyDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "personalDataIncluded": {
              "const": false
            },
            "purpose": {
              "pattern": "^[a-z][a-z0-9-]{2,63}$",
              "type": "string"
            },
            "recipient": {
              "pattern": "^0x[0-9a-f]{40}$",
              "type": "string"
            },
            "revocable": {
              "const": true
            },
            "sourceChainId": {
              "pattern": "^[1-9][0-9]*$",
              "type": "string"
            },
            "surveillanceDataIncluded": {
              "const": false
            },
            "validUntil": {
              "pattern": "^(0|[1-9][0-9]*)$",
              "type": "string"
            }
          },
          "required": [
            "historyDigest",
            "sourceChainId",
            "destinationChainId",
            "personalDataIncluded",
            "surveillanceDataIncluded",
            "explicitConsent",
            "chainSpecificAuthorizationRequired",
            "purpose",
            "recipient",
            "validUntil",
            "authorizationDigest",
            "revocable"
          ],
          "type": "object"
        },
        "proposalDeadline": {
          "pattern": "^(0|[1-9][0-9]*)$",
          "type": "string"
        },
        "protocolVersion": {
          "const": "3.0.0"
        },
        "provenanceGraph": {
          "additionalProperties": false,
          "properties": {
            "authorizationDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "authorizationVerified": {
              "const": false
            },
            "graphDigest": {
              "pattern": "^0x[0-9a-f]{64}$",
              "type": "string"
            },
            "nodes": {
              "items": {
                "additionalProperties": false,
                "properties": {
                  "containsPersonalData": {
                    "const": false
                  },
                  "containsSurveillanceData": {
                    "const": false
                  },
                  "derivation": {
                    "additionalProperties": false,
                    "properties": {
                      "algorithm": {
                        "enum": [
                          "none",
                          "sha256-rfc8785"
                        ]
                      },
                      "kind": {
                        "enum": [
                          "root-canonical",
                          "canonical-transform"
                        ]
                      },
                      "parametersDigest": {
                        "pattern": "^0x[0-9a-f]{64}$",
                        "type": "string"
                      }
                    },
                    "required": [
                      "kind",
                      "algorithm",
                      "parametersDigest"
                    ],
                    "type": "object"
                  },
                  "digest": {
                    "pattern": "^0x[0-9a-f]{64}$",
                    "type": "string"
                  },
                  "parentDigests": {
                    "items": {
                      "pattern": "^0x[0-9a-f]{64}$",
                      "type": "string"
                    },
                    "maxItems": 16,
                    "type": "array",
                    "uniqueItems": true
                  },
                  "sourceBinding": {
                    "additionalProperties": false,
                    "properties": {
                      "chainId": {
                        "enum": [
                          "8453",
                          "84532"
                        ]
                      },
                      "contentDigest": {
                        "pattern": "^0x[0-9a-f]{64}$",
                        "type": "string"
                      },
                      "sourceIdentifier": {
                        "pattern": "^0x[0-9a-f]{64}$",
                        "type": "string"
                      },
                      "verifyingContract": {
                        "pattern": "^0x[0-9a-f]{40}$",
                        "type": "string"
                      }
                    },
                    "required": [
                      "chainId",
                      "verifyingContract",
                      "sourceIdentifier",
                      "contentDigest"
                    ],
                    "type": "object"
                  },
                  "sourceClass": {
                    "enum": [
                      "canonical-contract-state",
                      "canonical-contract-event"
                    ]
                  }
                },
                "required": [
                  "digest",
                  "sourceClass",
                  "parentDigests",
                  "containsPersonalData",
                  "containsSurveillanceData",
                  "sourceBinding",
                  "derivation"
                ],
                "type": "object"
              },
              "maxItems": 64,
              "minItems": 1,
              "type": "array",
              "uniqueItems": true
            }
          },
          "required": [
            "nodes",
            "graphDigest",
            "authorizationDigest",
            "authorizationVerified"
          ],
          "type": "object"
        },
        "schema": {
          "const": "vaultfire.v3.open.bond-definition.v1"
        },
        "schemaVersion": {
          "const": "1.0.0"
        },
        "stakeAsset": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        },
        "verifyingContract": {
          "pattern": "^0x[0-9a-f]{40}$",
          "type": "string"
        }
      },
      "required": [
        "schema",
        "schemaVersion",
        "protocolVersion",
        "kind",
        "chainId",
        "verifyingContract",
        "bondId",
        "createdAt",
        "stakeAsset",
        "activePeriodStart",
        "activePeriodEnd",
        "challengeWindow",
        "nonce",
        "consent",
        "invariants",
        "decisionInputs",
        "extensions",
        "portability",
        "partyA",
        "partyB",
        "partyAStake",
        "partyBStake",
        "partnershipType",
        "objectiveRuleClass",
        "objectiveRuleSchemaVersion",
        "proposalDeadline",
        "provenanceGraph"
      ],
      "type": "object"
    }
  ]
}
