: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
refactor(growth): deprecate two finished enrichment workflow patches (#108613)
Matt Brookera8daee35002b
diff --git a/products/growth/backend/temporal/signup_enrichment/reenrichment.py b/products/growth/backend/temporal/signup_enrichment/reenrichment.pyindex 8ef5c32c6690..ff7dd630de3e 100644--- a/products/growth/backend/temporal/signup_enrichment/reenrichment.py+++ b/products/growth/backend/temporal/signup_enrichment/reenrichment.py@@ -361,13 +361,14 @@ class IcpReenrichmentSweepWorkflow(PostHogWorkflow):failed += 1summary = SweepRunSummary(selected=len(candidates), attempted=attempted, matched=matched, failed=failed)+ # Keep this call until no execution that recorded this patch through workflow.patched() can+ # replay, including closed executions inside namespace retention. Their replays fail without it.+ workflow.deprecate_patch("icp-sweep-run-summary-2026-08")# Keep analytics I/O in an activity so workflow replay remains deterministic.- # Patched so an execution recorded before this activity existed still replays.- if workflow.patched("icp-sweep-run-summary-2026-08"):- await workflow.execute_activity(- report_sweep_run_activity,- summary,- start_to_close_timeout=dt.timedelta(seconds=30),- retry_policy=RetryPolicy(maximum_attempts=2),- )+ await workflow.execute_activity(+ report_sweep_run_activity,+ summary,+ start_to_close_timeout=dt.timedelta(seconds=30),+ retry_policy=RetryPolicy(maximum_attempts=2),+ )return dataclasses.asdict(summary)diff --git a/products/growth/backend/temporal/signup_enrichment/tests/signup_enrichment_pre_recheck_child_history.json b/products/growth/backend/temporal/signup_enrichment/tests/signup_enrichment_pre_recheck_child_history.jsondeleted file mode 100644index 5b6e089ac8c3..000000000000--- a/products/growth/backend/temporal/signup_enrichment/tests/signup_enrichment_pre_recheck_child_history.json+++ /dev/null@@ -1,373 +0,0 @@-{- "events": [- {- "eventId": "1",- "eventTime": "2026-09-14T13:13:32.883Z",- "eventType": "EVENT_TYPE_WORKFLOW_EXECUTION_STARTED",- "workflowExecutionStartedEventAttributes": {- "workflowType": {- "name": "signup-enrichment"- },- "taskQueue": {- "name": "signup-enrichment-replay-fixture"- },- "input": {- "payloads": [- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "eyJkaXN0aW5jdF9pZCI6ImQxIiwiZG9tYWluIjoic3RyaXBlLmNvbSIsImdlb2lwX2NvdW50cnlfY29kZSI6bnVsbCwib3JnYW5pemF0aW9uX2lkIjoib3JnLTEiLCJyb2xlX2F0X29yZ2FuaXphdGlvbiI6bnVsbH0="- }- ]- },- "workflowExecutionTimeout": "315360000s",- "workflowRunTimeout": "315360000s",- "workflowTaskTimeout": "10s",- "originalExecutionRunId": "7288506c-1456-4c3c-8c8c-48efb2a06502",- "identity": "replay-fixture",- "firstExecutionRunId": "7288506c-1456-4c3c-8c8c-48efb2a06502",- "attempt": 1,- "firstWorkflowTaskBackoff": "0s",- "priority": {}- }- },- {- "eventId": "2",- "eventTime": "2026-09-14T13:13:32.883Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_SCHEDULED",- "workflowTaskScheduledEventAttributes": {- "taskQueue": {- "name": "signup-enrichment-replay-fixture"- },- "startToCloseTimeout": "10s",- "attempt": 1- }- },- {- "eventId": "3",- "eventTime": "2026-09-14T13:13:32.884Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_STARTED",- "workflowTaskStartedEventAttributes": {- "scheduledEventId": "2",- "identity": "replay-fixture",- "historySizeBytes": "449"- }- },- {- "eventId": "4",- "eventTime": "2026-09-14T13:13:32.899Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_COMPLETED",- "workflowTaskCompletedEventAttributes": {- "scheduledEventId": "2",- "identity": "replay-fixture",- "binaryChecksum": "91e100948e480e0d64f712d2808dc815",- "sdkMetadata": {- "coreUsedFlags": [2, 1, 3],- "sdkName": "temporal-python",- "sdkVersion": "1.24.0"- },- "meteringMetadata": {}- }- },- {- "eventId": "5",- "eventTime": "2026-09-14T13:13:32.899Z",- "eventType": "EVENT_TYPE_ACTIVITY_TASK_SCHEDULED",- "activityTaskScheduledEventAttributes": {- "activityId": "1",- "activityType": {- "name": "enrich_signup_organization_activity"- },- "taskQueue": {- "name": "signup-enrichment-replay-fixture",- "kind": "TASK_QUEUE_KIND_NORMAL"- },- "header": {},- "input": {- "payloads": [- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "eyJkaXN0aW5jdF9pZCI6ImQxIiwiZG9tYWluIjoic3RyaXBlLmNvbSIsImdlb2lwX2NvdW50cnlfY29kZSI6bnVsbCwib3JnYW5pemF0aW9uX2lkIjoib3JnLTEiLCJyb2xlX2F0X29yZ2FuaXphdGlvbiI6bnVsbH0="- },- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "ZmFsc2U="- },- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "ZmFsc2U="- }- ]- },- "scheduleToCloseTimeout": "315360000s",- "scheduleToStartTimeout": "315360000s",- "startToCloseTimeout": "90s",- "heartbeatTimeout": "0s",- "workflowTaskCompletedEventId": "3",- "retryPolicy": {- "initialInterval": "5s",- "backoffCoefficient": 2.0,- "maximumInterval": "500s",- "maximumAttempts": 3- },- "priority": {}- }- },- {- "eventId": "6",- "eventTime": "2026-09-14T13:13:32.899Z",- "eventType": "EVENT_TYPE_ACTIVITY_TASK_STARTED",- "activityTaskStartedEventAttributes": {- "scheduledEventId": "5",- "identity": "replay-fixture",- "attempt": 1- }- },- {- "eventId": "7",- "eventTime": "2026-09-14T13:13:32.902Z",- "eventType": "EVENT_TYPE_ACTIVITY_TASK_COMPLETED",- "activityTaskCompletedEventAttributes": {- "result": {- "payloads": [- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "eyJmaWVsZHNfZmlsbGVkIjowLCJtYXRjaGVkIjpmYWxzZX0="- }- ]- },- "scheduledEventId": "5",- "startedEventId": "6",- "identity": "replay-fixture"- }- },- {- "eventId": "8",- "eventTime": "2026-09-14T13:13:32.902Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_SCHEDULED",- "workflowTaskScheduledEventAttributes": {- "taskQueue": {- "name": "signup-enrichment-replay-fixture"- },- "startToCloseTimeout": "10s",- "attempt": 1- }- },- {- "eventId": "9",- "eventTime": "2026-09-14T13:13:32.902Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_STARTED",- "workflowTaskStartedEventAttributes": {- "scheduledEventId": "8",- "identity": "replay-fixture",- "historySizeBytes": "1176"- }- },- {- "eventId": "10",- "eventTime": "2026-09-14T13:13:32.904Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_COMPLETED",- "workflowTaskCompletedEventAttributes": {- "scheduledEventId": "8",- "identity": "replay-fixture",- "binaryChecksum": "91e100948e480e0d64f712d2808dc815",- "sdkMetadata": {},- "meteringMetadata": {}- }- },- {- "eventId": "11",- "eventTime": "2026-09-14T13:13:32.904Z",- "eventType": "EVENT_TYPE_TIMER_STARTED",- "timerStartedEventAttributes": {- "timerId": "1",- "startToFireTimeout": "14400s",- "workflowTaskCompletedEventId": "9"- }- },- {- "eventId": "12",- "eventTime": "2026-09-14T17:13:32.904Z",- "eventType": "EVENT_TYPE_TIMER_FIRED",- "timerFiredEventAttributes": {- "timerId": "1",- "startedEventId": "11"- }- },- {- "eventId": "13",- "eventTime": "2026-09-14T17:13:32.904Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_SCHEDULED",- "workflowTaskScheduledEventAttributes": {- "taskQueue": {- "name": "signup-enrichment-replay-fixture"- },- "startToCloseTimeout": "10s",- "attempt": 1- }- },- {- "eventId": "14",- "eventTime": "2026-09-14T17:13:32.904Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_STARTED",- "workflowTaskStartedEventAttributes": {- "scheduledEventId": "13",- "identity": "replay-fixture",- "historySizeBytes": "1412"- }- },- {- "eventId": "15",- "eventTime": "2026-09-14T17:13:32.904Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_COMPLETED",- "workflowTaskCompletedEventAttributes": {- "scheduledEventId": "13",- "identity": "replay-fixture",- "binaryChecksum": "91e100948e480e0d64f712d2808dc815",- "sdkMetadata": {},- "meteringMetadata": {}- }- },- {- "eventId": "16",- "eventTime": "2026-09-14T17:13:32.904Z",- "eventType": "EVENT_TYPE_ACTIVITY_TASK_SCHEDULED",- "activityTaskScheduledEventAttributes": {- "activityId": "2",- "activityType": {- "name": "enrich_signup_organization_activity"- },- "taskQueue": {- "name": "signup-enrichment-replay-fixture",- "kind": "TASK_QUEUE_KIND_NORMAL"- },- "header": {},- "input": {- "payloads": [- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "eyJkaXN0aW5jdF9pZCI6ImQxIiwiZG9tYWluIjoic3RyaXBlLmNvbSIsImdlb2lwX2NvdW50cnlfY29kZSI6bnVsbCwib3JnYW5pemF0aW9uX2lkIjoib3JnLTEiLCJyb2xlX2F0X29yZ2FuaXphdGlvbiI6bnVsbH0="- },- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "dHJ1ZQ=="- },- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "ZmFsc2U="- }- ]- },- "scheduleToCloseTimeout": "315360000s",- "scheduleToStartTimeout": "315360000s",- "startToCloseTimeout": "90s",- "heartbeatTimeout": "0s",- "workflowTaskCompletedEventId": "14",- "retryPolicy": {- "initialInterval": "5s",- "backoffCoefficient": 2.0,- "maximumInterval": "500s",- "maximumAttempts": 3- },- "priority": {}- }- },- {- "eventId": "17",- "eventTime": "2026-09-14T17:13:32.904Z",- "eventType": "EVENT_TYPE_ACTIVITY_TASK_STARTED",- "activityTaskStartedEventAttributes": {- "scheduledEventId": "16",- "identity": "replay-fixture",- "attempt": 1- }- },- {- "eventId": "18",- "eventTime": "2026-09-14T17:13:32.905Z",- "eventType": "EVENT_TYPE_ACTIVITY_TASK_COMPLETED",- "activityTaskCompletedEventAttributes": {- "result": {- "payloads": [- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "eyJmaWVsZHNfZmlsbGVkIjozLCJtYXRjaGVkIjp0cnVlfQ=="- }- ]- },- "scheduledEventId": "16",- "startedEventId": "17",- "identity": "replay-fixture"- }- },- {- "eventId": "19",- "eventTime": "2026-09-14T17:13:32.905Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_SCHEDULED",- "workflowTaskScheduledEventAttributes": {- "taskQueue": {- "name": "signup-enrichment-replay-fixture"- },- "startToCloseTimeout": "10s",- "attempt": 1- }- },- {- "eventId": "20",- "eventTime": "2026-09-14T17:13:32.905Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_STARTED",- "workflowTaskStartedEventAttributes": {- "scheduledEventId": "19",- "identity": "replay-fixture",- "historySizeBytes": "2107"- }- },- {- "eventId": "21",- "eventTime": "2026-09-14T17:13:32.906Z",- "eventType": "EVENT_TYPE_WORKFLOW_TASK_COMPLETED",- "workflowTaskCompletedEventAttributes": {- "scheduledEventId": "19",- "identity": "replay-fixture",- "binaryChecksum": "91e100948e480e0d64f712d2808dc815",- "sdkMetadata": {},- "meteringMetadata": {}- }- },- {- "eventId": "22",- "eventTime": "2026-09-14T17:13:32.906Z",- "eventType": "EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED",- "workflowExecutionCompletedEventAttributes": {- "result": {- "payloads": [- {- "metadata": {- "encoding": "anNvbi9wbGFpbg=="- },- "data": "eyJmaWVsZHNfZmlsbGVkIjozLCJtYXRjaGVkIjp0cnVlfQ=="- }- ]- },- "workflowTaskCompletedEventId": "20"- }- }- ]-}diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py b/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.pyindex 8e4861b99b58..44385d03676f 100644--- a/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py@@ -1,7 +1,5 @@import uuid-import asyncioimport datetime as dt-from pathlib import Pathimport pytestfrom unittest.mock import AsyncMock, MagicMock, patch@@ -9,7 +7,7 @@ from unittest.mock import AsyncMock, MagicMock, patchfrom temporalio.api.enums.v1 import EventTypefrom temporalio.client import WorkflowExecutionStatus, WorkflowHistoryfrom temporalio.testing import WorkflowEnvironment-from temporalio.worker import Replayer, UnsandboxedWorkflowRunner, Worker+from temporalio.worker import UnsandboxedWorkflowRunner, Workerfrom posthog.dataclasses import frozen@@ -31,9 +29,6 @@ _TASK_QUEUE = "signup-enrichment-test-queue"_EVALUATED_AT = dt.datetime(2026, 9, 14, 12, 0, tzinfo=dt.UTC)_RECHECK_ID = f"signup-enrichment-recheck-{_INPUTS.organization_id}"_TEST_RECHECK_DELAY = dt.timedelta(milliseconds=100)-# An execution that took the un-patched path, where the recheck is a timer and a second activity-# in this same workflow, recorded against a mocked activity.-_PRE_CHILD_HISTORY = Path(__file__).parent / "signup_enrichment_pre_recheck_child_history.json"@frozen@@ -230,14 +225,3 @@ async def test_recheck_skips_deleted_organization():assert result["matched"] is Falseenrich_mock.assert_not_called()client_mock.assert_not_called()---async def test_history_recorded_before_the_recheck_child_still_replays():- history = WorkflowHistory.from_json(- "signup-enrichment-org-1", await asyncio.to_thread(_PRE_CHILD_HISTORY.read_text)- )-- await Replayer(- workflows=[SignupEnrichmentWorkflow, SignupEnrichmentRecheckWorkflow],- workflow_runner=UnsandboxedWorkflowRunner(),- ).replay_workflow(history)diff --git a/products/growth/backend/temporal/signup_enrichment/workflow.py b/products/growth/backend/temporal/signup_enrichment/workflow.pyindex 441f30f84956..83989b4a29ad 100644--- a/products/growth/backend/temporal/signup_enrichment/workflow.py+++ b/products/growth/backend/temporal/signup_enrichment/workflow.py@@ -252,19 +252,17 @@ class SignupEnrichmentWorkflow(PostHogWorkflow):first_result = await _execute_enrich_activity(inputs, is_recheck=False)first_attempt_matched = bool(first_result.get("matched"))- if workflow.patched("signup-enrichment-recheck-child-2026-09"):- try:- await workflow.start_child_workflow(- SignupEnrichmentRecheckWorkflow.run,- SignupEnrichmentRecheckInputs(signup=inputs, first_attempt_matched=first_attempt_matched),- id=f"signup-enrichment-recheck-{inputs.organization_id}",- parent_close_policy=workflow.ParentClosePolicy.ABANDON,- id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,- )- except WorkflowAlreadyStartedError:- LOGGER.bind(organization_id=inputs.organization_id).info("signup_enrichment_recheck_already_pending")- return first_result-- # Executions recorded before the recheck child existed replay through this path.- await workflow.sleep(RECHECK_DELAY)- return await _execute_enrich_activity(inputs, is_recheck=True, first_attempt_matched=first_attempt_matched)+ # Keep this call until no execution that recorded this patch through workflow.patched() can+ # replay, including closed executions inside namespace retention. Their replays fail without it.+ workflow.deprecate_patch("signup-enrichment-recheck-child-2026-09")+ try:+ await workflow.start_child_workflow(+ SignupEnrichmentRecheckWorkflow.run,+ SignupEnrichmentRecheckInputs(signup=inputs, first_attempt_matched=first_attempt_matched),+ id=f"signup-enrichment-recheck-{inputs.organization_id}",+ parent_close_policy=workflow.ParentClosePolicy.ABANDON,+ id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,+ )+ except WorkflowAlreadyStartedError:+ LOGGER.bind(organization_id=inputs.organization_id).info("signup_enrichment_recheck_already_pending")+ return first_result