Server admin 3: fluxer-proto members, bans, member search, invite events, error codes (#669) #711

Closed
charles wants to merge 0 commits from serveradmin-3-proto-members-bans-invites into serveradmin
Owner

What

fluxer-proto types and server-shaped fixtures for member moderation, bans, the members page, the ban and invite events and the server administration error codes (plan Task 3, spec §3.5, §5).

  • models::moderation: MemberUpdateRequest { nick: Option<Option<String>>, roles, communication_disabled_until: Option<Option<Timestamp>>, timeout_reason } with nick / roles / timeout / remove_timeout builders (blank nick is null, reason only when non-empty, as GuildMemberCommands.ts timeoutPatch); BanCreateRequest { delete_message_seconds, reason, ban_duration_seconds } (all three always, reason: null when empty, as banMemberRequest) with the server limits as constants; GuildBan (+ GuildBan::list_from_value, lenient); MemberSearchRequest (Default = 25 per page, joinedAt, desc; filters only when set), MemberSearchResponse, MemberSearchResult (+ user_created_at()), MemberSearchSupplemental, MemberSort, JoinSourceType with Unknown(i32).
  • GatewayEvent::{GuildBanAdd { guild_id, user: UserRef }, GuildBanRemove { .. }, InviteCreate(Box<InviteMetadata>), InviteDelete { code, channel_id: Option, guild_id: Option }}; moved from UNTYPED_IN_FOUNDATION to TYPED_DISPATCH_NAMES.
  • Errors: API codes SUDO_SECOND_FACTOR_REQUIRED, TWO_FACTOR_REQUIRED, RESOURCE_LOCKED, MAX_GUILD_ROLES, UNKNOWN_ROLE, UNKNOWN_MEMBER (the others already existed); errors::validation::{USER_IS_NOT_BANNED, GUILD_FEATURE_NOT_TOGGLEABLE, CANNOT_REORDER_EVERYONE_ROLE, TIMEOUT_CANNOT_EXCEED_365_DAYS, MUST_ENABLE_2FA_BEFORE_REQUIRING_FOR_MODS, INVALID_PASSWORD, INVALID_MFA_CODE}; ApiErrorBody::field_errors() -> Vec<(&str, &str)>, ApiErrorBody::is_sudo_verification_failure() and errors::SUDO_VERIFICATION_FIELDS (the original isSudoVerificationFailure).

Fixture sources are named in commit 2c3c964e (server schema / service file and line for each).

Testing

  • tests/moderation.rs: all the tests the plan names, including proptests arbitrary_ban_json_never_panics and arbitrary_member_search_json_never_panics; spec_contract_moderation_types in tests/spec_contract.rs (answers through check, request bodies against GuildMemberUpdateRequest, MyGuildMemberUpdateRequest, GuildBanCreateRequest, GuildMemberSearchRequest, enums against the schema).
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. The first run hit a flaky, unrelated fluxer-ui timing test (window_input_updates_last_input), filed as #709; the rerun passed. No display tests needed (no UI change).

Deviations from the plan

  • InviteCreate(Box<InviteMetadata>) rather than unboxed, like the other large variants.
  • The validation codes live in errors::validation (as the existing CANNOT_LEAVE_GUILD_AS_OWNER), not at the top level: the server sends them nested in INVALID_FORM_BODY.
  • field_errors() is on ApiErrorBody (this crate), since fluxer-proto has no ApiError.
  • MemberSearchRequest also has user_created_at_gte/lte, join_source_type and source_invite_code, which the original sends; limit, offset, sort_by, sort_order are plain values (always sent, as the original does).
  • MemberSearchResult is the server flat shape (user fields + supplemental), not a nested member.
  • Also touched outside the Files list: tests/models_roundtrip.rs (every REST fixture must be registered there; has_mfa/methods of error_sudo_required.json listed as ignored).

Closes #669

🤖 Generated with Claude Code

## What `fluxer-proto` types and server-shaped fixtures for member moderation, bans, the members page, the ban and invite events and the server administration error codes (plan Task 3, spec §3.5, §5). - `models::moderation`: `MemberUpdateRequest { nick: Option<Option<String>>, roles, communication_disabled_until: Option<Option<Timestamp>>, timeout_reason }` with `nick` / `roles` / `timeout` / `remove_timeout` builders (blank nick is `null`, reason only when non-empty, as `GuildMemberCommands.ts` `timeoutPatch`); `BanCreateRequest { delete_message_seconds, reason, ban_duration_seconds }` (all three always, `reason: null` when empty, as `banMemberRequest`) with the server limits as constants; `GuildBan` (+ `GuildBan::list_from_value`, lenient); `MemberSearchRequest` (`Default` = 25 per page, `joinedAt`, `desc`; filters only when set), `MemberSearchResponse`, `MemberSearchResult` (+ `user_created_at()`), `MemberSearchSupplemental`, `MemberSort`, `JoinSourceType` with `Unknown(i32)`. - `GatewayEvent::{GuildBanAdd { guild_id, user: UserRef }, GuildBanRemove { .. }, InviteCreate(Box<InviteMetadata>), InviteDelete { code, channel_id: Option, guild_id: Option }}`; moved from `UNTYPED_IN_FOUNDATION` to `TYPED_DISPATCH_NAMES`. - Errors: API codes `SUDO_SECOND_FACTOR_REQUIRED`, `TWO_FACTOR_REQUIRED`, `RESOURCE_LOCKED`, `MAX_GUILD_ROLES`, `UNKNOWN_ROLE`, `UNKNOWN_MEMBER` (the others already existed); `errors::validation::{USER_IS_NOT_BANNED, GUILD_FEATURE_NOT_TOGGLEABLE, CANNOT_REORDER_EVERYONE_ROLE, TIMEOUT_CANNOT_EXCEED_365_DAYS, MUST_ENABLE_2FA_BEFORE_REQUIRING_FOR_MODS, INVALID_PASSWORD, INVALID_MFA_CODE}`; `ApiErrorBody::field_errors() -> Vec<(&str, &str)>`, `ApiErrorBody::is_sudo_verification_failure()` and `errors::SUDO_VERIFICATION_FIELDS` (the original `isSudoVerificationFailure`). Fixture sources are named in commit 2c3c964e (server schema / service file and line for each). ## Testing - `tests/moderation.rs`: all the tests the plan names, including proptests `arbitrary_ban_json_never_panics` and `arbitrary_member_search_json_never_panics`; `spec_contract_moderation_types` in `tests/spec_contract.rs` (answers through `check`, request bodies against `GuildMemberUpdateRequest`, `MyGuildMemberUpdateRequest`, `GuildBanCreateRequest`, `GuildMemberSearchRequest`, enums against the schema). - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. The first run hit a flaky, unrelated `fluxer-ui` timing test (`window_input_updates_last_input`), filed as #709; the rerun passed. No display tests needed (no UI change). ## Deviations from the plan - `InviteCreate(Box<InviteMetadata>)` rather than unboxed, like the other large variants. - The validation codes live in `errors::validation` (as the existing `CANNOT_LEAVE_GUILD_AS_OWNER`), not at the top level: the server sends them nested in `INVALID_FORM_BODY`. - `field_errors()` is on `ApiErrorBody` (this crate), since `fluxer-proto` has no `ApiError`. - `MemberSearchRequest` also has `user_created_at_gte/lte`, `join_source_type` and `source_invite_code`, which the original sends; `limit`, `offset`, `sort_by`, `sort_order` are plain values (always sent, as the original does). - `MemberSearchResult` is the server flat shape (user fields + `supplemental`), not a nested member. - Also touched outside the Files list: `tests/models_roundtrip.rs` (every REST fixture must be registered there; `has_mfa`/`methods` of `error_sudo_required.json` listed as ignored). Closes #669 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fixtures shaped like the server source (fork ~/src/fluxer-soundboard, ba98441b4):
- rest/member_update_{nick,timeout}.json: GuildMemberUpdateRequest,
  packages/schema/src/domains/guild/GuildRequestSchemas.ts:132-169, bodies as
  fluxer_app/src/features/member/commands/GuildMemberCommands.ts timeoutPatch (:56)
- rest/ban_create.json: GuildBanCreateRequest, GuildRequestSchemas.ts:302-330, body as
  fluxer_app/src/features/guild/commands/GuildCommands.ts banMemberRequest (:130)
- rest/bans.json: GuildBanResponse, GuildMemberSchemas.ts:42-48, written by
  fluxer_api/src/api/guild/GuildModel.ts mapBanWithUser (:208)
- rest/member_search_{request,response,indexing}.json: GuildMemberSearchSchemas.ts,
  fluxer_api/src/api/guild/controllers/GuildMemberSearchController.ts (mapSearchableMember,
  createEmptySearchResponse), request as guild_members_page/SearchApi.ts
  buildMemberSearchParams
- rest/error_sudo_required.json: packages/errors/src/domains/auth/SudoModeRequiredError.ts;
  rest/error_sudo_invalid.json: InputValidationError.fromCode('password', INVALID_PASSWORD),
  fluxer_api/src/api/auth/services/SudoVerificationService.ts:111
- gateway/guild_ban_{add,remove}.json: fluxer_api/src/api/guild/services/
  GuildModerationService.ts:196-203, :275-282
- gateway/invite_{create,delete}.json: fluxer_api/src/api/invite/InviteService.ts:480-528

Refs #669

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MemberUpdateRequest, BanCreateRequest, GuildBan, MemberSearchRequest/Response/Result,
JoinSourceType with an Unknown fallback, GatewayEvent::{GuildBanAdd, GuildBanRemove,
InviteCreate, InviteDelete}, the server administration error codes, and
ApiErrorBody::{field_errors, is_sudo_verification_failure}.

Refs #669

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #669

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Independent review: Server admin 3 (proto members, bans, member search, invite events, error codes)

Reviewed git diff 8c58a73f..origin/serveradmin-3-proto-members-bans-invites (97877e42) cold.

(1) Tests named by the plan: all 13 exist (tests/moderation.rs, spec_contract_moderation_types in tests/spec_contract.rs) and assert the spec's values: nick null clears, timeout/remove bodies, ban body with all three fields, ban limits 60 / 63 072 000 / 604 800 / 512, member-search defaults (25, joinedAt, desc), indexing answer, unknown join source kept, the 4 events, API vs validation code split checked against openapi.json, sudo field paths, and two no-panic proptests.

(2) Interfaces: all names present. Deviations, none of them breaking for Tasks 4/5:

  • [minor] InviteCreate(Box<InviteMetadata>) instead of InviteCreate(InviteMetadata). Pattern matching works the same way, but code that builds the variant needs Box::new.
  • [minor] field_errors() is on ApiErrorBody (the proto type), not ApiError. Task 4 should call it through the body. It is documented in the README.
  • [minor] Validation codes (USER_IS_NOT_BANNED, GUILD_FEATURE_NOT_TOGGLEABLE, CANNOT_REORDER_EVERYONE_ROLE, TIMEOUT_CANNOT_EXCEED_365_DAYS, MUST_ENABLE_2FA_BEFORE_REQUIRING_FOR_MODS) live in errors::validation, which matches C/ValidationErrorCodes.ts. Consumers must match them with has_code, not against the top-level code.
  • [minor] MemberSearchRequest.limit/offset/sort_* are plain values that are always sent. This matches buildMemberSearchParams.

(3) Invariants: the change is proto only, with no I/O and no secrets. Fixtures use fake ids and hashes. Every fixture matches its cited server source (GuildBanResponse, GuildMemberSearchSchemas.ts, SudoModeRequiredError.ts, GuildModerationService.ts:198/277, InviteService.ts dispatch*). Lenient parsing covers bans, members and join sources, and a fractional or out-of-range joined_at drops only that member.

(4) Parity spot checks against the fork: JoinSourceTypes 0,1,2,3,4,6 (GuildConstants.ts:176); SUDO_VERIFICATION_ERROR_FIELDS (RestTransport.ts:49); banMemberRequest (GuildCommands.ts:130, reason || undefined from BanMemberModal.tsx:132); timeoutPatch (GuildMemberCommands.ts:56); buildMemberSearchParams (SearchApi.ts:60); temp-ban limits (LimitConstants.ts:102-103); the API/validation classification of every code. All match.

  • [minor] The original's isSudoVerificationFailure also accepts an error entry keyed field instead of path. ApiFieldError reads path only. The server's InputValidationError writes path, so this has no effect today.

(5) Review Focus 7: proptests arbitrary_ban_json_never_panics and arbitrary_member_search_json_never_panics are present. The second also asserts that a response envelope always parses, whatever the member shape.

(6) Local CI: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passed (exit 0).

Verdict: APPROVED. No blocking findings; 5 minor findings, none of which needs a change before merge.

## Independent review: Server admin 3 (proto members, bans, member search, invite events, error codes) Reviewed `git diff 8c58a73f..origin/serveradmin-3-proto-members-bans-invites` (97877e42) cold. **(1) Tests named by the plan:** all 13 exist (`tests/moderation.rs`, `spec_contract_moderation_types` in `tests/spec_contract.rs`) and assert the spec's values: nick `null` clears, timeout/remove bodies, ban body with all three fields, ban limits 60 / 63 072 000 / 604 800 / 512, member-search defaults (25, joinedAt, desc), indexing answer, unknown join source kept, the 4 events, API vs validation code split checked against `openapi.json`, sudo field paths, and two no-panic proptests. **(2) Interfaces:** all names present. Deviations, none of them breaking for Tasks 4/5: - [minor] `InviteCreate(Box<InviteMetadata>)` instead of `InviteCreate(InviteMetadata)`. Pattern matching works the same way, but code that builds the variant needs `Box::new`. - [minor] `field_errors()` is on `ApiErrorBody` (the proto type), not `ApiError`. Task 4 should call it through the body. It is documented in the README. - [minor] Validation codes (`USER_IS_NOT_BANNED`, `GUILD_FEATURE_NOT_TOGGLEABLE`, `CANNOT_REORDER_EVERYONE_ROLE`, `TIMEOUT_CANNOT_EXCEED_365_DAYS`, `MUST_ENABLE_2FA_BEFORE_REQUIRING_FOR_MODS`) live in `errors::validation`, which matches `C/ValidationErrorCodes.ts`. Consumers must match them with `has_code`, not against the top-level `code`. - [minor] `MemberSearchRequest.limit/offset/sort_*` are plain values that are always sent. This matches `buildMemberSearchParams`. **(3) Invariants:** the change is proto only, with no I/O and no secrets. Fixtures use fake ids and hashes. Every fixture matches its cited server source (`GuildBanResponse`, `GuildMemberSearchSchemas.ts`, `SudoModeRequiredError.ts`, `GuildModerationService.ts:198/277`, `InviteService.ts` dispatch*). Lenient parsing covers bans, members and join sources, and a fractional or out-of-range `joined_at` drops only that member. **(4) Parity spot checks against the fork:** JoinSourceTypes 0,1,2,3,4,6 (`GuildConstants.ts:176`); `SUDO_VERIFICATION_ERROR_FIELDS` (`RestTransport.ts:49`); `banMemberRequest` (`GuildCommands.ts:130`, `reason || undefined` from `BanMemberModal.tsx:132`); `timeoutPatch` (`GuildMemberCommands.ts:56`); `buildMemberSearchParams` (`SearchApi.ts:60`); temp-ban limits (`LimitConstants.ts:102-103`); the API/validation classification of every code. All match. - [minor] The original's `isSudoVerificationFailure` also accepts an error entry keyed `field` instead of `path`. `ApiFieldError` reads `path` only. The server's `InputValidationError` writes `path`, so this has no effect today. **(5) Review Focus 7:** proptests `arbitrary_ban_json_never_panics` and `arbitrary_member_search_json_never_panics` are present. The second also asserts that a response envelope always parses, whatever the member shape. **(6) Local CI:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passed (exit 0). **Verdict: APPROVED.** No blocking findings; 5 minor findings, none of which needs a change before merge.
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-15 21:25:56 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.