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(cdp): move hog validation and filters into products/cdp (#115436)

Harley Alexander117c4dc7047c
diff --git a/.oxfmtrc.json b/.oxfmtrc.json
index 5e948632f7ab..2852f9e36798 100644
--- a/.oxfmtrc.json
+++ b/.oxfmtrc.json
@@ -148,7 +148,7 @@
"services/mcp/**/generated.ts",
"services/mcp/src/**/*.md",
"services/mcp/worker-configuration.d.ts",
- "posthog/cdp/filter_globals.json",
+ "products/cdp/backend/filter_globals.json",
"posthog/emoji_search/catalog.json",
"products/review_hog/backend/reviewer/prompts/**/schema.json",
"**/chart/*/templates/**",
diff --git a/frontend/src/scenes/hog-functions/email-templater/emailTemplaterLogic.tsx b/frontend/src/scenes/hog-functions/email-templater/emailTemplaterLogic.tsx
index dcbb4d3475a6..6c97f51b928a 100644
--- a/frontend/src/scenes/hog-functions/email-templater/emailTemplaterLogic.tsx
+++ b/frontend/src/scenes/hog-functions/email-templater/emailTemplaterLogic.tsx
@@ -120,7 +120,7 @@ function exportEditorHtml(editor: Editor): Promise<{ html: string; design: JSONT
* Wrap raw html in an Unlayer design holding a single custom HTML block. Emails authored
* programmatically (API/MCP) often have html but no design; loading a wrapped design shows the
* email in the canvas instead of a blank editor whose save would clobber the stored html.
- * Mirrors build_html_wrap_design in posthog/cdp/validation.py.
+ * Mirrors build_html_wrap_design in products/cdp/backend/validation.py.
*/
export function buildHtmlWrapDesign(html: string): JSONTemplate {
// Fixed ids keep the wrap deterministic: re-wrapping the same html yields an identical
diff --git a/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.ts b/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.ts
index e3d13f2f5c85..3011924a5394 100644
--- a/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.ts
+++ b/nodejs/src/cdp/templates/_destinations/posthog_signals/posthog-run-scout.template.ts
@@ -55,7 +55,7 @@ return run
// A missing or unrunnable scout answers 404, deliberately NOT listed here, so a
// misconfigured node fails loudly.
// required (despite being hidden): the backend only fills a schema default for a
- // required input (posthog/cdp/validation.py), and an API- or MCP-built step has no
+ // required input (products/cdp/backend/validation.py), and an API- or MCP-built step has no
// editor to pre-fill this from the template, so it would otherwise publish with the
// field unset and fail its workflow on ordinary backpressure instead of skipping.
key: 'non_failure_status_codes',
diff --git a/nodejs/src/cdp/utils/filter-runtime.ts b/nodejs/src/cdp/utils/filter-runtime.ts
index 70b2ec5432d3..b0e93dc188ef 100644
--- a/nodejs/src/cdp/utils/filter-runtime.ts
+++ b/nodejs/src/cdp/utils/filter-runtime.ts
@@ -7,7 +7,7 @@ import { HogFunctionInvocationGlobals, HogFunctionInvocationGlobalsWithInputs }
import { convertClickhouseRawEventToFilterGlobals, convertToHogFunctionFilterGlobal } from './hog-function-filtering'
/** Where Django reads the result. Relative to the repository root. */
-export const FILTER_GLOBALS_RELATIVE_PATH = 'posthog/cdp/filter_globals.json'
+export const FILTER_GLOBALS_RELATIVE_PATH = 'products/cdp/backend/filter_globals.json'
export type FilterRuntime = {
/** Data globals every filter compiled by compile_filters_bytecode is evaluated with. */
diff --git a/nodejs/src/cdp/workflows-e2e.serial.test.ts b/nodejs/src/cdp/workflows-e2e.serial.test.ts
index 7777a149ff96..f49f426a9c20 100644
--- a/nodejs/src/cdp/workflows-e2e.serial.test.ts
+++ b/nodejs/src/cdp/workflows-e2e.serial.test.ts
@@ -2371,7 +2371,7 @@ describe('Workflows E2E (postgres-v2)', () => {
})
describe('posthog_ticket_tags input resolves templated values per element', () => {
- // Regression guard for the templating opt-in in posthog/cdp/validation.py.
+ // Regression guard for the templating opt-in in products/cdp/backend/validation.py.
// Reproduces the real user-reported case: a ticket tag set to
// `zendesk/{variables.zendesk_ticketid}` used to ship to the runtime as
// a literal placeholder string (because the type wasn't on the bytecode
diff --git a/posthog/api/cohort.py b/posthog/api/cohort.py
index 4f33f91ff0bb..28163f08d359 100644
--- a/posthog/api/cohort.py
+++ b/posthog/api/cohort.py
@@ -46,7 +46,6 @@ from posthog.api.services.flags_service import (
)
from posthog.api.shared import SearchMatchTypeSerializerMixin, SerializedPersonActorSerializer, UserBasicSerializer
from posthog.api.utils import action, paging_params, parse_actor_property_filters
-from posthog.cdp.filters import build_behavioral_event_expr
from posthog.clickhouse.query_tagging import Feature, tag_queries
from posthog.dataclasses import frozen
from posthog.event_usage import report_user_action
@@ -87,6 +86,7 @@ from posthog.renderers import SafeJSONRenderer
from posthog.taxonomy.hidden_events import HIDDEN_EVENT_REASON, added_hidden_event
from posthog.utils import format_query_params_absolute_url, str_to_bool
+from products.cdp.backend.filters import build_behavioral_event_expr
from products.cohorts.backend.models.calculation_history import CohortCalculationHistory
from products.cohorts.backend.models.cohort import (
DEFAULT_COHORT_INSERT_BATCH_SIZE,
diff --git a/posthog/cdp/site_functions.py b/posthog/cdp/site_functions.py
index 03cf975027d9..7b3a13893737 100644
--- a/posthog/cdp/site_functions.py
+++ b/posthog/cdp/site_functions.py
@@ -3,11 +3,10 @@ from typing import Any
from posthog.hogql.compiler.javascript import JavaScriptCompiler
-from posthog.cdp.filters import hog_function_filters_to_expr
-from posthog.cdp.validation import transpile_template_code
-
+from products.cdp.backend.filters import hog_function_filters_to_expr
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
from products.cdp.backend.models.plugin import transpile
+from products.cdp.backend.validation import transpile_template_code
def exposed_secret_input_keys(hog_function: HogFunction) -> set[str]:
diff --git a/posthog/cdp/templates/helpers.py b/posthog/cdp/templates/helpers.py
index 6a9315e2e56d..25b08b159405 100644
--- a/posthog/cdp/templates/helpers.py
+++ b/posthog/cdp/templates/helpers.py
@@ -8,10 +8,10 @@ from unittest.mock import MagicMock, patch
from posthog.cdp.site_functions import get_transpiled_function
from posthog.cdp.templates.hog_function_template import HogFunctionTemplateDC, sync_template_to_db
-from posthog.cdp.validation import compile_hog
from posthog.models.utils import uuid7
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.validation import compile_hog
from common.hogvm.python.execute import execute_bytecode
from common.hogvm.python.stl import now
diff --git a/posthog/cdp/templates/knock/test_knock_template.py b/posthog/cdp/templates/knock/test_knock_template.py
index 103909634739..30b77e61f115 100644
--- a/posthog/cdp/templates/knock/test_knock_template.py
+++ b/posthog/cdp/templates/knock/test_knock_template.py
@@ -4,7 +4,8 @@ from parameterized import parameterized
from posthog.cdp.templates.helpers import BaseHogFunctionTemplateTest
from posthog.cdp.templates.knock.template_knock import template as template_knock
-from posthog.cdp.validation import generate_template_bytecode
+
+from products.cdp.backend.validation import generate_template_bytecode
from common.hogvm.python.execute import execute_bytecode
from common.hogvm.python.utils import HogVMException
diff --git a/posthog/cdp/templates/test_cdp_templates.py b/posthog/cdp/templates/test_cdp_templates.py
index 661b58ca2f0e..f538809c9303 100644
--- a/posthog/cdp/templates/test_cdp_templates.py
+++ b/posthog/cdp/templates/test_cdp_templates.py
@@ -4,10 +4,10 @@ from posthog.test.base import BaseTest
from posthog.cdp.templates import HOG_FUNCTION_TEMPLATES
from posthog.cdp.templates.hog_function_template import sync_template_to_db
-from posthog.cdp.validation import InputsSchemaItemSerializer, compile_hog
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
from products.cdp.backend.models.hog_functions.hog_function import TYPES_WITH_TRANSPILED_FILTERS
+from products.cdp.backend.validation import InputsSchemaItemSerializer, compile_hog
class TestTemplatesGeneral(BaseTest):
diff --git a/posthog/management/commands/migrate_legacy_geoip_transformations.py b/posthog/management/commands/migrate_legacy_geoip_transformations.py
index e72ce76e8864..4ae5546b3495 100644
--- a/posthog/management/commands/migrate_legacy_geoip_transformations.py
+++ b/posthog/management/commands/migrate_legacy_geoip_transformations.py
@@ -4,10 +4,9 @@ from django.core.management.base import BaseCommand
import structlog
-from posthog.cdp.validation import compile_hog
-
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.validation import compile_hog
logger = structlog.get_logger(__name__)
diff --git a/posthog/management/commands/refresh_hog_functions.py b/posthog/management/commands/refresh_hog_functions.py
index cda4264491cf..d5911657f4f6 100644
--- a/posthog/management/commands/refresh_hog_functions.py
+++ b/posthog/management/commands/refresh_hog_functions.py
@@ -7,11 +7,11 @@ from django.core.paginator import Paginator
import structlog
-from posthog.cdp.filters import DATA_WAREHOUSE_SOURCES, RUNTIME_CONTRACT, compile_filters_bytecode
-from posthog.cdp.validation import generate_template_bytecode
from posthog.dataclasses import frozen
+from products.cdp.backend.filters import DATA_WAREHOUSE_SOURCES, RUNTIME_CONTRACT, compile_filters_bytecode
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.validation import generate_template_bytecode
logger = structlog.get_logger(__name__)
diff --git a/posthog/management/commands/test/test_migrate_hooks.py b/posthog/management/commands/test/test_migrate_hooks.py
index 5ec2ab5b6cca..baa8fe59349a 100644
--- a/posthog/management/commands/test/test_migrate_hooks.py
+++ b/posthog/management/commands/test/test_migrate_hooks.py
@@ -1,11 +1,11 @@
from posthog.test.base import BaseTest
-from posthog.cdp.filters import RUNTIME_CONTRACT
from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.cdp.templates.zapier.template_zapier import template as template_zapier
from posthog.management.commands.migrate_hooks import migrate_hooks
from products.actions.backend.models.action import Action
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
from products.cdp.backend.models.hook import Hook
diff --git a/posthog/management/commands/test/test_migrate_legacy_geoip_transformations.py b/posthog/management/commands/test/test_migrate_legacy_geoip_transformations.py
index bcc4a9c2f3a8..1df809a3b08f 100644
--- a/posthog/management/commands/test/test_migrate_legacy_geoip_transformations.py
+++ b/posthog/management/commands/test/test_migrate_legacy_geoip_transformations.py
@@ -5,10 +5,9 @@ from unittest.mock import patch
from django.core.management import call_command
-from posthog.cdp.validation import compile_hog
-
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.validation import compile_hog
GEOIP_TEMPLATE_CODE = """
if (event.properties?.$geoip_disable or empty(event.properties?.$ip)) {
diff --git a/posthog/management/commands/test/test_refresh_hog_functions.py b/posthog/management/commands/test/test_refresh_hog_functions.py
index 8ad4fdd71db7..6401786bcd60 100644
--- a/posthog/management/commands/test/test_refresh_hog_functions.py
+++ b/posthog/management/commands/test/test_refresh_hog_functions.py
@@ -8,11 +8,11 @@ from django.core.management import call_command
from parameterized import parameterized
-from posthog.cdp.filters import RUNTIME_CONTRACT
-from posthog.cdp.validation import generate_template_bytecode
from posthog.models import Team
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.validation import generate_template_bytecode
class TestRefreshHogFunctions(BaseTest):
diff --git a/posthog/management/commands/test/test_update_hog_function_code.py b/posthog/management/commands/test/test_update_hog_function_code.py
index bb207e62c293..d48298edc935 100644
--- a/posthog/management/commands/test/test_update_hog_function_code.py
+++ b/posthog/management/commands/test/test_update_hog_function_code.py
@@ -7,9 +7,8 @@ from django.core.management import call_command
from parameterized import parameterized
-from posthog.cdp.validation import compile_hog as compile_hog_for_check
-
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.validation import compile_hog as compile_hog_for_check
# The powerplatform branch the migration must splice into stale Microsoft Teams functions.
POWERPLATFORM_BRANCH = "environment.api.powerplatform.com(:443)?/powerautomate/automations/direct/(.*/)?workflows"
@@ -386,7 +385,7 @@ class TestUpdateHogFunctionCode(BaseTest):
self.assertIn("Failed: 1", output)
self.assertIn(str(bad_function.id), output)
- @patch("posthog.cdp.validation.compile_hog")
+ @patch("products.cdp.backend.validation.compile_hog")
def test_invalid_replace_key(self, mock_compile_hog):
"""Test handling of invalid replace key."""
out = StringIO()
@@ -406,7 +405,7 @@ class TestUpdateHogFunctionCode(BaseTest):
output = out.getvalue()
self.assertIn("Invalid replace key provided: None", output)
- @patch("posthog.cdp.validation.compile_hog")
+ @patch("products.cdp.backend.validation.compile_hog")
def test_no_matching_functions(self, mock_compile_hog):
"""Test when no functions match the criteria."""
# Delete all LinkedIn functions
diff --git a/posthog/management/commands/update_hog_function_code.py b/posthog/management/commands/update_hog_function_code.py
index 04c64920e5b5..df5ca9e7adbc 100644
--- a/posthog/management/commands/update_hog_function_code.py
+++ b/posthog/management/commands/update_hog_function_code.py
@@ -6,9 +6,8 @@ from django.core.paginator import Paginator
import structlog
-from posthog.cdp.validation import compile_hog
-
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+from products.cdp.backend.validation import compile_hog
logger = structlog.get_logger(__name__)
diff --git a/posthog/models/group_usage_metric.py b/posthog/models/group_usage_metric.py
index d91437768f43..8d265401f57a 100644
--- a/posthog/models/group_usage_metric.py
+++ b/posthog/models/group_usage_metric.py
@@ -67,6 +67,6 @@ class GroupUsageMetric(UUIDModel, BytecodeModelMixin):
if self.is_data_warehouse:
return ast.Constant(value=True)
- from posthog.cdp.filters import hog_function_filters_to_expr
+ from products.cdp.backend.filters import hog_function_filters_to_expr
return hog_function_filters_to_expr(self.filters, self.team, {})
diff --git a/posthog/models/test/test_hog_function.py b/posthog/models/test/test_hog_function.py
index 032742c72ea4..f0a7dacdcda7 100644
--- a/posthog/models/test/test_hog_function.py
+++ b/posthog/models/test/test_hog_function.py
@@ -8,12 +8,12 @@ from django.test import TestCase
from parameterized import parameterized
-from posthog.cdp.filters import RUNTIME_CONTRACT
from posthog.models.file_system.file_system import FileSystem
from posthog.models.team.team import Team
from posthog.models.user import User
from products.actions.backend.models.action import Action
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.cdp.backend.models.hog_functions.hog_function import HogFunction, HogFunctionType
from products.cdp.backend.tasks.hog_functions import refresh_affected_hog_functions
from products.cohorts.backend.models.cohort import Cohort
diff --git a/posthog/temporal/ai_observability/test_run_evaluation.py b/posthog/temporal/ai_observability/test_run_evaluation.py
index ee2f4615045c..ff1bd7b1a090 100644
--- a/posthog/temporal/ai_observability/test_run_evaluation.py
+++ b/posthog/temporal/ai_observability/test_run_evaluation.py
@@ -3120,7 +3120,7 @@ class TestExecuteHogEvalActivity:
team = setup_data["team"]
# Compile source to bytecode for the test
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return true", "destination")
@@ -3146,7 +3146,7 @@ class TestExecuteHogEvalActivity:
async def test_hog_eval_returns_false(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return false", "destination")
@@ -3171,7 +3171,7 @@ class TestExecuteHogEvalActivity:
async def test_hog_eval_non_bool_returns_skipped(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return 42", "destination")
@@ -3201,7 +3201,7 @@ class TestExecuteHogEvalActivity:
async def test_hog_eval_captures_print_as_reasoning(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
source = "print('checking output'); return true"
bytecode = compile_hog(source, "destination")
@@ -3268,7 +3268,7 @@ class TestExecuteHogEvalActivity:
async def test_hog_eval_accesses_globals(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
source = """
return output == 'test output'
@@ -3299,7 +3299,7 @@ class TestExecuteHogEvalActivity:
async def test_hog_eval_runtime_error_returns_skipped(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return true", "destination")
@@ -3338,7 +3338,7 @@ class TestExecuteHogEvalActivity:
)
async def test_hog_eval_null_comparisons_evaluate_to_false(self, source):
# A missing value is no match, not a runtime error, so the eval completes with a verdict.
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog(source, "destination")
evaluation = {
@@ -3380,7 +3380,7 @@ class TestExecuteHogEvalActivity:
ids=["invalid-regex", "list-regex-input", "array-assignment-index"],
)
async def test_hog_eval_vm_user_errors_return_skipped(self, source, properties, expected_reasoning):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog(source, "destination")
evaluation = {
@@ -3406,7 +3406,7 @@ class TestExecuteHogEvalActivity:
@pytest.mark.asyncio
async def test_hog_eval_unexpected_error_raises(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return true", "destination")
@@ -3779,7 +3779,7 @@ class TestEvalResultModels:
class TestRunHogEvalAllowsNA:
@pytest.fixture(autouse=True)
def _compile(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
self.compile_hog = compile_hog
@@ -3844,7 +3844,7 @@ class TestExecuteHogEvalActivityAllowsNA:
async def test_hog_eval_null_return_with_allows_na(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return null", "destination")
@@ -3871,7 +3871,7 @@ class TestExecuteHogEvalActivityAllowsNA:
async def test_hog_eval_bool_return_with_allows_na(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return true", "destination")
@@ -3898,7 +3898,7 @@ class TestExecuteHogEvalActivityAllowsNA:
async def test_hog_eval_null_return_without_allows_na_returns_skipped(self, setup_data):
team = setup_data["team"]
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return null", "destination")
@@ -4234,7 +4234,7 @@ class TestRunLocalEvaluationActivity:
START_TIME = datetime(2026, 1, 1, tzinfo=UTC)
def _create_hog_evaluation(self, team, source: str):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
return Evaluation.objects.create(
team=team,
diff --git a/posthog/temporal/ai_observability/test_run_session_evaluation.py b/posthog/temporal/ai_observability/test_run_session_evaluation.py
index d2aaa3ae96cb..7981289a4ace 100644
--- a/posthog/temporal/ai_observability/test_run_session_evaluation.py
+++ b/posthog/temporal/ai_observability/test_run_session_evaluation.py
@@ -13,7 +13,6 @@ from posthog.schema import LLMTrace, LLMTraceEvent
from posthog.hogql.constants import MAX_SELECT_TRACES_LIMIT_EXPORT
-from posthog.cdp.validation import compile_hog
from posthog.temporal.ai_observability.evaluation_hog import run_hog_eval_for_event
from posthog.temporal.ai_observability.evaluation_llm_judge import (
ExecuteLLMJudgeInputs,
@@ -45,6 +44,7 @@ from posthog.temporal.ai_observability.run_trace_evaluation import (
)
from products.ai_observability.backend.hog import compile_ai_observability_hog
+from products.cdp.backend.validation import compile_hog
FROZEN_NOW = datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC)
diff --git a/posthog/temporal/ai_observability/test_run_tagger.py b/posthog/temporal/ai_observability/test_run_tagger.py
index 08d430650651..e5e52ed553ac 100644
--- a/posthog/temporal/ai_observability/test_run_tagger.py
+++ b/posthog/temporal/ai_observability/test_run_tagger.py
@@ -636,7 +636,7 @@ class TestRunTaggerWorkflow:
def make_hog_tagger_dict(team_id: int, source: str, tags: list[dict] | None = None) -> dict:
"""Build the tagger payload that the workflow passes to the Hog activity."""
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog(source, "tagger")
return {
@@ -661,7 +661,7 @@ class TestRunHogTagger:
return create_mock_event_data(team_id=1)
def test_returns_list_of_strings(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return ['billing']", "tagger")
@@ -671,7 +671,7 @@ class TestRunHogTagger:
assert result["error"] is None
def test_filters_unknown_tags_against_whitelist(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return ['billing', 'unknown', 'analytics']", "tagger")
@@ -685,7 +685,7 @@ class TestRunHogTagger:
"""When tagger_config['tags'] is empty (Hog-only freeform), the source's
return value is taken at face value — this is the documented behavior
for Hog taggers without a tag whitelist."""
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return ['anything', 'goes']", "tagger")
@@ -695,7 +695,7 @@ class TestRunHogTagger:
assert result["error"] is None
def test_string_return_is_promoted_to_single_tag_list(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return 'billing'", "tagger")
@@ -705,7 +705,7 @@ class TestRunHogTagger:
assert result["error"] is None
def test_non_list_return_type_surfaces_error(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return 42", "tagger")
@@ -716,7 +716,7 @@ class TestRunHogTagger:
assert "Must return a list of tag names" in result["error"]
def test_null_return_yields_empty_tags_no_error(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("return null", "tagger")
@@ -726,7 +726,7 @@ class TestRunHogTagger:
assert result["error"] is None
def test_print_output_captured_as_reasoning(self):
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
bytecode = compile_hog("print('inspecting input'); return ['billing']", "tagger")
diff --git a/posthog/temporal/ai_observability/test_run_trace_evaluation.py b/posthog/temporal/ai_observability/test_run_trace_evaluation.py
index fa57004a5a71..50a16ae300c3 100644
--- a/posthog/temporal/ai_observability/test_run_trace_evaluation.py
+++ b/posthog/temporal/ai_observability/test_run_trace_evaluation.py
@@ -15,7 +15,6 @@ from posthog.schema import LLMTrace, LLMTraceEvent
from posthog.hogql import ast
from posthog.api.capture import CaptureInternalError
-from posthog.cdp.validation import compile_hog
from posthog.constants import AvailableFeature
from posthog.models import Organization, PropertyDefinition, Team, User
from posthog.temporal.ai_observability.run_session_evaluation import fetch_session_for_evaluation
@@ -25,6 +24,7 @@ from products.access_control.backend.models.property_access_control import Prope
from products.ai_observability.backend.models.evaluation_config import EvaluationConfig
from products.ai_observability.backend.models.evaluations import Evaluation
from products.ai_observability.backend.models.provider_keys import LLMProviderKey
+from products.cdp.backend.validation import compile_hog
from .evaluation_hog import execute_hog_eval_bytecode
from .evaluation_llm_judge import BooleanEvalResult
diff --git a/products/ai_observability/backend/hog.py b/products/ai_observability/backend/hog.py
index a565a334c7b3..47af6c97fd77 100644
--- a/products/ai_observability/backend/hog.py
+++ b/products/ai_observability/backend/hog.py
@@ -1,6 +1,6 @@
from typing import Any, Literal
-from posthog.cdp.validation import compile_hog
+from products.cdp.backend.validation import compile_hog
AIObservabilityHogType = Literal["destination", "tagger"]
diff --git a/products/ai_observability/backend/models/evaluations.py b/products/ai_observability/backend/models/evaluations.py
index e73eb064b728..649b7a00efcf 100644
--- a/products/ai_observability/backend/models/evaluations.py
+++ b/products/ai_observability/backend/models/evaluations.py
@@ -232,7 +232,7 @@ class Evaluation(ModelActivityMixin, UUIDTModel):
return [c.get("properties", []) for c in self.conditions] != [c.get("properties", []) for c in stored]
def save(self, *args, **kwargs):
- from posthog.cdp.filters import compile_filters_bytecode
+ from products.cdp.backend.filters import compile_filters_bytecode
from ..hog import compile_ai_observability_hog # noqa: PLC0415 - keeps Hog compiler off model import path
diff --git a/products/ai_observability/backend/models/taggers.py b/products/ai_observability/backend/models/taggers.py
index 4fdfd26348d7..6af854df94bd 100644
--- a/products/ai_observability/backend/models/taggers.py
+++ b/products/ai_observability/backend/models/taggers.py
@@ -147,7 +147,7 @@ class Tagger(UUIDTModel):
return self.name
def save(self, *args, **kwargs):
- from posthog.cdp.filters import compile_filters_bytecode
+ from products.cdp.backend.filters import compile_filters_bytecode
from ..hog import compile_ai_observability_hog # noqa: PLC0415 - keeps Hog compiler off model import path
diff --git a/products/ai_observability/backend/models/test/test_evaluations.py b/products/ai_observability/backend/models/test/test_evaluations.py
index 7e926413e9b7..dc40d313660d 100644
--- a/products/ai_observability/backend/models/test/test_evaluations.py
+++ b/products/ai_observability/backend/models/test/test_evaluations.py
@@ -51,7 +51,7 @@ class TestEvaluationModel(BaseTest):
):
evaluation = self._create_hog_evaluation()
- with patch("posthog.cdp.filters.compile_filters_bytecode") as mock_compile:
+ with patch("products.cdp.backend.filters.compile_filters_bytecode") as mock_compile:
mock_compile.return_value = {"bytecode": None, "bytecode_error": "Invalid property filter"}
if updates is None:
evaluation.set_status(EvaluationStatus.ERROR, EvaluationStatusReason.HOG_ERROR)
diff --git a/products/ai_observability/backend/models/test/test_taggers.py b/products/ai_observability/backend/models/test/test_taggers.py
index 3092bae7aba8..bf912fbebd6d 100644
--- a/products/ai_observability/backend/models/test/test_taggers.py
+++ b/products/ai_observability/backend/models/test/test_taggers.py
@@ -154,7 +154,7 @@ class TestTaggerModel(BaseTest):
assert isinstance(tagger.conditions[0]["bytecode"], list)
def test_sets_bytecode_error_when_compilation_fails(self):
- with patch("posthog.cdp.filters.compile_filters_bytecode") as mock_compile:
+ with patch("products.cdp.backend.filters.compile_filters_bytecode") as mock_compile:
mock_compile.return_value = {"bytecode": None, "bytecode_error": "Invalid property filter"}
tagger = Tagger.objects.create(
diff --git a/products/ai_observability/backend/test_hog_eval_examples.py b/products/ai_observability/backend/test_hog_eval_examples.py
index 206783bbed51..49daf9d24f25 100644
--- a/products/ai_observability/backend/test_hog_eval_examples.py
+++ b/products/ai_observability/backend/test_hog_eval_examples.py
@@ -13,12 +13,13 @@ from parameterized import parameterized
from posthog.schema import LLMTrace, LLMTraceEvent
-from posthog.cdp.validation import compile_hog
from posthog.temporal.ai_observability.evaluation_hog import execute_hog_eval_bytecode
from posthog.temporal.ai_observability.run_evaluation import run_hog_eval
from posthog.temporal.ai_observability.run_session_evaluation import build_session_hog_globals
from posthog.temporal.ai_observability.run_trace_evaluation import build_trace_hog_globals
+from products.cdp.backend.validation import compile_hog
+
EXAMPLES_PATH = Path(__file__).resolve().parents[1] / "frontend" / "evaluations" / "hogEvalExamples.json"
EXAMPLES: list[dict] = json.loads(EXAMPLES_PATH.read_text())
EXAMPLE_LABELS = [e["label"] for e in EXAMPLES]
diff --git a/products/alerts/backend/destination_backfill.py b/products/alerts/backend/destination_backfill.py
index 36f774cc797a..fb0d790865ec 100644
--- a/products/alerts/backend/destination_backfill.py
+++ b/products/alerts/backend/destination_backfill.py
@@ -19,13 +19,13 @@ from django.db.models import QuerySet
import structlog
-from posthog.cdp.validation import generate_template_bytecode
from posthog.dataclasses import frozen
from posthog.plugins.plugin_server_api import reload_hog_functions_on_workers
from posthog.tasks.alerts.utils import INSIGHT_ALERT_FIRING_EVENT
from products.alerts.backend.logic.insight_alert_destinations import INSIGHT_CHART_BLOCK, SLACK_TEMPLATE_ID
from products.cdp.backend.facade.models import HogFunction
+from products.cdp.backend.validation import generate_template_bytecode
logger = structlog.get_logger(__name__)
diff --git a/products/cdp/backend/api/hog_function.py b/products/cdp/backend/api/hog_function.py
index 252b1f32b051..e8dce3d577d9 100644
--- a/products/cdp/backend/api/hog_function.py
+++ b/products/cdp/backend/api/hog_function.py
@@ -28,21 +28,8 @@ from posthog.api.log_entries import LogEntryMixin
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.shared import SearchMatchTypeSerializerMixin, UserBasicSerializer
from posthog.api.utils import action, log_activity_from_viewset
-from posthog.cdp.filters import DATA_WAREHOUSE_SOURCES
from posthog.cdp.services.icons import CDPIconsService
from posthog.cdp.site_functions import get_transpiled_function
-from posthog.cdp.validation import (
- DUPLICATE_INPUT_KEYS_ERROR,
- HogFunctionFiltersSerializer,
- InputsSchemaSerializer,
- InputsSerializer,
- MappingsSerializer,
- added_duplicate_input_keys,
- compile_hog,
- generate_template_bytecode,
- masked_secret_input_keys,
- reserved_functions_used,
-)
from posthog.event_usage import AGENT_EVENT_SOURCES, get_event_source
from posthog.exceptions_capture import capture_exception
from posthog.helpers.impersonation import is_impersonated
@@ -61,6 +48,7 @@ from posthog.scopes import APIScopeObject
from products.batch_exports.backend.facade import api as batch_exports_api
from products.batch_exports.backend.facade.contracts import InvalidBatchExportFilters
from products.cdp.backend.api.hog_function_template import HogFunctionTemplateSerializer
+from products.cdp.backend.filters import DATA_WAREHOUSE_SOURCES
from products.cdp.backend.internal_events import (
generic_api_editable_alert_scope,
is_managed_alert_internal_event,
@@ -82,6 +70,18 @@ from products.cdp.backend.presentation.hog_invocations.rerun import (
HogInvocationRerunRequestSerializer,
HogInvocationRerunResponseSerializer,
)
+from products.cdp.backend.validation import (
+ DUPLICATE_INPUT_KEYS_ERROR,
+ HogFunctionFiltersSerializer,
+ InputsSchemaSerializer,
+ InputsSerializer,
+ MappingsSerializer,
+ added_duplicate_input_keys,
+ compile_hog,
+ generate_template_bytecode,
+ masked_secret_input_keys,
+ reserved_functions_used,
+)
# Maximum size of HOG code as a string in bytes (100KB)
MAX_HOG_CODE_SIZE_BYTES = 100 * 1024
@@ -195,7 +195,7 @@ def _named_warehouse_tables(entries: Any) -> list[Any]:
"""The warehouse tables a filters blob actually names, ignoring the picker's placeholder row.
Matches the placeholder rule `HogFunctionFiltersSerializer.validate` applies moments later
- (posthog/cdp/validation.py): it drops any entry named "Select a table" outright, regardless of
+ (products/cdp/backend/validation.py): it drops any entry named "Select a table" outright, regardless of
whether that entry also carries a `table_name`. Checking `table_name` alone here would accept
`{"name": "Select a table", "table_name": "x"}` — the serializer would still strip it a moment
later, leaving `data_warehouse: []` stored despite this check having passed.
diff --git a/products/cdp/backend/api/test/test_hog_function.py b/products/cdp/backend/api/test/test_hog_function.py
index 8cde4005fb26..7d0bb0d53a27 100644
--- a/products/cdp/backend/api/test/test_hog_function.py
+++ b/products/cdp/backend/api/test/test_hog_function.py
@@ -10,7 +10,6 @@ from django.db import connection
from parameterized import parameterized
from rest_framework import status
-from posthog.cdp.filters import RUNTIME_CONTRACT
from posthog.cdp.templates.fixtures import template_slack
from posthog.cdp.templates.helpers import mock_transpile
from posthog.cdp.templates.hog_function_template import sync_template_to_db
@@ -24,6 +23,7 @@ from products.cdp.backend.api.hog_function import (
comparable_content,
)
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
from products.cdp.backend.models.hog_functions.hog_function import DEFAULT_STATE, HogFunction, HogFunctionState
from products.cohorts.backend.models.cohort import Cohort
diff --git a/products/cdp/backend/api/test/test_hooks.py b/products/cdp/backend/api/test/test_hooks.py
index 5bfd544de77d..e736a52fe23b 100644
--- a/products/cdp/backend/api/test/test_hooks.py
+++ b/products/cdp/backend/api/test/test_hooks.py
@@ -4,12 +4,12 @@ from typing import Any
import pytest
from posthog.test.base import ClickhouseTestMixin
-from posthog.cdp.filters import RUNTIME_CONTRACT
from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.cdp.templates.zapier.template_zapier import template as template_zapier
from products.actions.backend.models.action import Action
from products.cdp.backend.api.hooks import create_zapier_hog_function, valid_domain
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
from products.cdp.backend.models.hook import Hook
diff --git a/products/cdp/backend/api/test/test_plugin.py b/products/cdp/backend/api/test/test_plugin.py
index 64408e1f9993..8491e146b67c 100644
--- a/products/cdp/backend/api/test/test_plugin.py
+++ b/products/cdp/backend/api/test/test_plugin.py
@@ -15,7 +15,6 @@ from django.test import override_settings
from rest_framework import status
-from posthog.cdp.filters import RUNTIME_CONTRACT
from posthog.cdp.templates.helpers import mock_transpile
from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.constants import FROZEN_POSTHOG_VERSION
@@ -27,6 +26,7 @@ from posthog.plugins.test.mock import mocked_plugin_github_request, mocked_plugi
from posthog.plugins.test.plugin_archives import HELLO_WORLD_PLUGIN_GITHUB_ATTACHMENT_ZIP, HELLO_WORLD_PLUGIN_GITHUB_ZIP
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
from products.cdp.backend.models.plugin import Plugin, PluginConfig, PluginSourceFile
diff --git a/posthog/cdp/filter_globals.json b/products/cdp/backend/filter_globals.json
similarity index 100%
rename from posthog/cdp/filter_globals.json
rename to products/cdp/backend/filter_globals.json
diff --git a/posthog/cdp/filters.py b/products/cdp/backend/filters.py
similarity index 100%
rename from posthog/cdp/filters.py
rename to products/cdp/backend/filters.py
diff --git a/products/cdp/backend/max_tools.py b/products/cdp/backend/max_tools.py
index 8dee549dec28..16487b336612 100644
--- a/products/cdp/backend/max_tools.py
+++ b/products/cdp/backend/max_tools.py
@@ -9,8 +9,6 @@ from pydantic import BaseModel, Field
from posthog.hogql import errors as hogql_errors
from posthog.hogql.parser import parse_program
-from posthog.cdp.validation import compile_hog
-
from products.cdp.backend.prompts import (
DESTINATION_LIMITATIONS_MESSAGE,
HOG_EXAMPLE_MESSAGE,
@@ -25,6 +23,7 @@ from products.cdp.backend.prompts import (
TRANSFORMATION_STRUCTURE_MESSAGE,
render_filters_system_prompt,
)
+from products.cdp.backend.validation import compile_hog
from ee.hogai.chat_agent.schema_generator.parsers import PydanticOutputParserException
from ee.hogai.llm import MaxChatOpenAI
diff --git a/products/cdp/backend/models/hog_function_template.py b/products/cdp/backend/models/hog_function_template.py
index 83e8a7aba0ac..897fff413aae 100644
--- a/products/cdp/backend/models/hog_function_template.py
+++ b/products/cdp/backend/models/hog_function_template.py
@@ -136,7 +136,7 @@ class HogFunctionTemplate(UUIDTModel):
self.bytecode = None
return
try:
- from posthog.cdp.validation import compile_hog
+ from products.cdp.backend.validation import compile_hog
# Compile the hog code_language to bytecode and store it in the database field
self.bytecode = compile_hog(self.code, self.type)
diff --git a/products/cdp/backend/models/hog_functions/hog_function.py b/products/cdp/backend/models/hog_functions/hog_function.py
index 09475222256b..7fa912188c07 100644
--- a/products/cdp/backend/models/hog_functions/hog_function.py
+++ b/products/cdp/backend/models/hog_functions/hog_function.py
@@ -290,7 +290,7 @@ class HogFunction(FileSystemSyncMixin, UUIDTModel):
return absolute_uri(f"/project/{self.team_id}/pipeline/destinations/hog-{str(self.id)}")
def _compile_filters(self) -> dict:
- from posthog.cdp.filters import compile_filters_bytecode
+ from products.cdp.backend.filters import compile_filters_bytecode
compiled = compile_filters_bytecode(self.filters, self.team)
if not compiled.get("bytecode_error"):
diff --git a/products/cdp/backend/presentation/hog_functions.py b/products/cdp/backend/presentation/hog_functions.py
index 8ce43a55b232..f54ceb48328f 100644
--- a/products/cdp/backend/presentation/hog_functions.py
+++ b/products/cdp/backend/presentation/hog_functions.py
@@ -5,15 +5,16 @@ the helpers that workflows and messaging views use cross here. Their signatures
return untyped bytecode, so they cannot cross through the facade.
"""
-from posthog.cdp.filters import (
- DATA_WAREHOUSE_SOURCES as DATA_WAREHOUSE_SOURCES,
- compile_filters_expr as compile_filters_expr,
-)
from posthog.cdp.flag_gated_templates import (
FLAG_GATED_TEMPLATE_IDS as FLAG_GATED_TEMPLATE_IDS,
gated_template_enabled as gated_template_enabled,
)
-from posthog.cdp.validation import (
+
+from products.cdp.backend.filters import (
+ DATA_WAREHOUSE_SOURCES as DATA_WAREHOUSE_SOURCES,
+ compile_filters_expr as compile_filters_expr,
+)
+from products.cdp.backend.validation import (
build_html_wrap_design as build_html_wrap_design,
generate_template_bytecode as generate_template_bytecode,
)
diff --git a/products/cdp/backend/presentation/serializers.py b/products/cdp/backend/presentation/serializers.py
index 98d36d3931b8..833b00a2c339 100644
--- a/products/cdp/backend/presentation/serializers.py
+++ b/products/cdp/backend/presentation/serializers.py
@@ -3,7 +3,7 @@
A facade must not hand out DRF classes, so these cross through presentation instead.
"""
-from posthog.cdp.validation import (
+from products.cdp.backend.validation import (
HogFunctionFiltersSerializer as HogFunctionFiltersSerializer,
InputsSchemaSerializer as InputsSchemaSerializer,
InputsSerializer as InputsSerializer,
diff --git a/products/cdp/backend/tasks/hog_functions.py b/products/cdp/backend/tasks/hog_functions.py
index aad007930f58..e033c41c714b 100644
--- a/products/cdp/backend/tasks/hog_functions.py
+++ b/products/cdp/backend/tasks/hog_functions.py
@@ -78,9 +78,9 @@ def refresh_affected_hog_functions(
actions_by_id = {action.id: action for action in all_related_actions}
- # posthog.cdp.filters pulls hogql.property and with it the HogQL/schema layer;
+ # products.cdp.backend.filters pulls hogql.property and with it the HogQL/schema layer;
# posthog.apps ready() imports this module in every process at setup.
- from posthog.cdp.filters import compile_filters_bytecode # noqa: PLC0415 — keeps HogQL off the import path
+ from products.cdp.backend.filters import compile_filters_bytecode # noqa: PLC0415 — keeps HogQL off the import path
successfully_compiled_hog_functions = []
for hog_function in affected_hog_functions:
diff --git a/posthog/cdp/test/test_filters.py b/products/cdp/backend/test/test_filters.py
similarity index 99%
rename from posthog/cdp/test/test_filters.py
rename to products/cdp/backend/test/test_filters.py
index 710a13c04670..25f7165449e5 100644
--- a/posthog/cdp/test/test_filters.py
+++ b/products/cdp/backend/test/test_filters.py
@@ -7,15 +7,14 @@ from parameterized import parameterized
from posthog.hogql.compiler.bytecode import create_bytecode
-from posthog.cdp.filters import (
+from products.actions.backend.models.action import Action
+from products.cdp.backend.filters import (
RUNTIME_CONTRACT,
build_behavioral_event_expr,
cohort_filters_to_expr,
compile_filters_bytecode,
hog_function_filters_to_expr,
)
-
-from products.actions.backend.models.action import Action
from products.cohorts.backend.models.cohort import Cohort
from common.hogvm.python.execute import execute_bytecode
diff --git a/posthog/cdp/test/test_validation.py b/products/cdp/backend/test/test_validation.py
similarity index 99%
rename from posthog/cdp/test/test_validation.py
rename to products/cdp/backend/test/test_validation.py
index 6c874e4853e0..fc945aea3cc9 100644
--- a/posthog/cdp/test/test_validation.py
+++ b/products/cdp/backend/test/test_validation.py
@@ -10,8 +10,10 @@ from rest_framework.exceptions import ValidationError
from posthog.hogql import ast
-from posthog.cdp.filters import RUNTIME_CONTRACT
-from posthog.cdp.validation import (
+from posthog.models.integration import Integration
+
+from products.cdp.backend.filters import RUNTIME_CONTRACT
+from products.cdp.backend.validation import (
FunctionInputsSerializer,
HogFunctionFiltersSerializer,
InputsSchemaItemSerializer,
@@ -21,8 +23,6 @@ from posthog.cdp.validation import (
generate_template_bytecode,
reserved_functions_used,
)
-from posthog.models.integration import Integration
-
from products.messaging.backend.facade.api import validate_design
from common.hogvm.python.operation import HOGQL_BYTECODE_VERSION
diff --git a/posthog/cdp/validation.py b/products/cdp/backend/validation.py
similarity index 99%
rename from posthog/cdp/validation.py
rename to products/cdp/backend/validation.py
index aef7a2de8d84..cd7cce79ea59 100644
--- a/posthog/cdp/validation.py
+++ b/products/cdp/backend/validation.py
@@ -16,7 +16,9 @@ from posthog.hogql.context import HogQLContext
from posthog.hogql.parser import parse_program, parse_string_template
from posthog.hogql.visitor import TraversingVisitor
-from posthog.cdp.filters import (
+from posthog.models.integration import POSTHOG_CONNECT_KIND, Integration
+
+from products.cdp.backend.filters import (
DATA_WAREHOUSE_SOURCES,
FILTER_FUNCTIONS,
RUNTIME_CONTRACT,
@@ -25,8 +27,6 @@ from posthog.cdp.filters import (
compile_filters_bytecode,
compile_filters_expr,
)
-from posthog.models.integration import POSTHOG_CONNECT_KIND, Integration
-
from products.cdp.backend.models.hog_functions.hog_function import (
TYPES_WITH_JAVASCRIPT_SOURCE,
TYPES_WITH_TRANSPILED_FILTERS,
diff --git a/products/error_tracking/backend/logic/alerts.py b/products/error_tracking/backend/logic/alerts.py
index 52f417e395d1..68197e9380d7 100644
--- a/products/error_tracking/backend/logic/alerts.py
+++ b/products/error_tracking/backend/logic/alerts.py
@@ -8,13 +8,13 @@ from django.db.models import QuerySet
import structlog
-from posthog.cdp.filters import compile_filters_bytecode
from posthog.models.integration import Integration
from posthog.models.scoping.manager import resolve_effective_team_id
from posthog.models.team.team import Team
from posthog.models.user import User
from posthog.ph_client import feature_enabled_or_false
+from products.cdp.backend.filters import compile_filters_bytecode
from products.error_tracking.backend.models import ErrorTrackingAlert, ErrorTrackingAlertDestination
logger = structlog.get_logger(__name__)
diff --git a/products/error_tracking/backend/models.py b/products/error_tracking/backend/models.py
index 407117058622..714158e2cd2e 100644
--- a/products/error_tracking/backend/models.py
+++ b/products/error_tracking/backend/models.py
@@ -986,7 +986,7 @@ class ErrorTrackingAlert(TeamScopedRootMixin, UUIDTModel):
enabled = models.BooleanField(default=True)
triggers = models.JSONField(default=list) # list of Trigger values
# Same property-filter shape hog functions store, with the compiled HogQL bytecode
- # embedded under "bytecode" (see posthog.cdp.filters.compile_filters_bytecode).
+ # embedded under "bytecode" (see products.cdp.backend.filters.compile_filters_bytecode).
filters = models.JSONField(default=dict, blank=True)
# Minimum seconds between thread-opening notifications per (alert, issue).
# Replies into an existing thread are never throttled. 0 disables the throttle.
diff --git a/products/error_tracking/backend/tests/test_alert_delivery.py b/products/error_tracking/backend/tests/test_alert_delivery.py
index 74469018977d..d89e6cb2d19a 100644
--- a/products/error_tracking/backend/tests/test_alert_delivery.py
+++ b/products/error_tracking/backend/tests/test_alert_delivery.py
@@ -17,11 +17,11 @@ from slack_sdk.web.slack_response import SlackResponse
from temporalio.common import WorkflowIDReusePolicy
from temporalio.exceptions import ApplicationError, WorkflowAlreadyStartedError
-from posthog.cdp.filters import compile_filters_bytecode
from posthog.models.integration import Integration
from posthog.models.scoping import team_scope
from posthog.redis import get_client
+from products.cdp.backend.filters import compile_filters_bytecode
from products.error_tracking.backend.logic.alerts import MAX_THROTTLE_SECONDS, update_alert
from products.error_tracking.backend.models import ErrorTrackingAlert, ErrorTrackingAlertThread, ErrorTrackingIssue
from products.error_tracking.backend.tasks.tasks import dispatch_error_tracking_alert_deliveries
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/browse_ai/tests/test_browse_ai_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/browse_ai/tests/test_browse_ai_source.py
index 6ff4050bb801..a6e3218805e4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/browse_ai/tests/test_browse_ai_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/browse_ai/tests/test_browse_ai_source.py
@@ -6,8 +6,7 @@ from unittest.mock import Mock
import requests_mock
-from posthog.cdp.validation import compile_hog
-
+from products.cdp.backend.validation import compile_hog
from products.warehouse_sources.backend.temporal.data_imports.sources.browse_ai.settings import BASE_URL
from products.warehouse_sources.backend.temporal.data_imports.sources.browse_ai.source import BrowseAISource
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.browseai import (
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fintoc/tests/test_fintoc.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fintoc/tests/test_fintoc.py
index 93871e2c13b3..a93d131f0922 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fintoc/tests/test_fintoc.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fintoc/tests/test_fintoc.py
@@ -12,8 +12,7 @@ from unittest.mock import MagicMock
import pyarrow as pa
from requests import HTTPError, PreparedRequest
-from posthog.cdp.validation import compile_hog
-
+from products.cdp.backend.validation import compile_hog
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client import (
RESTClientRetryableError,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo_source.py
index 030dc6ab7de6..98a4b36b2200 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo_source.py
@@ -7,8 +7,7 @@ from typing import Any
import pytest
from unittest.mock import MagicMock
-from posthog.cdp.validation import compile_hog
-
+from products.cdp.backend.validation import compile_hog
from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import UnknownResourceError
from products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (
ScriptedResponse,
diff --git a/products/workflows/backend/test/test_github_trigger_filters.py b/products/workflows/backend/test/test_github_trigger_filters.py
index b65b1a14fda2..c6e4c23981b7 100644
--- a/products/workflows/backend/test/test_github_trigger_filters.py
+++ b/products/workflows/backend/test/test_github_trigger_filters.py
@@ -7,7 +7,7 @@ from parameterized import parameterized
from posthog.hogql.compiler.bytecode import create_bytecode
-from posthog.cdp.filters import hog_function_filters_to_expr
+from products.cdp.backend.filters import hog_function_filters_to_expr
from common.hogvm.python.execute import execute_bytecode
diff --git a/products/workflows/backend/test/test_refresh_hog_flows.py b/products/workflows/backend/test/test_refresh_hog_flows.py
index dfba81496511..2d0d09ad370f 100644
--- a/products/workflows/backend/test/test_refresh_hog_flows.py
+++ b/products/workflows/backend/test/test_refresh_hog_flows.py
@@ -9,11 +9,11 @@ from django.core.management import call_command
from parameterized import parameterized
-from posthog.cdp.filters import RUNTIME_CONTRACT
from posthog.cdp.templates.hog_function_template import sync_template_to_db
from posthog.models import Team
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.workflows.backend.models.hog_flow.hog_flow import HogFlow
diff --git a/products/workflows/backend/test/test_slack_trigger_filters.py b/products/workflows/backend/test/test_slack_trigger_filters.py
index b51b7007e35b..a91bff0881cc 100644
--- a/products/workflows/backend/test/test_slack_trigger_filters.py
+++ b/products/workflows/backend/test/test_slack_trigger_filters.py
@@ -7,7 +7,7 @@ from parameterized import parameterized
from posthog.hogql.compiler.bytecode import create_bytecode
-from posthog.cdp.filters import hog_function_filters_to_expr
+from products.cdp.backend.filters import hog_function_filters_to_expr
from common.hogvm.python.execute import execute_bytecode
diff --git a/products/workflows/backend/tests/api/test_hog_flow.py b/products/workflows/backend/tests/api/test_hog_flow.py
index ab145bcc5122..5dd899502411 100644
--- a/products/workflows/backend/tests/api/test_hog_flow.py
+++ b/products/workflows/backend/tests/api/test_hog_flow.py
@@ -17,7 +17,6 @@ from django.utils import timezone
from parameterized import parameterized
from rest_framework import status
-from posthog.cdp.filters import RUNTIME_CONTRACT
from posthog.cdp.flag_gated_templates import gated_template_enabled
from posthog.cdp.templates.fixtures import template_slack
from posthog.cdp.templates.hog_function_template import sync_template_to_db
@@ -33,6 +32,7 @@ from posthog.test.fixtures import create_app_metric2
from products.access_control.backend.models.access_control import AccessControl
from products.actions.backend.models.action import Action
from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATES
+from products.cdp.backend.filters import RUNTIME_CONTRACT
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
from products.cohorts.backend.models.cohort import Cohort
from products.skills.backend.models.skills import LLMSkill
diff --git a/pyproject.toml b/pyproject.toml
index 52f3f3d7882e..5b32289b3527 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -589,6 +589,12 @@ ignore_imports = [
# Allowed: presentation can import facade and itself
"products.**.backend.presentation.** -> products.**.backend.facade.**",
"products.**.backend.presentation.** -> products.**.backend.presentation.**",
+ # TODO: cdp presentation wave — the helpers, serializers and icon service other products' views
+ # reuse still live in cdp internals, and products/cdp/backend/presentation/ re-exports them.
+ # Move each one into presentation and delete its entry.
+ "products.cdp.backend.presentation.hog_functions -> products.cdp.backend.filters",
+ "products.cdp.backend.presentation.hog_functions -> products.cdp.backend.validation",
+ "products.cdp.backend.presentation.serializers -> products.cdp.backend.validation",
# TODO: existing violations — fix by routing through facade
"products.alerts.backend.presentation.views.alert -> products.alerts.backend.evaluation.contract",
"products.alerts.backend.presentation.views.alert -> products.alerts.backend.evaluation.detector",
diff --git a/tach.toml b/tach.toml
index 0dc2532cc36c..04630eee5459 100644
--- a/tach.toml
+++ b/tach.toml
@@ -550,6 +550,8 @@ depends_on = [
"products.dashboards",
"products.exports",
"products.workflows", "products.access_control",
+ # Evaluations and taggers compile Hog through products.cdp.backend.validation and filters.
+ "products.cdp",
]
layer = "modules"