feat: tenant isolation Phase 0 — app-layer filters, UUID audit, CI gate #132
Reference in New Issue
Block a user
Delete Branch "feat/tenant-isolation-phase-0"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the application-layer half of tenant data isolation (Phase 0). No schema changes — all existing tables, all existing data. Establishes the patterns and CI gate that all future tenant-data work must comply with.
Depends on: #131 (copilot hotfix) must merge first.
What's in this PR
tenant_filter(model, account_id)— canonical app-layer scoping helper infilters.py. Every query on a tenant table must use it.get_tenant_contextdependency indeps.py— centralises theaccount_idnull checkGET /analytics/flows/{tree_id}) — scoped to requesting accountGET /categories/{id}) —tree_countno longer leaks cross-tenant row countsuser_idonly (wasOR(user_id, account_id))retry_psa_push(CRITICAL): no ownership check existed — any user could retry any session's PSA pushget_documentation: was returning 403 (confirming session existence) → now 404update_tree: restored 403 for intra-account permission failures (same-account users who can see a tree but can't edit it no longer get a confusing 404)_get_tree_or_403renamed to_get_tree_or_404inmaintenance_schedules.pyaccount_idin Phase 1 (not dead code)backend/scripts/check_tenant_filters.pyadded to CI backend job (warn mode, 109 current warnings = Phase 1 backlog)Spec
docs/superpowers/specs/2026-04-09-tenant-data-isolation-design.mdPhase 0 gate status
get_tenant_contextdependency addedtenant_filter()helper addedTest plan
test_tenant_isolation_p0.pygreenpython scripts/check_tenant_filters.pyshows 109 warnings (Phase 1 backlog, not regressions)🤖 Generated with Claude Code
🚅 Deployed to the resolutionflow-pr-132 environment in selfless-grace