: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
feat(cdp): stamp compiled bytecode with the runtime contract it was built against (#105759)
Meikel Ratz1f8248be98d5
diff --git a/nodejs/src/cdp/schema/cyclotron.ts b/nodejs/src/cdp/schema/cyclotron.tsindex a2687757538c..b2df321e8fee 100644--- a/nodejs/src/cdp/schema/cyclotron.ts+++ b/nodejs/src/cdp/schema/cyclotron.ts@@ -7,6 +7,8 @@ export const CyclotronInputSchema = z.object({templating: z.enum(['hog', 'liquid']).optional(),secret: z.boolean().optional(),bytecode: z.any().optional(),+ /** The runtime contract the bytecode was compiled against. Absent on templates saved before stamping. */+ bytecode_contract: z.string().optional(),order: z.number().optional(),})diff --git a/nodejs/src/cdp/services/hog-inputs.service.ts b/nodejs/src/cdp/services/hog-inputs.service.tsindex ba17ee56bc82..a2ccea6aaa56 100644--- a/nodejs/src/cdp/services/hog-inputs.service.ts+++ b/nodejs/src/cdp/services/hog-inputs.service.ts@@ -6,7 +6,7 @@ import { logger } from '~/common/utils/logger'import { HogFunctionInvocationGlobals, HogFunctionInvocationGlobalsWithInputs, HogFunctionType } from '../types'import { EncryptedFields } from '../utils/encryption-utils'-import { isHogVMErrorKind } from '../utils/hog-error-classification'+import { isHogVMErrorKind, withBytecodeContract } from '../utils/hog-error-classification'import { execHog } from '../utils/hog-exec'import { LiquidRenderBudget, LiquidRenderer } from '../utils/liquid'import { getDevicePushSubscriptionToken } from '../utils/push-subscription-utils'@@ -52,7 +52,11 @@ export class HogInputsService {return formatLiquidInput(input.value, newGlobals, key, liquidBudget)}if (templating === 'hog' && input?.bytecode) {- return await formatHogInput(input.bytecode, newGlobals, key)+ try {+ return await formatHogInput(input.bytecode, newGlobals, key)+ } catch (error) {+ throw withBytecodeContract(error, input.bytecode_contract)+ }}return input.valuediff --git a/nodejs/src/cdp/utils/hog-error-classification.ts b/nodejs/src/cdp/utils/hog-error-classification.tsindex 0cb7b737cad8..d25d7ed396a3 100644--- a/nodejs/src/cdp/utils/hog-error-classification.ts+++ b/nodejs/src/cdp/utils/hog-error-classification.ts@@ -51,6 +51,27 @@ function findHogVMException(error: unknown): KindedError | undefined {return undefined}+const BYTECODE_CONTRACT = 'bytecodeContract'++/**+ * Attaches the stamp of the bytecode that threw to the error, so the catch block that classifies it+ * knows which runtime the program was compiled against. The message is untouched.+ */+export function withBytecodeContract<T>(error: T, bytecodeContract: string | undefined): T {+ if (bytecodeContract !== undefined && typeof error === 'object' && error !== null) {+ Object.defineProperty(error, BYTECODE_CONTRACT, { value: bytecodeContract, enumerable: false })+ }+ return error+}++export function bytecodeContractOf(error: unknown): string | undefined {+ if (typeof error !== 'object' || error === null) {+ return undefined+ }+ const value = (error as Record<string, unknown>)[BYTECODE_CONTRACT]+ return typeof value === 'string' ? value : undefined+}+export function classifyHogError(error: unknown, contract: HogErrorContract): HogErrorClass {const vmError = findHogVMException(error)if (!vmError) {diff --git a/nodejs/src/cdp/utils/invocation-utils.test.ts b/nodejs/src/cdp/utils/invocation-utils.test.tsindex ac75121965a2..3b1bead59e61 100644--- a/nodejs/src/cdp/utils/invocation-utils.test.ts+++ b/nodejs/src/cdp/utils/invocation-utils.test.ts@@ -6,6 +6,7 @@ import { createHogExecutionGlobals, createHogFunction } from '../_tests/fixturesimport { HogInputsService } from '../services/hog-inputs.service'import { HogFunctionType } from '../types'import { MAX_LOG_LENGTH } from '../utils'+import { currentRuntimeContractHash } from './filter-runtime'import { buildHogFunctionInvocations, cloneInvocation, createInvocation } from './invocation-utils'describe('Invocation utils', () => {@@ -265,10 +266,16 @@ describe('Invocation utils', () => {.filter(({ labels }) => labels.class === cls && labels.type === 'destination').reduce((sum, { value }) => sum + value, 0)}- const before = { legacy: await inputsErrors('legacy'), data: await inputsErrors('data') }+ const before = {+ legacy: await inputsErrors('legacy'),+ data: await inputsErrors('data'),+ drift: await inputsErrors('drift'),+ bug: await inputsErrors('bug'),+ }const withInput = (input: {value: stringbytecode?: unknown[]+ bytecode_contract?: stringtemplating?: 'liquid'}): HogFunctionType =>createHogFunction({@@ -284,6 +291,18 @@ describe('Invocation utils', () => {withInput({ value: '{% if %}', templating: 'liquid' }),// A value that does not fit the function it meets.withInput({ value: 'x', bytecode: ['_H', 1, 32, 'bogus', 33, 1, 33, 1, 2, 'dateDiff', 3] }),+ // The same missing global on a template compiled against an older runtime: our change.+ withInput({+ value: '{distinct_id}',+ bytecode: ['_H', 1, 32, 'distinct_id', 1, 1],+ bytecode_contract: 'older',+ }),+ // And on one compiled against this runtime: the compiler let through what the VM refuses.+ withInput({+ value: '{distinct_id}',+ bytecode: ['_H', 1, 32, 'distinct_id', 1, 1],+ bytecode_contract: currentRuntimeContractHash(),+ }),]const results = await buildHogFunctionInvocations(hogInputsService, fns, pageviewGlobals())@@ -291,6 +310,8 @@ describe('Invocation utils', () => {expect(results.invocations).toHaveLength(0)expect(await inputsErrors('legacy')).toBe(before.legacy + 2)expect(await inputsErrors('data')).toBe(before.data + 1)+ expect(await inputsErrors('drift')).toBe(before.drift + 1)+ expect(await inputsErrors('bug')).toBe(before.bug + 1)})it('masks a secret input quoted by the failure', async () => {diff --git a/nodejs/src/cdp/utils/invocation-utils.ts b/nodejs/src/cdp/utils/invocation-utils.tsindex 7d248757e906..c609d50e0c7e 100644--- a/nodejs/src/cdp/utils/invocation-utils.ts+++ b/nodejs/src/cdp/utils/invocation-utils.ts@@ -17,7 +17,7 @@ import {import { HogFunctionType } from '../types'import { getConfiguredSensitiveValues, logEntry, sanitizeLogMessage } from '../utils'import { currentRuntimeContractHash } from './filter-runtime'-import { classifyHogError } from './hog-error-classification'+import { bytecodeContractOf, classifyHogError } from './hog-error-classification'import { convertToHogFunctionFilterGlobal, filterFunctionInstrumented } from './hog-function-filtering'/** The inputs step of the dead-letter pipeline. Read next to cdp_hog_function_filter_error. */@@ -124,8 +124,10 @@ export async function buildHogFunctionInvocations(hogFunctionInputsErrors.inc({type: hogFunction.type,- // Inputs are not stamped yet, so a contract error here always reads as legacy.- class: classifyHogError(error, { runtimeContract: currentRuntimeContractHash() }),+ class: classifyHogError(error, {+ bytecodeContract: bytecodeContractOf(error),+ runtimeContract: currentRuntimeContractHash(),+ }),})metrics.push({diff --git a/posthog/cdp/filters.py b/posthog/cdp/filters.pyindex f20321246958..06472e9f3912 100644--- a/posthog/cdp/filters.py+++ b/posthog/cdp/filters.py@@ -466,6 +466,9 @@ _RUNTIME = json.loads((Path(__file__).parent / "filter_globals.json").read_text(# GET_GLOBAL path, so `arrayMap(lower, ...)` is a working filter rather than an unknown global.# Generated from the runtime by `pnpm --filter=@posthog/nodejs run build:filter-globals`.FILTER_GLOBALS: set[str] = set(_RUNTIME["roots"]) | set(_RUNTIME["callables"])+# Stamped on every bytecode this module compiles. The runtime compares it with its own hash, so a+# filter compiled against an older runtime can be told apart from one saved before the compiler checked.+RUNTIME_CONTRACT: str = _RUNTIME["contract"]# The Python compiler knows its own standard library, which is not the one the Node VM runs.FILTER_FUNCTIONS: dict[str, tuple[int, Optional[int]]] = {name: (arity[0], arity[1]) for name, arity in _RUNTIME["functions"].items()@@ -538,6 +541,7 @@ def compile_filters_bytecode(filters: Optional[dict], team: Team, actions: Optioif compiled.unknown_roots and filters.get("source") in DATA_WAREHOUSE_SOURCES:compiled = _compile_against_runtime(_resolve_warehouse_columns(filters, team, actions), team)filters["bytecode"] = compiled.bytecode+ filters["bytecode_contract"] = RUNTIME_CONTRACTunknown = compiled.unknown_rootscontext = compiled.contextif unknown:@@ -572,6 +576,7 @@ def compile_filters_bytecode(filters: Optional[dict], team: Team, actions: Optiosettings_url = _internal_user_settings_url(team.id)details = "; ".join(e.reasons)filters["bytecode"] = None+ filters.pop("bytecode_contract", None)filters["bytecode_error"] = (f"Your internal/test user filters include cohorts that can't be used in real-time filters: "f"{details}. "@@ -594,6 +599,7 @@ def compile_filters_bytecode(filters: Optional[dict], team: Team, actions: Optio)filters["bytecode"] = None+ filters.pop("bytecode_contract", None)filters["bytecode_error"] = error_msgreturn filtersdiff --git a/posthog/cdp/test/test_filters.py b/posthog/cdp/test/test_filters.pyindex 896ec296fd58..5d5f7aa49cb6 100644--- a/posthog/cdp/test/test_filters.py+++ b/posthog/cdp/test/test_filters.py@@ -8,6 +8,7 @@ from parameterized import parameterizedfrom posthog.hogql.compiler.bytecode import create_bytecodefrom posthog.cdp.filters import (+ RUNTIME_CONTRACT,build_behavioral_event_expr,cohort_filters_to_expr,compile_filters_bytecode,@@ -329,6 +330,24 @@ class TestHogFunctionFilters(ClickhouseTestMixin, APIBaseTest, QueryMatchingTestassert "$virt_is_bot" in response["bytecode_error"]assert response["bytecode"] is None+ def test_filters_carry_the_contract_they_compiled_against(self):+ # The stamp is what lets the runtime tell "compiled against an older runtime" from "saved+ # before the compiler checked". Only bytecode that actually compiled gets one.+ compiled = compile_filters_bytecode({"properties": [{"type": "hogql", "key": "event = 'x'"}]}, self.team)+ assert compiled["bytecode_contract"] == RUNTIME_CONTRACT+ assert len(RUNTIME_CONTRACT) == 16++ stale = compile_filters_bytecode(+ {"properties": [{"type": "hogql", "key": "event = 'x'"}], "bytecode_contract": "older"}, self.team+ )+ assert stale["bytecode_contract"] == RUNTIME_CONTRACT++ broken = compile_filters_bytecode(+ {"properties": [{"type": "hogql", "key": "$virt_is_bot = true"}], "bytecode_contract": "older"}, self.team+ )+ assert broken["bytecode"] is None+ assert "bytecode_contract" not in broken+def test_filters_allow_a_global_the_runtime_does_have(self):response = compile_filters_bytecode(filters={"properties": [{"type": "hogql", "key": "person.properties.email is not null"}]},diff --git a/posthog/cdp/test/test_validation.py b/posthog/cdp/test/test_validation.pyindex e587ee0d0f0e..5b62181f0dd0 100644--- a/posthog/cdp/test/test_validation.py+++ b/posthog/cdp/test/test_validation.py@@ -10,6 +10,7 @@ from rest_framework.exceptions import ValidationErrorfrom posthog.hogql import ast+from posthog.cdp.filters import RUNTIME_CONTRACTfrom posthog.cdp.validation import (HogFunctionFiltersSerializer,InputsSchemaItemSerializer,@@ -151,6 +152,7 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingTassert json.loads(json.dumps(validate_inputs(inputs_schema, inputs))) == {"url": {"value": "http://localhost:2080/0e02d917-563f-4050-9725-aad881b69937",+ "bytecode_contract": RUNTIME_CONTRACT,"bytecode": ["_H",HOGQL_BYTECODE_VERSION,@@ -167,6 +169,7 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingT"person": "{person}","event_url": "{f'{event.url}-test'}",},+ "bytecode_contract": RUNTIME_CONTRACT,"bytecode": {"event": ["_H", HOGQL_BYTECODE_VERSION, 32, "event", 1, 1],"groups": ["_H", HOGQL_BYTECODE_VERSION, 32, "groups", 1, 1],@@ -196,6 +199,7 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingT},"headers": {"value": {"version": "v={event.properties.$lib_version}"},+ "bytecode_contract": RUNTIME_CONTRACT,"bytecode": {"version": ["_H",@@ -258,6 +262,7 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingT)) == {"html": {+ "bytecode_contract": RUNTIME_CONTRACT,"bytecode": ["_H",HOGQL_BYTECODE_VERSION,@@ -783,6 +788,50 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingTassert validated["first"]["bytecode"] is not Noneassert validated["second"]["bytecode"] is not None+ def test_filters_carry_a_stamp_only_beside_bytecode(self):+ # A client echoes stored filters back on save. The stamp it sends is ignored: bytecode filters+ # get the compiler's stamp, transpiled filters have no bytecode and get none.+ filters = {"events": [{"id": "$pageview", "type": "events"}], "bytecode_contract": "older"}+ compiled = HogFunctionFiltersSerializer(data=filters, context=self.filters_context)+ assert compiled.is_valid(), compiled.errors+ assert compiled.validated_data["bytecode_contract"] == RUNTIME_CONTRACT++ transpiled = HogFunctionFiltersSerializer(+ data=filters, context={**self.filters_context, "function_type": "site_destination"}+ )+ assert transpiled.is_valid(), transpiled.errors+ assert "bytecode" not in transpiled.validated_data+ assert "bytecode_contract" not in transpiled.validated_data++ def test_validate_inputs_stamps_compiled_templates_with_the_runtime_contract(self):+ # A hog template gets the stamp beside its bytecode. A liquid template has no bytecode and no+ # stamp, and a plain value compiles to nothing that could drift.+ inputs_schema = [+ {"key": "hog", "type": "string", "required": False},+ {"key": "liquid", "type": "string", "required": False},+ {"key": "body", "type": "json", "required": False},+ ]+ inputs = {+ "hog": {"value": "{event.uuid}", "bytecode_contract": "older"},+ "liquid": {"value": "{{ event.uuid }}", "templating": "liquid"},+ "body": {"value": {"id": "{event.uuid}", "kind": "x"}},+ }+ validated = validate_inputs(inputs_schema, inputs)+ assert validated["hog"]["bytecode_contract"] == RUNTIME_CONTRACT+ assert validated["body"]["bytecode_contract"] == RUNTIME_CONTRACT+ assert "bytecode_contract" not in validated["liquid"]++ def test_validate_inputs_refuses_a_call_the_runtime_would_reject(self):+ # The stamp says "checked against this runtime", so a call with an argument count the runtime+ # refuses must not compile, or it would later read as a compiler bug instead of a typo.+ inputs_schema = [{"key": "amount", "type": "string", "required": False}]+ with pytest.raises(Exception) as ctx:+ validate_inputs(inputs_schema, {"amount": {"value": "{round(19.99, 2, 3)}"}})+ assert "round" in str(ctx.value) and "2" in str(ctx.value)++ validated = validate_inputs(inputs_schema, {"amount": {"value": "{round(19.99, 2)}"}})+ assert validated["amount"]["bytecode_contract"] == RUNTIME_CONTRACT+def test_validate_transformation_inputs_allows_stl_and_runtime_functions(self):# STL functions (e.g. now) and transformation runtime helpers (e.g. geoipLookup)# are valid root identifiers because the Hog VM falls back to STL/runtime lookups@@ -897,6 +946,7 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingTserializer.is_valid(raise_exception=True)value = json.loads(json.dumps(serializer.validated_data))assert value == {+ "bytecode_contract": RUNTIME_CONTRACT,"source": "events","events": [{"id": "$pageview", "type": "events", "name": "$pageview", "order": 0}],"properties": [{"key": "email", "value": ["[email protected]"], "operator": "exact", "type": "person"}],@@ -967,6 +1017,7 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingTserializer.is_valid(raise_exception=True)value = json.loads(json.dumps(serializer.validated_data))assert value == {+ "bytecode_contract": RUNTIME_CONTRACT,"source": "person-updates","properties": [{"key": "email", "value": ["[email protected]"], "operator": "exact", "type": "person"}],"bytecode": ["_H", 1, 32, "[email protected]", 32, "email", 32, "properties", 32, "person", 1, 3, 11],diff --git a/posthog/cdp/validation.py b/posthog/cdp/validation.pyindex 252da3a98d48..d179bbc64f6b 100644--- a/posthog/cdp/validation.py+++ b/posthog/cdp/validation.py@@ -18,6 +18,8 @@ from posthog.hogql.visitor import TraversingVisitorfrom posthog.cdp.filters import (DATA_WAREHOUSE_SOURCES,+ FILTER_FUNCTIONS,+ RUNTIME_CONTRACT,TEMPLATE_CALLABLES,TEMPLATE_GLOBALS,compile_filters_bytecode,@@ -291,6 +293,9 @@ class TemplateGlobalsValidator(TraversingVisitor):"""invalid_globals: set[str]+ # Calls the Node runtime would refuse for their argument count, as messages. Only checked for+ # names the runtime table knows, so a name it does not know is left to the globals check.+ invalid_calls: list[str]def __init__(self,@@ -302,6 +307,7 @@ class TemplateGlobalsValidator(TraversingVisitor):):super().__init__()self.invalid_globals = set()+ self.invalid_calls = []self._python_stl = python_stlself._declared: set[str] = set()self._available_globals = (@@ -334,6 +340,20 @@ class TemplateGlobalsValidator(TraversingVisitor):returnself.invalid_globals.add(root)+ def visit_call(self, node: ast.Call) -> None:+ super().visit_call(node)+ if self._python_stl or node.name in self._declared:+ return+ arity = FILTER_FUNCTIONS.get(node.name)+ if arity is None:+ return+ minimum, maximum = arity+ count = len(node.args)+ if count < minimum:+ self.invalid_calls.append(f"{node.name} needs at least {minimum} argument(s), got {count}")+ elif maximum is not None and count > maximum:+ self.invalid_calls.append(f"{node.name} takes at most {maximum} argument(s), got {count}")+class DeclaredNamesCollector(TraversingVisitor):"""Collect every identifier a hog program declares (variables, functions, params,@@ -521,6 +541,10 @@ def generate_template_bytecode(f"Inputs can read event, person, groups, project, source and inputs, and in a workflow "f"also variables.")+ if template_validator.invalid_calls:+ raise Exception(+ "This template would fail on every event: " + "; ".join(template_validator.invalid_calls)+ )return create_bytecode(node).bytecodeelse:return obj@@ -637,6 +661,7 @@ class InputsItemSerializer(serializers.Serializer):value = AnyInputField(required=False)templating = serializers.ChoiceField(choices=HogFunctionTemplating.choices, required=False)bytecode = serializers.ListField(required=False, read_only=True)+ bytecode_contract = serializers.CharField(required=False, read_only=True)order = serializers.IntegerField(required=False, read_only=True)transpiled = serializers.JSONField(required=False, read_only=True)@@ -820,6 +845,7 @@ class InputsItemSerializer(serializers.Serializer):attrs["transpiled"] = {"lang": "ts", "code": code, "stl": list(compiler.stl_functions)}if "bytecode" in attrs:del attrs["bytecode"]+ attrs.pop("bytecode_contract", None)else:input_collector: set[str] = set()attrs["bytecode"] = generate_template_bytecode(@@ -830,6 +856,7 @@ class InputsItemSerializer(serializers.Serializer):validate_globals=self.context.get("function_will_be_enabled", True),)attrs["input_deps"] = list(input_collector)+ attrs["bytecode_contract"] = RUNTIME_CONTRACTif "transpiled" in attrs:del attrs["transpiled"]except Exception as e:@@ -988,6 +1015,7 @@ class HogFunctionFiltersSerializer(serializers.Serializer):transpiled = serializers.JSONField(required=False)filter_test_accounts = serializers.BooleanField(required=False)bytecode_error = serializers.CharField(required=False)+ bytecode_contract = serializers.CharField(required=False)def to_internal_value(self, data):# Weirdly nested serializers don't get this set...@@ -1001,6 +1029,9 @@ class HogFunctionFiltersSerializer(serializers.Serializer):# Ensure data is initialized as an empty dict if it's Nonedata = data or {}+ # The compiler writes the stamp below, so a value a client echoes back is never kept.+ data.pop("bytecode_contract", None)+if _contains_behavioral_property(data):raise serializers.ValidationError("Behavioral (performed event) filters can't be evaluated in realtime functions. "diff --git a/posthog/management/commands/test/test_migrate_hooks.py b/posthog/management/commands/test/test_migrate_hooks.pyindex ef44484820dc..5ec2ab5b6cca 100644--- a/posthog/management/commands/test/test_migrate_hooks.py+++ b/posthog/management/commands/test/test_migrate_hooks.py@@ -1,5 +1,6 @@from posthog.test.base import BaseTest+from posthog.cdp.filters import RUNTIME_CONTRACTfrom posthog.cdp.templates.hog_function_template import sync_template_to_dbfrom posthog.cdp.templates.zapier.template_zapier import template as template_zapierfrom posthog.management.commands.migrate_hooks import migrate_hooks@@ -63,6 +64,7 @@ class TestMigrateHooks(BaseTest):"source": "events","actions": [{"id": f"{self.action.id}", "name": "", "type": "actions", "order": 0}],"bytecode": ["_H", HOGQL_BYTECODE_VERSION, 29],+ "bytecode_contract": RUNTIME_CONTRACT,}assert hog_function.hog == template_zapier.codeassert hog_function.description == f"{template_zapier.description} Migrated from legacy hook {self.hook.id}."diff --git a/posthog/models/test/test_hog_function.py b/posthog/models/test/test_hog_function.pyindex 0790ee5d5e94..8a691fa68e52 100644--- a/posthog/models/test/test_hog_function.py+++ b/posthog/models/test/test_hog_function.py@@ -6,6 +6,7 @@ from unittest.mock import Mock, patchfrom django.test import TestCase+from posthog.cdp.filters import RUNTIME_CONTRACTfrom posthog.models.file_system.file_system import FileSystemfrom posthog.models.team.team import Teamfrom posthog.models.user import User@@ -66,6 +67,7 @@ class TestHogFunction(TestCase):# Some json serialization is needed to compare the bytecode more easily in testsjson_filters = to_dict(item.filters)assert json_filters == {+ "bytecode_contract": RUNTIME_CONTRACT,"events": [{"id": "$pageview", "name": "$pageview", "type": "events", "order": 0}],"actions": [{"id": str(action.pk), "name": "Test Action", "type": "actions", "order": 1}],"filter_test_accounts": True,diff --git a/products/cdp/backend/api/hog_function.py b/products/cdp/backend/api/hog_function.pyindex 2915076eedc0..79d8bcafe4ba 100644--- a/products/cdp/backend/api/hog_function.py+++ b/products/cdp/backend/api/hog_function.py@@ -200,18 +200,20 @@ def _without(value: Any, keys: tuple[str, ...]) -> Any:def _inputs_without_derived(inputs: Any) -> Any:if not isinstance(inputs, dict):return inputs- return {key: _without(value, ("bytecode", "transpiled", "order")) for key, value in inputs.items()}+ return {+ key: _without(value, ("bytecode", "bytecode_contract", "transpiled", "order")) for key, value in inputs.items()+ }def comparable_content(content: dict) -> dict:"""A config snapshot with the values validation derives from it dropped: filter and input- bytecode, transpiled JS, input ordering.+ bytecode, the runtime stamp beside it, transpiled JS, input ordering.A background re-save can change those on its own without the config changing at all — most often`refresh_affected_hog_functions` recompiling filter bytecode after an action or cohort edit — socomparing them would version a plain rename."""- filter_derived = ("bytecode", "bytecode_error", "transpiled")+ filter_derived = ("bytecode", "bytecode_error", "bytecode_contract", "transpiled")mappings = content.get("mappings")return {**content,diff --git a/products/cdp/backend/api/test/__snapshots__/test_hooks.ambr b/products/cdp/backend/api/test/__snapshots__/test_hooks.ambrindex ea888f2f05fa..8af8520ff329 100644--- a/products/cdp/backend/api/test/__snapshots__/test_hooks.ambr+++ b/products/cdp/backend/api/test/__snapshots__/test_hooks.ambr@@ -148,6 +148,7 @@]),}),}),+ 'bytecode_contract': 'bfd6ece60e41383c','order': 1,'value': dict({'data': dict({@@ -177,6 +178,7 @@32,'hooks/standard/1234/abcd',]),+ 'bytecode_contract': 'bfd6ece60e41383c','order': 0,'value': 'hooks/standard/1234/abcd',}),diff --git a/products/cdp/backend/api/test/test_hog_function.py b/products/cdp/backend/api/test/test_hog_function.pyindex 47d3c4d31a56..b40ec94e4d33 100644--- a/products/cdp/backend/api/test/test_hog_function.py+++ b/products/cdp/backend/api/test/test_hog_function.py@@ -10,6 +10,7 @@ from django.db import connectionfrom parameterized import parameterizedfrom rest_framework import status+from posthog.cdp.filters import RUNTIME_CONTRACTfrom posthog.cdp.templates.fixtures import template_slackfrom posthog.cdp.templates.helpers import mock_transpilefrom posthog.cdp.templates.hog_function_template import sync_template_to_db@@ -20,6 +21,7 @@ from products.cdp.backend.api.hog_function import (MAX_HOG_CODE_SIZE_BYTES,MAX_LOG_TRANSFORMATIONS_PER_TEAM,MAX_TRANSFORMATIONS_PER_TEAM,+ comparable_content,)from products.cdp.backend.api.test.test_hog_function_templates import MOCK_NODE_TEMPLATESfrom products.cdp.backend.models.hog_function_template import HogFunctionTemplate@@ -591,6 +593,48 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):if expected == status.HTTP_400_BAD_REQUEST:assert "static cohort" in response.json()["detail"]+ def test_a_new_runtime_stamp_alone_is_not_a_content_change(self):+ # A re-save against a newer runtime rewrites every stamp. That must not version the function.+ stamped = {+ "filters": {"events": [{"id": "$pageview"}], "bytecode": ["_H", 1], "bytecode_contract": "new"},+ "inputs": {"url": {"value": "https://example.com", "bytecode": ["_H", 1], "bytecode_contract": "new"}},+ "mappings": [+ {"filters": {"bytecode_contract": "new"}, "inputs": {"k": {"value": 1, "bytecode_contract": "new"}}}+ ],+ }+ unstamped = {+ "filters": {"events": [{"id": "$pageview"}], "bytecode": ["_H", 1]},+ "inputs": {"url": {"value": "https://example.com", "bytecode": ["_H", 1]}},+ "mappings": [{"filters": {}, "inputs": {"k": {"value": 1}}}],+ }+ assert comparable_content(stamped) == comparable_content(unstamped)++ def test_kept_bytecode_keeps_the_contract_it_was_compiled_against(self):+ # When a save cannot recompile the filters, the model keeps the last working bytecode. The+ # stamp has to stay with that bytecode, or the runtime would read old code as freshly compiled.+ fn = HogFunction.objects.create(+ team=self.team,+ name="Destination",+ type="destination",+ enabled=True,+ inputs_schema=[],+ inputs={},+ hog="return event",+ filters={"filter_test_accounts": True},+ )+ HogFunction.objects.filter(pk=fn.pk).update(filters={**(fn.filters or {}), "bytecode_contract": "older"})+ fn.refresh_from_db()+ self.team.test_account_filters = [{"type": "hogql", "key": "$virt_is_bot = false"}]+ self.team.save()++ fn.save()++ fn.refresh_from_db()+ filters = fn.filters or {}+ assert filters["bytecode"] is not None+ assert "$virt_is_bot" in filters["bytecode_error"]+ assert filters["bytecode_contract"] == "older"+def test_uncompilable_filters_disable_with_string_boolean_value(self):# A client may send the boolean as a JSON string ("false"). The enable-guard reads the raw# value before field coercion, so it must coerce rather than rely on truthiness - otherwise@@ -658,6 +702,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):"filters": {"source": "events","bytecode": ["_H", HOGQL_BYTECODE_VERSION, 29],+ "bytecode_contract": RUNTIME_CONTRACT,},"icon_url": None,"template": None,@@ -983,6 +1028,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):32,"I AM SECRET",],+ "bytecode_contract": RUNTIME_CONTRACT,"value": "I AM SECRET","order": 0,},@@ -992,7 +1038,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):assert (raw_encrypted_inputs- == "gAAAAABlkgC8AAAAAAAAAAAAAAAAAAAAAKvzDjuLG689YjjVhmmbXAtZSRoucXuT8VtokVrCotIx3ttPcVufoVt76dyr2phbuotMldKMVv_Y6uzMDZFjX1Uvej4GHsYRbsTN_txcQHNnU7zvLee83DhHIrThEjceoq8i7hbfKrvqjEi7GCGc_k_Gi3V5KFxDOfLKnke4KM4s"+ == "gAAAAABlkgC8AAAAAAAAAAAAAAAAAAAAAKvzDjuLG689YjjVhmmbXAtZSRoucXuT8VtokVrCotIx3ttPcVufoVt76dyr2phbuotMldKMVv_Y6uzMDZFjX1VQVJqL13wH-WALMn9obfpLYD_WWOUdMA6VurFg1TxdopwQKcL10Y5Yg8s8Gswibi1pCMfjwSnKwod91SMtLKgNfAU4EPZ6GxA77xCHIjaTLueR3qx-hy2Pu3W0r5Rh1hWy0bq01uIdulQ_LhxkQgpj")def test_masked_secrets_lists_only_functions_storing_the_mask(self, *args):@@ -1191,6 +1237,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):32,"http://localhost:2080/0e02d917-563f-4050-9725-aad881b69937",],+ "bytecode_contract": RUNTIME_CONTRACT,"order": 0,},"payload": {@@ -1223,6 +1270,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):2,],},+ "bytecode_contract": RUNTIME_CONTRACT,},"method": {"value": "POST", "order": 2},"headers": {@@ -1246,6 +1294,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):2,]},+ "bytecode_contract": RUNTIME_CONTRACT,"order": 3,},}@@ -1331,6 +1380,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):3,2,],+ "bytecode_contract": RUNTIME_CONTRACT,}def test_saves_masking_config(self, *args):@@ -2096,6 +2146,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):"concat",3,],+ "bytecode_contract": RUNTIME_CONTRACT,"order": 0,}},@@ -2129,6 +2180,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):3,2,],+ "bytecode_contract": RUNTIME_CONTRACT,"filter_test_accounts": True,},}@@ -2267,6 +2319,7 @@ class TestHogFunctionAPI(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):Operation.STRING,"http://localhost:2080/0e02d917-563f-4050-9725-aad881b69937",],+ "bytecode_contract": RUNTIME_CONTRACT,"order": 0,"value": "http://localhost:2080/0e02d917-563f-4050-9725-aad881b69937",}diff --git a/products/cdp/backend/api/test/test_hooks.py b/products/cdp/backend/api/test/test_hooks.pyindex 1ee1210cc47a..5bfd544de77d 100644--- a/products/cdp/backend/api/test/test_hooks.py+++ b/products/cdp/backend/api/test/test_hooks.py@@ -4,6 +4,7 @@ from typing import Anyimport pytestfrom posthog.test.base import ClickhouseTestMixin+from posthog.cdp.filters import RUNTIME_CONTRACTfrom posthog.cdp.templates.hog_function_template import sync_template_to_dbfrom posthog.cdp.templates.zapier.template_zapier import template as template_zapier@@ -78,6 +79,7 @@ class TestHooksAPI(ClickhouseTestMixin, APILicensedTest):"source": "events","actions": [{"id": str(self.action.id), "name": "", "type": "actions", "order": 0}],"bytecode": ["_H", HOGQL_BYTECODE_VERSION, 32, "$pageview", 32, "event", 1, 1, 11],+ "bytecode_contract": RUNTIME_CONTRACT,}assert (hog_function.hog, hog_function.inputs) == self.snapshotdiff --git a/products/cdp/backend/api/test/test_plugin.py b/products/cdp/backend/api/test/test_plugin.pyindex df99b5fa1380..64408e1f9993 100644--- a/products/cdp/backend/api/test/test_plugin.py+++ b/products/cdp/backend/api/test/test_plugin.py@@ -15,6 +15,7 @@ from django.test import override_settingsfrom rest_framework import status+from posthog.cdp.filters import RUNTIME_CONTRACTfrom posthog.cdp.templates.helpers import mock_transpilefrom posthog.cdp.templates.hog_function_template import sync_template_to_dbfrom posthog.constants import FROZEN_POSTHOG_VERSION@@ -1142,6 +1143,7 @@ class TestPluginAPI(APIBaseTest, QueryMatchingTest):assert hog_function[0].filters == {"source": "events","bytecode": ["_H", 1, 29],+ "bytecode_contract": RUNTIME_CONTRACT,} # Assert the compiled bytecode for empty filterassert hog_function[0].hog == "return event"assert hog_function[0].enableddiff --git a/products/cdp/backend/models/hog_functions/hog_function.py b/products/cdp/backend/models/hog_functions/hog_function.pyindex 2c0da3527445..ac08b6eea409 100644--- a/products/cdp/backend/models/hog_functions/hog_function.py+++ b/products/cdp/backend/models/hog_functions/hog_function.py@@ -96,7 +96,7 @@ TYPES_THAT_CAN_RERUN = (DRAFT_ONLY_UPDATE_FIELDS = frozenset({"draft", "draft_updated_at", "draft_encrypted_inputs"})-DERIVED_FILTER_KEYS = {"bytecode", "bytecode_error"}+DERIVED_FILTER_KEYS = {"bytecode", "bytecode_error", "bytecode_contract"}def _is_draft_only_save(update_fields: Optional[Iterable[str]]) -> bool:@@ -313,6 +313,11 @@ class HogFunction(FileSystemSyncMixin, UUIDTModel):# filters no longer describe.if previous_bytecode is not None and _raw_filters(compiled) == _raw_filters(previous):compiled["bytecode"] = previous_bytecode+ # The stamp belongs to the bytecode it was compiled with, so it travels with it.+ if "bytecode_contract" in previous:+ compiled["bytecode_contract"] = previous["bytecode_contract"]+ else:+ compiled.pop("bytecode_contract", None)logger.warning("hog_function_filters_kept_previous_bytecode",hog_function_id=str(self.pk),diff --git a/products/cdp/frontend/generated/api.schemas.ts b/products/cdp/frontend/generated/api.schemas.tsindex b15cd7a8553a..e7a30f5e6efd 100644--- a/products/cdp/frontend/generated/api.schemas.ts+++ b/products/cdp/frontend/generated/api.schemas.ts@@ -231,6 +231,7 @@ export interface InputsItemApi {value?: unknowntemplating?: HogFunctionTemplatingEnumApireadonly bytecode: readonly unknown[]+ readonly bytecode_contract: stringreadonly order: numberreadonly transpiled: unknown}@@ -373,6 +374,7 @@ export interface HogFunctionFiltersApi {transpiled?: unknownfilter_test_accounts?: booleanbytecode_error?: string+ bytecode_contract?: string}export interface HogFunctionMaskingApi {diff --git a/products/cdp/frontend/generated/api.zod.ts b/products/cdp/frontend/generated/api.zod.tsindex 730e424c7e2b..4d338b283bf9 100644--- a/products/cdp/frontend/generated/api.zod.ts+++ b/products/cdp/frontend/generated/api.zod.ts@@ -116,6 +116,7 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -138,6 +139,7 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -229,6 +231,7 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -256,6 +259,7 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})@@ -390,6 +394,7 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -412,6 +417,7 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -503,6 +509,7 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -530,6 +537,7 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})@@ -664,6 +672,7 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -686,6 +695,7 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -777,6 +787,7 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -804,6 +815,7 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})@@ -942,6 +954,7 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object(value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -964,6 +977,7 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object(transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -1061,6 +1075,7 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object(.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -1088,6 +1103,7 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object(transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})@@ -1301,6 +1317,7 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -1329,6 +1346,7 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -1426,6 +1444,7 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()),+ bytecode_contract: zod.string(),order: zod.number(),transpiled: zod.unknown(),})@@ -1455,6 +1474,7 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})diff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.tsindex acc0cf53e05e..27d4806b0437 100644--- a/products/warehouse_sources/frontend/generated/api.schemas.ts+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts@@ -5155,6 +5155,7 @@ export interface InputsItemApi {value?: unknowntemplating?: HogFunctionTemplatingEnumApireadonly bytecode: readonly unknown[]+ readonly bytecode_contract: stringreadonly order: numberreadonly transpiled: unknown}diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.pyindex 753fb91b9f3f..777109d2eb5c 100644--- a/products/workflows/backend/api/hog_flow.py+++ b/products/workflows/backend/api/hog_flow.py@@ -218,7 +218,7 @@ DRAFT_CONTENT_FIELDS = (# Compiled from the author's filters rather than written by them, and only present once a condition has# been through validation. Comparing them would make an unchanged condition look edited.-_DERIVED_FILTER_KEYS = ("bytecode", "bytecode_error", "source")+_DERIVED_FILTER_KEYS = ("bytecode", "bytecode_error", "bytecode_contract", "source")def _authored_condition(condition: Optional[dict]) -> Optional[dict]:@@ -234,6 +234,24 @@ def _authored_condition(condition: Optional[dict]) -> Optional[dict]:}+def _without_bytecode_contracts(node: Any) -> Any:+ # Every recompile writes the current runtime's stamp beside each filter and input bytecode. A flow+ # stored before stamping, or under an older runtime, gets a new stamp on its next save even when+ # nobody changed it, so the revision comparison must not count the stamp as content. A stamp only+ # ever sits next to a `bytecode` key, so a same-named key inside a person's own JSON value stays+ # content and still versions the flow.+ if isinstance(node, dict):+ derived = "bytecode" in node+ return {+ key: _without_bytecode_contracts(value)+ for key, value in node.items()+ if not (derived and key == "bytecode_contract")+ }+ if isinstance(node, list):+ return [_without_bytecode_contracts(item) for item in node]+ return node++def _wait_condition_already_stored(action: dict, context: dict) -> bool:"""True when this wait's condition matches the one already persisted for the same action.@@ -4592,8 +4610,8 @@ class HogFlowViewSet(# recovered into `actions` (stripping happens later in save()), while `before` is the persisted# stripped snapshot; without this a secret-bearing flow would bump on every actions-carrying save.template_cache: TemplateCache = {}- old_content = strip_content_secrets(raw_old, template_cache)- new_content = strip_content_secrets(raw_new, template_cache)+ old_content = _without_bytecode_contracts(strip_content_secrets(raw_old, template_cache))+ new_content = _without_bytecode_contracts(strip_content_secrets(raw_new, template_cache))if new_content == old_content:return Falseinstance.version = (before.version or 0) + 1diff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.pyindex 6234a01be5a4..2a87c7e33e1c 100644--- a/products/workflows/backend/api/test/test_hog_flow.py+++ b/products/workflows/backend/api/test/test_hog_flow.py@@ -15,6 +15,7 @@ from django.test import override_settingsfrom parameterized import parameterizedfrom rest_framework import status+from posthog.cdp.filters import RUNTIME_CONTRACTfrom posthog.cdp.flag_gated_templates import gated_template_enabledfrom posthog.cdp.templates.fixtures import template_slackfrom posthog.cdp.templates.hog_function_template import sync_template_to_db@@ -933,6 +934,7 @@ class TestHogFlowAPI(APIBaseTest):"url": {"value": "https://example.com","bytecode": ["_H", 1, 32, "https://example.com"],+ "bytecode_contract": RUNTIME_CONTRACT,"order": 0,}},@@ -1338,7 +1340,12 @@ class TestHogFlowAPI(APIBaseTest):assert hog_flow.actions[1]["filters"].get("bytecode") == ["_H", 1, 32, "custom_event", 32, "event", 1, 1, 11]assert hog_flow.actions[1]["config"]["inputs"] == {- "url": {"order": 0, "value": "https://example.com", "bytecode": ["_H", 1, 32, "https://example.com"]}+ "url": {+ "order": 0,+ "value": "https://example.com",+ "bytecode": ["_H", 1, 32, "https://example.com"],+ "bytecode_contract": RUNTIME_CONTRACT,+ }}def test_hog_flow_conversion_filters_compiles_bytecode_on_create(self):@@ -4517,6 +4524,8 @@ class TestHogFlowAPI(APIBaseTest):# Bytecode should just check for $pageview eventbytecode_without = response_without.json()["trigger"]["filters"]["bytecode"]assert bytecode_without == ["_H", 1, 32, "$pageview", 32, "event", 1, 1, 11]+ # A flow's trigger is stamped like a destination's filters, so its errors classify the same way.+ assert response_without.json()["trigger"]["filters"]["bytecode_contract"] == RUNTIME_CONTRACT# Create a workflow WITH filter_test_accounts: truetrigger_action_with_filter = {@@ -4577,7 +4586,12 @@ class TestHogFlowAPI(APIBaseTest):assert flow.actions[1]["filters"].get("bytecode") == ["_H", 1, 32, "custom_event", 32, "event", 1, 1, 11]assert flow.actions[1]["config"]["inputs"] == {- "url": {"order": 0, "value": "https://example.com", "bytecode": ["_H", 1, 32, "https://example.com"]}+ "url": {+ "order": 0,+ "value": "https://example.com",+ "bytecode": ["_H", 1, 32, "https://example.com"],+ "bytecode_contract": RUNTIME_CONTRACT,+ }}def test_hog_flow_draft_to_active_compiles_bytecode(self):@@ -4603,7 +4617,12 @@ class TestHogFlowAPI(APIBaseTest):flow = HogFlow.objects.get(pk=flow_id)assert flow.trigger["filters"].get("bytecode") == ["_H", 1, 32, "$pageview", 32, "event", 1, 1, 11]assert flow.actions[1]["config"]["inputs"] == {- "url": {"order": 0, "value": "https://example.com", "bytecode": ["_H", 1, 32, "https://example.com"]}+ "url": {+ "order": 0,+ "value": "https://example.com",+ "bytecode": ["_H", 1, 32, "https://example.com"],+ "bytecode_contract": RUNTIME_CONTRACT,+ }}def test_hog_flow_draft_partial_inputs_skips_input_bytecode(self):diff --git a/products/workflows/backend/api/test/test_hog_flow_revisions.py b/products/workflows/backend/api/test/test_hog_flow_revisions.pyindex ddfaa673bbbd..abd8ff507ca7 100644--- a/products/workflows/backend/api/test/test_hog_flow_revisions.py+++ b/products/workflows/backend/api/test/test_hog_flow_revisions.py@@ -1,3 +1,5 @@+from typing import Any, Optional+from posthog.test.base import APIBaseTestfrom unittest.mock import MagicMock, patch@@ -36,6 +38,17 @@ def _webhook_action(action_id: str = "action_1", url: str = "https://example.com}+def _restamp(node: Any, contract: Optional[str]) -> Any:+ if isinstance(node, dict):+ restamped = {key: _restamp(value, contract) for key, value in node.items() if key != "bytecode_contract"}+ if "bytecode_contract" in node and contract is not None:+ restamped["bytecode_contract"] = contract+ return restamped+ if isinstance(node, list):+ return [_restamp(item, contract) for item in node]+ return node++class TestHogFlowRevisions(APIBaseTest):def setUp(self):super().setUp()@@ -189,6 +202,43 @@ class TestHogFlowRevisions(APIBaseTest):assert self._list_revisions(flow_id) == []assert response.json()["version"] == 1+ @parameterized.expand([("stored_before_stamping", None), ("stamped_by_an_older_runtime", "0000000000000000")])+ def test_activation_after_a_runtime_change_does_not_append_revision(self, _name, stored_contract):+ flow_id = self._create_active_flow()+ disable = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"status": "draft"})+ assert disable.status_code == 200, disable.json()+ flow = HogFlow.objects.get(pk=flow_id)+ HogFlow.objects.filter(pk=flow_id).update(+ actions=_restamp(flow.actions, stored_contract), trigger=_restamp(flow.trigger, stored_contract)+ )++ activate = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"status": "active"})+ assert activate.status_code == 200, activate.json()+ assert activate.json()["version"] == 1+ assert self._list_revisions(flow_id) == []++ def test_an_authored_key_named_like_the_stamp_still_versions_the_flow(self):+ # The stamp is stripped from the comparison only where it sits beside a bytecode. A person's+ # own JSON body can carry a key with the same name, and editing it is a real change.+ flow_id = self._create_active_flow()++ def body_action(marker: str) -> dict:+ action = _webhook_action()+ action["config"]["inputs"]["body"] = {"value": {"bytecode_contract": marker}}+ return action++ first = self.client.patch(+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"actions": [_trigger_action(), body_action("one")]}+ )+ assert first.status_code == 200, first.json()+ version_after_first = first.json()["version"]++ second = self.client.patch(+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"actions": [_trigger_action(), body_action("two")]}+ )+ assert second.status_code == 200, second.json()+ assert second.json()["version"] == version_after_first + 1+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.diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.tsindex a4bf5cc3a238..24854d225c4d 100644--- a/products/workflows/frontend/generated/api.schemas.ts+++ b/products/workflows/frontend/generated/api.schemas.ts@@ -101,6 +101,7 @@ export interface HogFunctionFiltersApi {transpiled?: unknownfilter_test_accounts?: booleanbytecode_error?: string+ bytecode_contract?: string}/**diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.tsindex c2d2f8dac6a2..dcd7c8b774d0 100644--- a/products/workflows/frontend/generated/api.zod.ts+++ b/products/workflows/frontend/generated/api.zod.ts@@ -112,6 +112,7 @@ export const HogFlowTemplatesCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -240,6 +241,7 @@ export const HogFlowTemplatesUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -374,6 +376,7 @@ export const HogFlowTemplatesPartialUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -503,6 +506,7 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).describe("Event\/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side."@@ -642,6 +646,7 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -711,6 +716,7 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -760,6 +766,7 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -901,6 +908,7 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).describe("Event\/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side."@@ -1040,6 +1048,7 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -1109,6 +1118,7 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -1158,6 +1168,7 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -1306,6 +1317,7 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).describe("Event\/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side."@@ -1445,6 +1457,7 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -1514,6 +1527,7 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -1563,6 +1577,7 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -1964,6 +1979,7 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).describe("Event\/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side."@@ -2110,6 +2126,7 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -2179,6 +2196,7 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -2228,6 +2246,7 @@ export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -2700,6 +2719,7 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).describe("Event\/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side."@@ -2839,6 +2859,7 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -2908,6 +2929,7 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -2957,6 +2979,7 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 29ca39a4d8ee..53d3de640988 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -49384,6 +49384,7 @@ export namespace Schemas {transpiled?: unknown;filter_test_accounts?: boolean;bytecode_error?: string;+ bytecode_contract?: string;}export interface HogFlowConversionEvent {@@ -50189,6 +50190,7 @@ export namespace Schemas {value?: unknown;templating?: HogFunctionTemplatingEnum;readonly bytecode: readonly unknown[];+ readonly bytecode_contract: string;readonly order: number;readonly transpiled: unknown;}diff --git a/services/mcp/src/generated/cdp_functions/api.ts b/services/mcp/src/generated/cdp_functions/api.tsindex 278d168bdc55..2c44d9e9778b 100644--- a/services/mcp/src/generated/cdp_functions/api.ts+++ b/services/mcp/src/generated/cdp_functions/api.ts@@ -136,6 +136,7 @@ export const HogFunctionsCreateBody = () => zod.object({value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -155,6 +156,7 @@ export const HogFunctionsCreateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -237,6 +239,7 @@ export const HogFunctionsCreateBody = () => zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -261,6 +264,7 @@ export const HogFunctionsCreateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})@@ -400,6 +404,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -419,6 +424,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -501,6 +507,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -525,6 +532,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})@@ -769,6 +777,7 @@ export const HogFunctionsInvocationsCreateBody = () => zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -797,6 +806,7 @@ export const HogFunctionsInvocationsCreateBody = () => zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -894,6 +904,7 @@ export const HogFunctionsInvocationsCreateBody = () => zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -923,6 +934,7 @@ export const HogFunctionsInvocationsCreateBody = () => zod.object({transpiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})diff --git a/services/mcp/src/generated/error_tracking_alerts/api.ts b/services/mcp/src/generated/error_tracking_alerts/api.tsindex 93b5e68e9015..50f7da504017 100644--- a/services/mcp/src/generated/error_tracking_alerts/api.ts+++ b/services/mcp/src/generated/error_tracking_alerts/api.ts@@ -136,6 +136,7 @@ export const HogFunctionsCreateBody = () => zod.object({value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -155,6 +156,7 @@ export const HogFunctionsCreateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -237,6 +239,7 @@ export const HogFunctionsCreateBody = () => zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -261,6 +264,7 @@ export const HogFunctionsCreateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})@@ -391,6 +395,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({value: zod.unknown().optional(),templating: zod.enum(['hog', 'liquid']).optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -410,6 +415,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional().describe('Event filters that control which events trigger this function.'),@@ -492,6 +498,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({.optional().describe('\* `hog` - hog\n\* `liquid` - liquid'),bytecode: zod.array(zod.unknown()).optional(),+ bytecode_contract: zod.string().optional(),order: zod.number().optional(),transpiled: zod.unknown().optional(),})@@ -516,6 +523,7 @@ export const HogFunctionsPartialUpdateBody = () => zod.object({data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),filter_test_accounts: zod.boolean().optional(),+ bytecode_contract: zod.string().optional(),}).optional(),})diff --git a/services/mcp/src/generated/workflows/api.ts b/services/mcp/src/generated/workflows/api.tsindex e03a95b34651..ac57499642e6 100644--- a/services/mcp/src/generated/workflows/api.ts+++ b/services/mcp/src/generated/workflows/api.ts@@ -168,6 +168,7 @@ export const HogFlowsCreateBody = () => zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).describe("Event\/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side."@@ -307,6 +308,7 @@ export const HogFlowsCreateBody = () => zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -376,6 +378,7 @@ export const HogFlowsCreateBody = () => zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -425,6 +428,7 @@ export const HogFlowsCreateBody = () => zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}),zod.null(),])@@ -571,6 +575,7 @@ export const HogFlowsPartialUpdateBody = () => zodtranspiled: zod.unknown().optional(),filter_test_accounts: zod.boolean().optional(),bytecode_error: zod.string().optional(),+ bytecode_contract: zod.string().optional(),}).describe("Event\/action filters for this conversion event, same shape as trigger filters: {events: [{id, name, type: 'events', properties?: [<cond>]}], actions?: [...], properties?: [<cond>]}. bytecode is compiled server-side."diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.jsonindex 6b0fdbb3951e..957477a2dccb 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json@@ -35,6 +35,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -105,6 +108,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},@@ -225,6 +231,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -280,6 +289,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.jsonindex ef026aef19b2..ef1dfd3232d3 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json@@ -179,6 +179,9 @@"type": "array"},"bytecode": {},+ "bytecode_contract": {+ "type": "string"+ },"bytecode_error": {"type": "string"},@@ -256,6 +259,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},@@ -392,6 +398,9 @@"type": "array"},"bytecode": {},+ "bytecode_contract": {+ "type": "string"+ },"bytecode_error": {"type": "string"},@@ -451,6 +460,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.jsonindex 431d4976882f..7322f3e025c2 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json@@ -41,6 +41,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -115,6 +118,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},@@ -235,6 +241,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -290,6 +299,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.jsonindex 2ae366f1831c..6dc32032ab78 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json@@ -35,6 +35,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -105,6 +108,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},@@ -225,6 +231,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -280,6 +289,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.jsonindex 11419da65800..6a4de21cedde 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json@@ -41,6 +41,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -115,6 +118,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},@@ -235,6 +241,9 @@},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"data_warehouse": {"items": {"additionalProperties": {},@@ -290,6 +299,9 @@"items": {},"type": "array"},+ "bytecode_contract": {+ "type": "string"+ },"order": {"type": "number"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.jsonindex 4bb49a06758f..55b90c68a7db 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-create.json@@ -37,6 +37,9 @@"type": "array"},"bytecode": {},+ "bytecode_contract": {+ "type": "string"+ },"bytecode_error": {"type": "string"},@@ -121,6 +124,9 @@"type": "array"},"bytecode": {},+ "bytecode_contract": {+ "type": "string"+ },"bytecode_error": {"type": "string"},@@ -223,6 +229,9 @@"type": "array"},"bytecode": {},+ "bytecode_contract": {+ "type": "string"+ },"bytecode_error": {"type": "string"},@@ -359,6 +368,9 @@"type": "array"},"bytecode": {},+ "bytecode_contract": {+ "type": "string"+ },"bytecode_error": {"type": "string"},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.jsonindex 9441e657a8b4..dd9f89818f7e 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json@@ -26,6 +26,9 @@"type": "array"},"bytecode": {},+ "bytecode_contract": {+ "type": "string"+ },"bytecode_error": {"type": "string"},