The per-session scope rule of the access decision, applied to the session LoadOwnedSession returned.
Decides whether contextUser may address an already-loaded session: the AuthorizeSessionAccess
decision, reading the session's conversation only when that decision needs it.
AuthorizeSessionAccess decides a principal without a scope identity — a named user with no magic-link
scope, the usual signed-in caller — from the owner check alone, and refuses a non-owner before it looks at
anything else, so neither needs the conversation read. This function and that one encode the same rule on
purpose and live together for that reason: change the rule there, change the read here. The
AuthorizeLoadedSession table test in sessionAccess.test.ts fails if the two ever disagree.
the session, loaded through the caller's own gate
the authenticated caller; the conversation, when read, is read as this user (RLS applies)
the request-scoped provider
Grace before an incomplete recording is assembled as Partial.
Loads a session under the caller's identity and enforces ownership: UserID === contextUser.ID, then the
scope rule of AuthorizeSessionAccess (every anonymous visitor shares one Anonymous user, so the
session's conversation ExternalID must equal the caller's scope identity). It deliberately does NOT
reject Closed sessions: the final channel-state flush and the recording terminal signal legitimately
arrive after the session closed. Loading as the caller also applies the entity's row-level security.
The server's system user, or null when it is not available. Deciding whether a recording is ready reads the shard entity, which callers (UI users, widget guests) deliberately cannot read; that read is the server's own scheduling decision, made after the caller was authorized, so it runs as this user. With none, nothing is scheduled and the session janitor assembles the recording.
The ledger for one request; contextUser is the caller (used for logging by the procs).
The authenticated caller, or null (answered 401).
Dependencies of CreateRealtimeRecordingRouter; injectable so the routes can be tested without a database.