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.

chore(tasks): replace dispatch flags with a setting (#119984)

Charles Vien2e7a79c21f77
diff --git a/posthog/settings/temporal.py b/posthog/settings/temporal.py
index 030df511f189..7533754c28e9 100644
--- a/posthog/settings/temporal.py
+++ b/posthog/settings/temporal.py
@@ -355,6 +355,11 @@ TASKS_DISPATCHER_RPC_TIMEOUT_SECONDS = get_from_env("TASKS_DISPATCHER_RPC_TIMEOU
TASKS_DISPATCHER_MAX_DISPATCH_AGE_SECONDS = get_from_env(
"TASKS_DISPATCHER_MAX_DISPATCH_AGE_SECONDS", 6 * 60 * 60, type_cast=int
)
+TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED: bool = get_from_env(
+ "TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED",
+ CLOUD_DEPLOYMENT in ("US", "EU"),
+ type_cast=str_to_bool,
+)
STAMPHOG_TASK_QUEUE = _set_temporal_task_queue("stamphog-task-queue")
TEST_TASK_QUEUE = _set_temporal_task_queue("test-task-queue")
BILLING_TASK_QUEUE = _set_temporal_task_queue("billing-task-queue")
diff --git a/products/posthog_ai/eval_harness/harness/lifecycle.py b/products/posthog_ai/eval_harness/harness/lifecycle.py
index 2cc5907ec928..ebac910a0768 100644
--- a/products/posthog_ai/eval_harness/harness/lifecycle.py
+++ b/products/posthog_ai/eval_harness/harness/lifecycle.py
@@ -22,11 +22,7 @@ from posthoganalytics import Posthog
from posthog.ph_client import get_client
-from products.tasks.backend.constants import (
- MCP_EXEC_SKILLS_FEATURE_FLAG,
- WORKFLOW_DISPATCH_ASYNC_FEATURE_FLAG,
- WORKFLOW_DISPATCH_RESTART_FEATURE_FLAG,
-)
+from products.tasks.backend.constants import MCP_EXEC_SKILLS_FEATURE_FLAG
from products.tasks.backend.temporal.process_task.utils import get_reasoning_effort_error
from ..engines.base import EvalEngine
@@ -74,17 +70,6 @@ from .temporal_env import (
logger = logging.getLogger(__name__)
-# Exceptions to the blanket "every flag is on" stub the run installs below. These two hand a
-# task run to `run_task_workflow_dispatcher` instead of starting its Temporal workflow inline,
-# and the harness never starts that command — so a forced-on flag leaves every case parked in
-# QUEUED, with nothing to fail it, until the case's poll budget runs out.
-FORCED_OFF_FEATURE_FLAGS = frozenset(
- {
- WORKFLOW_DISPATCH_ASYNC_FEATURE_FLAG,
- WORKFLOW_DISPATCH_RESTART_FEATURE_FLAG,
- }
-)
-
def eval_feature_enabled(
key: str, *_args: object, skill_delivery: SkillDelivery = DEFAULT_SKILL_DELIVERY, **_kwargs: object
@@ -92,7 +77,7 @@ def eval_feature_enabled(
"""Stands in for `posthoganalytics.feature_enabled` so evals exercise flagged code paths."""
if key == MCP_EXEC_SKILLS_FEATURE_FLAG:
return skill_delivery == "exec"
- return key not in FORCED_OFF_FEATURE_FLAGS
+ return True
def _git(*args: str) -> str | None:
@@ -387,6 +372,9 @@ class SandboxedEvalHarness:
# the same per-process queue lets the single eval worker serve both, and keeps
# those workflows off a dev worker the same way.
GENERAL_PURPOSE_TASK_QUEUE=temporal_task_queue(),
+ # The harness never starts run_task_workflow_dispatcher, so an outbox dispatch would
+ # leave every case parked in QUEUED until the case's poll budget runs out.
+ TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED=False,
**self.provider.settings_overrides(),
)
diff --git a/products/posthog_ai/eval_harness/test/test_sandboxed_harness.py b/products/posthog_ai/eval_harness/test/test_sandboxed_harness.py
index ac78a0b000b4..9d769aca6342 100644
--- a/products/posthog_ai/eval_harness/test/test_sandboxed_harness.py
+++ b/products/posthog_ai/eval_harness/test/test_sandboxed_harness.py
@@ -23,14 +23,10 @@ from products.posthog_ai.eval_harness.harness import lifecycle
from products.posthog_ai.eval_harness.harness.cli import SkillDelivery, parse_args
from products.posthog_ai.eval_harness.harness.context import EvalContext
from products.posthog_ai.eval_harness.harness.discovery import EvalSuite
-from products.posthog_ai.eval_harness.harness.lifecycle import SandboxedEvalHarness, eval_feature_enabled
+from products.posthog_ai.eval_harness.harness.lifecycle import SandboxedEvalHarness
from products.posthog_ai.eval_harness.harness.live_server import EvalLiveServer
from products.posthog_ai.eval_harness.harness.providers import ModalProviderStrategy, SandboxProviderStrategy
from products.posthog_ai.eval_harness.harness.reporting import ProgressReporter
-from products.tasks.backend.constants import (
- WORKFLOW_DISPATCH_ASYNC_FEATURE_FLAG,
- WORKFLOW_DISPATCH_RESTART_FEATURE_FLAG,
-)
from products.tasks.backend.facade.agents import MultiTurnSession, TurnPollResult, TurnPollTimeout
from products.tasks.backend.facade.contracts import AgentTaskRunDTO
from products.tasks.backend.temporal.process_task.activities.get_task_processing_context import TaskProcessingContext
@@ -159,17 +155,6 @@ def test_parse_args_resolves_team_setup_concurrency(
assert options.team_setup_concurrency == expected_concurrency
- [
- ("workflow dispatch async", WORKFLOW_DISPATCH_ASYNC_FEATURE_FLAG, False),
- ("workflow dispatch restart", WORKFLOW_DISPATCH_RESTART_FEATURE_FLAG, False),
- ("anything else", "tasks-modal-vm-sandbox", True),
- ]
-)
-def test_eval_feature_enabled_leaves_dispatcher_flags_off(_name: str, flag: str, expected: bool) -> None:
- assert eval_feature_enabled(flag, distinct_id="distinct-1") is expected
-
-
@pytest.mark.parametrize(
"outcome, fail_under, score, expected_exit_code",
[
diff --git a/products/tasks/backend/constants.py b/products/tasks/backend/constants.py
index 0292ce5f6d54..e105b673c813 100644
--- a/products/tasks/backend/constants.py
+++ b/products/tasks/backend/constants.py
@@ -27,9 +27,6 @@ def is_html_artifact(name: str, content_type: str) -> bool:
return mime_type == "text/html" or name.lower().endswith((".html", ".htm"))
-WORKFLOW_DISPATCH_SHADOW_FEATURE_FLAG = "tasks-workflow-dispatch-shadow"
-WORKFLOW_DISPATCH_ASYNC_FEATURE_FLAG = "tasks-workflow-dispatch-async"
-WORKFLOW_DISPATCH_RESTART_FEATURE_FLAG = "tasks-workflow-dispatch-restart"
# Shared with the MCP server (services/mcp/src/hono/constants.ts): one flag decides both whether
# the MCP serves product skills through `learn` and whether a sandbox launches without bundled skills.
MCP_EXEC_SKILLS_FEATURE_FLAG = "mcp-exec-skills"
diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.py
index 41e493959850..8e16fbd9b38c 100644
--- a/products/tasks/backend/facade/api.py
+++ b/products/tasks/backend/facade/api.py
@@ -102,11 +102,7 @@ from products.tasks.backend.constants import (
)
from products.tasks.backend.error_telemetry import truncate_error_message
from products.tasks.backend.facade.gateway import mint_private_gateway_token, revoke_private_gateway_token
-from products.tasks.backend.feature_flags import (
- get_model_access_error,
- is_workflow_dispatch_shadow_enabled,
- pi_cloud_runtime_enabled,
-)
+from products.tasks.backend.feature_flags import get_model_access_error, pi_cloud_runtime_enabled
from products.tasks.backend.github_repository_access import (
inaccessible_repositories_via_integration as _inaccessible_repositories_via_integration,
)
@@ -1713,7 +1709,7 @@ def filter_uncovered_workflow_dispatch_run_ids(candidate_ids: list[UUID]) -> lis
.values_list("task_run_id", flat=True)
)
uncovered_ids = [run_id for run_id in candidate_ids if run_id not in live_dispatch_run_ids]
- if not is_workflow_dispatch_shadow_enabled():
+ if not settings.TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED:
return uncovered_ids
runs = {
run.id: run
@@ -6662,7 +6658,6 @@ def resume_task_run_in_cloud(
return "not_found", None, None
ensure_subscription_owner(run.state, user_id)
- from products.tasks.backend.feature_flags import is_workflow_dispatch_restart_enabled # noqa: PLC0415
from products.tasks.backend.logic.services.workflow_dispatch import ( # noqa: PLC0415
RestartSnapshot,
build_restart_payload,
@@ -6670,10 +6665,7 @@ def resume_task_run_in_cloud(
)
from products.tasks.backend.models import TaskWorkflowDispatch # noqa: PLC0415
- distinct_id = run.task.created_by.distinct_id if run.task.created_by else str(run.id)
- restart_dispatch_enabled = is_workflow_dispatch_restart_enabled(
- str(run.task.team.organization_id), distinct_id or str(run.id)
- )
+ restart_dispatch_enabled = settings.TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED
logger.info(
"resume_in_cloud_called",
extra={
diff --git a/products/tasks/backend/feature_flags.py b/products/tasks/backend/feature_flags.py
index 6688c95b8528..00a861362fa4 100644
--- a/products/tasks/backend/feature_flags.py
+++ b/products/tasks/backend/feature_flags.py
@@ -12,9 +12,6 @@ from products.tasks.backend.constants import (
DEV_STACK_IMAGE_BAKE_FEATURE_FLAG,
MCP_EXEC_SKILLS_FEATURE_FLAG,
PI_CLOUD_RUNTIME_FEATURE_FLAG,
- WORKFLOW_DISPATCH_ASYNC_FEATURE_FLAG,
- WORKFLOW_DISPATCH_RESTART_FEATURE_FLAG,
- WORKFLOW_DISPATCH_SHADOW_FEATURE_FLAG,
get_required_model_flag,
)
@@ -25,48 +22,6 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
DEV_STACK_IMAGE_BAKE_DISTINCT_ID = "tasks-dev-stack-image-bake"
-WORKFLOW_DISPATCH_SHADOW_DISTINCT_ID = "tasks-workflow-dispatch-shadow"
-
-
-def is_workflow_dispatch_shadow_enabled() -> bool:
- try:
- return bool(
- posthoganalytics.feature_enabled(
- WORKFLOW_DISPATCH_SHADOW_FEATURE_FLAG,
- distinct_id=WORKFLOW_DISPATCH_SHADOW_DISTINCT_ID,
- person_properties={"region": get_instance_region() or "DEV"},
- only_evaluate_locally=True,
- send_feature_flag_events=False,
- )
- )
- except Exception:
- logger.exception("workflow_dispatch_shadow_flag_check_failed")
- return False
-
-
-def _is_workflow_dispatch_org_flag_enabled(flag: str, organization_id: str, distinct_id: str) -> bool:
- try:
- return bool(
- posthoganalytics.feature_enabled(
- flag,
- distinct_id=distinct_id,
- groups={"organization": organization_id},
- group_properties={"organization": {"id": organization_id}},
- only_evaluate_locally=True,
- send_feature_flag_events=False,
- )
- )
- except Exception:
- logger.exception("workflow_dispatch_org_flag_check_failed", extra={"flag": flag})
- return False
-
-
-def is_workflow_dispatch_async_enabled(organization_id: str, distinct_id: str) -> bool:
- return _is_workflow_dispatch_org_flag_enabled(WORKFLOW_DISPATCH_ASYNC_FEATURE_FLAG, organization_id, distinct_id)
-
-
-def is_workflow_dispatch_restart_enabled(organization_id: str, distinct_id: str) -> bool:
- return _is_workflow_dispatch_org_flag_enabled(WORKFLOW_DISPATCH_RESTART_FEATURE_FLAG, organization_id, distinct_id)
def is_task_run_stream_presence_gated(origin_product: str) -> bool:
diff --git a/products/tasks/backend/logic/services/workflow_dispatch.py b/products/tasks/backend/logic/services/workflow_dispatch.py
index 63d1c77a3f90..fb0f7c5bc512 100644
--- a/products/tasks/backend/logic/services/workflow_dispatch.py
+++ b/products/tasks/backend/logic/services/workflow_dispatch.py
@@ -5,6 +5,7 @@ from datetime import datetime, timedelta
from typing import Any, Protocol, cast
from uuid import UUID
+from django.conf import settings
from django.db import close_old_connections, transaction
from django.db.models import Count, F, Min, Q
from django.utils import timezone as django_timezone
@@ -51,12 +52,6 @@ class RestartSnapshot:
state: dict[str, Any]
-@frozen
-class WorkflowDispatchFlags:
- shadow_enabled: bool
- async_enabled: bool
-
-
class SlackThreadContextLike(Protocol):
def to_dict(self) -> dict[str, Any]: ...
@@ -472,29 +467,10 @@ def renew_leases_in_worker_thread(instance_id: str, dispatch_ids: list[Any], lea
close_old_connections()
-def evaluate_workflow_dispatch_flags(task_run: TaskRun) -> WorkflowDispatchFlags:
- from products.tasks.backend.feature_flags import (
- is_workflow_dispatch_async_enabled,
- is_workflow_dispatch_shadow_enabled,
- )
-
- distinct_id = (
- task_run.task.created_by.distinct_id
- if task_run.task.created_by and task_run.task.created_by.distinct_id
- else str(task_run.id)
- )
- organization_id = str(task_run.task.team.organization_id)
- return WorkflowDispatchFlags(
- shadow_enabled=is_workflow_dispatch_shadow_enabled(),
- async_enabled=is_workflow_dispatch_async_enabled(organization_id, distinct_id),
- )
-
-
def enqueue_or_start_workflow(
task_run: TaskRun,
*,
options: WorkflowDispatchOptions,
- precomputed_flags: WorkflowDispatchFlags | None = None,
start_workflow: Callable[..., None] | None = None,
) -> None:
if start_workflow is None:
@@ -502,13 +478,11 @@ def enqueue_or_start_workflow(
start_workflow = execute_task_processing_workflow
- flags = precomputed_flags or evaluate_workflow_dispatch_flags(task_run)
workflow_id = TaskRun.get_workflow_id(str(task_run.task_id), str(task_run.id), options.workflow_id_prefix)
if options.workflow_id_prefix:
TaskRun.update_state_atomic(task_run.id, updates={"workflow_id": workflow_id})
task_run.state = {**(task_run.state or {}), "workflow_id": workflow_id}
- dispatch_written = False
- if flags.shadow_enabled or flags.async_enabled:
+ if settings.TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED:
if transaction.get_connection().in_atomic_block:
create_dispatch(task_run, TaskWorkflowDispatch.Kind.CREATE, build_create_payload(options), workflow_id)
else:
@@ -517,8 +491,6 @@ def enqueue_or_start_workflow(
create_dispatch(
locked_run, TaskWorkflowDispatch.Kind.CREATE, build_create_payload(options), workflow_id
)
- dispatch_written = True
- if flags.async_enabled:
return
def start_synchronously() -> None:
@@ -542,8 +514,6 @@ def enqueue_or_start_workflow(
workflow_kwargs["initial_message"] = options.initial_message
if options.skip_user_check:
workflow_kwargs["skip_user_check"] = True
- if dispatch_written:
- workflow_kwargs["durable_dispatch"] = True
start_workflow(**workflow_kwargs)
execute_after_commit(start_synchronously)
diff --git a/products/tasks/backend/temporal/client.py b/products/tasks/backend/temporal/client.py
index e9e6198d2204..f867c3e3b90f 100644
--- a/products/tasks/backend/temporal/client.py
+++ b/products/tasks/backend/temporal/client.py
@@ -278,14 +278,10 @@ async def execute_task_processing_workflow_async(
prewarmed: bool = False,
workflow_id_prefix: Optional[str] = None,
initial_message: PendingFollowup | None = None,
- durable_dispatch: bool = False,
) -> None:
"""
Start the task processing workflow asynchronously. Fire-and-forget.
Use this from async contexts (e.g., within Temporal activities).
-
- ``durable_dispatch`` means an outbox row already covers this run, so a failed start
- leaves the run QUEUED for the dispatcher to retry instead of terminalizing it.
"""
logger.info(
"execute_task_processing_workflow_async_called",
@@ -359,8 +355,6 @@ async def execute_task_processing_workflow_async(
"task_processing_workflow_start_failed",
extra={"task_id": task_id, "run_id": run_id, "error": str(e)},
)
- if durable_dispatch:
- return
await _terminalize_unstarted_task_run_async(
run_id,
f"Failed to start task workflow: {e}",
@@ -381,14 +375,10 @@ def execute_task_processing_workflow(
prewarmed: bool = False,
workflow_id_prefix: Optional[str] = None,
initial_message: PendingFollowup | None = None,
- durable_dispatch: bool = False,
) -> None:
"""
Start the task processing workflow synchronously. Fire-and-forget.
Use this from sync contexts (e.g., API endpoints).
-
- ``durable_dispatch`` means an outbox row already covers this run, so a failed start
- leaves the run QUEUED for the dispatcher to retry instead of terminalizing it.
"""
# Metrics lookups stay inside the try so a failure here can't bypass terminalization and
# leave the run orphaned in QUEUED (see the async variant above).
@@ -469,8 +459,6 @@ def execute_task_processing_workflow(
"task_processing_workflow_start_failed",
extra={"task_id": task_id, "run_id": run_id, "error": str(e)},
)
- if durable_dispatch:
- return
_terminalize_unstarted_task_run(
run_id,
f"Failed to start task workflow: {e}",
diff --git a/products/tasks/backend/tests/test_workflow_dispatch.py b/products/tasks/backend/tests/test_workflow_dispatch.py
index 5ed589d18b81..799e31fdab54 100644
--- a/products/tasks/backend/tests/test_workflow_dispatch.py
+++ b/products/tasks/backend/tests/test_workflow_dispatch.py
@@ -31,7 +31,6 @@ from products.tasks.backend.facade.api import (
from products.tasks.backend.logic.services.code_usage_gate import CodeUsageStatus
from products.tasks.backend.logic.services.workflow_dispatch import (
RestartSnapshot,
- WorkflowDispatchFlags,
WorkflowDispatchOptions,
build_create_payload,
build_restart_payload,
@@ -351,20 +350,6 @@ class TestWorkflowDispatchPersistence(TestCase):
self.assertEqual(dispatch.status, TaskWorkflowDispatch.Status.DEAD)
terminalize.assert_called_once_with(str(self.task_run.id), "invalid restart payload")
- @patch("products.tasks.backend.feature_flags.is_workflow_dispatch_restart_enabled")
- def test_restart_flag_is_evaluated_before_locking_run(self, restart_enabled: Mock) -> None:
- baseline_atomic_depth = len(transaction.get_connection().atomic_blocks)
-
- def assert_outside_transaction(*_args: object) -> bool:
- self.assertEqual(len(transaction.get_connection().atomic_blocks), baseline_atomic_depth)
- return True
-
- restart_enabled.side_effect = assert_outside_transaction
-
- outcome, _, _ = resume_task_run_in_cloud(self.task_run.id, self.task_run.task_id, self.team.id, None)
-
- self.assertEqual(outcome, "already_active")
-
@parameterized.expand([(False,), (True,)])
def test_failed_restart_preserves_concurrent_state(self, use_dispatch: bool) -> None:
run = self.task_run
@@ -386,9 +371,7 @@ class TestWorkflowDispatchPersistence(TestCase):
raise RuntimeError("unavailable")
with (
- patch(
- "products.tasks.backend.feature_flags.is_workflow_dispatch_restart_enabled", return_value=use_dispatch
- ),
+ override_settings(TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED=use_dispatch),
patch("products.tasks.backend.facade.streams.reset_task_run_stream", return_value=True),
patch("products.tasks.backend.temporal.client.resume_task_in_cloud_workflow", side_effect=fail_restart),
):
@@ -520,29 +503,20 @@ class TestWorkflowDispatchPersistence(TestCase):
pending[1].refresh_from_db()
self.assertEqual(pending[1].status, TaskWorkflowDispatch.Status.PENDING)
+ @parameterized.expand([("outbox_off", False, 0), ("outbox_on", True, 1)])
@patch("products.tasks.backend.metrics.WORKFLOW_DISPATCH_MISSING_INTENT_TOTAL.inc")
- @patch("products.tasks.backend.facade.api.is_workflow_dispatch_shadow_enabled", return_value=False)
- def test_missing_intent_metric_stays_quiet_before_shadow_rollout(
- self, _shadow_enabled: Mock, increment_missing_intent: Mock
- ) -> None:
- uncovered = filter_uncovered_workflow_dispatch_run_ids([self.task_run.id])
-
- self.assertEqual(uncovered, [self.task_run.id])
- increment_missing_intent.assert_not_called()
-
- @patch("products.tasks.backend.metrics.WORKFLOW_DISPATCH_MISSING_INTENT_TOTAL.inc")
- @patch("products.tasks.backend.facade.api.is_workflow_dispatch_shadow_enabled", return_value=True)
- def test_missing_intent_counts_bare_runs_but_not_restart_rollout_gaps(
- self, _shadow_enabled: Mock, increment_missing_intent: Mock
+ def test_missing_intent_counts_bare_runs_only_with_outbox(
+ self, _name: str, outbox_enabled: bool, expected_count: int, increment_missing_intent: Mock
) -> None:
resumed_run = TaskRun.objects.create(
task=self.task_run.task, team=self.team, status=TaskRun.Status.QUEUED, state={"same_run_resume": True}
)
- uncovered = filter_uncovered_workflow_dispatch_run_ids([self.task_run.id, resumed_run.id])
+ with override_settings(TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED=outbox_enabled):
+ uncovered = filter_uncovered_workflow_dispatch_run_ids([self.task_run.id, resumed_run.id])
self.assertEqual(uncovered, [self.task_run.id, resumed_run.id])
- increment_missing_intent.assert_called_once()
+ self.assertEqual(increment_missing_intent.call_count, expected_count)
def test_deferred_start_create_and_run_persists_dispatch_marker(self) -> None:
creator_id = self.task_run.task.created_by_id
@@ -854,14 +828,13 @@ class TestWorkflowDispatchPersistence(TestCase):
@parameterized.expand(
[
- ("already_started_keeps_run_alive", WorkflowAlreadyStartedError("wf", "process-task"), False, "queued"),
- ("durable_dispatch_leaves_retry_to_dispatcher", RuntimeError("temporal down"), True, "queued"),
- ("no_durable_dispatch_terminalizes", RuntimeError("temporal down"), False, "failed"),
+ ("already_started_keeps_run_alive", WorkflowAlreadyStartedError("wf", "process-task"), "queued"),
+ ("start_failure_terminalizes", RuntimeError("temporal down"), "failed"),
]
)
@patch("products.tasks.backend.temporal.client.sync_connect")
- def test_sync_start_failure_only_terminalizes_without_durable_dispatch(
- self, _name: str, error: Exception, durable_dispatch: bool, expected_status: str, connect: Mock
+ def test_sync_start_failure_terminalizes_unless_already_started(
+ self, _name: str, error: Exception, expected_status: str, connect: Mock
) -> None:
connect.side_effect = error
@@ -870,22 +843,18 @@ class TestWorkflowDispatchPersistence(TestCase):
task_id=str(self.task_run.task_id),
run_id=str(self.task_run.id),
team_id=self.team.id,
- durable_dispatch=durable_dispatch,
)
self.task_run.refresh_from_db()
self.assertEqual(self.task_run.status, expected_status)
- def test_dispatch_facade_normalizes_slack_context_into_shadow_row(self) -> None:
+ def test_dispatch_facade_normalizes_slack_context_into_outbox_row(self) -> None:
class Context:
def to_dict(self) -> dict:
return {"channel": "C1", "thread_ts": "123.45"}
with (
- patch(
- "products.tasks.backend.logic.services.workflow_dispatch.evaluate_workflow_dispatch_flags",
- return_value=WorkflowDispatchFlags(shadow_enabled=True, async_enabled=False),
- ),
+ override_settings(TASKS_WORKFLOW_DISPATCH_OUTBOX_ENABLED=True),
patch("products.tasks.backend.temporal.client.execute_task_processing_workflow") as start,
self.captureOnCommitCallbacks(execute=True),
):
@@ -900,7 +869,7 @@ class TestWorkflowDispatchPersistence(TestCase):
row = TaskWorkflowDispatch.objects.unscoped().get(task_run=self.task_run)
self.assertEqual(row.payload["slack_thread_context"], {"channel": "C1", "thread_ts": "123.45"})
- start.assert_called_once()
+ start.assert_not_called()
def test_reconciler_excludes_covered_runs_at_any_age_unlike_the_killer_view(self) -> None:
orphan_run = TaskRun.objects.create(task=self.task_run.task, team=self.team, status=TaskRun.Status.QUEUED)