Voice 8: fluxer-core::voice live room, subscriptions, volumes, speaking, chimes (#69) #117

Manually merged
charles merged 0 commits from voice-8-core-live-room-volumes into voice 2026-11-11 21:03:44 +00:00
Owner

What this builds

Voice plan Task 8 (spec §5.2 "Subscription policy", "Gain", "Speaking", "Chimes"), in fluxer-core::voice:

  • voice/live.rs — LiveRoom (app.voice.live): remote participants by LiveKit identity (parse_identity, the original's user_(\d+)_(.+)), their tracks, rtt() and rtt_history() (60 samples). Malformed identities and this client's own are ignored everywhere.
  • Subscription policy: TrackPublished of a microphone emits SetSubscribed (true iff not effectively deaf and the user is not locally muted) and AudioCommand::SetGain. After every event the policy is re-evaluated for every microphone publication and only changes are sent: deafen/undeafen (self or by a moderator), SetLocalMute, SetUserVolume; everything is sent again after VoiceEvent::Reconnected. Other sources get one explicit SetSubscribed { subscribed: false } on publish (as the original's VoiceRoomEventBinder) and are never subscribed.
  • voice/volumes.rs — ParticipantVolumes { volumes, local_mutes } (app.voice.volumes), UserAction::{SetUserVolume { user_id, percent }, SetLocalMute { user_id, muted }}, persisted in LocalSettings::participant_volumes ([voice.volumes] table and voice.local_mutes in settings.toml; old files load). volume_gain is the original's curve, participant_gain(user, output) the product.
  • voice/speaking.rs — the level detector with the original's 30 ms attack / 220 ms release and threshold (0.006 RMS at the default sensitivity), counted in 50 ms level reports because the store has no clock. Selectors is_speaking, self_speaking, voice_ping; VoiceParticipantRow::speaking is now live. Speaking is hidden while the user shows as self-muted, server-muted or suppressed.
  • Join/leave sounds for other connections entering or leaving my channel, with the 2000 ms duplicate window per connection (a timer; a leave ends the window).
  • A participant leaving (or the room being replaced or left) drops it from the room, so nothing is addressed to its playback source any more and a return sets it up from scratch.

How it was tested

crates/fluxer-core/tests/voice_live.rs: the nine tests the plan names, plus volumes loading/persisting, track mute, ping history, "nobody chimes while not in a room", "participant leaving removes its playback source", and a proptest that walks random room/gateway/user events and checks after every step that what the room was told equals the policy (a microphone is received exactly when not deaf and not locally muted; nothing else is ever subscribed). Unit tests for the curve, the detector and the identity parser. crates/fluxer-platform/tests/settings.rs round-trips the new keys and loads hand-written junk. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green locally.

Review focus 1 (deafen must stop receiving and mute the microphone): deafen_unsubscribes_all_mics_and_undeafen_resubscribes.

Deviations from the plan

  • Files outside the task's list, each minimal: event.rs (the two UserActions the Interfaces block asks for), app.rs (two lines: Voice::load_settings, pass &Voice to the persist reducer), voice/connection.rs (three lines: call reduce_live, empty the room on a new Connect and on close), selectors/mod.rs and lib.rs (re-exports), fluxer-platform settings.rs + test (the file format, as Task 7 did for [voice]), both READMEs.
  • tests/voice_connection.rs::events_of_later_tasks_are_accepted asserted that a published microphone has no effects; that is exactly what this task changes, so that event moved out of the "no effects" loop.
  • LocalSettings::participant_volumes is a Box<ParticipantVolumes>: unboxed, the settings pushed PersistOp/PersistResult over clippy's large_enum_variant limit, and boxing the enum variants instead would have changed signatures other crates build against.
  • Output volume: the spec says "curve(user volume) × output volume"; the original (composeVoiceVolumeGain) puts the output volume through the same curve, and so does participant_gain. The setting itself arrives with Task 9; until then Voice::output_volume_percent() and Voice::vad_threshold() return the original's defaults (100, 50) — Task 9 only has to change those two functions, gains are re-evaluated after every event.
  • "Participant leaving removes its playback source": the port has no command to remove a mixer source, so core forgets the participant and what it told about it; freeing the mixer source on track end is the runtime's (Task 14).
  • The original also plays the join sound for this client's own join; the spec says "join/leave of others", which is what is built.

Stacked on: voice-7-core-voice-connection

Closes #69

🤖 Generated with Claude Code

## What this builds Voice plan Task 8 (spec §5.2 "Subscription policy", "Gain", "Speaking", "Chimes"), in `fluxer-core::voice`: - `voice/live.rs` — `LiveRoom` (`app.voice.live`): remote participants by LiveKit identity (`parse_identity`, the original's `user_(\d+)_(.+)`), their tracks, `rtt()` and `rtt_history()` (60 samples). Malformed identities and this client's own are ignored everywhere. - Subscription policy: `TrackPublished` of a microphone emits `SetSubscribed` (true iff not effectively deaf and the user is not locally muted) and `AudioCommand::SetGain`. After every event the policy is re-evaluated for every microphone publication and only changes are sent: deafen/undeafen (self or by a moderator), `SetLocalMute`, `SetUserVolume`; everything is sent again after `VoiceEvent::Reconnected`. Other sources get one explicit `SetSubscribed { subscribed: false }` on publish (as the original's `VoiceRoomEventBinder`) and are never subscribed. - `voice/volumes.rs` — `ParticipantVolumes { volumes, local_mutes }` (`app.voice.volumes`), `UserAction::{SetUserVolume { user_id, percent }, SetLocalMute { user_id, muted }}`, persisted in `LocalSettings::participant_volumes` (`[voice.volumes]` table and `voice.local_mutes` in `settings.toml`; old files load). `volume_gain` is the original's curve, `participant_gain(user, output)` the product. - `voice/speaking.rs` — the level detector with the original's 30 ms attack / 220 ms release and threshold (0.006 RMS at the default sensitivity), counted in 50 ms level reports because the store has no clock. Selectors `is_speaking`, `self_speaking`, `voice_ping`; `VoiceParticipantRow::speaking` is now live. Speaking is hidden while the user shows as self-muted, server-muted or suppressed. - Join/leave sounds for other connections entering or leaving my channel, with the 2000 ms duplicate window per connection (a timer; a leave ends the window). - A participant leaving (or the room being replaced or left) drops it from the room, so nothing is addressed to its playback source any more and a return sets it up from scratch. ## How it was tested `crates/fluxer-core/tests/voice_live.rs`: the nine tests the plan names, plus volumes loading/persisting, track mute, ping history, "nobody chimes while not in a room", "participant leaving removes its playback source", and a proptest that walks random room/gateway/user events and checks after every step that what the room was told equals the policy (a microphone is received exactly when not deaf and not locally muted; nothing else is ever subscribed). Unit tests for the curve, the detector and the identity parser. `crates/fluxer-platform/tests/settings.rs` round-trips the new keys and loads hand-written junk. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is green locally. Review focus 1 (deafen must stop receiving and mute the microphone): `deafen_unsubscribes_all_mics_and_undeafen_resubscribes`. ## Deviations from the plan - Files outside the task's list, each minimal: `event.rs` (the two `UserAction`s the Interfaces block asks for), `app.rs` (two lines: `Voice::load_settings`, pass `&Voice` to the persist reducer), `voice/connection.rs` (three lines: call `reduce_live`, empty the room on a new `Connect` and on close), `selectors/mod.rs` and `lib.rs` (re-exports), `fluxer-platform` `settings.rs` + test (the file format, as Task 7 did for `[voice]`), both READMEs. - `tests/voice_connection.rs::events_of_later_tasks_are_accepted` asserted that a published microphone has no effects; that is exactly what this task changes, so that event moved out of the "no effects" loop. - `LocalSettings::participant_volumes` is a `Box<ParticipantVolumes>`: unboxed, the settings pushed `PersistOp`/`PersistResult` over clippy's `large_enum_variant` limit, and boxing the enum variants instead would have changed signatures other crates build against. - Output volume: the spec says "curve(user volume) × output volume"; the original (`composeVoiceVolumeGain`) puts the output volume through the same curve, and so does `participant_gain`. The setting itself arrives with Task 9; until then `Voice::output_volume_percent()` and `Voice::vad_threshold()` return the original's defaults (100, 50) — Task 9 only has to change those two functions, gains are re-evaluated after every event. - "Participant leaving removes its playback source": the port has no command to remove a mixer source, so core forgets the participant and what it told about it; freeing the mixer source on track end is the runtime's (Task 14). - The original also plays the join sound for this client's own join; the spec says "join/leave of others", which is what is built. Stacked on: voice-7-core-voice-connection Closes #69 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #68

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
feat(core): voice connection state machine and ports
Some checks failed
ci / Linux (x86_64) (push) Has been cancelled
ci / Windows (x64) (push) Has been cancelled
ci / Linux (x86_64) (pull_request) Has been cancelled
ci / Windows (x64) (pull_request) Has been cancelled
3b33ca2c55
The ports of Voice spec §5.3 (voice::port), Effect::{Voice, Audio},
CoreEvent::{Voice, Audio, GatewayError}, the connection machine
(VoiceConnection, VoiceFailure) with join, leave, move, kick, resume and
token refresh, the user's mute and deafen switches (LocalVoiceState) saved
in a new [voice] section of the local settings, and effective_mute /
effective_deaf.

fluxer-platform reads and writes the new settings section; apps/fluxer
drops the two new effects until the voice runtime (Voice 14) exists.

Refs #68

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/voice' into voice/7-core-voice-connection
All checks were successful
ci / Linux (x86_64) (push) Successful in 7m37s
ci / Windows (x64) (push) Successful in 8m56s
ci / Linux (x86_64) (pull_request) Successful in 7m50s
ci / Windows (x64) (pull_request) Successful in 8m51s
67f0d8f32f
Refs #69

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
feat(core): live room, subscriptions, volumes and speaking
All checks were successful
ci / Linux (x86_64) (push) Successful in 21m31s
ci / Windows (x64) (push) Successful in 8m3s
e68ab28091
Refs #69

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Independent review: Voice 8 (core live room, volumes, speaking, chimes)

Reviewed 6a8bab0..e68ab28 cold, against the plan's Task 8, spec §5.2 and the fork.

1. Plan tests — all nine exist in tests/voice_live.rs and assert what the plan says: mic_track_subscribed_when_not_deaf, deafen_unsubscribes_all_mics_and_undeafen_resubscribes, local_mute_unsubscribes_that_user_only, camera_and_screen_tracks_never_subscribed, gain_is_curve_times_output_volume (0 / 50 / 100 / 150 / 200 % = 0, 10^-0.6, 1, 2, 4 to 1e-4, same as VoiceVolumeUtils.ts), speaking_is_active_speaker_or_level_and_hidden_when_muted, join_chime_deduplicated_within_2000ms (timer is exactly 2000 ms), leave_chime_for_my_channel_only, malformed_identity_is_ignored. Clearing the duplicate window on a leave matches the original (recentJoinChimesByConnectionId.delete).

2. Interfaces — ParticipantVolumes { volumes, local_mutes }, UserAction::{SetUserVolume { user_id, percent }, SetLocalMute { user_id, muted }}, is_speaking(&App, user_id), self_speaking(&App), voice_ping(&App), App.voice.{volumes, live} are present as written and persisted ([voice.volumes], voice.local_mutes; old files load).

3. Invariants — no new dependency in fluxer-core, core-isolation step green, no I/O. Identities, levels (NaN) and settings values from outside cannot panic; the proptest covers it. No secrets in code or fixtures.

4. Review Focus 1 — covered: self deafen and server deafen each emit SetSubscribed { subscribed: false } for every microphone and SetMicrophoneMuted(true); undeafen resubscribes; a microphone published while deaf is told false; Reconnected re-tells the room.

5. CI — FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci on e68ab28 in a clean target dir: all steps passed. Remote runners not checked.

Findings

  • minor — voice/live.rs: LiveRoom exposes rtt() / rtt_history() / participants() as methods over private fields, where the plan's Interfaces block reads rtt: Option<Duration>. Nothing merged reads the field and voice_ping is the selector, but Voice 17 (ping graph) has to use live.rtt_history().
  • minor — voice/speaking.rs: attack/release are counted in 50 ms reports, so the effective times are 50 ms / 250 ms instead of 30 / 220 ms, and they stretch or shrink if the audio engine (Voice 4/14) reports at another rate. Voice 14 has to keep the ~20 Hz cadence or pass elapsed time.
  • minor — voice/live.rs ParticipantLeft: core only forgets the participant; no command frees the mixer source (the port has none). Plan says "participant leaving removes its playback source", so Voice 14 has to drop the source on the room's ParticipantLeft itself. Worth a follow-up issue so it is not lost.
  • minor — voice/volumes.rs participant_gain: the output volume goes through the curve (as the original's composeVoiceVolumeGain) where spec §5.2 says a plain "× output volume". Identical at the fixed 100 % today; Voice 9 should confirm which one is meant when it wires the setting.
  • minor — event.rs, app.rs, voice/connection.rs, fluxer-platform/settings.rs are outside the task's file list, and voice_connection.rs::events_of_later_tasks_are_accepted (Voice 7) was edited. All of it is needed for the task and the edit only moves the microphone publication out of the "no effects" loop; Voice 9/10 will touch the same lines (LocalSettings is now boxed for ParticipantVolumes because of large_enum_variant).

Verdict: approve — no blocking findings, local ci green.

## Independent review: Voice 8 (core live room, volumes, speaking, chimes) Reviewed `6a8bab0..e68ab28` cold, against the plan's Task 8, spec §5.2 and the fork. **1. Plan tests** — all nine exist in `tests/voice_live.rs` and assert what the plan says: `mic_track_subscribed_when_not_deaf`, `deafen_unsubscribes_all_mics_and_undeafen_resubscribes`, `local_mute_unsubscribes_that_user_only`, `camera_and_screen_tracks_never_subscribed`, `gain_is_curve_times_output_volume` (0 / 50 / 100 / 150 / 200 % = 0, 10^-0.6, 1, 2, 4 to 1e-4, same as `VoiceVolumeUtils.ts`), `speaking_is_active_speaker_or_level_and_hidden_when_muted`, `join_chime_deduplicated_within_2000ms` (timer is exactly 2000 ms), `leave_chime_for_my_channel_only`, `malformed_identity_is_ignored`. Clearing the duplicate window on a leave matches the original (`recentJoinChimesByConnectionId.delete`). **2. Interfaces** — `ParticipantVolumes { volumes, local_mutes }`, `UserAction::{SetUserVolume { user_id, percent }, SetLocalMute { user_id, muted }}`, `is_speaking(&App, user_id)`, `self_speaking(&App)`, `voice_ping(&App)`, `App.voice.{volumes, live}` are present as written and persisted (`[voice.volumes]`, `voice.local_mutes`; old files load). **3. Invariants** — no new dependency in `fluxer-core`, core-isolation step green, no I/O. Identities, levels (NaN) and settings values from outside cannot panic; the proptest covers it. No secrets in code or fixtures. **4. Review Focus 1** — covered: self deafen and server deafen each emit `SetSubscribed { subscribed: false }` for every microphone and `SetMicrophoneMuted(true)`; undeafen resubscribes; a microphone published while deaf is told `false`; `Reconnected` re-tells the room. **5. CI** — `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` on `e68ab28` in a clean target dir: all steps passed. Remote runners not checked. ### Findings - **minor** — `voice/live.rs`: `LiveRoom` exposes `rtt()` / `rtt_history()` / `participants()` as methods over private fields, where the plan's Interfaces block reads `rtt: Option<Duration>`. Nothing merged reads the field and `voice_ping` is the selector, but Voice 17 (ping graph) has to use `live.rtt_history()`. - **minor** — `voice/speaking.rs`: attack/release are counted in 50 ms reports, so the effective times are 50 ms / 250 ms instead of 30 / 220 ms, and they stretch or shrink if the audio engine (Voice 4/14) reports at another rate. Voice 14 has to keep the ~20 Hz cadence or pass elapsed time. - **minor** — `voice/live.rs` `ParticipantLeft`: core only forgets the participant; no command frees the mixer source (the port has none). Plan says "participant leaving removes its playback source", so Voice 14 has to drop the source on the room's `ParticipantLeft` itself. Worth a `follow-up` issue so it is not lost. - **minor** — `voice/volumes.rs` `participant_gain`: the output volume goes through the curve (as the original's `composeVoiceVolumeGain`) where spec §5.2 says a plain "× output volume". Identical at the fixed 100 % today; Voice 9 should confirm which one is meant when it wires the setting. - **minor** — `event.rs`, `app.rs`, `voice/connection.rs`, `fluxer-platform/settings.rs` are outside the task's file list, and `voice_connection.rs::events_of_later_tasks_are_accepted` (Voice 7) was edited. All of it is needed for the task and the edit only moves the microphone publication out of the "no effects" loop; Voice 9/10 will touch the same lines (`LocalSettings` is now boxed for `ParticipantVolumes` because of `large_enum_variant`). **Verdict: approve** — no blocking findings, local ci green.
charles manually merged commit fb05a010cb into voice 2026-11-11 21:03:44 +00:00
Sign in to join this conversation.
No description provided.