import json

from m3m_disease.demo import generate_records, generate_synthetic_fixture, run_demo


def test_fixed_seed_fixture_is_deterministic(tmp_path):
    first = generate_synthetic_fixture(tmp_path / "first", seed=99)
    second = generate_synthetic_fixture(tmp_path / "second", seed=99)
    first_records = generate_records(first)
    second_records = generate_records(second)
    assert first_records == second_records
    assert {row["data_provenance"] for row in first_records} == {"synthetic"}
    assert {row["label_reference"] for row in first_records} == {"synthetic_latent_truth"}


def test_end_to_end_demo_never_claims_field_performance(tmp_path):
    result = run_demo(tmp_path / "demo", seed=20260804)
    assert result["status"] == "PASSED"
    assert result["modelPromotionStatus"] == "RESEARCH_ONLY"
    assert result["fieldFlightExecuted"] is False
    assert result["fieldDataCollected"] is False
    assert result["fieldPerformanceEstablished"] is False
    card = json.loads((tmp_path / "demo" / "artifacts" / "model-card.json").read_text(encoding="utf-8"))
    assert card["fieldPerformanceEstablished"] is False
    assert card["evaluation"]["engineeringSyntheticOnly"] is True
