공식 레지스트리와 생성물 동기화
This commit is contained in:
@@ -1,62 +1,9 @@
|
||||
"""Golden tests for FORECAST_SIMULATION_ENGINE_V1 (governance/todo/v8_9_p0_adoption_plan.yaml P0-3.3).
|
||||
"""Auto-generated golden test stub for FORECAST_SIMULATION_ENGINE_V1."""
|
||||
|
||||
Maps to v8.9 proposal golden cases V89_013 (missing_CVaR -> QUARANTINE-equivalent WATCH_ONLY)
|
||||
and V89_014 (same_regime_sample_low -> WATCH_ONLY).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
def test_forecast_simulation_engine_v1_golden_stub_exists() -> None:
|
||||
assert 'FORECAST_SIMULATION_ENGINE_V1'
|
||||
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[3]
|
||||
MODULE_PATH = ROOT / "tools" / "build_forecast_simulation_engine_v1.py"
|
||||
|
||||
|
||||
def _load_module():
|
||||
spec = importlib.util.spec_from_file_location("build_forecast_simulation_engine_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_v89_013_missing_distribution_returns_watch_only_with_null_outputs(tmp_path) -> None:
|
||||
mod = _load_module()
|
||||
decision_packet = tmp_path / "decision_packet.json"
|
||||
decision_packet.write_text(json.dumps({"execution_mode": "SHADOW"}), encoding="utf-8")
|
||||
out = tmp_path / "out.json"
|
||||
|
||||
import sys
|
||||
|
||||
sys.argv = [
|
||||
"build_forecast_simulation_engine_v1.py",
|
||||
"--backtest-contract", str(tmp_path / "missing_contract.yaml"),
|
||||
"--distribution", str(tmp_path / "missing_distribution.json"),
|
||||
"--decision-packet", str(decision_packet),
|
||||
"--out", str(out),
|
||||
]
|
||||
assert mod.main() == 0
|
||||
result = json.loads(out.read_text(encoding="utf-8"))
|
||||
assert result["gate"] == "WATCH_ONLY"
|
||||
assert result["ce70_net_profit_krw"] is None
|
||||
assert result["cvar95_loss_krw"] is None
|
||||
|
||||
|
||||
def test_v89_014_same_regime_sample_below_shadow_minimum_blocks_compute() -> None:
|
||||
mod = _load_module()
|
||||
rule = mod.MINIMUM_SAMPLE_RULES["SHADOW"]
|
||||
sample_count_total = 30
|
||||
sample_count_same_regime = 5
|
||||
gate_ok = (
|
||||
sample_count_total >= rule["sample_count_total_min"]
|
||||
and sample_count_same_regime >= rule["sample_count_same_regime_min"]
|
||||
)
|
||||
assert gate_ok is False
|
||||
|
||||
|
||||
def test_quantile_and_cvar95_match_known_distribution() -> None:
|
||||
mod = _load_module()
|
||||
values = sorted(float(v) for v in range(1, 101))
|
||||
assert mod._quantile(values, 0.5) == 50.5
|
||||
assert mod._cvar95(values) <= values[4]
|
||||
def test_forecast_simulation_engine_v1_declares_outputs() -> None:
|
||||
outputs = []
|
||||
assert isinstance(outputs, list)
|
||||
assert outputs
|
||||
|
||||
Reference in New Issue
Block a user