Task 9: Guilds and channels domain (#9) #43
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/9-core-guilds-channels"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The guilds and channels domains of
fluxer-core(Foundation plan, Task 9; spec §4).guilds.rs:Guilds { by_id }ofGuildRecord { guild, roles, channels, members, member_count, unavailable }, reduced fromREADY,GUILD_CREATE/UPDATE/DELETE,CHANNEL_CREATE/UPDATE/DELETE(channel id set),GUILD_ROLE_*andGUILD_MEMBER_*.channels.rs:Channels { by_id }holding guild channels and DMs, reduced fromREADY(guilds[].channels,private_channels),GUILD_CREATE/DELETEandCHANNEL_*.selectors/sidebar.rs:guild_order,channel_tree(SidebarSection),can_view,dm_list.app.rs/lib.rs: the two stub structs are replaced by the real ones andApp::applycalls their reducers. README updated.Stacked on: task/8-core-store-session
How it was tested
crates/fluxer-core/tests/guilds_channels.rs, 18 tests throughApp::applywithfixtures/gateway/{ready,guild_create,channel_update}.json: the six the plan names (can_view_respects_role_and_member_overwriteshas its 4 cases) plus owner/administrator, base role permissions, unknown guild/member, a secondREADY,GUILD_CREATEover an unavailable stub,GUILD_UPDATE, role and member events, and logout. Tests were committed failing first.cargo xtask ciis green locally.Deviations and decisions the plan leaves open
App::applyfor these two domains, and a logout empties both (so a dispatch already on its way cannot repopulate the store, and nothing leaks into the next account). Task 12's cached-READY path will need to feed the store its own way.{id, unavailable}) that was never seen in full gets a record with a placeholderGuild(empty name, owner id 0), becauseGuildRecord.guildis not optional in the plan. An unavailable stub for a known guild only marks it; nothing is forgotten.can_viewfollows the fork'scomputePermissions(role overwrites of the member's roles are combined, allow wins over deny, then the member overwrite). Not ported: the fork's "visiting" guild mode and the MFA-elevated-permission mask, neither of which affectsVIEW_CHANNELfor a member. With no@everyonerole known the base is empty (the fork falls back toDEFAULT_PERMISSIONS).channel_tree: uncategorised channels come first as acategory: Nonesection (omitted when empty); a category is listed when the user may view it or it has a visible channel; threads are not rows; a channel whoseparent_idis not a known category is listed as uncategorised; channel kinds unknown to the client are listed as text-like.dm_listsorts bylast_message_id, falling back to the channel's own id for conversations without messages;pinned_dmsis not applied yet.CHANNEL_UPDATEwithoutlast_message_idkeeps the known one.GUILD_ROLE_DELETEalso strips the role from loaded members.member_countis adjusted on member add (new members only) and remove.Closes #9
🤖 Generated with Claude Code
Independent review: Task 9 (core-guilds-channels) at
e753f32Scope:
git diff cacedcb..e753f32(8 files, all incrates/fluxer-core).Checks
tests/guilds_channels.rsand assert what the plan says againstfixtures/gateway/ready.json(ready_populates_guilds_channels_and_dms,channel_tree_groups_by_category_and_sorts,guild_order_follows_user_settings_then_joined_at,can_view_respects_role_and_member_overwriteswith its 4 numbered cases,channel_delete_removes_from_tree,guild_delete_unavailable_keeps_record_marked), plus 12 extra. Failing-first commitdf15ba9precedes the implementation.Guilds { by_id },GuildRecord { guild, roles: BTreeMap, channels: BTreeSet, members: HashMap, member_count, unavailable },Channels { by_id },guild_order,channel_tree -> Vec<SidebarSection { category: Option<Channel>, channels: Vec<Channel> }>,can_view(app, &Channel),dm_listall present as written. Selectors are exported fromfluxer_core::selectors(not the crate root).cargo xtask ciin the review worktree: green (fmt, clippy, deny, core-isolation, tests; 18/18 inguilds_channels; screenshot tests skipped as configured).can_viewcompared with the fork'scomputePermissions: faithful for the non-visiting path.Findings
crates/fluxer-core/src/channels.rs(ChannelCreate/ChannelUpdate): the payload'sguild_idis stored as sent. If an update for a known guild channel ever arrived withoutguild_id, the stored channel would lose it andcan_viewwould treat it as a DM (always visible) while it stays in the guild's tree. The fork'smapChannelToResponsealways sendsguild_id, so this is not reachable today; keeping the knownguild_idon update (as is done forlast_message_id) would close it.crates/fluxer-core/src/app.rs: gateway dispatches are dropped for these two domains unlessAuth::LoggedIn. Correct for the logout race (tested), but Task 12's cached-READY path cannot populate the store before login completes without changing this gate. Should be afollow-upissue or a note on Task 12.crates/fluxer-core/src/selectors/sidebar.rscan_view: a missing@everyonerole yields an empty base where the fork usesDEFAULT_PERMISSIONS; "visiting" guilds are not handled. Fails closed (channels hidden), display only.crates/fluxer-core/src/guilds.rs:GUILD_UPDATEignoresrolescarried on the guild object (record.rolesonly changes via role events), and a never-loaded unavailable guild gets a placeholderGuild(empty name, owner id 0); UI tasks must checkunavailablebefore rendering the name.dm_listignorespinned_dms(not required by the plan).app.rsandlib.rsare outside the task's Files list (needed to replace the stubs); Tasks 10/11 will conflict there mechanically.Verdict: APPROVE — 0 blocking, 5 minor. Remote runners not checked (integrator's job).