Voice 12: fluxer-voice crate — session state machine over a room trait (#73) #114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "voice-12-voice-session"
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
New crate
crates/fluxer-voice(Voice spec §7, plan Voice 12):room.rs:trait Room(connect(url, token, RoomOptions { e2ee_key, max_bitrate })returning the connection'smpsc::Receiver<RoomEvent>,disconnect,set_mic_muted,set_subscribed(identity, sid, bool),publish_data,push_mic(Frame10ms)),RoomEvent(incl.Audio { identity, sid, samples }andRtt),Frame10ms,RoomError.session.rs:VoiceSession::spawn<R: Room>(room, events) -> VoiceHandle;VoiceHandle::{send, push_microphone(&[i16], channels), remote_audio() -> mpsc::Receiver<RemoteAudio>}.fake.rs(featurefake):FakeRoom+FakeRoomControl(scripted participants, tracks, tones, data, RTT, reconnects, connect failures and delays; records every call),tone_frame.Rules (documented at the top of
session.rsand in the README):Connectis dropped. Connecting:SetMicrophoneMuted/SetSubscribedare queued,PublishDatais dropped,Disconnectcancels the attempt, anotherConnectreplaces it.SetSubscribed { identity, source }resolves to the publication; a wish for a track published later is applied when it appears, and is forgotten when the participant leaves.Rttevery 2 s while connected, with the room's last measurement.Disconnectis idempotent; aConnectwhile connected swaps rooms withoutDisconnected, keeping mic state and wished subscriptions (the core does not re-send them on a token refresh).Tests
crates/fluxer-voice/tests/session.rs, 23 tests on tokio's paused clock againstFakeRoom: the eight named by the plan plus cancel/replace while connecting, queue-or-reject before connected, failed swap, per-source subscription, late-published track, mic gating, receiver replacement, and shutdown when the handle or the event reader is dropped. Seen failing against a stub session first.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally.Deviations from the plan
Room::connectreturns the event stream of that connection instead of the room having one stream for its lifetime: stale events of a replaced room cannot leak into the new one.RoomEvent::Audiocarries the tracksidnext toidentityandsamples(aFrame10ms), so the session can gate per track.RoomOptionsalso hasmax_bitrate(Voice 13 reads it).VoiceCommand::Connectdoes not carry the channel bitrate, so the session always passesDEFAULT_MAX_BITRATE(64 kbit/s); wiring the real value needs a port change influxer-core.Frame10msis defined here rather than reusingfluxer_audio::Frame, so the crate does not depend onfluxer-audio.fake(socargo testneeds no flags) and tokiotest-utilfor dev only; no new third-party crate.Cargo.lockgains only thefluxer-voiceentry.Stacked on: voice-7-core-voice-connection
Closes #73
🤖 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 12 (
fluxer-voicesession), commit3622ad7Reviewed
e847130..3622ad7cold (8 files, all incrates/fluxer-voiceplus theCargo.lockentry).Checks
tests/session.rsand assert what the plan says —connect_emits_connected_and_publishes_muted_mic,connect_failure_reports_error,subscribe_unsubscribe_gates_audio,reconnect_events_pass_through,second_connect_swaps_room_silently(noDisconnected, exactly one roomDisconnectbefore the newConnect),disconnect_is_idempotent,rtt_reported_every_2s(paused clock, on the 2000 ms grid),data_messages_round_trip(topic equalsfluxer_proto::rtc::CODEC_NEGOTIATION_TOPIC). 23 tests in total, all pass.VoiceSession::spawn<R: Room>(room, events: mpsc::Sender<VoiceEvent>) -> VoiceHandle,VoiceHandle::{send, push_microphone(&[i16], channels), remote_audio() -> mpsc::Receiver<RemoteAudio>},RemoteAudio { identity, samples: Vec<i16>, channels },FakeRoom+FakeRoomControlbehind featurefakeare as written.trait Roomhas the six methods. Deviations are listed under findings; none breaks a consumer that builds against the merged code.fluxer-coreuntouched; no LiveKit type anywhere; nounwrap/expect/indexing insrc/; malformed microphone frames are dropped, not asserted; no secret in code or tests (tokens are literals liketoken-one),Target/RoomOptionsholdSecretString, nothing logs a URL, token, key or payload. Crate also checks standalone with and withoutfake(no reliance on feature unification).room.set_subscribed(.., false)(asserted as the last room call) and frames arriving afterwards are not passed on; a muted microphone is never fed to the room (asserted onmic_frames). Core ignoresDisconnected { ClientInitiated }(connection.rs:664), so the cancel-while-connecting event is harmless.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin the review worktree: all steps passed (fmt, clippy, deny, core-isolation, parity, test, screenshot-tests).Findings
session.rs:427always passesDEFAULT_MAX_BITRATE(64 kbit/s). Spec §7 wants the channel bitrate clamped to 8–510 kbit/s; that needsVoiceCommand::Connectto carry it (afluxer-coreport change). PerCLAUDE.mda deferred item needs afollow-upissue linked from this PR before merge; none exists yet.Room::connectreturnsResult<mpsc::Receiver<RoomEvent>, RoomError>(one stream per connection, not per room);RoomEvent::Audio { identity, sid, samples: Frame10ms }(plan:{ identity, samples });RoomOptionshasmax_bitratebesidese2ee_key;Room::connectmay be dropped mid-flight and is then followed bydisconnect(). Reasonable and documented; flagged so the Voice 13 implementer does not follow the plan text.apply_subscription) and "a mute holds even if the room could not be told" have no test:FakeRoomControlcannot failset_subscribed/set_mic_mutedfor a published track. The code is right by reading. Related: a failed subscribe leaves the wishtruebut is not retried until the track is republished.wanted.subscriptionskeeps entries for identities that are not in the new room; they are only cleared byParticipantLeftor going idle. Bounded and harmless (an identity that reappears is re-subscribed as the core last asked), but it grows across repeated channel moves in one session.step()uses abiasedselect with room events ahead of the RTT timer and the microphone queue; a room that keeps its event stream non-empty would delay microphone frames. Not reachable with the fake; worth keeping in mind when Voice 13 feeds decoded audio of many participants through the same stream.README.mdcrate table has nocrates/fluxer-voicerow (outside this task's Files list).Verdict: APPROVE — zero blocking findings, local ci green. Remote runners not checked by this review.