~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The console's role editor shows what a permission set gives

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:console/role-sets

A role holding include:fyi.opensocial.authModerate or authManageGroup showed every action the set gives as ticked, and unticking one saved nothing different, since the set stayed. The roles editor now offers the sets as choices of their own, shows what a set gives as held because of it, and can change a role in place.

Claude Opus 5.5 · high effort

What changes

The roles editor. Each role's row ends in a ⋯ menu with Change and Delete. Change opens Change this role, which works like Create a role. Under Running the group, the group's three permission sets are choices of their own: Profile and rules (authManageProfile), Moderation (authModerate) and The whole group (authManageGroup, which is group.configure's scope, so group.configure is no longer an action you tick on its own). An action a ticked set gives shows ticked and greyed, with a short line naming the set ("Comes with moderation"). A smaller set The whole group covers shows the same way. To take one of those away, untick the set, or tick a smaller one, then tick the actions you want one by one. What a role has through scopes the editor doesn't show (Admin's space:*?manage=create&manage=delete, space:*?collection=*) says "Comes with its other permissions" and is kept as it was. Saving writes what the dialog shows: the ticked sets and actions, plus the role's other scopes unchanged. An action ticked on its own under a set stays ticked underneath and is still saved, so a moderator's space:*?collection=com.atproto.label.record (labels in every space, wider than the set's) is kept.

Escalation. The editor offers only what the host would accept. getGroup now tells a member, as viewer.grantable, which of the actions' scopes and the authManageProfile and authModerate sets they hold enough of to add to a role. It uses the same check as a role write (expanded + covers, ScopeNotHeld). The editor shows a set or action if it's grantable or the role already has it (to take it away). It lists Change and Delete only for roles the viewer may assign, and in People with it can give, only roles they may assign (or the role already lists). A member whose role holds only authManageGroup, for example, isn't offered label (labels in every space) or space.*.

getGroup. Each scope in a role's binding now also says actions, what the host reads it as granting (optional actions on fyi.opensocial.defs#scopeRef). The viewer's grantable (optional, members only) is on #viewerState. Both only add to the schema.

Docs. The rules-and-roles guide covers the sets, has a new "How do I change a role?" section with two new pictures, and its delete steps now go through the menu; just shots redrew it. docs/design/membership.md describes grantable, the per-scope actions and the editor; docs/reference/api.md mentions grantable. A look seed, roles, after full, adds a role with single actions only, and a steward role holding only authManageGroup, which dan holds.

Why

The editor showed what the host reads a role as granting (binding actions), but saved only the scopes it had boxes for and kept every other scope, the sets included. So it could show nothing true about why an action was held, and unticking it did nothing. Making the set a choice of its own and greying what it gives keeps what's shown and what's saved the same. I asked the host for what a member may give, instead of working out covers again in TypeScript, so the editor and the host's refusal can't drift apart.

Sets are tick boxes, not a single choice of tier, because authManageProfile and authModerate don't contain each other: a role may carry both, and a single choice couldn't show it. The whole group contains both, and shows them greyed as coming with it.

How it was checked

  • crates/group-host/tests/groups.rs: the founder's grantable is every action's scope and both sets. A plain member's is empty. A member holding only authModerate may give mod.read, mod.resolve, invite, admit, eject, role.assign and authModerate, but not label, the profile set, space.* or group.configure. The admin binding's scopes carry their actions. Run locally: cargo test -p group-host --test groups passes.
  • harness/e2e/flows.spec.mjs "defining a role, then giving it less": creates a role with Moderation (admit ticked and disabled), then changes it. Unticking Moderation and ticking invite saves a role whose actions are exactly invite.
  • npm run check (svelte-check, no warnings), harness/strings.mjs, layers.mjs, dialogs.mjs, just lex, just fmt, harness/docs.mjs pass locally. just shots docs/guides/rules-and-roles.md redrawn.
  • Looked at with just look: Admin (The whole group), Moderator (Moderation plus labels everywhere), Greeter (single actions), Create a role as dan (steward, authManageGroup only: no label or space.* offered), the ⋯ menu, on a phone and in the dark.
  • The full test suite under the coverage gate, e2e and just shots --check are left to CI.

Shortcomings

  • If a dialog is cancelled, its ticks stay as left until the page is drawn again (as Change roles behaves).
  • What the role has beyond the sets and actions (raw scopes such as repo:*) can't be edited here. The editor says so ("Comes with its other permissions") and the guide points to the terminal.
  • A fresh reviewer looked at the pictures. Fixed: the change dialog's intro used "take away", and a covered set lost its own line. Not changed here: the older labels "It may", "Its name" and "Its key"; the roles list's group.configure tag (the host's action name, where the dialog says The whole group); and the browser's grey for ticked boxes that can't be unticked, which is faint in light mode.
  • Nobody can reach the roles tab without group.configure, which is authManageGroup, so "can't give The whole group" can't happen in the console. The escalation case drawn is a steward who can't give labels in every space or the space actions.

admin-after-alice-desktop-light.png

mod-phone-alice-phone-dark.png

change-1-alice-desktop-light.png

dan-create-dan-desktop-light.png

rules-role-made.png

Approved

This pull makes the roles editor offer the permission sets as choices of their own and shows what a set gives as ticked and greyed. It also adds a Change dialog for a role, and it adds viewer.grantable and per-scope actions to getGroup. I read the Rust, lexicon, actions.ts, RoleFields.svelte, RolesEditor.svelte, settings.ts and the roles page. I did not read the tests, docs, shots, seeds, messages or CSS.

I found nothing that must change.

  • Escalation: grantable uses the same expanded and covers check as a role write, so the editor and the host's refusal stay in step.
  • Saved scopes: the form saves the ticked sets and actions plus the role's other scopes unchanged. A ticked action under a set is kept by a hidden input, because a disabled box isn't submitted.
  • Not covered: I did not run anything.
Merged as 41016b1