# One request authority decides who acts

Session authority, the captured scope, membership and the tenant handle moved into one module that the procedure builders, the files gateway, the tool authorization and MCP all ask. Two behaviours became the same everywhere.

- **One module, four callers.** `packages/api/src/platform/rpc/request-authority.ts` answers who is acting, at the `request` authority (the signed snapshot, at most 60 seconds old, or the database) or the `database` authority (read now), in which Active Organization, with which Org role and on which `app_tenant` handle. The procedure builders, the files gateway, the tool authorization and the MCP context ask it and translate its refusals into their own errors; before, three of them each read sessions, compared them, queried `member` and opened tenant handles. See [backend conventions](/docs/development/backend-conventions#one-module-decides-who-acts) and the amendment of [ADR-0015](/docs/adr/0015-server-reads-the-session-from-the-cookie-cache). ([#245](https://github.com/CarlosZiegler/fofo/pull/245))
- **A changed Active Organization is refused everywhere.** `uploads.prepare`, `uploads.resume`, `uploads.signPart` and `documents.prepareText` now answer FORBIDDEN ("The active organization changed.") when the database session names another Active Organization than the request's snapshot, as the files gateway and the agent tools already did. They used the database's Organization silently. A client that sends the captured scope already got a 409 in that case.
- **The database authority reads membership again.** A request-level check still reads `member` once per request. A database-level check (tools, tool approvals, presigned URLs, the gateway's minting operations) reads it now, so a tool call inside a long assistant stream is refused once the Member is removed, as before, and so is any other database-level check.
- **For template users.** `Context` carries `authority` instead of `authoritativeSession`, `membershipRole`, `rpcScopeHeader` and `mcpAccessToken`. Use `orgUserProcedure` where you wrote `userProcedure.use(requireActiveOrganization)`; `markAuthoritative` is gone, the builders `userProcedure`, `orgUserProcedure`, `adminProcedure` and `platformProcedure` are the authoritative ones. `tenantDatabase` may be imported only under `packages/api/src/platform/rpc/` (lint). In tests, `makeContext({ session, databaseSession, scopeHeader, accessToken })` builds the real authority over the sessions you give it.
