loom.core.authz.elevation

Elevation frames: which scopes an execution may write beyond its own rows.

A frame lives exactly as long as one use-case execution. elevate_scope records a scope in the open frame after checking the decision that justifies it, and asks the sink to flag the open transaction when there is one; the session-settings provider reads elevated_scopes for every later transaction. Tasks spawned inside the execution share the frame object and lose the elevation when it closes. Nothing here knows a database.

Functions

_check(decision, scope, at, permission, catalog)

_clear_added(frame)

_invalidate(sink)

_open_frame()

elevate_scope(scope, decision, *, at, ...)

Record scope as elevated for the rest of the execution.

elevated_scopes()

Scopes elevated by the execution running in this context; empty outside one.

elevation_scope(*, owns_transaction[, sink])

Open a frame for one execution; nested frames inherit and never mutate their parent.

in_execution_frame()

Whether an execution frame is open in this context.

Classes

ElevationSink(*args, **kwargs)

How the frame reaches the transaction that is open right now.

_Frame(owns_transaction, sink, parent, ...)

class loom.core.authz.elevation.ElevationSink(*args, **kwargs)[source]

Bases: Protocol

How the frame reaches the transaction that is open right now.

loom.core.authz.elevation.in_execution_frame()[source]

Whether an execution frame is open in this context.

Return type:

bool

loom.core.authz.elevation.elevated_scopes()[source]

Scopes elevated by the execution running in this context; empty outside one.

Return type:

frozenset[str]

loom.core.authz.elevation.elevation_scope(*, owns_transaction, sink=None)[source]

Open a frame for one execution; nested frames inherit and never mutate their parent.

Parameters:
Return type:

AsyncIterator[None]

async loom.core.authz.elevation.elevate_scope(scope, decision, *, at, permission, catalog)[source]

Record scope as elevated for the rest of the execution.

Raises:
  • RuntimeError – Outside an execution frame.

  • PermissionError – When the decision is denied, its grant’s role lacks permission, or its grant does not cover at.

Parameters:
Return type:

None