From a178a15e4e35c6968d4014735e10a8472188aa7a Mon Sep 17 00:00:00 2001 From: YYF Date: Thu, 3 Dec 2026 12:08:27 -0800 Subject: [PATCH] Fail closed on missing dialogue golden for Whisper cold/hero gates --- assets/samples/README.md | 3 +++ tests/test_cold_machine_hero.py | 29 ++++++++++++++++----------- tests/test_dialogue_fixture_gate.py | 25 +++++++++++++++++++++++ tests/test_featured_real_inference.py | 15 ++++++++------ tests/test_hero_real_inference.py | 16 ++++++++------- 5 files changed, 63 insertions(+), 25 deletions(-) create mode 100644 tests/test_dialogue_fixture_gate.py diff --git a/assets/samples/README.md b/assets/samples/README.md index 1bfaaf2..6ad53a1 100644 --- a/assets/samples/README.md +++ b/assets/samples/README.md @@ -8,4 +8,7 @@ # - `Fort-Zeelandia.png` — LoadImage / image-conditioned GenerateVideo # - `automation_cc7.mid` — LoadMIDI / MIDIToFloat / MIDINoteGate Help examples # +# Cold/hero Whisper gates use tracked `tests/golden/fixtures/dialogue_48k.wav` +# (not this folder — `*.wav` is gitignored here except allowlisted demos). +# # `archived/` is local-only (gitignored). diff --git a/tests/test_cold_machine_hero.py b/tests/test_cold_machine_hero.py index 57c9b37..dd52638 100644 --- a/tests/test_cold_machine_hero.py +++ b/tests/test_cold_machine_hero.py @@ -7,9 +7,7 @@ import shutil from pathlib import Path -import numpy as np import pytest -import soundfile as sf from groovy.executor import Executor from groovy.nodes.ai import register_all as register_ai from groovy.nodes.ai.inference_env import whisper_available @@ -26,7 +24,9 @@ from template_fixtures import require_template PODCAST = require_template("podcast-denoise") DIALOGUE = require_template("transcribe-dialogue") -DIALOGUE_FIXTURE = ROOT / "assets" / "samples" / "dialogue_48k.wav" +# Tracked golden — assets/samples/*.wav is gitignored except allowlisted demos. +DIALOGUE_FIXTURE = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav" +PODCAST_SHIPPED = ROOT / "assets" / "samples" / "podcast_denoise_demo.wav" pytestmark = pytest.mark.integration @@ -39,13 +39,19 @@ def project_dir(tmp_path: Path) -> Path: if not shutil.which("uv"): pytest.skip("uv is required for Model Browser python_deps install") + assert DIALOGUE_FIXTURE.is_file(), ( + "Missing tests/golden/fixtures/dialogue_48k.wav — fail closed " + "(Whisper cold gate must not skip)" + ) + assert PODCAST_SHIPPED.is_file(), ( + "Missing assets/samples/podcast_denoise_demo.wav — cold podcast gate " + "must use shipped demo WAV" + ) + assets = tmp_path / "assets" / "samples" assets.mkdir(parents=True) - sr = 48_000 - t = np.linspace(0, 1.0, int(sr), endpoint=False) - sf.write(assets / "podcast_denoise_demo.wav", 0.25 * np.sin(2 * np.pi * 440 * t), sr) - if DIALOGUE_FIXTURE.is_file(): - shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav") + shutil.copy(PODCAST_SHIPPED, assets / "podcast_denoise_demo.wav") + shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav") return tmp_path @@ -99,14 +105,13 @@ def test_whisper_install_from_model_browser(project_dir: Path) -> None: def test_transcribe_dialogue_cold_machine_gate(project_dir: Path) -> None: - if not (project_dir / "assets" / "samples" / "dialogue_48k.wav").is_file(): - pytest.skip("dialogue_48k.wav fixture missing from assets/samples") + dialogue = project_dir / "assets" / "samples" / "dialogue_48k.wav" + assert dialogue.is_file(), "dialogue_48k.wav must be staged from golden fixtures" registry = ModelRegistry(project_dir) install = registry.installer.install("whisper-large-v3-turbo") assert install.status == "ready", install.error - if not whisper_available(): - pytest.skip("faster_whisper unavailable after install") + assert whisper_available(), "faster_whisper unavailable after Model Browser install" workflow = Workflow.model_validate(json.loads(DIALOGUE.read_text())) for node in workflow.nodes: diff --git a/tests/test_dialogue_fixture_gate.py b/tests/test_dialogue_fixture_gate.py new file mode 100644 index 0000000..27b92f0 --- /dev/null +++ b/tests/test_dialogue_fixture_gate.py @@ -0,0 +1,25 @@ +"""Fail-closed gate: dialogue fixture must be present for cold/hero Whisper paths.""" + +from __future__ import annotations + +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +DIALOGUE_GOLDEN = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav" +PODCAST_SHIPPED = ROOT / "assets" / "samples" / "podcast_denoise_demo.wav" + + +def test_dialogue_golden_fixture_present() -> None: + assert DIALOGUE_GOLDEN.is_file(), ( + "Missing tests/golden/fixtures/dialogue_48k.wav — cold/hero Whisper gates " + "must fail closed (do not skip). Restore the tracked golden fixture." + ) + assert DIALOGUE_GOLDEN.stat().st_size > 1_000 + + +def test_podcast_denoise_demo_shipped() -> None: + assert PODCAST_SHIPPED.is_file(), ( + "Missing assets/samples/podcast_denoise_demo.wav — cold podcast gate " + "must use the shipped demo WAV (git allowlisted), not a synthetic tone." + ) + assert PODCAST_SHIPPED.stat().st_size > 1_000 diff --git a/tests/test_featured_real_inference.py b/tests/test_featured_real_inference.py index b1ca6ba..b1edbd2 100644 --- a/tests/test_featured_real_inference.py +++ b/tests/test_featured_real_inference.py @@ -33,7 +33,7 @@ ROOT = Path(__file__).resolve().parents[1] from template_fixtures import require_template -DIALOGUE_FIXTURE = ROOT / "assets" / "samples" / "dialogue_48k.wav" +DIALOGUE_FIXTURE = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav" FEATURED = [ "podcast-denoise", @@ -87,8 +87,11 @@ def project_dir(tmp_path: Path) -> Path: noise = 0.02 * np.random.default_rng(0).standard_normal(t.size) sf.write(assets / "podcast_denoise_demo.wav", tone + noise, sr) sf.write(assets / "Knockout_41k_mono.wav", tone + noise, sr) - if DIALOGUE_FIXTURE.is_file(): - shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav") + assert DIALOGUE_FIXTURE.is_file(), ( + "Missing tests/golden/fixtures/dialogue_48k.wav — fail closed " + "(featured Whisper templates must not fall back silently)" + ) + shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav") return tmp_path @@ -120,9 +123,9 @@ def test_featured_template_real_inference(project_dir: Path, template_id: str) - sample = "assets/samples/podcast_denoise_demo.wav" if template_id == "stem-separation": sample = "assets/samples/Knockout_41k_mono.wav" - if template_id in {"transcribe-dialogue", "transcribe-and-diarize"} and ( - project_dir / "assets" / "samples" / "dialogue_48k.wav" - ).is_file(): + if template_id in {"transcribe-dialogue", "transcribe-and-diarize"}: + dialogue = project_dir / "assets" / "samples" / "dialogue_48k.wav" + assert dialogue.is_file(), "dialogue_48k.wav must be staged from golden fixtures" sample = "assets/samples/dialogue_48k.wav" if template_id in {"text-to-music", "hello-groovy"}: sample = None diff --git a/tests/test_hero_real_inference.py b/tests/test_hero_real_inference.py index 50b9e7e..89e2e13 100644 --- a/tests/test_hero_real_inference.py +++ b/tests/test_hero_real_inference.py @@ -35,7 +35,7 @@ PODCAST = require_template("podcast-denoise") STEMS = require_template("stem-separation") DIALOGUE = require_template("transcribe-dialogue") -DIALOGUE_FIXTURE = ROOT / "assets" / "samples" / "dialogue_48k.wav" +DIALOGUE_FIXTURE = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav" # EXECUTOR_SPEC: Demucs verify SNR ≥ 40 dB. Short synthetic tones are looser. DEMUCS_RECONSTRUCTION_SNR_DB = 20.0 @@ -74,8 +74,11 @@ def project_dir(tmp_path: Path) -> Path: noise = 0.02 * np.random.default_rng(0).standard_normal(t.size) sf.write(assets / "podcast_denoise_demo.wav", tone + noise, sr) sf.write(assets / "Knockout_41k_mono.wav", tone + noise, sr) - if DIALOGUE_FIXTURE.is_file(): - shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav") + assert DIALOGUE_FIXTURE.is_file(), ( + "Missing tests/golden/fixtures/dialogue_48k.wav — fail closed " + "(Whisper hero gate must not skip)" + ) + shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav") return tmp_path @@ -216,12 +219,11 @@ def test_stem_split_vocals_real_inference_tolerance(project_dir: Path) -> None: def test_transcribe_dialogue_real_inference_tolerance(project_dir: Path) -> None: - if not (project_dir / "assets" / "samples" / "dialogue_48k.wav").is_file(): - pytest.skip("dialogue_48k.wav fixture missing from assets/samples") + dialogue = project_dir / "assets" / "samples" / "dialogue_48k.wav" + assert dialogue.is_file(), "dialogue_48k.wav must be staged from golden fixtures" _ensure_model(project_dir, "whisper-large-v3-turbo") - if not whisper_available(): - pytest.skip("faster_whisper unavailable after install") + assert whisper_available(), "faster_whisper unavailable after Model Browser install" workflow = _load_template(DIALOGUE, sample="assets/samples/dialogue_48k.wav") executor = Executor(project_dir)