: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
fix(team): make team extension creation at team creation opt-in (#105623)
Phil Haack58f4096e1391
diff --git a/posthog/api/test/test_event.py b/posthog/api/test/test_event.pyindex 2774f1d9d00b..5b3e31d7a687 100644--- a/posthog/api/test/test_event.py+++ b/posthog/api/test/test_event.py@@ -26,6 +26,8 @@ from rest_framework import statusfrom posthog.models import Element, Organization, PropertyDefinition, Userfrom posthog.models.event.legacy_events_query import _execute_events_list_query+from posthog.models.team.extensions import get_or_create_team_extension+from posthog.models.team.team_revenue_analytics_config import TeamRevenueAnalyticsConfigfrom posthog.test.persons import create_personfrom posthog.test.test_journeys import journeys_for@@ -102,6 +104,10 @@ class TestEvents(ClickhouseTestMixin, APIBaseTest):)flush_persons_and_events()+ # The HogQL database build creates the revenue analytics row on a team's first query.+ # Create it here so the count below covers only the queries every request makes.+ get_or_create_team_extension(self.team, TeamRevenueAnalyticsConfig)+# Auth/team/membership/instance-setting lookups, plus the HogQL pipeline's per-probe# access-control checks (the progressive-window loop probes several windows on this# sparse dataset; the schema is built once and shared). Group-type-mapping is read via@@ -135,6 +141,10 @@ class TestEvents(ClickhouseTestMixin, APIBaseTest):)flush_persons_and_events()+ # The HogQL database build creates the revenue analytics row on a team's first query.+ # Create it here so the count below covers only the queries every request makes.+ get_or_create_team_extension(self.team, TeamRevenueAnalyticsConfig)+# Auth/team/membership/access-control/instance-setting lookups, plus the HogQL# pipeline's per-probe access-control checks. The progressive-window loop probes several# windows on this sparse dataset; the HogQL schema is built once and shared across them.diff --git a/posthog/api/test/test_person.py b/posthog/api/test/test_person.pyindex 86087c079e53..0a2955ed1811 100644--- a/posthog/api/test/test_person.py+++ b/posthog/api/test/test_person.py@@ -42,6 +42,8 @@ from posthog.models.person.util import (get_person_by_id,get_person_by_uuid,)+from posthog.models.team.extensions import get_or_create_team_extension+from posthog.models.team.team_revenue_analytics_config import TeamRevenueAnalyticsConfigfrom posthog.personhog_client.fake_client import fake_personhog_clientfrom posthog.test.persons import add_distinct_id, create_person, delete_person@@ -1996,6 +1998,9 @@ class TestPerson(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):# We would return an empty "next" url.# Now we just return 9 people insteadcreate_person_in_ch(team_id=self.team.pk, version=0)+ # The HogQL database build creates the revenue analytics row on a team's first query.+ # Create it here so the count below covers only the queries every request makes.+ get_or_create_team_extension(self.team, TeamRevenueAnalyticsConfig)returned_ids = []# The property-access-control feature check reuses the request's already-loaded team,diff --git a/posthog/models/team/README.md b/posthog/models/team/README.mdindex 342ac341f88a..bed0468aeb52 100644--- a/posthog/models/team/README.md+++ b/posthog/models/team/README.md@@ -28,14 +28,9 @@ Recent additions that should have been extensions include toggles for Experiment```python# products/my_product/backend/models/team_my_product_config.py-import logging-from django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class TeamMyProductConfig(models.Model):@@ -45,16 +40,28 @@ class TeamMyProductConfig(models.Model):# Your domain-specific fieldssome_setting = models.BooleanField(default=False)config_json = models.JSONField(default=dict)+```++Then run `python manage.py makemigrations`.+By default, creating a team does not create its extension rows.+A row is created on first access, through `get_or_create_team_extension`, so a team has no row until code first reads or writes that extension for it.+Put default values on the model fields, not in a `defaults=` argument at a call site, so that every path that creates the row writes the same values.+Code that reads the table outside Django (Node, Rust, raw SQL) must treat a missing row as the field defaults, for example with a `LEFT JOIN` from the team table and `COALESCE` on each field.-register_team_extension_signal(- TeamMyProductConfig,- defaults={"some_setting": True}, # optional- logger=logger,-)+### Creating the row at team creation (opt-in)++Register the extension with `register_team_extension_signal` only when the row's default depends on other state at the moment the team is created, such as the organization's other teams.++```python+from posthog.models.team.extensions import register_team_extension_signal++register_team_extension_signal(TeamMyProductConfig)```-Then run `python manage.py makemigrations`.+The hook connects a `post_save` receiver on `Team` that creates the row when a team is created.+The receiver logs and ignores errors, and teams created before the registration have no row.+Django code still reads the row through `get_or_create_team_extension`, and code outside Django still treats a missing row as the field defaults.## Usagediff --git a/posthog/models/team/extensions.py b/posthog/models/team/extensions.pyindex e1a1f355e3b7..98d8632d108c 100644--- a/posthog/models/team/extensions.py+++ b/posthog/models/team/extensions.py@@ -78,7 +78,11 @@ def register_team_extension_signal(except Exception as e:_logger.warning(f"Error creating {model_name}: {e}")- post_save.connect(receiver_func, sender=Team, dispatch_uid=f"create_{model_name.lower()}")+ # weak=False: receiver_func is local, so the default weak reference dies as soon as this+ # function returns and the next connect() sweeps the dead entry away. Under DEBUG the+ # receiver survives by accident, because Signal.connect's kwargs check caches it, so only+ # production loses the receiver.+ post_save.connect(receiver_func, sender=Team, dispatch_uid=f"create_{model_name.lower()}", weak=False)class TeamExtensionDescriptor:diff --git a/posthog/models/team/js_snippet_config.py b/posthog/models/team/js_snippet_config.pyindex a6aa66f4093f..eac1125a1213 100644--- a/posthog/models/team/js_snippet_config.py+++ b/posthog/models/team/js_snippet_config.py@@ -1,17 +1,8 @@-import logging-from django.db import models-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)-class TeamJsSnippetConfig(models.Model):team = models.OneToOneField("posthog.Team", on_delete=models.CASCADE, primary_key=True)# Version pin: null = use latest, "1.358.0" = exact, "1" = major, "1.358" = minorjs_snippet_version = models.CharField(max_length=50, null=True, blank=True, default=None)---register_team_extension_signal(TeamJsSnippetConfig, logger=logger)diff --git a/posthog/models/team/team.py b/posthog/models/team/team.pyindex 14c638821021..7f8ffa4b30ff 100644--- a/posthog/models/team/team.py+++ b/posthog/models/team/team.py@@ -43,8 +43,6 @@ from posthog.settings.utils import get_list# without booting Django; re-exported here for existing callers.from posthog.week_start_day import WeekStartDay # noqa: F401-from products.customer_analytics.backend.facade.constants import DEFAULT_ACTIVITY_EVENT-from ...hogql.modifiers import set_default_modifier_valuesfrom ...schema_enums import CurrencyCode, PersonsOnEventsModefrom .extensions import get_or_create_team_extension@@ -745,9 +743,7 @@ class Team(UUIDTClassicModel):def customer_analytics_config(self):from products.customer_analytics.backend.facade.team_extension import TeamCustomerAnalyticsConfig- return get_or_create_team_extension(- self, TeamCustomerAnalyticsConfig, defaults={"activity_event": DEFAULT_ACTIVITY_EVENT}- )+ return get_or_create_team_extension(self, TeamCustomerAnalyticsConfig)@cached_propertydef workflows_config(self):diff --git a/posthog/models/team/team_marketing_analytics_config.py b/posthog/models/team/team_marketing_analytics_config.pyindex 777a831639bf..5e01a9b08f8a 100644--- a/posthog/models/team/team_marketing_analytics_config.py+++ b/posthog/models/team/team_marketing_analytics_config.py@@ -1,11 +1,9 @@-import loggingfrom typing import TYPE_CHECKINGfrom django.core.exceptions import ValidationErrorfrom django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.rbac.decorators import field_access_controlfrom posthog.schema_enums import AttributionMode, NodeKind@@ -18,8 +16,6 @@ if TYPE_CHECKING:# Based on team_revenue_analytics_config.py-logger = logging.getLogger(__name__)-def validate_sources_map(sources_map: dict) -> None:"""Validate sources_map structure: dict of source_id -> dict of string mappings."""@@ -496,6 +492,3 @@ class TeamMarketingAnalyticsConfig(models.Model):# Without this the flag isn't a kill switch: flipping it leaves the old numbers cached."costs_dedup_v2": costs_dedup_v2_enabled(self.team),}---register_team_extension_signal(TeamMarketingAnalyticsConfig, logger=logger)diff --git a/posthog/models/team/team_provisioning_config.py b/posthog/models/team/team_provisioning_config.pyindex effab744bdd1..a64a77670696 100644--- a/posthog/models/team/team_provisioning_config.py+++ b/posthog/models/team/team_provisioning_config.py@@ -1,11 +1,5 @@-import logging-from django.db import models-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)-class TeamProvisioningConfig(models.Model):team = models.OneToOneField("posthog.Team", on_delete=models.CASCADE, primary_key=True)@@ -29,6 +23,3 @@ class TeamProvisioningConfig(models.Model):indexes = [models.Index(fields=["application"], name="tpc_application_idx"),]---register_team_extension_signal(TeamProvisioningConfig, logger=logger)diff --git a/posthog/models/team/team_revenue_analytics_config.py b/posthog/models/team/team_revenue_analytics_config.pyindex ad8dd8b93104..37639e72540c 100644--- a/posthog/models/team/team_revenue_analytics_config.py+++ b/posthog/models/team/team_revenue_analytics_config.py@@ -1,11 +1,9 @@-import loggingfrom typing import TYPE_CHECKINGfrom django.core.exceptions import ValidationErrorfrom django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.models.team.team import CURRENCY_CODE_CHOICES, DEFAULT_CURRENCYfrom posthog.rbac.decorators import field_access_control@@ -14,8 +12,6 @@ from posthog.rbac.decorators import field_access_controlif TYPE_CHECKING:from posthog.schema import RevenueAnalyticsEventItem-logger = logging.getLogger(__name__)-# Intentionally not inheriting from UUIDModel/UUIDTModel because we're using a OneToOneField# and therefore using the exact same primary key as the Team model.@@ -65,6 +61,3 @@ class TeamRevenueAnalyticsConfig(models.Model):"filter_test_accounts": self.filter_test_accounts,"events": [event.model_dump() for event in self.events],}---register_team_extension_signal(TeamRevenueAnalyticsConfig, logger=logger)diff --git a/posthog/test/repo_invariants/test_startup_import_budget.py b/posthog/test/repo_invariants/test_startup_import_budget.pyindex cb2f25521383..f5ec242ac159 100644--- a/posthog/test/repo_invariants/test_startup_import_budget.py+++ b/posthog/test/repo_invariants/test_startup_import_budget.py@@ -1,9 +1,12 @@import osimport reimport sys+import weakrefimport subprocessfrom pathlib import Path+from django.db.models.signals import post_save+# Heavy subsystems that must NOT be imported by a bare ``django.setup()``. Each one was# deliberately pulled off the startup path (lazy API router, deferred AI-core imports,# deferred embedded-ClickHouse). Importing any of them at setup means a new module-level@@ -296,6 +299,25 @@ def test_setup_receivers_match_baseline() -> None:)+# The baseline above resolves a weak receiver and skips a dead one, so it cannot see a receiver that+# stays alive only by accident. The weak=False comment in register_team_extension_signal explains why+# a weakly connected receiver survives under DEBUG and dies in production.+def test_team_extension_receivers_are_connected_strongly() -> None:+ extension_receivers = [entry for entry in post_save.receivers if str(entry[0][0]).startswith("create_")]+ assert extension_receivers, (+ "Found no create_* receivers on post_save. Did the dispatch_uid in register_team_extension_signal "+ "change, or does no extension register the hook any more?"+ )+ weakly_held = sorted(+ str(entry[0][0]) for entry in extension_receivers if isinstance(entry[1], weakref.ReferenceType)+ )+ assert not weakly_held, (+ f"These team-extension receivers are connected weakly: {weakly_held}. "+ "Pass weak=False in register_team_extension_signal, or the receiver is collected right after "+ "registration and no extension row is written when a team is created."+ )++# Cold-start trap the lazy router introduced and the whole pytest suite is blind to. With the AI agent# core off the startup path, a fresh process no longer pre-imports it — so the FIRST reader of the MCP# tool registry (the first MCP-tools API request in a new worker) becomes the first importer of thediff --git a/products/batch_exports/backend/tests/temporal/conftest.py b/products/batch_exports/backend/tests/temporal/conftest.pyindex baa78deab3ee..610abf3761ea 100644--- a/products/batch_exports/backend/tests/temporal/conftest.py+++ b/products/batch_exports/backend/tests/temporal/conftest.py@@ -19,6 +19,8 @@ from temporalio.testing import ActivityEnvironmentfrom posthog.conftest import create_clickhouse_tablesfrom posthog.models import Organization, Teamfrom posthog.models.integration import Integration+from posthog.models.team.extensions import get_or_create_team_extension+from posthog.models.team.team_revenue_analytics_config import TeamRevenueAnalyticsConfigfrom posthog.models.team.util import delete_batch_exportsfrom posthog.models.utils import uuid7from posthog.temporal.common.clickhouse import ClickHouseClient@@ -107,6 +109,17 @@ def team(organization):team.delete()+def _create_async_fixture_team(organization: Organization) -> Team:+ # A test that builds a HogQL query creates the team's revenue analytics row in the test's transaction.+ # The async fixtures create and delete the team through sync_to_async, on a different connection.+ # That delete cannot cascade to the uncommitted row, so teardown fails its foreign key check.+ # Creating the row here puts it on the same connection as the delete.+ name = f"BatchExportsTestTeam-{random.randint(1, 99999)}"+ team = Team.objects.create(organization=organization, name=name)+ get_or_create_team_extension(team, TeamRevenueAnalyticsConfig)+ return team++@pytest_asyncio.fixtureasync def aorganization(db):name = f"BatchExportsTestOrg-{random.randint(1, 99999)}"@@ -119,8 +132,7 @@ async def aorganization(db):@pytest_asyncio.fixtureasync def ateam(aorganization):- name = f"BatchExportsTestTeam-{random.randint(1, 99999)}"- team = await sync_to_async(Team.objects.create)(organization=aorganization, name=name)+ team = await sync_to_async(_create_async_fixture_team)(aorganization)yield teamawait sync_to_async(delete_batch_exports)(team_ids=[team.pk])@@ -129,8 +141,7 @@ async def ateam(aorganization):@pytest_asyncio.fixtureasync def another_ateam(aorganization):- name = f"BatchExportsTestTeam-{random.randint(1, 99999)}"- team = await sync_to_async(Team.objects.create)(organization=aorganization, name=name)+ team = await sync_to_async(_create_async_fixture_team)(aorganization)yield teamawait sync_to_async(delete_batch_exports)(team_ids=[team.pk])diff --git a/products/business_knowledge/backend/models/team_business_knowledge_config.py b/products/business_knowledge/backend/models/team_business_knowledge_config.pyindex 28816442f9fa..faa6de9cc135 100644--- a/products/business_knowledge/backend/models/team_business_knowledge_config.py+++ b/products/business_knowledge/backend/models/team_business_knowledge_config.py@@ -1,11 +1,6 @@-import logging-from django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class TeamBusinessKnowledgeConfig(models.Model):@@ -26,6 +21,3 @@ class TeamBusinessKnowledgeConfig(models.Model):class Meta:app_label = "business_knowledge"---register_team_extension_signal(TeamBusinessKnowledgeConfig, logger=logger)diff --git a/products/conversations/backend/migrations/0027_slack_config_unique_slack_team_id.py b/products/conversations/backend/migrations/0027_slack_config_unique_slack_team_id.pyindex f166e31e234b..a2b099137713 100644--- a/products/conversations/backend/migrations/0027_slack_config_unique_slack_team_id.py+++ b/products/conversations/backend/migrations/0027_slack_config_unique_slack_team_id.py@@ -4,8 +4,8 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):"""Create partial unique index concurrently (non-blocking) on slack_team_id.- Excludes NULL rows since every team gets an auto-created config via- register_team_extension_signal with slack_team_id=NULL.+ Excludes NULL rows because every config row starts with slack_team_id=NULL+ until the team connects Slack."""atomic = Falsediff --git a/products/conversations/backend/models/team_conversations_slack_config.py b/products/conversations/backend/models/team_conversations_slack_config.pyindex 44c19220a0d3..46c4547e070e 100644--- a/products/conversations/backend/models/team_conversations_slack_config.py+++ b/products/conversations/backend/models/team_conversations_slack_config.py@@ -1,12 +1,7 @@-import logging-from django.db import modelsfrom posthog.helpers.encrypted_fields import EncryptedTextFieldfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class TeamConversationsSlackConfig(models.Model):@@ -28,6 +23,3 @@ class TeamConversationsSlackConfig(models.Model):name="unique_slack_team_id",),]---register_team_extension_signal(TeamConversationsSlackConfig, logger=logger)diff --git a/products/conversations/backend/models/team_conversations_teams_config.py b/products/conversations/backend/models/team_conversations_teams_config.pyindex a76125c21764..df80e7b2296a 100644--- a/products/conversations/backend/models/team_conversations_teams_config.py+++ b/products/conversations/backend/models/team_conversations_teams_config.py@@ -1,12 +1,7 @@-import logging-from django.db import modelsfrom posthog.helpers.encrypted_fields import EncryptedTextFieldfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class TeamConversationsTeamsConfig(models.Model):@@ -35,6 +30,3 @@ class TeamConversationsTeamsConfig(models.Model):name="unique_teams_tenant_id",),]---register_team_extension_signal(TeamConversationsTeamsConfig, logger=logger)diff --git a/products/customer_analytics/backend/migrations/0057_team_customer_analytics_config_activity_event_default.py b/products/customer_analytics/backend/migrations/0057_team_customer_analytics_config_activity_event_default.pynew file mode 100644index 000000000000..96b332a535e7--- /dev/null+++ b/products/customer_analytics/backend/migrations/0057_team_customer_analytics_config_activity_event_default.py@@ -0,0 +1,21 @@+# Generated by Django 5.2.17 on 2026-09-24 00:02++from django.db import migrations, models++import products.customer_analytics.backend.models.team_customer_analytics_config+++class Migration(migrations.Migration):+ dependencies = [+ ("customer_analytics", "0056_feature_request_github"),+ ]++ operations = [+ migrations.AlterField(+ model_name="teamcustomeranalyticsconfig",+ name="activity_event",+ field=models.JSONField(+ default=products.customer_analytics.backend.models.team_customer_analytics_config.default_activity_event+ ),+ ),+ ]diff --git a/products/customer_analytics/backend/migrations/max_migration.txt b/products/customer_analytics/backend/migrations/max_migration.txtindex b1a846365428..c1da31c3bf35 100644--- a/products/customer_analytics/backend/migrations/max_migration.txt+++ b/products/customer_analytics/backend/migrations/max_migration.txt@@ -1 +1 @@-0056_feature_request_github+0057_team_customer_analytics_config_activity_event_defaultdiff --git a/products/customer_analytics/backend/models/account_test.py b/products/customer_analytics/backend/models/account_test.pyindex a89b2dcd1980..12c56526cde4 100644--- a/products/customer_analytics/backend/models/account_test.py+++ b/products/customer_analytics/backend/models/account_test.py@@ -9,6 +9,7 @@ from pydantic import ValidationError as PydanticValidationErrorfrom posthog.models import Team, Userfrom posthog.models.scoping import team_scope+from posthog.models.team.extensions import get_or_create_team_extensionfrom products.customer_analytics.backend.models import Account, TeamCustomerAnalyticsConfigfrom products.customer_analytics.backend.models.account import AccountProperties@@ -86,7 +87,7 @@ class AccountExternalIdUniquenessTest(TeamScopedTestMixin, BaseTest):class TeamCustomerAnalyticsConfigDriftPolicyTest(TeamScopedTestMixin, BaseTest):def setUp(self):super().setUp()- self.config = TeamCustomerAnalyticsConfig.objects.get(team=self.team)+ self.config = get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)@parameterized.expand([diff --git a/products/customer_analytics/backend/models/team_customer_analytics_config.py b/products/customer_analytics/backend/models/team_customer_analytics_config.pyindex ed8f917823d0..0bae29975b34 100644--- a/products/customer_analytics/backend/models/team_customer_analytics_config.py+++ b/products/customer_analytics/backend/models/team_customer_analytics_config.py@@ -1,14 +1,13 @@-import logging-from django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.rbac.decorators import field_access_controlfrom products.customer_analytics.backend.constants import DEFAULT_ACTIVITY_EVENT-logger = logging.getLogger(__name__)++def default_activity_event() -> dict:+ return dict(DEFAULT_ACTIVITY_EVENT)def default_account_track_rules() -> dict:@@ -23,7 +22,7 @@ def default_account_track_rules() -> dict:class TeamCustomerAnalyticsConfig(models.Model):team = models.OneToOneField(Team, on_delete=models.CASCADE, primary_key=True)- activity_event = field_access_control(models.JSONField(default=dict), "project", "admin")+ activity_event = field_access_control(models.JSONField(default=default_activity_event), "project", "admin")signup_pageview_event = field_access_control(models.JSONField(default=dict), "project", "admin")signup_event = field_access_control(models.JSONField(default=dict), "project", "admin")subscription_event = field_access_control(models.JSONField(default=dict), "project", "admin")@@ -42,10 +41,3 @@ class TeamCustomerAnalyticsConfig(models.Model):"subscription_event": self.subscription_event,"payment_event": self.payment_event,}---register_team_extension_signal(- TeamCustomerAnalyticsConfig,- defaults={"activity_event": DEFAULT_ACTIVITY_EVENT},- logger=logger,-)diff --git a/products/customer_analytics/backend/test/test_account_track_rules.py b/products/customer_analytics/backend/test/test_account_track_rules.pyindex f655a960da9f..cfa6ac3643db 100644--- a/products/customer_analytics/backend/test/test_account_track_rules.py+++ b/products/customer_analytics/backend/test/test_account_track_rules.py@@ -21,8 +21,10 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Workerfrom posthog.models import OrganizationMembership, Teamfrom posthog.models.activity_logging.activity_log import ActivityLogfrom posthog.models.personal_api_key import PersonalAPIKey+from posthog.models.team.extensions import get_or_create_team_extensionfrom posthog.models.utils import generate_random_token_personal, hash_key_value+from products.customer_analytics.backend.constants import DEFAULT_ACTIVITY_EVENTfrom products.customer_analytics.backend.logic.account_track_rules import (AccountTrackRuleValidationError,EnabledAccountTrackRuleConfig,@@ -374,16 +376,20 @@ class AccountTrackRulesTestMixin:)return definition, paying, vip, unmatched, ignored, churned- def save_config(self, config: dict) -> None:- TeamCustomerAnalyticsConfig.objects.filter(team_id=self.team.id).update(account_track_rules=config)+ def save_config(self, config: dict, team: Team | None = None) -> None:+ team = team or self.team+ get_or_create_team_extension(team, TeamCustomerAnalyticsConfig)+ TeamCustomerAnalyticsConfig.objects.filter(team_id=team.id).update(account_track_rules=config)@time_machine.travel("2026-08-20T12:00:00Z", tick=False)class TestAccountTrackRuleLogic(AccountTrackRulesTestMixin, BaseTest):def test_config_defaults_to_a_disabled_empty_version(self) -> None:- config = TeamCustomerAnalyticsConfig.objects.get(team_id=self.team.id).account_track_rules+ get_account_track_rules(self.team.id)+ config = TeamCustomerAnalyticsConfig.objects.get(team_id=self.team.id)- assert config == {"schema_version": 1, "version": 0, "enabled": False, "groups": []}+ assert config.account_track_rules == {"schema_version": 1, "version": 0, "enabled": False, "groups": []}+ assert config.activity_event == DEFAULT_ACTIVITY_EVENTdef test_enablement_timestamp_tracks_the_current_enabled_period(self) -> None:update_account_track_rules(@@ -822,9 +828,7 @@ class TestAccountTrackRuleLogic(AccountTrackRulesTestMixin, BaseTest):(other_enabled_team, True),(disabled_team, False),]:- TeamCustomerAnalyticsConfig.objects.filter(team_id=team.id).update(- account_track_rules=account_name_track_rules_config(version=3, enabled=enabled)- )+ self.save_config(account_name_track_rules_config(version=3, enabled=enabled), team=team)found_team_ids: list[int] = []after_team_id = 0diff --git a/products/customer_analytics/backend/test/test_email_account_matching.py b/products/customer_analytics/backend/test/test_email_account_matching.pyindex e6c1b2f42ed5..028f23a05480 100644--- a/products/customer_analytics/backend/test/test_email_account_matching.py+++ b/products/customer_analytics/backend/test/test_email_account_matching.py@@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patchfrom parameterized import parameterizedfrom posthog.models.organization import Organization, OrganizationMembership+from posthog.models.team.extensions import get_or_create_team_extensionfrom posthog.models.user import Userfrom products.conversations.backend.facade.types import EmailThreadForAccountMatching@@ -19,10 +20,16 @@ from products.customer_analytics.backend.logic.email_account_matching import (MatchedAccount,match_accounts_for_gmail_emails,)-from products.customer_analytics.backend.models import Account+from products.customer_analytics.backend.models import Account, TeamCustomerAnalyticsConfigclass TestEmailAccountMatching(BaseTest):+ def setUp(self) -> None:+ super().setUp()+ # Team.customer_analytics_config caches the config object process-wide. Without a row here, a later test+ # gets the object an earlier test created and rolled back, and save(update_fields=...) updates no rows.+ get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)+def _create_account(self,*,diff --git a/products/data_modeling/backend/models/github_sync_config.py b/products/data_modeling/backend/models/github_sync_config.pyindex 218e8bb1ee15..85f2e4554b38 100644--- a/products/data_modeling/backend/models/github_sync_config.py+++ b/products/data_modeling/backend/models/github_sync_config.py@@ -1,13 +1,8 @@-import logging-from django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.models.utils import CreatedMetaFields, UpdatedMetaFields-logger = logging.getLogger(__name__)-class GitHubSyncStatus(models.TextChoices):IDLE = "idle"@@ -51,6 +46,3 @@ class GitHubSyncConfig(CreatedMetaFields, UpdatedMetaFields):class Meta:app_label = "data_modeling"db_table = "posthog_datamodelinggithubsyncconfig"---register_team_extension_signal(GitHubSyncConfig, logger=logger)diff --git a/products/data_quality/backend/models/team_data_quality_config.py b/products/data_quality/backend/models/team_data_quality_config.pyindex a98f99fec585..71917aacba73 100644--- a/products/data_quality/backend/models/team_data_quality_config.py+++ b/products/data_quality/backend/models/team_data_quality_config.py@@ -1,11 +1,6 @@-import logging-from django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class TeamDataQualityConfig(models.Model):@@ -26,6 +21,3 @@ class TeamDataQualityConfig(models.Model):class Meta:app_label = "data_quality"---register_team_extension_signal(TeamDataQualityConfig, logger=logger)diff --git a/products/data_warehouse/backend/models/team_data_warehouse_config.py b/products/data_warehouse/backend/models/team_data_warehouse_config.pyindex 34965c5381b9..beb71a0d8aaf 100644--- a/products/data_warehouse/backend/models/team_data_warehouse_config.py+++ b/products/data_warehouse/backend/models/team_data_warehouse_config.py@@ -1,11 +1,6 @@-import logging-from django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class TeamDataWarehouseConfig(models.Model):@@ -21,6 +16,3 @@ class TeamDataWarehouseConfig(models.Model):class Meta:app_label = "data_warehouse"---register_team_extension_signal(TeamDataWarehouseConfig, logger=logger)diff --git a/products/data_warehouse/backend/tests/api/test_data_warehouse.py b/products/data_warehouse/backend/tests/api/test_data_warehouse.pyindex da542e8d365b..f30be998f371 100644--- a/products/data_warehouse/backend/tests/api/test_data_warehouse.py+++ b/products/data_warehouse/backend/tests/api/test_data_warehouse.py@@ -626,9 +626,7 @@ class TestDataWarehouseAPI(APIBaseTest):def test_data_ops_dashboard_creates_dashboard_on_first_call(self):endpoint = f"/api/projects/{self.team.pk}/data_warehouse/data_ops_dashboard"- # Config is auto-created by the team extension signal, but starts with no dashboards- config = TeamDataWarehouseConfig.objects.get(team=self.team)- self.assertEqual(config.overview_dashboards.count(), 0)+ self.assertFalse(TeamDataWarehouseConfig.objects.filter(team=self.team).exists())response = self.client.get(endpoint)self.assertEqual(response.status_code, 200)diff --git a/products/endpoints/backend/tests/test_endpoint_materialization.py b/products/endpoints/backend/tests/test_endpoint_materialization.pyindex 2ca398610255..1be9a478bcd6 100644--- a/products/endpoints/backend/tests/test_endpoint_materialization.py+++ b/products/endpoints/backend/tests/test_endpoint_materialization.py@@ -20,6 +20,8 @@ from rest_framework.response import Responsefrom posthog.hogql.errors import QueryErrorfrom posthog.constants import RETENTION_FIRST_EVER_OCCURRENCE, TREND_FILTER_TYPE_EVENTS+from posthog.models.team.extensions import get_or_create_team_extension+from posthog.models.team.team_revenue_analytics_config import TeamRevenueAnalyticsConfigfrom posthog.sync import database_sync_to_asyncfrom products.data_modeling.backend.facade.api import UnsatisfiableFrequencyError, get_declared_target@@ -2180,6 +2182,10 @@ class TestEndpointMaterialization(ClickhouseTestMixin, APIBaseTest):"dateRange": {"date_from": "-7d"},}+ # The HogQL database build reads team.revenue_analytics_config, which creates the row on a team's+ # first access. Create it first so the capture measures only build_endpoint_hogql.+ get_or_create_team_extension(self.team, TeamRevenueAnalyticsConfig)+with CaptureQueriesContext(connection) as ctx:build_endpoint_hogql(insight_query, self.team)diff --git a/products/experiments/backend/models/team_experiments_config.py b/products/experiments/backend/models/team_experiments_config.pyindex a30058b8192b..5df29eeccbbf 100644--- a/products/experiments/backend/models/team_experiments_config.py+++ b/products/experiments/backend/models/team_experiments_config.py@@ -1,13 +1,8 @@-import logging-from django.core.validators import MaxValueValidator, MinValueValidatorfrom django.db import modelsfrom posthog.models.organization import Organizationfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class TeamExperimentsConfig(models.Model):@@ -122,6 +117,3 @@ class TeamExperimentsConfig(models.Model):"to the team's GitHub installation at cleanup time or it is ignored."),)---register_team_extension_signal(TeamExperimentsConfig, logger=logger)diff --git a/products/feature_flags/backend/models/team_feature_flag_defaults_config.py b/products/feature_flags/backend/models/team_feature_flag_defaults_config.pyindex 945e58b9cbb9..f5a6a495b32c 100644--- a/products/feature_flags/backend/models/team_feature_flag_defaults_config.py+++ b/products/feature_flags/backend/models/team_feature_flag_defaults_config.py@@ -1,11 +1,5 @@-import logging-from django.db import models-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)-class TeamFeatureFlagDefaultsConfig(models.Model):team = models.OneToOneField("posthog.Team", on_delete=models.CASCADE, primary_key=True, related_name="+")@@ -15,6 +9,3 @@ class TeamFeatureFlagDefaultsConfig(models.Model):# Matches FeatureFlag.filters["groups"] structure:# [{"properties": [...], "rollout_percentage": N, "variant": null}, ...]default_groups = models.JSONField(default=list)---register_team_extension_signal(TeamFeatureFlagDefaultsConfig, logger=logger)diff --git a/products/feature_flags/backend/models/team_feature_flag_policy_config.py b/products/feature_flags/backend/models/team_feature_flag_policy_config.pyindex 8627fee3a126..424e21794cdd 100644--- a/products/feature_flags/backend/models/team_feature_flag_policy_config.py+++ b/products/feature_flags/backend/models/team_feature_flag_policy_config.py@@ -1,11 +1,5 @@-import logging-from django.db import models-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)-class TeamFeatureFlagPolicyConfig(models.Model):"""Customer-editable rules that guard how a team's members create flags.@@ -34,9 +28,6 @@ class TeamFeatureFlagPolicyConfig(models.Model):require_tags = models.BooleanField(default=False)-register_team_extension_signal(TeamFeatureFlagPolicyConfig, logger=logger)--def team_requires_flag_tags(team_id: int) -> bool:"""Whether this team requires tags on flags.diff --git a/products/feature_flags/backend/test/test_team_feature_flag_policy_config.py b/products/feature_flags/backend/test/test_team_feature_flag_policy_config.pyindex 4a760ba1feb6..3efc78f4271e 100644--- a/products/feature_flags/backend/test/test_team_feature_flag_policy_config.py+++ b/products/feature_flags/backend/test/test_team_feature_flag_policy_config.py@@ -4,7 +4,10 @@ from rest_framework import statusfrom posthog.models import OrganizationMembership-from products.feature_flags.backend.models.team_feature_flag_policy_config import TeamFeatureFlagPolicyConfig+from products.feature_flags.backend.models.team_feature_flag_policy_config import (+ TeamFeatureFlagPolicyConfig,+ team_requires_flag_tags,+)class TestTeamFeatureFlagPolicyConfig(APIBaseTest):@@ -40,7 +43,7 @@ class TestTeamFeatureFlagPolicyConfig(APIBaseTest):response = self.client.patch(self.url, {"feature_flag_policy_config": {"require_tags": True}})assert response.status_code == status.HTTP_403_FORBIDDEN- assert TeamFeatureFlagPolicyConfig.objects.get(team=self.team).require_tags is False+ assert team_requires_flag_tags(self.team.id) is Falsedef test_patching_other_team_fields_leaves_require_tags_alone(self) -> None:self.client.patch(self.url, {"feature_flag_policy_config": {"require_tags": True}})diff --git a/products/logs/backend/models.py b/products/logs/backend/models.pyindex ea93c6e2d152..5d4ea98b81c5 100644--- a/products/logs/backend/models.py+++ b/products/logs/backend/models.py@@ -1,6 +1,5 @@from __future__ import annotations-import loggingfrom datetime import UTC, datetime, timedeltafrom typing import TYPE_CHECKING@@ -11,14 +10,12 @@ from django.db.models import Valuefrom posthog.models.activity_logging.model_activity import ModelActivityMixinfrom posthog.models.scoping.root_mixin import TeamScopedRootMixin-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.models.utils import CreatedMetaFields, UpdatedMetaFields, UUIDModelfrom posthog.utils import generate_short_idif TYPE_CHECKING:from products.logs.backend.alert_state_machine import AlertSnapshot-logger = logging.getLogger(__name__)# Default log attribute key whose value matches a PostHog person's distinct_id. Mirrors# the convention documented at https://posthog.com/docs/logs/link-session-replay: the@@ -164,8 +161,6 @@ class TeamLogsConfig(models.Model):)-register_team_extension_signal(TeamLogsConfig, logger=logger)-# Upper bound on LogsAlertConfiguration.evaluation_periods. Doubles as the per-alert# cap on retained OK event rows — the N-of-M evaluator never reads more than this many# non-errored rows per alert, so older OK rows are pruned. Mirrored in the serializer'sdiff --git a/products/marketing_analytics/backend/test_api_apply_setup_ops.py b/products/marketing_analytics/backend/test_api_apply_setup_ops.pyindex 80780cb5c89b..17ddccd994eb 100644--- a/products/marketing_analytics/backend/test_api_apply_setup_ops.py+++ b/products/marketing_analytics/backend/test_api_apply_setup_ops.py@@ -7,6 +7,7 @@ from parameterized import parameterizedfrom posthog.constants import AvailableFeaturefrom posthog.models.organization import OrganizationMembership+from posthog.models.team.extensions import get_or_create_team_extensionfrom posthog.models.team.team_marketing_analytics_config import TeamMarketingAnalyticsConfigfrom products.access_control.backend.models.access_control import AccessControl@@ -24,6 +25,7 @@ class TestApplySetupOps(APIBaseTest):def setUp(self):super().setUp()self.url = f"/api/projects/{self.team.pk}/marketing_analytics/apply_setup_ops"+ get_or_create_team_extension(self.team, TeamMarketingAnalyticsConfig)cache.clear()# Applying writes the same admin-gated config fields the team PATCH protects.self.organization_membership.level = OrganizationMembership.Level.ADMIN@@ -350,6 +352,7 @@ class TestRevenueGoalConsistencyViaOps(APIBaseTest):def setUp(self):super().setUp()self.url = f"/api/projects/{self.team.pk}/marketing_analytics/apply_setup_ops"+ get_or_create_team_extension(self.team, TeamMarketingAnalyticsConfig)cache.clear()# Applying writes the same admin-gated config fields the team PATCH protects.self.organization_membership.level = OrganizationMembership.Level.ADMIN@@ -413,6 +416,7 @@ class TestApplySetupOpsFeatureFlag(APIBaseTest):def setUp(self):super().setUp()self.url = f"/api/projects/{self.team.pk}/marketing_analytics/apply_setup_ops"+ get_or_create_team_extension(self.team, TeamMarketingAnalyticsConfig)cache.clear()@parameterized.expand([(False, False), (False, True), (True, False), (True, True)])@@ -442,6 +446,7 @@ class TestApplySetupOpsRequiresProjectAdmin(APIBaseTest):def setUp(self):super().setUp()self.url = f"/api/projects/{self.team.pk}/marketing_analytics/apply_setup_ops"+ get_or_create_team_extension(self.team, TeamMarketingAnalyticsConfig)cache.clear()flag = patch(_FLAG_TARGET, return_value=True)flag.start()diff --git a/products/marketing_analytics/backend/test_api_conversion_goals.py b/products/marketing_analytics/backend/test_api_conversion_goals.pyindex fdb1c712986b..9a6a4ec5463c 100644--- a/products/marketing_analytics/backend/test_api_conversion_goals.py+++ b/products/marketing_analytics/backend/test_api_conversion_goals.py@@ -13,6 +13,7 @@ from posthog.api.team import TeamMarketingAnalyticsConfigSerializerfrom posthog.constants import AvailableFeaturefrom posthog.models.activity_logging.activity_log import ActivityLogfrom posthog.models.organization import OrganizationMembership+from posthog.models.team.extensions import get_or_create_team_extensionfrom posthog.models.team.team import Teamfrom posthog.models.team.team_marketing_analytics_config import TeamMarketingAnalyticsConfig@@ -56,6 +57,7 @@ def goal_payload(name: str, event: str = "sign_up", **extra) -> dict:class TestConversionGoalWrites(APIBaseTest):def setUp(self):super().setUp()+ get_or_create_team_extension(self.team, TeamMarketingAnalyticsConfig)self.base_url = f"/api/projects/{self.team.pk}/marketing_analytics/conversion_goals"# Writing goals needs the same project-admin level the settings PATCH path requires.self.organization_membership.level = OrganizationMembership.Level.ADMIN@@ -346,6 +348,9 @@ class TestConversionGoalWrites(APIBaseTest):def test_another_teams_goals_are_not_reachable(self):goal = self.create_goal("Sign ups").json()["goal"]other_team = Team.objects.create(organization=self.organization, name="Other")+ # Without an existing row, the 404 rolls back the row that the first request creates.+ # Team.marketing_analytics_config then returns the rolled-back row from its process-wide cache.+ get_or_create_team_extension(other_team, TeamMarketingAnalyticsConfig)other_url = f"/api/projects/{other_team.pk}/marketing_analytics/conversion_goals"update = self.client.patch(@@ -409,6 +414,7 @@ class TestConversionGoalWrites(APIBaseTest):class TestConversionGoalIdIsOneName(APIBaseTest):def setUp(self):super().setUp()+ get_or_create_team_extension(self.team, TeamMarketingAnalyticsConfig)self.base_url = f"/api/projects/{self.team.pk}/marketing_analytics/conversion_goals"self.explain_url = f"/api/projects/{self.team.pk}/marketing_analytics/explain_conversion_goal"self.organization_membership.level = OrganizationMembership.Level.ADMINdiff --git a/products/marketing_analytics/backend/test_api_setup_plan.py b/products/marketing_analytics/backend/test_api_setup_plan.pyindex d1a9bfe7d5ff..3d55ebc29ac5 100644--- a/products/marketing_analytics/backend/test_api_setup_plan.py+++ b/products/marketing_analytics/backend/test_api_setup_plan.py@@ -6,7 +6,9 @@ from django.core.cache import cachefrom parameterized import parameterizedfrom posthog.models.organization import Organization, OrganizationMembership+from posthog.models.team.extensions import get_or_create_team_extensionfrom posthog.models.team.team import Team+from posthog.models.team.team_marketing_analytics_config import TeamMarketingAnalyticsConfigfrom posthog.models.user import Userfrom products.marketing_analytics.backend.services.setup_types import (@@ -202,6 +204,9 @@ class TestSetupPlanCaching(APIBaseTest):def setUp(self):super().setUp()self.url = f"/api/projects/{self.team.pk}/marketing_analytics/setup_plan"+ # Team.marketing_analytics_config caches the config object process-wide. Without a row here,+ # apply_setup_ops locks a row that an earlier test created and rolled back, and the request fails.+ get_or_create_team_extension(self.team, TeamMarketingAnalyticsConfig)# locmem persists across tests in a process; a leaked entry would make these# pass or fail depending on ordering.cache.clear()diff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.mdindex 76b78d29420f..9348862dbc15 100644--- a/products/signals/ARCHITECTURE.md+++ b/products/signals/ARCHITECTURE.md@@ -577,7 +577,7 @@ Per-team singleton config for Signals settings, including the default autonomy pNotes:-- Auto-created as a team extension via `register_team_extension_signal`+- Created on first access through `get_or_create_team_extension`. Readers treat a missing row as the field defaults.- `default_autostart_priority` defaults to `P4` (every report priority auto-starts). The inbox UI exposes it as the "Project threshold" control on the PR generation card.- `SignalUserAutonomyConfig.autostart_priority` holds a per-user override (`null` = use the team default). The inbox UI exposes it as the "My threshold" control on the same card, where a "Default" segment maps to `null` and inherits the project threshold.- `github_issue_writeback_enabled` adds a report link to each source GitHub issue after the report notification completes. The comment contains no report title or research. The report requires project access.@@ -1255,7 +1255,7 @@ The autonomy system allows Signals to automatically start a Tasks coding run wheAutonomy is configured at two levels:-1. **Team level** (`SignalTeamConfig`): Sets the `default_autostart_priority` threshold (`P0`–`P4`). Auto-created as a team extension via `register_team_extension_signal`. Managed via `GET/POST /api/projects/:team_id/signals/config/`.+1. **Team level** (`SignalTeamConfig`): Sets the `default_autostart_priority` threshold (`P0`–`P4`). Created on first access through `get_or_create_team_extension`. Managed via `GET/POST /api/projects/:team_id/signals/config/`.2. **User level** (`SignalUserAutonomyConfig`): Per-user opt-in. A row existing means the user is opted in. Each user can optionally override the team priority threshold with `autostart_priority`. Managed via `GET/PUT/DELETE /api/users/@me/signal_autonomy/`.diff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex 6e900d3b0cf8..f0afa3ad6cf6 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -22,7 +22,6 @@ from posthog.migration_helpers import deprecate_fieldfrom posthog.models.activity_logging.model_activity import ModelActivityMixinfrom posthog.models.scoping.manager import EnvironmentScopedManagerfrom posthog.models.scoping.root_mixin import TeamScopedRootMixin-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.models.utils import UUIDModelfrom products.signals.backend.artefact_attribution import ArtefactAttribution@@ -224,9 +223,6 @@ class SignalTeamConfig(ModelActivityMixin, UUIDModel):return self.autostart_base_branches.get(repository.lower()) or None-register_team_extension_signal(SignalTeamConfig, logger=logger)--class SignalUserAutonomyConfig(UUIDModel):user = models.OneToOneField("posthog.User", on_delete=models.CASCADE, related_name="signal_autonomy_config")autostart_priority = models.CharField(max_length=2, choices=AutonomyPriority, null=True, blank=True)diff --git a/products/signals/backend/test/test_daily_limit.py b/products/signals/backend/test/test_daily_limit.pyindex fd12faa346ff..a2818f7d5c12 100644--- a/products/signals/backend/test/test_daily_limit.py+++ b/products/signals/backend/test/test_daily_limit.py@@ -7,6 +7,7 @@ from unittest.mock import patchfrom parameterized import parameterizedfrom posthog.models import Team+from posthog.models.team.extensions import get_or_create_team_extensionfrom products.signals.backend.daily_limit import DailyReportLimitGate, daily_report_limit_gatefrom products.signals.backend.models import SignalReport, SignalTeamConfig@@ -17,8 +18,7 @@ DAILY_LIMIT_MODULE = "products.signals.backend.daily_limit"class TestDailyReportLimitGate(BaseTest):def setUp(self) -> None:super().setUp()- # A SignalTeamConfig is auto-created for every team via register_team_extension_signal.- self.config = SignalTeamConfig.objects.get(team=self.team)+ self.config = get_or_create_team_extension(self.team, SignalTeamConfig)def _set_limit(self, limit: int | None) -> None:self.config.max_reports_per_day = limitdiff --git a/products/signals/backend/test/test_signal_team_config_api.py b/products/signals/backend/test/test_signal_team_config_api.pyindex 67479b073019..5bf6a0adc8cc 100644--- a/products/signals/backend/test/test_signal_team_config_api.py+++ b/products/signals/backend/test/test_signal_team_config_api.py@@ -8,6 +8,7 @@ from parameterized import parameterizedfrom rest_framework import statusfrom posthog.models.activity_logging.activity_log import ActivityLog+from posthog.models.team.extensions import get_or_create_team_extensionfrom products.signals.backend.facade.api import set_default_slack_notification_channelfrom products.signals.backend.models import SignalReport, SignalTeamConfig@@ -17,8 +18,7 @@ from products.signals.backend.serializers import MAX_AUTOSTART_BASE_BRANCH_ENTRIclass TestSignalTeamConfigAPI(APIBaseTest):def setUp(self) -> None:super().setUp()- # A SignalTeamConfig is auto-created for every team via register_team_extension_signal.- self.config = SignalTeamConfig.objects.get(team=self.team)+ self.config = get_or_create_team_extension(self.team, SignalTeamConfig)def _url(self) -> str:return f"/api/projects/{self.team.id}/signals/config/"diff --git a/products/signals/backend/test/test_slack_inbox_notifications.py b/products/signals/backend/test/test_slack_inbox_notifications.pyindex edfd4179a16b..3ce8470d50f0 100644--- a/products/signals/backend/test/test_slack_inbox_notifications.py+++ b/products/signals/backend/test/test_slack_inbox_notifications.py@@ -13,11 +13,11 @@ from posthog.models.integration import Integrationfrom posthog.models.organization import OrganizationMembershipfrom products.access_control.backend.models.access_control import AccessControl+from products.signals.backend.facade.api import set_default_slack_notification_channelfrom products.signals.backend.models import (AutonomyPriority,SignalReport,SignalReportArtefact,- SignalTeamConfig,SignalUserAutonomyConfig,)from products.signals.backend.report_generation.research import ActionabilityChoice@@ -235,8 +235,7 @@ def org_and_team():def _set_team_channel(team: Team, channel: str) -> None:- # SignalTeamConfig is auto-created per team via register_team_extension_signal.- SignalTeamConfig.objects.filter(team=team).update(default_slack_notification_channel=channel)+ set_default_slack_notification_channel(team.id, channel)def _make_reviewer_user(org: Organization, email: str, login: str) -> User:diff --git a/products/signals/backend/test/test_summary_settle_autostart.py b/products/signals/backend/test/test_summary_settle_autostart.pyindex 022f646423d4..ef696c5c9402 100644--- a/products/signals/backend/test/test_summary_settle_autostart.py+++ b/products/signals/backend/test/test_summary_settle_autostart.py@@ -74,6 +74,7 @@ async def ateam(aorganization):async def _set_config_created_at(team_id: int, created_at: datetime) -> None:# created_at is auto_now_add, so it can't be set on create — update it directly.+ await SignalTeamConfig.objects.aget_or_create(team_id=team_id)await SignalTeamConfig.objects.filter(team_id=team_id).aupdate(created_at=created_at)@@ -91,7 +92,6 @@ async def _set_config_created_at(team_id: int, created_at: datetime) -> None:],)async def test_implementation_buffer_carve_out(ateam, name, configured_seconds, config_age, expected):- # SignalTeamConfig is auto-created with the team (post_save signal); age it to exercise the carve-out.await _set_config_created_at(ateam.id, timezone.now() - config_age)with patch(f"{SUMMARY_MODULE_PATH}.IMPLEMENTATION_DEBOUNCE_SECONDS", configured_seconds):diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.pyindex e93030ce893b..00328fb0089f 100644--- a/products/tasks/backend/models.py+++ b/products/tasks/backend/models.py@@ -33,7 +33,6 @@ from posthog.models.activity_logging.model_activity import ModelActivityMixinfrom posthog.models.github_integration_base import INSTALLATION_UNAVAILABLE_SINCE_CONFIG_KEYfrom posthog.models.integration import ERROR_TOKEN_REFRESH_FAILED, Integrationfrom posthog.models.scoping.root_mixin import TeamScopedRootMixin-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.models.team.team import Teamfrom posthog.models.user import Userfrom posthog.models.utils import DeletedMetaFields, UUIDModel@@ -4123,9 +4122,6 @@ class TeamTasksConfig(models.Model):return f"TeamTasksConfig(team={self.team_id})"-register_team_extension_signal(TeamTasksConfig)--class UserTasksConfig(TeamScopedRootMixin):"""Per-(user, team) tasks settings; overrides `TeamTasksConfig` wholesale where set."""diff --git a/products/tasks/backend/tests/test_admin.py b/products/tasks/backend/tests/test_admin.pyindex 3d29cebf62cf..1ef3518d236b 100644--- a/products/tasks/backend/tests/test_admin.py+++ b/products/tasks/backend/tests/test_admin.py@@ -11,6 +11,7 @@ from django.urls import reversefrom parameterized import parameterizedfrom posthog.admin import register_all_admin+from posthog.models.team.extensions import get_or_create_team_extensionfrom posthog.models.team.team import Teamfrom products.tasks.backend.models import Channel, Loop, Task, TaskRun, TeamTasksConfig, UserTasksConfig@@ -213,9 +214,9 @@ class TestTasksConfigAdminForms(BaseTest):assert "ai_run_preferences" in form.errorsdef test_accepts_a_valid_payload_on_both_admin_forms(self) -> None:- # The extension row is auto-created with the team, so the admin flow is a change form.+ # Pass an existing row so that the admin flow is a change form.team_form = self.team_form_class(- instance=TeamTasksConfig.objects.get(team=self.team),+ instance=get_or_create_team_extension(self.team, TeamTasksConfig),data={"team": self.team.pk,"ai_run_preferences": {"runtime_adapter": "claude", "model": "claude-opus-4-8"},diff --git a/products/tracing/backend/models.py b/products/tracing/backend/models.pyindex 8711b9771761..b81a23030adb 100644--- a/products/tracing/backend/models.py+++ b/products/tracing/backend/models.py@@ -1,6 +1,5 @@"""Django models for tracing."""-import loggingfrom typing import TYPE_CHECKINGfrom django.contrib.postgres.fields import ArrayField@@ -11,14 +10,12 @@ from posthog.dataclasses import frozenfrom posthog.models.activity_logging.model_activity import ModelActivityMixinfrom posthog.models.scoping.manager import EnvironmentScopedManagerfrom posthog.models.scoping.root_mixin import TeamScopedRootMixin-from posthog.models.team.extensions import register_team_extension_signalfrom posthog.models.utils import CreatedMetaFields, UpdatedMetaFields, UUIDModelfrom posthog.utils import generate_short_idif TYPE_CHECKING:from posthog.models import Team-logger = logging.getLogger(__name__)# Define your models here# Important:@@ -152,9 +149,6 @@ class TeamTracingConfig(models.Model):retention_last_updated = models.DateTimeField(null=True, blank=True)-register_team_extension_signal(TeamTracingConfig, logger=logger)--class TracesRetentionRule(ModelActivityMixin, CreatedMetaFields, UpdatedMetaFields, UUIDModel):"""User-defined rules that override how long matching spans are retained (evaluated in ingestionwhen enabled). First matching rule by (priority, created_at) wins; spans matching no rule keepdiff --git a/products/workflows/backend/models/team_workflows_config.py b/products/workflows/backend/models/team_workflows_config.pyindex 17101cbc00df..a8c308ff3b99 100644--- a/products/workflows/backend/models/team_workflows_config.py+++ b/products/workflows/backend/models/team_workflows_config.py@@ -1,12 +1,7 @@-import logging-from django.core.validators import MinValueValidatorfrom django.db import modelsfrom posthog.models.team import Team-from posthog.models.team.extensions import register_team_extension_signal--logger = logging.getLogger(__name__)class EmailTrackingConsentMode(models.TextChoices):@@ -68,6 +63,3 @@ class TeamWorkflowsConfig(models.Model):workflow_task_team_rate_limit_per_day = models.IntegerField(null=True, blank=True, validators=[MinValueValidator(0)])---register_team_extension_signal(TeamWorkflowsConfig, logger=logger)