: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(workflows): remove the revisions and timing-reschedule flags (#77578)
Harley Alexander6279198ace82
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.pyindex ef6cd5347ef4..4393a2c1c7d0 100644--- a/products/workflows/backend/api/hog_flow.py+++ b/products/workflows/backend/api/hog_flow.py@@ -120,11 +120,9 @@ from products.workflows.backend.services.batch_audience import (get_batch_audience_person_ids,use_workflows_batch_audience_query,)-from products.workflows.backend.services.revisions import use_workflows_revisionsfrom products.workflows.backend.services.timing_reschedule import (get_all_timing_action_ids,get_timing_reschedule_action_ids,- use_workflows_timing_reschedule,)from products.workflows.backend.services.wait_clock_conditions import find_clock_functionfrom products.workflows.backend.tasks.hog_flows import reschedule_hog_flow_timing@@ -137,15 +135,6 @@ logger = structlog.get_logger(__name__)# (nodejs/src/cdp/services/hogflows/actions/delay.ts) that throws at runtime on mismatch.DELAY_DURATION_REGEX = re.compile(r"^\d*\.?\d+[dhm]$")-# Active workflows are read-only via MCP unless the workflows-revisions flag routes edits to the-# draft (see perform_update / graph): edits can break runs already scheduled or in flight, and-# there's no revision history to roll back. Shared by the plain update path and the graph endpoint.-MCP_ACTIVE_EDIT_REJECTION = (- "Editing an active workflow isn't supported via MCP yet — changes can break runs already "- "scheduled or in flight, and there's no revision history to roll back. If you need different "- "behavior, create a new draft workflow."-)-# The content of a workflow: everything the draft cycle stages and publish promotes, and nothing# else. Metadata (name, description) and lifecycle (status) always apply to the live row. The draft# blob is a full snapshot of these fields so publish is a plain copy, not a merge.@@ -2388,9 +2377,6 @@ class DraftExistsError(exceptions.APIException):default_code = "draft_exists"-REVISIONS_DISABLED_MESSAGE = "Revision history isn't enabled for this project yet."--# The confirm token makes the publish preview structurally unskippable: only the preview mints it,# and it signs the exact draft it previewed — so a valid token proves the caller saw the impact# summary for the draft being published. Short max-age keeps the previewed counts fresh.@@ -2700,9 +2686,6 @@ class HogFlowViewSet(# injects derived fields like 'trigger' and 'billable_action_types' which would otherwise make every# status-only PATCH look like a mixed edit.route_to_draft = False- # Resolved once, before the write transaction: the flag check can hit the network and must- # not extend the select_for_update row-lock hold (same rule as _maybe_reschedule_timing_edits).- revisions_enabled = use_workflows_revisions(self.team)if self._is_mcp_request(self.request):keys = set(self.request.data.keys())has_status = "status" in keys@@ -2726,12 +2709,9 @@ class HogFlowViewSet("changes steps by id and leaves the rest of the graph untouched.")- # Content edits on an active workflow stage a draft when the revisions cycle is on for the- # team; otherwise active workflows stay read-only via MCP. Status-only PATCHes (lifecycle- # tools) pass through either way, and metadata-only edits apply live once the flag is on.+ # Content edits on an active workflow stage a draft rather than landing live. Status-only+ # PATCHes (the lifecycle tools) and metadata-only edits apply straight to the live row.if serializer.instance.status == HogFlow.State.ACTIVE and has_non_status:- if not revisions_enabled:- raise exceptions.ValidationError(MCP_ACTIVE_EDIT_REJECTION)route_to_draft = bool(keys & set(DRAFT_CONTENT_FIELDS))instance_id = serializer.instance.id@@ -2782,14 +2762,9 @@ class HogFlowViewSet(bump = Falseif before_update is not None:self._refresh_action_redirects(- serializer.instance,- before_update,- serializer.validated_data.get("actions"),- enabled=revisions_enabled,- )- bump = self._stage_revision_bump(- serializer.instance, before_update, serializer.validated_data, enabled=revisions_enabled+ serializer.instance, before_update, serializer.validated_data.get("actions"))+ bump = self._stage_revision_bump(serializer.instance, before_update, serializer.validated_data)serializer.save()if bump:assert before_update is not None@@ -2826,32 +2801,25 @@ class HogFlowViewSet(instance.id = flow_idself._report_workflow_action("hog_flow_deleted", instance, {"via": "destroy"})- def _refresh_action_redirects(- self, target: HogFlow, old: HogFlow, new_actions: Optional[list], enabled: bool- ) -> None:+ def _refresh_action_redirects(self, target: HogFlow, old: HogFlow, new_actions: Optional[list]) -> None:# Skip-forward for deleted steps: refresh the redirect map whenever a live graph write is about# to land, while both the old graph (`old`, the locked pre-write row) and the new actions are in# hand. Must run before serializer.save() so the map persists in the same write, transaction,- # and worker reload as the graph it describes. Flag-gated with the rest of the revisions cycle;- # `enabled` is the caller's pre-transaction flag evaluation so no network call runs under the lock.+ # and worker reload as the graph it describes.# No status gate: disabling a flow doesn't purge its parked runs (the worker only cancels them# if they wake while the flow is still disabled), so a step deleted during a disable/re-enable# window needs its redirect recorded just like one deleted live.- if new_actions is None or not enabled:+ if new_actions is None:returntarget.action_redirects = compute_action_redirects(old.actions or [], old.edges or [], new_actions, old.action_redirects)- def _stage_revision_bump(self, instance: HogFlow, before: HogFlow, validated_data: dict, enabled: bool) -> bool:+ def _stage_revision_bump(self, instance: HogFlow, before: HogFlow, validated_data: dict) -> bool:# Revision history: only live-content changes get a version. Compared pre-save so the bumped# version lands in the same UPDATE (and worker reload) as the content it describes. The# serializer injects derived fields (trigger, billable_action_types) into every validated# payload, so a status/metadata-only write compares equal here and stays unversioned.- # `enabled` is the caller's pre-transaction flag evaluation — the flag check can hit the- # network and must not run under the select_for_update lock.- if not enabled:- return Falseraw_old = snapshot_flow_content(before)raw_new = {**raw_old,@@ -2921,19 +2889,11 @@ class HogFlowViewSet(# Authorize + team-scope via the normal lookup, then re-read FOR UPDATE inside the transaction.instance = self.get_object()- # Resolved before the write transaction: the flag check can hit the network and must not- # extend the select_for_update row-lock hold.- revisions_enabled = use_workflows_revisions(self.team)-with transaction.atomic():# nosemgrep: idor-lookup-without-team (re-fetch of already-authorized instance, locked for update)locked = HogFlow.objects.select_for_update().get(pk=instance.pk)- route_to_draft = False- if self._is_mcp_request(request) and locked.status == HogFlow.State.ACTIVE:- if not revisions_enabled:- raise exceptions.ValidationError(MCP_ACTIVE_EDIT_REJECTION)- route_to_draft = True+ route_to_draft = self._is_mcp_request(request) and locked.status == HogFlow.State.ACTIVE# Optimistic concurrency, mirroring perform_update: the graph endpoint is the only MCP# path that writes graph content, so it carries the base_updated_at staleness contract.@@ -2970,12 +2930,8 @@ class HogFlowViewSet(if route_to_draft:self._write_draft(locked, locked, serializer.validated_data)else:- self._refresh_action_redirects(- locked, before_update, serializer.validated_data.get("actions"), enabled=revisions_enabled- )- bump = self._stage_revision_bump(- locked, before_update, serializer.validated_data, enabled=revisions_enabled- )+ self._refresh_action_redirects(locked, before_update, serializer.validated_data.get("actions"))+ bump = self._stage_revision_bump(locked, before_update, serializer.validated_data)# save() mutates and returns `locked` in place, so it's the saved HogFlow from here on.serializer.save()if bump:@@ -3018,18 +2974,10 @@ class HogFlowViewSet(# Authorize + team-scope via the normal lookup, then re-read FOR UPDATE inside the transaction.instance = self.get_object()- # Resolved before the write transaction: the flag check can hit the network and must not- # extend the select_for_update row-lock hold.- revisions_enabled = use_workflows_revisions(self.team)-- # A doomed request must fail here, before the expensive render below, not under the lock.- # The locked section re-checks and stays authoritative if the status flips in between.- if self._is_mcp_request(request) and instance.status == HogFlow.State.ACTIVE and not revisions_enabled:- raise exceptions.ValidationError(MCP_ACTIVE_EDIT_REJECTION)-- # Rendering is a synchronous Unlayer HTTP call, so it also runs before the transaction,- # against the unlocked row. Draft routing is predicted the same way the locked section- # decides it; if the routing or the design moves before the lock, the apply conflicts.+ # Rendering is a synchronous Unlayer HTTP call, so it runs before the transaction, against the+ # unlocked row — it must not extend the select_for_update hold. Draft routing is predicted the+ # same way the locked section decides it; if the routing or the design moves before the lock,+ # the apply conflicts.rendered: Optional[_RenderedActionEmailDesign] = Noneif operations:predicts_draft = self._is_mcp_request(request) and instance.status == HogFlow.State.ACTIVE@@ -3043,11 +2991,7 @@ class HogFlowViewSet(# nosemgrep: idor-lookup-without-team (re-fetch of already-authorized instance, locked for update)locked = HogFlow.objects.select_for_update().get(pk=instance.pk)- route_to_draft = False- if self._is_mcp_request(request) and locked.status == HogFlow.State.ACTIVE:- if not revisions_enabled:- raise exceptions.ValidationError(MCP_ACTIVE_EDIT_REJECTION)- route_to_draft = True+ route_to_draft = self._is_mcp_request(request) and locked.status == HogFlow.State.ACTIVE# Same staleness contract as /graph: draft edits race against other draft edits, so the# baseline is the draft's timestamp once one exists.@@ -3078,9 +3022,7 @@ class HogFlowViewSet(if route_to_draft:self._write_draft(locked, locked, serializer.validated_data)else:- bump = self._stage_revision_bump(- locked, before_update, serializer.validated_data, enabled=revisions_enabled- )+ bump = self._stage_revision_bump(locked, before_update, serializer.validated_data)# save() mutates and returns `locked` in place, so it's the saved HogFlow from here on.serializer.save()if bump:@@ -3110,10 +3052,10 @@ class HogFlowViewSet(Called wherever the LIVE config changes - a direct save (the builder path, where saveis go-live), the graph endpoint, or publish - and never for draft writes, which don't- touch what runs execute. Deliberately called AFTER the writing transaction commits:- the feature-flag check can hit the network, and must not extend the select_for_update- row-lock hold. on_commit outside an atomic block runs the enqueue immediately, and in- tests (where an outer transaction wraps the request) it defers to that commit.+ touch what runs execute. Deliberately called AFTER the writing transaction, so the diff and+ the enqueue never extend the select_for_update row-lock hold. on_commit outside an atomic+ block runs the enqueue immediately, and in tests (where an outer transaction wraps the+ request) it defers to that commit."""if not before or after.status != HogFlow.State.ACTIVE:return@@ -3127,8 +3069,6 @@ class HogFlowViewSet(action_ids = get_timing_reschedule_action_ids(before.actions, after.actions)if not action_ids:return- if not use_workflows_timing_reschedule(self.team):- returnteam_id = self.team_idhog_flow_id = str(after.id)transaction.on_commit(@@ -3223,9 +3163,6 @@ class HogFlowViewSet(def publish(self, request: Request, *args, **kwargs):# Promote the staged draft to the live config. Two-step by design: a call without confirm only# echoes impact (how many runs are in flight), so callers — especially agents — never publish blind.- if not use_workflows_revisions(self.team):- raise exceptions.ValidationError("Publishing drafts isn't enabled for this project yet.")-param_serializer = HogFlowPublishRequestSerializer(data=request.data)param_serializer.is_valid(raise_exception=True)confirm = param_serializer.validated_data["confirm"]@@ -3287,12 +3224,8 @@ class HogFlowViewSet(# recompiles bytecode — a stored blob is never trusted to be execution-ready.serializer = self.get_serializer(locked, data=dict(locked.draft), partial=True)serializer.is_valid(raise_exception=True)- # enabled=True: the flag was already checked (and required) at the top of this method,- # before the transaction — re-evaluating it here would put a network call under the lock.- self._refresh_action_redirects(- locked, before_update, serializer.validated_data.get("actions"), enabled=True- )- bump = self._stage_revision_bump(locked, before_update, serializer.validated_data, enabled=True)+ self._refresh_action_redirects(locked, before_update, serializer.validated_data.get("actions"))+ bump = self._stage_revision_bump(locked, before_update, serializer.validated_data)# save() runs update(), which recovers the draft's secrets (from the merged live+draft# encrypted maps) and re-splits them into the live encrypted_inputs column. The draft's own# secret column is then cleared alongside the draft.@@ -3324,9 +3257,6 @@ class HogFlowViewSet(@action(detail=True, methods=["POST"])def discard_draft(self, request: Request, *args, **kwargs):# Throw away the staged draft. Idempotent: discarding when nothing is staged is a no-op.- if not use_workflows_revisions(self.team):- raise exceptions.ValidationError("Drafts aren't enabled for this project yet.")-instance = self.get_object()with transaction.atomic():# nosemgrep: idor-lookup-without-team (re-fetch of already-authorized instance, locked for update)@@ -3351,8 +3281,6 @@ class HogFlowViewSet(def revisions(self, request: Request, *args, **kwargs):# Version history: one snapshot per live-content change, newest first. Content is fetched# per-version via the detail endpoint — the list stays light.- if not use_workflows_revisions(self.team):- raise exceptions.ValidationError(REVISIONS_DISABLED_MESSAGE)instance = self.get_object()queryset = HogFlowRevision.objects.filter(hog_flow=instance).order_by("-version").select_related("created_by")page = self.paginate_queryset(queryset)@@ -3364,8 +3292,6 @@ class HogFlowViewSet()@action(detail=True, methods=["GET"], url_path=r"revisions/(?P<version>\d+)")def revision_detail(self, request: Request, version: Optional[str] = None, *args, **kwargs):- if not use_workflows_revisions(self.team):- raise exceptions.ValidationError(REVISIONS_DISABLED_MESSAGE)instance = self.get_object()try:revision = HogFlowRevision.objects.get(hog_flow=instance, version=int(version or 0))@@ -3385,8 +3311,6 @@ class HogFlowViewSet(# Rollback (or roll-forward) = copy the revision's content into the draft, then go through# the normal publish preview + confirm. Nothing here touches the live config, so the impact# of the rollback is always previewed and confirmed like any other publish.- if not use_workflows_revisions(self.team):- raise exceptions.ValidationError(REVISIONS_DISABLED_MESSAGE)param_serializer = HogFlowRevisionRestoreRequestSerializer(data=request.data)param_serializer.is_valid(raise_exception=True)diff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.pyindex b7cb4f51c9e1..91f05453cbdc 100644--- a/products/workflows/backend/api/test/test_hog_flow.py+++ b/products/workflows/backend/api/test/test_hog_flow.py@@ -52,7 +52,6 @@ class _StubAccountAudienceProvider:return self.group_type-_REVISIONS_FLAG_PATH = "products.workflows.backend.api.hog_flow.use_workflows_revisions"_SECRET_TEMPLATE_ID = "template-secret-webhook"@@ -1378,17 +1377,6 @@ class TestHogFlowAPI(APIBaseTest):assert activate.status_code == 200, activate.json()return flow_id- def test_mcp_cannot_modify_active_workflow(self):- # Active workflows are read-only via MCP for now — editing risks breaking already-scheduled runs.- flow_id = self._create_active_hog_flow()- response = self.client.patch(- f"/api/projects/{self.team.id}/hog_flows/{flow_id}",- {"name": "Renamed via MCP"},- HTTP_X_POSTHOG_CLIENT="mcp",- )- assert response.status_code == 400, response.json()- assert "active workflow isn't supported via MCP" in response.json()["detail"]-@parameterized.expand([("disable_to_draft", "draft"), ("archive", "archived")])def test_mcp_can_disable_active_workflow(self, _name, target_status):flow_id = self._create_active_hog_flow()@@ -1611,12 +1599,6 @@ class TestHogFlowAPI(APIBaseTest):response = self._patch_graph(flow_id, [])assert response.status_code == 400, response.json()- def test_graph_mcp_cannot_edit_active_workflow(self):- flow_id = self._create_active_hog_flow()- response = self._patch_graph(flow_id, [{"op": "update_action", "id": "action_1", "patch": {"name": "x"}}])- assert response.status_code == 400, response.json()- assert "active workflow isn't supported via MCP" in response.json()["detail"]-def test_graph_non_mcp_can_edit_active_workflow(self):flow_id = self._create_active_hog_flow()response = self.client.patch(@@ -4074,8 +4056,7 @@ class TestHogFlowSecretInputs(APIBaseTest):flow = HogFlow.objects.get(id=flow_id)assert flow.encrypted_inputs["action_1"]["api_key"]["value"] == "SUPER-SECRET"- @patch(_REVISIONS_FLAG_PATH, return_value=True)- def test_publish_promotes_draft_secret_to_live_without_wiping(self, _flag):+ def test_publish_promotes_draft_secret_to_live_without_wiping(self):flow_id = self._create()assert (self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"status": "active"}).status_code@@ -4157,8 +4138,7 @@ class TestHogFlowSecretInputs(APIBaseTest):assert res.status_code == 200, res.json()return res- @patch(_REVISIONS_FLAG_PATH, return_value=True)- def test_activation_keeps_secret_stripped_from_live_actions(self, _flag):+ def test_activation_keeps_secret_stripped_from_live_actions(self):# Activating a draft re-validates its actions (recovering secrets); the live actions blob must# stay stripped, with the secret only in encrypted_inputs.flow_id = self._create()@@ -4171,8 +4151,7 @@ class TestHogFlowSecretInputs(APIBaseTest):assert "api_key" not in db_inputsassert flow.encrypted_inputs["action_1"]["api_key"]["value"] == "SUPER-SECRET"- @patch(_REVISIONS_FLAG_PATH, return_value=True)- def test_restore_reattaches_live_secret_not_historical(self, _flag):+ def test_restore_reattaches_live_secret_not_historical(self):flow_id = self._create()assert (self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"status": "active"}).status_code@@ -4240,8 +4219,7 @@ class TestHogFlowSecretInputs(APIBaseTest):assert response.status_code == 400, response.json()assert "Duplicate action id" in str(response.json())- @patch(_REVISIONS_FLAG_PATH, return_value=True)- def test_noop_resave_of_secret_flow_does_not_bump_revision(self, _flag):+ def test_noop_resave_of_secret_flow_does_not_bump_revision(self):# Resending the masked graph a GET returned (api_key as {"secret": true}) must be a true no-op:# validation recovers the secret back into actions before the strip, so the version-bump compare# has to normalize both sides secret-free or every such save spuriously bumps the version.@@ -4334,8 +4312,7 @@ class TestHogFlowSecretInputs(APIBaseTest):assert row["trigger"]["inputs"]["api_key"] == {"secret": True}assert "TRIGGER-SECRET" not in json.dumps(listing)- @patch(_REVISIONS_FLAG_PATH, return_value=True)- def test_legacy_plaintext_secret_stripped_from_revision_snapshot(self, _flag):+ def test_legacy_plaintext_secret_stripped_from_revision_snapshot(self):# A row written before encryption shipped still has a plaintext secret in `actions`. The first# tracked live edit bootstraps a revision of that prior state, which must be stripped - not carry# the plaintext forward into history.@@ -4367,7 +4344,7 @@ class TestHogFlowSecretInputs(APIBaseTest):edges=[{"from": "trigger_node", "to": "action_1", "type": "continue"}],)- # A web live edit (flag on) bumps the version and bootstraps a revision of the pre-edit state.+ # A web live edit bumps the version and bootstraps a revision of the pre-edit state.changed_action = {"id": "action_1","name": "action_1",diff --git a/products/workflows/backend/api/test/test_hog_flow_action_email.py b/products/workflows/backend/api/test/test_hog_flow_action_email.pyindex e22922124a31..2be1680a75bc 100644--- a/products/workflows/backend/api/test/test_hog_flow_action_email.py+++ b/products/workflows/backend/api/test/test_hog_flow_action_email.py@@ -14,7 +14,6 @@ from products.workflows.backend.models.hog_flow_revision import HogFlowRevisionwebhook_template = MOCK_NODE_TEMPLATES[0]-FLAG_PATH = "products.workflows.backend.api.hog_flow.use_workflows_revisions"RENDER_PATH = "products.workflows.backend.api.hog_flow.render_design_html"RENDERED_HTML = "<html>rendered</html>"@@ -281,9 +280,8 @@ class TestHogFlowActionEmailAPI(APIBaseTest):# ── Draft routing (mirrors the /graph endpoint's contract) ────────- @patch(FLAG_PATH, return_value=True)@patch(RENDER_PATH, return_value=RENDERED_HTML)- def test_mcp_patch_on_active_flow_lands_in_draft(self, _mock_render, _flag):+ def test_mcp_patch_on_active_flow_lands_in_draft(self, _mock_render):flow_id = self._create_flow(status="active")live_actions_before = HogFlow.objects.get(pk=flow_id).actions@@ -296,25 +294,8 @@ class TestHogFlowActionEmailAPI(APIBaseTest):assert _stored_email_value(flow, from_draft=True)["subject"] == "Draft subject"assert response.json()["draft"] is not None- @patch(FLAG_PATH, return_value=False)@patch(RENDER_PATH, return_value=RENDERED_HTML)- def test_mcp_patch_on_active_flow_rejected_when_flag_off(self, mock_render, _flag):- flow_id = self._create_flow(status="active")- response = self._patch_email(- flow_id,- {- "operations": [{"op": "update_content", "id": "text_1", "patch": {"values": {"text": "x"}}}],- "email_patch": {"subject": "x"},- },- )- assert response.status_code == 400, response.json()- assert "active workflow isn't supported via MCP" in response.json()["detail"]- # The rejection must land before the render, or a doomed request pays the Unlayer HTTP call.- mock_render.assert_not_called()-- @patch(FLAG_PATH, return_value=True)- @patch(RENDER_PATH, return_value=RENDERED_HTML)- def test_mcp_patch_composes_on_existing_draft(self, _mock_render, _flag):+ def test_mcp_patch_composes_on_existing_draft(self, _mock_render):# A graph patch stages a draft first; the email patch must apply on that draft, not reset it.flow_id = self._create_flow(status="active")graph = self.client.patch(@@ -333,9 +314,8 @@ class TestHogFlowActionEmailAPI(APIBaseTest):assert draft_action["name"] == "Renamed step"assert draft_action["config"]["inputs"]["email"]["value"]["subject"] == "Draft subject"- @patch(FLAG_PATH, return_value=True)@patch(RENDER_PATH, return_value=RENDERED_HTML)- def test_design_ops_compose_on_a_drafted_design(self, _mock_render, _flag):+ def test_design_ops_compose_on_a_drafted_design(self, _mock_render):# Two consecutive draft design edits: the second must render against the draft's design,# not the live one, or the apply reads it as a concurrent edit and conflicts.flow_id = self._create_flow(status="active")@@ -350,9 +330,8 @@ class TestHogFlowActionEmailAPI(APIBaseTest):email = _stored_email_value(HogFlow.objects.get(pk=flow_id), from_draft=True)assert email["design"]["body"]["rows"][0]["columns"][0]["contents"][0]["values"]["text"] == "<p>Second</p>"- @patch(FLAG_PATH, return_value=True)@patch(RENDER_PATH, return_value=RENDERED_HTML)- def test_stale_base_updated_at_rejected_with_409(self, _mock_render, _flag):+ def test_stale_base_updated_at_rejected_with_409(self, _mock_render):flow_id = self._create_flow(status="active")first = self._patch_email(flow_id, {"email_patch": {"subject": "First"}})assert first.status_code == 200, first.json()@@ -363,9 +342,8 @@ class TestHogFlowActionEmailAPI(APIBaseTest):)assert response.status_code == 409, response.json()- @patch(FLAG_PATH, return_value=True)@patch(RENDER_PATH, return_value=RENDERED_HTML)- def test_web_patch_on_active_flow_applies_live_and_bumps_revision(self, _mock_render, _flag):+ def test_web_patch_on_active_flow_applies_live_and_bumps_revision(self, _mock_render):flow_id = self._create_flow(status="active")response = self._patch_email(flow_id, {"email_patch": {"subject": "Live subject"}}, mcp=False)diff --git a/products/workflows/backend/api/test/test_hog_flow_draft_publish.py b/products/workflows/backend/api/test/test_hog_flow_draft_publish.pyindex b7efbef5d34e..966b81dcb4ae 100644--- a/products/workflows/backend/api/test/test_hog_flow_draft_publish.py+++ b/products/workflows/backend/api/test/test_hog_flow_draft_publish.py@@ -12,8 +12,6 @@ from products.workflows.backend.models.hog_flow.hog_flow import HogFlowwebhook_template = MOCK_NODE_TEMPLATES[0]-FLAG_PATH = "products.workflows.backend.api.hog_flow.use_workflows_revisions"-def _trigger_action() -> dict:return {@@ -71,8 +69,7 @@ class TestHogFlowDraftPublish(APIBaseTest):# ── Draft routing ────────────────────────────────────────────────- @patch(FLAG_PATH, return_value=True)- def test_mcp_content_edit_on_active_flow_routes_to_draft(self, _flag):+ def test_mcp_content_edit_on_active_flow_routes_to_draft(self):flow_id = self._create_active_flow()live_actions_before = HogFlow.objects.get(pk=flow_id).actions@@ -88,15 +85,7 @@ class TestHogFlowDraftPublish(APIBaseTest):# The response surfaces the draft so callers can see what they stagedassert response.json()["draft"] is not None- @patch(FLAG_PATH, return_value=False)- def test_mcp_content_edit_on_active_flow_rejected_when_flag_off(self, _flag):- flow_id = self._create_active_flow()- response = self._patch_actions_via_mcp(flow_id)- assert response.status_code == 400, response.json()- assert "active workflow isn't supported via MCP" in response.json()["detail"]-- @patch(FLAG_PATH, return_value=True)- def test_web_content_edit_on_active_flow_still_applies_live(self, _flag):+ def test_web_content_edit_on_active_flow_still_applies_live(self):flow_id = self._create_active_flow()response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}",@@ -108,8 +97,7 @@ class TestHogFlowDraftPublish(APIBaseTest):live_urls = [a["config"]["inputs"]["url"]["value"] for a in flow.actions if a["type"] == "function"]assert live_urls == ["https://changed.example.com"]- @patch(FLAG_PATH, return_value=True)- def test_mcp_content_edit_on_inactive_flow_applies_live(self, _flag):+ def test_mcp_content_edit_on_inactive_flow_applies_live(self):# Disabled/draft-status workflows edit in place — the draft cycle protects in-flight runs onlyhog_flow = {"name": "Test Flow", "actions": [_trigger_action(), _webhook_action()]}create = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)@@ -122,8 +110,7 @@ class TestHogFlowDraftPublish(APIBaseTest):live_urls = [a["config"]["inputs"]["url"]["value"] for a in flow.actions if a["type"] == "function"]assert live_urls == ["https://changed.example.com"]- @patch(FLAG_PATH, return_value=True)- def test_mcp_metadata_edit_on_active_flow_applies_live_without_draft(self, _flag):+ def test_mcp_metadata_edit_on_active_flow_applies_live_without_draft(self):flow_id = self._create_active_flow()response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}",@@ -135,8 +122,7 @@ class TestHogFlowDraftPublish(APIBaseTest):assert flow.name == "Renamed live"assert flow.draft is None- @patch(FLAG_PATH, return_value=True)- def test_mcp_mixed_status_and_content_still_rejected(self, _flag):+ def test_mcp_mixed_status_and_content_still_rejected(self):flow_id = self._create_active_flow()response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}",@@ -145,8 +131,7 @@ class TestHogFlowDraftPublish(APIBaseTest):)assert response.status_code == 400, response.json()- @patch(FLAG_PATH, return_value=True)- def test_stale_draft_edit_is_rejected_with_409(self, _flag):+ def test_stale_draft_edit_is_rejected_with_409(self):flow_id = self._create_active_flow()first = self._patch_actions_via_mcp(flow_id)assert first.status_code == 200, first.json()@@ -170,8 +155,7 @@ class TestHogFlowDraftPublish(APIBaseTest):# ── Graph patch routing ──────────────────────────────────────────- @patch(FLAG_PATH, return_value=True)- def test_mcp_graph_patch_on_active_flow_lands_in_draft(self, _flag):+ def test_mcp_graph_patch_on_active_flow_lands_in_draft(self):flow_id = self._create_active_flow()live_actions_before = HogFlow.objects.get(pk=flow_id).actions@@ -196,8 +180,7 @@ class TestHogFlowDraftPublish(APIBaseTest):draft_urls = [a["config"]["inputs"]["url"]["value"] for a in flow.draft["actions"] if a["type"] == "function"]assert draft_urls == ["https://patched.example.com"]- @patch(FLAG_PATH, return_value=True)- def test_mcp_graph_patch_composes_on_existing_draft(self, _flag):+ def test_mcp_graph_patch_composes_on_existing_draft(self):# A second surgical patch must apply against the staged draft, not reset it from liveflow_id = self._create_active_flow()first = self._patch_actions_via_mcp(flow_id, url="https://draft-v1.example.com")@@ -223,30 +206,11 @@ class TestHogFlowDraftPublish(APIBaseTest):draft_urls = {a["config"]["inputs"]["url"]["value"] for a in flow.draft["actions"] if a["type"] == "function"}assert draft_urls == {"https://draft-v1.example.com", "https://added.example.com"}- @patch(FLAG_PATH, return_value=False)- def test_mcp_graph_patch_on_active_flow_rejected_when_flag_off(self, _flag):- flow_id = self._create_active_flow()- response = self.client.patch(- f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",- {- "operations": [- {- "op": "update_action",- "id": "action_1",- "patch": {"config": {"inputs": {"url": {"value": "https://patched.example.com"}}}},- }- ]- },- HTTP_X_POSTHOG_CLIENT="mcp",- )- assert response.status_code == 400, response.json()-# ── Publish ──────────────────────────────────────────────────────def _stage_draft(self, flow_id: str) -> HogFlow:- with patch(FLAG_PATH, return_value=True):- response = self._patch_actions_via_mcp(flow_id)- assert response.status_code == 200, response.json()+ response = self._patch_actions_via_mcp(flow_id)+ assert response.status_code == 200, response.json()return HogFlow.objects.get(pk=flow_id)def _publish_preview(self, flow_id: str, counts: dict | None = None):@@ -260,8 +224,7 @@ class TestHogFlowDraftPublish(APIBaseTest):return response@patch("products.workflows.backend.api.hog_flow.get_hog_flow_in_flight_count")- @patch(FLAG_PATH, return_value=True)- def test_publish_without_confirm_returns_impact_only(self, _flag, mock_count):+ def test_publish_without_confirm_returns_impact_only(self, mock_count):mock_count.return_value = MagicMock(status_code=200, json=lambda: {"count": 42, "by_action": {"action_1": 42}, "position_unknown": 0})@@ -287,8 +250,7 @@ class TestHogFlowDraftPublish(APIBaseTest):assert flow.draft is not None@patch("products.workflows.backend.api.hog_flow.get_hog_flow_in_flight_count")- @patch(FLAG_PATH, return_value=True)- def test_publish_impact_degrades_to_null_counts_when_unavailable(self, _flag, mock_count):+ def test_publish_impact_degrades_to_null_counts_when_unavailable(self, mock_count):mock_count.side_effect = Exception("node service down")flow_id = self._create_active_flow()self._stage_draft(flow_id)@@ -300,8 +262,7 @@ class TestHogFlowDraftPublish(APIBaseTest):assert response.json()["impact"]["position_unknown"] is None@patch("products.workflows.backend.api.hog_flow.get_hog_flow_in_flight_count")- @patch(FLAG_PATH, return_value=True)- def test_publish_preview_reports_deleted_step_moves(self, _flag, mock_count):+ def test_publish_preview_reports_deleted_step_moves(self, mock_count):mock_count.return_value = MagicMock(status_code=200, json=lambda: {"count": 7, "by_action": {"action_1": 5}, "position_unknown": 2})@@ -327,8 +288,7 @@ class TestHogFlowDraftPublish(APIBaseTest):]assert impact["position_unknown"] == 2- @patch(FLAG_PATH, return_value=True)- def test_publish_with_confirm_promotes_draft_and_clears_it(self, _flag):+ def test_publish_with_confirm_promotes_draft_and_clears_it(self):flow_id = self._create_active_flow()flow = self._stage_draft(flow_id)confirm_token = self._publish_preview(flow_id).json()["confirm_token"]@@ -352,8 +312,7 @@ class TestHogFlowDraftPublish(APIBaseTest):entry = ActivityLog.objects.filter(scope="HogFlow", item_id=flow_id).order_by("-created_at").first()assert entry is not None and entry.activity == "published"- @patch(FLAG_PATH, return_value=True)- def test_publish_with_stale_token_after_draft_reedit_is_rejected_with_409(self, _flag):+ def test_publish_with_stale_token_after_draft_reedit_is_rejected_with_409(self):flow_id = self._create_active_flow()self._stage_draft(flow_id)confirm_token = self._publish_preview(flow_id).json()["confirm_token"]@@ -369,25 +328,22 @@ class TestHogFlowDraftPublish(APIBaseTest):@parameterized.expand([- ("flag_off", False, True, "garbage"),- ("no_draft", True, False, "garbage"),- ("no_token", True, True, None),- ("forged_token", True, True, "not-a-signed-value:1a2b3c:forged"),+ ("no_draft", False, "garbage"),+ ("no_token", True, None),+ ("forged_token", True, "not-a-signed-value:1a2b3c:forged"),])- def test_publish_rejected(self, _name, flag_on, stage_draft, confirm_token):+ def test_publish_rejected(self, _name, stage_draft, confirm_token):flow_id = self._create_active_flow()if stage_draft:self._stage_draft(flow_id)payload: dict = {"confirm": True}if confirm_token is not None:payload["confirm_token"] = confirm_token- with patch(FLAG_PATH, return_value=flag_on):- response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/publish", payload)+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/publish", payload)assert response.status_code == 400, response.json()- @patch(FLAG_PATH, return_value=True)- def test_publish_with_expired_token_is_rejected(self, _flag):+ def test_publish_with_expired_token_is_rejected(self):flow_id = self._create_active_flow()with freeze_time("2026-01-01T00:00:00Z"):self._stage_draft(flow_id)@@ -399,8 +355,7 @@ class TestHogFlowDraftPublish(APIBaseTest):)assert response.status_code == 400, response.json()- @patch(FLAG_PATH, return_value=True)- def test_publish_validates_draft_strictly(self, _flag):+ def test_publish_validates_draft_strictly(self):# A draft written by some future lenient path must not promote unvalidated: publish is defensive# regardless of who wrote the blobflow_id = self._create_active_flow()@@ -424,8 +379,7 @@ class TestHogFlowDraftPublish(APIBaseTest):# ── Discard ──────────────────────────────────────────────────────- @patch(FLAG_PATH, return_value=True)- def test_discard_draft_clears_it(self, _flag):+ def test_discard_draft_clears_it(self):flow_id = self._create_active_flow()self._stage_draft(flow_id)@@ -442,8 +396,7 @@ class TestHogFlowDraftPublish(APIBaseTest):# ── Test-run from draft ──────────────────────────────────────────@patch("products.workflows.backend.api.hog_flow.create_hog_flow_invocation_test")- @patch(FLAG_PATH, return_value=True)- def test_invocation_with_use_draft_sends_draft_as_configuration(self, _flag, mock_invoke):+ def test_invocation_with_use_draft_sends_draft_as_configuration(self, mock_invoke):mock_invoke.return_value = MagicMock(status_code=200, json=lambda: {"status": "success"})flow_id = self._create_active_flow()self._stage_draft(flow_id)@@ -462,8 +415,7 @@ class TestHogFlowDraftPublish(APIBaseTest):]assert sent_urls == ["https://changed.example.com"]- @patch(FLAG_PATH, return_value=True)- def test_invocation_with_use_draft_and_no_draft_is_rejected(self, _flag):+ def test_invocation_with_use_draft_and_no_draft_is_rejected(self):flow_id = self._create_active_flow()response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/invocations",@@ -473,8 +425,7 @@ class TestHogFlowDraftPublish(APIBaseTest):# ── Serializer exposure ──────────────────────────────────────────- @patch(FLAG_PATH, return_value=True)- def test_get_surfaces_open_draft(self, _flag):+ def test_get_surfaces_open_draft(self):flow_id = self._create_active_flow()self._stage_draft(flow_id)@@ -508,8 +459,7 @@ class TestHogFlowDraftPublish(APIBaseTest):"edges": [{"from": "trigger_node", "to": "action_2", "type": "continue"}],}- @patch(FLAG_PATH, return_value=True)- def test_publish_deleting_a_step_persists_its_redirect(self, _flag):+ def test_publish_deleting_a_step_persists_its_redirect(self):flow_id = self._create_active_three_step_flow()response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",@@ -532,19 +482,14 @@ class TestHogFlowDraftPublish(APIBaseTest):assert flow.action_redirects == {"action_1": "action_2"}assert response.json()["workflow"]["action_redirects"] == {"action_1": "action_2"}- @parameterized.expand([("flag_on", True), ("flag_off", False)])- def test_web_edit_deleting_a_step_persists_its_redirect_only_when_flag_on(self, _name, flag_on):+ def test_web_edit_deleting_a_step_persists_its_redirect(self):flow_id = self._create_active_three_step_flow()- with patch(FLAG_PATH, return_value=flag_on):- response = self.client.patch(- f"/api/projects/{self.team.id}/hog_flows/{flow_id}", self._DELETE_ACTION_1_PAYLOAD- )+ response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", self._DELETE_ACTION_1_PAYLOAD)assert response.status_code == 200, response.json()flow = HogFlow.objects.get(pk=flow_id)- assert flow.action_redirects == ({"action_1": "action_2"} if flag_on else None)+ assert flow.action_redirects == {"action_1": "action_2"}- @patch(FLAG_PATH, return_value=True)- def test_edit_while_disabled_still_persists_its_redirect(self, _flag):+ def test_edit_while_disabled_still_persists_its_redirect(self):# Disabling a flow doesn't purge its parked runs — a step deleted during a disable/re-enable# window must still get a redirect, or those runs strand on re-activation.flow_id = self._create_active_three_step_flow()@@ -556,8 +501,7 @@ class TestHogFlowDraftPublish(APIBaseTest):flow = HogFlow.objects.get(pk=flow_id)assert flow.action_redirects == {"action_1": "action_2"}- @patch(FLAG_PATH, return_value=True)- def test_graph_remove_action_persists_its_redirect(self, _flag):+ def test_graph_remove_action_persists_its_redirect(self):flow_id = self._create_active_three_step_flow()response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",@@ -567,8 +511,7 @@ class TestHogFlowDraftPublish(APIBaseTest):flow = HogFlow.objects.get(pk=flow_id)assert flow.action_redirects == {"action_1": "action_2"}- @patch(FLAG_PATH, return_value=True)- def test_draft_contents_are_masked_in_activity_log(self, _flag):+ def test_draft_contents_are_masked_in_activity_log(self):flow_id = self._create_active_flow()self._stage_draft(flow_id)diff --git a/products/workflows/backend/api/test/test_hog_flow_revisions.py b/products/workflows/backend/api/test/test_hog_flow_revisions.pyindex b906b712fa9d..ddfaa673bbbd 100644--- a/products/workflows/backend/api/test/test_hog_flow_revisions.py+++ b/products/workflows/backend/api/test/test_hog_flow_revisions.py@@ -9,12 +9,9 @@ from posthog.models.activity_logging.activity_log import ActivityLogfrom products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATESfrom products.workflows.backend.api.hog_flow import DRAFT_CONTENT_FIELDSfrom products.workflows.backend.models.hog_flow.hog_flow import HogFlow-from products.workflows.backend.models.hog_flow_revision import HogFlowRevisionwebhook_template = MOCK_NODE_TEMPLATES[0]-FLAG_PATH = "products.workflows.backend.api.hog_flow.use_workflows_revisions"-def _trigger_action() -> dict:return {@@ -109,7 +106,7 @@ class TestHogFlowRevisions(APIBaseTest):def _list_revisions(self, flow_id: str) -> list[dict]:# Assert through the endpoint, not the ORM, so these exercise its team scoping, ordering- # (newest-first), and serialization (content omitted). Requires the flag on for a 200.+ # (newest-first), and serialization (content omitted).response = self.client.get(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/revisions")assert response.status_code == 200, response.json()return response.json()["results"]@@ -121,8 +118,7 @@ class TestHogFlowRevisions(APIBaseTest):# ── Appending on live-content writes ─────────────────────────────- @patch(FLAG_PATH, return_value=True)- def test_publish_appends_revision_and_bumps_version(self, _flag):+ def test_publish_appends_revision_and_bumps_version(self):flow_id = self._create_active_flow()self._stage_draft(flow_id)published = self._publish(flow_id)@@ -146,16 +142,14 @@ class TestHogFlowRevisions(APIBaseTest):# Content is exactly the draft-cycle content fields — no system bookkeepingassert set(v2_content.keys()) == set(DRAFT_CONTENT_FIELDS)- @patch(FLAG_PATH, return_value=True)- def test_web_live_edit_appends_revision(self, _flag):+ def test_web_live_edit_appends_revision(self):flow_id = self._create_active_flow()response = self._live_edit(flow_id)assert response.status_code == 200, response.json()assert response.json()["version"] == 2assert [r["version"] for r in self._list_revisions(flow_id)] == [2, 1]- @patch(FLAG_PATH, return_value=True)- def test_graph_live_edit_appends_revision(self, _flag):+ def test_graph_live_edit_appends_revision(self):flow_id = self._create_active_three_step_flow()response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",@@ -189,17 +183,13 @@ class TestHogFlowRevisions(APIBaseTest):)def test_non_content_writes_do_not_append_revisions(self, _name, path_suffix, payload, client_header):flow_id = self._create_active_flow()- with patch(FLAG_PATH, return_value=True):- extra = {"HTTP_X_POSTHOG_CLIENT": client_header} if client_header else {}- response = self.client.patch(- f"/api/projects/{self.team.id}/hog_flows/{flow_id}{path_suffix}", payload, **extra- )- assert response.status_code == 200, response.json()- assert self._list_revisions(flow_id) == []+ extra = {"HTTP_X_POSTHOG_CLIENT": client_header} if client_header else {}+ response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}{path_suffix}", payload, **extra)+ assert response.status_code == 200, response.json()+ assert self._list_revisions(flow_id) == []assert response.json()["version"] == 1- @patch(FLAG_PATH, return_value=True)- def test_no_op_live_edit_does_not_append_revision(self, _flag):+ def test_no_op_live_edit_does_not_append_revision(self):# Two identical saves in a row: the first may change stored shape (create vs update# serializer defaults differ), but the second must not append a junk revision.flow_id = self._create_active_flow()@@ -217,20 +207,9 @@ class TestHogFlowRevisions(APIBaseTest):assert second.status_code == 200, second.json()assert [r["version"] for r in self._list_revisions(flow_id)] == revisions_after_first- @patch(FLAG_PATH, return_value=False)- def test_flag_off_appends_no_revisions(self, _flag):- flow_id = self._create_active_flow()- response = self._live_edit(flow_id)- assert response.status_code == 200, response.json()- assert response.json()["version"] == 1- # Flag off: the list endpoint is rejected (see test_flag_off_rejects_revision_endpoints), so- # assert directly that nothing was persisted.- assert not HogFlowRevision.objects.for_team(self.team.id).filter(hog_flow_id=flow_id).exists()-# ── Listing and fetching ─────────────────────────────────────────- @patch(FLAG_PATH, return_value=True)- def test_list_and_retrieve_revisions(self, _flag):+ def test_list_and_retrieve_revisions(self):flow_id = self._create_active_flow()self._live_edit(flow_id)@@ -251,16 +230,14 @@ class TestHogFlowRevisions(APIBaseTest):]assert urls == ["https://example.com"]- @patch(FLAG_PATH, return_value=True)- def test_retrieve_missing_revision_404s(self, _flag):+ def test_retrieve_missing_revision_404s(self):flow_id = self._create_active_flow()response = self.client.get(f"/api/projects/{self.team.id}/hog_flows/{flow_id}/revisions/99")assert response.status_code == 404, response.json()# ── Restore (rollback) ───────────────────────────────────────────- @patch(FLAG_PATH, return_value=True)- def test_restore_copies_revision_into_draft_without_touching_live(self, _flag):+ def test_restore_copies_revision_into_draft_without_touching_live(self):flow_id = self._create_active_flow()self._live_edit(flow_id)live_actions = HogFlow.objects.get(pk=flow_id).actions@@ -279,8 +256,7 @@ class TestHogFlowRevisions(APIBaseTest):entry = ActivityLog.objects.filter(scope="HogFlow", item_id=flow_id).order_by("-created_at").first()assert entry is not None and entry.activity == "revision_restored"- @patch(FLAG_PATH, return_value=True)- def test_rollback_round_trip_restores_live_and_prunes_redirects(self, _flag):+ def test_rollback_round_trip_restores_live_and_prunes_redirects(self):# Publish v2 deleting a step (parked runs get a redirect), then roll back to v1: the step# comes back, its redirect entry is pruned, and the rollback is recorded as a new revision.flow_id = self._create_active_three_step_flow()@@ -307,8 +283,7 @@ class TestHogFlowRevisions(APIBaseTest):)assert response.status_code == 200, response.json()- @patch(FLAG_PATH, return_value=True)- def test_restore_with_open_draft_conflicts_unless_overwrite(self, _flag):+ def test_restore_with_open_draft_conflicts_unless_overwrite(self):flow_id = self._create_active_flow()self._live_edit(flow_id)self._stage_draft(flow_id, url="https://staged.example.com")@@ -328,12 +303,3 @@ class TestHogFlowRevisions(APIBaseTest):assert flow.draft is not Nonedraft_urls = [a["config"]["inputs"]["url"]["value"] for a in flow.draft["actions"] if a["type"] == "function"]assert draft_urls == ["https://example.com"]-- @parameterized.expand([("list", "GET", "revisions"), ("restore", "POST", "revisions/1/restore")])- def test_flag_off_rejects_revision_endpoints(self, _name, method, path):- flow_id = self._create_active_flow()- with patch(FLAG_PATH, return_value=False):- response = getattr(self.client, method.lower())(- f"/api/projects/{self.team.id}/hog_flows/{flow_id}/{path}", {} if method == "POST" else None- )- assert response.status_code == 400, response.json()diff --git a/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.py b/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.pyindex e325d842f081..5ada972b51ff 100644--- a/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.py+++ b/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.py@@ -10,8 +10,6 @@ from products.workflows.backend.models.hog_flow.hog_flow import HogFlowwebhook_template = MOCK_NODE_TEMPLATES[0]-TIMING_FLAG_PATH = "products.workflows.backend.api.hog_flow.use_workflows_timing_reschedule"-REVISIONS_FLAG_PATH = "products.workflows.backend.api.hog_flow.use_workflows_revisions"TASK_PATH = "products.workflows.backend.api.hog_flow.reschedule_hog_flow_timing"@@ -81,8 +79,7 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):)@patch(TASK_PATH)- @patch(TIMING_FLAG_PATH, return_value=True)- def test_shortened_delay_on_live_save_enqueues_sweep_post_commit(self, _flag, mock_task):+ def test_shortened_delay_on_live_save_enqueues_sweep_post_commit(self, mock_task):flow_id = self._create_flow()with self.captureOnCommitCallbacks(execute=False) as callbacks:@@ -96,25 +93,22 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):@parameterized.expand([- ("flag_off", False, "1d", "https://example.com"),- ("lengthened_delay", True, "30d", "https://example.com"),- ("non_timing_edit", True, "7d", "https://changed.example.com"),+ ("lengthened_delay", "30d", "https://example.com"),+ ("non_timing_edit", "7d", "https://changed.example.com"),])@patch(TASK_PATH)- def test_live_save_does_not_enqueue_sweep(self, _name, flag_on, delay_duration, webhook_url, mock_task):+ def test_live_save_does_not_enqueue_sweep(self, _name, delay_duration, webhook_url, mock_task):flow_id = self._create_flow()- with patch(TIMING_FLAG_PATH, return_value=flag_on):- with self.captureOnCommitCallbacks(execute=True):- response = self._patch_actions(flow_id, delay_duration=delay_duration, webhook_url=webhook_url)+ with self.captureOnCommitCallbacks(execute=True):+ response = self._patch_actions(flow_id, delay_duration=delay_duration, webhook_url=webhook_url)assert response.status_code == 200, response.json()mock_task.delay.assert_not_called()@patch(TASK_PATH)- @patch(TIMING_FLAG_PATH, return_value=True)- def test_inactive_flow_save_does_not_enqueue_sweep(self, _flag, mock_task):+ def test_inactive_flow_save_does_not_enqueue_sweep(self, mock_task):flow_id = self._create_flow(activate=False)with self.captureOnCommitCallbacks(execute=True):@@ -124,9 +118,7 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):mock_task.delay.assert_not_called()@patch(TASK_PATH)- @patch(TIMING_FLAG_PATH, return_value=True)- @patch(REVISIONS_FLAG_PATH, return_value=True)- def test_mcp_draft_routed_edit_does_not_enqueue_sweep(self, _revisions, _timing, mock_task):+ def test_mcp_draft_routed_edit_does_not_enqueue_sweep(self, mock_task):flow_id = self._create_flow()with self.captureOnCommitCallbacks(execute=True):@@ -137,9 +129,7 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):mock_task.delay.assert_not_called()@patch(TASK_PATH)- @patch(TIMING_FLAG_PATH, return_value=True)- @patch(REVISIONS_FLAG_PATH, return_value=True)- def test_publish_of_timing_shortening_draft_enqueues_sweep(self, _revisions, _timing, mock_task):+ def test_publish_of_timing_shortening_draft_enqueues_sweep(self, mock_task):flow_id = self._create_flow()response = self._patch_delay_via_mcp(flow_id)assert response.status_code == 200, response.json()@@ -163,8 +153,7 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):mock_task.delay.assert_called_once_with(team_id=self.team.id, hog_flow_id=flow_id, action_ids=["delay_1"])@patch(TASK_PATH)- @patch(TIMING_FLAG_PATH, return_value=True)- def test_re_enable_sweeps_all_timing_steps(self, _flag, mock_task):+ def test_re_enable_sweeps_all_timing_steps(self, mock_task):# Runs parked during a prior active period survive a disable, and timing edits made while# disabled never sweep - so the enable transition converges every timing step.flow_id = self._create_flow()@@ -181,8 +170,7 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):mock_task.delay.assert_called_once_with(team_id=self.team.id, hog_flow_id=flow_id, action_ids=["delay_1"])@patch(TASK_PATH)- @patch(TIMING_FLAG_PATH, return_value=True)- def test_graph_operation_shortening_delay_enqueues_sweep(self, _flag, mock_task):+ def test_graph_operation_shortening_delay_enqueues_sweep(self, mock_task):flow_id = self._create_flow()with self.captureOnCommitCallbacks(execute=True):diff --git a/products/workflows/backend/services/revisions.py b/products/workflows/backend/services/revisions.pydeleted file mode 100644index a575b62a72b0..000000000000--- a/products/workflows/backend/services/revisions.py+++ /dev/null@@ -1,37 +0,0 @@-import structlog-import posthoganalytics--from posthog.models.team.team import Team--logger = structlog.get_logger(__name__)--WORKFLOWS_REVISIONS_FLAG = "workflows-revisions"---def use_workflows_revisions(team: Team) -> bool:- """Gates the draft → test → publish cycle on active workflows; off means today's behavior- (active workflows are read-only via MCP).-- A raised exception (Redis/HyperCache blip, network glitch, SDK bug) is treated as "flag off" —- the rejection path is the safe fallback, making the flag a kill switch for the whole cycle.- """- try:- return bool(- posthoganalytics.feature_enabled(- WORKFLOWS_REVISIONS_FLAG,- str(team.uuid),- groups={"organization": str(team.organization_id), "project": str(team.id)},- group_properties={- "organization": {"id": str(team.organization_id)},- "project": {"id": str(team.id)},- },- )- )- except Exception:- logger.warning(- "workflows.revisions.feature_flag_check_failed_defaulting_off",- team_id=team.id,- flag=WORKFLOWS_REVISIONS_FLAG,- exc_info=True,- )- return Falsediff --git a/products/workflows/backend/services/timing_reschedule.py b/products/workflows/backend/services/timing_reschedule.pyindex 8c022bdc93ca..2c0f4414e9fa 100644--- a/products/workflows/backend/services/timing_reschedule.py+++ b/products/workflows/backend/services/timing_reschedule.py@@ -2,14 +2,9 @@ import refrom typing import Any, Optionalimport structlog-import posthoganalytics--from posthog.models.team.team import Teamlogger = structlog.get_logger(__name__)-WORKFLOWS_TIMING_RESCHEDULE_FLAG = "workflows-timing-reschedule"-# Steps whose parked runs a timing edit can strand: delays park up to 30 days out and time# windows up to a week. wait_until_condition currently re-parks on a 10-minute polling cap# (so a sweep is a cheap no-op re-park), but the poll is slated for removal in favor of@@ -31,35 +26,6 @@ _UNIT_MAX = {"d": 30, "h": 24, "m": 60, "s": 60}_TIME_WINDOW_CONFIG_KEYS = ("day", "time", "timezone", "use_person_timezone", "fallback_timezone")-def use_workflows_timing_reschedule(team: Team) -> bool:- """Gates the reschedule sweep for parked runs after a timing edit; off means today's- behavior (shortened delays only take effect at each run's old wake time).-- A raised exception is treated as "flag off" - skipping the sweep is the safe fallback,- making the flag a kill switch for the whole feature.- """- try:- return bool(- posthoganalytics.feature_enabled(- WORKFLOWS_TIMING_RESCHEDULE_FLAG,- str(team.uuid),- groups={"organization": str(team.organization_id), "project": str(team.id)},- group_properties={- "organization": {"id": str(team.organization_id)},- "project": {"id": str(team.id)},- },- )- )- except Exception:- logger.warning(- "workflows.timing_reschedule.feature_flag_check_failed_defaulting_off",- team_id=team.id,- flag=WORKFLOWS_TIMING_RESCHEDULE_FLAG,- exc_info=True,- )- return False--def parse_delay_duration_seconds(value: Any) -> Optional[float]:if not isinstance(value, str):return Nonediff --git a/products/workflows/backend/test/test_timing_reschedule.py b/products/workflows/backend/test/test_timing_reschedule.pyindex 841b95e80c42..ac10930d9b29 100644--- a/products/workflows/backend/test/test_timing_reschedule.py+++ b/products/workflows/backend/test/test_timing_reschedule.py@@ -15,7 +15,6 @@ from products.workflows.backend.services.timing_reschedule import (get_all_timing_action_ids,get_timing_reschedule_action_ids,parse_delay_duration_seconds,- use_workflows_timing_reschedule,)from products.workflows.backend.tasks.hog_flows import reschedule_hog_flow_timing@@ -170,20 +169,6 @@ class TestTimingRescheduleDiff(SimpleTestCase):assert get_all_timing_action_ids([_delay(f"delay_{i}") for i in range(101)]) == []-class TestTimingRescheduleFlag(SimpleTestCase):- def _team(self) -> MagicMock:- return MagicMock(uuid="team-uuid", organization_id="org-id", id=1)-- @parameterized.expand([("on", True), ("off", False)])- def test_flag_value_passthrough(self, _name, enabled):- with patch("posthoganalytics.feature_enabled", return_value=enabled):- assert use_workflows_timing_reschedule(self._team()) is enabled-- def test_flag_check_failure_defaults_off(self):- with patch("posthoganalytics.feature_enabled", side_effect=Exception("flag service down")):- assert use_workflows_timing_reschedule(self._team()) is False--class TestRescheduleParkedJobsClient(BaseTest):@patch("posthog.plugins.plugin_server_api.internal_requests.post")def test_call_carries_a_scoped_jwt_and_timeout(self, mock_post):diff --git a/products/workflows/mcp/tools.yaml b/products/workflows/mcp/tools.yamlindex 03b05fb84b77..d887980ea758 100644--- a/products/workflows/mcp/tools.yaml+++ b/products/workflows/mcp/tools.yaml@@ -325,8 +325,7 @@ tools:email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-renderedserver-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changesnothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing- reaches real people until workflows-publish; a rejection saying active workflows can't be edited means draft- editing isn't enabled for this project yet. The full updated workflow is returned. Prefer this over+ reaches real people until workflows-publish. The full updated workflow is returned. Prefer this overworkflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML insync. For library templates use workflows-patch-email-template instead.workflows-patch-graph:@@ -349,11 +348,10 @@ tools:validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothingchanges. On an active workflow, patches stage a draft instead of changing what's running: the first patchcopies the live graph into the draft, later patches compose onto it, and nothing reaches real people until- workflows-publish. A rejection saying active workflows can't be edited means draft editing isn't enabled for- this project yet — then a live change means recreating the workflow as a new draft. The full updated- workflow is returned, so you don't need to re-fetch before the next edit. When adding or editing a- conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not- {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.+ workflows-publish. The full updated workflow is returned, so you don't need to re-fetch before the next+ edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper:+ {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with+ workflows-test-run after patching.workflows-publish:operation: hog_flows_publish_createenabled: true@@ -448,10 +446,8 @@ tools:Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion,trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silentlydrop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow,- content fields stage a draft (published with workflows-publish) while name/description apply immediately; a- rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet -- then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable- / workflows-archive.+ content fields stage a draft (published with workflows-publish) while name/description apply immediately.+ Status changes go through workflows-enable / workflows-archive.exclude_params:- status- actionsdiff --git a/products/workflows/skills/building-workflows/SKILL.md b/products/workflows/skills/building-workflows/SKILL.mdindex 32b593c89ed7..f0cfa3b1f4b4 100644--- a/products/workflows/skills/building-workflows/SKILL.md+++ b/products/workflows/skills/building-workflows/SKILL.md@@ -57,8 +57,6 @@ Every live-content change appends a snapshot to the workflow's revision history.A restore returns 409 when a draft is already open; publish or discard it, or pass `overwrite=true` to replace it. Two things a rollback cannot undo: runs that already moved or exited while the newer version was live keep their positions (their side effects happened), and a publish that shortened a delay may have pulled parked wake times earlier — rolling back doesn't push them later again.-If an edit is rejected with "editing an active workflow isn't supported", draft editing isn't enabled for this project yet — then a live change means recreating the workflow as a new draft (`workflows-create`), testing it, and enabling it as a replacement.-## What the server owns, never send itThe server compiles and manages these. Authoring them by hand is the fastest way to a broken workflow:diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 376074730258..5b063db8257d 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -10927,7 +10927,7 @@}},"workflows-patch-action-email": {- "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet. The full updated workflow is returned. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.",+ "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish. The full updated workflow is returned. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.","category": "Workflows","feature": "workflows","summary": "Patch a workflow step's email",@@ -10955,7 +10955,7 @@}},"workflows-patch-graph": {- "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. A rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet — then a live change means recreating the workflow as a new draft. The full updated workflow is returned, so you don't need to re-fetch before the next edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.",+ "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. The full updated workflow is returned, so you don't need to re-fetch before the next edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.","category": "Workflows","feature": "workflows","summary": "Patch workflow graph",@@ -11039,7 +11039,7 @@}},"workflows-update": {- "description": "Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion, trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silently drop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet - then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable / workflows-archive.",+ "description": "Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion, trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silently drop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately. Status changes go through workflows-enable / workflows-archive.","category": "Workflows","feature": "workflows","summary": "Update workflow",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex fa97f17d361d..adf56cae9cd7 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -11441,7 +11441,7 @@}},"workflows-enable": {- "description": "Enable / activate a draft workflow and start processing events. From then on it runs on real people: test it first with workflows-test-run and get the user's explicit approval before invoking - don't enable on your own initiative. Once live, content edits stage as a draft you publish with workflows-publish; if draft editing isn't enabled for the project yet, a live change means recreating the workflow as a new draft.",+ "description": "Enable / activate a draft workflow and start processing events. From then on it runs on real people: test it first with workflows-test-run and get the user's explicit approval before invoking - don't enable on your own initiative. Once live, content edits stage as a draft you publish with workflows-publish.","category": "Workflows","feature": "workflows","summary": "Enable workflow",@@ -11609,7 +11609,7 @@}},"workflows-patch-action-email": {- "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet. The full updated workflow is returned. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.",+ "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish. The full updated workflow is returned. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.","category": "Workflows","feature": "workflows","summary": "Patch a workflow step's email",@@ -11637,7 +11637,7 @@}},"workflows-patch-graph": {- "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. A rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet — then a live change means recreating the workflow as a new draft. The full updated workflow is returned, so you don't need to re-fetch before the next edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.",+ "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. The full updated workflow is returned, so you don't need to re-fetch before the next edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.","category": "Workflows","feature": "workflows","summary": "Patch workflow graph",@@ -11749,7 +11749,7 @@}},"workflows-update": {- "description": "Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion, trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silently drop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet - then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable / workflows-archive.",+ "description": "Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion, trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silently drop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately. Status changes go through workflows-enable / workflows-archive.","category": "Workflows","feature": "workflows","summary": "Update workflow",diff --git a/services/mcp/schema/tool-definitions.json b/services/mcp/schema/tool-definitions.jsonindex 42ccadfd7269..f4a9a94e8d9b 100644--- a/services/mcp/schema/tool-definitions.json+++ b/services/mcp/schema/tool-definitions.json@@ -738,7 +738,7 @@}},"workflows-enable": {- "description": "Enable / activate a draft workflow and start processing events. From then on it runs on real people: test it first with workflows-test-run and get the user's explicit approval before invoking - don't enable on your own initiative. Once live, content edits stage as a draft you publish with workflows-publish; if draft editing isn't enabled for the project yet, a live change means recreating the workflow as a new draft.",+ "description": "Enable / activate a draft workflow and start processing events. From then on it runs on real people: test it first with workflows-test-run and get the user's explicit approval before invoking - don't enable on your own initiative. Once live, content edits stage as a draft you publish with workflows-publish.","category": "Workflows","feature": "workflows","summary": "Enable workflow",diff --git a/services/mcp/src/tools/index.ts b/services/mcp/src/tools/index.tsindex ac4b06546543..81b649f025f5 100644--- a/services/mcp/src/tools/index.ts+++ b/services/mcp/src/tools/index.ts@@ -57,9 +57,13 @@ import {import type { Context, Tool, ToolBase, ZodObjectAny } from './types'// Workflows (batch — orchestration over existing REST endpoints with a blast-radius guard)import { workflowsBlastRadius, workflowsRunBatch, workflowsScheduleCreate } from './workflows/batch'-// Workflows (lifecycle — CRUD lives in generated/workflows.ts). workflows-disable is intentionally-// not registered: editing active workflows is blocked, and exposing disable invited a-// disable→edit→enable workaround. The factory stays in lifecycle.ts for easy re-enable.+// Workflows (lifecycle — CRUD lives in generated/workflows.ts). workflows-disable is intentionally not+// registered: draft routing is gated on ACTIVE status, so disable→edit→enable lands the edit straight on+// the live row and resumes it, skipping the impact preview and signed confirm token that workflows-publish+// makes unskippable. A tool description telling the agent not to do that isn't enforcement — prompt+// injection reaching the agent would just ignore it. Register this only once edits made while disabled+// stage a draft too, or re-enabling a workflow edited while disabled requires publish confirmation.+// The factory stays in lifecycle.ts for that day.import { workflowsArchive, workflowsEnable } from './workflows/lifecycle'// Map of tool names to tool factory functionsdiff --git a/services/mcp/src/tools/workflows/batch.ts b/services/mcp/src/tools/workflows/batch.tsindex 2d9e9c7c5d7a..13aa13ac2b5f 100644--- a/services/mcp/src/tools/workflows/batch.ts+++ b/services/mcp/src/tools/workflows/batch.ts@@ -167,10 +167,10 @@ export const workflowsScheduleCreate = (): ToolBase<typeof ScheduleCreateSchema,)}- // Require the workflow to be active before scheduling. A draft's trigger can still be edited, so- // scheduling a draft would let the audience be broadened after you acknowledged it (the scheduler- // uses the trigger's filters at fire time). An active workflow's trigger can't be edited via MCP,- // so the acknowledged audience is locked in.+ // Require the workflow to be active before scheduling. A draft's trigger can still be edited in+ // place, so scheduling a draft would let the audience be broadened after you acknowledged it (the+ // scheduler uses the trigger's filters at fire time). On an active workflow an MCP trigger edit only+ // stages a draft, so the acknowledged audience can't change without an explicit publish.if (status !== 'active') {throw new Error(`Workflow is not active (status '${status ?? 'unknown'}') — enable it with workflows-enable before ` +diff --git a/services/mcp/tests/tools/workflows.integration.test.ts b/services/mcp/tests/tools/workflows.integration.test.tsindex f37ce43a3b6c..bf7ed768f407 100644--- a/services/mcp/tests/tools/workflows.integration.test.ts+++ b/services/mcp/tests/tools/workflows.integration.test.ts@@ -414,16 +414,6 @@ describe('Workflows', { concurrent: false }, () => {expect(renamed.id).toBe(created.id)expect(renamed.name).toBe('mcp-test-renamed')})-- it('should refuse editing an active workflow via MCP', async () => {- const created = parseToolResponse(await createTool.handler(context, makeWorkflowParams()))- createdWorkflowIds.push(created.id)- await enableTool.handler(context, { id: created.id })-- await expect(- updateTool.handler(context, { id: created.id, name: 'mcp-test-active-rename' })- ).rejects.toThrow(/active workflow isn't supported via MCP/)- })})// workflows-test-run hits the invocations endpoint, which forwards to the CDP plugin