{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "vaultfire.base-v3-deployment-manifest.v1.schema.json",
  "title": "Vaultfire Base V3 canonical deployment manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "chain",
    "status",
    "pilotReady",
    "v2Default",
    "pilotTruthfulness",
    "evidencePlaceholders",
    "releaseEvidence",
    "contracts",
    "roles",
    "routes",
    "caps",
    "audit",
    "approval"
  ],
  "properties": {
    "schema": {
      "const": "vaultfire.base-v3-deployment-manifest.v1"
    },
    "chain": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "chainId"
      ],
      "properties": {
        "name": {
          "const": "base"
        },
        "chainId": {
          "const": 8453
        }
      }
    },
    "status": {
      "enum": [
        "draft",
        "read-only-deployed",
        "pilot-prepared",
        "activated",
        "production-ready"
      ]
    },
    "pilotReady": {
      "type": "boolean"
    },
    "v2Default": {
      "const": true
    },
    "pilotTruthfulness": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "baseOnly",
        "activeDesignPartnerLimit",
        "requiredActiveDesignPartnersForActivation",
        "currentActiveDesignPartners",
        "privacyMeaning",
        "disputeFilingBond",
        "flourishingMeasurements",
        "excludedValueFlows"
      ],
      "properties": {
        "baseOnly": {
          "const": true
        },
        "activeDesignPartnerLimit": {
          "const": 1
        },
        "requiredActiveDesignPartnersForActivation": {
          "const": 1
        },
        "currentActiveDesignPartners": {
          "enum": [0, 1]
        },
        "privacyMeaning": {
          "const": "data minimization and commitments; Base transactions remain public"
        },
        "disputeFilingBond": {
          "const": "fully refundable filing bond; never a fee, slash, or forfeiture"
        },
        "flourishingMeasurements": {
          "const": "purpose-only; never controls principal, collateral, or any protected decision"
        },
        "excludedValueFlows": {
          "const": ["solana", "cross-chain"]
        }
      }
    },
    "evidencePlaceholders": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "writtenPartnerAcceptance",
        "qualifiedCounselReview",
        "baseSepoliaRehearsal",
        "x402SettlementEvidence",
        "mainnetApproval"
      ],
      "properties": {
        "writtenPartnerAcceptance": {"type": ["string", "null"]},
        "qualifiedCounselReview": {"type": ["string", "null"]},
        "baseSepoliaRehearsal": {"type": ["string", "null"]},
        "x402SettlementEvidence": {"type": ["string", "null"]},
        "mainnetApproval": {"type": ["string", "null"]}
      }
    },
    "releaseEvidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sourceCommit",
        "build",
        "deploymentTransaction",
        "postState"
      ],
      "properties": {
        "sourceCommit": {
          "type": [
            "string",
            "null"
          ]
        },
        "build": {
          "type": [
            "string",
            "null"
          ]
        },
        "deploymentTransaction": {
          "type": [
            "string",
            "null"
          ]
        },
        "postState": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "contracts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label",
          "address",
          "runtimeCodeHash",
          "abiReference",
          "status"
        ],
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "runtimeCodeHash": {
            "type": [
              "string",
              "null"
            ]
          },
          "abiReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "enum": [
              "unverified",
              "read-only-deployed",
              "activated"
            ]
          }
        }
      }
    },
    "roles": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "signers",
        "guardians",
        "attesters",
        "adjudicators",
        "designPartners"
      ],
      "properties": {
        "signers": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "items": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "guardians": {
          "type": "array",
          "items": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "attesters": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "adjudicators": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "designPartners": {
          "type": "array",
          "maxItems": 1,
          "items": {
            "type": "string"
          }
        }
      }
    },
    "routes": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "target",
          "status"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "target": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "enum": [
              "unprepared",
              "prepared",
              "activated"
            ]
          }
        }
      }
    },
    "caps": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "scope",
          "asset",
          "atomic",
          "decisionReference"
        ],
        "properties": {
          "scope": {
            "type": "string"
          },
          "asset": {
            "type": [
              "string",
              "null"
            ]
          },
          "atomic": {
            "type": [
              "string",
              "null"
            ]
          },
          "decisionReference": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "audit": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "frozenSourceReference",
        "reportReference",
        "findings"
      ],
      "properties": {
        "frozenSourceReference": {
          "type": [
            "string",
            "null"
          ]
        },
        "reportReference": {
          "type": [
            "string",
            "null"
          ]
        },
        "findings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "approval": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "proposalIds",
        "approvalEvidence"
      ],
      "properties": {
        "proposalIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "approvalEvidence": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "pilot-prepared"
          }
        }
      },
      "then": {
        "properties": {
          "pilotReady": {
            "const": false
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "activated"
          }
        }
      },
      "then": {
        "properties": {
          "pilotTruthfulness": {
            "properties": {
              "currentActiveDesignPartners": {
                "const": 1
              }
            }
          },
          "roles": {
            "properties": {
              "designPartners": {
                "minItems": 1,
                "maxItems": 1
              }
            }
          }
        }
      }
    }
  ]
}
