Context
0045 put pool tenancy, silo-on-demand and anltree scope tree from day one into one free package. The open-core split (0077) moves the scale features to Pro. The Figentra OS tenancy package also depends on the router, which a server-side package must not.
Decision
@stackra/tenancyis the one tenancy package. Products and services use it; none implements isolation itself.- Free: pool tenancy. Every tenant-owned table has a
tenant_idcolumn, and row-level security is bothENABLEd andFORCEd on it. The package provideswithTenantand an isolation test kit. - The connection resolver is a free contract. The pool resolver is free. DB-per-tenant and move-tenant are a Pro driver behind that contract.
- No schema-per-tenant.
- The scope tree is Pro,
@stackra-pro/scope, and plugs into tenancy andcheck()(0087). Free tenancy has no scope dependency. - No router dependency.
- Isolation is enforced at two layers, the MikroORM scoped entity and the database policy, and every tenant-owned table has a cross-tenant isolation test, written with the kit.
Consequences
- Free users get complete pool isolation. Silo and hierarchy are paid features.
- Academorix needs the scope tree from day one, so it would consume
@stackra-pro/scopeunder an internal licence. This is open and awaits owner confirmation. - The resolver contract must be designed for the Pro silo driver without it being present in this repository.
Enforcement
Planned: a validator check that a migration creating a table withtenant_id also enables and forces RLS, and the per-table isolation test of decision 7, run on real Postgres. Nothing is implemented yet.