Voice 7: fluxer-core::voice connection machine and ports (#68) #110
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "voice-7-core-voice-connection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this builds
Voice plan Task 7: this client's own voice connection in
fluxer-core, and the ports the voice session and the audio engine are driven through.voice::port, spec §5.3):VoiceCommand,VoiceEvent,AudioCommand,AudioEventwith exactly the variants of the spec, plusTrackSource,DisconnectReason,PlaybackSource,ClipRef,ClipTag,Chime,CaptureConfig,AudioDevices,DeviceId.Effect::{Voice, Audio}andCoreEvent::{Voice, Audio}carry them.VoiceCommand::Connectholds the token and the E2EE key asSecretStrings; a test checks that neither shows inDebug.voice::connection):VoiceConnection::{Idle, AwaitingServer, Connecting, Connected, Reconnecting, Failed}andVoiceFailure::{Timeout, Gateway(GatewayErrorCode), Room(String), E2eeRequired}. Join (op 4 without connection id, 15 s timeout,ConnectonVOICE_SERVER_UPDATE), leave (Disconnect, then op 4 with a null channel), move (same connection id), kick and moderator move (ownVOICE_STATE_UPDATE), op 4 re-sent afterREADY/RESUMED, a freshVOICE_SERVER_UPDATEreplacing the room without leaving, room loss and connect failure.voice::local):LocalVoiceState { self_mute, self_deaf },UserAction::{JoinVoice, LeaveVoice, RetryVoice, DismissVoiceError, ToggleSelfMute, ToggleSelfDeaf},effective_mute(&App),effective_deaf(&App). Deafening mutes, undeafening restores the mute state from before, unmuting while deafened undeafens (the fork'sLocalVoiceStateMachine.ts). The microphone track follows effective mute throughSetMicrophoneMuted, sent only on change.LocalSettings::voice, saved throughPersistOp::SaveSettingson each toggle; a settings file without the section loads as not muted.How it was tested
crates/fluxer-core/tests/voice_connection.rs, written first and committed failing (eab2d31): the twelve tests the plan names, the proptestany_event_order_never_panics(random walks over user actions, dispatches, room events, timers, gateway errors and logout, checking that a room or a capture never outlives the connection and that capture is never started twice; also run once with 4000 cases), and four more (unusable_endpoint_fails_the_join,local_state_is_saved_and_loaded,logout_leaves_the_room,events_of_later_tasks_are_accepted).crates/fluxer-platform/tests/settings.rsgains a test for a settings file from before voice.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally.Deviations from the plan
fluxer-platform(settings.rs, its test and README): the[voice]section, without which the new setting would never reach the file.apps/fluxer/src/runtime.rs: one match arm that dropsEffect::Voice/Effect::Audiowith a debug line, so the workspace compiles until Voice 14. Influxer-core,session.rsandmessages.rseach gained the newCoreEventvariants in an exhaustive match.CoreEvent::GatewayError(GatewayError)is new and not in the plan: op 12 had no way into the store. Nothing sends it yet, becausefluxer-gatewayonly logs the frame (#108). Until that lands, a refused join shows as a timeout after 15 s.Connected.sinceisOption<Timestamp>and alwaysNone. The store has no clock andVoiceEvent::Connectedcarries no time (#109). Voice 17's duration display depends on it.AwaitingServerhas a fourth field,moving: Option<MovingFrom>. During a move the old room stays up, and a move the server refuses or never answers returns toConnectedin the old channel instead of dropping the call. The refusal is only logged; the UI gets no error for it.VoiceTarget { guild_id, channel_id }is thetargetthe spec leaves untyped.DisconnectReason::{ClientInitiated, DuplicateIdentity, ParticipantRemoved, RoomDeleted, ServerShutdown, ConnectionLost, Other(String)},PlaybackSource::{Participant(identity), Clip(ClipTag)},ClipRef { key, content_type },ClipTag(u64),DeviceId(String)with"default",AudioDevices { inputs, outputs }ofAudioDevice { id, name, is_default },CaptureConfig { denoise, gate, auto_gain, echo_cancellation, stereo, input_volume_percent }(mirrorsfluxer_audio::ChainConfigwithout depending on it).Disconnectedwith any reason butClientInitiated, orConnectFailed) goes toFailedand sends the op 4 leave form for the connection, so the server does not keep a ghost; "Try again" is a fresh join. There is no automatic rejoin beyond the SDK's own reconnection.VOICE_CONNECTION_NOT_FOUND,VOICE_USER_NOT_IN_VOICE,VOICE_PENDING_EXPIRED,VOICE_NONCE_MISMATCH) fail it; others are ignored.GUILD_DELETEof the connection's guild ends the connection.AudioCommand::StartCapture(CaptureConfig::default())onConnectedandStopCapturewhen the connection ends (Voice 9 replaces the default withcapture_config(&App)), and the mute, unmute, deafen, undeafen and disconnect chimes (Voice 8 adds join and leave). The mute and deafen chimes play whether or not the client is in voice, as in the original.Notes for the reviewer
voice-7-core-voice-connection:voice/7-...cannot exist on the remote next to thevoicebranch (same as Voice 1 to 6). The local branch keeps the plan's name.ConnectFailedfrom an abandoned attempt would fail the next one if it arrives while that one isConnecting. Worth keeping in mind for Voice 12.Stacked on: voice-6-core-voice-states
Closes #68
🤖 Generated with Claude Code
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>Independent review: Voice 7 (core voice connection), head
3b33ca2Reviewed
d245b6f..3b33ca2cold, in its own worktree.Checks
any_event_order_never_panicsexist incrates/fluxer-core/tests/voice_connection.rsand assert the spec's values: 15 s timer (JOIN_TIMEOUTand the scheduledafter), the fork's join form withconnection_id: null, the leave form (channel_id: null,self_mute/self_deaf: true, connection id) sent afterVoiceCommand::Disconnect, the move with the same connection id, kick without op 4 and with the disconnect chime, op 4 re-sent onRESUMEDandREADY, a refreshedVOICE_SERVER_UPDATEgiving exactly oneConnectand noDisconnect/StopCapture, undeafen restoring the earlier mute state, server mute/suppress/deaf keeping the track muted,ReconnectingthenFailed, and another connection's server update ignored.VoiceCommand,VoiceEvent,AudioCommand,AudioEventwith the spec §5.3 variants and field names,TrackSource,DisconnectReason,PlaybackSource,ClipRef,ClipTag,Chime,CaptureConfig,AudioDevices,DeviceId,Effect::{Voice, Audio},CoreEvent::{Voice, Audio},VoiceFailurewith its four variants, the sixUserActions,LocalVoiceState { self_mute, self_deaf },effective_mute(&App),effective_deaf(&App)). Two shape differences from spec §5.1 are listed below.Cargo.toml/lock change, sofluxer-coregains no dependency; nounwrap/expect/indexing in the new source; the token and E2EE key staySecretStringand a test checks they do not show inDebug; the endpoint parse error is logged without the URL; no fixture was added.cargo xtask ciin the review worktree: all steps passed (screenshot step skipped,FLUXER_SCREENSHOT_TESTSnot set for this run).Findings
voice/connection.rs—VoiceConnectiondiffers from spec §5.1 in two places:Connected.sinceisOption<Timestamp>and alwaysNone(#109), andAwaitingServerhas a fourth fieldmoving. Both are declared in the PR. Voice 17 must handleNoneuntil #109 lands, and consumers have to matchAwaitingServer { .. }.voice/connection.rs(on_timer,on_server_update) — after a 15 s timeout, or a leave before the server answered, a lateVOICE_SERVER_UPDATEis dropped inIdle/Failedand the connection the server created for it is never given back. The original sends the leave form after the timeout (VoiceEngineV2AppConnectionHostAdapter.ts:1095). Until the server expires the pending connection, the user can show in the channel without being in it. Suggest answering such an update withVoiceStateUpdateParams::leave(guild_id, connection_id); worth a follow-up issue.voice/connection.rs(on_gateway_error) — any op 12 whileAwaitingServerfails the join, including codes that are not about voice. Nothing emitsCoreEvent::GatewayErroryet (#108); when it does, filter on voice codes or the join can fail because of an unrelated request.voice/connection.rs(on_gateway,GuildDelete) — the call is ended with no op 4 also whenunavailable: true(an outage, the user is still a member). If only the guild's gateway side restarted, the server may keep the connection while the client dropped it. Not checked against the original.voice/connection.rs(on_room) — room events carry no attempt id, so a lateConnectFailed/Disconnectedfrom a replaced or abandoned room can fail the next attempt while it isConnecting. Declared in the PR; Voice 12 has to guarantee that a replaced room reports nothing.voice/local.rs—unmute_on_undeafenis not persisted, so after a restart while deafened, undeafening leaves the microphone muted even if it was unmuted before deafening.fluxer-platformandapps/fluxerbesidesfluxer-core. Both are needed (the[voice]section, an exhaustive match) and declared; the platform change has its own test.Verdict: approved — no blocking findings, local ci green.