{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://easyai.local/schemas/acceptance-report-v1.schema.json",
  "title": "EasyAI acceptance-report/v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "runId", "release", "snapshot", "stages", "gates", "promotion", "createdAt", "secretSafe"],
  "properties": {
    "schemaVersion": {"const": "acceptance-report/v1"},
    "runId": {"type": "string", "minLength": 1},
    "release": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sourceSha", "apiImageDigest", "workerImageDigest"],
      "properties": {
        "sourceSha": {"type": "string", "pattern": "^[0-9a-f]{40}$"},
        "apiImageDigest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
        "workerImageDigest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}
      }
    },
    "snapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sourceReleaseSha", "configHash", "sha256"],
      "properties": {
        "sourceReleaseSha": {"type": "string", "pattern": "^[0-9a-f]{40}$"},
        "configHash": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
        "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
      }
    },
    "stages": {
      "type": "object",
      "additionalProperties": {"$ref": "#/$defs/stage"}
    },
    "certifiedProfile": {"type": ["object", "null"]},
    "gates": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "passed"],
        "properties": {
          "id": {"type": "string", "minLength": 1},
          "passed": {"type": "boolean"},
          "detail": {"type": "string"}
        }
      }
    },
    "promotion": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ready", "requiresManualConfirmation", "trafficMode"],
      "properties": {
        "ready": {"type": "boolean"},
        "requiresManualConfirmation": {"const": true},
        "trafficMode": {"enum": ["validation", "live", "not-applicable"]},
        "promotedAt": {"type": "string", "format": "date-time"}
      }
    },
    "createdAt": {"type": "string", "format": "date-time"},
    "secretSafe": {"const": true}
  },
  "$defs": {
    "stage": {
      "type": "object",
      "additionalProperties": true,
      "required": ["status"],
      "properties": {
        "status": {"enum": ["passed", "failed", "not-run"]}
      }
    }
  }
}
