"""Smoke test for the score-coherence filter using the LAFC vs Sounders
1-0 scenario from production. Verifies that markets that contradict the
predicted score are correctly excluded from the coherent set, and that
the markets the model got right are all included.
"""
import os, sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from services.betting_brain import BettingBrain

brain = BettingBrain()
pkg = {
    "score_prediction": {"ft": "1-0", "ht": "0-0"},
}
coh = brain._score_consistent_markets(pkg)
print(f"Predicted: 1-0 (HT 0-0)")
print(f"Coherent set size: {len(coh)}")
print()

# Each pick the system actually offered for the LAFC match, with whether
# it was the *actual* winning pick.
test_picks = [
    ("MS", "1",        True,  "correct"),
    ("MS", "2",        False, "wrong"),
    ("MS", "X",        False, "wrong"),
    ("DC", "1X",       True,  "correct"),
    ("DC", "12",       True,  "correct"),
    ("DC", "X2",       False, "wrong"),
    ("OU25", "Üst",    False, "WRONG — system featured this"),
    ("OU25", "Alt",    True,  "correct"),
    ("OU35", "Alt",    True,  "correct"),
    ("OU35", "Üst",    False, "wrong"),
    ("BTTS", "Var",    False, "wrong"),
    ("BTTS", "Yok",    True,  "correct"),
    ("HT", "X",        True,  "correct"),
    ("HT", "1",        False, "wrong"),
    ("HTFT", "X/1",    True,  "correct"),
    ("HTFT", "1/1",    False, "wrong (HT was 0-0)"),
    ("HT_OU05", "Üst", False, "wrong"),
    ("HT_OU05", "Alt", True,  "correct"),
    ("OE", "Çift",     False, "wrong (1 is odd)"),
    ("OE", "Tek",      True,  "correct"),
]

print(f"{'market':<10}{'pick':<10}{'real-win?':<12}{'in-coherent?':<14}{'match?'}")
print("-" * 60)
ok = 0
for market, pick, would_win, note in test_picks:
    in_coh = (market, pick) in coh
    match = "✓" if in_coh == would_win else "✗ MISMATCH"
    if in_coh == would_win: ok += 1
    print(f"{market:<10}{pick:<10}{str(would_win):<12}{str(in_coh):<14}{match}  {note}")

print()
print(f"Result: {ok}/{len(test_picks)} picks correctly classified")
