Expand description
Permission resolution and the management hierarchy (permissions.md).
Pure functions over plain data. The engine is authoritative; clients may run the same functions to drive their UI.
Typical use for one command:
gate(orgate_unbound) on the member’s state and the command’s wire name;requiredfor the command’sRequirement;- a
Resolverbuilt once per member, thenResolver::communityorResolver::channelfor the requirement’s scope, andRequirement::check; - the command’s hierarchy check (
roles,members,overrides,invites,safety) withResolver::partyfor actor and target.
Further pure checks that are plain bit tests on a resolved set are left to the engine:
channel.create under a parent and moving a channel into a category need
MANAGE_CHANNELS in the parent’s chp too (§4.4).
Re-exports§
pub use safety::ActiveLockdown;
Modules§
- invites
- Invitations without escalation (permissions §4.7, specification §8.6 and §8.9).
- members
- Member and membership checks (permissions §4.3, §4.5, §4.6; specification §8.3, §8.9). The required bit of each command is checked by the table first.
- overrides
- Override validation and override-edit checks (permissions §1.2, §2.2, §2.4, §4.4).
- roles
- Role management checks (permissions §4.2, specification §8.4).
cpis the actor’s effective community permissions; the requiredMANAGE_ROLESbit is checked by the table. - safety
- Admission policy and lockdown checks (permissions §3.3, §4.6; specification §8.9–8.10).
Structs§
- Channel
- The channel context of a channel-level resolution.
- Context
- Community-wide inputs shared by every resolution in one request.
- Denial
- A failed permission or hierarchy check.
- Lockdown
- The community’s lockdown row (specification §8.10).
- Lockdown
Restrictions - The restrictions a lockdown names (specification §8.10).
- Override
- A permission override on one channel or category (permissions §2.2).
- Party
- An actor or target member as the hierarchy sees it. Build it with
Resolver::party. - Requirement
- What a command requires (permissions §6, specification §8).
- Resolved
- One resolved permission set (
cporchp). - Resolver
- Per-member state computed once; then
Resolver::communityandResolver::channelare cheap enough to call for every channel of a snapshot. - Role
- A role as the resolver sees it (permissions §2.1).
- Steps
- The masks each step 7 restriction removed, in application order.
- Subject
- The member whose permissions are resolved.
Enums§
- Access
- Who may send the command at all, before any bit is checked.
- Conflict
Reason - Why a state transition does not apply (
CONFLICT). - Denial
Reason - Why a permission check failed, when a specific rule caused it (permissions §6).
- Gate
Denial - Why the gate refused a command.
- Invalid
- A malformed request (
BAD_REQUEST). - Override
Target - Whom an override applies to (permissions §2.2).
- Refusal
- Every way a pure check can refuse a command.
- Scope
- Where the required bits are evaluated.
- Top
- A member’s top position (§2.1). The owner is above every role.
Constants§
- ALL
ALLmeans every known bit, neveru64::MAX(permissions §1.1).- DM_
GRANTS - What both participants of a
dmchannel may always do (specification §8.15). - DM_
IF_ GRANTED - What a participant may do in a
dmchannel only when its roles grant it in the community. - EXPENSIVE_
HISTORY_ DEPTH restrict_expensive: a restricted member reads only the newest this-many sequences of a channel,sequence > head − EXPENSIVE_HISTORY_DEPTH(specification §8.10, §12). One fullmessage.historypage.- EXPENSIVE_
MEMBER_ PAGE restrict_expensive: the most members onemember.listpage returns to a restricted member, who gets only the first page (specification §8.10, §12).- LOCK_
MASK - Bits the channel
lockedflag removes (step 7d). - PENDING_
ALLOWED - Commands a
Pendingmember may issue (specification §6.4, normative).verification.*(P2, reserved) is not listed. - SUSPENDED_
ALLOWED - Commands a
Suspendedmember may issue: the same asPending(specification §6.4). - TABLE
- Every command of the table with its requirement, in specification order.
- TIMEOUT_
KEEP - Bits a timed-out member keeps (step 7a).
- UNBOUND_
ALLOWED - Commands an unbound (negotiated) connection may send (specification §6.1, §8.1):
community.rotationstoo, naming the community in the envelope’scommunity_id(the chain is public and signed; a client needs it to verify a welcome before it can bind). - UNBOUND_
ONLY - Commands that only make sense unbound; a bound connection gets
CONFLICT(§6.1). - WAITING_
MASK - Bits the admission policy’s waiting period withholds: posting, reacting and creating invitations (specification §6.4).
Functions§
- act_on
- H1 then H2, with H2 skipped when the actor targets themself and
self_okis set. - all_in
- The grants of an owner or administrator in a channel.
- applicable
- The channel bits that apply to a channel kind (§1.3).
- base
base(m)for a non-owner (steps 1–2):@everyoneOR the member’s roles;ALLwithADMINISTRATOR; otherwise masked byKNOWN.- channel_
grants grants(m, ch)(steps 3–6) for a non-administrator whose base isbase.- commands
- Every command name of the table.
- community_
dependencies - Implicit dependencies at community level: no attachment, embed or mass mention without
SEND_MESSAGES, no voice bit withoutCONNECT. There is noVIEW_CHANNELgate here: whether a member sees a channel is decided per channel (permissions §3.1). - dependencies
- Implicit dependencies (step 6) at channel level: no channel bit without
VIEW_CHANNEL, thencommunity_dependencies. - gate
- The gate for a connection bound to a member in
state.ProbationandActivepass every bound command, which is then subject to its permissions. - gate_
unbound - The gate for an unbound connection.
- h1
- H1: nobody acts on the owner, except the owner on themself.
- h2
- H2: acting on another member requires
top(T) < top(A); equal positions block andADMINISTRATORdoes not lift it. The owner passes. - h3
- H3: every changed bit must be held (
changed ⊆ held,heldbeingcporchp). - h4
- H4: a role is manageable only strictly below the actor’s top; the owner is exempt.
- h3_
owner_ only - H3 where only the owner is exempt: restriction masks (
newcomer_restrictions, a lockdown’s mask), for which permissions.md §4.6 says “owner exempt” and the specification is silent. So an administrator in probation cannot lift the newcomer mask that binds it (7b). - no_
new_ unknown - §1.2: a command may not set an unknown bit that
olddid not already hold. - required
- The requirement of a command by wire name;
Nonefor a name the table does not know (the engine answersUNSUPPORTED_COMMAND). - with_
dependants - Every bit that
dependencieswould also drop oncemaskis removed: used to attribute a lost dependant to the restriction that removed its prerequisite.