Skip to content

Commit 44898a8

Browse files
committed
lower base when no mx found at all in independents
1 parent c76f4fd commit 44898a8

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/mail_sovereignty/classifier.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ def _rule_confidence(
8484
8585
Rule chain (ordered by specificity, first match wins):
8686
87+
```
88+
- MX only 80% (Most likely unfinished config)
89+
- MX + SPF 90% (Managed setup)
90+
- AD + SPF 90% (Security GW upfront)
91+
- MX + SPF + AD 95% (Cloud Setup)
92+
93+
AD Cases sind natürlich nur MS-relevant. Mit den restlichen Indikatoren könntest du bspw. dann die restlichen 5-10% auffüllen.  Die %-te kann man natürlich auch anders aufteilen.
94+
```
95+
96+
// messen wie viel Rule gebraucht wird, evtl R5-R8 nicht unbeding relevant
97+
98+
8799
==== ========================== ====
88100
Rule Condition Base
89101
==== ========================== ====
@@ -93,7 +105,7 @@ def _rule_confidence(
93105
R4 MX ∧ TENANT 0.85
94106
R5 SPF ∧ TENANT 0.80
95107
R6 SPF ∧ GW 0.70
96-
R7 MX 0.60
108+
R7 MX 0.60 // eher auf 80%
97109
R8 SPF 0.50
98110
R9 else 0.40
99111
==== ========================== ====
@@ -143,7 +155,7 @@ def _independent_confidence(
143155
144156
* MX + SPF present → 0.90
145157
* MX only → 0.60
146-
* Any evidence → 0.50
158+
* No MX, secondary evidence only → 0.20
147159
* Nothing → 0.0
148160
149161
After the base is selected, each distinct signal kind in *evidence*
@@ -158,7 +170,7 @@ def _independent_confidence(
158170
elif has_mx:
159171
base = 0.60
160172
elif evidence:
161-
base = 0.50
173+
base = 0.20
162174
else:
163175
return 0.0
164176

tests/test_classifier.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def test_tenant_alone_no_winner(self):
226226
]
227227
result = _aggregate(evidence)
228228
assert result.provider == Provider.INDEPENDENT
229-
# Evidence present but no MX → 0.50 base + 1 extra kind × 0.02
230-
assert result.confidence == pytest.approx(0.52)
229+
# No MX, secondary evidence only → 0.20 base + 1 extra kind × 0.02
230+
assert result.confidence == pytest.approx(0.22)
231231

232232
def test_tenant_with_primary(self):
233233
"""Tenant evidence with MX primary → MX+TENANT rule."""
@@ -281,8 +281,8 @@ def test_txt_verification_alone_no_winner(self):
281281
]
282282
result = _aggregate(evidence)
283283
assert result.provider == Provider.INDEPENDENT
284-
# Evidence present but no MX → 0.50 base + 1 extra kind × 0.02
285-
assert result.confidence == pytest.approx(0.52)
284+
# No MX, secondary evidence only → 0.20 base + 1 extra kind × 0.02
285+
assert result.confidence == pytest.approx(0.22)
286286

287287
def test_txt_verification_with_primary(self):
288288
"""TXT_VERIFICATION with primary signals boosts confidence."""
@@ -302,8 +302,8 @@ def test_asn_alone_no_winner(self):
302302
]
303303
result = _aggregate(evidence)
304304
assert result.provider == Provider.INDEPENDENT
305-
# Evidence present but no MX → 0.50 base + 1 extra kind × 0.02
306-
assert result.confidence == pytest.approx(0.52)
305+
# No MX, secondary evidence only → 0.20 base + 1 extra kind × 0.02
306+
assert result.confidence == pytest.approx(0.22)
307307

308308
def test_asn_with_primary(self):
309309
"""ASN evidence with primary signals boosts confidence."""
@@ -331,8 +331,8 @@ def test_swiss_isp_spf_ip_alone_no_winner(self):
331331
]
332332
result = _aggregate(evidence)
333333
assert result.provider == Provider.INDEPENDENT
334-
# Evidence present but no MX → 0.50 base + 1 extra kind × 0.02
335-
assert result.confidence == pytest.approx(0.52)
334+
# No MX, secondary evidence only → 0.20 base + 1 extra kind × 0.02
335+
assert result.confidence == pytest.approx(0.22)
336336

337337
def test_spf_ip_alone_no_winner(self):
338338
"""SPF_IP(Google) alone → INDEPENDENT (regression test for zuerich.ch)."""
@@ -341,8 +341,8 @@ def test_spf_ip_alone_no_winner(self):
341341
]
342342
result = _aggregate(evidence)
343343
assert result.provider == Provider.INDEPENDENT
344-
# Evidence present but no MX → 0.50 base + 1 extra kind × 0.02
345-
assert result.confidence == pytest.approx(0.52)
344+
# No MX, secondary evidence only → 0.20 base + 1 extra kind × 0.02
345+
assert result.confidence == pytest.approx(0.22)
346346

347347
def test_spf_ip_with_primary(self):
348348
"""MX(Google) + SPF_IP(Google) → Google with boosted confidence."""

0 commit comments

Comments
 (0)