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.

fix(experiments): register enrollment census workflow on general-purpose queue (#93449)

Juraj Majerik50348aa325ff
diff --git a/posthog/management/commands/start_temporal_worker.py b/posthog/management/commands/start_temporal_worker.py
index eb655cc43c6a..9479e05a7f01 100644
--- a/posthog/management/commands/start_temporal_worker.py
+++ b/posthog/management/commands/start_temporal_worker.py
@@ -201,6 +201,8 @@ from products.experiments.backend.temporal import (
ACTIVITIES as EXPERIMENTS_RECALCULATION_ACTIVITIES,
EXPERIMENT_CANARY_ACTIVITIES,
EXPERIMENT_CANARY_WORKFLOWS,
+ EXPERIMENT_ENROLLMENT_CENSUS_ACTIVITIES,
+ EXPERIMENT_ENROLLMENT_CENSUS_WORKFLOWS,
WORKFLOWS as EXPERIMENTS_RECALCULATION_WORKFLOWS,
)
from products.exports.backend.temporal.subscriptions import (
@@ -327,6 +329,7 @@ _task_queue_specs = [
+ SYNC_PERSON_DISTINCT_IDS_WORKFLOWS
+ EXPERIMENTS_WORKFLOWS
+ EXPERIMENT_CANARY_WORKFLOWS
+ + EXPERIMENT_ENROLLMENT_CENSUS_WORKFLOWS
+ CLEANUP_PROPDEFS_WORKFLOWS
+ BACKFILL_GROUP_TYPE_CREATED_AT_WORKFLOWS
+ INGESTION_ACCEPTANCE_TEST_WORKFLOWS
@@ -349,6 +352,7 @@ _task_queue_specs = [
+ SYNC_PERSON_DISTINCT_IDS_ACTIVITIES
+ EXPERIMENTS_ACTIVITIES
+ EXPERIMENT_CANARY_ACTIVITIES
+ + EXPERIMENT_ENROLLMENT_CENSUS_ACTIVITIES
+ CLEANUP_PROPDEFS_ACTIVITIES
+ BACKFILL_GROUP_TYPE_CREATED_AT_ACTIVITIES
+ INGESTION_ACCEPTANCE_TEST_ACTIVITIES
diff --git a/products/experiments/backend/temporal/__init__.py b/products/experiments/backend/temporal/__init__.py
index 36023b69df0e..4b7daced4363 100644
--- a/products/experiments/backend/temporal/__init__.py
+++ b/products/experiments/backend/temporal/__init__.py
@@ -23,24 +23,32 @@ EXPERIMENT_CANARY_ACTIVITIES = [
run_experiment_metric_canary,
report_experiment_canary_results,
]
+EXPERIMENT_ENROLLMENT_CENSUS_WORKFLOWS = [
+ ExperimentPrecomputeEnrollmentCensusWorkflow,
+]
+EXPERIMENT_ENROLLMENT_CENSUS_ACTIVITIES = [
+ run_experiment_enrollment_census,
+]
WORKFLOWS = [
ExperimentMetricsRecalculationWorkflow,
*EXPERIMENT_CANARY_WORKFLOWS,
- ExperimentPrecomputeEnrollmentCensusWorkflow,
+ *EXPERIMENT_ENROLLMENT_CENSUS_WORKFLOWS,
]
ACTIVITIES = [
discover_experiment_metrics,
calculate_experiment_metric_for_recalculation,
update_recalculation_progress,
*EXPERIMENT_CANARY_ACTIVITIES,
- run_experiment_enrollment_census,
+ *EXPERIMENT_ENROLLMENT_CENSUS_ACTIVITIES,
]
__all__ = [
"ACTIVITIES",
"EXPERIMENT_CANARY_ACTIVITIES",
"EXPERIMENT_CANARY_WORKFLOWS",
+ "EXPERIMENT_ENROLLMENT_CENSUS_ACTIVITIES",
+ "EXPERIMENT_ENROLLMENT_CENSUS_WORKFLOWS",
"WORKFLOWS",
"ExperimentMetricsRecalculationWorkflow",
"ExperimentPrecomputeCanaryWorkflow",
diff --git a/products/experiments/backend/temporal/test_registration.py b/products/experiments/backend/temporal/test_registration.py
index 91cba04a6ed8..71b0b9f5a289 100644
--- a/products/experiments/backend/temporal/test_registration.py
+++ b/products/experiments/backend/temporal/test_registration.py
@@ -1,5 +1,6 @@
from products.experiments.backend.temporal import ACTIVITIES, WORKFLOWS
from products.experiments.backend.temporal.canary_workflow import ExperimentPrecomputeCanaryWorkflow
+from products.experiments.backend.temporal.enrollment_census_activities import run_experiment_enrollment_census
from products.experiments.backend.temporal.enrollment_census_workflow import (
ExperimentPrecomputeEnrollmentCensusWorkflow,
)
@@ -25,3 +26,26 @@ def test_workflow_registered():
ExperimentPrecomputeCanaryWorkflow,
ExperimentPrecomputeEnrollmentCensusWorkflow,
]
+
+
+def test_scheduled_workflows_registered_on_general_purpose_queue():
+ # The canary and census schedules dispatch to the general-purpose queue; membership in
+ # the product WORKFLOWS list alone registers on the recalculation queue only. A workflow
+ # missing here leaves its scheduled runs retrying "not registered on this worker" forever.
+ # Matches the raw queue specs by content, not by queue name: in test settings all queue
+ # names alias to one value and the aggregated WORKFLOWS_DICT merges every spec together,
+ # which would make a name-based assertion pass even when the registration is missing.
+ from posthog.management.commands.start_temporal_worker import ( # noqa: PLC0415 — imports every product's temporal modules
+ _task_queue_specs,
+ )
+
+ general_purpose_specs = [
+ (workflows, activities)
+ for _queue, workflows, activities in _task_queue_specs
+ if any(workflow.__name__ == "DeletePersonsWorkflow" for workflow in workflows)
+ ]
+ assert general_purpose_specs, "general-purpose queue spec not found"
+ for workflows, activities in general_purpose_specs:
+ assert ExperimentPrecomputeCanaryWorkflow in workflows
+ assert ExperimentPrecomputeEnrollmentCensusWorkflow in workflows
+ assert run_experiment_enrollment_census in activities
diff --git a/tach.toml b/tach.toml
index 01c0ce2a2eb9..dc2c3a3753de 100644
--- a/tach.toml
+++ b/tach.toml
@@ -1049,6 +1049,8 @@ expose = [
"backend\\.temporal\\.ACTIVITIES",
"backend\\.temporal\\.EXPERIMENT_CANARY_ACTIVITIES",
"backend\\.temporal\\.EXPERIMENT_CANARY_WORKFLOWS",
+ "backend\\.temporal\\.EXPERIMENT_ENROLLMENT_CENSUS_ACTIVITIES",
+ "backend\\.temporal\\.EXPERIMENT_ENROLLMENT_CENSUS_WORKFLOWS",
"backend\\.temporal\\.WORKFLOWS",
"backend\\.temporal\\.recalculation_metrics.*",
"backend\\.temporal\\.schedule\\.create_experiment_precompute_canary_schedule",