{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://vclaw.dev/schemas/video/artifacts/consistency-audit.schema.json",
  "title": "ConsistencyAuditReport",
  "description": "Automated character identity/costume consistency vision audit of a project's rendered scenes. Written by `vclaw video consistency-audit` to artifacts/consistency-audit.json.",
  "type": "object",
  "required": ["projectSlug", "ok", "generatedAt", "scenes", "findings"],
  "additionalProperties": false,
  "properties": {
    "projectSlug": { "type": "string", "minLength": 1 },
    "ok": {
      "type": "boolean",
      "description": "False when any checked character mismatches its reference OR any checked frame has a border OR any scene has appearing-elements / anatomy issues."
    },
    "generatedAt": { "type": "string", "format": "date-time" },
    "scenes": {
      "type": "array",
      "items": { "$ref": "#/definitions/SceneResult" }
    },
    "findings": {
      "type": "array",
      "description": "Flat operator-facing list of every problem found (drift + border + extra-figure + appearing-element + anatomy).",
      "items": { "type": "string" }
    }
  },
  "definitions": {
    "SceneResult": {
      "type": "object",
      "required": [
        "sceneIndex",
        "frameChecked",
        "characters",
        "borderDetected",
        "extraFigureSuspected",
        "appearingElements",
        "anatomyIssues",
        "framesSampled"
      ],
      "additionalProperties": false,
      "properties": {
        "sceneIndex": { "type": "integer", "minimum": 0 },
        "frameChecked": {
          "type": "boolean",
          "description": "True when a representative frame was actually extracted and assessed."
        },
        "characters": {
          "type": "array",
          "items": { "$ref": "#/definitions/CharacterResult" }
        },
        "borderDetected": { "type": "boolean" },
        "extraFigureSuspected": { "type": "boolean" },
        "appearingElements": {
          "type": "array",
          "description": "Elements that materialized mid-clip and were NOT in the scene keyframe, deduped across sampled frames and each tagged with the approx frame fraction (e.g. \"t≈0.6: floating garland\").",
          "items": { "type": "string" }
        },
        "anatomyIssues": {
          "type": "array",
          "description": "Anatomy/duplication errors (third hand, extra limb, duplicated person), deduped across sampled frames and each tagged with the approx frame fraction (e.g. \"t≈0.4: third hand on the figure\").",
          "items": { "type": "string" }
        },
        "framesSampled": {
          "type": "integer",
          "minimum": 0,
          "description": "Number of frames sampled across the clip for mid-clip inspection (0 when no keyframe was bound / the scene was not a video)."
        }
      }
    },
    "CharacterResult": {
      "type": "object",
      "required": ["name", "match", "issues"],
      "additionalProperties": false,
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "match": { "type": "boolean" },
        "issues": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    }
  }
}
