{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://videoclaw.dev/schemas/video/artifacts/run-contract.schema.json",
  "title": "Run Contract",
  "description": "Per-scene snapshot of the EXACT resolved submit payload at produce/execute time. The frozen baseline the live run dashboard diffs the current contract against to catch @tag-hijack-the-references drift. Written by src/video/run-status.ts writeRunContract(); read by the preview-portal run surface.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "projectSlug", "routeId", "runId", "recordedAt", "executionProfile", "scenes"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "projectSlug": { "type": "string", "minLength": 1 },
    "routeId": { "type": "string", "minLength": 1 },
    "runId": { "type": "string", "minLength": 1 },
    "recordedAt": { "type": "string", "format": "date-time" },
    "executionProfile": {
      "type": "object",
      "additionalProperties": false,
      "required": ["aspectRatio", "quality", "resolution", "generateAudio", "outputCount"],
      "properties": {
        "aspectRatio": { "type": "string", "enum": ["16:9", "9:16", "1:1"] },
        "quality": { "type": "string", "enum": ["fast", "quality"] },
        "resolution": { "type": "string", "enum": ["720p", "1080p"] },
        "generateAudio": { "type": "boolean" },
        "outputCount": { "type": "integer", "minimum": 1 },
        "veoModel": { "type": "string", "enum": ["fast", "quality", "lite", "free", "omni-flash"] }
      }
    },
    "scenes": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sceneIndex",
          "candidateId",
          "externalJobId",
          "submittedAt",
          "submittedPrompt",
          "submittedReferencePaths",
          "submittedInputKind",
          "submittedCharacters",
          "contractHash"
        ],
        "properties": {
          "sceneIndex": { "type": "integer", "minimum": 0 },
          "candidateId": { "type": ["string", "null"] },
          "externalJobId": { "type": ["string", "null"] },
          "submittedAt": { "type": "string", "format": "date-time" },
          "submittedPrompt": { "type": "string" },
          "submittedReferencePaths": { "type": "array", "items": { "type": "string" } },
          "submittedReferenceRole": { "type": "string", "enum": ["character", "keyframe"] },
          "submittedInputKind": { "type": "string", "enum": ["text", "image", "video"] },
          "submittedDurationSeconds": { "type": "number" },
          "submittedCharacters": { "type": "array", "items": { "type": "string" } },
          "submittedChainedFromCandidateId": { "type": "string" },
          "contractHash": { "type": "string", "minLength": 1 }
        }
      }
    }
  }
}
