: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: clarify RBAC ownership in product facade architecture (#65471)
Julian Bez34085d2d2387
diff --git a/products/architecture.md b/products/architecture.mdindex ed8d45541ffc..8d43be1ee7bd 100644--- a/products/architecture.md+++ b/products/architecture.md@@ -271,10 +271,16 @@ Presentation may only import `facade` and other `presentation` modules within thIf both presentation and logic need the same utility (caching, permissions, etc.), putting it at `backend/cache.py` and importing from both layers creates an "accidental shared kernel" — a hidden coupling that bypasses the facade. Instead:-- **Presentation concern** (response caching, rate limiting) → `presentation/`-- **Business concern** (domain-level caching, permission checks) → `logic/`, exposed through the facade+- **Presentation concern** (response caching, rate limiting, user RBAC — see below) → `presentation/`+- **Business concern** (domain-level caching, tenant scoping, domain invariants) → `logic/`, exposed through the facade- **Both layers need it** → that's a signal the boundary is drawn wrong; refactor+### Who owns RBAC?++User RBAC stays on the **viewset** — it depends on the authenticated `request`/`user`, which the facade doesn't have (facades also run from Celery, CLIs, and other products). Declare it the standard way: `scope_object` plus `scope_object_read_actions`/`scope_object_write_actions`, and let the shared permission classes (`APIScopePermission`, `AccessControlPermission`) on `TeamAndOrgViewSetMixin` enforce API-scope and resource access. See `products/visual_review/backend/presentation/views.py`.++The facade owns **tenant scoping** (`team_id` enforced via `for_team(team_id)` / a `ProductTeamModel` fail-closed manager) and **domain invariants** (state machines, idempotency) — these must hold for every caller, so they live below the HTTP boundary; user RBAC must not. Keeping RBAC in the shared DRF stack also lets cross-cutting permission tests enforce it consistently across products.+### Why not mix with the facade?- Keeps HTTP concerns decoupled