{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://vclaw.dev/schemas/video/artifacts/cinema-reference-pack.schema.json",
  "title": "CinemaReferencePackArtifact",
  "type": "object",
  "required": ["schemaVersion", "projectSlug", "packId", "shotId", "generatedAt", "references", "transitions", "referenceBudget"],
  "additionalProperties": false,
  "properties": {
    "schemaVersion": { "const": 1 },
    "projectSlug": { "type": "string", "minLength": 1 },
    "packId": { "type": "string", "minLength": 1 },
    "shotId": { "type": "string", "minLength": 1 },
    "generatedAt": { "type": "string", "format": "date-time" },
    "references": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/ReferenceEntry" } },
    "transitions": { "type": "array", "items": { "$ref": "#/definitions/MechanicalTransition" } },
    "referenceBudget": {
      "type": "object",
      "required": ["maximum", "actual", "withinLimit"],
      "additionalProperties": false,
      "properties": {
        "maximum": { "type": "integer", "minimum": 0 },
        "actual": { "type": "integer", "minimum": 0 },
        "withinLimit": { "type": "boolean" }
      }
    }
  },
  "definitions": {
    "Sha256": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "ReferenceEntry": {
      "type": "object",
      "required": ["assetId", "path", "contentHash", "role", "visibilityIntent", "subjectId", "identityBearingFaceCount"],
      "additionalProperties": false,
      "properties": {
        "assetId": { "type": "string", "minLength": 1 },
        "path": { "type": "string", "minLength": 1 },
        "contentHash": { "$ref": "#/definitions/Sha256" },
        "role": { "enum": ["identity_face", "body_front_headless", "body_back_headless", "wardrobe", "silhouette", "environment", "lighting", "prop", "vehicle", "component", "start_state", "end_state", "motion_donor", "voice_track"] },
        "mediaKind": { "enum": ["image", "video", "audio"] },
        "visibilityIntent": { "enum": ["visible_subject", "visible_environment", "lighting_only", "offscreen_context", "start_state", "end_state", "component_detail"] },
        "subjectId": { "type": "string", "minLength": 1 },
        "characterVersionId": { "type": "string", "minLength": 1 },
        "identityBearingFaceCount": { "enum": [0, 1] },
        "identityVariant": { "enum": ["canonical", "profile", "expression", "injury"] },
        "state": {
          "type": "object",
          "required": ["group", "value"],
          "additionalProperties": false,
          "properties": {
            "group": { "type": "string", "minLength": 1 },
            "value": { "type": "string", "minLength": 1 }
          }
        }
      }
    },
    "MechanicalTransition": {
      "type": "object",
      "required": ["subjectId", "stateGroup", "startValue", "endValue", "trigger", "direction", "orderedSteps", "interaction", "startSeconds", "endSeconds"],
      "additionalProperties": false,
      "properties": {
        "subjectId": { "type": "string", "minLength": 1 },
        "stateGroup": { "type": "string", "minLength": 1 },
        "startValue": { "type": "string", "minLength": 1 },
        "endValue": { "type": "string", "minLength": 1 },
        "trigger": { "type": "string", "minLength": 1 },
        "direction": { "type": "string", "minLength": 1 },
        "orderedSteps": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
        "interaction": { "type": "string", "minLength": 1 },
        "startSeconds": { "type": "number", "minimum": 0 },
        "endSeconds": { "type": "number", "minimum": 0 }
      }
    }
  }
}
