{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://vclaw.dev/schemas/video/artifacts/cinema-character-sheet.schema.json",
  "title": "CinemaCharacterSheetArtifact",
  "type": "object",
  "required": ["schemaVersion", "projectSlug", "characterVersionId", "characterName", "generatedAt", "identityAnchor", "bodyPlates", "compositeSheet", "qc"],
  "additionalProperties": false,
  "properties": {
    "schemaVersion": { "const": 1 },
    "projectSlug": { "type": "string", "minLength": 1 },
    "characterVersionId": { "type": "string", "minLength": 1 },
    "characterName": { "type": "string", "minLength": 1 },
    "generatedAt": { "type": "string", "format": "date-time" },
    "identityAnchor": { "$ref": "#/definitions/IdentityAnchor" },
    "bodyPlates": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "items": { "$ref": "#/definitions/BodyPlate" }
    },
    "compositeSheet": { "$ref": "#/definitions/CompositeSheet" },
    "qc": { "$ref": "#/definitions/Qc" }
  },
  "definitions": {
    "Sha256": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "IdentityAnchor": {
      "type": "object",
      "required": ["assetId", "path", "contentHash", "identityBearingFaceCount", "locked"],
      "additionalProperties": false,
      "properties": {
        "assetId": { "type": "string", "minLength": 1 },
        "path": { "type": "string", "minLength": 1 },
        "contentHash": { "$ref": "#/definitions/Sha256" },
        "identityBearingFaceCount": { "const": 1 },
        "locked": { "const": true }
      }
    },
    "BodyPlate": {
      "type": "object",
      "required": ["assetId", "path", "contentHash", "view", "headTreatment", "identityBearingFaceCount", "faceFragmentCount", "maskArtifactId", "garmentBoundaryEvidence", "garmentBoundaryStatus"],
      "additionalProperties": false,
      "properties": {
        "assetId": { "type": "string", "minLength": 1 },
        "path": { "type": "string", "minLength": 1 },
        "contentHash": { "$ref": "#/definitions/Sha256" },
        "view": { "enum": ["front", "back"] },
        "headTreatment": { "const": "removed" },
        "identityBearingFaceCount": { "const": 0 },
        "faceFragmentCount": { "type": "integer", "minimum": 0 },
        "maskArtifactId": { "type": "string", "minLength": 1 },
        "garmentBoundaryEvidence": {
          "type": "object",
          "additionalProperties": false,
          "required": ["maskContentHash", "requiredFeatures", "preservedFeatures", "evidenceIds"],
          "properties": {
            "maskContentHash": { "$ref": "#/definitions/Sha256" },
            "requiredFeatures": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
            "preservedFeatures": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
            "evidenceIds": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }
          }
        },
        "garmentBoundaryStatus": { "enum": ["pass", "fail"] }
      }
    },
    "CompositeSheet": {
      "type": "object",
      "required": ["assetId", "path", "contentHash", "template", "identityBearingFaceCount", "componentAssetIds"],
      "additionalProperties": false,
      "properties": {
        "assetId": { "type": "string", "minLength": 1 },
        "path": { "type": "string", "minLength": 1 },
        "contentHash": { "$ref": "#/definitions/Sha256" },
        "template": { "const": "single-face-front-back-v1" },
        "identityBearingFaceCount": { "type": "integer", "minimum": 0 },
        "componentAssetIds": {
          "type": "array",
          "minItems": 3,
          "maxItems": 3,
          "items": { "type": "string", "minLength": 1 }
        }
      }
    },
    "Qc": {
      "type": "object",
      "required": ["status", "automatedCheckedAt", "issues", "humanReview"],
      "additionalProperties": false,
      "properties": {
        "status": { "enum": ["pass", "fail"] },
        "automatedCheckedAt": { "type": "string", "format": "date-time" },
        "issues": { "type": "array", "items": { "type": "string" } },
        "humanReview": {
          "type": "object",
          "required": ["status", "reviewerId", "reviewedAt", "evidenceIds"],
          "additionalProperties": false,
          "properties": {
            "status": { "enum": ["approved", "rejected", "pending"] },
            "reviewerId": { "type": "string", "minLength": 1 },
            "reviewedAt": { "type": "string", "format": "date-time" },
            "evidenceIds": { "type": "array", "items": { "type": "string", "minLength": 1 } }
          }
        }
      }
    }
  }
}
