: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
chore(workflows): hand out HogFlow under the watched-models allowance (#113772)
Harley Alexander84751691fc50
diff --git a/products/architecture.md b/products/architecture.mdindex 217f6de731e0..32024bae9b33 100644--- a/products/architecture.md+++ b/products/architecture.md@@ -121,13 +121,16 @@ Two core registries are keyed by model class identity and are explicit, sanctionThere the class crosses for registration only, core drives only the registry's mixin methods, and the model's module must stay in the product's contract-check inputs.**The watched-models allowance** is the one further, deliberately temporary exception, for products whose models are load-bearing substrate that core and sibling products consume and cannot yet stop consuming.-Two products hold entries.+Three products hold entries.`warehouse_sources`: core HogQL reads its warehouse table/schema/source models to build queryable tables.`ExternalDataDestination`, `ExternalDataSourceDestination` and `ExternalDataSchemaDestination` cross for the same reason as the rest of the product's models — the destination CRUD `ModelViewSet` and the source-/schema-level link-table editors need the classes themselves for `Meta.model`, querysets, and edits to the link rows, not a read-only shape.`product_analytics`: `Insight` and `InsightVariable`.Core and seven products (alerts, dashboards, surveys, annotations, exports, customer_analytics, pulse) hold ForeignKeys or M2Ms into `Insight` — dashboard tiles, subscriptions and exported assets, sharing configurations, tagged items — and rely on cascade deletes, relation traversal, reverse relations, and queryset-typed access-control filtering that a frozen contract cannot express.`InsightVariable` has no consumer left outside the product; its entry survives only because the SQL-variables `ModelViewSet` in `presentation/` needs the class and presentation may reach internals only through the facade, so retiring the entry means converting that viewset off `ModelSerializer` first.The dashboards→product_analytics `DashboardTile.insight` FK and `Dashboard.insights` M2M-through cross into the product against §8's direction rule; that coupling is accepted under this entry until dashboards pursues its own isolation.+`workflows`: `HogFlow`.+`HogFlowViewSet` in `presentation/` reads and writes workflows through facade functions, but the log, metrics and access-control mixins it inherits read the row through `get_object()`, and `UserAccessControl` resolves the resource and the object-level rules from the model instance.+Retiring the entry means teaching those core mixins and `UserAccessControl` to accept a resource type and id in place of a model instance.An allowance product's facade may hand out model classes defined under `backend/models/`.The model surface is watched by every narrowed product anyway (see [What makes the skip sound](#what-makes-the-skip-sound)); the allowance adds only the permission to hand out the class.diff --git a/products/workflows/backend/facade/models.py b/products/workflows/backend/facade/models.pynew file mode 100644index 000000000000..6adad071da22--- /dev/null+++ b/products/workflows/backend/facade/models.py@@ -0,0 +1,15 @@+"""+Model-class wiring for workflows.++Re-exports the ``HogFlow`` model class for ``HogFlowViewSet`` under the watched-models allowance+(MODEL_CROSSINGS). The viewset reads and writes workflows through facade functions, but the log,+metrics and access-control mixins it inherits still read the workflow row through ``get_object()``,+and ``UserAccessControl`` resolves the resource from the model instance. Presentation may reach+internals only through the facade. The whole model surface (``backend/models/`` and+``backend/migrations/``) stays in the contract-check inputs, so a change to this class still runs+the full suite.+"""++from products.workflows.backend.models.hog_flow.hog_flow import HogFlow++__all__ = ["HogFlow"]diff --git a/products/workflows/backend/presentation/views/hog_flow.py b/products/workflows/backend/presentation/views/hog_flow.pyindex da753f96e9f3..a4f2d826a53f 100644--- a/products/workflows/backend/presentation/views/hog_flow.py+++ b/products/workflows/backend/presentation/views/hog_flow.py@@ -181,6 +181,7 @@ from products.workflows.backend.facade.enums import (WorkflowProposalStatus,)from products.workflows.backend.facade.message_assets import fetch_message_asset_html, fetch_message_assets+from products.workflows.backend.facade.models import HogFlowfrom products.workflows.backend.facade.proposals import (HOG_FLOW_VERSION_APP_SOURCE,PROPOSAL_MERGE_BY_ID_FIELDS,@@ -261,7 +262,6 @@ from products.workflows.backend.facade.writes import (trigger_has_audience,update_workflow,)-from products.workflows.backend.models.hog_flow.hog_flow import HogFlowfrom products.workflows.backend.presentation.views.graph_operations import apply_graph_operationsfrom products.workflows.backend.presentation.views.graph_validation import validate_graphfrom products.workflows.backend.presentation.views.hog_flow_batch_job import (diff --git a/pyproject.toml b/pyproject.tomlindex 8b7898705a4b..c0983a1a632e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -718,7 +718,6 @@ ignore_imports = [# this list is empty. Only delete entries here: a new import from these views goes through# the facade."products.workflows.backend.presentation.views.hog_flow -> products.messaging.backend.api.message_templates",- "products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.models.hog_flow.hog_flow",# TODO: access-control presentation wave — the consolidated RBAC viewsets carry their ORM# access with them. Thin them to parse -> facade -> serialize and delete each entry."products.access_control.backend.presentation.access_control -> products.access_control.backend.models.access_control",diff --git a/tools/hogli-commands/hogli_commands/product/isolation.py b/tools/hogli-commands/hogli_commands/product/isolation.pyindex e231eb681fe7..8b57a8438c54 100644--- a/tools/hogli-commands/hogli_commands/product/isolation.py+++ b/tools/hogli-commands/hogli_commands/product/isolation.py@@ -617,6 +617,7 @@ MODEL_CROSSINGS: frozenset[tuple[str, str]] = frozenset(("warehouse_sources", "PendingSourceCredential"),("warehouse_sources", "WarehouseColumnAnnotation"),("warehouse_sources", "WarehouseColumnStatistics"),+ ("workflows", "HogFlow"),})