YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
test(audio): pin the FaceTime contract around the mic-holder snapshot gate
Ezra Ellettec5508d54b684
diff --git a/crates/screenpipe-audio/src/meeting_processes.rs b/crates/screenpipe-audio/src/meeting_processes.rsindex 9d503cad8..ed6f4e783 100644--- a/crates/screenpipe-audio/src/meeting_processes.rs+++ b/crates/screenpipe-audio/src/meeting_processes.rs@@ -70,6 +70,26 @@ fn is_screenpipe_bundle_id(bundle_id: &str) -> bool {|| bundle_id.starts_with("com.mediar.screenpipe.")}+/// The snapshot inclusion decision: `Some(reason)` if this mic-holding+/// process must be dropped from the snapshot, `None` if it counts as meeting+/// evidence. This is the single gate the macOS collector runs, kept pure so+/// the contract is directly testable — in particular the FaceTime contract:+/// `avconferenced` (FaceTime's audio engine) and the FaceTime app itself MUST+/// pass, or FaceTime meetings lose adoption/capture.+#[cfg_attr(not(target_os = "macos"), allow(dead_code))]+fn excluded_input_process_reason(+ process: &AudioInputProcess,+ self_pid: i32,+) -> Option<&'static str> {+ if is_screenpipe_process(process, self_pid) {+ return Some("Screenpipe process");+ }+ if is_system_voice_daemon(process) {+ return Some("always-on voice daemon");+ }+ None+}+/// Always-on system voice daemons whose input claims are ambient noise, not/// meeting evidence. `corespeechd` (com.apple.CoreSpeech) holds the mic for/// the "Hey Siri" voice trigger more or less permanently, so counting it made@@ -104,7 +124,7 @@ fn is_screenpipe_app_name(name: &str) -> bool {#[cfg(target_os = "macos")]mod platform {- use super::{is_screenpipe_process, AudioInputProcess, AudioProcessSnapshot};+ use super::{excluded_input_process_reason, AudioInputProcess, AudioProcessSnapshot};use cidre::{core_audio as ca, ns};use tracing::debug;@@ -162,9 +182,9 @@ mod platform {first_seen_at_ms: None,};- if is_screenpipe_process(&snapshot, self_pid) {+ if let Some(reason) = excluded_input_process_reason(&snapshot, self_pid) {debug!(- "audio-process snapshot: skipped Screenpipe process (pid={:?}, bundle={:?}, owner_bundle={:?}, name={:?})",+ "audio-process snapshot: skipped {reason} (pid={:?}, bundle={:?}, owner_bundle={:?}, name={:?})",snapshot.pid,snapshot.bundle_id,snapshot.owner_bundle_id,@@ -176,14 +196,6 @@ mod platform {continue;}- if super::is_system_voice_daemon(&snapshot) {- debug!(- "audio-process snapshot: skipped always-on voice daemon (pid={:?}, bundle={:?})",- snapshot.pid, snapshot.bundle_id- );- continue;- }-out.push(snapshot);}@@ -717,6 +729,45 @@ mod tests {);}+ /// The FaceTime contract, pinned on the exact gate the macOS collector+ /// runs: during a FaceTime call the mic holders are `avconferenced`+ /// (audio IO daemon) and/or the FaceTime app itself. BOTH must pass the+ /// snapshot gate — the daemon's pid is what manual-meeting adoption taps+ /// and what mic-follow resolves; the app's bundle id is what the auto+ /// meeting detector maps to the "FaceTime" platform.+ #[test]+ fn facetime_processes_pass_the_snapshot_gate() {+ let daemon = process(+ Some(809),+ Some("com.apple.avconferenced"),+ None,+ None,+ None,+ );+ let app = process(+ Some(1234),+ Some("com.apple.FaceTime"),+ Some("FaceTime"),+ Some("FaceTime"),+ Some("com.apple.FaceTime"),+ );+ assert_eq!(+ excluded_input_process_reason(&daemon, 999),+ None,+ "avconferenced must be included in mic-holder snapshots"+ );+ assert_eq!(+ excluded_input_process_reason(&app, 999),+ None,+ "the FaceTime app must be included in mic-holder snapshots"+ );+ // And the gate still drops what it must:+ let siri = process(Some(727), Some("com.apple.CoreSpeech"), None, None, None);+ assert!(excluded_input_process_reason(&siri, 999).is_some());+ let own = process(Some(999), None, None, None, None);+ assert!(excluded_input_process_reason(&own, 999).is_some());+ }+#[test]fn meeting_apps_are_not_system_voice_daemons() {for bundle_id in ["us.zoom.xos", "com.google.Chrome", "com.microsoft.teams2"] {diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rsindex 12e6631cf..06db3391b 100644--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs@@ -133,6 +133,72 @@ fn windows_exe_names_map_to_native_platform() {}}+fn facetime_app_process() -> AudioInputProcess {+ AudioInputProcess {+ audio_session_id: None,+ audio_object_id: Some(400),+ pid: Some(1234),+ bundle_id: Some("com.apple.FaceTime".to_string()),+ process_name: Some("FaceTime".to_string()),+ owner_app_name: Some("FaceTime".to_string()),+ owner_bundle_id: Some("com.apple.FaceTime".to_string()),+ first_seen_at_ms: None,+ }+}++/// FaceTime auto-detection: the FaceTime APP holding the mic resolves to the+/// FaceTime native platform. (FaceTime's audio IO daemon `avconferenced` is a+/// separate process — see `facetime_daemon_is_not_an_identity_signal`.)+#[test]+fn facetime_app_maps_to_native_platform() {+ let profiles = load_detection_profiles();+ let process = facetime_app_process();+ let candidate = resolve_process_candidate(+ ProcessKey::from_process(&process).unwrap(),+ Instant::now(),+ &process,+ &profiles,+ &[],+ &[],+ &[],+ );+ assert!(matches!(+ candidate,+ ResolvedMeetingCandidate::Native { platform, .. } if platform == "FaceTime"+ ));+}++/// Documents (pre-existing, unchanged) behavior: `avconferenced` — FaceTime's+/// audio IO daemon — is NOT a platform identity for auto-detection; the+/// FaceTime app itself is (above). The daemon still matters downstream: it+/// stays in mic-holder snapshots (see+/// `meeting_processes::tests::facetime_processes_pass_the_snapshot_gate`) so+/// manual-meeting adoption taps it and mic-follow resolves its real mic.+#[test]+fn facetime_daemon_is_not_an_identity_signal() {+ let profiles = load_detection_profiles();+ let process = AudioInputProcess {+ audio_session_id: None,+ audio_object_id: Some(104),+ pid: Some(809),+ bundle_id: Some("com.apple.avconferenced".to_string()),+ process_name: None,+ owner_app_name: None,+ owner_bundle_id: None,+ first_seen_at_ms: None,+ };+ let candidate = resolve_process_candidate(+ ProcessKey::from_process(&process).unwrap(),+ Instant::now(),+ &process,+ &profiles,+ &[],+ &[],+ &[],+ );+ assert!(matches!(candidate, ResolvedMeetingCandidate::NonMeeting));+}+#[test]fn browser_helper_alone_is_unresolved_browser() {let profiles = load_detection_profiles();