Server admin 9b: fluxer-core hierarchy, tabs, moderation capabilities; bulk events in the store (#676) #726

Closed
charles wants to merge 0 commits from serveradmin-9b-core-hierarchy-bulk-events into serveradmin
Owner

Fills admin::perms and teaches the store the two bulk events.

Built

  • admin::perms (spec §3.2, §3.4, §3.5): highest_role(app, guild, user) -> Option<&Role>, is_role_higher(&Role, &Role) (position, then lower id), can_manage_role(app, guild, &Role) (owner always; otherwise hierarchy only, MANAGE_ROLES is the caller's as in useRoleHierarchy), can_manage_target(app, guild, user) (never self; owner manages everyone else incl. uncached members; nobody manages the owner; otherwise known member + highest role above), is_role_locked(app, guild, &Role) (GuildRolesTab.isRoleLocked), moderation_caps(app, guild, user) -> ModerationCaps { nickname, roles, timeout: TimeoutCap::{No, Timeout, Remove}, kick, ban, transfer } (GuildModerationCapabilityUtils.ts + GuildMemberContextMenu.tsx:83-116: kick/timeout/nickname/transfer need a cached member, ban does not; timeout not on administrators), settings_tabs (Overview, Roles, Moderation, Members, Invites, Bans), can_delete_guild, channel_tabs (by type and permissions in the channel; forum/media Permissions only per §17 Q9), can_manage_channels, threads_active (chat.threads.enabled).
  • Store: GUILD_ROLE_UPDATE_BULK replaces each listed role; CHANNEL_UPDATE_BULK applies each channel as CHANNEL_UPDATE (keeps a known last_message_id) and records new ids in the guild. GUILD_UPDATE already replaced the whole guild object; a test pins the new fields.

Tests crates/fluxer-core/tests/admin_perms.rs: role_hierarchy (owner/administrator/moderator/member x above/equal lower id/equal higher id/below/own/@everyone), highest_role_is_position_then_lower_id, target_hierarchy (self, owner, bot, higher, equal, lower, no role, administrator, not cached), moderation_caps_by_permission, timed_out_user_cannot_change_own_nickname, settings_tabs_by_permission, channel_tabs_by_type_and_permission, can_manage_channels_and_threads_active, role_bulk_event_reorders_roles, channel_bulk_event_moves_channels, guild_update_carries_new_fields (fixtures from Tasks 1/2). Local FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green. No display tests involved.

Deviations

  • moderation_caps returns ModerationCaps (as this task's Interfaces block), not Option as Task 13's text mentions; an uncached member gets every row off except ban (owner only).
  • The stock-community exception of "Delete community" is not modelled (discovery does not read single_community): follow-up #725.
  • tests/admin_ports.rs (9a) asserted the two perms stubs were empty; those two lines are replaced by a comment.

Stacked on: serveradmin-9a-core-ports

Closes #676

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

Fills `admin::perms` and teaches the store the two bulk events. **Built** - `admin::perms` (spec §3.2, §3.4, §3.5): `highest_role(app, guild, user) -> Option<&Role>`, `is_role_higher(&Role, &Role)` (position, then lower id), `can_manage_role(app, guild, &Role)` (owner always; otherwise hierarchy only, MANAGE_ROLES is the caller's as in `useRoleHierarchy`), `can_manage_target(app, guild, user)` (never self; owner manages everyone else incl. uncached members; nobody manages the owner; otherwise known member + highest role above), `is_role_locked(app, guild, &Role)` (`GuildRolesTab.isRoleLocked`), `moderation_caps(app, guild, user) -> ModerationCaps { nickname, roles, timeout: TimeoutCap::{No, Timeout, Remove}, kick, ban, transfer }` (`GuildModerationCapabilityUtils.ts` + `GuildMemberContextMenu.tsx:83-116`: kick/timeout/nickname/transfer need a cached member, ban does not; timeout not on administrators), `settings_tabs` (Overview, Roles, Moderation, Members, Invites, Bans), `can_delete_guild`, `channel_tabs` (by type and permissions in the channel; forum/media Permissions only per §17 Q9), `can_manage_channels`, `threads_active` (`chat.threads.enabled`). - Store: `GUILD_ROLE_UPDATE_BULK` replaces each listed role; `CHANNEL_UPDATE_BULK` applies each channel as `CHANNEL_UPDATE` (keeps a known `last_message_id`) and records new ids in the guild. `GUILD_UPDATE` already replaced the whole guild object; a test pins the new fields. **Tests** `crates/fluxer-core/tests/admin_perms.rs`: `role_hierarchy` (owner/administrator/moderator/member x above/equal lower id/equal higher id/below/own/@everyone), `highest_role_is_position_then_lower_id`, `target_hierarchy` (self, owner, bot, higher, equal, lower, no role, administrator, not cached), `moderation_caps_by_permission`, `timed_out_user_cannot_change_own_nickname`, `settings_tabs_by_permission`, `channel_tabs_by_type_and_permission`, `can_manage_channels_and_threads_active`, `role_bulk_event_reorders_roles`, `channel_bulk_event_moves_channels`, `guild_update_carries_new_fields` (fixtures from Tasks 1/2). Local `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green. No display tests involved. **Deviations** - `moderation_caps` returns `ModerationCaps` (as this task's Interfaces block), not `Option` as Task 13's text mentions; an uncached member gets every row off except ban (owner only). - The stock-community exception of "Delete community" is not modelled (discovery does not read `single_community`): follow-up #725. - `tests/admin_ports.rs` (9a) asserted the two perms stubs were empty; those two lines are replaced by a comment. Stacked on: serveradmin-9a-core-ports Closes #676 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
admin::perms gets the original's hierarchy (isRoleHigher, getHighestRole,
canManageRole, canManageTarget, isRoleLocked), the member menu's moderation
capabilities, the community and channel settings tabs by permission and type,
can_delete_guild, can_manage_channels and threads_active. The store applies
GUILD_ROLE_UPDATE_BULK and CHANNEL_UPDATE_BULK (fixtures
guild_role_update_bulk.json from GuildRoleService.ts:1076-1083 and
channel_update_bulk.json from ChannelOperationsService.ts:640-666, both landed
by Task 2/1).

Refs #676

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Author
Owner

Independent review: Server admin 9b (core-hierarchy-bulk-events)

I reviewed 32e111cf..92d0fc0e cold.

1. Tests the plan names. All nine named tests are in crates/fluxer-core/tests/admin_perms.rs, plus two extra ones: highest_role_is_position_then_lower_id and can_manage_channels_and_threads_active.

  • The role_hierarchy table covers owner, administrator, moderator and member against: the role above, equal position with a lower id, equal position with a higher id, below, the user's own role and @everyone.
  • The target_hierarchy table covers self, owner, bot, higher, equal, lower, no role, administrator and not cached.
  • The other tests match the plan. Spec §17 Q9's recommended answer is applied: forum and media channels get the Permissions tab only.

2. Interfaces. These all match Task 9b's block: highest_role -> Option<&Role>, is_role_higher(&Role,&Role), can_manage_role, can_manage_target, is_role_locked, moderation_caps -> ModerationCaps { nickname, roles, timeout: TimeoutCap::{No, Timeout, Remove}, kick, ban, transfer }, settings_tabs, can_delete_guild, channel_tabs, can_manage_channels and threads_active. The 9a stub test change in admin_ports.rs is limited to dropping two asserts that the stubs were empty, which is correct.

3. Invariants. fluxer-core gains no new dependency and does no I/O. No fixtures were added; the tests reuse Task 2's fixtures. Nothing in the change can panic on server data: every lookup is an Option, and an unknown guild or channel allows nothing. No secrets appear. Role positions are compared only in admin::perms.

4. Parity spot-checks against ~/src/fluxer-soundboard.

  • PermissionUtils.isRoleHigher and getHighestRole: higher position wins, then the lower id. Matches.
  • useRoleHierarchy.canManageRole and canManageTarget, plus canManageTargetUser. Matches: the owner short-circuits, nobody manages the owner, an unknown membership is refused for non-owners, and the owner may ban an uncached member.
  • GuildRolesTab.isRoleLocked. Matches, including >= on ids at equal positions.
  • GuildModerationCapabilityUtils and GuildMemberContextMenu: nickname, timeout (target not an administrator; the owner counts as one through guild_permissions), kick, ban (no member needed) and canTransfer. Matches.
  • GuildSettingsConstants order and gates. Matches.
  • ChannelSettingsModalUtils.getAvailableTabs: category keeps Overview and Permissions, thread-only channels have no Invites, and voice Overview also opens with UPDATE_RTC_REGION. Matches.

5. Review Focus.

  • Item 1 (hierarchy) holds.
  • Item 4: GUILD_ROLE_UPDATE_BULK replaces only the listed roles and leaves the others in place. CHANNEL_UPDATE_BULK goes through the same update as CHANNEL_UPDATE, which keeps last_message_id, and registers new channel ids on the guild. No other reducer in core handles ChannelUpdate for guild channels; users.rs handles DM recipients only, so it does not need the bulk event.

Findings

  • minor crates/fluxer-core/src/admin/perms.rs, moderation_caps: Task 13's text (plan line 338) expects moderation_caps to be None for an uncached member, but the Interfaces block, which this branch follows, returns ModerationCaps. Task 13 should check membership itself or wrap the result. This is not blocking: the Interfaces block is what the plan says other tasks consume.
  • minor nickname for oneself: the original also allows the owner to change their own nickname through MANAGE_NICKNAMES && canManageTarget(self) while timed out. The spec's "not oneself" removes that path. An owner cannot be timed out in practice, so there is no visible difference.
  • minor "Delete community" is not hidden for the stock community of a single-community instance. This is deferred to #725, which is already linked.

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree: green ("all steps passed", exit 0; livekit-interop skipped as usual).

Verdict: APPROVED (0 blocking, 3 minor)

## Independent review: Server admin 9b (core-hierarchy-bulk-events) I reviewed `32e111cf..92d0fc0e` cold. **1. Tests the plan names.** All nine named tests are in `crates/fluxer-core/tests/admin_perms.rs`, plus two extra ones: `highest_role_is_position_then_lower_id` and `can_manage_channels_and_threads_active`. - The `role_hierarchy` table covers owner, administrator, moderator and member against: the role above, equal position with a lower id, equal position with a higher id, below, the user's own role and @everyone. - The `target_hierarchy` table covers self, owner, bot, higher, equal, lower, no role, administrator and not cached. - The other tests match the plan. Spec §17 Q9's recommended answer is applied: forum and media channels get the Permissions tab only. **2. Interfaces.** These all match Task 9b's block: `highest_role -> Option<&Role>`, `is_role_higher(&Role,&Role)`, `can_manage_role`, `can_manage_target`, `is_role_locked`, `moderation_caps -> ModerationCaps { nickname, roles, timeout: TimeoutCap::{No, Timeout, Remove}, kick, ban, transfer }`, `settings_tabs`, `can_delete_guild`, `channel_tabs`, `can_manage_channels` and `threads_active`. The 9a stub test change in `admin_ports.rs` is limited to dropping two asserts that the stubs were empty, which is correct. **3. Invariants.** `fluxer-core` gains no new dependency and does no I/O. No fixtures were added; the tests reuse Task 2's fixtures. Nothing in the change can panic on server data: every lookup is an `Option`, and an unknown guild or channel allows nothing. No secrets appear. Role positions are compared only in `admin::perms`. **4. Parity spot-checks against `~/src/fluxer-soundboard`.** - `PermissionUtils.isRoleHigher` and `getHighestRole`: higher position wins, then the lower id. Matches. - `useRoleHierarchy.canManageRole` and `canManageTarget`, plus `canManageTargetUser`. Matches: the owner short-circuits, nobody manages the owner, an unknown membership is refused for non-owners, and the owner may ban an uncached member. - `GuildRolesTab.isRoleLocked`. Matches, including `>=` on ids at equal positions. - `GuildModerationCapabilityUtils` and `GuildMemberContextMenu`: nickname, timeout (target not an administrator; the owner counts as one through `guild_permissions`), kick, ban (no member needed) and `canTransfer`. Matches. - `GuildSettingsConstants` order and gates. Matches. - `ChannelSettingsModalUtils.getAvailableTabs`: category keeps Overview and Permissions, thread-only channels have no Invites, and voice Overview also opens with `UPDATE_RTC_REGION`. Matches. **5. Review Focus.** - Item 1 (hierarchy) holds. - Item 4: `GUILD_ROLE_UPDATE_BULK` replaces only the listed roles and leaves the others in place. `CHANNEL_UPDATE_BULK` goes through the same `update` as `CHANNEL_UPDATE`, which keeps `last_message_id`, and registers new channel ids on the guild. No other reducer in core handles `ChannelUpdate` for guild channels; `users.rs` handles DM recipients only, so it does not need the bulk event. **Findings** - *minor* `crates/fluxer-core/src/admin/perms.rs`, `moderation_caps`: Task 13's text (plan line 338) expects `moderation_caps` to be `None` for an uncached member, but the Interfaces block, which this branch follows, returns `ModerationCaps`. Task 13 should check membership itself or wrap the result. This is not blocking: the Interfaces block is what the plan says other tasks consume. - *minor* `nickname` for oneself: the original also allows the owner to change their own nickname through `MANAGE_NICKNAMES && canManageTarget(self)` while timed out. The spec's "not oneself" removes that path. An owner cannot be timed out in practice, so there is no visible difference. - *minor* "Delete community" is not hidden for the stock community of a single-community instance. This is deferred to #725, which is already linked. **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree: green ("all steps passed", exit 0; livekit-interop skipped as usual). **Verdict: APPROVED (0 blocking, 3 minor)**
Author
Owner

Merged into serveradmin by hand (the merge API returns 405); the commits are in the branch.

Merged into `serveradmin` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-16 00:34:11 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.