Role Checks
A permission says what a viewer may do to a node: read it, update it, delete it. A role says what the viewer is on it: the Underwriter on this cedent, the Pricer on this desk. A business step that only an Underwriter may take, such as binding a submission, asks the role question. Two underwriters and a broker may all hold Update on the submission, but only the underwriters may bind it.
// live: re-emits on every grant, deny, membership, policy or lock change
IObservable<bool> held = hub.HoldsRole(nodePath, "Underwriter"); // the current viewer
IObservable<bool> held = hub.HoldsRole(nodePath, userId, "Underwriter"); // an explicit identity
IObservable<bool> any = hub.HoldsAnyRole(nodePath, userId, ["Underwriter", "Pricer"]); // any-of
One fold, never two
HoldsRole reads the same role fold as GetEffectivePermissions (PermissionEvaluator.ObserveRoleFold). The
permission fold turns that role set into permissions; HoldsRole asks whether the role is in it. Both consume the
same observable, so a role check and a permission check cannot disagree about which grant applies:
| Input | What it does to a held role |
|---|---|
| A grant on the node's own scope | Held there and below. |
| A grant on an ancestor | Held below when the role is inheritable (Role.IsInheritable, default true). A role declared isInheritable: false is held only on the scope it was assigned on. |
| A grant on a sibling or another partition | Not held. Only the target path's own scope chain is consulted. |
Denied at or below a grant |
Not held from that scope down. Denied wins. |
A _Policy that breaks inheritance |
Clears what came from above it. |
A _Policy permission cap |
No effect. A cap limits permissions, not roles. |
| A group grant | Held by the group's members, transitively, wherever the group lives. |
A grant to Public |
Held by every signed-in viewer, as the permission fold ORs the Public leg in. |
| An account lock | Nothing is held. |
A role id no Role node declares |
Never held. An undeclared custom role confers nothing, in both folds. |
System holds every role, as it holds every permission. The cache hydrator and a hub credential hold none. On an
instance with Access:DenyAnonymous, a logged-out viewer holds none.
Where the answer comes from
AddRowLevelSecurity() configures both delegates on a hub: the EffectivePermissionsDelegate and the
HeldRoleDelegate. A hub built without it, such as a session hub or an execution hub, falls back to the
mesh hub's role delegate. It never falls back to the ungated default. Only a mesh built with no RLS at all
answers true everywhere, matching its Permission.All.
Declaring a role
A custom role is content, never derived (policy declared-not-derived): a Role node at Role/{id}. A package
that needs one ships it, and a grant names it in an AccessAssignment:
{ "id": "Underwriter", "namespace": "Role", "nodeType": "Role",
"content": { "$type": "Role", "id": "Underwriter", "displayName": "Underwriter", "permissions": "Read" } }
{ "id": "anna_Access", "namespace": "CedentA/_Access", "nodeType": "AccessAssignment",
"content": { "$type": "AccessAssignment", "accessObject": "anna",
"roles": [ { "role": "Underwriter" } ] } }
Giving a person a role is a grant like any other. It is made through a governed activity or by an admin on that scope, never in bulk by a package.
Who holds a role — the lookups
Three live lookups answer the questions a person asks about roles. All three come from the AccessAssignment nodes,
and each row's Holds column is the HoldsRole verdict, so a lookup and a role check always agree.
| Lookup | Where it shows | What it lists |
|---|---|---|
hub.GetRoleHolders(scope, roleId?) |
Every node's Settings → Roles tab | Every assignment on the scope and above it: Direct (assigned here), Inherited (assigned on an ancestor) or Via group G (a group's grant listed once for the group and once for each member). |
hub.GetHoldersOfRole(roleId) |
The Role node's page | Every scope the role is assigned on, mesh-wide. |
hub.GetRolesOf(userId) |
A user's Roles area (/{user}/Roles) |
Every role the user is assigned, directly or through a group, and where. |
A denied assignment appears as a row with Denied set, and the subject's Holds is false from that scope down.
Membership is not leaked. A row is shown only to a viewer who may manage access on its scope. That is the
Delete permission, the same right the Access Control page requires before it grants anything. Anyone else gets
no rows and no count: GetRoleHolders reports Visible: false, and the other two lookups leave those scopes out. A
user always sees their own roles.
🚨 GetHoldersOfRole and GetRolesOf read every assignment in the mesh, explicitly across partitions. That read
was measured as a slow fan-out (nodeType:AccessAssignment path:- scope:Subtree). It is therefore not a fold read and
is not listed in SecurityQueries.AllShapes: only these two on-demand pages issue it, through one cached subscription
per process. The permission fold never issues it.
The Role page: what the role is and what it may do
A Role node's page shows the role's name and description, its permissions and whether it is inheritable. It also
shows what it may do, beyond the permissions, from the sources the role declares in Role.UsagesFrom: node
paths whose RoleUsages area (reference id = the role id) lists the steps that require it, generated from their
own definitions. The Process package's Process/Roles is such a source and lists every process move that asks for
the role. Below that, the page shows who holds it.
Gating a process move on a role
The Process package (Process/Guide) declares a move's roles with .RequiresRole("Underwriter"), any-of for
several. The move then:
- Is not visible without the role. The … menu and the process page leave it out; it is not shown disabled.
- Opened directly at
/{node}/Process/{move}, its page says which role it needs and shows no button. - Is refused on the server. Taking the move asks
HoldsRoleagain for the viewer taking it, so a stale button or a posted click is refused by the move'sROLE-{role}rule. - Follows the grant live. Granting the role makes the move appear without a reload; revoking it removes it.
Proven by
test/MeshWeaver.Graph.Test/HoldsRoleTest.cs covers these cases: a grant on the node's scope, an inheritable grant
on an ancestor, a grant on another partition, a deny below a grant, a group grant, a non-inheritable role, an
undeclared role, the live flip on grant and revoke on one subscription, and the current-viewer overload under
TestUsers.DevLogin personas. The lookups are covered too: they list a granted persona, a group member through
the group, and a denial as a denial; they stop listing a revoked grant; a viewer who may not manage access (no role,
an Underwriter, an admin of another cedent) sees no membership; and a user sees their own roles.