: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
chore(slack_app): retire drained temporal patches (#117533)
Vojta Bartoš27547972cb49
diff --git a/posthog/temporal/ai/slack_app/posthog_code_slack_mention.py b/posthog/temporal/ai/slack_app/posthog_code_slack_mention.pyindex f1b140d410cf..58aa182f2d7e 100644--- a/posthog/temporal/ai/slack_app/posthog_code_slack_mention.py+++ b/posthog/temporal/ai/slack_app/posthog_code_slack_mention.py@@ -35,17 +35,13 @@ from posthog.temporal.common.base import PostHogWorkflowPOSTHOG_CODE_SLACK_MENTION_TIMEOUT_SECONDS = 10 * 60POSTHOG_CODE_SLACK_PICKER_TIMEOUT_MINUTES = 15-# Temporal patch IDs — arbitrary strings recorded in workflow history. Every gate below-# has drained: this workflow's longest wait is the 15-minute repo picker, and it is-# bounded at an hour as a child of the queue workflow, so the pre-patch histories are-# gone within hours of a deploy. Each branch is gone and only `deprecate_patch` remains,-# keeping the recorded marker compatible for executions in flight across the deploy that-# removes the branch. Standard two-step Temporal patch lifecycle: these calls come out in-# turn, once the histories that recorded a plain marker have drained as well.-_PATCH_ID_FOLLOWUP_MODEL_CLASSIFIER = "slack-app-followup-model-classifier-v1"-_PATCH_ID_PROJECT_ROUTE_CLASSIFIER = "slack-app-project-route-classifier-v1"-_PATCH_ID_PROJECT_ROUTE_QUOTA = "slack-app-project-route-quota-v1"-_PATCH_ID_UNTAGGED_FOLLOWUP_CONFIRMATION = "slack-untagged-followup-confirmation-v1"+# Temporal patch ID — an arbitrary string recorded in workflow history. The gate has+# drained: this workflow's longest wait is the 15-minute repo picker, and it is bounded+# at an hour as a child of the queue workflow, so the pre-patch histories are gone within+# hours of a deploy. The branch is gone and only `deprecate_patch` remains, keeping the+# recorded marker compatible for executions in flight across the deploy that removes the+# branch. Standard two-step Temporal patch lifecycle: the call comes out once the+# histories that recorded a plain marker have drained as well._PATCH_ID_MODEL_ROUTER = "slack-app-model-router-v1"@@ -128,7 +124,6 @@ class PostHogCodeSlackMentionWorkflow(PostHogWorkflow):# only interrupts someone over a message that would otherwise start work.# A confirmed run skips it — the answer is what re-dispatched this.if unconfirmed_followup:- workflow.deprecate_patch(_PATCH_ID_UNTAGGED_FOLLOWUP_CONFIRMATION)awaiting_confirmation = await _execute_posthog_code_activity(request_untagged_followup_confirmation_activity,inputs,@@ -145,7 +140,6 @@ class PostHogCodeSlackMentionWorkflow(PostHogWorkflow):# follow-up activity: one call here serves whichever path the message takes,# and recording the choice in history once stops a retry of either activity# from landing on a different model than the first attempt announced.- workflow.deprecate_patch(_PATCH_ID_FOLLOWUP_MODEL_CLASSIFIER)model_override: SlackAppModelOverride | None = await _execute_posthog_code_activity(classify_slack_app_model_override_activity,SlackAppModelOverrideInput(@@ -181,7 +175,6 @@ class PostHogCodeSlackMentionWorkflow(PostHogWorkflow):# pick its own project, because a task, its mapping and its run all belong to# one. Everything below reads the integration from `inputs`, so the switch# lands above the repo cascade. Eligibility is decided inside the activity.- workflow.deprecate_patch(_PATCH_ID_PROJECT_ROUTE_CLASSIFIER)project_route = await _execute_posthog_code_activity(classify_slack_app_project_route_activity,SlackAppProjectRouteInput(@@ -199,7 +192,6 @@ class PostHogCodeSlackMentionWorkflow(PostHogWorkflow):# resolved, not the one the message named. Without this the run spends# the thread fetch, the needs-repo classifier and possibly a discovery# sandbox before task creation refuses on the same quota.- workflow.deprecate_patch(_PATCH_ID_PROJECT_ROUTE_QUOTA)blocked = await _execute_posthog_code_activity(enforce_posthog_code_billing_quota_activity,inputs,@@ -310,20 +302,20 @@ class PostHogCodeSlackMentionWorkflow(PostHogWorkflow):repository = self._selected_repo# After repo selection, so the repository can inform the pick.- if workflow.patched(_PATCH_ID_MODEL_ROUTER):- model_override = await _execute_posthog_code_activity(- classify_slack_app_model_router_activity,- SlackAppModelRouterInput(- integration_id=inputs.integration_id,- slack_team_id=inputs.slack_team_id,- slack_user_id=slack_user_id,- user_id=user_id,- event_text=event.get("text", ""),- thread_ts=thread_ts,- repository=repository,- model_override=model_override,- ),- )+ workflow.deprecate_patch(_PATCH_ID_MODEL_ROUTER)+ model_override = await _execute_posthog_code_activity(+ classify_slack_app_model_router_activity,+ SlackAppModelRouterInput(+ integration_id=inputs.integration_id,+ slack_team_id=inputs.slack_team_id,+ slack_user_id=slack_user_id,+ user_id=user_id,+ event_text=event.get("text", ""),+ thread_ts=thread_ts,+ repository=repository,+ model_override=model_override,+ ),+ )await _execute_posthog_code_activity(create_posthog_code_task_for_repo_activity,diff --git a/posthog/temporal/ai/slack_app/slack_app_mention.py b/posthog/temporal/ai/slack_app/slack_app_mention.pyindex 68469df55be8..8f77e57c9825 100644--- a/posthog/temporal/ai/slack_app/slack_app_mention.py+++ b/posthog/temporal/ai/slack_app/slack_app_mention.py@@ -27,27 +27,12 @@ SLACK_APP_MENTION_IDLE_TIMEOUT_SECONDS = 30# stays small; old keys only matter for Slack retries, which arrive within# minutes of the original event.SLACK_APP_MENTION_MAX_PROCESSED_KEYS = 200-# Temporal runs buffered signal handlers before run() starts, so dedup state seeded in-# run() arrived too late: a redelivered Slack event signalled into the first workflow task-# missed the dedup keys and started a duplicate child workflow. Seeding happens in-# __init__, which runs first. Pre-patch histories drained long ago — these workflows-# complete after a 30 second idle timeout — so only `deprecate_patch` remains, keeping the-# recorded marker compatible for executions in flight across the deploy that removes the-# gate. Standard two-step Temporal patch lifecycle: the call comes out once the histories-# that recorded a plain marker have drained in turn.-SLACK_APP_MENTION_SEED_IN_INIT_PATCH = "slack-app-mention-seed-in-init"-# The queue awaits each child serially, so a child that never completes stalls every# later message in the conversation and the user sees nothing but an :eyes: reaction# that never resolves. The ceiling sits above any healthy run: the child's own wait# (15 minutes for the repo picker) plus its 10-minute activity timeouts stay well# inside an hour.SLACK_APP_MENTION_CHILD_EXECUTION_TIMEOUT = timedelta(hours=1)-# Bounding the child and telling the user when it dies both add workflow commands. The-# executions that replayed the unbounded, silent path are long gone; `deprecate_patch`-# only keeps their marker compatible across the deploy that removes the gate, and comes-# out on the same lifecycle as the seeding patch above.-SLACK_APP_MENTION_CHILD_TIMEOUT_PATCH = "slack-app-mention-child-timeout"def derive_slack_app_mention_workflow_id(inputs: PostHogCodeSlackMentionWorkflowInputs) -> str | None:@@ -100,7 +85,8 @@ class SlackAppMentionWorkflow(PostHogWorkflow):# iteration order stays deterministic for the continue_as_new carry-over.self._seen_keys: dict[str, None] = {}self._queue: list[PostHogCodeSlackMentionWorkflowInputs] = []- workflow.deprecate_patch(SLACK_APP_MENTION_SEED_IN_INIT_PATCH)+ # Temporal runs buffered signal handlers before run() starts, so dedup state seeded+ # in run() arrives too late and a redelivered Slack event starts a duplicate child.self._seed(inputs)def _seed(self, inputs: SlackAppMentionWorkflowInputs) -> None:@@ -190,7 +176,6 @@ class SlackAppMentionWorkflow(PostHogWorkflow):ALLOW_DUPLICATE mirrors the standalone dispatch's reuse policy forretries that outlive this instance's dedup keys."""- workflow.deprecate_patch(SLACK_APP_MENTION_CHILD_TIMEOUT_PATCH)try:# The default parent close policy (terminate) is deliberate: an# operator killing this queue means "stop this conversation", sodiff --git a/posthog/temporal/tests/ai/test_posthog_code_slack_mention_workflow.py b/posthog/temporal/tests/ai/test_posthog_code_slack_mention_workflow.pyindex 0debc837d1c7..397d382609bc 100644--- a/posthog/temporal/tests/ai/test_posthog_code_slack_mention_workflow.py+++ b/posthog/temporal/tests/ai/test_posthog_code_slack_mention_workflow.py@@ -47,11 +47,7 @@ async def test_untagged_followup_with_files_classifier_gating(text: str, expect_raise AssertionError(f"unexpected activity: {activity_fn.__name__}")- with (- # Runs outside a workflow context, where the real marker call would raise.- patch.object(posthog_code_slack_mention.workflow, "deprecate_patch"),- patch.object(posthog_code_slack_mention, "_execute_posthog_code_activity", side_effect=fake_execute_activity),- ):+ with patch.object(posthog_code_slack_mention, "_execute_posthog_code_activity", side_effect=fake_execute_activity):await workflow.run(inputs)expected = ["enforce_posthog_code_billing_quota_activity"]@@ -92,11 +88,7 @@ async def test_confirmed_untagged_followup_skips_the_classifier_and_the_prompt()return Trueraise AssertionError(f"unexpected activity: {activity_fn.__name__}")- with (- # Runs outside a workflow context, where the real marker call would raise.- patch.object(posthog_code_slack_mention.workflow, "deprecate_patch"),- patch.object(posthog_code_slack_mention, "_execute_posthog_code_activity", side_effect=fake_execute_activity),- ):+ with patch.object(posthog_code_slack_mention, "_execute_posthog_code_activity", side_effect=fake_execute_activity):await workflow.run(inputs)assert calls == [