: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
feat(signals): add a self-driving task queue for the inbox ranking sweep (#108242)
posthog[bot]4c9805638e15
diff --git a/posthog/management/commands/start_temporal_worker.py b/posthog/management/commands/start_temporal_worker.pyindex 951ba9f60508..09724716d8b7 100644--- a/posthog/management/commands/start_temporal_worker.py+++ b/posthog/management/commands/start_temporal_worker.py@@ -282,6 +282,8 @@ from products.signals.backend.emission.temporal_settings import (from products.signals.backend.temporal import (ACTIVITIES as SIGNALS_PRODUCT_ACTIVITIES,WORKFLOWS as SIGNALS_PRODUCT_WORKFLOWS,+ InboxRankingScoringWorkflow,+ score_inbox_reports_activity,)from products.stamphog.backend.facade.temporal import (ACTIVITIES as STAMPHOG_ACTIVITIES,@@ -574,6 +576,13 @@ _task_queue_specs = [AUTORESEARCH_WORKFLOWS,AUTORESEARCH_ACTIVITIES,),+ # The ranking sweep also stays on the signals spec above until every environment runs a+ # self-driving fleet. Specs that share a queue name combine, so the default adds nothing.+ (+ settings.SELF_DRIVING_TASK_QUEUE,+ [InboxRankingScoringWorkflow],+ [score_inbox_reports_activity],+ ),(settings.STAMPHOG_TASK_QUEUE,STAMPHOG_WORKFLOWS,diff --git a/posthog/management/commands/test/test_start_temporal_worker.py b/posthog/management/commands/test/test_start_temporal_worker.pyindex 6a53c06e06a0..175098b4abc6 100644--- a/posthog/management/commands/test/test_start_temporal_worker.py+++ b/posthog/management/commands/test/test_start_temporal_worker.py@@ -25,6 +25,7 @@ from products.alerts.backend.facade.temporal import (SHARED_ORCHESTRATION_ACTIVITIES,SHARED_ORCHESTRATION_WORKFLOWS,)+from products.signals.backend.temporal import InboxRankingScoringWorkflow, score_inbox_reports_activityfrom products.wizard.backend.facade.temporal import (ACTIVITIES as WIZARD_ACTIVITIES,WORKFLOWS as WIZARD_WORKFLOWS,@@ -46,6 +47,7 @@ class _NotADataSyncWorkflow:),("alerts-platform-evaluation-task-queue", EVALUATION_WORKFLOWS, EVALUATION_ACTIVITIES),("alerts-platform-delivery-task-queue", DELIVERY_WORKFLOWS, DELIVERY_ACTIVITIES),+ (settings.SELF_DRIVING_TASK_QUEUE, [InboxRankingScoringWorkflow], [score_inbox_reports_activity]),],)def test_queue_registers_workflows_and_activities(diff --git a/posthog/settings/temporal.py b/posthog/settings/temporal.pyindex 17152d29ecab..6c8e147ef538 100644--- a/posthog/settings/temporal.py+++ b/posthog/settings/temporal.py@@ -316,6 +316,9 @@ LOGS_ALERTING_TASK_QUEUE = _set_temporal_task_queue("logs-alerting-task-queue")# Defaults to the general-purpose fleet so the daily coordinator always has a live worker. Deploy a# fleet polling "autoresearch-task-queue" before setting this env, or the schedule strands its runs.AUTORESEARCH_TASK_QUEUE = _set_temporal_task_queue(os.getenv("AUTORESEARCH_TASK_QUEUE", "general-purpose-task-queue"))+# Defaults to the video-export fleet, where the self-driving work runs today. Deploy a fleet polling+# "self-driving-task-queue" before setting this env, or the ranking sweep schedule strands its runs.+SELF_DRIVING_TASK_QUEUE = _set_temporal_task_queue(os.getenv("SELF_DRIVING_TASK_QUEUE", "video-export-task-queue"))# Dedicated queue: the tick becomes the scan-heavy rollup writer, and it must not# share pods with the latency-sensitive alerting workers.LOGS_VOLUME_TICK_TASK_QUEUE = _set_temporal_task_queue(diff --git a/products/signals/backend/ranking/schedule.py b/products/signals/backend/ranking/schedule.pyindex 3236644ad229..d9601a9402d4 100644--- a/products/signals/backend/ranking/schedule.py+++ b/products/signals/backend/ranking/schedule.py@@ -23,7 +23,7 @@ INBOX_RANKING_SCORING_SCHEDULE_ID = "inbox-ranking-scoring-sweep-schedule"async def create_inbox_ranking_scoring_schedule(client: Client) -> None:- """Create or update the sweep schedule on the signals task queue.+ """Create or update the sweep schedule on the self-driving task queue.The schedule exists in every environment. `INBOX_RANKING_SCORING_ENABLED` gates the work, soturning the sweep on or off needs no schedule change. SKIP on overlap: a slow tick leaves the@@ -35,7 +35,7 @@ async def create_inbox_ranking_scoring_schedule(client: Client) -> None:SCORING_WORKFLOW_NAME,asdict(ScoreInboxReportsInput()),id=INBOX_RANKING_SCORING_SCHEDULE_ID,- task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,+ task_queue=settings.SELF_DRIVING_TASK_QUEUE,execution_timeout=interval,),spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=interval)]),