From c8464e075cc66704c0f9210113a3b852121c5d2a Mon Sep 17 00:00:00 2001
From: cai <cai@nbcai.cc>
Date: Sat, 08 Aug 2026 18:55:07 +0800
Subject: [PATCH] test: cover participant binding rejection

---
 helper-paired-manifest.json |    4 ++--
 src/main.rs                 |   25 +++++++++++++++++++++----
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/helper-paired-manifest.json b/helper-paired-manifest.json
index dc77434..e7fd9a2 100644
--- a/helper-paired-manifest.json
+++ b/helper-paired-manifest.json
@@ -11,8 +11,8 @@
     "lmDocRollbackCommit": "0cec0c4ffed92f277778adbbd14eea3e5aa562b6",
     "implementationBaseCommit": "afd9833f82e9c1f6d5dfe7f2250f19f1af5cdd7d",
     "implementationBaseTree": "a9af1be31c66740fefe54223e0ea0559b78aaba0",
-    "candidateCommit": "cce5655f2f88e6541ba6f70cb68d183beba19ac9",
-    "candidateTree": "65acfece24241a5f9fd3cc5a2e3351ed33bb641f",
+    "candidateCommit": "ad9ba4c2a439c8ef464e34c19696300519e134b6",
+    "candidateTree": "2a3f48f3394e4d87bf8ae59db6bef132f64c7b6a",
     "repairParent": "efc73c570bb70ba4de23afc785350629ef5016a7",
     "buildBoundary": "JENKINS_33_BUILD_ONLY_SUCCESS"
   },
diff --git a/src/main.rs b/src/main.rs
index eeb7158..9b08934 100644
--- a/src/main.rs
+++ b/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();
 

--
Gitblit v1.9.3