Server admin 2: fluxer-proto channel administration #668

Closed
opened 2026-11-15 19:01:07 +00:00 by charles · 1 comment
Owner

Task 2 of the Server administration plan (docs/superpowers/plans/2026-11-15-serveradmin.md, section "### Task 2:"). The plan on the serveradmin branch is the source of truth; this copy is for reading.

Closes: —
Depends on: —

Files:

  • Create: crates/fluxer-proto/src/models/channel_admin.rs, fixtures fixtures/rest/{channel_update_text.json,channel_update_voice.json,channel_update_overwrites.json,channel_positions.json,follower_stats.json}, fixtures/gateway/channel_update_bulk.json
  • Modify: crates/fluxer-proto/src/models/{channel.rs,mod.rs}, crates/fluxer-proto/src/gateway/events.rs, crates/fluxer-proto/tests/spec_contract.rs, README
  • Test: crates/fluxer-proto/tests/channel_admin.rs

Interfaces:

  • Produces: Channel gains rtc_region: Option<String>, voice_connection_limit: Option<u16>, and url if #663 did not add it; ChannelUpdateRequest { name, topic: Option<Option<String>>, rate_limit_per_user, r#type: Option<ChannelType>, url, bitrate, user_limit, voice_connection_limit, rtc_region: Option<Option<String>>, permission_overwrites: Option<Vec<PermissionOverwrite>> } (only set fields; S/channel/ChannelRequestSchemas.ts; the existing EditChannelRequest stays the group-DM body); ChannelPosition { id, position: Option<i32>, parent_id: Option<Option<Snowflake>>, preceding_sibling_id: Option<Option<Snowflake>>, lock_permissions: Option<bool> }; FollowerStats (the answer of GET /channels/{id}/follower-stats, shape from the controller); PermissionOverwrite checked to serialise {id, type: 0|1, allow, deny} with decimal strings and an OverwriteType::Unknown fallback; GatewayEvent::ChannelUpdateBulk { channels: Vec<Channel> } (api/guild/controllers/GuildChannelController.ts).

  • Step 1: Write failing tests: channel_update_only_set_fields, topic_null_clears_and_absent_keeps, rtc_region_null_is_automatic, overwrites_array_decimal_strings, unknown_overwrite_type_kept, positions_body_one_element_as_the_original (the body GuildCommands.moveChannel builds), parent_null_versus_absent, channel_update_bulk_parses, voice_fields_parse, follower_stats_parse, proptest arbitrary_channel_json_never_panics, spec_contract_channel_admin_types.

  • Step 2–5: FAIL → implement → PASS → commit feat(proto): channel administration.

Task 2 of the Server administration plan (`docs/superpowers/plans/2026-11-15-serveradmin.md`, section "### Task 2:"). The plan on the `serveradmin` branch is the source of truth; this copy is for reading. **Closes:** — **Depends on:** — **Files:** - Create: `crates/fluxer-proto/src/models/channel_admin.rs`, fixtures `fixtures/rest/{channel_update_text.json,channel_update_voice.json,channel_update_overwrites.json,channel_positions.json,follower_stats.json}`, `fixtures/gateway/channel_update_bulk.json` - Modify: `crates/fluxer-proto/src/models/{channel.rs,mod.rs}`, `crates/fluxer-proto/src/gateway/events.rs`, `crates/fluxer-proto/tests/spec_contract.rs`, README - Test: `crates/fluxer-proto/tests/channel_admin.rs` **Interfaces:** - Produces: `Channel` gains `rtc_region: Option<String>`, `voice_connection_limit: Option<u16>`, and `url` if #663 did not add it; `ChannelUpdateRequest { name, topic: Option<Option<String>>, rate_limit_per_user, r#type: Option<ChannelType>, url, bitrate, user_limit, voice_connection_limit, rtc_region: Option<Option<String>>, permission_overwrites: Option<Vec<PermissionOverwrite>> }` (only set fields; `S/channel/ChannelRequestSchemas.ts`; the existing `EditChannelRequest` stays the group-DM body); `ChannelPosition { id, position: Option<i32>, parent_id: Option<Option<Snowflake>>, preceding_sibling_id: Option<Option<Snowflake>>, lock_permissions: Option<bool> }`; `FollowerStats` (the answer of `GET /channels/{id}/follower-stats`, shape from the controller); `PermissionOverwrite` checked to serialise `{id, type: 0|1, allow, deny}` with decimal strings and an `OverwriteType::Unknown` fallback; `GatewayEvent::ChannelUpdateBulk { channels: Vec<Channel> }` (`api/guild/controllers/GuildChannelController.ts`). - [ ] **Step 1: Write failing tests**: `channel_update_only_set_fields`, `topic_null_clears_and_absent_keeps`, `rtc_region_null_is_automatic`, `overwrites_array_decimal_strings`, `unknown_overwrite_type_kept`, `positions_body_one_element_as_the_original` (the body `GuildCommands.moveChannel` builds), `parent_null_versus_absent`, `channel_update_bulk_parses`, `voice_fields_parse`, `follower_stats_parse`, proptest `arbitrary_channel_json_never_panics`, `spec_contract_channel_admin_types`. - [ ] **Step 2–5:** FAIL → implement → PASS → commit `feat(proto): channel administration`.
Author
Owner

Independent review: Server admin 2, fluxer-proto channel administration (dd663d99)

There is no PR for this task yet: serveradmin-2-proto-channel-admin exists only as a local branch (commits 2595f2b8 and dd663d99) and has not been pushed. I am posting the review here, on the task issue, for that reason. I reviewed git diff 8c58a73f..dd663d99.

Plan tests (Step 1): all 12 tests exist under the names the plan gives, in tests/channel_admin.rs plus spec_contract_channel_admin_types, and each asserts what the plan describes. For example, positions_body_one_element_as_the_original checks every key and lock_permissions: false, and channel_update_bulk_parses checks that one bad entry is dropped without losing the rest.

Interfaces: all names in the task's Interfaces block exist as written (ChannelUpdateRequest and its 10 fields, ChannelPosition, FollowerStats, OverwriteType::{Role, Member, Unknown(u8)}, GatewayEvent::ChannelUpdateBulk { channels }, Channel.{rtc_region, voice_connection_limit}; url already existed). One deviation: PermissionOverwrite keeps kind: u8 and gets overwrite_type() and role()/member() builders. This is acceptable because fluxer-core/src/guilds.rs reads .kind, and the README documents it for Task 17.

Spot-checks against the original (fluxer-soundboard, ba98441b4):

  • GuildCommands.ts:87-104 channelMovePayload: one element with keys id, parent_id, preceding_sibling_id, lock_permissions false, position. Ids are null when absent (ChannelMoveOperation gives string | null). Matches ChannelPosition::moved and the fixture.
  • ChannelFollowSchemas.ts:19-22: {channel_count, guild_count}. ChannelOverviewTab.tsx:341-345 checks stats.channel_count !== 0, which matches has_followers().
  • ChannelOperationsService.ts:660-666 sends CHANNEL_UPDATE_BULK as {channels: [ChannelResponse]}, with no guild_id. Matches the variant and the fixture.
  • ChannelSchemas.ts: ChannelOverwriteResponse has a numeric type and string allow/deny; voice_connection_limit and rtc_region are nullish. These match the lenient fields.
  • ChannelRequestSchemas.ts:464-476 (positions) and ChannelCommands.updatePermissionOverwrites send the whole array. Matches.

The ChannelUpdateRequestBody anyOf check (the implementer asked me to look at it): it is sound. None of the 11 branches in spec/openapi.json has required or additionalProperties, so matching on keys alone is correct. Branches 0 and 1 hold every key the struct writes, including type, which is limited to the constants 0 or 5. The check does not validate values such as that type constant, but that is the core's job (Task 16).

Invariants: fluxer-core is changed by one struct literal only, and no I/O is added. Every fixture is shaped like the schema its commit message names. The proptest shows server data cannot panic the client. There are no secrets or paths.

Findings

  • minor FollowerStats reads with lenient_default, so an unreadable count becomes 0, has_followers() returns false, and the announcement-off confirm is skipped. In the original, a failed fetch gives null and the confirm is still shown, with the "unknown followers" text. Task 16 should treat a failed or unreadable fetch as unknown, not as zero, or channel_count could become Option<u32>.
  • minor OverwriteType::Unknown only covers values 2-255. An overwrite whose type is above 255 or is a string still fails the whole Channel, because permission_overwrites uses null_to_default and not lenient_vec. Behaviour is unchanged from before this task and nothing panics (it is Malformed on CHANNEL_UPDATE, and the entry is dropped in a bulk event). It is worth a follow-up if Review Focus 7 is read strictly.
  • minor The branch has not been pushed and there is no PR (title Server admin 2: … (#668), body Closes #668).

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passed in a clean review worktree ("all steps passed", 0 failures).

Verdict: approved. No blocking findings and CI is green.

## Independent review: Server admin 2, fluxer-proto channel administration (dd663d99) There is no PR for this task yet: `serveradmin-2-proto-channel-admin` exists only as a local branch (commits 2595f2b8 and dd663d99) and has not been pushed. I am posting the review here, on the task issue, for that reason. I reviewed `git diff 8c58a73f..dd663d99`. **Plan tests (Step 1):** all 12 tests exist under the names the plan gives, in `tests/channel_admin.rs` plus `spec_contract_channel_admin_types`, and each asserts what the plan describes. For example, `positions_body_one_element_as_the_original` checks every key and `lock_permissions: false`, and `channel_update_bulk_parses` checks that one bad entry is dropped without losing the rest. **Interfaces:** all names in the task's Interfaces block exist as written (`ChannelUpdateRequest` and its 10 fields, `ChannelPosition`, `FollowerStats`, `OverwriteType::{Role, Member, Unknown(u8)}`, `GatewayEvent::ChannelUpdateBulk { channels }`, `Channel.{rtc_region, voice_connection_limit}`; `url` already existed). One deviation: `PermissionOverwrite` keeps `kind: u8` and gets `overwrite_type()` and `role()/member()` builders. This is acceptable because `fluxer-core/src/guilds.rs` reads `.kind`, and the README documents it for Task 17. **Spot-checks against the original** (fluxer-soundboard, ba98441b4): - `GuildCommands.ts:87-104` `channelMovePayload`: one element with keys id, parent_id, preceding_sibling_id, lock_permissions false, position. Ids are null when absent (`ChannelMoveOperation` gives `string | null`). Matches `ChannelPosition::moved` and the fixture. - `ChannelFollowSchemas.ts:19-22`: `{channel_count, guild_count}`. `ChannelOverviewTab.tsx:341-345` checks `stats.channel_count !== 0`, which matches `has_followers()`. - `ChannelOperationsService.ts:660-666` sends `CHANNEL_UPDATE_BULK` as `{channels: [ChannelResponse]}`, with no guild_id. Matches the variant and the fixture. - `ChannelSchemas.ts`: `ChannelOverwriteResponse` has a numeric type and string allow/deny; `voice_connection_limit` and `rtc_region` are nullish. These match the lenient fields. - `ChannelRequestSchemas.ts:464-476` (positions) and `ChannelCommands.updatePermissionOverwrites` send the whole array. Matches. **The `ChannelUpdateRequestBody` anyOf check** (the implementer asked me to look at it): it is sound. None of the 11 branches in `spec/openapi.json` has `required` or `additionalProperties`, so matching on keys alone is correct. Branches 0 and 1 hold every key the struct writes, including `type`, which is limited to the constants 0 or 5. The check does not validate values such as that `type` constant, but that is the core's job (Task 16). **Invariants:** fluxer-core is changed by one struct literal only, and no I/O is added. Every fixture is shaped like the schema its commit message names. The proptest shows server data cannot panic the client. There are no secrets or paths. **Findings** - **minor** `FollowerStats` reads with `lenient_default`, so an unreadable count becomes 0, `has_followers()` returns false, and the announcement-off confirm is skipped. In the original, a failed fetch gives `null` and the confirm is still shown, with the "unknown followers" text. Task 16 should treat a failed or unreadable fetch as unknown, not as zero, or `channel_count` could become `Option<u32>`. - **minor** `OverwriteType::Unknown` only covers values 2-255. An overwrite whose `type` is above 255 or is a string still fails the whole `Channel`, because `permission_overwrites` uses `null_to_default` and not `lenient_vec`. Behaviour is unchanged from before this task and nothing panics (it is `Malformed` on `CHANNEL_UPDATE`, and the entry is dropped in a bulk event). It is worth a follow-up if Review Focus 7 is read strictly. - **minor** The branch has not been pushed and there is no PR (title `Server admin 2: … (#668)`, body `Closes #668`). **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passed in a clean review worktree ("all steps passed", 0 failures). **Verdict: approved.** No blocking findings and CI is green.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#668
No description provided.