: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(devex): stop tach from excluding test directories (#90021)
Julian Bez5431914d6115
diff --git a/.agents/skills/isolating-product-facade-contracts/SKILL.md b/.agents/skills/isolating-product-facade-contracts/SKILL.mdindex 8f0e73c45a78..e21da261cd99 100644--- a/.agents/skills/isolating-product-facade-contracts/SKILL.md+++ b/.agents/skills/isolating-product-facade-contracts/SKILL.md@@ -140,8 +140,16 @@ coupling escape it — none is a dead end, each has a defined move. After thebackend sweep, `git grep "products.<name>"` (not just `.backend`) and read thescan's string-reference section to find them.-**Test-infrastructure coupling.** Core tests reach into the product's test-helpers, which no facade re-export naturally covers:+**Test-infrastructure coupling.** Tests are in tach's interface graph but not+in its dependency graph (`hogli lint:tach` runs the two passes CI runs). A test+may import any product's public surface without a `depends_on` entry, and a+test that imports another product's internals fails CI the same way production+code does. Such a test gets one of the moves below. When the product cannot+offer the move yet, a legacy-leak `[[interfaces]]` block that names the debt and+the exit demotes the product until the block is drained; the block is never a+facade module that hands the internals out under a sanctioned name. Core tests+reach into the product's test helpers, which no facade re-export naturally+covers:- _Monkeypatch targets_ — a core test base patches a product module attribute(e.g. `posthog/test/base.py` patches `execute_hogql_query` on each runner@@ -384,7 +392,7 @@ records the decrease. See `products/architecture.md` § Wiring couplings.preserved by a re-export shim in the original module; the shim's residualexposure (the frozen migration still imports the model module) must bedocumented honestly in the block comment, not papered over by the marker.- - Verify with `tach check --dependencies --interfaces`, `lint-imports`+ - Verify with `hogli lint:tach`, `lint-imports`(import-linter contract for presentation → facade), and `hogli product:lint <name>`.- Use `hogli product:maturity <name>` for a detailed breakdown of remainingisolation work scored across models, facade, presentation, boundaries, codegen.@@ -516,7 +524,7 @@ Treat migration as complete only when:- The product is listed in the shared `[[interfaces]]` block in `tach.toml`exposing `backend.facade.*` and `backend.presentation.views.*` — no legacyleak block remains.-- `tach check --dependencies --interfaces` passes with no violations for this product.+- `hogli lint:tach` passes with no violations for this product.- `lint-imports` passes **with no `ignore_imports` entries left for this product** in the`pyproject.toml` TODO section — entries are tracked architectural debt from deferredview modules; the presentation wave deletes them.diff --git a/.claude/rules/product-isolation.md b/.claude/rules/product-isolation.mdindex 031af8b39b58..e350570c50a7 100644--- a/.claude/rules/product-isolation.md+++ b/.claude/rules/product-isolation.md@@ -33,4 +33,6 @@ this product is isolated.If you need to extend what's reachable across a boundary, add a function to the relevantfacade module (or a re-export to its wiring submodule) — not a `depends_on` entry in`tach.toml`.-Run `tach check --dependencies --interfaces` to verify import boundaries are clean.+Run `hogli lint:tach` to verify import boundaries are clean. It runs the two tach passes CI runs:+dependencies without test code, interfaces with it, so a test may import any product's public+surface without a `depends_on` entry but never its internals.diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex ccae87d5db07..eda8ef07fbca 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -1065,7 +1065,15 @@ jobs:- name: Check operator parityrun: python .github/scripts/check-operator-parity.py- name: Check module boundaries (tach)- run: tach check --dependencies --interfaces+ # Two passes: tests are in the interface graph but not the dependency graph.+ # A branch that predates the command still excludes tests in tach.toml, so+ # the old single pass is the right check there.+ run: |+ if ./bin/hogli lint:tach --help >/dev/null 2>&1; then+ ./bin/hogli lint:tach+ else+ tach check --dependencies --interfaces+ fi- name: Check product facade enforcement (import-linter)run: lint-imports# These guards take the whole repo as input (import graph afterdiff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 029515215dcd..b147d21210c9 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -1273,7 +1273,15 @@ jobs:run: python .github/scripts/check-operator-parity.py- name: Check module boundaries (tach)- run: tach check --dependencies --interfaces+ # Two passes: tests are in the interface graph but not the dependency graph.+ # A branch that predates the command still excludes tests in tach.toml, so+ # the old single pass is the right check there.+ run: |+ if ./bin/hogli lint:tach --help >/dev/null 2>&1; then+ ./bin/hogli lint:tach+ else+ tach check --dependencies --interfaces+ fi- name: Check product facade enforcement (import-linter)run: lint-importsdiff --git a/hogli.yaml b/hogli.yamlindex 803cb42d54fa..312d57a21c06 100644--- a/hogli.yaml+++ b/hogli.yaml@@ -850,6 +850,9 @@ quality:lint:workflows:click: hogli_commands.workflow_lint.cli:cmd_lint_workflowsdescription: Lint .github/workflows/** for repo conventions+ lint:tach:+ click: hogli_commands.tach_lint:cmd_lint_tach+ description: Check module boundaries with tach (dependencies without test code, interfaces with it)lint:migration-deletions:click: hogli_commands.migration_deletions:cmd_lint_migration_deletionsdescription: Block deleting historical Django migration filesdiff --git a/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py b/posthog/temporal/tests/data_modeling/test_materialize_view_activities.pyindex 5e23803353c4..59c68be855c0 100644--- a/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py+++ b/posthog/temporal/tests/data_modeling/test_materialize_view_activities.py@@ -43,10 +43,8 @@ from posthog.temporal.data_modeling.activities.materialize_view import ()from posthog.temporal.data_modeling.activities.notify_materialization_failure import _SavedQueryViewers+from products.customer_analytics.backend.facade.temporal import stage_warehouse_account_property_files_activityfrom products.customer_analytics.backend.facade.temporal_contracts import StageAccountPropertySyncInput-from products.customer_analytics.backend.temporal.account_property_sync import (- stage_warehouse_account_property_files_activity,-)from products.data_modeling.backend.facade.api import compute_enrichment_hashfrom products.data_modeling.backend.facade.modeling import bounded_resolver_factory_for_viewfrom products.data_modeling.backend.facade.models import (@@ -65,11 +63,9 @@ from products.warehouse_sources.backend.facade.hooks import (saved_query_binding,)from products.warehouse_sources.backend.facade.models import DataWarehouseTable-from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.account_property_paths import (- job_staged_prefix as account_job_staged_prefix,-)-from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.person_property_paths import (- job_staged_prefix,+from products.warehouse_sources.backend.facade.temporal import (+ account_property_job_staged_prefix,+ person_property_job_staged_prefix,)pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]@@ -976,7 +972,7 @@ class TestNodeSuspension:async def test_does_not_resuspend_on_failures_from_before_a_resume(self, ateam, anode, asaved_query, adag):from posthog.temporal.data_modeling.activities.utils import is_node_suspended, maybe_suspend_node_for_engine- from products.data_modeling.backend.logic.node_suspension import resume_nodes+ from products.data_modeling.backend.facade.api import resume_nodesjobs = [await _make_job(ateam, asaved_query, DataModelingJob.Status.FAILED, error="boom") for _ in range(5)]first_job = await _make_job(ateam, asaved_query, DataModelingJob.Status.FAILED, error="boom")@@ -1787,7 +1783,7 @@ class TestMaterializeViewStagesPersonPropertyRows:with self._env(bucket_name, projection):result = await activity_environment.run(materialize_view_activity, inputs)# Resolved inside the overridden settings, so it names the same bucket the sink wrote to.- prefix = job_staged_prefix(ateam.pk, saved_query_binding(asaved_query.id), str(ajob.id))+ prefix = person_property_job_staged_prefix(ateam.pk, saved_query_binding(asaved_query.id), str(ajob.id))# The workflow gates the person-property child on this field.assert result.person_property_sync_enabled is True@@ -1867,7 +1863,7 @@ class TestMaterializeViewStagesAccountPropertyRows:),):result = await activity_environment.run(materialize_view_activity, inputs)- prefix = account_job_staged_prefix(+ prefix = account_property_job_staged_prefix(ateam.pk,saved_query_binding(asaved_query.id),str(ajob.id),diff --git a/posthog/temporal/tests/weekly_digest/test_queries.py b/posthog/temporal/tests/weekly_digest/test_queries.pyindex da820c18f70f..874f01ca534e 100644--- a/posthog/temporal/tests/weekly_digest/test_queries.py+++ b/posthog/temporal/tests/weekly_digest/test_queries.py@@ -1,24 +1,21 @@from datetime import UTC, datetime, timedelta+from uuid import UUIDimport pytest+from posthog.schema import ErrorTrackingIssueStatus+from posthog.temporal.weekly_digest.queries import query_new_error_issues-from products.error_tracking.backend.models import ErrorTrackingIssue+from products.error_tracking.backend.facade.testing import create_issuepytestmark = pytest.mark.django_dbdef _create_issue(- team,- name: str,- created_at: datetime,- status: ErrorTrackingIssue.Status = ErrorTrackingIssue.Status.ACTIVE,-) -> ErrorTrackingIssue:- issue = ErrorTrackingIssue.objects.create(team=team, name=name, status=status)- # created_at is auto_now_add, so it has to be set after creation- ErrorTrackingIssue.objects.filter(id=issue.id).update(created_at=created_at)- return issue+ team, name: str, created_at: datetime, status: ErrorTrackingIssueStatus = ErrorTrackingIssueStatus.ACTIVE+) -> UUID:+ return create_issue(team_id=team.id, name=name, status=status, created_at=created_at)def test_query_new_error_issues_window_boundaries_and_status(team):@@ -31,15 +28,15 @@ def test_query_new_error_issues_window_boundaries_and_status(team):_create_issue(team, "before window", period_start - timedelta(seconds=1))_create_issue(team, "after window", period_end + timedelta(seconds=1))for status in (- ErrorTrackingIssue.Status.ARCHIVED,- ErrorTrackingIssue.Status.RESOLVED,- ErrorTrackingIssue.Status.SUPPRESSED,- ErrorTrackingIssue.Status.PENDING_RELEASE,+ ErrorTrackingIssueStatus.ARCHIVED,+ ErrorTrackingIssueStatus.RESOLVED,+ ErrorTrackingIssueStatus.SUPPRESSED,+ ErrorTrackingIssueStatus.PENDING_RELEASE,):_create_issue(team, f"{status} in window", period_start + timedelta(days=1), status=status)results = list(query_new_error_issues(period_start, period_end))# Only active issues created within the window, newest first- assert [r["id"] for r in results] == [at_period_end.id, in_window.id]+ assert [r["id"] for r in results] == [at_period_end, in_window]assert all(r["team_id"] == team.id for r in results)diff --git a/products/canvas/backend/tests/test_canvas_api.py b/products/canvas/backend/tests/test_canvas_api.pyindex f68242bed247..28ff89bf1249 100644--- a/products/canvas/backend/tests/test_canvas_api.py+++ b/products/canvas/backend/tests/test_canvas_api.py@@ -25,7 +25,7 @@ from products.canvas.backend import activity_visibility, build_servicefrom products.canvas.backend.actions import CANVAS_ACTIONS, TaskCreatePayloadSerializerfrom products.canvas.backend.models import Canvas, CanvasBuild, CanvasSourceVersionfrom products.canvas.backend.source import synthetic_source_project-from products.tasks.backend.logic.services.compute_quota import ComputeQuotaDenialReason+from products.tasks.backend.facade.contracts import ComputeQuotaDenialReasonfrom products.tasks.backend.models import Channel, Task, TaskRun, TaskThreadMessagediff --git a/products/conversations/backend/api/tests/test_slack_message_routing.py b/products/conversations/backend/api/tests/test_slack_message_routing.pyindex 48564175b779..5ae0556733c6 100644--- a/products/conversations/backend/api/tests/test_slack_message_routing.py+++ b/products/conversations/backend/api/tests/test_slack_message_routing.py@@ -27,7 +27,7 @@ from products.conversations.backend.slack import ()from products.conversations.backend.tasks import process_supporthog_interactivityfrom products.customer_analytics.backend.facade import api as customer_analytics-from products.customer_analytics.backend.test.factories import create_account+from products.customer_analytics.backend.facade.testing import create_accountMODULE = "products.conversations.backend.slack"TASKS_MODULE = "products.conversations.backend.tasks"diff --git a/products/conversations/backend/temporal/tests/test_channel_summary.py b/products/conversations/backend/temporal/tests/test_channel_summary.pyindex 43ea43b87f25..4c11dd1fac82 100644--- a/products/conversations/backend/temporal/tests/test_channel_summary.py+++ b/products/conversations/backend/temporal/tests/test_channel_summary.py@@ -17,7 +17,7 @@ from products.conversations.backend.temporal.channel_summary.summarize import (_slack_permalink,)from products.customer_analytics.backend.facade import api as customer_analytics-from products.customer_analytics.backend.test.factories import create_account+from products.customer_analytics.backend.facade.testing import create_accountCOORD_MODULE = "products.conversations.backend.temporal.channel_summary.coordinator"diff --git a/products/conversations/backend/tests/test_gmail_sync.py b/products/conversations/backend/tests/test_gmail_sync.pyindex 875c08db6150..d0f5491bdc29 100644--- a/products/conversations/backend/tests/test_gmail_sync.py+++ b/products/conversations/backend/tests/test_gmail_sync.py@@ -20,7 +20,7 @@ from products.conversations.backend.models import ()from products.conversations.backend.services import gmail_syncfrom products.customer_analytics.backend.facade.email_matching import recalculate_email_thread_links-from products.customer_analytics.backend.models import Account+from products.customer_analytics.backend.facade.testing import create_accountdef _response(payload: dict, status_code: int = 200) -> MagicMock:@@ -86,7 +86,7 @@ class TestGmailSync(BaseTest):self.user.save(update_fields=["email"])self.integration.config["email"] = self.user.emailself.integration.save(update_fields=["config"])- account = Account.objects.for_team(self.team.id).create(team=self.team, name="Example", external_id="example")+ account = create_account(team_id=self.team.id, name="Example", external_id="example")account.properties = {"email_domains": ["example.com"]}account.save()diff --git a/products/customer_analytics/backend/facade/temporal.py b/products/customer_analytics/backend/facade/temporal.pyindex 51cec80f2771..08da88800f36 100644--- a/products/customer_analytics/backend/facade/temporal.py+++ b/products/customer_analytics/backend/facade/temporal.py@@ -6,6 +6,7 @@ from products.customer_analytics.backend.temporal import ACTIVITIES, WORKFLOWSfrom products.customer_analytics.backend.temporal.account_property_sync import (ACCOUNT_PROPERTY_SYNC_ACTIVITIES,ACCOUNT_PROPERTY_SYNC_WORKFLOWS,+ stage_warehouse_account_property_files_activity,)from products.customer_analytics.backend.temporal.account_track_rules import (create_account_track_rule_coordinator_schedule,@@ -20,4 +21,5 @@ __all__ = ["AccountPropertySyncInput","create_account_track_rule_coordinator_schedule","create_calendar_sync_coordinator_schedule",+ "stage_warehouse_account_property_files_activity",]diff --git a/products/customer_analytics/backend/facade/testing.py b/products/customer_analytics/backend/facade/testing.pynew file mode 100644index 000000000000..9afccc523e7f--- /dev/null+++ b/products/customer_analytics/backend/facade/testing.py@@ -0,0 +1,9 @@+"""Test-support facade for customer_analytics.++Sibling products' tests plant accounts through this module so they never import the+product's model or its test factories directly.+"""++from products.customer_analytics.backend.test.factories import create_account++__all__ = ["create_account"]diff --git a/products/data_modeling/backend/facade/api.py b/products/data_modeling/backend/facade/api.pyindex 394076b21bc6..5be42de0f60d 100644--- a/products/data_modeling/backend/facade/api.py+++ b/products/data_modeling/backend/facade/api.py@@ -41,6 +41,7 @@ _LAZY = {"tiered_schedules_enabled": "logic.schedule_reconcile","declared_targets_by_saved_query": "logic.node_frequency","get_declared_target": "logic.node_frequency",+ "set_declared_target": "logic.node_frequency","saved_query_target_bounds": "logic.node_frequency","clear_node_suspension": "logic.node_suspension","is_node_suspended": "logic.node_suspension",diff --git a/products/data_quality/backend/tests/test_runs_api.py b/products/data_quality/backend/tests/test_runs_api.pyindex fbb4a2fbee69..5acebb3dc927 100644--- a/products/data_quality/backend/tests/test_runs_api.py+++ b/products/data_quality/backend/tests/test_runs_api.py@@ -12,9 +12,7 @@ from posthog.constants import AvailableFeaturefrom posthog.test.db_context_capturing import capture_db_queriesfrom products.access_control.backend.models.access_control import AccessControl-from products.data_modeling.backend.facade.models import DataWarehouseSavedQuery-from products.data_modeling.backend.models.dag import DAG-from products.data_modeling.backend.models.node import Node+from products.data_modeling.backend.facade.models import DAG, DataWarehouseSavedQuery, Nodefrom products.data_quality.backend.facade import apifrom products.data_quality.backend.facade.enums import CheckRunStatus, CheckType, SubjectStatus, SubjectTypefrom products.data_quality.backend.models import DataQualityCheck, DataQualityCheckRun, DataQualitySuiteRundiff --git a/products/data_quality/backend/tests/test_triggers.py b/products/data_quality/backend/tests/test_triggers.pyindex 7e207d4da949..18b0cdd2fdb4 100644--- a/products/data_quality/backend/tests/test_triggers.py+++ b/products/data_quality/backend/tests/test_triggers.py@@ -5,8 +5,7 @@ from unittest.mock import patchfrom parameterized import parameterized-from products.data_modeling.backend.models import DAG, Node-from products.data_modeling.backend.models.datawarehouse_saved_query import DataWarehouseSavedQuery+from products.data_modeling.backend.facade.models import DAG, DataWarehouseSavedQuery, Nodefrom products.data_quality.backend.facade.contracts import QUALITY_AUDIT_GATE, QUALITY_AUDIT_SKIP, QUALITY_AUDIT_WARNfrom products.data_quality.backend.facade.enums import CheckSeverity, CheckType, SubjectTypefrom products.data_quality.backend.logic.triggers import (diff --git a/products/data_warehouse/backend/facade/api.py b/products/data_warehouse/backend/facade/api.pyindex fd08dc1d0998..a59fe3cbdb9b 100644--- a/products/data_warehouse/backend/facade/api.py+++ b/products/data_warehouse/backend/facade/api.py@@ -81,6 +81,7 @@ _LAZY = {"DIRECT_MOTHERDUCK_URL_PATTERN": "direct_motherduck","DIRECT_TRINO_URL_PATTERN": "direct_trino","DIRECT_POSTGRES_URL_PATTERN": "direct_postgres",+ "DIRECT_SNOWFLAKE_URL_PATTERN": "direct_snowflake","hide_direct_postgres_table": "direct_postgres","upsert_direct_postgres_table": "direct_postgres","hide_direct_snowflake_table": "direct_snowflake",diff --git a/products/data_warehouse/backend/facade/contracts.py b/products/data_warehouse/backend/facade/contracts.pyindex 6b04cc3299af..0ef2f086543b 100644--- a/products/data_warehouse/backend/facade/contracts.py+++ b/products/data_warehouse/backend/facade/contracts.py@@ -21,3 +21,13 @@ class TeamDataWarehouseConfig:team_id: intoverview_dashboard_ids: list[int]+++@dataclass(frozen=True)+class WebhookHogFunctionCreateResult:+ """Outcome of creating or updating the HogFunction that receives a source's webhook events."""++ hog_function_id: str | None = None+ webhook_url: str = ""+ error: str | None = None+ hog_function_created: bool = Falsediff --git a/products/data_warehouse/backend/facade/tasks.py b/products/data_warehouse/backend/facade/tasks.pyindex 75dd958e69bf..a845570f3076 100644--- a/products/data_warehouse/backend/facade/tasks.py+++ b/products/data_warehouse/backend/facade/tasks.py@@ -1,7 +1,8 @@"""Celery task wiring for data_warehouse.-Re-export of the beat-scheduled task that core registers (posthog/tasks/scheduled.py).+Re-exports the beat-scheduled task that core registers (posthog/tasks/scheduled.py) and the+managed-warehouse soft-delete and ensure tasks that managed_warehouse tests drive directly."""from products.data_warehouse.backend.tasks import (@@ -9,11 +10,19 @@ from products.data_warehouse.backend.tasks import (send_external_data_failure_digest_catchup,sync_team_earliest_event_date,)-from products.data_warehouse.backend.tasks.tasks import schedule_external_data_failure_digest+from products.data_warehouse.backend.tasks.tasks import (+ ensure_managed_warehouse_direct_source_v2_task,+ schedule_external_data_failure_digest,+ soft_delete_managed_warehouse_sources_task,+ soft_delete_managed_warehouse_sources_v2_task,+)__all__ = [+ "ensure_managed_warehouse_direct_source_v2_task","reconcile_all_managed_warehouse_tables_task","schedule_external_data_failure_digest","send_external_data_failure_digest_catchup",+ "soft_delete_managed_warehouse_sources_task",+ "soft_delete_managed_warehouse_sources_v2_task","sync_team_earliest_event_date",]diff --git a/products/data_warehouse/backend/logic/external_data_source/test/test_webhooks.py b/products/data_warehouse/backend/logic/external_data_source/test/test_webhooks.pyindex d99514c6ad97..36d8a1efa42b 100644--- a/products/data_warehouse/backend/logic/external_data_source/test/test_webhooks.py+++ b/products/data_warehouse/backend/logic/external_data_source/test/test_webhooks.py@@ -6,6 +6,8 @@ from unittest.mock import MagicMock, patchfrom posthog.models import Organization, Teamfrom products.cdp.backend.models.hog_function_template import HogFunctionTemplate+from products.cdp.backend.models.hog_functions.hog_function import HogFunction+from products.data_warehouse.backend.facade.contracts import WebhookHogFunctionCreateResultfrom products.data_warehouse.backend.logic.external_data_source.webhooks import (create_and_register_webhook,get_or_create_webhook_hog_function,@@ -92,6 +94,11 @@ def _make_webhook_source(return source+def _hog_function(result: WebhookHogFunctionCreateResult) -> HogFunction:+ assert result.hog_function_id is not None+ return HogFunction.objects.get(id=result.hog_function_id)++class TestGetOrCreateWebhookHogFunction:def test_returns_error_when_no_webhook_template(self):_, team = _create_org_and_team()@@ -100,7 +107,7 @@ class TestGetOrCreateWebhookHogFunction:result = get_or_create_webhook_hog_function(team, source, "source-123", [])- assert result.hog_function is None+ assert result.hog_function_id is Noneassert result.error == "No webhook template available for this source"def test_returns_error_when_template_not_in_db(self):@@ -109,7 +116,7 @@ class TestGetOrCreateWebhookHogFunction:result = get_or_create_webhook_hog_function(team, source, "source-123", [])- assert result.hog_function is None+ assert result.hog_function_id is Noneassert result.error is not Noneassert "template not found" in result.error.lower()@@ -124,13 +131,13 @@ class TestGetOrCreateWebhookHogFunction:assert result.hog_function_created is Trueassert result.error is None- assert result.hog_function is not None- assert result.hog_function.inputs is not None+ hog_function = _hog_function(result)+ assert hog_function.inputs is not None- mapping = result.hog_function.inputs["schema_mapping"]["value"]+ mapping = hog_function.inputs["schema_mapping"]["value"]assert mapping["customer"] == str(schemas[0].id)assert mapping["invoice"] == str(schemas[1].id)- assert result.hog_function.inputs["source_id"]["value"] == "source-123"+ assert hog_function.inputs["source_id"]["value"] == "source-123"def test_falls_back_to_schema_name_when_not_in_resource_map(self):_, team = _create_org_and_team()@@ -141,10 +148,10 @@ class TestGetOrCreateWebhookHogFunction:result = get_or_create_webhook_hog_function(team, source, "source-123", schemas)- assert result.hog_function is not None- assert result.hog_function.inputs is not None+ hog_function = _hog_function(result)+ assert hog_function.inputs is not None- mapping = result.hog_function.inputs["schema_mapping"]["value"]+ mapping = hog_function.inputs["schema_mapping"]["value"]assert "customer" in mappingassert "UnknownTable" in mappingassert len(mapping) == 2@@ -162,9 +169,9 @@ class TestGetOrCreateWebhookHogFunction:team, source, "source-123", schemas, extra_inputs={"signing_secret": "sec_123"})- assert result.hog_function is not None- assert result.hog_function.inputs is not None- assert result.hog_function.inputs["signing_secret"]["value"] == "sec_123"+ hog_function = _hog_function(result)+ assert hog_function.inputs is not None+ assert hog_function.inputs["signing_secret"]["value"] == "sec_123"def test_updates_existing_hog_function(self):_, team = _create_org_and_team()@@ -175,14 +182,12 @@ class TestGetOrCreateWebhookHogFunction:first_result = get_or_create_webhook_hog_function(team, source, "source-123", schemas)assert first_result.hog_function_created is True- assert first_result.hog_function is not None-- hog_id = first_result.hog_function.id+ hog_id = first_result.hog_function_id+ assert hog_id is not Nonesecond_result = get_or_create_webhook_hog_function(team, source, "source-123", schemas)assert second_result.hog_function_created is False- assert second_result.hog_function is not None- assert second_result.hog_function.id == hog_id+ assert second_result.hog_function_id == hog_iddef test_merges_schema_mapping_on_update(self):_, team = _create_org_and_team()@@ -196,11 +201,9 @@ class TestGetOrCreateWebhookHogFunction:invoices_schema = _create_schemas(team, ext_source, ["Invoices"])result = get_or_create_webhook_hog_function(team, source, "source-123", invoices_schema)- assert result.hog_function is not None- assert result.hog_function.inputs is not None-- result.hog_function.refresh_from_db()- mapping = result.hog_function.inputs["schema_mapping"]["value"]+ hog_function = _hog_function(result)+ assert hog_function.inputs is not None+ mapping = hog_function.inputs["schema_mapping"]["value"]assert "customer" in mappingassert "invoice" in mapping@@ -225,8 +228,8 @@ class TestGetOrCreateWebhookHogFunction:result = get_or_create_webhook_hog_function(team, source, "source-123", schemas)assert result.webhook_url.startswith(expected_host)- assert result.hog_function is not None- assert str(result.hog_function.id) in result.webhook_url+ assert result.hog_function_id is not None+ assert result.hog_function_id in result.webhook_urldef test_webhook_url_falls_back_to_site_url(self):_, team = _create_org_and_team()@@ -251,8 +254,7 @@ class TestGetOrCreateWebhookHogFunction:result = get_or_create_webhook_hog_function(team, source, "source-123", schemas)- hog = result.hog_function- assert hog is not None+ hog = _hog_function(result)assert hog.name == db_template.nameassert hog.hog == db_template.codeassert hog.template_id == db_template.template_id@@ -300,11 +302,9 @@ class TestCreateAndRegisterWebhook:result = create_and_register_webhook(webhook_source, config, hog_fn_result, team.id)assert result.success is True- assert hog_fn_result.hog_function is not None- assert hog_fn_result.hog_function.inputs is not None-- hog_fn_result.hog_function.refresh_from_db()- assert hog_fn_result.hog_function.inputs["webhook_secret"]["value"] == "whsec_123"+ hog_function = _hog_function(hog_fn_result)+ assert hog_function.inputs is not None+ assert hog_function.inputs["webhook_secret"]["value"] == "whsec_123"def test_failure_does_not_save_extra_inputs(self):_, team = _create_org_and_team()@@ -326,11 +326,9 @@ class TestCreateAndRegisterWebhook:assert result.success is Falseassert result.error == "API error"- assert hog_fn_result.hog_function is not None- assert hog_fn_result.hog_function.inputs is not None-- hog_fn_result.hog_function.refresh_from_db()- assert "webhook_secret" not in hog_fn_result.hog_function.inputs+ hog_function = _hog_function(hog_fn_result)+ assert hog_function.inputs is not None+ assert "webhook_secret" not in hog_function.inputsdef test_returns_webhook_url_from_hog_fn_result(self):_, team = _create_org_and_team()diff --git a/products/data_warehouse/backend/logic/external_data_source/webhooks.py b/products/data_warehouse/backend/logic/external_data_source/webhooks.pyindex 351a43c917dc..6396221c0563 100644--- a/products/data_warehouse/backend/logic/external_data_source/webhooks.py+++ b/products/data_warehouse/backend/logic/external_data_source/webhooks.py@@ -7,6 +7,7 @@ from posthog.models import Teamfrom products.cdp.backend.models.hog_function_template import HogFunctionTemplatefrom products.cdp.backend.models.hog_functions.hog_function import HogFunction+from products.data_warehouse.backend.facade.contracts import WebhookHogFunctionCreateResultfrom products.warehouse_sources.backend.facade.models import ExternalDataSchemafrom products.warehouse_sources.backend.facade.source_management import (Config,@@ -34,14 +35,6 @@ class WebhookSetupResult:pending_inputs: list[str] = dataclasses.field(default_factory=list)-class WebhookHogFunctionCreateResult:- hog_function: HogFunction | None = None- webhook_url: str = ""- error: str | None = None- hog_function_created: bool = False--def get_or_create_webhook_hog_function(team: Team,source: WebhookSource,@@ -130,7 +123,7 @@ def get_or_create_webhook_hog_function(webhook_url = get_webhook_url(hog_function.id)return WebhookHogFunctionCreateResult(- hog_function=hog_function, webhook_url=webhook_url, hog_function_created=created+ hog_function_id=str(hog_function.id), webhook_url=webhook_url, hog_function_created=created)@@ -142,14 +135,14 @@ def create_and_register_webhook(api_version: str | None = None,) -> WebhookSetupResult:"""Create the external webhook and save any extra inputs (e.g. signing secret) onto the HogFunction."""- assert hog_fn_result.hog_function is not None+ assert hog_fn_result.hog_function_id is not Noneresult: WebhookCreationResult = source.create_webhook(config, hog_fn_result.webhook_url, team_id, api_version=api_version)if result.success and result.extra_inputs:- hog_function = hog_fn_result.hog_function+ hog_function = HogFunction.objects.get(id=hog_fn_result.hog_function_id, team_id=team_id)assert hog_function.inputs is not Nonehog_function.inputs = {**hog_function.inputs,diff --git a/products/data_warehouse/backend/tests/api/test_saved_query.py b/products/data_warehouse/backend/tests/api/test_saved_query.pyindex c767f6789a14..097bfbfab5d2 100644--- a/products/data_warehouse/backend/tests/api/test_saved_query.py+++ b/products/data_warehouse/backend/tests/api/test_saved_query.py@@ -790,8 +790,8 @@ class TestSavedQuery(APIBaseTest):def test_update_sync_frequency_on_tiered_v2_writes_target_through(self, sync_frequency: str, expected_target: timedelta | None):- from products.data_modeling.backend.logic.node_frequency import get_declared_target, set_declared_target- from products.data_modeling.backend.models import Node+ from products.data_modeling.backend.facade.api import get_declared_target, set_declared_target+ from products.data_modeling.backend.facade.models import Nodesaved_query = self._create_saved_query_for_frequency_tests()node = Node.objects.get(saved_query_id=saved_query["id"])@@ -839,8 +839,8 @@ class TestSavedQuery(APIBaseTest):# a tiered team stores the cadence on the DAG node and keeps the interval column NULL, so a# frequency edit changes no model field — changes_between() returns nothing and log_activity# drops an "updated" entry with no changes, leaving the edit with no audit trail at all- from products.data_modeling.backend.logic.node_frequency import set_declared_target- from products.data_modeling.backend.models import Node+ from products.data_modeling.backend.facade.api import set_declared_target+ from products.data_modeling.backend.facade.models import Nodesaved_query = self._create_saved_query_for_frequency_tests()node = Node.objects.get(saved_query_id=saved_query["id"])@@ -869,7 +869,7 @@ class TestSavedQuery(APIBaseTest):self.assertEqual(frequency_changes[0]["after"], expected_after)def test_update_sync_frequency_on_tiered_v2_without_node_is_rejected(self):- from products.data_modeling.backend.models import Node+ from products.data_modeling.backend.facade.models import Nodesaved_query = self._create_saved_query_for_frequency_tests()Node.objects.filter(saved_query_id=saved_query["id"]).delete()@@ -895,7 +895,7 @@ class TestSavedQuery(APIBaseTest):self.assertIsNone(updated.sync_frequency_interval)def test_update_sync_frequency_on_tiered_v2_rolls_back_invalid_target(self):- from products.data_modeling.backend.logic.freshness import UnsatisfiableFrequencyError+ from products.data_modeling.backend.facade.api import UnsatisfiableFrequencyErrorsaved_query = self._create_saved_query_for_frequency_tests()reconcile_module = "products.data_modeling.backend.logic.schedule_reconcile"@@ -976,7 +976,7 @@ class TestSavedQuery(APIBaseTest):# Reconcile NULLs sync_frequency_interval on tiered teams and stores the cadence on the# node, so deriving the read from the column alone reports "never" for every tiered view.# The list and retrieve actions use different serializer classes: cover both.- from products.data_modeling.backend.logic.node_frequency import set_declared_target+ from products.data_modeling.backend.facade.api import set_declared_targetsaved_query = self._create_saved_query_for_frequency_tests()if node_target is not None:@@ -988,7 +988,7 @@ class TestSavedQuery(APIBaseTest):def test_sync_frequency_read_hits_the_node_table_once_per_page(self):# N+1 guard: view-list serializes a whole page, so a per-view target lookup would issue# one node query per view.- from products.data_modeling.backend.logic.node_frequency import set_declared_target+ from products.data_modeling.backend.facade.api import set_declared_targetfor name in ("view_a", "view_b", "view_c"):saved_query = self._create_saved_query_for_frequency_tests(name=name)@@ -1048,7 +1048,7 @@ class TestSavedQuery(APIBaseTest):query, where a source floor would need a warehouse table plus a schema to hang aninterval off. The bound arithmetic itself is covered in test_freshness."""- from products.data_modeling.backend.logic.node_frequency import set_declared_target+ from products.data_modeling.backend.facade.api import set_declared_targetupstream = self._create_saved_query_for_frequency_tests(name="upstream_view")consumer = self.client.post(diff --git a/products/data_warehouse/backend/tests/api/test_saved_query_access_control.py b/products/data_warehouse/backend/tests/api/test_saved_query_access_control.pyindex 8acd11f26e4a..5cbb319675da 100644--- a/products/data_warehouse/backend/tests/api/test_saved_query_access_control.py+++ b/products/data_warehouse/backend/tests/api/test_saved_query_access_control.py@@ -10,8 +10,8 @@ from posthog.models.organization import OrganizationMembershipfrom posthog.models.user import Userfrom products.access_control.backend.models.access_control import AccessControl+from products.data_modeling.backend.facade.api import set_declared_targetfrom products.data_modeling.backend.facade.models import DAG, DataWarehouseSavedQuery, Edge, Node, NodeType-from products.data_modeling.backend.logic.node_frequency import set_declared_targetfrom products.data_tools.backend.models.datawarehouse_saved_query_folder import DataWarehouseSavedQueryFolderfrom products.warehouse_sources.backend.facade.models import (DataWarehouseCredential,diff --git a/products/engineering_analytics/backend/tests/_github_fixtures.py b/products/engineering_analytics/backend/tests/_github_fixtures.pyindex 7ab6874ac317..fc8341006918 100644--- a/products/engineering_analytics/backend/tests/_github_fixtures.py+++ b/products/engineering_analytics/backend/tests/_github_fixtures.py@@ -22,8 +22,8 @@ from products.engineering_analytics.backend.logic.sources import (GitHubTables,)from products.warehouse_sources.backend.facade.models import DataWarehouseTable, ExternalDataSchema, ExternalDataSource+from products.warehouse_sources.backend.facade.testing import create_data_warehouse_table_from_csvfrom products.warehouse_sources.backend.facade.types import ExternalDataSourceType-from products.warehouse_sources.backend.test.utils import create_data_warehouse_table_from_csvTEST_BUCKET = "test_storage_bucket-posthog.products.engineering_analytics.github_fixtures"diff --git a/products/engineering_analytics/backend/tests/_logic_helpers.py b/products/engineering_analytics/backend/tests/_logic_helpers.pyindex 49ade9805608..22a82084aedd 100644--- a/products/engineering_analytics/backend/tests/_logic_helpers.py+++ b/products/engineering_analytics/backend/tests/_logic_helpers.py@@ -25,7 +25,7 @@ from products.engineering_analytics.backend.tests._github_fixtures import (seeding_object_storage,)from products.warehouse_sources.backend.facade.models import ExternalDataSource-from products.warehouse_sources.backend.test.utils import create_data_warehouse_table_from_csv+from products.warehouse_sources.backend.facade.testing import create_data_warehouse_table_from_csv# Every query module runs HogQL through this method; patch it to test row mapping without a# warehouse. Patching the unbound method means the mock is called without `self`, so a plaindiff --git a/products/engineering_analytics/backend/tests/test_ci_signals.py b/products/engineering_analytics/backend/tests/test_ci_signals.pyindex b4c3da390fcf..61bb2671e983 100644--- a/products/engineering_analytics/backend/tests/test_ci_signals.py+++ b/products/engineering_analytics/backend/tests/test_ci_signals.py@@ -71,12 +71,12 @@ from products.warehouse_sources.backend.facade.models import (ExternalDataSchema,ExternalDataSource,)+from products.warehouse_sources.backend.facade.testing import create_data_warehouse_table_from_csvfrom products.warehouse_sources.backend.facade.types import (ExternalDataSchemaStatus,ExternalDataSourceStatus,ExternalDataSourceType,)-from products.warehouse_sources.backend.test.utils import create_data_warehouse_table_from_csv_BY_DESIGN_JOB_NAMES = [entry.split("/", 2)[2] for entry in BY_DESIGN_FAILURES]diff --git a/products/engineering_analytics/backend/tests/test_ci_views.py b/products/engineering_analytics/backend/tests/test_ci_views.pyindex 8183afc9379d..471f8d59c54d 100644--- a/products/engineering_analytics/backend/tests/test_ci_views.py+++ b/products/engineering_analytics/backend/tests/test_ci_views.py@@ -25,8 +25,8 @@ from products.engineering_analytics.backend.tests._github_fixtures import (seeding_object_storage,)from products.warehouse_sources.backend.facade.models import DataWarehouseTable, ExternalDataSchema, ExternalDataSource+from products.warehouse_sources.backend.facade.testing import create_data_warehouse_table_from_csvfrom products.warehouse_sources.backend.facade.types import ExternalDataSourceType-from products.warehouse_sources.backend.test.utils import create_data_warehouse_table_from_csvTEST_BUCKET = "test_storage_bucket-posthog.products.engineering_analytics.ci_views"GITHUB_SOURCE_PREFIX = "myprefix"diff --git a/products/engineering_analytics/backend/tests/test_job_costs.py b/products/engineering_analytics/backend/tests/test_job_costs.pyindex 9f2c435f31eb..b5e00df348f8 100644--- a/products/engineering_analytics/backend/tests/test_job_costs.py+++ b/products/engineering_analytics/backend/tests/test_job_costs.py@@ -23,7 +23,7 @@ from products.engineering_analytics.backend.logic.views.source_schema import (WORKFLOW_RUNS_COLUMNS,)from products.engineering_analytics.backend.tests._github_fixtures import seeding_object_storage-from products.warehouse_sources.backend.test.utils import create_data_warehouse_table_from_csv+from products.warehouse_sources.backend.facade.testing import create_data_warehouse_table_from_csvTEST_BUCKET = "test_storage_bucket-posthog.products.engineering_analytics.job_costs"GITHUB_SOURCE_PREFIX = "myprefix"diff --git a/products/error_tracking/backend/facade/testing.py b/products/error_tracking/backend/facade/testing.pynew file mode 100644index 000000000000..255b56aac8bf--- /dev/null+++ b/products/error_tracking/backend/facade/testing.py@@ -0,0 +1,44 @@+"""Test-support facade for error_tracking.++Outside test suites (core's weekly digest, the metrics error overlay) plant issues and+spike events. They get them here instead of importing the models.+"""++from datetime import datetime+from uuid import UUID++from posthog.schema import ErrorTrackingIssueStatus++from products.error_tracking.backend.models import ErrorTrackingIssue, ErrorTrackingSpikeEvent+++def create_issue(+ *,+ team_id: int,+ name: str,+ status: ErrorTrackingIssueStatus = ErrorTrackingIssueStatus.ACTIVE,+ created_at: datetime | None = None,+) -> UUID:+ issue = ErrorTrackingIssue.objects.create(team_id=team_id, name=name, status=status)+ if created_at is not None:+ # created_at is auto_now_add, so it can only be set after the insert.+ ErrorTrackingIssue.objects.filter(id=issue.id).update(created_at=created_at)+ return issue.id+++def create_spike_event(+ *,+ team_id: int,+ issue_id: UUID,+ detected_at: datetime,+ computed_baseline: float = 1.0,+ current_bucket_value: int = 10,+) -> UUID:+ spike = ErrorTrackingSpikeEvent.objects.create(+ team_id=team_id,+ issue_id=issue_id,+ detected_at=detected_at,+ computed_baseline=computed_baseline,+ current_bucket_value=current_bucket_value,+ )+ return spike.iddiff --git a/products/exports/backend/tests/test_facade.py b/products/exports/backend/tests/test_facade.pyindex eef22dcc1dfa..4a6193b990dc 100644--- a/products/exports/backend/tests/test_facade.py+++ b/products/exports/backend/tests/test_facade.py@@ -15,7 +15,7 @@ from products.exports.backend.facade.api import (render_png_export,)from products.exports.backend.models.exported_asset import ExportedAsset-from products.product_analytics.backend.models.insight import Insight+from products.product_analytics.backend.facade.models import Insightclass TestValidateAdhocExportContext(SimpleTestCase):diff --git a/products/managed_warehouse/backend/tests/test_connection.py b/products/managed_warehouse/backend/tests/test_connection.pyindex 205ed53581cc..79731a06bc85 100644--- a/products/managed_warehouse/backend/tests/test_connection.py+++ b/products/managed_warehouse/backend/tests/test_connection.py@@ -15,11 +15,13 @@ from posthog.hogql.query import HogQLQueryExecutorfrom posthog.models import Organization, Team-from products.data_warehouse.backend.facade.api import DIRECT_POSTGRES_URL_PATTERN-from products.data_warehouse.backend.tasks.tasks import (- ensure_managed_warehouse_direct_source_v2_task,+from products.data_warehouse.backend.facade.api import (+ DIRECT_POSTGRES_URL_PATTERN,schedule_managed_warehouse_direct_source_ensure,schedule_soft_delete_managed_warehouse_sources,+)+from products.data_warehouse.backend.facade.tasks import (+ ensure_managed_warehouse_direct_source_v2_task,soft_delete_managed_warehouse_sources_task,soft_delete_managed_warehouse_sources_v2_task,)diff --git a/products/metrics/backend/tests/test_api.py b/products/metrics/backend/tests/test_api.pyindex 2f3c194cca68..646ca4f4d90f 100644--- a/products/metrics/backend/tests/test_api.py+++ b/products/metrics/backend/tests/test_api.py@@ -22,7 +22,7 @@ from products.access_control.backend.facade.user_access_control import (AccessControlLevelResource,)from products.access_control.backend.models.access_control import AccessControl-from products.error_tracking.backend.models import ErrorTrackingIssue, ErrorTrackingSpikeEvent+from products.error_tracking.backend.facade.testing import create_issue, create_spike_eventdef test_metrics_app_is_installed():@@ -50,15 +50,9 @@ class TestMetricsValuesApi(APIBaseTest):class TestMetricsErrorSpikesApi(APIBaseTest):def test_returns_spikes_from_error_tracking_in_the_window(self) -> None:- issue = ErrorTrackingIssue.objects.create(team=self.team, name="Boom")+ issue_id = create_issue(team_id=self.team.id, name="Boom")now = timezone.now()- ErrorTrackingSpikeEvent.objects.create(- team=self.team,- issue=issue,- detected_at=now,- computed_baseline=1.0,- current_bucket_value=10,- )+ create_spike_event(team_id=self.team.id, issue_id=issue_id, detected_at=now)# The overlay is a staff-only PoC behind its own flag, on top of the# `metrics` gate the conftest already enables — turn both on here.@@ -71,7 +65,7 @@ class TestMetricsErrorSpikesApi(APIBaseTest):assert response.status_code == status.HTTP_200_OKresults = response.json()["results"]assert len(results) == 1- assert results[0]["issue_id"] == str(issue.id)+ assert results[0]["issue_id"] == str(issue_id)assert results[0]["issue_name"] == "Boom"def test_is_forbidden_when_only_the_metrics_flag_is_enabled(self) -> None:diff --git a/products/notifications/backend/facade/testing.py b/products/notifications/backend/facade/testing.pynew file mode 100644index 000000000000..58843512c12f--- /dev/null+++ b/products/notifications/backend/facade/testing.py@@ -0,0 +1,25 @@+"""Test-support facade for notifications.++Products that notify through ``facade.api`` assert on the stored event in their tests. They+read it here instead of importing the model.+"""++from posthog.dataclasses import frozen++from products.notifications.backend.models import NotificationEvent+++@frozen+class StoredNotification:+ title: str+ source_url: str+ resolved_user_ids: list[int]+++def stored_notification_for_resource(*, resource_type: str, resource_id: str) -> StoredNotification:+ event = NotificationEvent.objects.get(resource_type=resource_type, resource_id=resource_id)+ return StoredNotification(+ title=event.title,+ source_url=event.source_url,+ resolved_user_ids=list(event.resolved_user_ids),+ )diff --git a/products/replay_vision/backend/tests/test_sweep.py b/products/replay_vision/backend/tests/test_sweep.pyindex 41b0ffbc723d..3a678be0485c 100644--- a/products/replay_vision/backend/tests/test_sweep.py+++ b/products/replay_vision/backend/tests/test_sweep.py@@ -1246,7 +1246,7 @@ def test_limit_notification_is_delivered_end_to_end() -> None:# whole delivery path regress invisibly.from posthog.models import User- from products.notifications.backend.models import NotificationEvent+ from products.notifications.backend.facade.testing import stored_notification_for_resourcelimit = 20 * _OBSERVATION_CREDITSscanner = _make_scanner(credit_limit=limit)@@ -1260,7 +1260,7 @@ def test_limit_notification_is_delivered_end_to_end() -> None:output = check_scanner_budget_activity(CheckScannerBudgetInputs(scanner_id=scanner.id, team_id=scanner.team_id))assert output.capped is True- event = NotificationEvent.objects.get(resource_type="replay_scanner", resource_id=str(scanner.id))+ event = stored_notification_for_resource(resource_type="replay_scanner", resource_id=str(scanner.id))assert member.id in event.resolved_user_idsassert event.source_url == f"/project/{scanner.team.project_id}/replay-vision/{scanner.id}"assert scanner.name in event.titlediff --git a/products/review_hog/backend/tests/test_settings_api.py b/products/review_hog/backend/tests/test_settings_api.pyindex e9f6452de29e..76a0e36bbdf8 100644--- a/products/review_hog/backend/tests/test_settings_api.py+++ b/products/review_hog/backend/tests/test_settings_api.py@@ -3,11 +3,10 @@ from posthog.test.base import APIBaseTestfrom parameterized import parameterizedfrom posthog.models import Team, User-from posthog.models.scoping import team_scopefrom products.review_hog.backend.models import ReviewUserSettingsfrom products.skills.backend.models.skills import LLMSkill-from products.stamphog.backend.models import StamphogRepoConfig+from products.stamphog.backend.facade.testing import seed_repo_configclass TestReviewUserSettingsAPI(APIBaseTest):@@ -66,14 +65,13 @@ class TestReviewUserSettingsAPI(APIBaseTest):def test_stamphog_connected_requires_a_synced_enabled_repo_config(self, _name, enabled, installation_id, connected_by_user_id, expected) -> None:- with team_scope(self.team.id):- StamphogRepoConfig.objects.create(- team_id=self.team.id,- repository="posthog/posthog",- enabled=enabled,- installation_id=installation_id,- connected_by_user_id=connected_by_user_id,- )+ seed_repo_config(+ team_id=self.team.id,+ repository="posthog/posthog",+ enabled=enabled,+ installation_id=installation_id,+ connected_by_user_id=connected_by_user_id,+ )res = self.client.get(self.url)diff --git a/products/signals/backend/test/test_backfill_task_run_artefacts.py b/products/signals/backend/test/test_backfill_task_run_artefacts.pyindex 30093dad603e..4ab39f35c629 100644--- a/products/signals/backend/test/test_backfill_task_run_artefacts.py+++ b/products/signals/backend/test/test_backfill_task_run_artefacts.py@@ -13,7 +13,7 @@ from products.signals.backend.task_run_artefacts import ()# Task ORM model needed to build cross-product fixtures; the tasks facade exposes DTOs only.-from products.tasks.backend.models import Task # tach-ignore+from products.tasks.backend.models import Taskclass TestBackfillTaskRunArtefacts(BaseTest):diff --git a/products/signals/backend/test/test_custom_agent_log_artefacts.py b/products/signals/backend/test/test_custom_agent_log_artefacts.pyindex 15614dd0879c..81d4bb270793 100644--- a/products/signals/backend/test/test_custom_agent_log_artefacts.py+++ b/products/signals/backend/test/test_custom_agent_log_artefacts.py@@ -25,7 +25,7 @@ from products.signals.backend.report_generation.research import (from products.signals.backend.report_generation.select_repo import RepoSelectionResult# Task ORM model needed to build cross-product fixtures; the tasks facade exposes DTOs only.-from products.tasks.backend.models import Task # tach-ignore+from products.tasks.backend.models import Taskclass _StubAgent(CustomSignalAgent):diff --git a/products/signals/backend/test/test_scout_chat_api.py b/products/signals/backend/test/test_scout_chat_api.pyindex ab4d900de0dc..b9c608a49328 100644--- a/products/signals/backend/test/test_scout_chat_api.py+++ b/products/signals/backend/test/test_scout_chat_api.py@@ -6,7 +6,7 @@ from rest_framework import statusfrom products.signals.backend.scout_chat import SCOUT_CHAT_TEMPLATESfrom products.tasks.backend.logic.services.code_usage_gate import CodeUsageStatus # tach-ignore-from products.tasks.backend.models import Task, TaskRun # tach-ignore+from products.tasks.backend.models import Task, TaskRunclass TestScoutChatTaskAPI(APIBaseTest):diff --git a/products/signals/backend/test/test_signal_report_artefact_api.py b/products/signals/backend/test/test_signal_report_artefact_api.pyindex 665fb6770ab9..7e153a76e646 100644--- a/products/signals/backend/test/test_signal_report_artefact_api.py+++ b/products/signals/backend/test/test_signal_report_artefact_api.py@@ -25,7 +25,7 @@ from products.signals.backend.artefact_schemas import (from products.signals.backend.models import ArtefactAttribution, SignalReport, SignalReportArtefact# Task ORM model needed to build cross-product fixtures; the tasks facade exposes DTOs only.-from products.tasks.backend.models import Channel, Task # tach-ignore+from products.tasks.backend.models import Channel, Taskdef _attach_github_login(user: User, login: str, *, uid: str | None = None) -> None:diff --git a/products/signals/backend/test/test_signal_report_artefact_model.py b/products/signals/backend/test/test_signal_report_artefact_model.pyindex 3c4b354f6074..ead27f6fb281 100644--- a/products/signals/backend/test/test_signal_report_artefact_model.py+++ b/products/signals/backend/test/test_signal_report_artefact_model.py@@ -17,7 +17,7 @@ from products.signals.backend.models import ArtefactAttribution, SignalReport, Sfrom products.signals.backend.temporal.agentic.report import _AGENTIC_ARTEFACT_TYPES# Task ORM model needed to build cross-product fixtures; the tasks facade exposes DTOs only.-from products.tasks.backend.models import Task # tach-ignore+from products.tasks.backend.models import Taskclass TestSignalReportArtefactHelpers(BaseTest):diff --git a/products/signals/backend/test/test_task_run_artefacts.py b/products/signals/backend/test/test_task_run_artefacts.pyindex 09f3e6ab2d38..ce2229c67d4e 100644--- a/products/signals/backend/test/test_task_run_artefacts.py+++ b/products/signals/backend/test/test_task_run_artefacts.py@@ -29,7 +29,7 @@ from products.signals.backend.task_run_artefacts import (from products.tasks.backend.facade.repo_selection_types import RepoSelectionResult# Task/TaskRun ORM models needed to build cross-product fixtures; the tasks facade exposes DTOs only.-from products.tasks.backend.models import Task, TaskRun # tach-ignore+from products.tasks.backend.models import Task, TaskRunclass TestTaskRunArtefacts(BaseTest):diff --git a/products/stamphog/backend/facade/testing.py b/products/stamphog/backend/facade/testing.pynew file mode 100644index 000000000000..b689eadeb81c--- /dev/null+++ b/products/stamphog/backend/facade/testing.py@@ -0,0 +1,25 @@+"""Test-support facade for stamphog.++Sibling products' tests need a repo config in a given sync state (installation bound,+connecting user set). ``facade.api.create_repo_config`` refuses that by design, because only+the verified sync flow may bind an installation, so tests seed the row here.+"""++from products.stamphog.backend.models import StamphogRepoConfig+++def seed_repo_config(+ *,+ team_id: int,+ repository: str,+ enabled: bool = True,+ installation_id: str = "",+ connected_by_user_id: int | None = None,+) -> None:+ StamphogRepoConfig.objects.for_team(team_id).create(+ team_id=team_id,+ repository=repository,+ enabled=enabled,+ installation_id=installation_id,+ connected_by_user_id=connected_by_user_id,+ )diff --git a/products/tasks/backend/facade/contracts.py b/products/tasks/backend/facade/contracts.pyindex d89813738829..0f7521c17ed4 100644--- a/products/tasks/backend/facade/contracts.py+++ b/products/tasks/backend/facade/contracts.py@@ -828,3 +828,10 @@ class TaskRunStateMetricsDTO:oldest_open_age_seconds: list[TaskRunGaugeRow] = Field(default_factory=list)created_recently: list[TaskRunGaugeRow] = Field(default_factory=list)terminal_recently: list[TaskRunGaugeRow] = Field(default_factory=list)+++class ComputeQuotaDenialReason(StrEnum):+ """Why a compute request was refused. The value is the denial code the API returns."""++ COMPUTE_QUOTA_EXHAUSTED = "posthog_code_billing_limit_exceeded"+ ORGANIZATION_DEACTIVATED = "organization_deactivated"diff --git a/products/tasks/backend/logic/services/compute_quota.py b/products/tasks/backend/logic/services/compute_quota.pyindex 8d9ecf962f3f..1626327fc313 100644--- a/products/tasks/backend/logic/services/compute_quota.py+++ b/products/tasks/backend/logic/services/compute_quota.py@@ -1,20 +1,15 @@import logging-from enum import StrEnumfrom django.conf import settingsfrom posthog.models import Team, User+from products.tasks.backend.facade.contracts import ComputeQuotaDenialReasonfrom products.tasks.backend.metrics import observe_compute_quota_checkfrom products.tasks.backend.models import Task, TaskClientProvenance-COMPUTE_QUOTA_DENIAL_CODE = "posthog_code_billing_limit_exceeded"-ORGANIZATION_DEACTIVATED_DENIAL_CODE = "organization_deactivated"---class ComputeQuotaDenialReason(StrEnum):- COMPUTE_QUOTA_EXHAUSTED = COMPUTE_QUOTA_DENIAL_CODE- ORGANIZATION_DEACTIVATED = ORGANIZATION_DEACTIVATED_DENIAL_CODE+COMPUTE_QUOTA_DENIAL_CODE = ComputeQuotaDenialReason.COMPUTE_QUOTA_EXHAUSTED.value+ORGANIZATION_DEACTIVATED_DENIAL_CODE = ComputeQuotaDenialReason.ORGANIZATION_DEACTIVATED.valuelogger = logging.getLogger(__name__)diff --git a/products/streamlit_apps/backend/tests/test_proxy.py b/products/tasks/backend/tests/test_streamlit_auth_proxy.pysimilarity index 100%rename from products/streamlit_apps/backend/tests/test_proxy.pyrename to products/tasks/backend/tests/test_streamlit_auth_proxy.pydiff --git a/products/tasks/package.json b/products/tasks/package.jsonindex 2db1e49456a6..707272ae35d3 100644--- a/products/tasks/package.json+++ b/products/tasks/package.json@@ -1,8 +1,7 @@{"name": "@posthog/products-tasks","scripts": {- "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests backend/logic backend/management backend/temporal -v --tb=short",- "backend:contract-check": "echo 'Contract files unchanged'"+ "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests backend/logic backend/management backend/temporal -v --tb=short"},"dependencies": {},"devDependencies": {diff --git a/products/warehouse_sources/backend/facade/temporal.py b/products/warehouse_sources/backend/facade/temporal.pyindex 002ad2a70613..080cdf538c85 100644--- a/products/warehouse_sources/backend/facade/temporal.py+++ b/products/warehouse_sources/backend/facade/temporal.py@@ -42,6 +42,9 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.accfrom products.warehouse_sources.backend.temporal.data_imports.pipelines.core.account_property_row_sink import (AccountPropertyRowSink,)+from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.person_property_paths import (+ job_staged_prefix as person_property_job_staged_prefix,+)from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.person_property_row_sink import (PersonPropertyRowSink,)@@ -68,6 +71,7 @@ __all__ = ["account_property_job_staged_prefix","account_property_snapshot_prefix","PersonPropertyRowSink",+ "person_property_job_staged_prefix","SavedQueryNotFoundError","SavedQueryNotOnV2ScheduleError","WarehouseBindingMissingError",diff --git a/products/warehouse_sources/backend/presentation/views/external_data_schema.py b/products/warehouse_sources/backend/presentation/views/external_data_schema.pyindex 4299c996ce42..eaeee2c77b26 100644--- a/products/warehouse_sources/backend/presentation/views/external_data_schema.py+++ b/products/warehouse_sources/backend/presentation/views/external_data_schema.py@@ -1277,7 +1277,7 @@ class ExternalDataSchemaSerializer(UserAccessControlSerializerMixin, serializersconfig=config,)- if hog_fn_result.error or not hog_fn_result.hog_function:+ if hog_fn_result.error or hog_fn_result.hog_function_id is None:raise ValidationError(f"Failed to set up webhook: {hog_fn_result.error or 'Unknown error'}. ""You can set up the webhook manually from the Webhook tab."diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source.py b/products/warehouse_sources/backend/presentation/views/external_data_source.pyindex 1c3d803c953e..ce26d01c4663 100644--- a/products/warehouse_sources/backend/presentation/views/external_data_source.py+++ b/products/warehouse_sources/backend/presentation/views/external_data_source.py@@ -3794,7 +3794,7 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixieligible_schemas=eligible_schemas,config=source_config,)- if hog_fn_result.error or hog_fn_result.hog_function is None:+ if hog_fn_result.error or hog_fn_result.hog_function_id is None:return failure(hog_fn_result.error)registration = create_and_register_webhook(@@ -3811,7 +3811,7 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixiif not registration.success:# The external registration failed (e.g. credentials can't create webhooks), so the# handler would never receive events — remove it and keep the polling defaults.- hog_function = hog_fn_result.hog_function+ hog_function = HogFunction.objects.get(id=hog_fn_result.hog_function_id, team_id=self.team_id)hog_function.deleted = Truehog_function.enabled = Falsehog_function.save(update_fields=["deleted", "enabled"])diff --git a/posthog/temporal/tests/external_data/test_external_data_job.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_external_data_job.pysimilarity index 98%rename from posthog/temporal/tests/external_data/test_external_data_job.pyrename to products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_external_data_job.pyindex d727e683be20..ebea652c3758 100644--- a/posthog/temporal/tests/external_data/test_external_data_job.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_external_data_job.py@@ -141,15 +141,6 @@ async def postgres_connection(postgres_config, setup_postgres_test_db):await connection.close()[email protected](autouse=True)-def _stub_sync_teardown_dispatch():- # transaction=True plus eager Celery makes a real auto-disable run the- # disable-teardown task inline, reaching for the queue DB and Temporal.- # Tests that assert the dispatch layer their own patch over this one.- with mock.patch("products.warehouse_sources.backend.tasks.cleanup_disabled_external_data_schema.delay"):- yield--def _create_schema(schema_name: str, source: ExternalDataSource, team: Team, table_id: Optional[str] = None):return ExternalDataSchema.objects.create(name=schema_name,@@ -246,10 +237,11 @@ def test_create_external_job_activity_schemas_exist(activity_environment, team,)@pytest.mark.django_db(transaction=True)def test_create_external_job_activity_emit_signals_respects_ai_consent(- activity_environment, team, organization, ai_consent, source_config_enabled, expected+ activity_environment, team, ai_consent, source_config_enabled, expected):from products.signals.backend.models import SignalSourceConfig+ organization = team.organizationorganization.is_ai_data_processing_approved = ai_consentorganization.save()if source_config_enabled is not None:@@ -286,8 +278,9 @@ def test_create_external_job_activity_emit_signals_respects_ai_consent()@pytest.mark.django_db(transaction=True)def test_create_external_job_activity_enrichment_enabled_gates_on_flag_and_consent(- activity_environment, team, organization, flag_enabled, ai_consent, expected+ activity_environment, team, flag_enabled, ai_consent, expected):+ organization = team.organizationorganization.is_ai_data_processing_approved = ai_consentorganization.save()new_source = ExternalDataSource.objects.create(diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py b/products/warehouse_sources/backend/tests/api/test_external_data_schema.pyindex 8a58250fb4ec..cae87fb7e434 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py@@ -27,10 +27,8 @@ from posthog.models.utils import generate_random_token_personalfrom posthog.temporal.common.schedule import describe_schedulefrom products.data_modeling.backend.facade.models import Edge, Node-from products.data_warehouse.backend.direct_postgres import DIRECT_POSTGRES_URL_PATTERN-from products.data_warehouse.backend.direct_snowflake import DIRECT_SNOWFLAKE_URL_PATTERN-from products.data_warehouse.backend.logic.external_data_source.webhooks import WebhookHogFunctionCreateResult-from products.data_warehouse.backend.tests.api.utils import create_external_data_source_ok+from products.data_warehouse.backend.facade.api import DIRECT_POSTGRES_URL_PATTERN, DIRECT_SNOWFLAKE_URL_PATTERN+from products.data_warehouse.backend.facade.contracts import WebhookHogFunctionCreateResultfrom products.warehouse_sources.backend.facade.models import (DataWarehouseTable,ExternalDataSchema,@@ -46,6 +44,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.bas)from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchemafrom products.warehouse_sources.backend.temporal.data_imports.sources.stripe.source import StripeSource+from products.warehouse_sources.backend.tests.api.utils import create_external_data_source_okpytestmark = [pytest.mark.django_db,@@ -1502,7 +1501,7 @@ class TestExternalDataSchema(APIBaseTest):)mock_hog_fn_result = WebhookHogFunctionCreateResult(- hog_function=mock.MagicMock(),+ hog_function_id=str(uuid.uuid4()),webhook_url="https://test.com/webhook",hog_function_created=False,)@@ -1758,11 +1757,8 @@ class TestExternalDataSchema(APIBaseTest):sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,)- mock_hog_function = mock.MagicMock()- mock_hog_function.id = uuid.uuid4()- mock_hog_function.inputs = {"schema_mapping": {"value": {}}, "source_id": {"value": "test-source-id"}}mock_hog_fn_result = WebhookHogFunctionCreateResult(- hog_function=mock_hog_function,+ hog_function_id=str(uuid.uuid4()),webhook_url="https://test.com/webhook",hog_function_created=True,)@@ -1806,12 +1802,9 @@ class TestExternalDataSchema(APIBaseTest):sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,)- mock_hog_function = mock.MagicMock()- mock_hog_function.id = uuid.uuid4()- mock_hog_function.inputs = {"schema_mapping": {"value": {}}, "source_id": {"value": "test-source-id"}}# hog_function_created=False → existing webhook, so the reconcile path (not create) runs.mock_hog_fn_result = WebhookHogFunctionCreateResult(- hog_function=mock_hog_function,+ hog_function_id=str(uuid.uuid4()),webhook_url="https://test.com/webhook",hog_function_created=False,)@@ -1859,11 +1852,8 @@ class TestExternalDataSchema(APIBaseTest):sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,)- mock_hog_function = mock.MagicMock()- mock_hog_function.id = uuid.uuid4()- mock_hog_function.inputs = {"schema_mapping": {"value": {}}, "source_id": {"value": "test-source-id"}}mock_hog_fn_result = WebhookHogFunctionCreateResult(- hog_function=mock_hog_function,+ hog_function_id=str(uuid.uuid4()),webhook_url="https://test.com/webhook",hog_function_created=False,)@@ -1912,11 +1902,8 @@ class TestExternalDataSchema(APIBaseTest):sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,)- mock_hog_function = mock.MagicMock()- mock_hog_function.id = uuid.uuid4()- mock_hog_function.inputs = {"schema_mapping": {"value": {}}, "source_id": {"value": "test-source-id"}}mock_hog_fn_result = WebhookHogFunctionCreateResult(- hog_function=mock_hog_function,+ hog_function_id=str(uuid.uuid4()),webhook_url="https://test.com/webhook",hog_function_created=False,)diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source.py b/products/warehouse_sources/backend/tests/api/test_external_data_source.pyindex 582ba0a33e83..200922cffe84 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_source.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source.py@@ -41,9 +41,8 @@ from posthog.models.integration import ERROR_TOKEN_REFRESH_FAILED, Integration,from posthog.models.project import Projectfrom products.data_tools.backend.models.join import DataWarehouseJoin-from products.data_warehouse.backend.direct_postgres import DIRECT_POSTGRES_URL_PATTERN-from products.data_warehouse.backend.direct_trino import DIRECT_TRINO_URL_PATTERN-from products.data_warehouse.backend.models.revenue_analytics_config import ExternalDataSourceRevenueAnalyticsConfig+from products.data_warehouse.backend.facade.api import DIRECT_POSTGRES_URL_PATTERN, DIRECT_TRINO_URL_PATTERN+from products.data_warehouse.backend.facade.models import ExternalDataSourceRevenueAnalyticsConfigfrom products.revenue_analytics.backend.joins import get_customer_revenue_view_namefrom products.warehouse_sources.backend.facade.models import (DataWarehouseCredential,@@ -1371,7 +1370,6 @@ class TestExternalDataSource(APIBaseTest):# Webhook reconcile runs as a deferred post-commit hook in the bulk path, AFTER the# atomic block. If it raised there it would 500 the request with the rows already# committed. Guard that a raising reconcile is swallowed and the response stays 200.- from products.data_warehouse.backend.logic.external_data_source.webhooks import WebhookHogFunctionCreateResultfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.base import WebhookCreationResultfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (SourceSchema as _SourceSchema,@@ -1386,11 +1384,10 @@ class TestExternalDataSource(APIBaseTest):sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,)- mock_hog_function = MagicMock()- mock_hog_function.id = uuid.uuid4()- mock_hog_function.inputs = {"schema_mapping": {"value": {}}, "source_id": {"value": "test-source-id"}}+ from products.data_warehouse.backend.facade.contracts import WebhookHogFunctionCreateResult+mock_hog_fn_result = WebhookHogFunctionCreateResult(- hog_function=mock_hog_function,+ hog_function_id=str(uuid.uuid4()),webhook_url="https://test.com/webhook",hog_function_created=False,)diff --git a/products/data_warehouse/backend/tests/api/utils.py b/products/warehouse_sources/backend/tests/api/utils.pysimilarity index 100%rename from products/data_warehouse/backend/tests/api/utils.pyrename to products/warehouse_sources/backend/tests/api/utils.pydiff --git a/tach.toml b/tach.tomlindex b177f216fb5e..7995153105a2 100644--- a/tach.toml+++ b/tach.toml@@ -5,10 +5,12 @@ exclude = ["**/*__pycache__","**/*egg-info","docs",- "tests",- # Eval trees are dev/CI-only tooling (same class as `tests`): the harness orchestrates- # many products by design, and product-owned suites under products/*/evals import the- # harness contracts, so neither fits the production dependency graph.+ # Test directories stay in the graph so that a test outside a product that imports the+ # product's internals is an interface violation. They are not dependency edges: `hogli+ # lint:tach` (what CI runs) excludes test code from the dependency pass only.+ # Eval trees are dev/CI-only tooling: the harness orchestrates many products by+ # design, and product-owned suites under products/*/evals import the harness+ # contracts, so neither fits the production dependency graph."products/posthog_ai/eval_harness","products/*/evals",]@@ -890,6 +892,8 @@ expose = [# canvas analog of the backend.tasks Celery registration above. Canvas is# not isolated yet, so this stays a legacy leak rather than a facade expose."backend\\.temporal\\.registry.*",+ # tasks' tests build canvases that point at a generation task.+ "backend\\.models\\.Canvas",]from = ["products.canvas",@@ -1298,6 +1302,18 @@ path = "products.field_notes"depends_on = ["posthog"]layer = "modules"+# Isolation debt: outside test suites build tasks rows and read its enums straight+# from the models. Drain by adding factories to facade/testing.py and migrating the+# suites, then delete this block. Consumers: canvas, slack_app, review_hog,+# replay_vision, posthog_ai, stamphog, conversations, signals, ee.+[[interfaces]]+expose = [+ "backend\\.models\\.(Channel|SandboxEnvironment|Task|TaskRun|TaskThreadMessage)",+]+from = [+ "products.tasks",+]+[[modules]]path = "products.stamphog"depends_on = ["posthog", "products.tasks"]diff --git a/tools/hogli-commands/hogli_commands/product/cli.py b/tools/hogli-commands/hogli_commands/product/cli.pyindex 12a4ad5763a1..055312a6db9c 100644--- a/tools/hogli-commands/hogli_commands/product/cli.py+++ b/tools/hogli-commands/hogli_commands/product/cli.py@@ -179,7 +179,7 @@ def cmd_isolate_move(name: str, views: tuple[str, ...], dry_run: bool) -> None:if dry_run:click.echo("\n(dry run — nothing changed)")else:- click.echo("\nNext: review `git status`, then run tach check + lint-imports + hogli product:lint")+ click.echo("\nNext: review `git status`, then run hogli lint:tach + lint-imports + hogli product:lint")@click.command(diff --git a/tools/hogli-commands/hogli_commands/tach_lint.py b/tools/hogli-commands/hogli_commands/tach_lint.pynew file mode 100644index 000000000000..0a8fc5384dd1--- /dev/null+++ b/tools/hogli-commands/hogli_commands/tach_lint.py@@ -0,0 +1,40 @@+"""Click entrypoint for ``lint:tach``.++tach reads one import graph for both of its checks, and the repo wants tests on only one+axis: a test must respect every product's interface, but a test importing a product's+public surface is not an architectural dependency of the product that owns the test. tach+cannot split that in ``tach.toml``, so this command runs the dependency pass with test+code excluded and the interface pass on the full graph. CI runs the same two passes.+"""++from __future__ import annotations++import sys+import subprocess++import click++# Every test spelling the repo uses. The interface pass sees all of them.+TEST_CODE_EXCLUDES = "tests,test,**/test_*.py,**/*_test.py"++PASSES: tuple[tuple[str, ...], ...] = (+ ("tach", "check", "--dependencies", "--exclude", TEST_CODE_EXCLUDES),+ ("tach", "check", "--interfaces"),+)+++def run_tach_passes() -> int:+ failed = False+ for command in PASSES:+ click.echo("$ " + " ".join(command))+ # A signal-killed pass returns a negative code; anything but zero is a failure.+ failed = subprocess.run(command).returncode != 0 or failed+ return 1 if failed else 0+++ name="lint:tach",+ help="Check module boundaries with tach: dependencies without test code, interfaces with it",+)+def cmd_lint_tach() -> None:+ sys.exit(run_tach_passes())