Skip to content
Docs
Changelog

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.

Markdown

  • 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 and the amendment of ADR-0015. (#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.
Edit on GitHubDocumentation is in English.
Cookie settings
We use essential cookies to make our app work. With your consent, we also use optional cookies to improve your experience.

Read our Cookie Policy and Privacy Policy.