Spaces:
Sleeping
Sleeping
docs: rule on the Task 5 scoring findings
Browse filesTier 2 now honours the spec's exclusion rule (fit produit = 0 is excluded
however high the total) - a firm with no listed-equity book cannot be a lead
for a product that reads listed-equity filings. score_reach stops reporting
"no contact" about accounts that have one, score_access records a reason on
every branch, and the tier cap gets a secondary sort so the account sitting at
the 40 boundary does not move between runs.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016XzekHxqiXutBW4gw3Arsx
docs/superpowers/plans/2026-08-29-prospection-buyside.md
CHANGED
|
@@ -1136,8 +1136,6 @@ Les deux fonctions d'attribution renvoient `{account_id: tier}`.
|
|
| 1136 |
"""tests/test_prospection_scoring.py — scoring ICP déterministe, deux passes."""
|
| 1137 |
from __future__ import annotations
|
| 1138 |
|
| 1139 |
-
import pytest
|
| 1140 |
-
|
| 1141 |
from prospection import scoring
|
| 1142 |
|
| 1143 |
|
|
@@ -1180,6 +1178,37 @@ def test_signal_points_are_capped_at_25():
|
|
| 1180 |
assert points == 25
|
| 1181 |
|
| 1182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1183 |
def test_reach_prefers_verified_over_probable():
|
| 1184 |
verified, _ = scoring.score_reach([_named_contact(email_status="verified")])
|
| 1185 |
probable, _ = scoring.score_reach([_named_contact(email_status="probable")])
|
|
@@ -1201,7 +1230,7 @@ def test_provisional_assignment_caps_at_60_and_requires_min_fit():
|
|
| 1201 |
results.append((999, scoring.ScoreResult(total=95, fit=10, reasons=[])))
|
| 1202 |
tiers = scoring.assign_provisional(results)
|
| 1203 |
assert sum(1 for t in tiers.values() if t == 1) == 60
|
| 1204 |
-
assert tiers[999]
|
| 1205 |
|
| 1206 |
|
| 1207 |
def test_final_assignment_demotes_accounts_without_a_named_contact():
|
|
@@ -1223,6 +1252,23 @@ def test_final_assignment_caps_tier1_at_40():
|
|
| 1223 |
assert sum(1 for t in tiers.values() if t == 2) == 15
|
| 1224 |
|
| 1225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1226 |
def test_scores_below_tier2_threshold_are_excluded():
|
| 1227 |
weak = scoring.ScoreResult(total=12, fit=30, reasons=[])
|
| 1228 |
tiers = scoring.assign_final([(1, weak, [_named_contact()])])
|
|
@@ -1273,11 +1319,17 @@ def score_fit(account: dict, has_equity_funds: bool, has_edgar_overlap: bool) ->
|
|
| 1273 |
def score_access(account: dict) -> tuple[int, list[str]]:
|
| 1274 |
points, reasons = 0, []
|
| 1275 |
effectif = account.get("effectif")
|
| 1276 |
-
if effectif is
|
|
|
|
|
|
|
| 1277 |
points += 12
|
| 1278 |
reasons.append("access:effectif_5_60")
|
| 1279 |
-
elif effectif
|
| 1280 |
reasons.append("access:effectif_hors_cible")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1281 |
if account.get("independante"):
|
| 1282 |
points += 8
|
| 1283 |
reasons.append("access:independante")
|
|
@@ -1286,6 +1338,8 @@ def score_access(account: dict) -> tuple[int, list[str]]:
|
|
| 1286 |
if account.get("dirigeants"):
|
| 1287 |
points += 5
|
| 1288 |
reasons.append("access:dirigeant_nomme")
|
|
|
|
|
|
|
| 1289 |
return points, reasons
|
| 1290 |
|
| 1291 |
|
|
@@ -1300,7 +1354,11 @@ def score_signals(signals: list[dict]) -> tuple[int, list[str]]:
|
|
| 1300 |
|
| 1301 |
|
| 1302 |
def score_reach(contacts: list[dict]) -> tuple[int, list[str]]:
|
| 1303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1304 |
for contact in contacts:
|
| 1305 |
if contact.get("is_generic"):
|
| 1306 |
candidate, label = 2, "reach:standard_seul"
|
|
@@ -1312,7 +1370,7 @@ def score_reach(contacts: list[dict]) -> tuple[int, list[str]]:
|
|
| 1312 |
candidate, label = 0, "reach:contact_sans_email"
|
| 1313 |
if candidate > best:
|
| 1314 |
best, reason = candidate, label
|
| 1315 |
-
return best, [reason]
|
| 1316 |
|
| 1317 |
|
| 1318 |
def score_pass1(account: dict, has_equity_funds: bool, has_edgar_overlap: bool,
|
|
@@ -1331,17 +1389,28 @@ def score_pass2(base: ScoreResult, contacts: list[dict]) -> ScoreResult:
|
|
| 1331 |
|
| 1332 |
|
| 1333 |
def _eligible(result: ScoreResult) -> bool:
|
|
|
|
| 1334 |
return result.fit >= config.MIN_FIT
|
| 1335 |
|
| 1336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1337 |
def assign_provisional(results: list[tuple[int, ScoreResult]]) -> dict[int, int]:
|
| 1338 |
"""Passe 1 : au plus TIER1_PROVISIONAL_CAP comptes deviennent enrichissables."""
|
|
|
|
|
|
|
|
|
|
| 1339 |
ranked = sorted((r for r in results if _eligible(r[1])),
|
| 1340 |
-
key=lambda r: r[1].total,
|
| 1341 |
promoted = {account_id for account_id, _ in ranked[:config.TIER1_PROVISIONAL_CAP]}
|
| 1342 |
return {
|
| 1343 |
-
account_id: 1 if account_id in promoted
|
| 1344 |
-
else (2 if result.total >= config.TIER2_MIN_SCORE else 0)
|
| 1345 |
for account_id, result in results
|
| 1346 |
}
|
| 1347 |
|
|
@@ -1354,12 +1423,11 @@ def assign_final(results: list[tuple[int, ScoreResult, list[dict]]]) -> dict[int
|
|
| 1354 |
candidates = sorted(
|
| 1355 |
(r for r in results
|
| 1356 |
if _eligible(r[1]) and r[1].total >= config.TIER1_MIN_SCORE and _has_named_contact(r[2])),
|
| 1357 |
-
key=lambda r: r[1].total,
|
| 1358 |
)
|
| 1359 |
promoted = {account_id for account_id, _, _ in candidates[:config.TIER1_FINAL_CAP]}
|
| 1360 |
return {
|
| 1361 |
-
account_id: 1 if account_id in promoted
|
| 1362 |
-
else (2 if result.total >= config.TIER2_MIN_SCORE else 0)
|
| 1363 |
for account_id, result, _ in results
|
| 1364 |
}
|
| 1365 |
```
|
|
|
|
| 1136 |
"""tests/test_prospection_scoring.py — scoring ICP déterministe, deux passes."""
|
| 1137 |
from __future__ import annotations
|
| 1138 |
|
|
|
|
|
|
|
| 1139 |
from prospection import scoring
|
| 1140 |
|
| 1141 |
|
|
|
|
| 1178 |
assert points == 25
|
| 1179 |
|
| 1180 |
|
| 1181 |
+
def test_reach_reports_a_contact_without_an_email_as_such():
|
| 1182 |
+
"""Le piège : un contact nommé sans adresse vaut 0 point. Si la raison ne
|
| 1183 |
+
l'emporte pas sur l'amorce, le score affirme « aucun contact » alors qu'il y
|
| 1184 |
+
en a un."""
|
| 1185 |
+
points, reasons = scoring.score_reach([_named_contact(email_status="unknown")])
|
| 1186 |
+
assert points == 0
|
| 1187 |
+
assert reasons == ["reach:contact_sans_email"]
|
| 1188 |
+
|
| 1189 |
+
|
| 1190 |
+
def test_reach_on_an_empty_list_says_no_contact():
|
| 1191 |
+
assert scoring.score_reach([]) == (0, ["reach:aucun_contact"])
|
| 1192 |
+
|
| 1193 |
+
|
| 1194 |
+
def test_access_records_a_reason_at_every_headcount_boundary():
|
| 1195 |
+
"""Chaque issue doit s'expliquer, pas seulement celles qui rapportent."""
|
| 1196 |
+
def reasons_for(effectif):
|
| 1197 |
+
return scoring.score_access(_account(effectif=effectif))[1]
|
| 1198 |
+
|
| 1199 |
+
assert "access:effectif_trop_petit" in reasons_for(0)
|
| 1200 |
+
assert "access:effectif_trop_petit" in reasons_for(4)
|
| 1201 |
+
assert "access:effectif_5_60" in reasons_for(5)
|
| 1202 |
+
assert "access:effectif_5_60" in reasons_for(60)
|
| 1203 |
+
assert "access:effectif_hors_cible" in reasons_for(61)
|
| 1204 |
+
assert "access:effectif_inconnu" in reasons_for(None)
|
| 1205 |
+
|
| 1206 |
+
|
| 1207 |
+
def test_access_records_the_absence_of_a_named_director():
|
| 1208 |
+
reasons = scoring.score_access(_account(dirigeants=[]))[1]
|
| 1209 |
+
assert "access:aucun_dirigeant_nomme" in reasons
|
| 1210 |
+
|
| 1211 |
+
|
| 1212 |
def test_reach_prefers_verified_over_probable():
|
| 1213 |
verified, _ = scoring.score_reach([_named_contact(email_status="verified")])
|
| 1214 |
probable, _ = scoring.score_reach([_named_contact(email_status="probable")])
|
|
|
|
| 1230 |
results.append((999, scoring.ScoreResult(total=95, fit=10, reasons=[])))
|
| 1231 |
tiers = scoring.assign_provisional(results)
|
| 1232 |
assert sum(1 for t in tiers.values() if t == 1) == 60
|
| 1233 |
+
assert tiers[999] == 2 # fit sous MIN_FIT mais non nul : Tier 2, pas Tier 1
|
| 1234 |
|
| 1235 |
|
| 1236 |
def test_final_assignment_demotes_accounts_without_a_named_contact():
|
|
|
|
| 1252 |
assert sum(1 for t in tiers.values() if t == 2) == 15
|
| 1253 |
|
| 1254 |
|
| 1255 |
+
def test_zero_fit_is_excluded_however_high_the_total():
|
| 1256 |
+
"""La spec exclut sur « fit produit = 0 » : sans poche actions cotées, le
|
| 1257 |
+
produit n'a pas d'objet, et aucun cumul de signaux ne rachète ça."""
|
| 1258 |
+
no_fit = scoring.ScoreResult(total=90, fit=0, reasons=[])
|
| 1259 |
+
assert scoring.assign_final([(1, no_fit, [_named_contact()])])[1] == 0
|
| 1260 |
+
assert scoring.assign_provisional([(1, no_fit)])[1] == 0
|
| 1261 |
+
|
| 1262 |
+
|
| 1263 |
+
def test_tier_assignment_is_stable_when_totals_tie():
|
| 1264 |
+
"""Le compte qui occupe la dernière place sous le plafond décide qui reçoit
|
| 1265 |
+
une démo : il ne doit pas dépendre de l'ordre de la liste d'entrée."""
|
| 1266 |
+
tied = scoring.ScoreResult(total=80, fit=30, reasons=[])
|
| 1267 |
+
forward = [(i, tied, [_named_contact()]) for i in range(45)]
|
| 1268 |
+
reversed_order = list(reversed(forward))
|
| 1269 |
+
assert scoring.assign_final(forward) == scoring.assign_final(reversed_order)
|
| 1270 |
+
|
| 1271 |
+
|
| 1272 |
def test_scores_below_tier2_threshold_are_excluded():
|
| 1273 |
weak = scoring.ScoreResult(total=12, fit=30, reasons=[])
|
| 1274 |
tiers = scoring.assign_final([(1, weak, [_named_contact()])])
|
|
|
|
| 1319 |
def score_access(account: dict) -> tuple[int, list[str]]:
|
| 1320 |
points, reasons = 0, []
|
| 1321 |
effectif = account.get("effectif")
|
| 1322 |
+
if effectif is None:
|
| 1323 |
+
reasons.append("access:effectif_inconnu")
|
| 1324 |
+
elif 5 <= effectif <= 60:
|
| 1325 |
points += 12
|
| 1326 |
reasons.append("access:effectif_5_60")
|
| 1327 |
+
elif effectif > 60:
|
| 1328 |
reasons.append("access:effectif_hors_cible")
|
| 1329 |
+
else:
|
| 1330 |
+
# Moins de 5 : trop petit pour porter un budget. Perdre les points sans
|
| 1331 |
+
# inscrire de raison laisserait un trou dans la piste d'audit.
|
| 1332 |
+
reasons.append("access:effectif_trop_petit")
|
| 1333 |
if account.get("independante"):
|
| 1334 |
points += 8
|
| 1335 |
reasons.append("access:independante")
|
|
|
|
| 1338 |
if account.get("dirigeants"):
|
| 1339 |
points += 5
|
| 1340 |
reasons.append("access:dirigeant_nomme")
|
| 1341 |
+
else:
|
| 1342 |
+
reasons.append("access:aucun_dirigeant_nomme")
|
| 1343 |
return points, reasons
|
| 1344 |
|
| 1345 |
|
|
|
|
| 1354 |
|
| 1355 |
|
| 1356 |
def score_reach(contacts: list[dict]) -> tuple[int, list[str]]:
|
| 1357 |
+
# Amorce à -1, pas à 0 : un contact nommé sans adresse vaut 0 point, et avec
|
| 1358 |
+
# une amorce à 0 sa raison ("contact_sans_email") ne pourrait jamais l'emporter
|
| 1359 |
+
# sur "aucun_contact" — le score dirait qu'il n'y a personne alors qu'il y a
|
| 1360 |
+
# quelqu'un, ce qui est faux et invérifiable.
|
| 1361 |
+
best, reason = -1, "reach:aucun_contact"
|
| 1362 |
for contact in contacts:
|
| 1363 |
if contact.get("is_generic"):
|
| 1364 |
candidate, label = 2, "reach:standard_seul"
|
|
|
|
| 1370 |
candidate, label = 0, "reach:contact_sans_email"
|
| 1371 |
if candidate > best:
|
| 1372 |
best, reason = candidate, label
|
| 1373 |
+
return max(best, 0), [reason]
|
| 1374 |
|
| 1375 |
|
| 1376 |
def score_pass1(account: dict, has_equity_funds: bool, has_edgar_overlap: bool,
|
|
|
|
| 1389 |
|
| 1390 |
|
| 1391 |
def _eligible(result: ScoreResult) -> bool:
|
| 1392 |
+
"""Éligible au Tier 1 : la porte haute."""
|
| 1393 |
return result.fit >= config.MIN_FIT
|
| 1394 |
|
| 1395 |
|
| 1396 |
+
def _workable(result: ScoreResult) -> bool:
|
| 1397 |
+
"""Travaillable en Tier 2. La spec exclut sur `fit produit = 0` : sans aucune
|
| 1398 |
+
poche actions cotées, le produit n'a pas d'objet, quel que soit le total.
|
| 1399 |
+
Le seuil est bien `> 0` et non `>= MIN_FIT` — une société exposée aux actions
|
| 1400 |
+
mais sans émetteur EDGAR ingérable marque 20 et reste un prospect légitime."""
|
| 1401 |
+
return result.fit > 0 and result.total >= config.TIER2_MIN_SCORE
|
| 1402 |
+
|
| 1403 |
+
|
| 1404 |
def assign_provisional(results: list[tuple[int, ScoreResult]]) -> dict[int, int]:
|
| 1405 |
"""Passe 1 : au plus TIER1_PROVISIONAL_CAP comptes deviennent enrichissables."""
|
| 1406 |
+
# Tri secondaire sur l'identifiant : le compte qui occupe la dernière place
|
| 1407 |
+
# sous le plafond décide qui reçoit une démo. Il ne doit pas changer d'une
|
| 1408 |
+
# exécution à l'autre parce que l'appelant a listé les comptes autrement.
|
| 1409 |
ranked = sorted((r for r in results if _eligible(r[1])),
|
| 1410 |
+
key=lambda r: (-r[1].total, r[0]))
|
| 1411 |
promoted = {account_id for account_id, _ in ranked[:config.TIER1_PROVISIONAL_CAP]}
|
| 1412 |
return {
|
| 1413 |
+
account_id: 1 if account_id in promoted else (2 if _workable(result) else 0)
|
|
|
|
| 1414 |
for account_id, result in results
|
| 1415 |
}
|
| 1416 |
|
|
|
|
| 1423 |
candidates = sorted(
|
| 1424 |
(r for r in results
|
| 1425 |
if _eligible(r[1]) and r[1].total >= config.TIER1_MIN_SCORE and _has_named_contact(r[2])),
|
| 1426 |
+
key=lambda r: (-r[1].total, r[0]),
|
| 1427 |
)
|
| 1428 |
promoted = {account_id for account_id, _, _ in candidates[:config.TIER1_FINAL_CAP]}
|
| 1429 |
return {
|
| 1430 |
+
account_id: 1 if account_id in promoted else (2 if _workable(result) else 0)
|
|
|
|
| 1431 |
for account_id, result, _ in results
|
| 1432 |
}
|
| 1433 |
```
|