Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(endpoints): thin presentation onto facade, enable isolated CI (#67559)

Jovan Sakovic8eaa241b488c
diff --git a/products/endpoints/backend/constants.py b/products/endpoints/backend/constants.py
index b6ef219b9796..05fb23ed4305 100644
--- a/products/endpoints/backend/constants.py
+++ b/products/endpoints/backend/constants.py
@@ -23,3 +23,7 @@ VALID_DATA_FRESHNESS_SECONDS: frozenset[int] = frozenset(DATA_FRESHNESS_BUCKETS)
DEFAULT_DATA_FRESHNESS_SECONDS = 86400
ENDPOINT_NAME_REGEX = r"^[a-zA-Z][a-zA-Z0-9_-]{0,127}$"
+
+# Matches the `log_source` column written for endpoint execution logs in the `log_entries`
+# ClickHouse table. The Logs tab and the `endpoints_logs_retrieve` API both read by this value.
+ENDPOINTS_LOG_SOURCE = "endpoints"
diff --git a/products/endpoints/backend/facade/api.py b/products/endpoints/backend/facade/api.py
index f33c598261f8..48d227a73203 100644
--- a/products/endpoints/backend/facade/api.py
+++ b/products/endpoints/backend/facade/api.py
@@ -11,18 +11,63 @@ Responsibilities:
Do NOT:
- Implement business logic here
-- Import DRF, serializers, or HTTP concerns
- Return ORM instances or QuerySets
Wiring that core registers crosses the boundary through the dedicated
submodules instead: ``facade.tasks`` (celery beat), ``facade.temporal``
-(data-modeling workflow hooks), ``facade.models`` (model-class consumers).
+(data-modeling workflow hooks), ``facade.models`` (model-class consumers),
+``facade.enums`` (exported constants).
+
+The service surface the product's own presentation consumes (CRUD/execution/
+materialization services, request validation, OpenAPI generation) is resolved
+lazily via PEP 562 — those modules pull heavy dependencies (HogQL, query
+runners) that must stay off the ``django.setup()`` path.
"""
+import importlib
+from datetime import datetime
+from typing import TYPE_CHECKING
+
+from products.endpoints.backend import rate_limit
from products.endpoints.backend.models import Endpoint, EndpointVersion
from . import contracts
+if TYPE_CHECKING:
+ from products.endpoints.backend.logic.crud import EndpointCrudService
+ from products.endpoints.backend.logic.execution import EndpointExecutionService
+ from products.endpoints.backend.logic.materialization import (
+ EndpointMaterializationService,
+ build_materialization_info,
+ )
+ from products.endpoints.backend.logic.validation import (
+ validate_bucket_overrides,
+ validate_endpoint_request,
+ validate_update_request,
+ )
+ from products.endpoints.backend.openapi import generate_openapi_spec
+
+# symbol -> source module (relative to products.endpoints.backend)
+_LAZY = {
+ "EndpointCrudService": "logic.crud",
+ "EndpointExecutionService": "logic.execution",
+ "EndpointMaterializationService": "logic.materialization",
+ "build_materialization_info": "logic.materialization",
+ "validate_bucket_overrides": "logic.validation",
+ "validate_endpoint_request": "logic.validation",
+ "validate_update_request": "logic.validation",
+ "generate_openapi_spec": "openapi",
+}
+
+
+def __getattr__(name: str):
+ try:
+ module_path = _LAZY[name]
+ except KeyError:
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
+ module = importlib.import_module(f"products.endpoints.backend.{module_path}")
+ return getattr(module, name)
+
def _to_endpoint_info(endpoint: Endpoint) -> contracts.EndpointInfo:
return contracts.EndpointInfo(
@@ -72,3 +117,34 @@ def get_endpoint_version(team_id: int, name: str, version: int | None = None) ->
return _to_version_info(endpoint.get_version(version))
except EndpointVersion.DoesNotExist:
return None
+
+
+def get_last_execution_times(team_id: int, names: list[str]) -> list[tuple[str, datetime]]:
+ """Most recent execution time per endpoint, for the endpoints that have one."""
+ rows = Endpoint.objects.filter(team_id=team_id, name__in=names, last_executed_at__isnull=False).values_list(
+ "name", "last_executed_at"
+ )
+ # The isnull=False filter already excludes None, but mypy can't narrow through queryset filters.
+ return [(name, ts) for name, ts in rows if ts is not None]
+
+
+def is_materialization_ready(team_id: int, endpoint_name: str, version: int | None = None) -> bool:
+ """Whether the targeted version (current when ``version`` is None) is ready for materialized execution."""
+ return rate_limit.check_materialization_ready(team_id, endpoint_name, version)
+
+
+__all__ = [
+ "EndpointCrudService",
+ "EndpointExecutionService",
+ "EndpointMaterializationService",
+ "build_materialization_info",
+ "generate_openapi_spec",
+ "get_endpoint",
+ "get_endpoint_version",
+ "get_last_execution_times",
+ "is_materialization_ready",
+ "list_endpoints",
+ "validate_bucket_overrides",
+ "validate_endpoint_request",
+ "validate_update_request",
+]
diff --git a/products/endpoints/backend/facade/enums.py b/products/endpoints/backend/facade/enums.py
new file mode 100644
index 000000000000..e7150be01b74
--- /dev/null
+++ b/products/endpoints/backend/facade/enums.py
@@ -0,0 +1,10 @@
+"""
+Exported constants for endpoints.
+
+Contract-file tier alongside ``contracts.py``: pure values the product's own
+presentation and external consumers may import without touching internals.
+"""
+
+from products.endpoints.backend.constants import ENDPOINT_NAME_REGEX, ENDPOINTS_LOG_SOURCE
+
+__all__ = ["ENDPOINT_NAME_REGEX", "ENDPOINTS_LOG_SOURCE"]
diff --git a/products/endpoints/backend/logs.py b/products/endpoints/backend/logs.py
index 178ea7515beb..7f431799fe65 100644
--- a/products/endpoints/backend/logs.py
+++ b/products/endpoints/backend/logs.py
@@ -6,11 +6,10 @@ import structlog
from posthog.kafka_client.routing import get_producer
from posthog.kafka_client.topics import KAFKA_LOG_ENTRIES
+from products.endpoints.backend.constants import ENDPOINTS_LOG_SOURCE
+
logger = structlog.get_logger(__name__)
-# Matches the `log_source` column written for endpoint execution logs in the `log_entries`
-# ClickHouse table. The Logs tab and the `endpoints_logs_retrieve` API both read by this value.
-ENDPOINTS_LOG_SOURCE = "endpoints"
# ClickHouse DateTime64(6, 'UTC') input format — same as the temporal logger uses.
_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S.%f"
diff --git a/products/endpoints/backend/metrics.py b/products/endpoints/backend/metrics.py
index 428d09b28032..47a2bb0dafcf 100644
--- a/products/endpoints/backend/metrics.py
+++ b/products/endpoints/backend/metrics.py
@@ -30,12 +30,6 @@ ENDPOINT_MATERIALIZATION_EVENT_TOTAL = Counter(
labelnames=["action", "status"],
)
-ENDPOINT_RATE_LIMITED_TOTAL = Counter(
- "posthog_endpoint_rate_limited_total",
- "Rate-limited endpoint requests",
- labelnames=["scope"],
-)
-
ENDPOINT_CONCURRENCY_REJECTED_TOTAL = Counter(
"posthog_endpoint_concurrency_rejected_total",
"Endpoint executions rejected because the concurrency limit was exceeded",
diff --git a/products/endpoints/backend/presentation/throttles.py b/products/endpoints/backend/presentation/throttles.py
new file mode 100644
index 000000000000..ec22f9fd03ec
--- /dev/null
+++ b/products/endpoints/backend/presentation/throttles.py
@@ -0,0 +1,123 @@
+"""DRF throttles for the endpoints run API.
+
+Materialized endpoints get a higher rate budget than inline ones. Readiness is
+resolved through the facade (cached, with a DB fallback); the throttle classes
+and their request-parsing helpers are pure HTTP concerns and live here.
+"""
+
+from prometheus_client import Counter
+from rest_framework.throttling import SimpleRateThrottle
+
+from posthog.rate_limit import (
+ APIQueriesBurstThrottle,
+ APIQueriesSustainedThrottle,
+ PersonalOrProjectSecretApiKeyRateThrottle,
+ ProjectSecretApiKeyTeamRateThrottle,
+)
+
+from products.endpoints.backend.facade.api import is_materialization_ready
+
+ENDPOINT_RATE_LIMITED_TOTAL = Counter(
+ "posthog_endpoint_rate_limited_total",
+ "Rate-limited endpoint requests",
+ labelnames=["scope"],
+)
+
+
+def _parse_requested_version(request) -> int | None:
+ """Best-effort parse of the targeted version from the request (body first, then query params).
+
+ Mirrors EndpointViewSet._parse_version_param; invalid or absent values fall back to None
+ (current version) — the view validates and rejects properly later.
+ """
+ try:
+ body_version = request.data.get("version") if hasattr(request, "data") else None
+ raw_version = body_version if body_version is not None else request.query_params.get("version")
+ return int(raw_version) if raw_version is not None else None
+ except Exception:
+ return None
+
+
+def _get_endpoint_info_from_request(request, view) -> tuple[int | None, str | None, int | None]:
+ """Extract team_id, endpoint_name, and requested version from request/view context."""
+ team_id = getattr(view, "team_id", None)
+ endpoint_name = view.kwargs.get("name") if hasattr(view, "kwargs") else None
+ return team_id, endpoint_name, _parse_requested_version(request)
+
+
+def _is_materialized_endpoint_request(request, view) -> bool:
+ """Check if this request targets a materialized endpoint version (cached check with lazy loading)."""
+ team_id, endpoint_name, version = _get_endpoint_info_from_request(request, view)
+ if not team_id or not endpoint_name:
+ return False
+ return is_materialization_ready(team_id, endpoint_name, version)
+
+
+class _MaterializedRateMixin(SimpleRateThrottle):
+ """Swaps in the higher materialized-endpoint rate and records 429s, on top of any base throttle.
+
+ Mix in before a SimpleRateThrottle subclass — `allow_request` adjusts the rate/scope for
+ materialized endpoints, then defers to the base throttle's own gating (which sits between
+ this mixin and SimpleRateThrottle in the MRO).
+ """
+
+ materialized_rate: str
+ materialized_scope: str
+
+ def allow_request(self, request, view):
+ if _is_materialized_endpoint_request(request, view):
+ self.rate = self.materialized_rate
+ self.scope = self.materialized_scope
+ self.num_requests, self.duration = self.parse_rate(self.rate)
+
+ allowed = super().allow_request(request, view)
+ if not allowed:
+ try:
+ ENDPOINT_RATE_LIMITED_TOTAL.labels(scope=self.scope).inc()
+ except Exception:
+ pass
+ return allowed
+
+
+class EndpointBurstThrottle(_MaterializedRateMixin, PersonalOrProjectSecretApiKeyRateThrottle, APIQueriesBurstThrottle):
+ """
+ Adaptive burst throttle for endpoints, keyed per credential (personal API key or PSAK).
+ Uses higher rate limit for materialized endpoints.
+ Non-materialized endpoints share the api_queries_burst bucket.
+ """
+
+ materialized_rate = "1200/minute"
+ materialized_scope = "materialized_endpoint_burst"
+
+
+class EndpointSustainedThrottle(
+ _MaterializedRateMixin, PersonalOrProjectSecretApiKeyRateThrottle, APIQueriesSustainedThrottle
+):
+ """
+ Adaptive sustained throttle for endpoints, keyed per credential (personal API key or PSAK).
+ Uses higher rate limit for materialized endpoints.
+ Non-materialized endpoints share the api_queries_sustained bucket.
+ """
+
+ materialized_rate = "12000/hour"
+ materialized_scope = "materialized_endpoint_sustained"
+
+
+class EndpointProjectSecretApiKeyTeamBurstThrottle(_MaterializedRateMixin, ProjectSecretApiKeyTeamRateThrottle):
+ """Per-team aggregate burst budget across all of a project's PSAKs — same size as the per-key
+ budget, so minting extra keys never multiplies a project's total burst capacity."""
+
+ # Own scope (not api_queries_burst) so 429 metrics and cache keys name the bucket that tripped.
+ scope = "endpoint_psak_team_burst"
+ rate = APIQueriesBurstThrottle.rate
+ materialized_rate = EndpointBurstThrottle.materialized_rate
+ materialized_scope = "materialized_endpoint_psak_team_burst"
+
+
+class EndpointProjectSecretApiKeyTeamSustainedThrottle(_MaterializedRateMixin, ProjectSecretApiKeyTeamRateThrottle):
+ """Per-team aggregate sustained budget across all of a project's PSAKs."""
+
+ scope = "endpoint_psak_team_sustained"
+ rate = APIQueriesSustainedThrottle.rate
+ materialized_rate = EndpointSustainedThrottle.materialized_rate
+ materialized_scope = "materialized_endpoint_psak_team_sustained"
diff --git a/products/endpoints/backend/presentation/views/api.py b/products/endpoints/backend/presentation/views/api.py
index b01e196ec6a7..7d742adb4abd 100644
--- a/products/endpoints/backend/presentation/views/api.py
+++ b/products/endpoints/backend/presentation/views/api.py
@@ -53,18 +53,19 @@ from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin
from posthog.rbac.user_access_control import access_level_satisfied_for_resource
from posthog.schema_migrations.upgrade import upgrade
-from products.endpoints.backend.constants import ENDPOINT_NAME_REGEX
-from products.endpoints.backend.logic.crud import EndpointCrudService
-from products.endpoints.backend.logic.execution import EndpointExecutionService
-from products.endpoints.backend.logic.materialization import EndpointMaterializationService, build_materialization_info
-from products.endpoints.backend.logic.validation import (
+from products.endpoints.backend.facade.api import (
+ EndpointCrudService,
+ EndpointExecutionService,
+ EndpointMaterializationService,
+ build_materialization_info,
+ generate_openapi_spec,
+ get_last_execution_times,
validate_bucket_overrides,
validate_endpoint_request,
validate_update_request,
)
-from products.endpoints.backend.logs import ENDPOINTS_LOG_SOURCE
-from products.endpoints.backend.models import Endpoint, EndpointVersion
-from products.endpoints.backend.openapi import generate_openapi_spec
+from products.endpoints.backend.facade.enums import ENDPOINT_NAME_REGEX, ENDPOINTS_LOG_SOURCE
+from products.endpoints.backend.facade.models import Endpoint, EndpointVersion
from products.endpoints.backend.presentation.serializers import (
EndpointMaterializationSerializer,
EndpointRequestSerializer,
@@ -72,7 +73,7 @@ from products.endpoints.backend.presentation.serializers import (
EndpointRunResponseSerializer,
EndpointVersionResponseSerializer,
)
-from products.endpoints.backend.rate_limit import (
+from products.endpoints.backend.presentation.throttles import (
EndpointBurstThrottle,
EndpointProjectSecretApiKeyTeamBurstThrottle,
EndpointProjectSecretApiKeyTeamSustainedThrottle,
@@ -525,12 +526,7 @@ class EndpointViewSet(
if not isinstance(name, str) or not re.fullmatch(ENDPOINT_NAME_REGEX, name):
raise ValidationError({"names": f"Invalid endpoint name: {name}"})
- endpoint_rows = list(
- Endpoint.objects.filter(team=self.team, name__in=names, last_executed_at__isnull=False).values_list(
- "name", "last_executed_at"
- )
- )
- results = [[name, ts.isoformat()] for name, ts in endpoint_rows if ts is not None]
+ results = [[name, ts.isoformat()] for name, ts in get_last_execution_times(self.team.pk, names)]
query_status = QueryStatus(id="", team_id=self.team.pk, complete=True, results=results)
diff --git a/products/endpoints/backend/rate_limit.py b/products/endpoints/backend/rate_limit.py
index 121fda1d4153..c1ce99be5b45 100644
--- a/products/endpoints/backend/rate_limit.py
+++ b/products/endpoints/backend/rate_limit.py
@@ -1,17 +1,14 @@
-from collections.abc import Iterable
-
-from django.core.cache import cache
+"""Materialization-readiness cache for endpoint versions.
-from rest_framework.throttling import SimpleRateThrottle
+Read by the presentation throttles (materialized endpoints get a higher rate
+budget) and written by the data-modeling Temporal workflow on materialization
+completion/failure. The DRF throttle classes themselves live in
+``presentation/throttles.py``.
+"""
-from posthog.rate_limit import (
- APIQueriesBurstThrottle,
- APIQueriesSustainedThrottle,
- PersonalOrProjectSecretApiKeyRateThrottle,
- ProjectSecretApiKeyTeamRateThrottle,
-)
+from collections.abc import Iterable
-from products.endpoints.backend.metrics import ENDPOINT_RATE_LIMITED_TOTAL
+from django.core.cache import cache
# Keyed per version so the throttle budget matches the version actually being executed:
# an explicit `?version=N` request is classified by that version's readiness, everything
@@ -92,27 +89,6 @@ def update_materialization_ready_for_saved_query(team_id: int, saved_query, is_r
set_endpoint_materialization_ready(team_id, endpoint_name, is_ready)
-def _parse_requested_version(request) -> int | None:
- """Best-effort parse of the targeted version from the request (body first, then query params).
-
- Mirrors EndpointViewSet._parse_version_param; invalid or absent values fall back to None
- (current version) — the view validates and rejects properly later.
- """
- try:
- body_version = request.data.get("version") if hasattr(request, "data") else None
- raw_version = body_version if body_version is not None else request.query_params.get("version")
- return int(raw_version) if raw_version is not None else None
- except Exception:
- return None
-
-
-def _get_endpoint_info_from_request(request, view) -> tuple[int | None, str | None, int | None]:
- """Extract team_id, endpoint_name, and requested version from request/view context."""
- team_id = getattr(view, "team_id", None)
- endpoint_name = view.kwargs.get("name") if hasattr(view, "kwargs") else None
- return team_id, endpoint_name, _parse_requested_version(request)
-
-
def _check_and_cache_materialization_status(team_id: int, endpoint_name: str, version: int | None = None) -> bool:
"""
Check materialization status from DB and populate cache.
@@ -141,85 +117,9 @@ def _check_and_cache_materialization_status(team_id: int, endpoint_name: str, ve
return False
-def _is_materialized_endpoint_request(request, view) -> bool:
- """Check if this request targets a materialized endpoint version (cached check with lazy loading)."""
- team_id, endpoint_name, version = _get_endpoint_info_from_request(request, view)
- if not team_id or not endpoint_name:
- return False
-
+def check_materialization_ready(team_id: int, endpoint_name: str, version: int | None = None) -> bool:
+ """Cached readiness check with a DB fallback on cache miss."""
cached_status = is_endpoint_materialization_ready(team_id, endpoint_name, version)
-
if cached_status is None:
return _check_and_cache_materialization_status(team_id, endpoint_name, version)
-
return cached_status
-
-
-class _MaterializedRateMixin(SimpleRateThrottle):
- """Swaps in the higher materialized-endpoint rate and records 429s, on top of any base throttle.
-
- Mix in before a SimpleRateThrottle subclass — `allow_request` adjusts the rate/scope for
- materialized endpoints, then defers to the base throttle's own gating (which sits between
- this mixin and SimpleRateThrottle in the MRO).
- """
-
- materialized_rate: str
- materialized_scope: str
-
- def allow_request(self, request, view):
- if _is_materialized_endpoint_request(request, view):
- self.rate = self.materialized_rate
- self.scope = self.materialized_scope
- self.num_requests, self.duration = self.parse_rate(self.rate)
-
- allowed = super().allow_request(request, view)
- if not allowed:
- try:
- ENDPOINT_RATE_LIMITED_TOTAL.labels(scope=self.scope).inc()
- except Exception:
- pass
- return allowed
-
-
-class EndpointBurstThrottle(_MaterializedRateMixin, PersonalOrProjectSecretApiKeyRateThrottle, APIQueriesBurstThrottle):
- """
- Adaptive burst throttle for endpoints, keyed per credential (personal API key or PSAK).
- Uses higher rate limit for materialized endpoints.
- Non-materialized endpoints share the api_queries_burst bucket.
- """
-
- materialized_rate = "1200/minute"
- materialized_scope = "materialized_endpoint_burst"
-
-
-class EndpointSustainedThrottle(
- _MaterializedRateMixin, PersonalOrProjectSecretApiKeyRateThrottle, APIQueriesSustainedThrottle
-):
- """
- Adaptive sustained throttle for endpoints, keyed per credential (personal API key or PSAK).
- Uses higher rate limit for materialized endpoints.
- Non-materialized endpoints share the api_queries_sustained bucket.
- """
-
- materialized_rate = "12000/hour"
- materialized_scope = "materialized_endpoint_sustained"
-
-
-class EndpointProjectSecretApiKeyTeamBurstThrottle(_MaterializedRateMixin, ProjectSecretApiKeyTeamRateThrottle):
- """Per-team aggregate burst budget across all of a project's PSAKs — same size as the per-key
- budget, so minting extra keys never multiplies a project's total burst capacity."""
-
- # Own scope (not api_queries_burst) so 429 metrics and cache keys name the bucket that tripped.
- scope = "endpoint_psak_team_burst"
- rate = APIQueriesBurstThrottle.rate
- materialized_rate = EndpointBurstThrottle.materialized_rate
- materialized_scope = "materialized_endpoint_psak_team_burst"
-
-
-class EndpointProjectSecretApiKeyTeamSustainedThrottle(_MaterializedRateMixin, ProjectSecretApiKeyTeamRateThrottle):
- """Per-team aggregate sustained budget across all of a project's PSAKs."""
-
- scope = "endpoint_psak_team_sustained"
- rate = APIQueriesSustainedThrottle.rate
- materialized_rate = EndpointSustainedThrottle.materialized_rate
- materialized_scope = "materialized_endpoint_psak_team_sustained"
diff --git a/products/endpoints/backend/tests/test_endpoint_psak_auth.py b/products/endpoints/backend/tests/test_endpoint_psak_auth.py
index 7d7d27810059..39690e486fe0 100644
--- a/products/endpoints/backend/tests/test_endpoint_psak_auth.py
+++ b/products/endpoints/backend/tests/test_endpoint_psak_auth.py
@@ -312,7 +312,7 @@ class TestEndpointViewSetPSAKAuth(ClickhouseTestMixin, APIBaseTest):
@patch("posthog.rate_limit.is_rate_limit_enabled", return_value=True)
-@patch("products.endpoints.backend.rate_limit.EndpointBurstThrottle.rate", new="2/minute")
+@patch("products.endpoints.backend.presentation.throttles.EndpointBurstThrottle.rate", new="2/minute")
class TestEndpointPSAKRateLimit(ClickhouseTestMixin, APIBaseTest):
def setUp(self):
super().setUp()
@@ -352,7 +352,10 @@ class TestEndpointPSAKRateLimit(ClickhouseTestMixin, APIBaseTest):
self.assertEqual(self._run(token_a).status_code, status.HTTP_429_TOO_MANY_REQUESTS)
self.assertEqual(self._run(token_b).status_code, status.HTTP_200_OK)
- @patch("products.endpoints.backend.rate_limit.EndpointProjectSecretApiKeyTeamBurstThrottle.rate", new="3/minute")
+ @patch(
+ "products.endpoints.backend.presentation.throttles.EndpointProjectSecretApiKeyTeamBurstThrottle.rate",
+ new="3/minute",
+ )
def test_distinct_psak_keys_share_project_bucket(self, *_args):
token_a, _a = _make_psak(self.team, label="team-key-a")
token_b, _b = _make_psak(self.team, label="team-key-b")
diff --git a/products/endpoints/backend/tests/test_rate_limit.py b/products/endpoints/backend/tests/test_rate_limit.py
index 84d248d1dde5..e5c5187f507d 100644
--- a/products/endpoints/backend/tests/test_rate_limit.py
+++ b/products/endpoints/backend/tests/test_rate_limit.py
@@ -8,11 +8,13 @@ from parameterized import parameterized
from products.data_modeling.backend.facade.models import DataWarehouseSavedQuery
from products.endpoints.backend.models import Endpoint
-from products.endpoints.backend.rate_limit import (
+from products.endpoints.backend.presentation.throttles import (
EndpointBurstThrottle,
EndpointSustainedThrottle,
- _check_and_cache_materialization_status,
_is_materialized_endpoint_request,
+)
+from products.endpoints.backend.rate_limit import (
+ _check_and_cache_materialization_status,
clear_endpoint_materialization_cache,
is_endpoint_materialization_ready,
set_endpoint_materialization_ready,
diff --git a/products/endpoints/package.json b/products/endpoints/package.json
index facc7fac6dff..6ab21a6125b4 100644
--- a/products/endpoints/package.json
+++ b/products/endpoints/package.json
@@ -1,7 +1,8 @@
{
"name": "@posthog/products-endpoints",
"scripts": {
- "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests -v --tb=short"
+ "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests -v --tb=short",
+ "backend:contract-check": "echo 'Contract files unchanged'"
},
"dependencies": {
"kea": "catalog:",
diff --git a/products/endpoints/turbo.json b/products/endpoints/turbo.json
new file mode 100644
index 000000000000..e16d4eabe6e9
--- /dev/null
+++ b/products/endpoints/turbo.json
@@ -0,0 +1,10 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "backend:contract-check": {
+ "inputs": ["backend/facade/**", "backend/presentation/**", "backend/routes.py"],
+ "outputs": [],
+ "cache": true
+ }
+ }
+}
diff --git a/pyproject.toml b/pyproject.toml
index efdd9953923e..170af7083d29 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -564,19 +564,6 @@ ignore_imports = [
"products.logs.backend.presentation.views.api -> products.exports.backend.models.exported_asset",
"products.logs.backend.presentation.views.alerts_api -> products.cdp.backend.api.hog_function",
"products.logs.backend.presentation.views.alerts_api -> products.cdp.backend.models.hog_functions.hog_function",
- # TODO: endpoints presentation wave — the structural move landed EndpointViewSet under
- # presentation/views/ but it still reaches in-product internals (models, logic services,
- # throttles, openapi generation) directly. Thin it to parse -> facade -> serialize and
- # delete each entry. backend:contract-check stays off until this list is empty.
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.constants",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.logs",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.models",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.openapi",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.rate_limit",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.logic.crud",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.logic.execution",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.logic.materialization",
- "products.endpoints.backend.presentation.views.api -> products.endpoints.backend.logic.validation",
# TODO: notebooks presentation wave — the moved NotebookViewSet still reaches in-product
# internals (collab, kernel runtime, query validation, models) and the tasks sandbox
# directly. Thin it to parse -> facade -> serialize and delete each entry.