{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kelyvo.life/schemas/kelyvo-audio-gold-v1.schema.json",
  "title": "KELYVO Audio & Music Intelligence Delivery Schema (kelyvo-audio-gold-v1)",
  "description": "Machine-validatable contract for KELYVO Gold Standard Audio & Music RLHF, Structural Segmentation, and Mix QA deliveries.",
  "type": "object",
  "required": ["dataset_metadata", "tracks"],
  "additionalProperties": false,
  "properties": {
    "dataset_metadata": {
      "type": "object",
      "required": [
        "name",
        "version",
        "schema",
        "vendor",
        "website",
        "contact",
        "generated_at_utc",
        "track_count",
        "total_temporal_sections",
        "qa_workflow",
        "ip_and_licensing",
        "privacy_and_anonymization"
      ],
      "properties": {
        "name": { "type": "string" },
        "version": { "type": "string" },
        "schema": { "const": "kelyvo-audio-gold-v1" },
        "schema_file": { "type": "string" },
        "vendor": { "type": "string" },
        "website": { "type": "string", "format": "uri" },
        "showcase_url": { "type": "string", "format": "uri" },
        "contact": { "type": "string", "format": "email" },
        "generated_at_utc": { "type": "string", "format": "date-time" },
        "track_count": { "type": "integer", "minimum": 1 },
        "total_temporal_sections": { "type": "integer", "minimum": 1 },
        "qa_workflow": { "type": "string" },
        "iaa_and_calibration_targets": { "type": "object" },
        "audio_delivery_note": { "type": "string" },
        "ip_and_licensing": { "type": "string" },
        "privacy_and_anonymization": { "type": "string" }
      }
    },
    "tracks": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/track" }
    }
  },
  "$defs": {
    "track": {
      "type": "object",
      "required": [
        "sample_id",
        "title",
        "artist",
        "audio_file",
        "audio_sha256",
        "duration_sec",
        "sample_rate_hz",
        "channels",
        "clip_type",
        "showcase_focus",
        "qa_verification",
        "audio_technical_specs",
        "musical_metadata",
        "mix_qa_scorecard",
        "lyrics",
        "executive_producer_caption",
        "temporal_sections"
      ],
      "properties": {
        "sample_id": { "type": "string", "pattern": "^KLY-AUD-[0-9]{3,}$" },
        "title": { "type": "string", "minLength": 1 },
        "artist": { "type": "string", "minLength": 1 },
        "audio_file": { "type": "string", "pattern": "^audio/.+\\.(mp3|m4a|wav|flac)$" },
        "audio_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "duration_sec": { "type": "number", "exclusiveMinimum": 0 },
        "sample_rate_hz": { "type": "integer", "enum": [16000, 22050, 24000, 44100, 48000, 96000] },
        "channels": { "type": "integer", "minimum": 1, "maximum": 8 },
        "clip_type": { "type": "string", "enum": ["full_song", "excerpt_50s", "excerpt", "stem", "speech_clip"] },
        "showcase_focus": { "type": "string", "minLength": 10 },
        "qa_verification": {
          "type": "object",
          "required": ["status", "pipeline"],
          "properties": {
            "status": { "type": "string", "enum": ["PASSED_QA", "PASSED_LEAD_AUDIT"] },
            "pipeline": { "type": "string" }
          }
        },
        "audio_technical_specs": {
          "type": "object",
          "required": [
            "codec",
            "bitrate_kbps",
            "sample_rate_hz",
            "channels",
            "file_size_bytes",
            "peak_dbfs",
            "rms_dbfs",
            "crest_factor_db"
          ],
          "properties": {
            "codec": { "type": "string" },
            "bitrate_kbps": { "type": "integer", "minimum": 32 },
            "sample_rate_hz": { "type": "integer" },
            "channels": { "type": "integer" },
            "file_size_bytes": { "type": "integer", "minimum": 1 },
            "peak_dbfs": { "type": "number", "maximum": 0.5 },
            "rms_dbfs": { "type": "number", "maximum": 0.0 },
            "crest_factor_db": { "type": "number", "minimum": 0.0 }
          }
        },
        "musical_metadata": {
          "type": "object",
          "required": [
            "bpm",
            "key",
            "mode",
            "time_signature",
            "primary_language",
            "genres",
            "overall_moods",
            "overall_instruments"
          ],
          "properties": {
            "bpm": { "type": "number", "minimum": 20, "maximum": 300 },
            "key": { "type": "string" },
            "mode": { "type": "string" },
            "time_signature": { "type": "string", "pattern": "^[0-9]+/[0-9]+$" },
            "primary_language": { "type": "string" },
            "genres": { "type": "array", "minItems": 1, "items": { "type": "string" } },
            "overall_moods": { "type": "array", "minItems": 1, "items": { "type": "string" } },
            "overall_instruments": { "type": "array", "minItems": 1, "items": { "type": "string" } }
          }
        },
        "mix_qa_scorecard": {
          "type": "object",
          "required": [
            "scale",
            "mix_clarity",
            "frequency_balance",
            "vocal_intelligibility",
            "dynamic_range",
            "overall_production_quality",
            "composite_mean"
          ],
          "properties": {
            "scale": { "type": "string" },
            "mix_clarity": { "type": "integer", "minimum": 1, "maximum": 5 },
            "frequency_balance": { "type": "integer", "minimum": 1, "maximum": 5 },
            "vocal_intelligibility": { "type": "integer", "minimum": 1, "maximum": 5 },
            "dynamic_range": { "type": "integer", "minimum": 1, "maximum": 5 },
            "overall_production_quality": { "type": "integer", "minimum": 1, "maximum": 5 },
            "composite_mean": { "type": "number", "minimum": 1.0, "maximum": 5.0 }
          }
        },
        "lyrics": {
          "type": "object",
          "required": ["script", "original_script", "romanized_transliteration"],
          "properties": {
            "script": { "type": "string" },
            "original_script": { "type": "string" },
            "romanized_transliteration": { "type": "string" }
          }
        },
        "executive_producer_caption": { "type": "string", "minLength": 40 },
        "temporal_sections": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/temporal_section" }
        }
      }
    },
    "temporal_section": {
      "type": "object",
      "required": [
        "section_index",
        "label",
        "structural_role",
        "start_sec",
        "end_sec",
        "duration_sec",
        "active_instruments",
        "drum_rhythm_pattern",
        "emotions",
        "description"
      ],
      "properties": {
        "section_index": { "type": "integer", "minimum": 1 },
        "label": {
          "type": "string",
          "enum": [
            "Intro",
            "Verse",
            "Pre-Chorus",
            "Chorus / Hook",
            "Bridge",
            "Solo",
            "Breakdown",
            "Outro",
            "Artifact / Noise / Glitch"
          ]
        },
        "structural_role": { "type": "string", "minLength": 3 },
        "start_sec": { "type": "number", "minimum": 0 },
        "end_sec": { "type": "number", "exclusiveMinimum": 0 },
        "duration_sec": { "type": "number", "exclusiveMinimum": 0 },
        "active_instruments": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "drum_rhythm_pattern": { "type": "string", "minLength": 1 },
        "emotions": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "description": { "type": "string", "minLength": 15 }
      }
    }
  }
}
