Skip to main content

Module permissions

Module permissions 

Source
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:

  1. gate (or gate_unbound) on the member’s state and the command’s wire name;
  2. required for the command’s Requirement;
  3. a Resolver built once per member, then Resolver::community or Resolver::channel for the requirement’s scope, and Requirement::check;
  4. the command’s hierarchy check (roles, members, overrides, invites, safety) with Resolver::party for 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). cp is the actor’s effective community permissions; the required MANAGE_ROLES bit 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).
LockdownRestrictions
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 (cp or chp).
Resolver
Per-member state computed once; then Resolver::community and Resolver::channel are 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.
ConflictReason
Why a state transition does not apply (CONFLICT).
DenialReason
Why a permission check failed, when a specific rule caused it (permissions §6).
GateDenial
Why the gate refused a command.
Invalid
A malformed request (BAD_REQUEST).
OverrideTarget
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
ALL means every known bit, never u64::MAX (permissions §1.1).
DM_GRANTS
What both participants of a dm channel may always do (specification §8.15).
DM_IF_GRANTED
What a participant may do in a dm channel 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 full message.history page.
EXPENSIVE_MEMBER_PAGE
restrict_expensive: the most members one member.list page returns to a restricted member, who gets only the first page (specification §8.10, §12).
LOCK_MASK
Bits the channel locked flag removes (step 7d).
PENDING_ALLOWED
Commands a Pending member may issue (specification §6.4, normative). verification.* (P2, reserved) is not listed.
SUSPENDED_ALLOWED
Commands a Suspended member may issue: the same as Pending (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.rotations too, naming the community in the envelope’s community_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_ok is 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): @everyone OR the member’s roles; ALL with ADMINISTRATOR; otherwise masked by KNOWN.
channel_grants
grants(m, ch) (steps 3–6) for a non-administrator whose base is base.
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 without CONNECT. There is no VIEW_CHANNEL gate 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, then community_dependencies.
gate
The gate for a connection bound to a member in state. Probation and Active pass 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 and ADMINISTRATOR does not lift it. The owner passes.
h3
H3: every changed bit must be held (changed ⊆ held, held being cp or chp).
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 old did not already hold.
required
The requirement of a command by wire name; None for a name the table does not know (the engine answers UNSUPPORTED_COMMAND).
with_dependants
Every bit that dependencies would also drop once mask is removed: used to attribute a lost dependant to the restriction that removed its prerequisite.