{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pactverity.com/specs/data-centre-assurance-receipt-v0.1.schema.json",
  "title": "PactVerity Data Centre Assurance Receipt v0.1",
  "description": "Pilot-ready format for deterministic evaluation of caller-supplied data-centre evidence. It is not an audit, rating, monitoring service, insurance product or repayment guarantee.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "receiptId", "profileStatus", "facility", "period", "evidence", "checks", "outcome", "limitations", "issuedAt"],
  "properties": {
    "schema": { "const": "pactverity.data-centre-assurance-receipt.v0.1" },
    "receiptId": { "type": "string", "minLength": 8, "maxLength": 160 },
    "profileStatus": { "const": "evaluation" },
    "facility": {
      "type": "object",
      "additionalProperties": false,
      "required": ["facilityId", "name", "jurisdiction"],
      "properties": {
        "facilityId": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "jurisdiction": { "type": "string", "minLength": 2 },
        "operator": { "type": "string" }
      }
    },
    "period": {
      "type": "object",
      "additionalProperties": false,
      "required": ["start", "end", "timezone"],
      "properties": {
        "start": { "type": "string", "format": "date-time" },
        "end": { "type": "string", "format": "date-time" },
        "timezone": { "type": "string", "minLength": 1 }
      }
    },
    "evidence": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["evidenceId", "metric", "sourceType", "observedAt", "value", "unit", "sourceReference", "digest"],
        "properties": {
          "evidenceId": { "type": "string", "minLength": 1 },
          "metric": { "enum": ["commissioning", "contracted_power", "delivered_power", "availability", "pue", "renewable_provenance", "water_use", "backup_power", "cooling", "network", "security_incident", "covenant"] },
          "sourceType": { "enum": ["operator_reported", "meter_derived", "monitoring_platform", "independent_engineer", "system_of_record"] },
          "observedAt": { "type": "string", "format": "date-time" },
          "value": { "type": ["number", "integer", "string", "boolean"] },
          "unit": { "type": "string", "minLength": 1 },
          "sourceReference": { "type": "string", "minLength": 1 },
          "digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "signer": { "type": "string" }
        }
      }
    },
    "checks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["checkId", "evidenceId", "operator", "threshold", "result"],
        "properties": {
          "checkId": { "type": "string", "minLength": 1 },
          "evidenceId": { "type": "string", "minLength": 1 },
          "operator": { "enum": ["gte", "lte", "eq", "present"] },
          "threshold": { "type": ["number", "integer", "string", "boolean"] },
          "result": { "enum": ["pass", "fail", "unevaluated"] },
          "reason": { "type": "string" }
        }
      }
    },
    "outcome": { "enum": ["pass", "fail", "incomplete"] },
    "limitations": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
    "payloadDigest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "signatures": { "type": "array", "items": { "type": "object", "required": ["role", "signer", "signature"], "properties": { "role": { "enum": ["operator", "independent_engineer", "reviewer"] }, "signer": { "type": "string" }, "signature": { "type": "string" } } } },
    "issuedAt": { "type": "string", "format": "date-time" }
  }
}
