Skip to Content
Baseera Docs

Data isolation

How organizations, tenants and document access rules keep one customer's data away from another, enforced in the database.

Isolation is enforced where the data lives, not only in application code. If a server action forgets a check, the database still refuses.

Organizations and row-level security

Every table has row-level security. A signed-in person can read the rows of their own organization and write nothing directly. Writes go through reviewed security definer functions that check the caller's role and pin search_path. The anon role has no privileges in public.

Four roles exist: owner, admin, developer and viewer.

AreaWho can read it
Sessions, traces, usage, immersive eventsAll members, including viewers
Agent configuration, key metadata, knowledge, evals, tool manifestsOwners, admins and developers
Provider keys and secret keys (create, remove), webhook secretsOwners and admins
Audit logOwners and admins

supabase/tests/role_access.test.sql proves this for every role. A missing row and a forbidden one look the same to the caller.

Sessions belong to a tenant

A session stores the tenant of the token that started it. Every runtime function that reads or writes a session or its turns takes the tenant from the verified token, never from a body field, and refuses a different one with the same answer as an unknown id. A person who belongs to two organizations cannot continue one organization's conversation under the other. A token without a tenant matches only sessions without one.

Knowledge isolation

Knowledge bases, their sources and their chunks carry the organization. Only owners, admins and developers read them, and members can read chunk text but not vectors. An agent can attach only its own organization's knowledge bases, enforced by a trigger on every agent version.

Uploaded originals live in a private storage bucket. A user can insert only to the exact object path a pending source was issued, and can never read, update or delete. There is no signed-in read policy at all. The only way a person gets a file is a link signed for 5 minutes after the database checks the session, tenant and linkability.

Tenants

Sources and chunks carry an optional tenant_id. Null means shared by every tenant. A session sees platform-wide chunks plus its own tenant's chunks, never another tenant's, on every path: search, source links, the retrieval test and AI checks all take the tenant from the verified token.

Tenant uploads are off by default. When on, they run only through your server, which signs an upload token naming the agent, knowledge base, tenant and user. The runtime reads those values from the token alone, so the browser cannot widen them.

How search filters inside SQL

Retrieval is one service-role function, kb_search, and it is the only path from the runtime to chunk text. It filters inside SQL by:

  1. the session's organization, from the agent's key;
  2. knowledge bases that belong to that organization (another organization's id is dropped);
  3. the tenant: tenant_id is null or tenant_id = <the user token's tenant>;
  4. document access rules, against the claims in the verified user token;
  5. the source's searchable version, so a half-processed file never shows up.

Both the vector and the full-text leg carry the same filters. The runtime passes the values and does no filtering of its own, so there is no query shape that skips them.

Tests prove tenant A never gets tenant B's chunks, nor another organization's (supabase/tests/kb_search.test.sql, plus an end-to-end test against the local stack). Retrieved text reaches the model marked as untrusted data, never reaches the browser, and is removed from stored tool calls when the agent does not store tool data.

Document access rules

A source can carry rules such as {"roles": ["staff"]}. A reader must satisfy every key with one of its values. The rules are checked inside the same SQL functions that return chunks, citations and source links, before ranking and before the result limit.

  • They fail closed. No claims, a missing claim, a case or type mismatch, an oversized claim set, or an empty or corrupt rule all match nothing.
  • A source with no rules stays open.
  • The reader's claims come only from the verified user token. Never from a request body, the model or a tool input.
  • Results never say that a restricted source exists.
  • Setting rules is audited with counts and flags only, never the rules.

Purging a tenant

DELETE /v0/knowledge/tenants/{tenantId} removes every source, chunk and embedding for a tenant, and writes a confirmation record with ids and counts to the organization's deletion log. See Knowledge.

Next steps

On this page