- One module, four callers.
packages/api/src/platform/rpc/request-authority.tsanswers who is acting, at therequestauthority (the signed snapshot, at most 60 seconds old, or the database) or thedatabaseauthority (read now), in which Active Organization, with which Org role and on whichapp_tenanthandle. 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, queriedmemberand opened tenant handles. See backend conventions and the amendment of ADR-0015. (#245) - A changed Active Organization is refused everywhere.
uploads.prepare,uploads.resume,uploads.signPartanddocuments.prepareTextnow 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
memberonce 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.
Contextcarriesauthorityinstead ofauthoritativeSession,membershipRole,rpcScopeHeaderandmcpAccessToken. UseorgUserProcedurewhere you wroteuserProcedure.use(requireActiveOrganization);markAuthoritativeis gone, the buildersuserProcedure,orgUserProcedure,adminProcedureandplatformProcedureare the authoritative ones.tenantDatabasemay be imported only underpackages/api/src/platform/rpc/(lint). In tests,makeContext({ session, databaseSession, scopeHeader, accessToken })builds the real authority over the sessions you give it.
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.
Edit on GitHubDocumentation is in English.