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(modeling): freeze v1 workflow (#58858)

andrew j. mcgeheefe1acd275ef4
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index abdb92c7aa2b..92898f4d9a9f 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -47,3 +47,7 @@ rust/persons_migrations/** @PostHog/team-ingestion
posthog/api/authentication.py @PostHog/team-security
posthog/auth.py @PostHog/team-security
ee/api/scim/auth.py @PostHog/team-security
+
+# v1 data-modeling workflow is frozen during the v1 → v2 migration.
+# this will be removed from CODEOWNERS by June 1
+posthog/temporal/data_modeling/run_workflow.py @PostHog/team-data-modeling
diff --git a/posthog/temporal/data_modeling/AGENTS.md b/posthog/temporal/data_modeling/AGENTS.md
new file mode 100644
index 000000000000..3d288cfd5b3e
--- /dev/null
+++ b/posthog/temporal/data_modeling/AGENTS.md
@@ -0,0 +1,31 @@
+# Data-modeling Temporal workflows
+
+Temporal workflows and activities that materialize data-modeling saved queries.
+Two implementations live here side by side during the v1 → v2 migration.
+
+## v1 — FROZEN
+
+- `run_workflow.py` (1814-line monolith).
+- Dispatched from `products/data_modeling/backend/api/node.py` when
+ `_is_v2_backend_enabled(...)` is false.
+- Almost all US teams are still on v1; almost all EU teams are on v2.
+
+**Do not extend v1.** No new features, no refactors, no new error types.
+Bug fixes that affect both versions can land here, but treat that as the
+exception — the goal is to keep the migration window small.
+
+## v2 — active
+
+- `workflows/materialize_view.py` and `workflows/execute_dag.py`.
+- Activities in `activities/*.py`.
+- Dispatched when `_is_v2_backend_enabled(...)` is true.
+
+All new work targets v2: new activities, new error types, configuration knobs,
+reliability fixes, and tests.
+
+## Scoping
+
+- `products/data_warehouse/` is owned by another team. Read-only from here —
+ do not modify code under that tree without their review.
+- `DataModelingJob` currently lives in `products/data_warehouse/` for historical
+ reasons; It will soon be moved to `products/data_modeling/`.
diff --git a/posthog/temporal/data_modeling/run_workflow.py b/posthog/temporal/data_modeling/run_workflow.py
index 4d8aa5711056..1807856e2f82 100644
--- a/posthog/temporal/data_modeling/run_workflow.py
+++ b/posthog/temporal/data_modeling/run_workflow.py
@@ -1,3 +1,13 @@
+"""Data-modeling Temporal workflow v1 — FROZEN.
+
+Do not extend this module. v1 is being migrated to v2, which lives at
+`posthog/temporal/data_modeling/workflows/{materialize_view,execute_dag}.py`.
+New features, bug fixes for new behavior, and refactors belong in v2.
+
+Bug fixes that affect both versions can land here, but treat that as the
+exception.
+"""
+
import gc
import os
import re
diff --git a/products/data_modeling/backend/api/node.py b/products/data_modeling/backend/api/node.py
index d597a5dcae69..f08ba031b88f 100644
--- a/products/data_modeling/backend/api/node.py
+++ b/products/data_modeling/backend/api/node.py
@@ -266,6 +266,9 @@ class NodeViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
workflow_name = "data-modeling-execute-dag"
workflow_id = f"execute-dag-{uuid4()}"
else:
+ # v1 workflow is frozen — do not extend this branch.
+ # v2 lives at posthog/temporal/data_modeling/workflows/. Teams are
+ # being migrated off v1 via the `_is_v2_backend_enabled` flag.
saved_query_ids = list(
# nosemgrep: idor-lookup-without-team (node_ids from prior team-scoped graph traversal)
Node.objects.filter(