{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tunx.ai/guides/video-reverse-prompt-engineering/reverse-shotspec.schema.json",
  "title": "ReverseShotSpec 1.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "org_id", "job_id", "source", "analysis", "global", "shots", "reproduction", "evidence", "uncertainties", "provenance"],
  "properties": {
    "schema_version": {"enum": ["1.0.0", "1.1.0"]},
    "org_id": {"type": "string", "minLength": 1},
    "job_id": {"type": "string", "minLength": 1},
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sha256", "mime_type", "bytes", "duration_seconds", "width", "height", "fps", "has_audio", "rights_status", "contains_people"],
      "properties": {
        "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
        "mime_type": {"type": "string"},
        "bytes": {"type": "integer", "minimum": 1},
        "duration_seconds": {"type": "number", "exclusiveMinimum": 0},
        "width": {"type": "integer", "minimum": 1},
        "height": {"type": "integer", "minimum": 1},
        "fps": {"type": "number", "exclusiveMinimum": 0},
        "has_audio": {"type": "boolean"},
        "rights_status": {"enum": ["owned", "licensed", "consented", "public_domain"]},
        "contains_people": {"type": "boolean"},
        "consent_record_id": {"type": "string"},
        "source_type": {"enum": ["upload", "url"]},
        "source_locator_redacted": {"type": "string", "maxLength": 700},
        "remote_provider": {"type": "string", "maxLength": 80}
      }
    },
    "analysis": {
      "type": "object",
      "required": ["profile_id", "model", "level", "sampling", "limitations"],
      "properties": {
        "profile_id": {"type": "string"},
        "model": {"type": "string"},
        "level": {"enum": ["metadata_only", "frame_ensemble", "native_video", "forensic_hybrid"]},
        "sampling": {"type": "object"},
        "limitations": {"type": "array", "items": {"type": "string"}}
      }
    },
    "global": {
      "type": "object",
      "required": ["objective", "format", "visual_language", "continuity", "audio_language"],
      "properties": {
        "objective": {"$ref": "#/$defs/inference"},
        "format": {"$ref": "#/$defs/inference"},
        "visual_language": {"$ref": "#/$defs/inference"},
        "continuity": {"type": "array", "items": {"$ref": "#/$defs/inference"}},
        "audio_language": {"$ref": "#/$defs/inference"}
      }
    },
    "shots": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["index", "start_seconds", "end_seconds", "visual", "motion", "camera", "lighting", "timeline", "audio", "references", "confidence"],
        "properties": {
          "index": {"type": "integer", "minimum": 1},
          "start_seconds": {"type": "number", "minimum": 0},
          "end_seconds": {"type": "number", "exclusiveMinimum": 0},
          "visual": {
            "type": "object",
            "properties": {
              "subject": {"$ref": "#/$defs/inference"},
              "scene": {"$ref": "#/$defs/inference"},
              "composition": {"$ref": "#/$defs/inference"},
              "style_medium": {"$ref": "#/$defs/inference"},
              "palette": {"$ref": "#/$defs/inference"},
              "materials": {"$ref": "#/$defs/inference"},
              "visible_text": {"type": "array", "items": {"$ref": "#/$defs/inference"}}
            }
          },
          "motion": {
            "type": "object",
            "properties": {
              "subject_action": {"$ref": "#/$defs/inference"},
              "environment_motion": {"$ref": "#/$defs/inference"},
              "direction_speed_easing": {"$ref": "#/$defs/inference"},
              "interactions_physics": {"$ref": "#/$defs/inference"},
              "trajectories": {"type": "array", "items": {"$ref": "#/$defs/inference"}}
            }
          },
          "camera": {
            "type": "object",
            "properties": {
              "shot_size": {"$ref": "#/$defs/inference"},
              "angle": {"$ref": "#/$defs/inference"},
              "movement": {"$ref": "#/$defs/inference"},
              "lens_estimate": {"$ref": "#/$defs/inference"},
              "focus_depth": {"$ref": "#/$defs/inference"},
              "shutter_motion_blur": {"$ref": "#/$defs/inference"},
              "pose_path": {"type": "array", "items": {"$ref": "#/$defs/inference"}}
            }
          },
          "lighting": {
            "type": "object",
            "properties": {
              "key_fill_rim": {"$ref": "#/$defs/inference"},
              "quality_direction": {"$ref": "#/$defs/inference"},
              "color_temperature": {"$ref": "#/$defs/inference"},
              "contrast_grade": {"$ref": "#/$defs/inference"},
              "atmosphere": {"$ref": "#/$defs/inference"}
            }
          },
          "timeline": {"type": "array", "items": {"$ref": "#/$defs/beat"}},
          "audio": {
            "type": "object",
            "properties": {
              "dialogue": {"type": "array", "items": {"$ref": "#/$defs/audioEvent"}},
              "sound_effects": {"type": "array", "items": {"$ref": "#/$defs/audioEvent"}},
              "ambience": {"$ref": "#/$defs/inference"},
              "music": {"$ref": "#/$defs/inference"},
              "sync_events": {"type": "array", "items": {"$ref": "#/$defs/audioEvent"}}
            }
          },
          "references": {"type": "array", "items": {"$ref": "#/$defs/reference"}},
          "negative_constraints": {"type": "array", "items": {"type": "string"}},
          "confidence": {"type": "number", "minimum": 0, "maximum": 1}
        }
      }
    },
    "reproduction": {
      "type": "object",
      "required": ["recommended_mode", "fidelity_tier", "target_adapter_id", "compiled_shots"],
      "properties": {
        "recommended_mode": {"type": "string"},
        "fidelity_tier": {"enum": ["text_only", "prompt_plus_frames", "prompt_plus_motion_reference", "model_specific_inversion"]},
        "target_adapter_id": {"type": "string"},
        "compiled_shots": {"type": "array", "items": {"type": "object"}},
        "assembly_notes": {"type": "array", "items": {"type": "string"}}
      }
    },
    "evidence": {"type": "array", "items": {"$ref": "#/$defs/evidence"}},
    "uncertainties": {"type": "array", "items": {"$ref": "#/$defs/uncertainty"}},
    "provenance": {"type": "object"}
  },
  "$defs": {
    "inference": {
      "type": "object",
      "required": ["value", "kind", "confidence", "evidence_ids"],
      "properties": {
        "value": {},
        "kind": {"enum": ["observed", "measured", "inferred", "user_supplied", "unknown"]},
        "confidence": {"type": "number", "minimum": 0, "maximum": 1},
        "evidence_ids": {"type": "array", "items": {"type": "string"}},
        "alternatives": {"type": "array", "items": {"type": "string"}}
      }
    },
    "beat": {
      "type": "object",
      "required": ["start_seconds", "end_seconds", "action", "evidence_ids"],
      "properties": {
        "start_seconds": {"type": "number", "minimum": 0},
        "end_seconds": {"type": "number", "exclusiveMinimum": 0},
        "action": {"type": "string"},
        "camera": {"type": "string"},
        "audio": {"type": "string"},
        "evidence_ids": {"type": "array", "items": {"type": "string"}}
      }
    },
    "audioEvent": {
      "type": "object",
      "required": ["start_seconds", "end_seconds", "content", "confidence"],
      "properties": {
        "start_seconds": {"type": "number", "minimum": 0},
        "end_seconds": {"type": "number", "minimum": 0},
        "speaker": {"type": "string"},
        "content": {"type": "string"},
        "confidence": {"type": "number", "minimum": 0, "maximum": 1}
      }
    },
    "reference": {
      "type": "object",
      "required": ["artifact_id", "role", "time_seconds", "rights_status"],
      "properties": {
        "artifact_id": {"type": "string"},
        "role": {"enum": ["identity", "style", "composition", "first_frame", "last_frame", "motion", "camera", "audio"]},
        "time_seconds": {"type": "number", "minimum": 0},
        "rights_status": {"enum": ["owned", "licensed", "consented", "public_domain"]}
      }
    },
    "evidence": {
      "type": "object",
      "required": ["id", "kind", "time_seconds", "artifact_id"],
      "properties": {
        "id": {"type": "string"},
        "kind": {"enum": ["metadata", "frame", "audio", "track", "mask", "depth", "camera", "ocr", "transcript"]},
        "time_seconds": {"type": "number", "minimum": 0},
        "artifact_id": {"type": "string"},
        "region": {"type": "array", "items": {"type": "number"}, "minItems": 4, "maxItems": 4}
      }
    },
    "uncertainty": {
      "type": "object",
      "required": ["field", "reason", "impact", "resolution"],
      "properties": {
        "field": {"type": "string"},
        "reason": {"type": "string"},
        "impact": {"enum": ["low", "medium", "high", "blocking"]},
        "resolution": {"type": "string"}
      }
    }
  }
}
