Text chat 55: fluxer-proto and fluxer-api entrance-sound library endpoints (#384) #401

Manually merged
charles merged 5 commits from textchat-55-proto-api-entrance-library into textchat 2026-11-13 04:31:16 +00:00
Owner

What this builds

fluxer-proto (models/soundboard.rs, limits.rs, lib.rs):

  • EntranceSoundUploadRequest { name, audio } (bare base64, no data: prefix; Debug prints only the length), EntranceSoundRenameRequest { name }, EntranceSoundSelectionRequest { scope_id, sound_id } (None is written as null, no skip_serializing_if).
  • EntranceSoundScope::{Global, Guilds, Dms, Guild(Snowflake)} with id(), parse(), fallbacks() (as EntranceSoundScopes.ts:65-74) and for_voice().
  • Constants: ENTRANCE_SOUND_MAX_PER_USER 8, ENTRANCE_SOUND_MAX_BYTES 1 MiB, ENTRANCE_SOUND_{MIN,MAX}_DURATION 100 ms / 5.2 s, ENTRANCE_SOUND_NAME_MAX_CHARS 32, SOUNDBOARD_SOUND_{MIN,MAX}_DURATION 100 ms / 30 s; limits::FEATURE_VOICE_ENTRANCE_SOUNDS with default_limit Some(0.0).

fluxer-api (voice.rs): upload_entrance_sound (POST, 201, not shown to the --record observer), rename_entrance_sound (PATCH), delete_entrance_sound (204), set_entrance_sound_selection (PUT, 204).

How it was tested

  • proto: entrance_upload_request_shape, selection_request_clear_serialises_null_sound_id, scope_ids_round_trip, scope_parse_rejects_unknown_and_empty_guild, scope_fallbacks_match_the_original, for_voice_without_guild_is_dms, entrance_limits_match_the_server_constants (tests/soundboard.rs), spec_contract_entrance_requests (tests/spec_contract.rs, against spec/openapi.json: properties, required keys, nullable sound_id, scope-id pattern).
  • api (wiremock): upload_entrance_sound_posts_base64_and_parses_201, rename_entrance_sound_patches_name, delete_entrance_sound_expects_204, set_selection_puts_scope_and_null, quota_reached_is_a_validation_error_with_its_code, plus entrance_upload_is_not_shown_to_the_observer.
  • New fixtures, shaped from the server source: fixtures/rest/entrance_sound_created.json (serializeSound, EntranceSoundController.ts:22-34) and fixtures/errors/entrance_sound_quota_reached.json (InputValidationError.fromCode as written by ErrorHandlers.ts:118-143).
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passes locally (Linux).

Deviations from the plan

  • The plan says a validation code comes back as "the existing validation error variant". ApiError has no such variant, and the server nests these codes inside a 400 INVALID_FORM_BODY (errors[].code). So ApiError::classify (crates/fluxer-api/src/error.rs, same crate but outside the Files list) now returns ApiError::Http { status: 400, code: Some(<entrance code>), message: <entry message> }, but only for the four entrance-sound codes. Every other validation error keeps INVALID_FORM_BODY, so the login mapping in core does not change.
  • Files outside the list: fixtures/rest/entrance_sound_created.json, a new fixtures/errors/ directory (an error body is not a proto model, and fixtures/rest must round-trip through models), and crates/fluxer-proto/tests/models_roundtrip.rs (covers the new REST fixture).
  • Found while doing this, not fixed here: #398 (the soundboard upload body reaches the --record observer).

Closes #384

🤖 Generated with Claude Code

## What this builds **fluxer-proto** (`models/soundboard.rs`, `limits.rs`, `lib.rs`): - `EntranceSoundUploadRequest { name, audio }` (bare base64, no `data:` prefix; `Debug` prints only the length), `EntranceSoundRenameRequest { name }`, `EntranceSoundSelectionRequest { scope_id, sound_id }` (`None` is written as `null`, no `skip_serializing_if`). - `EntranceSoundScope::{Global, Guilds, Dms, Guild(Snowflake)}` with `id()`, `parse()`, `fallbacks()` (as `EntranceSoundScopes.ts:65-74`) and `for_voice()`. - Constants: `ENTRANCE_SOUND_MAX_PER_USER` 8, `ENTRANCE_SOUND_MAX_BYTES` 1 MiB, `ENTRANCE_SOUND_{MIN,MAX}_DURATION` 100 ms / 5.2 s, `ENTRANCE_SOUND_NAME_MAX_CHARS` 32, `SOUNDBOARD_SOUND_{MIN,MAX}_DURATION` 100 ms / 30 s; `limits::FEATURE_VOICE_ENTRANCE_SOUNDS` with `default_limit` `Some(0.0)`. **fluxer-api** (`voice.rs`): `upload_entrance_sound` (POST, 201, not shown to the `--record` observer), `rename_entrance_sound` (PATCH), `delete_entrance_sound` (204), `set_entrance_sound_selection` (PUT, 204). ## How it was tested - proto: `entrance_upload_request_shape`, `selection_request_clear_serialises_null_sound_id`, `scope_ids_round_trip`, `scope_parse_rejects_unknown_and_empty_guild`, `scope_fallbacks_match_the_original`, `for_voice_without_guild_is_dms`, `entrance_limits_match_the_server_constants` (`tests/soundboard.rs`), `spec_contract_entrance_requests` (`tests/spec_contract.rs`, against `spec/openapi.json`: properties, required keys, nullable `sound_id`, scope-id pattern). - api (wiremock): `upload_entrance_sound_posts_base64_and_parses_201`, `rename_entrance_sound_patches_name`, `delete_entrance_sound_expects_204`, `set_selection_puts_scope_and_null`, `quota_reached_is_a_validation_error_with_its_code`, plus `entrance_upload_is_not_shown_to_the_observer`. - New fixtures, shaped from the server source: `fixtures/rest/entrance_sound_created.json` (`serializeSound`, `EntranceSoundController.ts:22-34`) and `fixtures/errors/entrance_sound_quota_reached.json` (`InputValidationError.fromCode` as written by `ErrorHandlers.ts:118-143`). - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passes locally (Linux). ## Deviations from the plan - The plan says a validation code comes back as "the existing validation error variant". `ApiError` has no such variant, and the server nests these codes inside a 400 `INVALID_FORM_BODY` (`errors[].code`). So `ApiError::classify` (`crates/fluxer-api/src/error.rs`, same crate but outside the Files list) now returns `ApiError::Http { status: 400, code: Some(<entrance code>), message: <entry message> }`, but only for the four entrance-sound codes. Every other validation error keeps `INVALID_FORM_BODY`, so the login mapping in core does not change. - Files outside the list: `fixtures/rest/entrance_sound_created.json`, a new `fixtures/errors/` directory (an error body is not a proto model, and `fixtures/rest` must round-trip through models), and `crates/fluxer-proto/tests/models_roundtrip.rs` (covers the new REST fixture). - Found while doing this, not fixed here: #398 (the soundboard upload body reaches the `--record` observer). Closes #384 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Request shapes from fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts:72-96
and packages/schema/src/domains/user/EntranceSoundSchemas.ts; scopes from
fluxer_app/src/features/notification/utils/EntranceSoundScopes.ts:65-74; limits from
packages/constants/src/{EntranceSoundConstants,SoundboardConstants}.ts.

Refs #384

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
entrance_sound_created.json: serializeSound of
fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts:22-34 (the 201 of the
upload at :72-96 and the 200 of the rename at :97-121).
entrance_sound_quota_reached.json: the 400 of InputValidationError.fromCode
(packages/errors/src/domains/core/InputValidationError.ts:34-36) as written by
handleLocalizedValidationErrors (packages/errors/src/domains/core/ErrorHandlers.ts:118-143,
FluxerError.toJSON spreads data at packages/errors/src/FluxerError.ts:50-56), thrown by
fluxer_api/src/api/user/entrance_sound/EntranceSoundService.ts:95.

Refs #384

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Endpoints of fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts:72-177.
The service's validation codes (EntranceSoundService.ts:95-145) are nested in a 400
INVALID_FORM_BODY; ApiError::Http now carries them as its code (error.rs, same crate).

Refs #384

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fixtures/rest is the round-trip set of fluxer-proto models; the quota-reached body is an
error, not a model, so it moves to fixtures/errors. entrance_sound_created.json joins the
round-trip and unknown-field tables as an EntranceSound.

Refs #384

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

Independent review: Text chat 55 (proto + api entrance-sound library)

Reviewed 6113a8e..origin/textchat-55-proto-api-entrance-library (c0c6a65) cold, against the plan's Task 55, Global Constraints and the fork sources.

Tests named by the plan: all 13 are there (entrance_upload_request_shape, selection_request_clear_serialises_null_sound_id, scope_ids_round_trip, scope_parse_rejects_unknown_and_empty_guild, scope_fallbacks_match_the_original, for_voice_without_guild_is_dms, entrance_limits_match_the_server_constants, spec_contract_entrance_requests, upload_entrance_sound_posts_base64_and_parses_201, rename_entrance_sound_patches_name, delete_entrance_sound_expects_204, set_selection_puts_scope_and_null, quota_reached_is_a_validation_error_with_its_code), and the values match the spec. Constants match EntranceSoundConstants.ts and SoundboardConstants.ts. Fallbacks match EntranceSoundScopes.ts:65-74. The status codes (201/200/204/204) match EntranceSoundController.ts. There is also an extra observer test.

Interfaces: every name and signature in the proto and api Interfaces block exists as written. sound_id has no skip_serializing_if, so None goes out as null. default_limit(FEATURE_VOICE_ENTRANCE_SOUNDS) == Some(0.0).

Deviation (error.rs): I accept it. ApiError has no validation variant. The server's InputValidationError.fromCode really does go out as a 400 INVALID_FORM_BODY with errors[{path,message,code}] (ErrorHandlers.ts:118-143). Promoting the nested code is limited to the 4 ENTRANCE_SOUND_* codes, and only when the top-level code is INVALID_FORM_BODY. The captcha and IP branches are unaffected and every other validation error keeps its code, so the login mapping is unchanged.

Invariants: the upload goes through unobserved(), so the audio never reaches --record (the test proves it). EntranceSoundUploadRequest's Debug prints only the length. There are no new dependencies (base64 was already a fluxer-api dependency), no core/ui/emoji changes and no secrets. The fixtures follow serializeSound (EntranceSoundController.ts:22-34) and the localized InputValidationError body, and the commit messages cite the server lines they come from.

Findings

  • minor: fixtures/errors/entrance_sound_quota_reached.json: the entry message ("You can save at most 8 entrance sounds.") is not the server's text. ErrorI18nMessages.ts:758 resolves it to "You've reached the limit of 8 saved entrance sounds." The shape is right; only the text is invented. Suggest copying the real string, and the test's assertion with it.
  • minor: fixtures/rest/entrance_sound_created.json: hash has 32 hex chars, but the server stores md5(...).slice(0, 16) (EntranceSoundService.ts), which is 16. The existing entrance_sounds.json has the same issue. It has no effect on parsing.
  • minor: EntranceSoundScope::parse accepts what Snowflake::from_str accepts. That may be laxer than the server's ^guild:\d{1,20}$ (for example a leading +, if the decimal parser allows it). id() always writes a valid id, so nothing invalid reaches the server.
  • minor: the commits carry Claude Opus 5.5 attribution, while the repo CLAUDE.md says Fable 5.2. This is consistent with the rest of textchat and is an orchestrator question, not one for this task.

CI: cargo xtask ci in the review worktree passed (all steps; screenshot and livekit steps skipped locally).

Verdict: APPROVED. No blocking findings.

## Independent review: Text chat 55 (proto + api entrance-sound library) Reviewed `6113a8e..origin/textchat-55-proto-api-entrance-library` (c0c6a65) cold, against the plan's Task 55, Global Constraints and the fork sources. **Tests named by the plan:** all 13 are there (`entrance_upload_request_shape`, `selection_request_clear_serialises_null_sound_id`, `scope_ids_round_trip`, `scope_parse_rejects_unknown_and_empty_guild`, `scope_fallbacks_match_the_original`, `for_voice_without_guild_is_dms`, `entrance_limits_match_the_server_constants`, `spec_contract_entrance_requests`, `upload_entrance_sound_posts_base64_and_parses_201`, `rename_entrance_sound_patches_name`, `delete_entrance_sound_expects_204`, `set_selection_puts_scope_and_null`, `quota_reached_is_a_validation_error_with_its_code`), and the values match the spec. Constants match `EntranceSoundConstants.ts` and `SoundboardConstants.ts`. Fallbacks match `EntranceSoundScopes.ts:65-74`. The status codes (201/200/204/204) match `EntranceSoundController.ts`. There is also an extra observer test. **Interfaces:** every name and signature in the proto and api Interfaces block exists as written. `sound_id` has no `skip_serializing_if`, so `None` goes out as `null`. `default_limit(FEATURE_VOICE_ENTRANCE_SOUNDS) == Some(0.0)`. **Deviation (error.rs):** I accept it. `ApiError` has no validation variant. The server's `InputValidationError.fromCode` really does go out as a 400 `INVALID_FORM_BODY` with `errors[{path,message,code}]` (`ErrorHandlers.ts:118-143`). Promoting the nested code is limited to the 4 `ENTRANCE_SOUND_*` codes, and only when the top-level code is `INVALID_FORM_BODY`. The captcha and IP branches are unaffected and every other validation error keeps its code, so the login mapping is unchanged. **Invariants:** the upload goes through `unobserved()`, so the audio never reaches `--record` (the test proves it). `EntranceSoundUploadRequest`'s `Debug` prints only the length. There are no new dependencies (base64 was already a fluxer-api dependency), no core/ui/emoji changes and no secrets. The fixtures follow `serializeSound` (`EntranceSoundController.ts:22-34`) and the localized `InputValidationError` body, and the commit messages cite the server lines they come from. **Findings** - minor: `fixtures/errors/entrance_sound_quota_reached.json`: the entry `message` ("You can save at most 8 entrance sounds.") is not the server's text. `ErrorI18nMessages.ts:758` resolves it to "You've reached the limit of 8 saved entrance sounds." The shape is right; only the text is invented. Suggest copying the real string, and the test's assertion with it. - minor: `fixtures/rest/entrance_sound_created.json`: `hash` has 32 hex chars, but the server stores `md5(...).slice(0, 16)` (`EntranceSoundService.ts`), which is 16. The existing `entrance_sounds.json` has the same issue. It has no effect on parsing. - minor: `EntranceSoundScope::parse` accepts what `Snowflake::from_str` accepts. That may be laxer than the server's `^guild:\d{1,20}$` (for example a leading `+`, if the decimal parser allows it). `id()` always writes a valid id, so nothing invalid reaches the server. - minor: the commits carry `Claude Opus 5.5` attribution, while the repo CLAUDE.md says Fable 5.2. This is consistent with the rest of `textchat` and is an orchestrator question, not one for this task. **CI:** `cargo xtask ci` in the review worktree passed (all steps; screenshot and livekit steps skipped locally). **Verdict: APPROVED.** No blocking findings.
charles manually merged commit 67da1c73b3 into textchat 2026-11-13 04:31:15 +00:00
Sign in to join this conversation.
No description provided.