Skip to content

: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.

feat(growth): count wizard AI-SDK evidence in ICP fit scores (#92974)

Matt Brookerc06297ade7c5
diff --git a/products/growth/backend/enrichment/bridge.py b/products/growth/backend/enrichment/bridge.py
index e1f326ea300c..ba84cc2d5611 100644
--- a/products/growth/backend/enrichment/bridge.py
+++ b/products/growth/backend/enrichment/bridge.py
@@ -14,6 +14,7 @@ simply has no properties (a real null, and Clay scored nothing for it either), w
unreachable group store raises. Scoring an org on inputs we failed to fetch would write a
silently-too-low score, which is worse than writing none — so callers degrade to writing
firmographics without a score on a raise, and get another chance at the delayed recheck.
+
"""
import dataclasses
@@ -21,6 +22,7 @@ from typing import Any, Optional
from django.conf import settings
+from posthog.dataclasses import frozen
from posthog.models.group.util import get_group_by_key
from posthog.models.group_type_mapping import get_group_types_for_project
from posthog.models.team import Team
@@ -30,6 +32,7 @@ from products.growth.backend.enrichment.writer import ORGANIZATION_GROUP_TYPE
CLAY_EST_REVENUE_PROPERTY = "icp_est_revenue"
CLAY_COMPANY_TYPE_PROPERTY = "icp_company_type"
+WIZARD_AI_SDK_DETECTED_PROPERTY = "wizard_ai_sdk_detected"
class OrganizationGroupTypeMissing(Exception):
@@ -46,6 +49,19 @@ class ClayBridgeInputs:
clay_processed: bool = False
+@frozen
+class WizardBridgeInputs:
+ """The wizard's own AI-SDK detection stamp for one org. False when the wizard never reported it."""
+
+ ai_sdk_detected: bool = False
+
+
+@frozen
+class OrganizationBridgeInputs:
+ clay: ClayBridgeInputs = dataclasses.field(default_factory=ClayBridgeInputs)
+ wizard: WizardBridgeInputs = dataclasses.field(default_factory=WizardBridgeInputs)
+
+
def _numeric(value: Any) -> Optional[float]:
# Clay writes this through capture, so it can arrive as a JSON number or a numeric string;
# JS would coerce either in a `>` comparison, Python would raise on the string.
@@ -70,12 +86,12 @@ def _organization_group_type_index(team: Team) -> int:
raise OrganizationGroupTypeMissing(f"no `{ORGANIZATION_GROUP_TYPE}` group type on project {team.project_id}")
-def read_clay_bridge_inputs(*, organization_id: str) -> ClayBridgeInputs:
- """Fetch the Clay-written score inputs for one org. Raises if the group store can't be read."""
+def read_organization_bridge_inputs(*, organization_id: str) -> OrganizationBridgeInputs:
+ """Fetch score inputs from one organization-group read. Raises when the group store cannot be read."""
# Clay only ever wrote to the US internal project, so outside US there is nothing to read —
# skip the lookup entirely instead of querying a project the bridge never touched.
if get_instance_region() != "US":
- return ClayBridgeInputs()
+ return OrganizationBridgeInputs()
# The internal project the enrichment group properties are projected onto, and the same one
# the ProductLed_Outbound consumer reads them back from (ee/billing/dags/productled_outbound_targets.py).
team = Team.objects.get(id=settings.GROWTH_ENRICHMENT_INTERNAL_TEAM_ID)
@@ -85,10 +101,15 @@ def read_clay_bridge_inputs(*, organization_id: str) -> ClayBridgeInputs:
group_key=organization_id,
)
if group is None:
- return ClayBridgeInputs()
+ return OrganizationBridgeInputs()
properties = group.group_properties or {}
- return ClayBridgeInputs(
- est_revenue=_numeric(properties.get(CLAY_EST_REVENUE_PROPERTY)),
- clay_processed=CLAY_COMPANY_TYPE_PROPERTY in properties,
+ return OrganizationBridgeInputs(
+ clay=ClayBridgeInputs(
+ est_revenue=_numeric(properties.get(CLAY_EST_REVENUE_PROPERTY)),
+ clay_processed=CLAY_COMPANY_TYPE_PROPERTY in properties,
+ ),
+ wizard=WizardBridgeInputs(
+ ai_sdk_detected=properties.get(WIZARD_AI_SDK_DETECTED_PROPERTY) is True,
+ ),
)
diff --git a/products/growth/backend/enrichment/core.py b/products/growth/backend/enrichment/core.py
index ab05efd1e620..6032a2304589 100644
--- a/products/growth/backend/enrichment/core.py
+++ b/products/growth/backend/enrichment/core.py
@@ -21,7 +21,11 @@ from posthoganalytics.client import Client
from posthog.exceptions_capture import capture_exception
from posthog.models.person.util import get_person_by_distinct_id
-from products.growth.backend.enrichment.bridge import ClayBridgeInputs, read_clay_bridge_inputs
+from products.growth.backend.enrichment.bridge import (
+ ClayBridgeInputs,
+ OrganizationBridgeInputs,
+ read_organization_bridge_inputs,
+)
from products.growth.backend.enrichment.clearbit import ClearbitInputs, clearbit_inputs_from_person_properties
from products.growth.backend.enrichment.fields import EnrichmentFields
from products.growth.backend.enrichment.fit_score import IcpFitResult, score_company
@@ -179,6 +183,7 @@ def _company_type_from_ownership(ownership_status: Optional[str]) -> Optional[st
def _score_and_mirror(
*,
organization_id: str,
+ bridge_inputs: Optional[OrganizationBridgeInputs],
fields: EnrichmentFields,
role: Optional[str],
is_recheck: bool,
@@ -193,57 +198,67 @@ def _score_and_mirror(
things: the mirror-ownership check and the Clearbit fallback for est_revenue (Clay wins when
both exist). company_type comes from Harmonic's own ownershipStatus, fetched server-side in
the same lookup as the other firmographics.
-
- Wrapped so a bridge-read or score failure degrades to no score rather than taking down the
- firmographic write below — see enrich_organization's docstring.
"""
try:
- clay = read_clay_bridge_inputs(organization_id=organization_id)
- except Exception as e:
- # A failed bridge READ is not absent bridge data: the bridge is optional input, so a
- # read failure (unresolvable internal team, transient store error) degrades to scoring
- # without it rather than costing the score entirely. Degraded-mode scores only fill a
- # gap, though — a persisted score may have been computed WITH bridge data, and a
- # bridge-less recompute would silently downgrade it.
- capture_exception(e)
- if _persisted_score_exists(organization_id):
- return None, None
- clay = ClayBridgeInputs()
-
- mirror_ok = False
- clearbit = ClearbitInputs()
- if is_recheck and distinct_id:
- mirror_ok, clearbit = _fetch_recheck_person_inputs(distinct_id)
-
- icp_score = compute_icp_score(
- IcpScoreInputs(
- employees=fields.headcount,
- # A Clay-written 0 is not information the formula can use either (_in_band is false
- # at 0 same as at None), so it must not shadow a real Clearbit band.
- est_revenue=clay.est_revenue or clearbit.est_revenue,
- role=role,
- # Clay never projects its GitHub column into PostHog, so this input is always
- # absent here — product-role orgs score 3, not 6, until v-next substitutes the
- # signup's own GitHub auth. Kept on IcpScoreInputs for formula fidelity.
- github_profile_url=None,
- company_type=_company_type_from_ownership(fields.ownership_status),
- founded_year=fields.founded_year,
- country=fields.country,
+ if bridge_inputs is None:
+ if _persisted_score_exists(organization_id):
+ return None, None
+ clay = ClayBridgeInputs()
+ else:
+ clay = bridge_inputs.clay
+
+ mirror_ok = False
+ clearbit = ClearbitInputs()
+ if is_recheck and distinct_id:
+ mirror_ok, clearbit = _fetch_recheck_person_inputs(distinct_id)
+
+ icp_score = compute_icp_score(
+ IcpScoreInputs(
+ employees=fields.headcount,
+ # A Clay-written 0 is not information the formula can use either (_in_band is false
+ # at 0 same as at None), so it must not shadow a real Clearbit band.
+ est_revenue=clay.est_revenue or clearbit.est_revenue,
+ role=role,
+ # Clay never projects its GitHub column into PostHog, so this input is always
+ # absent here — product-role orgs score 3, not 6, until v-next substitutes the
+ # signup's own GitHub auth. Kept on IcpScoreInputs for formula fidelity.
+ github_profile_url=None,
+ company_type=_company_type_from_ownership(fields.ownership_status),
+ founded_year=fields.founded_year,
+ country=fields.country,
+ )
)
- )
- mirror_distinct_id = distinct_id if mirror_ok else None
+ mirror_distinct_id = distinct_id if mirror_ok else None
+ return icp_score, mirror_distinct_id
+ except Exception as e:
+ capture_exception(e, {"organization_id": organization_id})
+ return None, None
- return icp_score, mirror_distinct_id
+
+def _read_bridge_inputs(*, organization_id: str) -> Optional[OrganizationBridgeInputs]:
+ try:
+ return read_organization_bridge_inputs(organization_id=organization_id)
+ except Exception as e:
+ capture_exception(e, {"organization_id": organization_id})
+ return None
+
+
+def _persisted_wizard_ai_sdk(*, organization_id: str) -> bool:
+ record = OrganizationEnrichment.objects.filter(organization_id=organization_id).only("data").first()
+ flags = record.data.get("icp_fit_flags") if record else None
+ return isinstance(flags, dict) and flags.get("wizard_ai_sdk") is True
def _score_fit(
*,
organization_id: str,
+ bridge_inputs: Optional[OrganizationBridgeInputs],
raw_payload: Optional[dict[str, Any]],
role: Optional[str],
domain: str,
distinct_id: Optional[str],
+ is_recheck: bool,
) -> tuple[Optional[IcpFitResult], Optional[str]]:
"""Evaluate one org under the ICP fit score.
@@ -252,6 +267,9 @@ def _score_fit(
active curated-lists row degrades to no evaluation at all (captured, never raised):
scoring against empty lists would floor three components and look like a real answer.
+ The wizard's AI-SDK stamp affects rechecks only because the wizard usually finishes
+ after the first score.
+
The fit person mirror needs no ownership guard and no person read: `icp_fit_score` is a
brand-new person key nothing else writes, so every evaluation mirrors blindly on every
attempt (unlike the clay mirror, which shares Clay's key and stays recheck-only behind
@@ -259,6 +277,14 @@ def _score_fit(
number left by an earlier scored attempt.
"""
try:
+ wizard_ai_sdk = False
+ if is_recheck:
+ if bridge_inputs is None:
+ if not _persisted_wizard_ai_sdk(organization_id=organization_id):
+ return None, None
+ wizard_ai_sdk = True
+ else:
+ wizard_ai_sdk = bridge_inputs.wizard.ai_sdk_detected
lists = load_active_lists()
if lists is None:
capture_exception(RuntimeError("icp_fit_no_active_lists: IcpScoringConfig has no active row"))
@@ -268,9 +294,9 @@ def _score_fit(
if payload is None:
payload = normalize_graphql_company(latest_matched_payload(organization_id))
- result = score_company(payload, lists=lists, role=role, domain=domain)
+ result = score_company(payload, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)
except Exception as e:
- capture_exception(e)
+ capture_exception(e, {"organization_id": organization_id})
return None, None
return result, distinct_id
@@ -345,11 +371,16 @@ async def enrich_organization(
if fallback_country:
fields = dataclasses.replace(fields, country=fallback_country)
+ bridge_inputs: Optional[OrganizationBridgeInputs] = OrganizationBridgeInputs()
+ if fields is not None or is_recheck:
+ bridge_inputs = await sync_to_async(_read_bridge_inputs)(organization_id=organization_id)
+
icp_score: Optional[int] = None
mirror_distinct_id: Optional[str] = None
if fields is not None:
icp_score, mirror_distinct_id = await sync_to_async(_score_and_mirror)(
organization_id=organization_id,
+ bridge_inputs=bridge_inputs,
fields=fields,
role=role_at_organization,
is_recheck=is_recheck,
@@ -358,10 +389,12 @@ async def enrich_organization(
fit, fit_mirror_distinct_id = await sync_to_async(_score_fit)(
organization_id=organization_id,
+ bridge_inputs=bridge_inputs,
raw_payload=lookup.raw_payload,
role=role_at_organization,
domain=domain,
distinct_id=distinct_id,
+ is_recheck=is_recheck,
)
if fields is None and fit is None:
diff --git a/products/growth/backend/enrichment/fit_score.py b/products/growth/backend/enrichment/fit_score.py
index 978f7161c470..c6cd5f8ccdc1 100644
--- a/products/growth/backend/enrichment/fit_score.py
+++ b/products/growth/backend/enrichment/fit_score.py
@@ -1,7 +1,8 @@
"""The ICP fit score — encodes the Aug 2026 "who we build for" definition.
Definitional score, not an MRR predictor: components are Traction (35), Capital (30),
-AIPilled (15), HeadcountGrowth (10), SoftwareRelevance (10), summing to 100. Spec:
+AIPilled (15), HeadcountGrowth (10), SoftwareRelevance (10), summing to 100. AIPilled
+awards its 15 points on the Harmonic AI signal OR a detected wizard AI SDK stamp. Spec:
https://posthog.com/handbook/growth/revops/icp-scoring. Weights and rules are owned by
RevOps and validated against a 382-company exemplar/customer set plus a 9.7k-signup
cohort. The curated tag and investor lists ride in versioned DB rows (see icp_lists.py);
@@ -29,7 +30,8 @@ from typing import Any, Optional
from products.growth.backend.enrichment.icp_lists import CuratedLists, norm
-SCORE_VERSION = "v0.5"
+SCORE_VERSION = "v0.6"
+AI_PILLED_POINTS = 15
STATUS_SCORED = "scored"
STATUS_INSUFFICIENT_DATA = "insufficient_data"
@@ -71,6 +73,8 @@ class IcpFitResult:
low_confidence: Optional[bool] = None
agency_flag: Optional[bool] = None
nonprofit_flag: Optional[bool] = None
+ wizard_ai_sdk: Optional[bool] = None
+ ai_pilled_source: Optional[str] = None
version: str = SCORE_VERSION
lists_version: Optional[str] = None
@@ -98,6 +102,7 @@ def score_company(
lists: CuratedLists,
role: Optional[str] = None,
domain: Optional[str] = None,
+ wizard_ai_sdk: bool = False,
) -> IcpFitResult:
"""Score one company payload (REST shape — see module docstring) against the fit rules.
@@ -109,6 +114,10 @@ def score_company(
know the answer regardless of enrichment); a missing/unmatched payload is not_found; a
matched but empty-shell profile is insufficient_data (no numeric score — "no data yet"
must never read as "evaluated and low"); everything else is scored 0–100.
+
+ `wizard_ai_sdk` earns AIPilled's 15 points on its own, same as the Harmonic signal:
+ either one fires the full award, and `ai_pilled_source` records "harmonic" / "wizard" /
+ "both" so which source fired stays visible.
"""
if (role or "").strip().lower() == "student":
return IcpFitResult(status=STATUS_DISQUALIFIED, score=0, dq_reason="role=student", lists_version=lists.version)
@@ -191,11 +200,13 @@ def score_company(
capital = min(30, capital + (10 if quality else 0))
description = payload.get("description") or payload.get("short_description") or ""
- # AI tags, AI language in the description, or a .ai signup domain all qualify in full.
- ai_pilled = (
- 15
- if (tags & lists.ai_positive or (description and AI_DESC.search(description)) or (domain or "").endswith(".ai"))
- else 0
+ has_ai_tag = bool(tags & lists.ai_positive)
+ has_ai_description = bool(description and AI_DESC.search(description))
+ has_ai_domain = (domain or "").endswith(".ai")
+ harmonic_ai = has_ai_tag or has_ai_description or has_ai_domain
+ ai_pilled = AI_PILLED_POINTS if (harmonic_ai or wizard_ai_sdk) else 0
+ ai_pilled_source = (
+ "both" if harmonic_ai and wizard_ai_sdk else "harmonic" if harmonic_ai else "wizard" if wizard_ai_sdk else None
)
headcount_growth = (
@@ -240,5 +251,7 @@ def score_company(
low_confidence=coverage <= 1,
agency_flag=bool(tags & AGENCY_TAGS),
nonprofit_flag=bool(tags & NONPROFIT_TAGS),
+ wizard_ai_sdk=wizard_ai_sdk,
+ ai_pilled_source=ai_pilled_source,
lists_version=lists.version,
)
diff --git a/products/growth/backend/enrichment/writer.py b/products/growth/backend/enrichment/writer.py
index 7aab4d918fc7..718b844c98d7 100644
--- a/products/growth/backend/enrichment/writer.py
+++ b/products/growth/backend/enrichment/writer.py
@@ -87,6 +87,8 @@ def _fit_record_writes(fit: IcpFitResult) -> tuple[dict[str, Any], list[str]]:
"low_confidence": fit.low_confidence,
"agency_flag": fit.agency_flag,
"nonprofit_flag": fit.nonprofit_flag,
+ "wizard_ai_sdk": fit.wizard_ai_sdk,
+ "ai_pilled_source": fit.ai_pilled_source,
}.items()
if value is not None
}
diff --git a/products/growth/backend/management/commands/backfill_icp_fit_scores.py b/products/growth/backend/management/commands/backfill_icp_fit_scores.py
index c8ab59cef8aa..e6e189410c8b 100644
--- a/products/growth/backend/management/commands/backfill_icp_fit_scores.py
+++ b/products/growth/backend/management/commands/backfill_icp_fit_scores.py
@@ -27,14 +27,19 @@ import json
import time
import statistics
from pathlib import Path
-from typing import Any, Optional
+from typing import Any, Literal, Optional
from django.core.management.base import BaseCommand, CommandError, CommandParser
+from posthoganalytics.client import Client
+
+from posthog.exceptions_capture import capture_exception
+from posthog.models.organization import Organization
from posthog.ph_client import get_regional_ph_client
from posthog.utils import get_instance_region
from products.growth.backend.enrichment import icp_lists as icp_lists_module
+from products.growth.backend.enrichment.bridge import read_organization_bridge_inputs
from products.growth.backend.enrichment.core import latest_matched_payload
from products.growth.backend.enrichment.fit_score import IcpFitResult, score_company
from products.growth.backend.enrichment.harmonic_adapter import normalize_graphql_company
@@ -47,7 +52,9 @@ from products.growth.backend.enrichment.icp_lists import (
)
from products.growth.backend.enrichment.labels import recent_latest_fetches_qs, signup_domain_for_organization
from products.growth.backend.enrichment.writer import write_organization_enrichment
-from products.growth.backend.models import OrganizationEnrichment
+from products.growth.backend.models import OrganizationEnrichment, OrganizationEnrichmentFetch
+
+_BackfillOutcome = Literal["written", "skipped_org_gone", "skipped_wizard_unavailable"]
class _Stats:
@@ -112,6 +119,39 @@ def _lists_from_csvs(tags_csv: str, investors_csv: str) -> CuratedLists:
)
+def _wizard_ai_sdk_for_backfill(*, organization_id: str, record: Optional[OrganizationEnrichment]) -> Optional[bool]:
+ flags = record.data.get("icp_fit_flags") if record else None
+ persisted = isinstance(flags, dict) and flags.get("wizard_ai_sdk") is True
+ try:
+ return read_organization_bridge_inputs(organization_id=organization_id).wizard.ai_sdk_detected
+ except Exception as e:
+ capture_exception(e, {"organization_id": organization_id})
+ return True if persisted else None
+
+
+def _score_backfill_fetch(
+ *, fetch: OrganizationEnrichmentFetch, organization: Organization, lists: CuratedLists
+) -> Optional[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
+
+ payload = _normalize_any_payload(fetch.payload)
+ if payload is None:
+ payload = _normalize_any_payload(latest_matched_payload(str(fetch.organization_id)))
+
+ wizard_ai_sdk = _wizard_ai_sdk_for_backfill(organization_id=str(fetch.organization_id), record=record)
+ if wizard_ai_sdk is None:
+ return None
+ return score_company(
+ payload,
+ lists=lists,
+ role=role,
+ domain=domain,
+ wizard_ai_sdk=wizard_ai_sdk,
+ )
+
+
def _iter_parity_payloads(path: str):
"""Yield (domain, payload) from a JSONL(.gz) file or a directory of per-domain JSON files."""
p = Path(path)
@@ -171,6 +211,40 @@ class Command(BaseCommand):
)
return lists
+ def _process_fetch(
+ self,
+ *,
+ fetch: OrganizationEnrichmentFetch,
+ lists: CuratedLists,
+ stats: _Stats,
+ pha_client: Client,
+ dry_run: bool,
+ delay: float,
+ ) -> _BackfillOutcome:
+ try:
+ organization = fetch.organization
+ except Exception:
+ organization = None
+ if organization is None:
+ return "skipped_org_gone"
+
+ result = _score_backfill_fetch(fetch=fetch, organization=organization, lists=lists)
+ if result is None:
+ return "skipped_wizard_unavailable"
+ stats.add(result)
+
+ if dry_run:
+ self.stdout.write(f"would write {fetch.organization_id}: {result.status} score={result.score}")
+ return "written"
+
+ write_organization_enrichment(
+ organization_id=str(fetch.organization_id), fields=None, pha_client=pha_client, fit=result
+ )
+ self.stdout.write(f"wrote {fetch.organization_id}: {result.status} score={result.score}")
+ if delay:
+ time.sleep(delay)
+ return "written"
+
def _run_backfill(self, options: dict[str, Any]) -> None:
if get_instance_region() not in ("US", "EU"):
raise CommandError("Signup enrichment is Cloud-only; refusing to backfill in this region")
@@ -193,50 +267,34 @@ class Command(BaseCommand):
if limit is not None:
fetches = fetches[:limit]
+ outcomes: dict[_BackfillOutcome, int] = {
+ "written": 0,
+ "skipped_org_gone": 0,
+ "skipped_wizard_unavailable": 0,
+ }
try:
- considered = written = skipped_org_gone = 0
+ considered = 0
for fetch in fetches.iterator():
considered += 1
- try:
- organization = fetch.organization
- except Exception:
- organization = None
- if organization is None:
- # db_constraint=False allows orphan archive rows after org deletion; a score
- # write (and its group projection) for a dead org is pointless.
- skipped_org_gone += 1
- continue
-
- 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
-
- payload = _normalize_any_payload(fetch.payload)
- if payload is None:
- # Same lookback the live path uses: the latest fetch alone can be a flaky
- # miss even when an earlier one matched.
- payload = _normalize_any_payload(latest_matched_payload(str(fetch.organization_id)))
- result = score_company(payload, lists=lists, role=role, domain=domain)
- stats.add(result)
-
- if dry_run:
- written += 1
- self.stdout.write(f"would write {fetch.organization_id}: {result.status} score={result.score}")
- continue
-
- write_organization_enrichment(
- organization_id=str(fetch.organization_id), fields=None, pha_client=pha_client, fit=result
+ outcome = self._process_fetch(
+ fetch=fetch,
+ lists=lists,
+ stats=stats,
+ pha_client=pha_client,
+ dry_run=dry_run,
+ delay=delay,
)
- written += 1
- self.stdout.write(f"wrote {fetch.organization_id}: {result.status} score={result.score}")
- if delay:
- time.sleep(delay)
+ outcomes[outcome] += 1
finally:
pha_client.shutdown()
verb = "would write" if dry_run else "wrote"
self.stdout.write(
- self.style.SUCCESS(f"considered {considered}, {verb} {written}, skipped_org_gone {skipped_org_gone}")
+ self.style.SUCCESS(
+ f"considered {considered}, {verb} {outcomes['written']}, "
+ f"skipped_org_gone {outcomes['skipped_org_gone']}, "
+ f"skipped_wizard_unavailable {outcomes['skipped_wizard_unavailable']}"
+ )
)
if options["stats"]:
self.stdout.write(stats.summary())
diff --git a/products/growth/backend/temporal/signup_enrichment/reenrichment.py b/products/growth/backend/temporal/signup_enrichment/reenrichment.py
index bde7f44bddf4..d8322ec6b513 100644
--- a/products/growth/backend/temporal/signup_enrichment/reenrichment.py
+++ b/products/growth/backend/temporal/signup_enrichment/reenrichment.py
@@ -1,4 +1,4 @@
-"""Scheduled re-enrichment sweep for orgs whose V0.5 evaluation produced no score.
+"""Scheduled re-enrichment sweep for orgs whose fit evaluation produced no score.
Measured on prod-us 2026-08-24 over 14,848 scored orgs: 40.8% of matched signups are
empty-shell Harmonic profiles (insufficient_data) and 0.9% aren't matched at all (not_found)
diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_activity.py b/products/growth/backend/temporal/signup_enrichment/tests/test_activity.py
index 1174638b16cd..37d4d010e34e 100644
--- a/products/growth/backend/temporal/signup_enrichment/tests/test_activity.py
+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_activity.py
@@ -51,7 +51,7 @@ async def test_emits_success_signal_and_snapshot_on_match():
snapshot_arg = snapshot_mock.call_args.kwargs["snapshot"]
assert snapshot_arg.company_type == "STARTUP"
assert snapshot_arg.icp_fit_score == 77
- assert snapshot_arg.icp_fit_version == "v0.5"
+ assert snapshot_arg.icp_fit_version == "v0.6"
assert snapshot_arg.icp_fit_status == "scored"
# Launch signal emitted with success + the filled field keys + the fit status.
signal = next(c for c in pha_client.capture.call_args_list if c.kwargs["event"] == "signup_enrichment_completed")
diff --git a/products/growth/backend/tests/test_backfill_icp_fit_scores.py b/products/growth/backend/tests/test_backfill_icp_fit_scores.py
new file mode 100644
index 000000000000..9a21cc4d63f8
--- /dev/null
+++ b/products/growth/backend/tests/test_backfill_icp_fit_scores.py
@@ -0,0 +1,107 @@
+from posthog.test.base import BaseTest
+from unittest.mock import MagicMock, patch
+
+from django.core.management import call_command
+
+from parameterized import parameterized
+
+from products.growth.backend.enrichment.bridge import OrganizationBridgeInputs, WizardBridgeInputs
+from products.growth.backend.enrichment.icp_lists import clear_lists_cache
+from products.growth.backend.models import IcpScoringConfig, OrganizationEnrichment, OrganizationEnrichmentFetch
+
+_COMMAND_MODULE = "products.growth.backend.management.commands.backfill_icp_fit_scores"
+
+_PAYLOAD = {
+ "id": "company-1",
+ "company_type": "STARTUP",
+ "headcount": 12,
+ "funding": {"funding_total": None, "investors": []},
+ "tags_v2": [],
+ "traction_metrics": {},
+}
+
+
+class TestBackfillIcpFitScores(BaseTest):
+ def setUp(self):
+ super().setUp()
+ IcpScoringConfig.objects.create(
+ version="test-lists-1",
+ tags=[],
+ quality_investors=[],
+ is_active=True,
+ )
+ clear_lists_cache()
+
+ def tearDown(self):
+ clear_lists_cache()
+ super().tearDown()
+
+ def _record(self, data):
+ OrganizationEnrichmentFetch.objects.create(
+ organization=self.organization,
+ provider="harmonic",
+ payload=_PAYLOAD,
+ )
+ return OrganizationEnrichment.objects.create(
+ organization=self.organization,
+ data=data,
+ )
+
+ @parameterized.expand(
+ [
+ (
+ "live_stamp",
+ OrganizationBridgeInputs(wizard=WizardBridgeInputs(ai_sdk_detected=True)),
+ ),
+ ("group_read_failure", RuntimeError("group store down")),
+ ]
+ )
+ def test_wizard_score_survives_a_backfill(self, _name, bridge_result):
+ record = self._record(
+ {
+ "icp_fit_score": 15,
+ "icp_fit_flags": {"wizard_ai_sdk": True, "ai_pilled_source": "wizard"},
+ "icp_fit_version": "v0.6",
+ }
+ )
+ pha_client = MagicMock()
+ bridge_patch_kwargs = (
+ {"side_effect": bridge_result} if isinstance(bridge_result, Exception) else {"return_value": bridge_result}
+ )
+
+ with (
+ patch(f"{_COMMAND_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", **bridge_patch_kwargs),
+ patch(f"{_COMMAND_MODULE}.capture_exception") as capture_mock,
+ ):
+ call_command("backfill_icp_fit_scores", "--delay=0")
+
+ if isinstance(bridge_result, Exception):
+ capture_mock.assert_called_once()
+ else:
+ capture_mock.assert_not_called()
+ record.refresh_from_db()
+ assert record.data["icp_fit_score"] == 15
+ assert record.data["icp_fit_flags"]["wizard_ai_sdk"] is True
+ assert record.data["icp_fit_flags"]["ai_pilled_source"] == "wizard"
+
+ def test_group_read_failure_skips_a_record_without_persisted_wizard_evidence(self):
+ record = self._record({"signup_role": "engineering"})
+ pha_client = MagicMock()
+
+ with (
+ patch(f"{_COMMAND_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",
+ side_effect=RuntimeError("group store down"),
+ ),
+ patch(f"{_COMMAND_MODULE}.capture_exception") as capture_mock,
+ ):
+ call_command("backfill_icp_fit_scores", "--delay=0")
+
+ capture_mock.assert_called_once()
+ record.refresh_from_db()
+ assert record.data == {"signup_role": "engineering"}
+ pha_client.group_identify.assert_not_called()
diff --git a/products/growth/backend/tests/test_enrichment_bridge.py b/products/growth/backend/tests/test_enrichment_bridge.py
index 5e738906ab88..bf88e226ac47 100644
--- a/products/growth/backend/tests/test_enrichment_bridge.py
+++ b/products/growth/backend/tests/test_enrichment_bridge.py
@@ -7,8 +7,10 @@ from posthog.models.group.group import Group
from products.growth.backend.enrichment.bridge import (
ClayBridgeInputs,
+ OrganizationBridgeInputs,
OrganizationGroupTypeMissing,
- read_clay_bridge_inputs,
+ WizardBridgeInputs,
+ read_organization_bridge_inputs,
)
_ORGANIZATION_GROUP_TYPES = [{"group_type": "organization", "group_type_index": 3}]
@@ -25,44 +27,46 @@ class TestEnrichmentBridge(BaseTest):
),
patch("products.growth.backend.enrichment.bridge.get_group_by_key", return_value=group) as get_group,
):
- return read_clay_bridge_inputs(organization_id="org-1"), get_group
+ return read_organization_bridge_inputs(organization_id="org-1"), get_group
@parameterized.expand([("eu", "EU"), ("self_hosted", None)])
def test_non_us_regions_skip_the_lookup_entirely(self, _name, region):
inputs, get_group = self._read(Group(group_properties={"icp_company_type": "private"}), region=region)
- assert inputs == ClayBridgeInputs()
+ assert inputs == OrganizationBridgeInputs()
get_group.assert_not_called()
- def test_reads_clays_columns_off_the_organization_group(self):
+ def test_reads_score_inputs_off_the_organization_group(self):
group = Group(
group_properties={
"icp_est_revenue": 25_000_000,
"icp_company_type": "private",
"icp_employees": 750,
+ "wizard_ai_sdk_detected": True,
}
)
inputs, get_group = self._read(group)
- assert inputs == ClayBridgeInputs(est_revenue=25_000_000.0, clay_processed=True)
+ assert inputs == OrganizationBridgeInputs(
+ clay=ClayBridgeInputs(est_revenue=25_000_000.0, clay_processed=True),
+ wizard=WizardBridgeInputs(ai_sdk_detected=True),
+ )
assert get_group.call_args.kwargs["group_type_index"] == 3
assert get_group.call_args.kwargs["group_key"] == "org-1"
def test_org_with_no_group_yet_reads_as_all_absent(self):
inputs, _ = self._read(None)
- assert inputs == ClayBridgeInputs()
- assert inputs.clay_processed is False
+ assert inputs == OrganizationBridgeInputs()
def test_group_without_clays_columns_reads_as_all_absent(self):
inputs, _ = self._read(Group(group_properties={"icp_employees": 750}))
- assert inputs == ClayBridgeInputs()
- assert inputs.clay_processed is False
+ assert inputs.clay == ClayBridgeInputs()
def test_clay_processed_true_even_when_the_company_type_value_itself_is_unusable(self):
# clay_processed is a raw key-presence check, not the coerced value — Clay fills this
# column on essentially every row it writes, so presence alone is the ran/didn't-run signal.
inputs, _ = self._read(Group(group_properties={"icp_company_type": 12}))
- assert inputs.clay_processed is True
+ assert inputs.clay.clay_processed is True
@parameterized.expand(
[
@@ -79,7 +83,11 @@ class TestEnrichmentBridge(BaseTest):
)
def test_est_revenue_coercion(self, _name, raw, expected):
inputs, _ = self._read(Group(group_properties={"icp_est_revenue": raw}))
- assert inputs.est_revenue == expected
+ assert inputs.clay.est_revenue == expected
+
+ def test_non_boolean_wizard_value_reads_as_false(self):
+ inputs, _ = self._read(Group(group_properties={"wizard_ai_sdk_detected": "true"}))
+ assert inputs.wizard == WizardBridgeInputs()
def test_missing_organization_group_type_raises_rather_than_reading_as_absent(self):
with self.assertRaises(OrganizationGroupTypeMissing):
diff --git a/products/growth/backend/tests/test_enrichment_core.py b/products/growth/backend/tests/test_enrichment_core.py
index b94e78ec62fb..e52e2b383f5d 100644
--- a/products/growth/backend/tests/test_enrichment_core.py
+++ b/products/growth/backend/tests/test_enrichment_core.py
@@ -6,7 +6,7 @@ from unittest.mock import MagicMock, patch
from asgiref.sync import async_to_sync
from parameterized import parameterized
-from products.growth.backend.enrichment.bridge import ClayBridgeInputs
+from products.growth.backend.enrichment.bridge import ClayBridgeInputs, OrganizationBridgeInputs, WizardBridgeInputs
from products.growth.backend.enrichment.core import _MISS_PAYLOAD, enrich_organization
from products.growth.backend.enrichment.fields import EnrichmentFields
from products.growth.backend.enrichment.icp_lists import clear_lists_cache
@@ -103,6 +103,7 @@ class TestEnrichmentCore(BaseTest):
is_recheck: bool = False,
role_at_organization=None,
clay=None,
+ wizard=None,
pha_client=None,
distinct_id=None,
person=None,
@@ -111,11 +112,23 @@ class TestEnrichmentCore(BaseTest):
provider=None,
):
person_patch_kwargs = {"side_effect": person} if isinstance(person, Exception) else {"return_value": person}
- clay_patch_kwargs = (
- {"side_effect": clay} if isinstance(clay, Exception) else {"return_value": clay or ClayBridgeInputs()}
+ bridge_error = None
+ if isinstance(clay, Exception):
+ bridge_error = clay
+ elif isinstance(wizard, Exception):
+ bridge_error = wizard
+ bridge_patch_kwargs = (
+ {"side_effect": bridge_error}
+ if bridge_error is not None
+ else {
+ "return_value": OrganizationBridgeInputs(
+ clay=clay or ClayBridgeInputs(),
+ wizard=wizard or WizardBridgeInputs(),
+ )
+ }
)
with (
- patch("products.growth.backend.enrichment.core.read_clay_bridge_inputs", **clay_patch_kwargs),
+ patch("products.growth.backend.enrichment.core.read_organization_bridge_inputs", **bridge_patch_kwargs),
patch("products.growth.backend.enrichment.core.get_person_by_distinct_id", **person_patch_kwargs),
):
return async_to_sync(enrich_organization)(
@@ -312,7 +325,10 @@ class TestEnrichmentCore(BaseTest):
def test_first_attempt_does_not_look_up_the_person(self):
fields = EnrichmentFields(headcount=750, country="US", founded_year=2021)
with (
- patch("products.growth.backend.enrichment.core.read_clay_bridge_inputs", return_value=ClayBridgeInputs()),
+ patch(
+ "products.growth.backend.enrichment.core.read_organization_bridge_inputs",
+ return_value=OrganizationBridgeInputs(),
+ ),
patch("products.growth.backend.enrichment.core.get_person_by_distinct_id") as person_mock,
):
async_to_sync(enrich_organization)(
@@ -389,7 +405,7 @@ class TestEnrichmentCore(BaseTest):
assert outcome.fit is not None and outcome.fit.score == 100
record = OrganizationEnrichment.objects.get(organization=self.organization)
assert record.data["icp_fit_score"] == 100
- assert record.data["icp_fit_version"] == "v0.5"
+ assert record.data["icp_fit_version"] == "v0.6"
assert record.data["icp_fit_status"] == "scored"
assert record.data["icp_fit_lists_version"] == "test-lists-1"
assert record.data["icp_fit_components"] == {
@@ -411,7 +427,10 @@ class TestEnrichmentCore(BaseTest):
pha_client = MagicMock()
fields = EnrichmentFields(company_type="STARTUP")
with (
- patch("products.growth.backend.enrichment.core.read_clay_bridge_inputs", return_value=ClayBridgeInputs()),
+ patch(
+ "products.growth.backend.enrichment.core.read_organization_bridge_inputs",
+ return_value=OrganizationBridgeInputs(),
+ ),
patch("products.growth.backend.enrichment.core.get_person_by_distinct_id") as person_mock,
):
async_to_sync(enrich_organization)(
@@ -426,7 +445,7 @@ class TestEnrichmentCore(BaseTest):
person_mock.assert_not_called()
pha_client.set.assert_called_once_with(
distinct_id="signer-distinct-id",
- properties={"icp_fit_score": 100, "icp_fit_version": "v0.5", "icp_fit_status": "scored"},
+ properties={"icp_fit_score": 100, "icp_fit_version": "v0.6", "icp_fit_status": "scored"},
)
def test_student_role_disqualifies_fit_regardless_of_the_payload(self):
@@ -493,7 +512,7 @@ class TestEnrichmentCore(BaseTest):
record = OrganizationEnrichment.objects.get(organization=self.organization)
assert record.data == {
"icp_fit_status": "not_found",
- "icp_fit_version": "v0.5",
+ "icp_fit_version": "v0.6",
"icp_fit_lists_version": "test-lists-1",
}
@@ -548,6 +567,123 @@ class TestEnrichmentCore(BaseTest):
assert record.data["icp_score"] == 12
assert "icp_fit_score" not in record.data
+ def test_recheck_reads_the_wizard_bridge(self):
+ fields = EnrichmentFields(company_type="STARTUP", headcount=12)
+ payload = _company(description="We sell shoes", tagsV2=[{"displayValue": "S25", "type": "YC_BATCH"}])
+ with patch(
+ "products.growth.backend.enrichment.core.read_organization_bridge_inputs",
+ return_value=OrganizationBridgeInputs(wizard=WizardBridgeInputs(ai_sdk_detected=True)),
+ ) as bridge_mock:
+ outcome = async_to_sync(enrich_organization)(
+ organization_id=str(self.organization.id),
+ domain="acme.com",
+ provider=_FakeProvider(ProviderLookup(fields=fields, raw_payload=payload)),
+ pha_client=MagicMock(),
+ is_recheck=True,
+ )
+
+ bridge_mock.assert_called_once_with(organization_id=str(self.organization.id))
+ assert outcome.fit is not None
+ assert outcome.fit.wizard_ai_sdk is True
+ assert outcome.fit.ai_pilled_source == "wizard"
+ assert (outcome.fit.components or {}).get("ai_pilled") == 15
+
+ def test_recheck_reads_the_organization_group_once_for_both_scores(self):
+ fields = EnrichmentFields(company_type="STARTUP", headcount=12)
+ group = MagicMock(group_properties={"wizard_ai_sdk_detected": True})
+ with (
+ patch("products.growth.backend.enrichment.bridge.get_instance_region", return_value="US"),
+ patch("products.growth.backend.enrichment.bridge.Team.objects.get", return_value=self.team),
+ patch(
+ "products.growth.backend.enrichment.bridge.get_group_types_for_project",
+ return_value=[{"group_type": "organization", "group_type_index": 3}],
+ ),
+ patch("products.growth.backend.enrichment.bridge.get_group_by_key", return_value=group) as get_group,
+ ):
+ outcome = async_to_sync(enrich_organization)(
+ organization_id=str(self.organization.id),
+ domain="acme.com",
+ provider=_FakeProvider(ProviderLookup(fields=fields, raw_payload=_company())),
+ pha_client=MagicMock(),
+ is_recheck=True,
+ )
+
+ assert outcome.fit is not None
+ assert outcome.fit.wizard_ai_sdk is True
+ get_group.assert_called_once()
+
+ def test_first_attempt_ignores_the_wizard_bridge_input(self):
+ fields = EnrichmentFields(company_type="STARTUP", headcount=12)
+ with patch(
+ "products.growth.backend.enrichment.core.read_organization_bridge_inputs",
+ return_value=OrganizationBridgeInputs(wizard=WizardBridgeInputs(ai_sdk_detected=True)),
+ ):
+ outcome = async_to_sync(enrich_organization)(
+ organization_id=str(self.organization.id),
+ domain="acme.ai",
+ provider=_FakeProvider(ProviderLookup(fields=fields, raw_payload=_company())),
+ pha_client=MagicMock(),
+ is_recheck=False,
+ )
+
+ assert outcome.fit is not None
+ assert outcome.fit.wizard_ai_sdk is False
+ assert outcome.fit.ai_pilled_source == "harmonic"
+
+ def test_wizard_bridge_read_failure_skips_a_fit_score_without_persisted_evidence(self):
+ fields = EnrichmentFields(company_type="STARTUP", headcount=12)
+ with (
+ patch(
+ "products.growth.backend.enrichment.core.read_organization_bridge_inputs",
+ side_effect=RuntimeError("group store down"),
+ ),
+ patch("products.growth.backend.enrichment.core.capture_exception") as capture_mock,
+ ):
+ outcome = async_to_sync(enrich_organization)(
+ organization_id=str(self.organization.id),
+ domain="acme.ai",
+ provider=_FakeProvider(ProviderLookup(fields=fields, raw_payload=_company())),
+ pha_client=MagicMock(),
+ is_recheck=True,
+ )
+
+ capture_mock.assert_called_once()
+ assert outcome.fit is None
+
+ def test_wizard_bridge_read_failure_preserves_persisted_wizard_evidence(self):
+ record = OrganizationEnrichment.objects.create(
+ organization=self.organization,
+ data={
+ "icp_fit_score": 15,
+ "icp_fit_flags": {"wizard_ai_sdk": True, "ai_pilled_source": "wizard"},
+ "icp_fit_version": "v0.6",
+ },
+ )
+ fields = EnrichmentFields(company_type="STARTUP", headcount=12)
+ payload = _company(description="We sell shoes", tagsV2=[{"displayValue": "S25", "type": "YC_BATCH"}])
+ with (
+ patch(
+ "products.growth.backend.enrichment.core.read_organization_bridge_inputs",
+ side_effect=RuntimeError("group store down"),
+ ),
+ patch("products.growth.backend.enrichment.core.capture_exception"),
+ ):
+ outcome = async_to_sync(enrich_organization)(
+ organization_id=str(self.organization.id),
+ domain="acme.com",
+ provider=_FakeProvider(ProviderLookup(fields=fields, raw_payload=payload)),
+ pha_client=MagicMock(),
+ is_recheck=True,
+ )
+
+ assert outcome.fit is not None
+ assert outcome.fit.wizard_ai_sdk is True
+ assert outcome.fit.ai_pilled_source == "wizard"
+ assert (outcome.fit.components or {}).get("ai_pilled") == 15
+ record.refresh_from_db()
+ assert record.data["icp_fit_flags"]["wizard_ai_sdk"] is True
+ assert record.data["icp_fit_flags"]["ai_pilled_source"] == "wizard"
+
def test_scoreless_fit_mirrors_status_only(self):
pha_client = MagicMock()
fields = EnrichmentFields(company_type="STARTUP")
diff --git a/products/growth/backend/tests/test_enrichment_writer.py b/products/growth/backend/tests/test_enrichment_writer.py
index 57336f968c6c..08c25c6fc38f 100644
--- a/products/growth/backend/tests/test_enrichment_writer.py
+++ b/products/growth/backend/tests/test_enrichment_writer.py
@@ -98,7 +98,7 @@ class TestEnrichmentWriter(BaseTest):
# The two families never share a key.
assert record.data["icp_score"] == 9
assert record.data["icp_fit_score"] == 72
- assert record.data["icp_fit_version"] == "v0.5"
+ assert record.data["icp_fit_version"] == "v0.6"
assert record.data["icp_fit_status"] == "scored"
assert record.data["icp_fit_lists_version"] == "lists-1"
assert record.data["icp_fit_components"]["capital"] == 30
@@ -112,9 +112,25 @@ class TestEnrichmentWriter(BaseTest):
properties = pha_client.group_identify.call_args.kwargs["properties"]
assert properties["icp_score"] == 9
assert properties["icp_fit_score"] == 72
- assert properties["icp_fit_version"] == "v0.5"
+ assert properties["icp_fit_version"] == "v0.6"
assert properties["icp_fit_status"] == "scored"
+ def test_fit_flags_record_wizard_evidence_and_ai_pilled_source(self):
+ pha_client = MagicMock()
+ write_organization_enrichment(
+ organization_id=str(self.organization.id),
+ fields=None,
+ pha_client=pha_client,
+ fit=_fit(wizard_ai_sdk=True, ai_pilled_source="both"),
+ )
+
+ record = OrganizationEnrichment.objects.get(organization=self.organization)
+ assert record.data["icp_fit_flags"]["wizard_ai_sdk"] is True
+ assert record.data["icp_fit_flags"]["ai_pilled_source"] == "both"
+ properties = pha_client.group_identify.call_args.kwargs["properties"]
+ assert "wizard_ai_sdk" not in properties
+ assert "ai_pilled_source" not in properties
+
def test_fit_only_write_carries_no_field_or_clay_keys(self):
# The fit backfill passes fields=None and no clay score: only icp_fit_* keys move.
pha_client = MagicMock()
@@ -156,7 +172,7 @@ class TestEnrichmentWriter(BaseTest):
"work_email": True,
"icp_score": 6,
"icp_fit_status": "insufficient_data",
- "icp_fit_version": "v0.5",
+ "icp_fit_version": "v0.6",
"icp_fit_lists_version": "lists-1",
}
# Group properties cannot be deleted, so only the status key is projected: pairing
@@ -212,7 +228,7 @@ class TestEnrichmentWriter(BaseTest):
)
pha_client.set.assert_called_once_with(
distinct_id="signer",
- properties={"icp_fit_score": 55, "icp_fit_version": "v0.5", "icp_fit_status": "scored"},
+ properties={"icp_fit_score": 55, "icp_fit_version": "v0.6", "icp_fit_status": "scored"},
)
pha_client.reset_mock()
diff --git a/products/growth/backend/tests/test_icp_fit_score.py b/products/growth/backend/tests/test_icp_fit_score.py
index 052b0ae3fbbe..ed402776a164 100644
--- a/products/growth/backend/tests/test_icp_fit_score.py
+++ b/products/growth/backend/tests/test_icp_fit_score.py
@@ -59,9 +59,9 @@ def _traction(
def test_version_is_stamped():
- assert SCORE_VERSION == "v0.5"
+ assert SCORE_VERSION == "v0.6"
result = score_company(_payload(), lists=LISTS)
- assert result.version == "v0.5"
+ assert result.version == "v0.6"
assert result.lists_version == "test-lists"
@@ -241,6 +241,39 @@ def test_ai_pilled_signals(_name, tags, description, domain, expected):
assert (result.components or {}).get("ai_pilled") == expected
+def test_wizard_evidence_alone_earns_the_ai_pilled_points():
+ payload = _payload(description="We sell shoes")
+ without_wizard = score_company(payload, lists=LISTS, domain="acme.com")
+ with_wizard = score_company(payload, lists=LISTS, domain="acme.com", wizard_ai_sdk=True)
+
+ assert without_wizard.score is not None and with_wizard.score == without_wizard.score + 15
+ assert (with_wizard.components or {}).get("ai_pilled") == 15
+ assert with_wizard.wizard_ai_sdk is True
+ assert with_wizard.ai_pilled_source == "wizard"
+
+
+ [
+ ("harmonic_only", [{"display_value": "Artificial Intelligence", "type": "MARKET"}], False, "harmonic", 15),
+ ("wizard_only", None, True, "wizard", 15),
+ ("both", [{"display_value": "Artificial Intelligence", "type": "MARKET"}], True, "both", 15),
+ ("neither", None, False, None, 0),
+ ]
+)
+def test_ai_pilled_source_records_which_evidence_was_present(
+ _name, tags, wizard_ai_sdk, expected_source, expected_score
+):
+ payload = _payload(description="We sell shoes")
+ if tags:
+ payload["tags_v2"] = tags
+ result = score_company(payload, lists=LISTS, domain="acme.com", wizard_ai_sdk=wizard_ai_sdk)
+
+ assert result.ai_pilled_source == expected_source
+ assert result.wizard_ai_sdk is wizard_ai_sdk
+ # "both" sources still cap at 15, never stack to 30.
+ assert (result.components or {}).get("ai_pilled") == expected_score
+
+
# ---------- headcount growth (10) ----------