:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(growth): stop scoring personal email providers as icp companies (#114772)
Matt Brooker2911276efda2
diff --git a/posthog/helpers/generic_emails.txt b/posthog/helpers/generic_emails.txtindex 7dcd87b9fdc9..23ba1d1ec1a2 100644--- a/posthog/helpers/generic_emails.txt+++ b/posthog/helpers/generic_emails.txt@@ -6,6 +6,7 @@123mail.cl123qwe.co.uk126.com+139.com150ml.com15meg4free.com163.com@@ -64,6 +65,7 @@ ace-of-base.comacmecity.comacmemail.netacninc.net+addy.ioadelphia.netadexec.comadfarrow.com@@ -87,6 +89,7 @@ ajacied.comak47.huaknet.kgalbawaba.com+aleeas.comalex4all.comalexandria.ccalgeria.com@@ -125,6 +128,8 @@ animal.netanimalhouse.comanimalwoman.netanjungcafe.com+anonaddy.com+anonaddy.meanote.comanother.comanotherwin95.com@@ -177,6 +182,7 @@ atlanticbb.netatlaswebmail.comatlink.comato.check.com+atomicmail.ioatozasia.comatt.netatt.net@@ -309,6 +315,7 @@ bt.combtinternet.combtopenworld.co.ukbuffymail.com+bugcrowdninja.combullsfan.combullsgame.combumerang.ro@@ -588,6 +595,7 @@ dslextreme.comdubaimail.comdublin.comdublin.ie+duck.comdunlopdriver.comdunloprider.comduno.com@@ -628,6 +636,7 @@ elvis.comemail-london.co.ukemail.comemail.cz+email.deemail.eeemail.itemail.nu@@ -666,6 +675,7 @@ eqqu.comeramail.co.zaeresmas.comeriga.lv+erine.emailerols.comestranet.itethos.st@@ -704,6 +714,7 @@ fastemail.usfastemailer.comfastermail.comfastimap.com+fastmail.comfastmail.fmfastmailbox.netfastmessaging.com@@ -931,6 +942,7 @@ gmx.degmx.frgmx.ligmx.net+gmx.usgnwmail.comgo.comgo.ro@@ -1002,6 +1014,7 @@ herediano.comheremail.comherono1.comhetnet.nl+hey.comhey.tohhdevel.comhighmilton.com@@ -1037,18 +1050,24 @@ hotepmail.comhotfire.nethotletter.comhotmail.be+hotmail.cahotmail.co.il+hotmail.co.jp+hotmail.co.nzhotmail.co.ukhotmail.comhotmail.com.arhotmail.com.brhotmail.com.mx+hotmail.com.trhotmail.dehotmail.eshotmail.frhotmail.ithotmail.kghotmail.kz+hotmail.nl+hotmail.nohotmail.ruhotpop.comhotpop3.com@@ -1217,6 +1236,7 @@ katamail.comkayafmmail.co.zakbjrmail.comkcks.com+keemail.mekeg-party.comkeko.com.arkellychen.com@@ -1283,15 +1303,21 @@ list.rulittleblueroom.comlive.belive.ca+live.cl+live.cnlive.co.uklive.comlive.com.arlive.com.aulive.com.mxlive.de+live.dklive.fr+live.inlive.it+live.jplive.nl+live.seliverpoolfans.comllandudno.comllangollen.com@@ -1348,6 +1374,7 @@ mail.bulgaria.commail.byte.itmail.co.zamail.com+mail.demail.eemail.entrepeneurmag.commail.freetown.com@@ -2645,6 +2672,7 @@ mailbox.asmailbox.co.zamailbox.grmailbox.hu+mailbox.orgmailbr.com.brmailc.netmailcan.com@@ -2654,6 +2682,7 @@ mailcity.commailclub.frmailclub.netmailexcite.com+mailfence.commailforce.netmailftp.commailgate.gr@@ -2761,6 +2790,7 @@ mostlysunny.commotormania.commovemail.commovieluver.com+mozmail.commp4.itmr-potatohead.commrpost.com@@ -2797,6 +2827,7 @@ mystupidjob.commythirdage.commyway.commyworldmail.com+myyahoo.comn2.comn2business.comn2mail.com@@ -2939,8 +2970,23 @@ ourbrisbane.comournet.mdoutel.comoutgun.com+outlook.cl+outlook.co.id+outlook.co.nzoutlook.com+outlook.com.ar+outlook.com.auoutlook.com.br+outlook.de+outlook.es+outlook.fr+outlook.in+outlook.it+outlook.jp+outlook.kr+outlook.lv+outlook.ph+outlook.saover-the-rainbow.comownmail.netozbytes.net.au@@ -2958,6 +3004,10 @@ parsmail.compartlycloudy.compartynight.atparvazi.com+passfwd.com+passinbox.com+passmail.com+passmail.netpasswordmail.compathfindermail.compatmedia.net@@ -2997,6 +3047,7 @@ plasa.complayersodds.complayful.complusmail.com.br+pm.mepmail.netpobox.compobox.hu@@ -3027,6 +3078,8 @@ postaccesslite.compostafree.compostaweb.composte.it+posteo.de+posteo.netpostinbox.compostino.chpostmark.net@@ -3041,6 +3094,7 @@ press.co.jppriest.comprimposta.comprimposta.hu+privaterelay.appleid.compro.huprobemail.comprodigy.net@@ -3053,6 +3107,8 @@ project2k.comprolaunch.compromessage.comprontomail.com+proton.me+protonmail.chprotonmail.compsi.netpsv-supporter.com@@ -3199,6 +3255,8 @@ sialkotian.comsialkotoye.comsify.comsilkroad.net+simplelogin.com+simplelogin.frsina.cnsina.comsinamail.com@@ -3213,6 +3271,8 @@ sky.comskynet.beslamdunkfan.comslingshot.com+slmail.me+slmails.comslo.netslotter.comsmapxsmap.net@@ -3281,6 +3341,7 @@ starpower.netstarspath.comstart.com.austarting-point.com+startmail.comstartrekmail.comstealthmail.comstockracer.com@@ -3491,6 +3552,11 @@ tsamail.co.zattml.co.intunisiamail.comturkey.com+tuta.com+tuta.io+tutamail.com+tutanota.com+tutanota.detvcablenet.betwinstarsmail.comtycoonmail.com@@ -3601,6 +3667,7 @@ warrior.huwaumail.comwbdet.comwearab.net+wearehackerone.comweb-mail.com.arweb-police.comweb.de@@ -3635,6 +3702,7 @@ whoopymail.comwickedmail.comwideopenwest.comwildmail.com+windowslive.comwindrivers.netwindstream.netwingnutz.com@@ -3721,10 +3789,12 @@ yalla.com.lbyalook.comyam.comyandex.com+yandex.kzyandex.ruyapost.comyawmail.comyclub.com+yeah.netyebox.comyehaa.comyehey.com@@ -3771,6 +3841,9 @@ zipmail.com.brzipmax.comzmail.ruzoho.com+zohomail.com+zohomail.com.au+zohomail.inzonnet.nlzoominternet.netzubee.comdiff --git a/posthog/utils.py b/posthog/utils.pyindex f7f40d6e19c3..48461840f95f 100644--- a/posthog/utils.py+++ b/posthog/utils.py@@ -1826,7 +1826,10 @@ class GenericEmails:at_location = email.find("@")if at_location == -1:return False- return self.emails.get(email[(at_location + 1) :], False)+ return self.is_generic_domain(email[(at_location + 1) :])++ def is_generic_domain(self, domain: str) -> bool:+ return self.emails.get(domain, False)# maxsize=2 keeps the previous hour's bucket warm so requests interleaved across thediff --git a/products/growth/backend/enrichment/fit_score.py b/products/growth/backend/enrichment/fit_score.pyindex 7f7d2ed7216f..e8aa07bb6ac8 100644--- a/products/growth/backend/enrichment/fit_score.py+++ b/products/growth/backend/enrichment/fit_score.py@@ -141,3 +141,17 @@ def score_company(payload, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk, enrichments=enrichments)return score_context(inputs, source=lists.rules.source, lists_version=lists.version, input_versions=input_versions)+++def no_company_fit(+ *, lists: CuratedLists, role: Optional[str], domain: Optional[str], wizard_ai_sdk: bool+) -> IcpFitResult:+ # The editable formula can give a missing company another status, such as the student+ # disqualification that runs before its company check, so this result does not run it.+ inputs = build_scoring_inputs(None, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)+ return IcpFitResult(+ status=STATUS_NOT_FOUND,+ lists_version=lists.version,+ input_hash=scoring_input_hash(inputs, {}),+ input_values=inputs,+ )diff --git a/products/growth/backend/enrichment/gates.py b/products/growth/backend/enrichment/gates.pyindex ea249c7261c2..b503d45f9b1e 100644--- a/products/growth/backend/enrichment/gates.py+++ b/products/growth/backend/enrichment/gates.py@@ -18,6 +18,10 @@ SIGNUP_MEMBERSHIP_WINDOW = dt.timedelta(minutes=5)_generic_emails = GenericEmails()+# These domains identify no company. They stay out of GenericEmails because the internal-users+# cohort also uses that list, and a test team needs its own test domain in that cohort.+_NON_COMPANY_DOMAINS = frozenset({"example.com", "example.net", "example.org", "test.com"})+def enrichment_enabled() -> bool:return bool(get_instance_setting(KILL_SWITCH_SETTING))@@ -39,7 +43,17 @@ def domain_from_email(email: str) -> str | None:return domain or None-SignupIdentitySkipReason = Literal["signup_user_left", "no_usable_member"]+def is_work_domain(domain: str) -> bool:+ domain = domain.strip().lower()+ return bool(domain) and domain not in _NON_COMPANY_DOMAINS and not _generic_emails.is_generic_domain(domain)+++def is_work_email(email: str) -> bool:+ domain = domain_from_email(email)+ return domain is not None and is_work_domain(domain)+++SignupIdentitySkipReason = Literal["signup_user_left", "no_usable_member", "not_work_email"]@frozen@@ -66,7 +80,9 @@ def resolve_signup_identity(organization_id: str) -> SignupIdentity | SignupIdenreturn SignupIdentitySkip(reason="signup_user_left")user = membership.userdomain = domain_from_email(user.email) if user and user.email else None- # The signup user's email can have changed since signup, so re-check it's a work email.- if user is None or not user.distinct_id or not domain or _generic_emails.is_generic(user.email):+ if user is None or not user.distinct_id or not domain:return SignupIdentitySkip(reason="no_usable_member")+ # The signup user's email can have changed since signup, so re-check it's a work email.+ if not is_work_email(user.email):+ return SignupIdentitySkip(reason="not_work_email")return SignupIdentity(distinct_id=user.distinct_id, domain=domain)diff --git a/products/growth/backend/management/commands/backfill_icp_fit_scores.py b/products/growth/backend/management/commands/backfill_icp_fit_scores.pyindex a3a5194f41ec..dbf734284d5b 100644--- a/products/growth/backend/management/commands/backfill_icp_fit_scores.py+++ b/products/growth/backend/management/commands/backfill_icp_fit_scores.py@@ -3,11 +3,17 @@The score-side sibling of backfill_enrichment_fields (which owns the firmographic keys andnever touches any score): this command writes ONLY the icp_fit_* keys — a fit-onlywrite_organization_enrichment call — so the two backfills stay independently re-runnable,-and the legacy clay icp_score is never touched here.+and the legacy clay icp_score is never touched here. The one exception is work_email, which+the clear below sets to false.No new Harmonic calls: everything replays from the fetch archive. A sentinel (miss) archiverow scores as not_found, which is recorded rather than skipped so the re-enrichment sweepcan find those orgs.+An org whose signup domain is a personal or relay email provider is cleared, not scored:+its archived payload describes the email provider, so its fit becomes not_found. The signup+domain is the one the stored score used, so a member who changes their email later does not+move the org between scored and cleared.+Role for the student disqualification comes from the record's signup_role key, persisted atsignup since the fit score shipped; historical orgs without it simply score without thestudent DQ.@@ -44,7 +50,7 @@ from products.growth.backend.enrichment import (from products.growth.backend.enrichment.bridge import read_organization_bridge_inputsfrom products.growth.backend.enrichment.context import FIT_EVALUATION_KIND_BACKFILLfrom products.growth.backend.enrichment.fit_recomputation import latest_fetch, score_archived_fit-from products.growth.backend.enrichment.fit_score import IcpFitResult, score_company+from products.growth.backend.enrichment.fit_score import IcpFitResult, no_company_fit, score_companyfrom products.growth.backend.enrichment.icp_lists import (CuratedLists,load_active_lists,@@ -57,11 +63,18 @@ from products.growth.backend.enrichment.scoring_context import normalize_fit_payfrom products.growth.backend.enrichment.writer import (lock_organization_enrichment,project_organization_enrichment,+ record_signup_work_email,write_organization_enrichment,)from products.growth.backend.models import IcpScoringConfig, OrganizationEnrichment, OrganizationEnrichmentFetch-_BackfillOutcome = Literal["written", "skipped_org_gone", "skipped_wizard_unavailable", "skipped_stale_fetch"]+_BackfillOutcome = Literal[+ "written",+ "cleared_not_work_email",+ "skipped_org_gone",+ "skipped_wizard_unavailable",+ "skipped_stale_fetch",+]class _Stats:@@ -125,14 +138,20 @@ def _wizard_ai_sdk_for_backfill(*, organization_id: str, record: Optional[Organireturn True if persisted else None-def _score_backfill_fetch(- *, fetch: OrganizationEnrichmentFetch, organization: Organization, lists: CuratedLists, wizard_ai_sdk: bool-) -> IcpFitResult:- domain = signup_domain_for_organization(organization)- record = OrganizationEnrichment.objects.filter(organization_id=fetch.organization_id).first()- role = record.data.get("signup_role") if record else None+def _signup_domain(*, organization: Organization, record: Optional[OrganizationEnrichment]) -> str | None:+ signup = record.data.get("icp_fit_signup") if record else None+ domain = signup.get("domain") if isinstance(signup, dict) else None+ return domain if isinstance(domain, str) and domain else signup_domain_for_organization(organization)+++def _signup_role(organization_id: str) -> str | None:+ record = OrganizationEnrichment.objects.filter(organization_id=organization_id).first()+ return record.data.get("signup_role") if record else None+- return score_archived_fit(fetch, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)+def _earliest_member_distinct_id(organization: Organization) -> str | None:+ membership = organization.memberships.select_related("user").order_by("joined_at").first()+ return membership.user.distinct_id if membership else Nonedef _iter_parity_payloads(path: str):@@ -213,21 +232,32 @@ class Command(BaseCommand):return "skipped_org_gone"record = OrganizationEnrichment.objects.filter(organization_id=fetch.organization_id).first()- wizard_ai_sdk = _wizard_ai_sdk_for_backfill(organization_id=str(fetch.organization_id), record=record)+ domain = _signup_domain(organization=organization, record=record)+ clears_fit = domain is not None and not gates.is_work_domain(domain)+ outcome: _BackfillOutcome = "cleared_not_work_email" if clears_fit else "written"+ verb, done = ("clear", "cleared") if clears_fit else ("write", "wrote")+ detail = f" signup_domain={domain}" if clears_fit else ""+ wizard_ai_sdk = (+ saved_wizard_ai_sdk(record.data if record else {})+ if clears_fit+ else _wizard_ai_sdk_for_backfill(organization_id=str(fetch.organization_id), record=record)+ )if wizard_ai_sdk is None:return "skipped_wizard_unavailable"with lock_organization_enrichment(str(fetch.organization_id)):current_fetch = latest_fetch(str(fetch.organization_id))if current_fetch is None or current_fetch.id != fetch.id:return "skipped_stale_fetch"- result = _score_backfill_fetch(- fetch=fetch, organization=organization, lists=lists, wizard_ai_sdk=wizard_ai_sdk- )- stats.add(result)+ role = _signup_role(str(fetch.organization_id))+ if clears_fit:+ result = no_company_fit(lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)+ else:+ result = score_archived_fit(fetch, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)+ stats.add(result)if dry_run:- self.stdout.write(f"would write {fetch.organization_id}: {result.status} score={result.score}")- return "written"+ self.stdout.write(f"would {verb} {fetch.organization_id}: {result.status} score={result.score}{detail}")+ return outcomeif (require_active_config@@ -244,13 +274,19 @@ class Command(BaseCommand):fit_evaluation_kind=FIT_EVALUATION_KIND_BACKFILL,project=False,)+ if clears_fit:+ record_signup_work_email(organization_id=str(fetch.organization_id), work_email=False)project_organization_enrichment(- organization_id=str(fetch.organization_id), fields=None, pha_client=pha_client, fit=result+ organization_id=str(fetch.organization_id),+ fields=None,+ pha_client=pha_client,+ fit=result,+ fit_mirror_distinct_id=_earliest_member_distinct_id(organization) if clears_fit else None,)- self.stdout.write(f"wrote {fetch.organization_id}: {result.status} score={result.score}")+ self.stdout.write(f"{done} {fetch.organization_id}: {result.status} score={result.score}{detail}")if delay:time.sleep(delay)- return "written"+ return outcomedef _run_backfill(self, options: dict[str, Any]) -> None:if not gates.region_allowed():@@ -276,6 +312,7 @@ class Command(BaseCommand):outcomes: dict[_BackfillOutcome, int] = {"written": 0,+ "cleared_not_work_email": 0,"skipped_org_gone": 0,"skipped_wizard_unavailable": 0,"skipped_stale_fetch": 0,@@ -297,10 +334,11 @@ class Command(BaseCommand):finally:pha_client.shutdown()- verb = "would write" if dry_run else "wrote"+ verb, clear_verb = ("would write", "would clear") if dry_run else ("wrote", "cleared")self.stdout.write(self.style.SUCCESS(f"considered {considered}, {verb} {outcomes['written']}, "+ f"{clear_verb} {outcomes['cleared_not_work_email']}, "f"skipped_org_gone {outcomes['skipped_org_gone']}, "f"skipped_wizard_unavailable {outcomes['skipped_wizard_unavailable']}, "f"skipped_stale_fetch {outcomes['skipped_stale_fetch']}"diff --git a/products/growth/backend/management/commands/backfill_signup_enrichment.py b/products/growth/backend/management/commands/backfill_signup_enrichment.pyindex 044512dadc84..a25bd9308378 100644--- a/products/growth/backend/management/commands/backfill_signup_enrichment.py+++ b/products/growth/backend/management/commands/backfill_signup_enrichment.py@@ -18,6 +18,12 @@ from products.growth.backend.enrichment import gatesfrom products.growth.backend.temporal.signup_enrichment.trigger import dispatch_signup_enrichmentfrom products.growth.backend.temporal.signup_enrichment.workflow import SignupEnrichmentInputs+_SKIP_REASONS: dict[gates.SignupIdentitySkipReason, str] = {+ "signup_user_left": "signup user no longer a member",+ "no_usable_member": "no usable signup member",+ "not_work_email": "signup email is not a work email",+}+class Command(BaseCommand):help = (@@ -67,12 +73,7 @@ class Command(BaseCommand):identity = gates.resolve_signup_identity(str(org.id))if isinstance(identity, gates.SignupIdentitySkip):skipped += 1- if identity.reason == "signup_user_left":- self.stdout.write(- f"skip {org.id} ({org.created_at:%Y-%m-%d %H:%M}) (signup user no longer a member)"- )- else:- self.stdout.write(f"skip {org.id} ({org.created_at:%Y-%m-%d %H:%M}) (no usable signup member)")+ self.stdout.write(f"skip {org.id} ({org.created_at:%Y-%m-%d %H:%M}) ({_SKIP_REASONS[identity.reason]})")continueinputs = SignupEnrichmentInputs(diff --git a/products/growth/backend/temporal/signup_enrichment/reenrichment.py b/products/growth/backend/temporal/signup_enrichment/reenrichment.pyindex ff7dd630de3e..8e3570b01c08 100644--- a/products/growth/backend/temporal/signup_enrichment/reenrichment.py+++ b/products/growth/backend/temporal/signup_enrichment/reenrichment.py@@ -127,9 +127,13 @@ async def select_reenrichment_candidates_activity(inputs: IcpReenrichmentSweepIndue_for_retry = Q(data__has_key=ICP_REENRICHMENT_LAST_ATTEMPTED_AT_KEY) & Q(**{f"data__{ICP_REENRICHMENT_LAST_ATTEMPTED_AT_KEY}__lte": attempt_cutoff})+ # Excluding data__work_email=False instead would also drop every record without the key,+ # for the same missing-key NULL reason as above.+ not_work_email = Q(data__contains={"work_email": False})attempt_eligible = {str(record.organization_id): record.data.get(ICP_REENRICHMENT_LAST_ATTEMPTED_AT_KEY)for record in OrganizationEnrichment.objects.filter(data__icp_fit_status__in=list(SWEEPABLE_STATUSES))+ .exclude(not_work_email).filter(never_attempted | due_for_retry).only("organization_id", "data")}diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.py b/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.pyindex 1723ddf875f2..11503d836d10 100644--- a/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.py+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.py@@ -55,8 +55,11 @@ class TestReenrichmentSelection(BaseTest):last_attempted_days_ago: int | None = 31,first_fetch_days_ago: int = 40,signup_role: str | None = None,+ work_email: bool | None = True,) -> None:- data: dict = {"icp_fit_status": status, "work_email": True}+ data: dict = {"icp_fit_status": status}+ if work_email is not None:+ data["work_email"] = work_emailif signup_role:data["signup_role"] = signup_roleif last_attempted_days_ago is not None:@@ -101,12 +104,18 @@ class TestReenrichmentSelection(BaseTest):never_attempted_but_freshly_fetched = self._org_with_member("[email protected]")self._prime(never_attempted_but_freshly_fetched, last_attempted_days_ago=None, first_fetch_days_ago=1)+ not_work_email = self._org_with_member("[email protected]")+ self._prime(not_work_email, status="not_found", work_email=False)++ missing_work_email = self._org_with_member("[email protected]")+ self._prime(missing_work_email, last_attempted_days_ago=32, first_fetch_days_ago=40, work_email=None)+due = self._org_with_member("[email protected]")self._prime(due, last_attempted_days_ago=31, first_fetch_days_ago=40)candidates = self._select()- assert [c["organization_id"] for c in candidates] == [str(due.id)]+ assert [c["organization_id"] for c in candidates] == [str(missing_work_email.id), str(due.id)]def test_cap_takes_the_least_recently_attempted_org_first(self):newer = self._org_with_member("[email protected]")diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.py b/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.pyindex 2ce491514a73..64a6b65a22b8 100644--- a/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.py+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.py@@ -126,11 +126,12 @@ def test_kill_switch_off_never_dispatches_in_eu_either():connect_mock.assert_not_called()@override_settings(HARMONIC_API_KEY="key")-def test_personal_email_records_work_email_false_without_provider_dispatch():+def test_personal_email_records_work_email_false_without_provider_dispatch(email):on_commit, connect, run, region, record = _dispatch_mocks()with on_commit, connect as connect_mock, run, region, record as record_mock:- start_signup_enrichment_workflow(organization_id="org-1", distinct_id="d1", email="[email protected]")+ start_signup_enrichment_workflow(organization_id="org-1", distinct_id="d1", email=email)connect_mock.assert_not_called()record_mock.assert_called_once_with(organization_id="org-1", work_email=False, signup_role=None)diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py b/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.pyindex 44385d03676f..9a79db06e18f 100644--- a/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py@@ -209,19 +209,22 @@ async def test_a_second_signup_dispatch_keeps_its_first_leg_while_a_recheck_is_passert enrich.await_count == 2-async def test_recheck_skips_deleted_organization():- """The 4h recheck must not enrich or emit for an org deleted during the delay."""+ "domain,org_exists,skip_key",+ [("gone.dev", False, "org_deleted"), ("proton.me", True, "not_work_email")],+)+async def test_recheck_skips_without_enriching_or_emitting(domain, org_exists, skip_key):inputs = SignupEnrichmentInputs(- organization_id="00000000-0000-0000-0000-00000000dead", distinct_id="d1", domain="gone.dev"+ organization_id="00000000-0000-0000-0000-00000000dead", distinct_id="d1", domain=domain)with (patch(f"{_MODULE}.enrich_organization") as enrich_mock,patch(f"{_MODULE}.get_regional_ph_client") as client_mock,patch("posthog.models.Organization.objects") as org_objects,):- org_objects.filter.return_value.exists.return_value = False+ org_objects.filter.return_value.exists.return_value = org_existsresult = await enrich_signup_organization_activity(inputs, is_recheck=True)- assert result["org_deleted"] is True+ assert result[skip_key] is Trueassert result["matched"] is Falseenrich_mock.assert_not_called()client_mock.assert_not_called()diff --git a/products/growth/backend/temporal/signup_enrichment/trigger.py b/products/growth/backend/temporal/signup_enrichment/trigger.pyindex f06fb3050cca..58b3f3107e59 100644--- a/products/growth/backend/temporal/signup_enrichment/trigger.py+++ b/products/growth/backend/temporal/signup_enrichment/trigger.py@@ -23,7 +23,6 @@ from temporalio.service import RPCErrorfrom posthog.exceptions_capture import capture_exceptionfrom posthog.geoip import get_geoip_propertiesfrom posthog.temporal.common.client import sync_connect-from posthog.utils import GenericEmailsfrom products.growth.backend.enrichment import gatesfrom products.growth.backend.enrichment.writer import record_signup_work_email@@ -34,8 +33,6 @@ logger = structlog.get_logger(__name__)RescoreDispatchFailure = Literal["dispatch_backlog_full", "dispatch_failed"]-_generic_emails = GenericEmails()-# Bounded dispatch pool: a slow or unreachable Temporal must never let signup-triggered# threads accumulate on web pods. When the pool's backlog cap is hit, dispatch drops —# fire-and-forget degrades to "enrichment did not run", which the launch signal surfaces.@@ -70,7 +67,7 @@ def start_signup_enrichment_workflow(if not domain:return- work_email = not _generic_emails.is_generic(email)+ work_email = gates.is_work_email(email)_record_work_email(organization_id=str(organization_id), work_email=work_email, signup_role=role_at_organization or None)diff --git a/products/growth/backend/temporal/signup_enrichment/workflow.py b/products/growth/backend/temporal/signup_enrichment/workflow.pyindex 83989b4a29ad..460246161a22 100644--- a/products/growth/backend/temporal/signup_enrichment/workflow.py+++ b/products/growth/backend/temporal/signup_enrichment/workflow.py@@ -101,6 +101,11 @@ async def enrich_signup_organization_activity(if not org_exists:logger.info("signup_enrichment_recheck_skipped_org_deleted")return {"matched": False, "fields_filled": 0, "org_deleted": True}+ # The personal email domain list can grow while a recheck waits, so a domain the trigger+ # accepted can be a personal email provider by now.+ if not gates.is_work_domain(inputs.domain):+ logger.info("signup_enrichment_recheck_skipped_not_work_email")+ return {"matched": False, "fields_filled": 0, "not_work_email": True}# Region-local on purpose: EU enrichment lands in the EU internal project, US in US — the# same split the usage report uses. Never fall back to a cross-region client here.diff --git a/products/growth/backend/tests/test_backfill_icp_fit_scores.py b/products/growth/backend/tests/test_backfill_icp_fit_scores.pyindex ead834e36ced..eafc6aae855a 100644--- a/products/growth/backend/tests/test_backfill_icp_fit_scores.py+++ b/products/growth/backend/tests/test_backfill_icp_fit_scores.py@@ -6,6 +6,9 @@ from django.core.management.base import CommandErrorfrom parameterized import parameterized+from posthog.models.organization import Organization, OrganizationMembership+from posthog.models.user import User+from products.growth.backend.enrichment.bridge import OrganizationBridgeInputs, WizardBridgeInputsfrom products.growth.backend.enrichment.fit_score import score_companyfrom products.growth.backend.enrichment.icp_lists import build_curated_lists, clear_lists_cache@@ -124,6 +127,65 @@ class TestBackfillIcpFitScores(BaseTest):assert record.data["icp_fit_evaluation_kind"] == "backfill"assert record.data["icp_fit_evaluated_at"]+ def _member_org_record(self, email: str, data: dict) -> tuple[User, OrganizationEnrichment]:+ organization = Organization.objects.create(name=email)+ user = User.objects.create_user(email=email, password=None, first_name="signup")+ OrganizationMembership.objects.create(organization=organization, user=user)+ OrganizationEnrichmentFetch.objects.create(organization=organization, provider="harmonic", payload=_PAYLOAD)+ return user, OrganizationEnrichment.objects.create(organization=organization, data=data)++ def _backfill(self, pha_client: MagicMock) -> None:+ with (+ patch(f"{_GATES_MODULE}.get_instance_region", return_value="US"),+ patch(f"{_COMMAND_MODULE}.get_regional_ph_client", return_value=pha_client),+ patch(f"{_COMMAND_MODULE}.read_organization_bridge_inputs", return_value=OrganizationBridgeInputs()),+ ):+ call_command("backfill_icp_fit_scores", "--delay=0")++ @parameterized.expand(+ [+ (+ "stored_signup_domain",+ "[email protected]",+ {"icp_fit_signup": {"role": "", "domain": "proton.me", "wizard_ai_sdk": True}},+ ),+ ("member_email_without_a_stored_domain", "[email protected]", {"icp_fit_flags": {"wizard_ai_sdk": True}}),+ ]+ )+ def test_clears_the_fit_of_an_org_scored_with_a_personal_email_domain(self, _name, email, saved):+ IcpScoringConfig.objects.filter(is_active=True).update(+ scoring_rules={"source": "return {'status': 'disqualified', 'score': 0, 'dq_reason': 'any'};"}+ )+ clear_lists_cache()+ user, record = self._member_org_record(+ email, {"icp_fit_status": "scored", "icp_fit_score": 75, "icp_fit_version": "v0.7", **saved}+ )+ pha_client = MagicMock()++ self._backfill(pha_client)++ record.refresh_from_db()+ assert record.data["icp_fit_status"] == "not_found"+ assert "icp_fit_score" not in record.data+ assert record.data["work_email"] is False+ assert record.data["icp_fit_signup"] == {"role": "", "domain": "proton.me", "wizard_ai_sdk": True}+ assert pha_client.group_identify.call_args.kwargs["properties"] == {"icp_fit_status": "not_found"}+ pha_client.set.assert_called_once_with(distinct_id=user.distinct_id, properties={"icp_fit_status": "not_found"})++ def test_keeps_scoring_with_the_stored_domain_after_the_member_switches_to_a_personal_email(self):+ _, record = self._member_org_record(+ "[email protected]",+ {"icp_fit_status": "scored", "icp_fit_score": 75, "icp_fit_signup": {"domain": "stripe.com"}},+ )+ pha_client = MagicMock()++ self._backfill(pha_client)++ record.refresh_from_db()+ assert record.data["icp_fit_signup"]["domain"] == "stripe.com"+ assert "work_email" not in record.data+ pha_client.set.assert_not_called()+def test_policy_change_stops_an_old_backfill_before_it_overwrites_a_new_score(self):record = self._record({})next_config = IcpScoringConfig.objects.create(diff --git a/products/growth/backend/tests/test_enrichment_gates.py b/products/growth/backend/tests/test_enrichment_gates.pyindex 3fccbacf9967..42847c23b1cf 100644--- a/products/growth/backend/tests/test_enrichment_gates.py+++ b/products/growth/backend/tests/test_enrichment_gates.py@@ -41,10 +41,19 @@ class TestEnrichmentGates(BaseTest):assert resolve_signup_identity(str(organization.id)) == SignupIdentitySkip(reason="signup_user_left")- def test_resolve_signup_identity_with_a_generic_email_is_unusable(self):- organization = self._org_with_member("[email protected]")+ @parameterized.expand(+ [+ ("generic_provider", "[email protected]"),+ ("privacy_provider", "[email protected]"),+ ("reserved_domain", "[email protected]"),+ ("mixed_case_address_saved_before_normalization", "[email protected]"),+ ]+ )+ def test_resolve_signup_identity_without_a_work_email_is_unusable(self, _name, email):+ organization = self._org_with_member(email)+ User.objects.filter(id=organization.memberships.get().user_id).update(email=email)- assert resolve_signup_identity(str(organization.id)) == SignupIdentitySkip(reason="no_usable_member")+ assert resolve_signup_identity(str(organization.id)) == SignupIdentitySkip(reason="not_work_email")def test_resolve_signup_identity_with_a_work_email_returns_a_lowercased_identity(self):organization = self._org_with_member("[email protected]")