{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Golden Watt teaching deal passport",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "deal_id",
    "model_version",
    "status",
    "period",
    "currency",
    "tax_basis",
    "physical",
    "components",
    "evidence",
    "assumptions",
    "unknowns",
    "authority"
  ],
  "properties": {
    "deal_id": {
      "type": "string",
      "minLength": 1
    },
    "model_version": {
      "const": "1.1.0"
    },
    "status": {
      "enum": [
        "synthetic",
        "draft",
        "verified",
        "disputed"
      ]
    },
    "period": {
      "type": "object",
      "required": [
        "start",
        "end",
        "timezone"
      ],
      "additionalProperties": false,
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "type": "string",
          "format": "date-time"
        },
        "timezone": {
          "type": "string"
        }
      }
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "tax_basis": {
      "enum": [
        "ex_VAT",
        "incl_VAT"
      ]
    },
    "physical": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "site_id",
        "energy_unit",
        "baseline",
        "actual"
      ],
      "properties": {
        "site_id": {
          "type": "string"
        },
        "energy_unit": {
          "const": "kWh"
        },
        "baseline": {
          "type": "number",
          "minimum": 0
        },
        "actual": {
          "type": "number",
          "minimum": 0
        }
      }
    },
    "components": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "obligation",
          "payer",
          "beneficiary",
          "unit",
          "evidence_id",
          "compatibility_checked"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "obligation": {
            "type": "string",
            "minLength": 1
          },
          "payer": {
            "type": "string",
            "minLength": 1
          },
          "beneficiary": {
            "type": "string",
            "minLength": 1
          },
          "unit": {
            "type": "string"
          },
          "evidence_id": {
            "type": "string"
          },
          "compatibility_checked": {
            "type": "boolean"
          }
        }
      }
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "kind",
          "reference"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "measurement",
              "calculation",
              "assumption",
              "source_claim"
            ]
          },
          "reference": {
            "type": "string"
          }
        }
      }
    },
    "assumptions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "unknowns": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "authority": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "allowed_actions"
      ],
      "properties": {
        "mode": {
          "enum": [
            "propose",
            "execute"
          ]
        },
        "allowed_actions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}