cai
2026-08-08 c8464e075cc66704c0f9210113a3b852121c5d2a
src/main.rs
@@ -737,6 +737,10 @@
    })
}
fn is_bound_user_participant(identity: &str, expected: Option<&str>) -> bool {
    expected.is_none_or(|value| identity == value)
}
async fn observe_user_audio_events(
    mut events: UnboundedReceiver<RoomEvent>,
    call_id: String,
@@ -771,10 +775,10 @@
                publication: _,
                participant,
            } => {
                if user_participant_identity
                    .as_deref()
                    .is_some_and(|expected| participant.identity().to_string() != expected)
                {
                if !is_bound_user_participant(
                    &participant.identity().to_string(),
                    user_participant_identity.as_deref(),
                ) {
                    warn!(call_id = %call_id, trace_id = %trace_id,
                        metadata_status = "wrong_participant",
                        "runtime helper ignored non-user audio participant");
@@ -4036,6 +4040,19 @@
    }
    #[test]
    fn production_observer_rejects_wrong_participant_before_vad_session() {
        assert!(!is_bound_user_participant(
            "participant-other",
            Some("participant-user")
        ));
        assert!(is_bound_user_participant(
            "participant-user",
            Some("participant-user")
        ));
        assert!(is_bound_user_participant("participant-any", None));
    }
    #[test]
    fn reply_chunk_marker_state_emits_turn_first_once_and_later_segment_first_once() {
        let mut state = ReplyChunkMarkerState::default();