"""Golden tests for BREAKOUT_FAILURE_STOP_V1 (governance/todo/technical_signals_p4_adoption_plan.yaml P4-6).""" from __future__ import annotations import importlib.util from pathlib import Path ROOT = Path(__file__).resolve().parents[3] MODULE_PATH = ROOT / "tools" / "build_breakout_failure_stop_v1.py" def _load_module(): spec = importlib.util.spec_from_file_location("build_breakout_failure_stop_v1", MODULE_PATH) module = importlib.util.module_from_spec(spec) assert spec.loader is not None spec.loader.exec_module(module) return module def test_reentry_below_prior_high_within_window_triggers_sell_review() -> None: mod = _load_module() result = mod.evaluate(100, 95, 3) assert result["breakout_failure"] is True assert result["gate"] == "SELL_RISK_EXIT_REVIEW" def test_reentry_after_window_does_not_trigger() -> None: mod = _load_module() result = mod.evaluate(100, 95, 10) assert result["breakout_failure"] is False def test_missing_prior_high_returns_null() -> None: mod = _load_module() result = mod.evaluate(None, 95, 3) assert result["breakout_failure"] is None