{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vaultfire.example/schemas/base-sepolia-rehearsal-record.v1.json",
  "title": "Vaultfire Base Sepolia bonds-only rehearsal result",
  "type": "object",
  "required": ["schema", "network", "contracts", "scenarios", "reconciliations", "recordingRules"],
  "properties": {
    "schema": {"const": "vaultfire.base-sepolia-rehearsal-record.v1"},
    "network": {
      "type": "object",
      "required": ["name", "chainId"],
      "properties": {"name": {"const": "Base Sepolia"}, "chainId": {"const": 84532}},
      "additionalProperties": false
    },
    "contracts": {
      "type": "object",
      "required": ["governance", "controller", "consensus", "disputeRegistry", "partnershipBond", "accountabilityBond", "bondFactory"],
      "properties": {
        "governance": {"$ref": "#/$defs/addressOrNull"},
        "controller": {"$ref": "#/$defs/addressOrNull"},
        "consensus": {"$ref": "#/$defs/addressOrNull"},
        "disputeRegistry": {"$ref": "#/$defs/addressOrNull"},
        "partnershipBond": {"$ref": "#/$defs/addressOrNull"},
        "accountabilityBond": {"$ref": "#/$defs/addressOrNull"},
        "bondFactory": {"$ref": "#/$defs/addressOrNull"}
      },
      "additionalProperties": false
    },
    "scenarios": {
      "type": "array",
      "minItems": 19,
      "maxItems": 19,
      "items": {"$ref": "#/$defs/scenario"}
    },
    "reconciliations": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/reconciliation"}
    },
    "recordingRules": {"type": "array", "minItems": 1, "items": {"type": "string"}}
  },
  "allOf": [
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "GOV-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "GOV-02"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "PILOT-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "PILOT-02"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "PART-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "PART-02"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "ACC-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "DISP-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "DISP-02"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "DISP-03"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "TIME-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "WITHDRAW-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "EXIT-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "CAP-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "REPLAY-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "COMP-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "ROT-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "MON-01"}}, "required": ["id"]}}}},
    {"properties": {"scenarios": {"contains": {"properties": {"id": {"const": "MIG-01"}}, "required": ["id"]}}}}
  ],
  "$defs": {
    "address": {"type": "string", "pattern": "^0x[a-fA-F0-9]{40}$"},
    "addressOrNull": {"anyOf": [{"$ref": "#/$defs/address"}, {"type": "null"}]},
    "atomic": {"type": "string", "pattern": "^(0|[1-9][0-9]*)$"},
    "txHash": {"type": "string", "pattern": "^0x[a-fA-F0-9]{64}$"},
    "scenario": {
      "type": "object",
      "required": ["id", "title", "status", "transactionHashes", "events", "expectedState", "actualState", "evidenceReferences", "operator"],
      "properties": {
        "id": {"enum": ["GOV-01", "GOV-02", "PILOT-01", "PILOT-02", "PART-01", "PART-02", "ACC-01", "DISP-01", "DISP-02", "DISP-03", "TIME-01", "WITHDRAW-01", "EXIT-01", "CAP-01", "REPLAY-01", "COMP-01", "ROT-01", "MON-01", "MIG-01"]},
        "title": {"type": "string"},
        "status": {"enum": ["planned", "observed", "failed"]},
        "transactionHashes": {"type": "array", "items": {"$ref": "#/$defs/txHash"}},
        "events": {"type": "array", "items": {"$ref": "#/$defs/event"}},
        "expectedState": {"type": "object"},
        "actualState": {"type": "object"},
        "evidenceReferences": {"type": "array", "items": {"type": "string"}},
        "operator": {"type": "string"}
      },
      "additionalProperties": false
    },
    "event": {
      "type": "object",
      "required": ["name", "emitter", "logIndex", "blockNumber"],
      "properties": {
        "name": {"type": "string"},
        "emitter": {"$ref": "#/$defs/address"},
        "logIndex": {"$ref": "#/$defs/atomic"},
        "blockNumber": {"$ref": "#/$defs/atomic"}
      },
      "additionalProperties": false
    },
    "reconciliation": {
      "type": "object",
      "required": ["asset", "contractLabel", "observedBalanceAtomic", "principalLiabilityAtomic", "pendingCreditLiabilityAtomic", "blockNumber", "balanceEvidence", "liabilityEvidence"],
      "properties": {
        "asset": {"type": "string"},
        "contractLabel": {"type": "string"},
        "observedBalanceAtomic": {"$ref": "#/$defs/atomic"},
        "principalLiabilityAtomic": {"$ref": "#/$defs/atomic"},
        "pendingCreditLiabilityAtomic": {"$ref": "#/$defs/atomic"},
        "blockNumber": {"$ref": "#/$defs/atomic"},
        "balanceEvidence": {"type": "string"},
        "liabilityEvidence": {"type": "string"}
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
