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(data-warehouse): surface warehouse suggestions in for you today (#124356)

Thiago Salvatore74da4b1eb841
diff --git a/frontend/src/scenes/project-homepage/today/todayRowIcons.tsx b/frontend/src/scenes/project-homepage/today/todayRowIcons.tsx
index 82250fed3949..9f43a6b66bc9 100644
--- a/frontend/src/scenes/project-homepage/today/todayRowIcons.tsx
+++ b/frontend/src/scenes/project-homepage/today/todayRowIcons.tsx
@@ -38,6 +38,7 @@ const PRODUCT_ICONS: Record<string, TodayRowIcon> = {
replay: REPLAY,
surveys: { color: 'var(--color-product-surveys-light)', glyph: <IconMessage /> },
warehouse_sources: { color: 'var(--color-product-data-warehouse-light)', glyph: <IconDatabase /> },
+ warehouse_suggestions: { color: 'var(--color-product-data-warehouse-light)', glyph: <IconDatabase /> },
workflows: { color: 'var(--color-product-workflows-light)', glyph: <IconDecisionTree /> },
}
diff --git a/products/data_catalog/backend/tests/test_today_highlights.py b/products/data_catalog/backend/tests/test_today_highlights.py
deleted file mode 100644
index cb1019a45ca7..000000000000
--- a/products/data_catalog/backend/tests/test_today_highlights.py
+++ /dev/null
@@ -1,74 +0,0 @@
-from collections.abc import Callable
-from types import SimpleNamespace
-from typing import cast
-
-from unittest.mock import MagicMock, patch
-
-from django.test import SimpleTestCase
-
-from parameterized import parameterized
-
-from products.data_catalog.backend import today_highlights
-from products.data_catalog.backend.facade.api import PendingGroup, PendingKind, TeamPendingReview
-from products.data_catalog.backend.facade.today_highlights import HIGHLIGHT_SOURCES
-from products.today.backend.facade.contracts import HighlightContext, HighlightFindings
-from products.today.backend.facade.enums import HighlightLabel
-
-METRICS = PendingGroup(kind=PendingKind.METRICS, noun="metric", count=3, sample_names=[])
-RELATIONSHIPS = PendingGroup(kind=PendingKind.RELATIONSHIPS, noun="relationship", count=2, sample_names=[])
-ONE_CERTIFICATION = PendingGroup(kind=PendingKind.CERTIFICATIONS, noun="certification", count=1, sample_names=[])
-
-
-class TestDataCatalogApprovalsHighlight(SimpleTestCase):
- @parameterized.expand(
- [
- (
- "one item uses the singular",
- [ONE_CERTIFICATION],
- "1 certification waits for approval",
- "Review it in the data catalog.",
- "/data-catalog?tab=certifications",
- ),
- (
- "several queues join their counts and link the first queue",
- [METRICS, RELATIONSHIPS, ONE_CERTIFICATION],
- "3 metrics, 2 relationships and 1 certification wait for approval",
- "Review them in the data catalog.",
- "/data-catalog?tab=metrics",
- ),
- ]
- )
- def test_pending_queues_are_one_opportunity_item(
- self, _name: str, groups: list[PendingGroup], title: str, detail: str, url: str
- ) -> None:
- review = TeamPendingReview(
- team_id=1, team_name="Team", groups=groups, total=sum(group.count for group in groups)
- )
- registered = next(source for source in HIGHLIGHT_SOURCES if source.name == "data_catalog_approvals")
-
- with patch.object(today_highlights, "build_team_pending_review", return_value=review):
- found = self._find(registered.find, can_approve=True)
-
- assert len(found.items) == 1
- item = found.items[0]
- assert (item.title, item.detail, item.url) == (title, detail, url)
- assert item.label == HighlightLabel.OPPORTUNITY
- assert (item.importance, item.relevance) == (0.5, 1.0)
- assert registered.scopes == ("data_catalog:read", "data_catalog_approval:write")
-
- def test_a_user_who_cannot_approve_gets_no_item(self) -> None:
- review = TeamPendingReview(team_id=1, team_name="Team", groups=[METRICS], total=3)
-
- with patch.object(today_highlights, "build_team_pending_review", return_value=review):
- found = self._find(today_highlights.find_pending_approvals, can_approve=False)
-
- assert found.items == ()
-
- def _find(self, find: Callable[[HighlightContext], HighlightFindings], *, can_approve: bool) -> HighlightFindings:
- access = MagicMock()
- access.check_access_level_for_resource.side_effect = lambda resource, level: (
- can_approve and (resource, level) == ("data_catalog", "editor")
- )
- context = cast(HighlightContext, SimpleNamespace(team=SimpleNamespace(id=1), user=SimpleNamespace(id=2)))
- with patch.object(today_highlights, "UserAccessControl", return_value=access):
- return find(context)
diff --git a/products/data_catalog/backend/today_highlights.py b/products/data_catalog/backend/today_highlights.py
deleted file mode 100644
index 52eb73f5520d..000000000000
--- a/products/data_catalog/backend/today_highlights.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from products.access_control.backend.facade.user_access_control import AccessControlLevel, UserAccessControl
-from products.data_catalog.backend.facade.api import PendingGroup, build_team_pending_review
-from products.today.backend.facade.contracts import HighlightCandidate, HighlightContext, HighlightFindings
-from products.today.backend.facade.enums import HighlightLabel
-
-APPROVER_ACCESS_LEVEL: AccessControlLevel = "editor"
-IMPORTANCE = 0.5
-
-ONE_TITLE = "{counts} waits for approval"
-MANY_TITLE = "{counts} wait for approval"
-ONE_DETAIL = "Review it in the data catalog."
-MANY_DETAIL = "Review them in the data catalog."
-
-
-def _join(groups: list[PendingGroup]) -> str:
- counts = [f"{group.count} {group.noun}{'' if group.count == 1 else 's'}" for group in groups]
- return counts[0] if len(counts) == 1 else f"{', '.join(counts[:-1])} and {counts[-1]}"
-
-
-def find_pending_approvals(context: HighlightContext) -> HighlightFindings:
- access = UserAccessControl(user=context.user, team=context.team)
- if not access.check_access_level_for_resource("data_catalog", APPROVER_ACCESS_LEVEL):
- return HighlightFindings()
- review = build_team_pending_review(context.team, sample_size=0)
- if review is None:
- return HighlightFindings()
- one = review.total == 1
- return HighlightFindings(
- items=(
- HighlightCandidate(
- key="data_catalog_approvals",
- label=HighlightLabel.OPPORTUNITY,
- family="data_catalog",
- importance=IMPORTANCE,
- relevance=1.0,
- title=(ONE_TITLE if one else MANY_TITLE).format(counts=_join(review.groups)),
- detail=ONE_DETAIL if one else MANY_DETAIL,
- url=f"/data-catalog?tab={review.groups[0].kind}",
- ),
- )
- )
diff --git a/products/warehouse_suggestions/backend/facade/contracts.py b/products/warehouse_suggestions/backend/facade/contracts.py
index 08c6a09b002c..e902455ba4a2 100644
--- a/products/warehouse_suggestions/backend/facade/contracts.py
+++ b/products/warehouse_suggestions/backend/facade/contracts.py
@@ -1,7 +1,7 @@
"""Contract types for warehouse_suggestions."""
from datetime import datetime
-from typing import Any
+from typing import Any, Final
from uuid import UUID
from posthog.dataclasses import frozen
@@ -17,6 +17,11 @@ from .enums import (
)
PAYLOAD_VERSION = 1
+WAREHOUSE_SCOPE_OBJECT: Final = "warehouse_objects"
+SUBJECT_SCOPE_OBJECTS = {
+ WarehouseSuggestionSubjectKind.SAVED_QUERY: "warehouse_view",
+ WarehouseSuggestionSubjectKind.TABLE: "warehouse_table",
+}
@frozen
diff --git a/products/data_catalog/backend/facade/today_highlights.py b/products/warehouse_suggestions/backend/facade/today_highlights.py
similarity index 53%
rename from products/data_catalog/backend/facade/today_highlights.py
rename to products/warehouse_suggestions/backend/facade/today_highlights.py
index f3f6bef83a06..6df1c57ab750 100644
--- a/products/data_catalog/backend/facade/today_highlights.py
+++ b/products/warehouse_suggestions/backend/facade/today_highlights.py
@@ -1,13 +1,12 @@
-"""Data catalog's sources for the "For you today" list. Today finds this module by name."""
-
from products.today.backend.facade.contracts import HighlightSource
-from ..today_highlights import find_pending_approvals
+from ..today_highlights import find_catalog_approvals, find_model_suggestions
HIGHLIGHT_SOURCES = (
HighlightSource(
name="data_catalog_approvals",
- find=find_pending_approvals,
+ find=find_catalog_approvals,
scopes=("data_catalog:read", "data_catalog_approval:write"),
),
+ HighlightSource(name="warehouse_model_suggestions", find=find_model_suggestions),
)
diff --git a/products/warehouse_suggestions/backend/logic/access.py b/products/warehouse_suggestions/backend/logic/access.py
index e8746487d941..5e4f72bf9c80 100644
--- a/products/warehouse_suggestions/backend/logic/access.py
+++ b/products/warehouse_suggestions/backend/logic/access.py
@@ -14,6 +14,7 @@ from products.warehouse_sources.backend.facade.api import allowed_table_ids
from ..facade.contracts import SubjectKinds
from ..facade.enums import WarehouseSuggestionKind, WarehouseSuggestionStatus, WarehouseSuggestionSubjectKind
from ..models import WarehouseSuggestion
+from .flags import is_warehouse_suggestions_enabled
from .rules import RULES
if TYPE_CHECKING:
@@ -109,6 +110,24 @@ def visible_suggestions(
return visible, access
+def actionable_open_count(
+ team: "Team",
+ user: "User",
+ kinds: frozenset[WarehouseSuggestionKind],
+ subject_kinds: frozenset[WarehouseSuggestionSubjectKind],
+) -> int:
+ """How many surfaced, proposed suggestions of `kinds` on `subject_kinds` `user` can act on."""
+ if not is_warehouse_suggestions_enabled(team):
+ return 0
+ visible, access = visible_suggestions(
+ team.pk,
+ UserAccessControl(user, team),
+ status=WarehouseSuggestionStatus.PROPOSED,
+ subject_kinds=SubjectKinds(readable=subject_kinds, actionable=subject_kinds),
+ )
+ return sum(1 for suggestion in visible.filter(kind__in=kinds) if access.can_act_on(suggestion))
+
+
def subject_access(
team_id: int,
user_access_control: "UserAccessControl",
diff --git a/products/warehouse_suggestions/backend/presentation/views.py b/products/warehouse_suggestions/backend/presentation/views.py
index 7f27ab8608ca..04ec883d665f 100644
--- a/products/warehouse_suggestions/backend/presentation/views.py
+++ b/products/warehouse_suggestions/backend/presentation/views.py
@@ -27,6 +27,8 @@ from posthog.utils import UUID_REGEX
from ..facade import api
from ..facade.api import is_warehouse_suggestions_enabled
from ..facade.contracts import (
+ SUBJECT_SCOPE_OBJECTS,
+ WAREHOUSE_SCOPE_OBJECT,
AcceptFailedError,
AcceptOptionRefusedError,
AcceptOptions,
@@ -76,10 +78,6 @@ ASSIGNEE_CANNOT_ACT = (
ONLY_OPEN_ASSIGNABLE = "Only open suggestions can be assigned."
ACCEPT_SCOPES = ["data_catalog_approval:write", "warehouse_view:write"]
ScopeLevel = Literal["read", "write"]
-SUBJECT_SCOPE_OBJECTS = {
- WarehouseSuggestionSubjectKind.SAVED_QUERY: "warehouse_view",
- WarehouseSuggestionSubjectKind.TABLE: "warehouse_table",
-}
class SuggestionPagination(LimitOffsetPagination):
@@ -102,7 +100,7 @@ class ProjectAccessPermission(BasePermission):
class WarehouseSuggestionViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
- scope_object = "warehouse_objects"
+ scope_object = WAREHOUSE_SCOPE_OBJECT
scope_object_read_actions = ["list", "retrieve", "status"]
scope_object_write_actions = ["accept", "assign", "dismiss", "resume"]
pagination_class = SuggestionPagination
diff --git a/products/warehouse_suggestions/backend/tests/test_today_highlights.py b/products/warehouse_suggestions/backend/tests/test_today_highlights.py
new file mode 100644
index 000000000000..a421ac882294
--- /dev/null
+++ b/products/warehouse_suggestions/backend/tests/test_today_highlights.py
@@ -0,0 +1,210 @@
+from contextlib import AbstractContextManager
+from dataclasses import replace
+from datetime import date
+from types import SimpleNamespace
+from typing import cast
+from uuid import UUID
+
+from posthog.test.base import BaseTest
+from unittest.mock import MagicMock, patch
+
+from django.test import SimpleTestCase
+
+from parameterized import parameterized
+
+from posthog.constants import AvailableFeature
+
+from products.access_control.backend.models.access_control import AccessControl
+from products.data_catalog.backend.facade.api import PendingGroup, PendingKind, TeamPendingReview
+from products.data_modeling.backend.facade.models import DataWarehouseSavedQuery
+from products.today.backend.facade.contracts import HighlightContext
+from products.today.backend.facade.enums import HighlightLabel
+from products.today.backend.facade.testing import highlight_context
+from products.warehouse_suggestions.backend import today_highlights
+from products.warehouse_suggestions.backend.facade.contracts import SuggestionDraft
+from products.warehouse_suggestions.backend.facade.enums import WarehouseSuggestionKind, WarehouseSuggestionStatus
+from products.warehouse_suggestions.backend.facade.today_highlights import HIGHLIGHT_SOURCES
+from products.warehouse_suggestions.backend.logic.suggestions import transition_to
+from products.warehouse_suggestions.backend.models import WarehouseSuggestion
+
+from .test_api import ingest_surfaced
+from .test_suggestions import ingest_one, make_draft
+
+METRICS = PendingGroup(kind=PendingKind.METRICS, noun="metric", count=3, sample_names=[])
+RELATIONSHIPS = PendingGroup(kind=PendingKind.RELATIONSHIPS, noun="relationship", count=2, sample_names=[])
+ONE_CERTIFICATION = PendingGroup(kind=PendingKind.CERTIFICATIONS, noun="certification", count=1, sample_names=[])
+FLAG = "products.warehouse_suggestions.backend.logic.access.is_warehouse_suggestions_enabled"
+
+
+class TestCatalogApprovalsHighlight(SimpleTestCase):
+ @parameterized.expand(
+ [
+ (
+ "one item uses the singular",
+ [ONE_CERTIFICATION],
+ 0,
+ "1 certification waits for approval",
+ "Review it in the data catalog.",
+ "/data-catalog?tab=certifications",
+ ),
+ (
+ "several queues join their counts and link the first queue",
+ [METRICS, RELATIONSHIPS, ONE_CERTIFICATION],
+ 0,
+ "3 metrics, 2 relationships and 1 certification wait for approval",
+ "Review them in the data catalog.",
+ "/data-catalog?tab=metrics",
+ ),
+ (
+ "certification suggestions join the proposals in one item",
+ [RELATIONSHIPS],
+ 3,
+ "2 relationships and 3 certification suggestions wait for approval",
+ "Review them in the data catalog.",
+ "/data-catalog?tab=relationships",
+ ),
+ (
+ "certification suggestions alone still make an item",
+ [],
+ 1,
+ "1 certification suggestion waits for approval",
+ "Review it in the data catalog.",
+ "/data-catalog?tab=certifications",
+ ),
+ ]
+ )
+ def test_proposals_and_suggestions_are_one_opportunity_item(
+ self, _name: str, groups: list[PendingGroup], suggested: int, title: str, detail: str, url: str
+ ) -> None:
+ review = (
+ TeamPendingReview(team_id=1, team_name="Team", groups=groups, total=sum(group.count for group in groups))
+ if groups
+ else None
+ )
+ registered = next(source for source in HIGHLIGHT_SOURCES if source.name == "data_catalog_approvals")
+
+ with self._catalog(review=review, suggested=suggested, can_approve=True):
+ found = registered.find(self._context())
+
+ assert len(found.items) == 1
+ item = found.items[0]
+ assert (item.title, item.detail, item.url) == (title, detail, url)
+ assert item.label == HighlightLabel.OPPORTUNITY
+ assert (item.importance, item.relevance) == (0.5, 1.0)
+ assert registered.scopes == ("data_catalog:read", "data_catalog_approval:write")
+
+ @parameterized.expand([("cannot approve", False, 2), ("nothing to review", True, 0)])
+ def test_no_item(self, _name: str, can_approve: bool, suggested: int) -> None:
+ with self._catalog(review=None, suggested=suggested, can_approve=can_approve):
+ found = today_highlights.find_catalog_approvals(self._context())
+
+ assert found.items == ()
+
+ def _catalog(
+ self, *, review: TeamPendingReview | None, suggested: int, can_approve: bool
+ ) -> AbstractContextManager[object]:
+ access = MagicMock()
+ access.check_access_level_for_resource.side_effect = lambda resource, level: (
+ can_approve and (resource, level) == ("data_catalog", "editor")
+ )
+ return patch.multiple(
+ today_highlights,
+ build_team_pending_review=MagicMock(return_value=review),
+ actionable_open_count=MagicMock(return_value=suggested),
+ UserAccessControl=MagicMock(return_value=access),
+ )
+
+ def _context(self) -> HighlightContext:
+ return cast(
+ HighlightContext,
+ SimpleNamespace(
+ team=SimpleNamespace(id=1),
+ user=SimpleNamespace(id=1),
+ guard=lambda _name, provider, _default: provider(),
+ allows=lambda *_required: True,
+ ),
+ )
+
+
+class TestModelSuggestionsHighlight(BaseTest):
+ def setUp(self) -> None:
+ super().setUp()
+ self.flag = self.enterContext(patch(FLAG, return_value=True))
+
+ def test_counts_the_open_model_suggestions_the_viewer_can_act_on(self) -> None:
+ self._suggest(WarehouseSuggestionKind.MATERIALIZE, self._view("orders").id)
+ self._suggest(WarehouseSuggestionKind.UNMATERIALIZE, self._view("events_daily").id)
+ self._suggest(WarehouseSuggestionKind.CERTIFY, self._view("users").id)
+ ingest_one(self.team.id, self._draft(WarehouseSuggestionKind.MATERIALIZE, self._view("unsurfaced").id))
+ dismissed = self._suggest(WarehouseSuggestionKind.MATERIALIZE, self._view("dismissed").id)
+ transition_to(dismissed.id, self.team.id, WarehouseSuggestionStatus.DISMISSED, user_id=self.user.id)
+ read_only = self._view("read_only")
+ self._suggest(WarehouseSuggestionKind.MATERIALIZE, read_only.id)
+ self._restrict_view(read_only.id, "viewer")
+
+ found = today_highlights.find_model_suggestions(self._context())
+
+ assert [(item.title, item.detail, item.url) for item in found.items] == [
+ ("2 model suggestions wait for review", "Review them in Models.", "/models?tab=models")
+ ]
+
+ @parameterized.expand(
+ [
+ ("session", None, 1),
+ ("umbrella warehouse scope", frozenset({"warehouse_objects:write"}), 1),
+ ("view scope", frozenset({"warehouse_view:write"}), 1),
+ ("read only view scope", frozenset({"warehouse_view:read"}), 0),
+ ("table scope", frozenset({"warehouse_table:write"}), 0),
+ ("catalog scopes only", frozenset({"data_catalog:read", "data_catalog_approval:write"}), 0),
+ ]
+ )
+ def test_counts_only_subjects_the_token_can_write(
+ self, _name: str, scopes: frozenset[str] | None, expected_items: int
+ ) -> None:
+ self._suggest(WarehouseSuggestionKind.MATERIALIZE, self._view("orders").id)
+
+ found = today_highlights.find_model_suggestions(self._context(scopes))
+
+ assert len(found.items) == expected_items
+
+ def test_no_item_when_suggestions_are_off(self) -> None:
+ self._suggest(WarehouseSuggestionKind.MATERIALIZE, self._view("orders").id)
+ self.flag.return_value = False
+
+ assert today_highlights.find_model_suggestions(self._context()).items == ()
+
+ def test_a_failed_suggestion_count_keeps_the_catalog_proposals(self) -> None:
+ review = TeamPendingReview(team_id=self.team.id, team_name="Team", groups=[ONE_CERTIFICATION], total=1)
+ self.flag.side_effect = RuntimeError("flag service down")
+
+ with patch.object(today_highlights, "build_team_pending_review", return_value=review):
+ found = today_highlights.find_catalog_approvals(self._context())
+
+ assert [item.title for item in found.items] == ["1 certification waits for approval"]
+
+ def _context(self, scopes: frozenset[str] | None = None) -> HighlightContext:
+ return highlight_context(team=self.team, user=self.user, today=date(2026, 10, 27), scopes=scopes)
+
+ def _view(self, name: str) -> DataWarehouseSavedQuery:
+ return DataWarehouseSavedQuery.objects.create(
+ team=self.team, name=name, query={"kind": "HogQLQuery", "query": "SELECT 1 AS id"}
+ )
+
+ def _draft(self, kind: WarehouseSuggestionKind, view_id: UUID) -> SuggestionDraft:
+ return replace(make_draft(fingerprint=f"{kind}:{view_id}", subject_id=view_id), kind=kind)
+
+ def _suggest(self, kind: WarehouseSuggestionKind, view_id: UUID) -> WarehouseSuggestion:
+ return ingest_surfaced(self.team.id, self._draft(kind, view_id))
+
+ def _restrict_view(self, view_id: UUID, access_level: str) -> None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL}
+ ]
+ self.organization.save(update_fields=["available_product_features"])
+ AccessControl.objects.create(
+ team=self.team,
+ resource="warehouse_view",
+ resource_id=str(view_id),
+ organization_member=self.organization_membership,
+ access_level=access_level,
+ )
diff --git a/products/warehouse_suggestions/backend/today_highlights.py b/products/warehouse_suggestions/backend/today_highlights.py
new file mode 100644
index 000000000000..cfcccb15e4db
--- /dev/null
+++ b/products/warehouse_suggestions/backend/today_highlights.py
@@ -0,0 +1,103 @@
+from products.access_control.backend.facade.user_access_control import AccessControlLevel, UserAccessControl
+from products.data_catalog.backend.facade.api import PendingGroup, PendingKind, build_team_pending_review
+from products.today.backend.facade.contracts import HighlightCandidate, HighlightContext, HighlightFindings
+from products.today.backend.facade.enums import HighlightLabel
+
+from .facade.contracts import SUBJECT_SCOPE_OBJECTS, WAREHOUSE_SCOPE_OBJECT
+from .facade.enums import WarehouseSuggestionKind, WarehouseSuggestionSubjectKind
+from .logic.access import CATALOG_KINDS, actionable_open_count
+
+APPROVER_ACCESS_LEVEL: AccessControlLevel = "editor"
+IMPORTANCE = 0.5
+
+ONE_TITLE = "{counts} waits for approval"
+MANY_TITLE = "{counts} wait for approval"
+ONE_DETAIL = "Review it in the data catalog."
+MANY_DETAIL = "Review them in the data catalog."
+CERTIFICATION_SUGGESTION_NOUN = "certification suggestion"
+
+MODEL_KINDS = frozenset({WarehouseSuggestionKind.MATERIALIZE, WarehouseSuggestionKind.UNMATERIALIZE})
+ONE_MODEL_TITLE = "1 model suggestion waits for review"
+MANY_MODEL_TITLE = "{count} model suggestions wait for review"
+ONE_MODEL_DETAIL = "Review it in Models."
+MANY_MODEL_DETAIL = "Review them in Models."
+MODELS_URL = "/models?tab=models"
+SUGGESTION_COUNT_GUARD = "data_catalog_approvals.suggestions"
+
+
+def find_catalog_approvals(context: HighlightContext) -> HighlightFindings:
+ access = UserAccessControl(user=context.user, team=context.team)
+ if not access.check_access_level_for_resource("data_catalog", APPROVER_ACCESS_LEVEL):
+ return HighlightFindings()
+ groups = _pending_groups(context)
+ if not groups:
+ return HighlightFindings()
+ one = sum(group.count for group in groups) == 1
+ return HighlightFindings(
+ items=(
+ HighlightCandidate(
+ key="data_catalog_approvals",
+ label=HighlightLabel.OPPORTUNITY,
+ family="data_catalog",
+ importance=IMPORTANCE,
+ relevance=1.0,
+ title=(ONE_TITLE if one else MANY_TITLE).format(counts=_join(groups)),
+ detail=ONE_DETAIL if one else MANY_DETAIL,
+ url=f"/data-catalog?tab={groups[0].kind}",
+ ),
+ )
+ )
+
+
+def find_model_suggestions(context: HighlightContext) -> HighlightFindings:
+ count = _open_count(context, MODEL_KINDS)
+ if not count:
+ return HighlightFindings()
+ one = count == 1
+ return HighlightFindings(
+ items=(
+ HighlightCandidate(
+ key="warehouse_model_suggestions",
+ label=HighlightLabel.OPPORTUNITY,
+ family="data_modeling",
+ importance=IMPORTANCE,
+ relevance=1.0,
+ title=ONE_MODEL_TITLE if one else MANY_MODEL_TITLE.format(count=count),
+ detail=ONE_MODEL_DETAIL if one else MANY_MODEL_DETAIL,
+ url=MODELS_URL,
+ ),
+ )
+ )
+
+
+def _pending_groups(context: HighlightContext) -> list[PendingGroup]:
+ review = build_team_pending_review(context.team, sample_size=0)
+ groups = list(review.groups) if review else []
+ suggested = context.guard(SUGGESTION_COUNT_GUARD, lambda: _open_count(context, CATALOG_KINDS), 0)
+ if suggested:
+ groups.append(
+ PendingGroup(
+ kind=PendingKind.CERTIFICATIONS,
+ noun=CERTIFICATION_SUGGESTION_NOUN,
+ count=suggested,
+ sample_names=[],
+ )
+ )
+ return groups
+
+
+def _open_count(context: HighlightContext, kinds: frozenset[WarehouseSuggestionKind]) -> int:
+ return actionable_open_count(context.team, context.user, kinds, _writable_subject_kinds(context))
+
+
+def _writable_subject_kinds(context: HighlightContext) -> frozenset[WarehouseSuggestionSubjectKind]:
+ return frozenset(
+ subject_kind
+ for subject_kind, scope_object in SUBJECT_SCOPE_OBJECTS.items()
+ if context.allows(f"{WAREHOUSE_SCOPE_OBJECT}:write") or context.allows(f"{scope_object}:write")
+ )
+
+
+def _join(groups: list[PendingGroup]) -> str:
+ counts = [f"{group.count} {group.noun}{'' if group.count == 1 else 's'}" for group in groups]
+ return counts[0] if len(counts) == 1 else f"{', '.join(counts[:-1])} and {counts[-1]}"
diff --git a/tach.toml b/tach.toml
index 49f73cde1ae8..7034cdd6443c 100644
--- a/tach.toml
+++ b/tach.toml
@@ -1602,8 +1602,6 @@ depends_on = [
"products.product_analytics",
"products.warehouse_sources",
"products.data_modeling", "products.access_control",
- # Facade-only: data catalog declares its Today highlight sources against the Today facade contract.
- "products.today",
]
layer = "modules"
@@ -1791,6 +1789,8 @@ depends_on = [
"products.data_catalog",
"products.data_modeling",
"products.notifications",
+ # Facade-only: warehouse suggestions declares its Today highlight sources against the Today facade contract.
+ "products.today",
"products.warehouse_sources",
]
layer = "modules"