Server admin 9a: core-ports (#675) #720

Closed
charles wants to merge 0 commits from serveradmin-9a-core-ports into serveradmin
Owner

What

The server administration ports (plan Task 9a): every action, request, answer, confirm and the state skeleton the later core tasks (9b–20) fill.

  • fluxer-core::admin with one file per area (perms, perm_spec, form, guild, roles, members, bans, invites, channel, overwrites, reorder, sudo): each its state type, Default/new, a stub reducer wired into App::apply through admin::reduce (logged in, after #663's create modals, with the store's confirm), and stub selectors answering empty models.
  • app.admin: Admin as spec §6.1, all empty; reset on logout.
  • UserAction::Admin(AdminAction) with every sub-action of the plan's Interfaces block; SudoAnswer::{Password, Totp} wraps a SecretString, Debug prints …, not Serialize, into_verification() gives the proto SudoVerification.
  • CoreEvent::SudoToken { valid_until }.
  • ApiRequest/ApiResult pairs for every method of Tasks 4 and 5 plus FetchRtcRegions; the three identity-check ones carry sudo: Option<SudoAnswer> (ApiRequest::is_sudo_capable). EditChannel, DeleteChannel, CreateGuildChannel unchanged.
  • chat::Confirm gains the ten admin confirms (Confirm::is_admin), closed by CloseConfirm; fluxer-ui's confirm draws nothing for them until Task 27.
  • MenuItemId gains the admin row ids as associated constants (MenuItemId::ADMIN_ROWS).
  • apps/fluxer/src/runtime.rs: each new request answers 501 CLIENT_NOT_WIRED until Task 22.

Tests

crates/fluxer-core/tests/admin_ports.rs: state_defaults, stubs_emit_nothing, new_confirm_variants_close_with_close_confirm, sudo_answer_debug_hides_the_secret, logout_resets_admin_state, new_requests_and_answers_exist_and_are_ignored, menu_row_ids_are_kebab_case_and_distinct, existing_tests_untouched (whole suite). Written first and seen failing (commit 63e6227d). FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No display tests run (none needed).

Deviations from the plan

  • Fields named in the codebase's style where the plan left them open: RoleAction::{Select(id), Duplicate(id), Delete { role_id, confirmed }}, MemberAction::ToggleRole { guild_id, user_id, role_id } (Task 13's text says { guild, user, role }), OverwriteAction::Remove(OverwriteTarget), ChannelAdminAction::{Delete { channel_id, confirmed }, OpenDuplicate { channel_id }, Duplicate { channel_id, name }}, InviteListAction::{Revoke { code, confirmed }, SetPaused { guild_id, paused, confirmed }}, BanListAction::Revoke { user_id, confirmed }, DeleteGuild { guild_id, confirmed }, SelectTab(SettingsTabRef::{Guild, Channel}), OpenGuildSettings { tab: Option<GuildTab> } (None = first allowed).
  • RoleMove { role, target: RoleMoveTarget::{Above, Below} }; SearchMembers { seq } / MembersFound { seq } for the stale-answer drop; UpdateGuild { icon, banner: Option<FileRef> } for the runtime's data URIs.
  • Spec §6.1's sudo.token is token_valid_until: Option<Timestamp> (the store never holds the token, per the plan).
  • AdminAction/SudoAction are not PartialEq (they may carry a secret), like UserAction.
  • Two one-line additions outside the Files list: messages.rs and session.rs exhaustive CoreEvent matches gained SudoToken.
  • Model structs returned by stub selectors are placeholders the owning tasks replace.

Closes #675

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

## What The server administration ports (plan Task 9a): every action, request, answer, confirm and the state skeleton the later core tasks (9b–20) fill. - `fluxer-core::admin` with one file per area (`perms`, `perm_spec`, `form`, `guild`, `roles`, `members`, `bans`, `invites`, `channel`, `overwrites`, `reorder`, `sudo`): each its state type, `Default`/`new`, a stub reducer wired into `App::apply` through `admin::reduce` (logged in, after #663's create modals, with the store's confirm), and stub selectors answering empty models. - `app.admin: Admin` as spec §6.1, all empty; reset on logout. - `UserAction::Admin(AdminAction)` with every sub-action of the plan's Interfaces block; `SudoAnswer::{Password, Totp}` wraps a `SecretString`, `Debug` prints `…`, not `Serialize`, `into_verification()` gives the proto `SudoVerification`. - `CoreEvent::SudoToken { valid_until }`. - `ApiRequest`/`ApiResult` pairs for every method of Tasks 4 and 5 plus `FetchRtcRegions`; the three identity-check ones carry `sudo: Option<SudoAnswer>` (`ApiRequest::is_sudo_capable`). `EditChannel`, `DeleteChannel`, `CreateGuildChannel` unchanged. - `chat::Confirm` gains the ten admin confirms (`Confirm::is_admin`), closed by `CloseConfirm`; `fluxer-ui`'s confirm draws nothing for them until Task 27. - `MenuItemId` gains the admin row ids as associated constants (`MenuItemId::ADMIN_ROWS`). - `apps/fluxer/src/runtime.rs`: each new request answers 501 `CLIENT_NOT_WIRED` until Task 22. ## Tests `crates/fluxer-core/tests/admin_ports.rs`: `state_defaults`, `stubs_emit_nothing`, `new_confirm_variants_close_with_close_confirm`, `sudo_answer_debug_hides_the_secret`, `logout_resets_admin_state`, `new_requests_and_answers_exist_and_are_ignored`, `menu_row_ids_are_kebab_case_and_distinct`, `existing_tests_untouched` (whole suite). Written first and seen failing (commit 63e6227d). `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No display tests run (none needed). ## Deviations from the plan - Fields named in the codebase's style where the plan left them open: `RoleAction::{Select(id), Duplicate(id), Delete { role_id, confirmed }}`, `MemberAction::ToggleRole { guild_id, user_id, role_id }` (Task 13's text says `{ guild, user, role }`), `OverwriteAction::Remove(OverwriteTarget)`, `ChannelAdminAction::{Delete { channel_id, confirmed }, OpenDuplicate { channel_id }, Duplicate { channel_id, name }}`, `InviteListAction::{Revoke { code, confirmed }, SetPaused { guild_id, paused, confirmed }}`, `BanListAction::Revoke { user_id, confirmed }`, `DeleteGuild { guild_id, confirmed }`, `SelectTab(SettingsTabRef::{Guild, Channel})`, `OpenGuildSettings { tab: Option<GuildTab> }` (None = first allowed). - `RoleMove { role, target: RoleMoveTarget::{Above, Below} }`; `SearchMembers { seq }` / `MembersFound { seq }` for the stale-answer drop; `UpdateGuild { icon, banner: Option<FileRef> }` for the runtime's data URIs. - Spec §6.1's `sudo.token` is `token_valid_until: Option<Timestamp>` (the store never holds the token, per the plan). - `AdminAction`/`SudoAction` are not `PartialEq` (they may carry a secret), like `UserAction`. - Two one-line additions outside the Files list: `messages.rs` and `session.rs` exhaustive `CoreEvent` matches gained `SudoToken`. - Model structs returned by stub selectors are placeholders the owning tasks replace. Closes #675 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Refs #675

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Lands the server administration ports (Server administration 9a): the
admin module skeleton (app.admin, one file per area with stub reducers
and selectors), UserAction::Admin(AdminAction), CoreEvent::SudoToken,
the ApiRequest/ApiResult pairs of Tasks 4 and 5, the new chat::Confirm
variants, MenuItemId row ids; fluxer-ui's confirm draws nothing for the
new confirms and the runtime answers the new requests 501
CLIENT_NOT_WIRED until Task 22.

Refs #675

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

Independent review: Server admin 9a, core ports (diff 28edd5a8..678ebc5c)

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passed in a clean review worktree (exit 0, admin_ports included).

Checked

  • Plan tests: state_defaults, stubs_emit_nothing, new_confirm_variants_close_with_close_confirm, sudo_answer_debug_hides_the_secret, logout_resets_admin_state and existing_tests_untouched all exist, and each asserts what the plan describes. There are also two extra tests: request/answer pairs, and menu ids.
  • Interfaces: every top-level AdminAction variant is present, along with SudoAction::{Submit(SudoAnswer), Cancel}, CoreEvent::SudoToken { valid_until }, all 22 ApiRequest/ApiResult pairs (FetchRtcRegions included, because the core had no such request before), sudo: Option<SudoAnswer> on exactly UpdateGuild/DeleteGuild/TransferOwnership, the 10 Confirm variants, app.admin shaped as spec §6.1, and Form { server, draft, saving, error }. EditChannel, DeleteChannel and CreateGuildChannel are unchanged.
  • Invariants: fluxer-core gains no I/O and no forbidden crate (the core-isolation step is green). SudoAnswer wraps SecretString, its Debug prints …, and it does not implement Serialize. The store never holds the token, only token_valid_until. app.admin is reset on logout. No fixtures, secrets or paths were added. The runtime does not Debug-log requests.
  • SudoAnswer::into_verification yields {password} / {mfa_method:"totp", mfa_code} (the test checks the JSON), as SudoVerificationSchema and spec §3.9 require.
  • The 501 arm in runtime.rs::perform covers exactly the 22 new requests and returns Http{501, CLIENT_NOT_WIRED} without touching the client. perform_chat lists them as not-a-chat-request. Nothing in the core emits them yet.
  • Parity spot-checks against fluxer-soundboard:
    1. Sudo-capable set: GuildBaseController.ts PATCH /guilds/:id (sudo only when mfa_level changes), POST /guilds/:id/delete, and GuildMemberController.ts POST transfer-ownership. Guild-channel DELETE needs sudo only for group-DM delete_messages, so it is correctly not marked.
    2. Header X-Fluxer-Sudo-Mode-JWT (SudoModeMiddleware.ts).
    3. Members page defaults: DEFAULT_PAGE_SIZE = 25, sort 'newest' (GuildMembersPageShared.ts, MembersTableView.tsx).
    4. Ban modal: duration 0 = Permanent, optional reason (BanMemberModal.tsx).
  • Review Focus item 6 (identity check): the ports are sound. The secret does not appear in Debug output and cannot be serialized.

Findings

  1. minor: MenuItemId::ROLES = "roles" is the same id that the existing read-only Roles submenu already uses (menus/user.rs:588). The new ROLES_READ_ONLY = "roles-read-only" claims to be the read-only row. Task 20 has to pick one convention, either renaming the existing row or swapping the constants. menu_row_ids_are_kebab_case_and_distinct only checks for duplicates inside ADMIN_ROWS, not against the existing menu ids.

  2. minor: Several shapes differ from the plan's Interfaces text. The PR lists each of these:

    • ChannelAdminAction::Duplicate { channel_id, name }
    • OverwriteAction::Remove(target)
    • RoleAction::Duplicate(id) / Delete { role_id, confirmed }
    • ToggleRole { guild_id, user_id, role_id }
    • tab: Option<_>
    • invites::list_model(app) without Task 14's scope parameter

    They follow codebase naming, so this is not blocking. Tasks 12, 13, 14, 16 and 17 should build against the code, not the plan text.

  3. minor (for Task 19): SudoPrompt.request: Box<ApiRequest> can, by type, hold a request whose sudo is Some(answer). Task 19 must keep the held request at sudo: None so that secret_not_in_state_after_submit holds.

  4. minor: existing_tests_untouched is mostly a placeholder; the full-suite run is the real check. That is acceptable.

Verdict: APPROVED. No blocking findings, and local CI is green.

## Independent review: Server admin 9a, core ports (diff 28edd5a8..678ebc5c) **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passed in a clean review worktree (exit 0, admin_ports included). **Checked** - Plan tests: `state_defaults`, `stubs_emit_nothing`, `new_confirm_variants_close_with_close_confirm`, `sudo_answer_debug_hides_the_secret`, `logout_resets_admin_state` and `existing_tests_untouched` all exist, and each asserts what the plan describes. There are also two extra tests: request/answer pairs, and menu ids. - Interfaces: every top-level `AdminAction` variant is present, along with `SudoAction::{Submit(SudoAnswer), Cancel}`, `CoreEvent::SudoToken { valid_until }`, all 22 `ApiRequest`/`ApiResult` pairs (`FetchRtcRegions` included, because the core had no such request before), `sudo: Option<SudoAnswer>` on exactly `UpdateGuild`/`DeleteGuild`/`TransferOwnership`, the 10 `Confirm` variants, `app.admin` shaped as spec §6.1, and `Form { server, draft, saving, error }`. `EditChannel`, `DeleteChannel` and `CreateGuildChannel` are unchanged. - Invariants: fluxer-core gains no I/O and no forbidden crate (the core-isolation step is green). `SudoAnswer` wraps `SecretString`, its `Debug` prints `…`, and it does not implement `Serialize`. The store never holds the token, only `token_valid_until`. `app.admin` is reset on logout. No fixtures, secrets or paths were added. The runtime does not Debug-log requests. - `SudoAnswer::into_verification` yields `{password}` / `{mfa_method:"totp", mfa_code}` (the test checks the JSON), as `SudoVerificationSchema` and spec §3.9 require. - The 501 arm in `runtime.rs::perform` covers exactly the 22 new requests and returns `Http{501, CLIENT_NOT_WIRED}` without touching the client. `perform_chat` lists them as not-a-chat-request. Nothing in the core emits them yet. - Parity spot-checks against fluxer-soundboard: 1. Sudo-capable set: `GuildBaseController.ts` PATCH /guilds/:id (sudo only when `mfa_level` changes), POST /guilds/:id/delete, and `GuildMemberController.ts` POST transfer-ownership. Guild-channel DELETE needs sudo only for group-DM `delete_messages`, so it is correctly not marked. 2. Header `X-Fluxer-Sudo-Mode-JWT` (`SudoModeMiddleware.ts`). 3. Members page defaults: `DEFAULT_PAGE_SIZE = 25`, sort `'newest'` (`GuildMembersPageShared.ts`, `MembersTableView.tsx`). 4. Ban modal: duration 0 = Permanent, optional reason (`BanMemberModal.tsx`). - Review Focus item 6 (identity check): the ports are sound. The secret does not appear in Debug output and cannot be serialized. **Findings** 1. *minor*: `MenuItemId::ROLES = "roles"` is the same id that the existing **read-only** Roles submenu already uses (`menus/user.rs:588`). The new `ROLES_READ_ONLY = "roles-read-only"` claims to be the read-only row. Task 20 has to pick one convention, either renaming the existing row or swapping the constants. `menu_row_ids_are_kebab_case_and_distinct` only checks for duplicates inside `ADMIN_ROWS`, not against the existing menu ids. 2. *minor*: Several shapes differ from the plan's Interfaces text. The PR lists each of these: - `ChannelAdminAction::Duplicate { channel_id, name }` - `OverwriteAction::Remove(target)` - `RoleAction::Duplicate(id)` / `Delete { role_id, confirmed }` - `ToggleRole { guild_id, user_id, role_id }` - `tab: Option<_>` - `invites::list_model(app)` without Task 14's `scope` parameter They follow codebase naming, so this is not blocking. Tasks 12, 13, 14, 16 and 17 should build against the code, not the plan text. 3. *minor (for Task 19)*: `SudoPrompt.request: Box<ApiRequest>` can, by type, hold a request whose `sudo` is `Some(answer)`. Task 19 must keep the held request at `sudo: None` so that `secret_not_in_state_after_submit` holds. 4. *minor*: `existing_tests_untouched` is mostly a placeholder; the full-suite run is the real check. That is acceptable. **Verdict: APPROVED.** No blocking findings, and local CI is green.
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 23:26:39 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.