{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "assemble-report",
  "description": "Per-project report from `vclaw video assemble` — manifest of generated assets + final stitched output.",
  "type": "object",
  "required": ["projectSlug", "generatedAt", "status", "manifest"],
  "properties": {
    "projectSlug": { "type": "string" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "status": { "type": "string", "enum": ["complete", "partial", "dry-run", "failed"] },
    "brandProfile": { "type": ["string", "null"], "description": "Path to the brand-profile.json used for this run." },
    "outputPath": { "type": "string", "description": "Path to the final stitched MP4." },
    "manifest": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["kind", "path", "durationMs", "sizeBytes", "generator"],
        "properties": {
          "kind": { "type": "string", "enum": ["narration", "music", "title-card", "slide-animation", "rendered-clip", "final-video"] },
          "path": { "type": "string" },
          "durationMs": { "type": "number" },
          "sceneIndex": { "type": "integer" },
          "sizeBytes": { "type": "integer" },
          "generator": { "type": "string", "description": "Which assemble/*.ts module produced this entry." }
        }
      }
    },
    "warnings": { "type": "array", "items": { "type": "string" } },
    "events": { "type": "array", "items": { "type": "string" } },
    "qc": {
      "type": "object",
      "description": "Structured media-quality audit over assembled scene clips and final master.",
      "required": ["status", "clips", "issues"],
      "properties": {
        "status": { "type": "string", "enum": ["pass", "warning", "fail", "skipped"] },
        "clips": {
          "type": "array",
          "items": { "$ref": "#/definitions/qcClip" }
        },
        "master": { "$ref": "#/definitions/qcMaster" },
        "issues": {
          "type": "array",
          "items": { "$ref": "#/definitions/qcIssue" }
        }
      }
    }
  },
  "definitions": {
    "mediaProbe": {
      "type": "object",
      "properties": {
        "durationSeconds": { "type": "number" },
        "sizeBytes": { "type": "number" },
        "videoCodec": { "type": "string" },
        "width": { "type": "number" },
        "height": { "type": "number" },
        "frameRate": { "type": "string" },
        "audioPresent": { "type": "boolean" },
        "audioCodec": { "type": "string" },
        "audioSampleRate": { "type": "number" },
        "audioChannels": { "type": "number" }
      }
    },
    "qcIssue": {
      "type": "object",
      "required": ["severity", "code", "scope", "message"],
      "properties": {
        "severity": { "type": "string", "enum": ["warning", "error"] },
        "code": {
          "type": "string",
          "enum": [
            "probe-failed",
            "missing-audio",
            "nonstandard-audio-codec",
            "nonstandard-audio-sample-rate",
            "nonstandard-video-codec",
            "duration-drift"
          ]
        },
        "scope": { "type": "string" },
        "message": { "type": "string" }
      }
    },
    "qcClip": {
      "type": "object",
      "required": ["path", "status", "issues"],
      "properties": {
        "path": { "type": "string" },
        "sceneIndex": { "type": "integer" },
        "status": { "type": "string", "enum": ["pass", "warning", "fail"] },
        "durationMs": { "type": "number" },
        "probe": { "$ref": "#/definitions/mediaProbe" },
        "issues": {
          "type": "array",
          "items": { "$ref": "#/definitions/qcIssue" }
        }
      }
    },
    "qcMaster": {
      "type": "object",
      "required": ["path", "status", "issues"],
      "properties": {
        "path": { "type": "string" },
        "status": { "type": "string", "enum": ["pass", "warning", "fail"] },
        "durationMs": { "type": "number" },
        "expectedDurationMs": { "type": "number" },
        "driftMs": { "type": "number" },
        "probe": { "$ref": "#/definitions/mediaProbe" },
        "issues": {
          "type": "array",
          "items": { "$ref": "#/definitions/qcIssue" }
        }
      }
    }
  }
}
