RULE_WEIGHTS = {
    "blocklist_hit": 40,
    "bad_ua": 20,
    "high_velocity": 15,
    "duplicate": 15,
    "geo_mismatch": 10
}


def calculate_rule_score(features):
    score = 0
    contributing_features = []

    for feature, weight in RULE_WEIGHTS.items():
        if features.get(feature, False):
            score += weight
            contributing_features.append(feature)

    score = min(score, 100)

    return score, contributing_features
