{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://confighub.github.io/helm-expt/site/promotion-review.schema.json",
  "title": "ConfigHub Workshop Promotion Review",
  "description": "A browser-generated record of the exact configuration change, its source-aware field classification, lifecycle requirements, target results, and checks that have not run.",
  "type": "object",
  "additionalProperties": false,
  "required": ["apiVersion", "kind", "metadata", "spec"],
  "properties": {
    "apiVersion": { "const": "workshop.confighub.com/v1alpha2" },
    "kind": { "const": "PromotionReview" },
    "metadata": {
      "type": "object",
      "additionalProperties": false,
      "required": ["createdAt"],
      "properties": {
        "createdAt": { "type": "string", "format": "date-time" }
      }
    },
    "spec": {
      "type": "object",
      "additionalProperties": false,
      "required": ["change", "current", "candidate", "comparison", "assessment", "sourceAware", "lifecycle", "destinationPreflight", "targets", "browserChecks", "testsRequired", "nextAction"],
      "properties": {
        "change": { "type": "object" },
        "current": { "$ref": "#/definitions/objectSet" },
        "candidate": { "$ref": "#/definitions/objectSet" },
        "comparison": { "type": "object" },
        "assessment": { "$ref": "#/definitions/assessment" },
        "sourceAware": { "type": "object" },
        "lifecycle": { "type": "object" },
        "destinationPreflight": { "$ref": "#/definitions/destinationPreflight" },
        "targets": { "type": "object" },
        "browserChecks": { "type": "object" },
        "testsRequired": {
          "type": "array",
          "items": { "type": "string" }
        },
        "nextAction": { "type": "string" },
        "configHubPlan": { "type": "object" }
      }
    }
  },
  "definitions": {
    "assessment": {
      "type": "object",
      "additionalProperties": false,
      "required": ["stages"],
      "properties": {
        "stages": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": { "$ref": "#/definitions/assessmentStage" }
        }
      }
    },
    "assessmentStage": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "question", "answer", "requiredInputs", "catalogMatchRequired", "sourceIntentRequired", "destinationAccessRequired", "deploymentRequired", "evidenceState", "resultState", "records", "nextAction"],
      "properties": {
        "id": { "enum": ["inspection", "materialization", "destination", "post-deployment"] },
        "question": { "type": "string", "minLength": 1 },
        "answer": { "type": "string", "minLength": 1 },
        "requiredInputs": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
        "catalogMatchRequired": { "type": "boolean" },
        "sourceIntentRequired": { "type": "boolean" },
        "destinationAccessRequired": { "type": "boolean" },
        "deploymentRequired": { "type": "boolean" },
        "evidenceState": { "enum": ["completed", "pending", "not-run", "blocked", "not-applicable"] },
        "resultState": { "enum": ["available", "pass", "watch", "fail", "pending", "not-run", "blocked", "not-applicable"] },
        "records": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "nextAction": { "type": "string", "minLength": 1 }
      }
    },
    "objectSet": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "sha256", "objectCount", "objectSetSha256", "objectSetHashAlgorithm", "objects"],
      "properties": {
        "name": { "type": "string" },
        "sha256": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
        "objectCount": { "type": "integer", "minimum": 0 },
        "objectSetSha256": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
        "objectSetHashAlgorithm": { "type": "string", "minLength": 1 },
        "objects": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "destinationPreflight": {
      "type": "object",
      "additionalProperties": false,
      "required": ["destinations", "namespaces", "namespaceHandling", "prerequisites", "lifecycleResolution", "delivery", "checks"],
      "properties": {
        "destinations": {
          "type": "array",
          "items": { "type": "string" }
        },
        "namespaces": {
          "type": "array",
          "items": { "type": "string" }
        },
        "namespaceHandling": {
          "enum": ["preserve-source-namespaces", "single-namespace", "cluster-scoped-only", "not-assessed"]
        },
        "prerequisites": { "type": "object" },
        "lifecycleResolution": { "type": "object" },
        "delivery": { "type": "object" },
        "checks": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id", "status", "note"],
            "properties": {
              "id": { "type": "string" },
              "status": { "enum": ["pass", "watch", "blocked", "not-run", "not-applicable"] },
              "note": { "type": "string" },
              "evidence": {
                "type": "array",
                "items": { "type": "string" }
              }
            }
          }
        }
      }
    }
  }
}
