Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
feat(meeting): Phase 4 - scored-clean attribution for voice-processing sessions
Shreeraman A K3745dab75a41
diff --git a/Fluid.xcodeproj/project.pbxproj b/Fluid.xcodeproj/project.pbxprojindex 0914fb40..f16be580 100644--- a/Fluid.xcodeproj/project.pbxproj+++ b/Fluid.xcodeproj/project.pbxproj@@ -40,6 +40,7 @@E5EC00000000000000000072 /* ClockDomainProbeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5EC00000000000000000071 /* ClockDomainProbeTests.swift */; };E5EC00000000000000000082 /* MeetingMicrophoneCaptureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5EC00000000000000000081 /* MeetingMicrophoneCaptureTests.swift */; };5A3B00000000000000000002 /* MeetingVoiceProcessingCaptureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A3B00000000000000000001 /* MeetingVoiceProcessingCaptureTests.swift */; };+ 5A4B00000000000000000002 /* MeetingPhase4Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A4B00000000000000000001 /* MeetingPhase4Tests.swift */; };E5EC000000000000000000A2 /* MeetingTimelineDriftProbeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5EC000000000000000000A1 /* MeetingTimelineDriftProbeTests.swift */; };E5EC00000000000000000092 /* ClockRegressionHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5EC00000000000000000091 /* ClockRegressionHelper.swift */; };A6E2246FA3744C7B3E2DB91C /* MeetingLiveTranscriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 355C1248D5386D1F815EB7D7 /* MeetingLiveTranscriptionTests.swift */; };@@ -108,6 +109,7 @@E5EC00000000000000000071 /* ClockDomainProbeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClockDomainProbeTests.swift; sourceTree = "<group>"; };E5EC00000000000000000081 /* MeetingMicrophoneCaptureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingMicrophoneCaptureTests.swift; sourceTree = "<group>"; };5A3B00000000000000000001 /* MeetingVoiceProcessingCaptureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingVoiceProcessingCaptureTests.swift; sourceTree = "<group>"; };+ 5A4B00000000000000000001 /* MeetingPhase4Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingPhase4Tests.swift; sourceTree = "<group>"; };E5EC000000000000000000A1 /* MeetingTimelineDriftProbeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingTimelineDriftProbeTests.swift; sourceTree = "<group>"; };E5EC00000000000000000091 /* ClockRegressionHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClockRegressionHelper.swift; sourceTree = "<group>"; };355C1248D5386D1F815EB7D7 /* MeetingLiveTranscriptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingLiveTranscriptionTests.swift; sourceTree = "<group>"; };@@ -224,6 +226,7 @@E5EC00000000000000000071 /* ClockDomainProbeTests.swift */,E5EC00000000000000000081 /* MeetingMicrophoneCaptureTests.swift */,5A3B00000000000000000001 /* MeetingVoiceProcessingCaptureTests.swift */,+ 5A4B00000000000000000001 /* MeetingPhase4Tests.swift */,E5EC000000000000000000A1 /* MeetingTimelineDriftProbeTests.swift */,E5EC00000000000000000091 /* ClockRegressionHelper.swift */,355C1248D5386D1F815EB7D7 /* MeetingLiveTranscriptionTests.swift */,@@ -425,6 +428,7 @@E5EC00000000000000000072 /* ClockDomainProbeTests.swift in Sources */,E5EC00000000000000000082 /* MeetingMicrophoneCaptureTests.swift in Sources */,5A3B00000000000000000002 /* MeetingVoiceProcessingCaptureTests.swift in Sources */,+ 5A4B00000000000000000002 /* MeetingPhase4Tests.swift in Sources */,E5EC000000000000000000A2 /* MeetingTimelineDriftProbeTests.swift in Sources */,E5EC00000000000000000092 /* ClockRegressionHelper.swift in Sources */,A6E2246FA3744C7B3E2DB91C /* MeetingLiveTranscriptionTests.swift in Sources */,diff --git a/MIC_CAPTURE_MIGRATION_PLAN.md b/MIC_CAPTURE_MIGRATION_PLAN.mdindex df686460..8f4b9c1d 100644--- a/MIC_CAPTURE_MIGRATION_PLAN.md+++ b/MIC_CAPTURE_MIGRATION_PLAN.md@@ -63,21 +63,30 @@ That acceptance was given for the **speakers** case and does not extend to headpFor a VPIO session, on the microphone track:- Diarization runs exactly as today (it is the segmenter), and **the election runs unchanged**.-- VPIO turns are marked **scored clean** — `echoScored = true, isLikelyEcho = false` — because that is- what they are: examined, and known to contain no far-end audio. They therefore count as supporting- evidence in `localSpeakerEvidence` (`MeetingProcessingPipeline.swift:357`) exactly as a- text-examined clean turn does today.+- VPIO turns are marked **scored clean** — `echoScored` is widened to `true` on every turn, forced+ after the existing text-detector loop runs — because that is what they are: AEC-clean by hardware.+ They therefore count as supporting evidence in `localSpeakerEvidence`+ (`MeetingProcessingPipeline.swift:357`) exactly as a text-examined clean turn does today.- **This is the whole change.** No branch on cluster count, no bypass. AEC does not make diarizationunnecessary — it makes it work, by removing the echo clusters that competed with the user's ownvoice and defeated the 1.75× margin rule in the observed failure. A second voice in the room is thenhandled by the election as it always was, which matters because misattribution is**uncorrectable in-product**: `mergeSpeakers` refuses any speaker with `isLocalUser`(`MeetingModels.swift:542`).-- The text echo detector is not consulted; the signal veto is not applied.-- `MeetingEchoSignalScorer` still runs as a **monitor**: its verdicts are recorded, never applied.- This is the only field evidence that AEC worked on hardware we have not measured; without it a- silently-degraded canceller yields bleed labelled "You", forever undetected.+- ~~The text echo detector is not consulted; the signal veto is not applied.~~ **Superseded by Phase 4+ measurement:** a healthy VPIO gate session produced zero `.echo` verdicts (7 `containsLocalSpeech` /+ 1 `unknown` / 0 `echo`) — the veto had nothing to veto. Suppressing it bought nothing on working+ hardware and risked bleed-as-"You" on degraded hardware. Phase 4 ships with **both kept**: the text+ detector still runs wherever remote text exists, and the signal veto still demotes+ `signalVerdict == .echo` turns exactly as it does for non-VPIO tracks.+- `MeetingEchoSignalScorer` still runs as a **monitor**: its verdicts are recorded, never applied+ beyond the (retained) veto. This is the only field evidence that AEC worked on hardware we have not+ measured; without it a silently-degraded canceller yields bleed labelled "You", forever undetected.+ Phase 4 adds a per-session log-only summary (verdict breakdown, real scoreable coverage, delay-lock+ info) plus a WARN when coverage is ~0 while the application track carried speech.- `MeetingLiveEchoFilter` is disabled for VPIO sessions (`MeetingLiveTranscriptionCoordinator.swift:150`).+- The decider now also requires `role == .personal` — the election and near-field gate already did,+ so a role-blind VPIO session captured cleanly but could never attribute.- `pipelineVersion` bumps; attribution rules changed.Unchanged: `.inRoom` (`AVCaptureSession`, not SCStream — `MeetingCaptureEngine.swift:624`), non-VPIO@@ -191,7 +200,7 @@ PTS behind emitted audio, timeline reset on `AVAudioEngineConfigurationChange`,values in the probe's track metadata. Absolute cross-path offset remains unmeasured (AEC removesacoustic stimuli, as reviewed) and is Phase 3's first real-call validation item.-**Phase 3 — integrate behind a flag, default off. BUILT 2026-08-15, gate pending (needs a real call).**+**Phase 3 — integrate behind a flag, default off. DONE 2026-08-17, gate PASSED on a real call.**Shipped behind `meetingVPIOMicCapture` (Settings → experimental, off): pre-flight capabilitydecision (pure decision table; flag + `.onlineCall` + CoreAudio UID + built-in-speaker output route,every decline reason logged to session events); `VoiceProcessingMeetingRuntime` with a commit gate —@@ -209,16 +218,40 @@ pipelineVersion bump (no pre-flag `.voiceProcessing` tracks can exist; checkpoinapplication pass only). Live echo filter untouched — deferred to Phase 4 as an attribution change.Reviewed adversarially over three rounds (two independent reviewers from BLOCK to PROCEED /PROCEED WITH CHANGES, all findings folded); 36 new unit tests.-*Gate (open):* a real call ≥15 min (materiality must actually cross) whose transcript ordering is-compared turn-by-turn against a human-checked reference. Not a simultaneous old-path capture — two-microphone clients with one enabling VPIO perturbs the system under test. Also: start latency-p50/p95 both paths, `silentForSeconds` under AGC, meeting→dictation teardown, flag-off byte-identical.--**Phase 4 — attribution.** One change: mark VPIO turns scored-clean and let the existing election run.-*Gate:* a single-voice VPIO session elects "You" with no `Microphone / Unknown`; a **two-voice**-session still elects the owner and demotes the second speaker; a non-VPIO session produces a-transcript identical to today's. The first alone proves nothing — the second is the real test, and it-is only possible because the diarizer was kept.+*Gate results (2026-08-17, 15.5-min Zoom call, built-in mic/speakers):* VPIO engaged+(`boundVerified` device 78, settled output BuiltInSpeakerDevice); live mic stream carried ONLY the+user's speech while far-end played on speakers (previously a verbatim mirror of the app stream);+double-talk captured the user cleanly as "You" mid-far-end-monologue; zero drops both streams.+Batch: 53 segments — You 20 (all genuinely the user, `isLocalUser` elected), far end 32 across+Speaker 1-5, ONE 2-word "Microphone / Unknown" fragment ("code and") — a non-local+diarization cluster; deliberately NOT forced into "You" by Phase 4 (indistinguishable from a second+voice's interjection). Drift record: −5.24 ms over 957 s (−5.5 ppm, matching the bench++6.7 ppm fast-mic sign analysis), eligible, materiality crossed → de-drift executed on a real+session. AirPods-at-start declined correctly ("The output device is Bluetooth", session ran+SCStream path); AirPods mid-recording → route listener fired instantly with the designed message,+clean interrupted state, audio preserved, retry offered. Post-meeting dictation normal.+Not yet measured: start latency p50/p95, `silentForSeconds` under AGC over a long quiet stretch.++**Phase 4 — attribution. BUILT 2026-08-17, gate PENDING.** Marks VPIO turns scored-clean+(`echoScored` widened to every turn, forced after the existing text-classification loop) and lets the+existing election run; text detector and signal veto both kept (measurement-driven reversal of the+original "not consulted / not applied" plan, see §5). Decider now requires `role == .personal`+(`MeetingCapturePathDecider.decide`, decline reason "Microphone role is not set to personal").+`logLocalSpeakerElection` gained `captureMethod` and a widened-turns counter (count + seconds forced+scored with no remote text to examine), since `unscoredOverlap` pins to 0.0s under VPIO. New log-only+per-session echo-monitor summary (verdict breakdown, real scoreable seconds — never fabricated from+turn duration, extended `EchoScoringOutcome`/`computeEchoVerdicts` — delay-lock chunks/confidence) plus+a WARN on ~0 coverage while the app track carried speech. Live: `MeetingLiveTranscriptionCoordinator`+gained `setMicrophoneCaptureMethod`, called from `MeetingSessionCoordinator` right after+`capture.start()` returns; `.voiceProcessing` skips `shouldSuppress`, nil (fail-safe default) keeps it+on, bracketed by `[live/ECHO]` log lines so pre-setter suppressions are countable.+`pipelineVersion` 6 → 7 (checkpoint invalidation only). The classification block was extracted to a+`nonisolated static` pure function, `classifyMicrophoneTurns`, so it and the election are unit-tested+directly; non-VPIO path is byte-identical by construction (the widening branch never executes).+*Gate (attended, not yet run):* a single-voice VPIO session elects "You" with no+`Microphone / Unknown`; a **two-voice** session still elects the owner and demotes the second speaker;+a non-VPIO session produces a transcript identical to today's. The first alone proves nothing — the+second is the real test, and it is only possible because the diarizer was kept.## 10. Not claimable unattendeddiff --git a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTranscriptionCoordinator.swift b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTranscriptionCoordinator.swiftindex 0f1c5f27..4ceacfe9 100644--- a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTranscriptionCoordinator.swift+++ b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTranscriptionCoordinator.swift@@ -22,6 +22,8 @@ final nonisolated class MeetingLiveTranscriptionCoordinator: @unchecked Sendableprivate var snapshot: MeetingLiveTranscriptSnapshot = .emptyprivate var recentThemUtterances: [MeetingLiveUtterance] = []private var offerCounts: [MeetingAudioTrackKind: Int] = [:]+ /// nil (fail-safe) keeps the echo filter ON; guarded by `stateLock` on both sides.+ private var microphoneCaptureMethod: MeetingAudioTrackCaptureMethod?private let originBox = MeetingLiveOriginBox()private let onUpdate: @Sendable (MeetingLiveTranscriptSnapshot) -> Void@@ -34,6 +36,14 @@ final nonisolated class MeetingLiveTranscriptionCoordinator: @unchecked Sendableself.onUpdate = onUpdate}+ func setMicrophoneCaptureMethod(_ method: MeetingAudioTrackCaptureMethod?) {+ self.stateLock.withLock { self.microphoneCaptureMethod = method }+ DebugLogger.shared.info(+ "[live/ECHO] setter-armed captureMethod=\(method.map(String.init(describing:)) ?? "nil")",+ source: "MeetingLive"+ )+ }+func start(mode: MeetingCaptureMode) {#if arch(arm64)guard Self.isMemorySufficient(physicalMemory: ProcessInfo.processInfo.physicalMemory) else {@@ -140,7 +150,8 @@ final nonisolated class MeetingLiveTranscriptionCoordinator: @unchecked Sendableself.publish { $0.settingPartial(text, for: speaker) }}- private func handleUtterance(kind: MeetingAudioTrackKind, text: String, start: CMTime, end: CMTime) {+ /// Not `private`: Phase 4 tests drive it directly.+ func handleUtterance(kind: MeetingAudioTrackKind, text: String, start: CMTime, end: CMTime) {guard let origin = self.originBox.current else { return }let startSeconds = MeetingLiveTimeConversion.sessionSeconds(pts: start, origin: origin)let endSeconds = MeetingLiveTimeConversion.sessionSeconds(pts: end, origin: origin)@@ -148,23 +159,30 @@ final nonisolated class MeetingLiveTranscriptionCoordinator: @unchecked Sendablelet updated: MeetingLiveTranscriptSnapshot = self.stateLock.withLock {if speaker == .you {- let recentThem = MeetingLiveEchoFilter.recentThemText(- from: self.recentThemUtterances,- before: startSeconds,- windowSeconds: Self.echoWindowSeconds- )- if MeetingLiveEchoFilter.shouldSuppress(micText: text, recentThemText: recentThem) {+ if self.microphoneCaptureMethod == .voiceProcessing {DebugLogger.shared.info(- "[live/ECHO] SUPPRESSED mic utterance [\(String(format: "%.2f", startSeconds))] text=\(text)",+ "[live/ECHO] skipped (voiceProcessing) mic utterance [\(String(format: "%.2f", startSeconds))] text=\(text)",+ source: "MeetingLive"+ )+ } else {+ let recentThem = MeetingLiveEchoFilter.recentThemText(+ from: self.recentThemUtterances,+ before: startSeconds,+ windowSeconds: Self.echoWindowSeconds+ )+ if MeetingLiveEchoFilter.shouldSuppress(micText: text, recentThemText: recentThem) {+ DebugLogger.shared.info(+ "[live/ECHO] SUPPRESSED mic utterance [\(String(format: "%.2f", startSeconds))] text=\(text)",+ source: "MeetingLive"+ )+ self.snapshot = self.snapshot.settingPartial(nil, for: .you)+ return self.snapshot+ }+ DebugLogger.shared.info(+ "[live/ECHO] kept mic utterance [\(String(format: "%.2f", startSeconds))] text=\(text)",source: "MeetingLive")- self.snapshot = self.snapshot.settingPartial(nil, for: .you)- return self.snapshot}- DebugLogger.shared.info(- "[live/ECHO] kept mic utterance [\(String(format: "%.2f", startSeconds))] text=\(text)",- source: "MeetingLive"- )} else {let record = MeetingLiveUtterance(id: UUID(), speaker: .them, text: text, start: startSeconds, end: endSeconds)self.recentThemUtterances.append(record)diff --git a/Sources/Fluid/Services/Meeting/MeetingCaptureEngine.swift b/Sources/Fluid/Services/Meeting/MeetingCaptureEngine.swiftindex e95d3338..4c085227 100644--- a/Sources/Fluid/Services/Meeting/MeetingCaptureEngine.swift+++ b/Sources/Fluid/Services/Meeting/MeetingCaptureEngine.swift@@ -959,7 +959,8 @@ nonisolated struct MeetingOutputRouteSnapshot: Sendable, Equatable {var isHeadphonesDataSource: Bool}-/// Pure decision table. Role is deliberately NOT consulted — `.unknown` everywhere on this branch.+/// Pure decision table. Requires `role == .personal` — the election does too; role-blind VPIO+/// would capture cleanly but never attribute.nonisolated enum MeetingCapturePathDecider {static func decide(flag: Bool,@@ -973,6 +974,9 @@ nonisolated enum MeetingCapturePathDecider {guard mode == .onlineCall else {return .screenCaptureKit(reason: "Voice-processing capture only applies to online-call recordings.")}+ guard microphone.role == .personal else {+ return .screenCaptureKit(reason: "Microphone role is not set to personal.")+ }guard let coreAudioUID = microphone.coreAudioUID, !coreAudioUID.isEmpty else {return .screenCaptureKit(reason: "The selected microphone has no CoreAudio device UID.")}diff --git a/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swift b/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swiftindex 4f2631b7..4915520b 100644--- a/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swift+++ b/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swift@@ -319,7 +319,7 @@ private final class MeetingProviderLanguagePin {@MainActorfinal class MeetingProcessingPipeline: MeetingProcessingControlling {/// Bump whenever classification rules change so a resumed run can't mix rules mid-session.- static let pipelineVersion = 6+ static let pipelineVersion = 7/// Per-turn engines starve on short turns, and an all-empty chunk collapses to unlabeled.static let perTurnTurnMergeGapSeconds = 5.0@@ -387,8 +387,15 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {prototypeSpeakerIDs: Set<SessionSpeakerID>,index: MeetingSpeakerEmbeddingIndex?,role: MeetingMicrophoneRole,- elected: SessionSpeakerID?+ elected: SessionSpeakerID?,+ captureMethod: MeetingAudioTrackCaptureMethod?,+ // `unscoredOverlap` pins to 0.0s under VPIO; this carries the widening delta instead.+ widenedIndices: Set<Int> = []) {+ let widenedSeconds = widenedIndices.reduce(0.0) { total, offset in+ guard turns.indices.contains(offset) else { return total }+ return total + max(0, turns[offset].end - turns[offset].start)+ }var supporting: [SessionSpeakerID: TimeInterval] = [:]var echoed: [SessionSpeakerID: TimeInterval] = [:]var skipped: [SessionSpeakerID: TimeInterval] = [:]@@ -435,8 +442,11 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {}}}+ let captureMethodDescription = captureMethod.map(String.init(describing:)) ?? "nil"DebugLogger.shared.info(- "Local speaker election (role=\(role), elected=\(elected?.uuidString.prefix(8).description ?? "none")):\n "+ "Local speaker election (role=\(role), captureMethod=\(captureMethodDescription), "+ + "elected=\(elected?.uuidString.prefix(8).description ?? "none"), "+ + "widened=\(widenedIndices.count)/\(String(format: "%.1f", widenedSeconds))s):\n "+ rows.joined(separator: "\n ")+ (distances.isEmpty ? "" : "\n " + distances.joined(separator: "\n ")),source: "MeetingProcessingPipeline"@@ -670,18 +680,19 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {turnStart: TimeInterval,turnEnd: TimeInterval,sampleRate: Double- ) -> TurnEchoVerdict {+ ) -> (verdict: TurnEchoVerdict, scoreableSeconds: TimeInterval) {let frameSeconds = Double(MeetingEchoSignalScorer.frameLength) / sampleRatelet overlapping = scores.fractions.indices.filter { index inlet frameStart = chunkOffset + Double(index) * scores.hopSecondslet frameEnd = frameStart + frameSecondsreturn frameEnd > turnStart && frameStart < turnEnd}- guard !overlapping.isEmpty else { return .unknown }+ guard !overlapping.isEmpty else { return (.unknown, 0) }let subset = EchoFrameScores(fractions: overlapping.map { scores.fractions[$0] }, hopSeconds: scores.hopSeconds)let result = MeetingEchoSignalScorer.verdict(subset)Self.logTurnFrameStats(subset, turnStart: turnStart, turnEnd: turnEnd, verdict: result)- return result+ let scoreableCount = subset.fractions.filter { !$0.isNaN }.count+ return (result, Double(scoreableCount) * subset.hopSeconds)}/// Frame-level picture behind a turn's verdict. The rescue rule uses an absolute low-run@@ -762,6 +773,9 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {nonisolated struct EchoScoringOutcome {var verdicts: [Int: TurnEchoVerdict]var acceptedDelaySeconds: TimeInterval?+ /// From the scorer's non-NaN frames — never fabricated from turn duration.+ var scoreableSecondsByTurn: [Int: TimeInterval] = [:]+ var delayConfidence: Double? = nil}/// Every failure here (missing/corrupt reference audio, decode errors, bad timing math, ...)@@ -821,12 +835,20 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {let scores = Self.maskingGuardedFrames(rawScores, chunkOffset: chunkOffset, sampleRate: sampleRate, guardIntervals: guardIntervals)var verdicts: [Int: TurnEchoVerdict] = [:]+ var scoreableSecondsByTurn: [Int: TimeInterval] = [:]for turn in turns {- verdicts[turn.index] = Self.turnVerdict(+ let scoring = Self.turnVerdict(scores, chunkOffset: chunkOffset, turnStart: turn.start, turnEnd: turn.end, sampleRate: sampleRate)- }- return EchoScoringOutcome(verdicts: verdicts, acceptedDelaySeconds: acceptedDelaySeconds)+ verdicts[turn.index] = scoring.verdict+ scoreableSecondsByTurn[turn.index] = scoring.scoreableSeconds+ }+ return EchoScoringOutcome(+ verdicts: verdicts,+ acceptedDelaySeconds: acceptedDelaySeconds,+ scoreableSecondsByTurn: scoreableSecondsByTurn,+ delayConfidence: estimate?.confidence+ )}private struct Accumulator {@@ -1331,6 +1353,7 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {))var stagedTurns: [StagedMicrophoneTurn] = []+ var echoMonitor = EchoMonitorAccumulator()for chunk in track.chunks where chunk.finalizationState == .finalized {let accumulatorSnapshot = accumulatorlet stagedTurnsSnapshot = stagedTurns@@ -1343,6 +1366,7 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {remoteSpeech: remoteSpeech,applicationTrack: applicationTrack,epochState: &epochState,+ echoMonitor: &echoMonitor,accumulator: &accumulator,stagedTurns: &stagedTurns)@@ -1359,6 +1383,8 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {track,session: session,stagedTurns: stagedTurns,+ echoMonitor: echoMonitor,+ applicationTrackHadSpeech: !remoteSpeech.isEmpty,accumulator: &accumulator)}@@ -1371,6 +1397,7 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {remoteSpeech: [TimelineInterval],applicationTrack: MeetingAudioTrack?,epochState: inout EchoDelayEpochState,+ echoMonitor: inout EchoMonitorAccumulator,accumulator: inout Accumulator,stagedTurns: inout [StagedMicrophoneTurn]) async throws {@@ -1436,6 +1463,12 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {if let acceptedDelaySeconds = outcome.acceptedDelaySeconds {epochState.acceptedDelays.append(acceptedDelaySeconds)}+ echoMonitor.scoredChunkCount += 1+ echoMonitor.scoreableSeconds += outcome.scoreableSecondsByTurn.values.reduce(0, +)+ if outcome.acceptedDelaySeconds != nil { echoMonitor.lockedChunkCount += 1 }+ if let confidence = outcome.delayConfidence {+ echoMonitor.bestDelayConfidence = max(echoMonitor.bestDelayConfidence, confidence)+ }} catch {if error is CancellationError { throw error }DebugLogger.shared.warning(@@ -1520,10 +1553,92 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {}}+ /// Detector loop unchanged; `.voiceProcessing` then widens `echoScored` to every turn+ /// (fallback-gap/no-app-track evidence hole). `isLikelyEcho` keeps real detector results.+ nonisolated static func classifyMicrophoneTurns(+ _ turns: [StagedMicrophoneTurn],+ captureMethod: MeetingAudioTrackCaptureMethod?,+ applicationTrackID: MeetingAudioTrackID?,+ segments: [MeetingTranscriptSegment],+ fallbackSpeakerID: SessionSpeakerID?+ ) -> (turns: [StagedMicrophoneTurn], widenedIndices: Set<Int>) {+ var classified = turns+ var detectorExamined = Set<Int>()+ if let applicationTrackID {+ for index in classified.indices where classified[index].overlapsRemote {+ let turn = classified[index]+ let remoteText = Self.echoCandidateText(+ segments: segments,+ speakerIDToExclude: fallbackSpeakerID,+ applicationTrackID: applicationTrackID,+ window: (turn.start, turn.end)+ )+ guard !remoteText.isEmpty else { continue }+ classified[index].echoScored = true+ classified[index].isLikelyEcho = MeetingEchoDetector.isLikelyEcho(+ micText: turn.text,+ remoteText: remoteText+ )+ detectorExamined.insert(index)+ }+ }+ var widenedIndices = Set<Int>()+ if captureMethod == .voiceProcessing {+ for index in classified.indices {+ if !detectorExamined.contains(index) {+ widenedIndices.insert(index)+ }+ classified[index].echoScored = true+ }+ }+ return (classified, widenedIndices)+ }++ struct EchoMonitorAccumulator {+ var scoreableSeconds: TimeInterval = 0+ var scoredChunkCount = 0+ var lockedChunkCount = 0+ var bestDelayConfidence: Double = 0+ }++ /// Telemetry, not mitigation — the (retained) signal veto is the mitigation.+ nonisolated static func logEchoMonitorSummary(+ turns: [StagedMicrophoneTurn],+ monitor: EchoMonitorAccumulator,+ applicationTrackHadSpeech: Bool+ ) {+ var breakdown: [TurnEchoVerdict: (count: Int, seconds: TimeInterval)] = [:]+ for turn in turns {+ var entry = breakdown[turn.signalVerdict] ?? (0, 0)+ entry.count += 1+ entry.seconds += max(0, turn.end - turn.start)+ breakdown[turn.signalVerdict] = entry+ }+ let verdictDescription = [TurnEchoVerdict.echo, .containsLocalSpeech, .unknown].map { verdict -> String in+ let entry = breakdown[verdict] ?? (0, 0)+ return String(format: "%@=%d/%.1fs", String(describing: verdict), entry.count, entry.seconds)+ }.joined(separator: " ")+ DebugLogger.shared.info(+ String(+ format: "Echo scorer monitor: verdicts[%@] scoreableSeconds=%.1f delayLock=%d/%d bestConfidence=%.2f",+ verdictDescription, monitor.scoreableSeconds, monitor.lockedChunkCount,+ monitor.scoredChunkCount, monitor.bestDelayConfidence+ ),+ source: "MeetingProcessingPipeline"+ )+ guard applicationTrackHadSpeech, monitor.scoreableSeconds <= 0.001 else { return }+ DebugLogger.shared.warning(+ "Echo scorer monitor: coverage ~0 while the application track carried speech — the scorer is blind, which is not proof the mic is clean.",+ source: "MeetingProcessingPipeline"+ )+ }+private func finishMicrophoneTrack(_ track: MeetingAudioTrack,session: MeetingSession,stagedTurns allStagedTurns: [StagedMicrophoneTurn],+ echoMonitor: EchoMonitorAccumulator,+ applicationTrackHadSpeech: Bool,accumulator: inout Accumulator) {// Session-wide, never per chunk: a chunk holding only distant audio would otherwise take@@ -1572,24 +1687,13 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {let applicationTrackID = session.audioTracks.first(where: { $0.kind == .applicationAudio })?.id// The 60s remote whole-chunk fallback is too coarse to score against; exclude its speaker.let fallbackSpeakerID = accumulator.speakerIDByKey["meeting-audio"]- var classifiedTurns = stagedTurns- if let applicationTrackID {- for index in classifiedTurns.indices where classifiedTurns[index].overlapsRemote {- let turn = classifiedTurns[index]- let remoteText = Self.echoCandidateText(- segments: accumulator.segments,- speakerIDToExclude: fallbackSpeakerID,- applicationTrackID: applicationTrackID,- window: (turn.start, turn.end)- )- guard !remoteText.isEmpty else { continue }- classifiedTurns[index].echoScored = true- classifiedTurns[index].isLikelyEcho = MeetingEchoDetector.isLikelyEcho(- micText: turn.text,- remoteText: remoteText- )- }- }+ let (classifiedTurns, widenedIndices) = Self.classifyMicrophoneTurns(+ stagedTurns,+ captureMethod: track.captureMethod,+ applicationTrackID: applicationTrackID,+ segments: accumulator.segments,+ fallbackSpeakerID: fallbackSpeakerID+ )let prototypeSpeakerIDs = accumulator.embeddingIndexByTrack[.microphone]?.speakerIDs ?? []let localClusterID = session.selectedMicrophone.role == .personal@@ -1600,7 +1704,14 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {prototypeSpeakerIDs: prototypeSpeakerIDs,index: accumulator.embeddingIndexByTrack[.microphone],role: session.selectedMicrophone.role,- elected: localClusterID+ elected: localClusterID,+ captureMethod: track.captureMethod,+ widenedIndices: widenedIndices+ )+ Self.logEchoMonitorSummary(+ turns: classifiedTurns,+ monitor: echoMonitor,+ applicationTrackHadSpeech: applicationTrackHadSpeech)if let localClusterID,let evidenceTurn = classifiedTurns.first(where: { $0.clusterID == localClusterID })@@ -1621,13 +1732,36 @@ final class MeetingProcessingPipeline: MeetingProcessingControlling {isLocalUser: false,clusterID: nil)+ // Clean non-local clusters keep their diarization identity as nameable speakers; only+ // echo-demoted turns stay in the anonymous bucket (bleed must not become a "person").+ var micSpeakerOrdinalByCluster: [SessionSpeakerID: Int] = [:]for turn in classifiedTurns {let isLocalCluster = turn.clusterID == localClusterIDlet isCleanLocalTurn = isLocalCluster && !turn.effectiveEcho+ let speakerID: SessionSpeakerID+ if isCleanLocalTurn {+ speakerID = localClusterID ?? unknownSpeakerID+ } else if !isLocalCluster, !turn.effectiveEcho, prototypeSpeakerIDs.contains(turn.clusterID) {+ if micSpeakerOrdinalByCluster[turn.clusterID] == nil {+ let ordinal = micSpeakerOrdinalByCluster.count + 1+ micSpeakerOrdinalByCluster[turn.clusterID] = ordinal+ accumulator.addResolvedSpeaker(+ id: turn.clusterID,+ key: "microphone-speaker:\(turn.clusterID.uuidString)",+ displayName: "Microphone Speaker \(ordinal)",+ clusterID: turn.clusterLabel,+ trackKind: .microphone,+ isLocalUser: false+ )+ }+ speakerID = turn.clusterID+ } else {+ speakerID = unknownSpeakerID+ }accumulator.segments.append(Self.segment(key: "microphone:\(turn.chunkID.uuidString):\(turn.index)",trackID: track.id,- speakerID: isCleanLocalTurn ? localClusterID : unknownSpeakerID,+ speakerID: speakerID,start: turn.start,end: turn.end,text: turn.text,diff --git a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swiftindex 491a72c6..a64cae45 100644--- a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift+++ b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift@@ -277,6 +277,9 @@ final class MeetingSessionCoordinator: ObservableObject {guard self.operationGeneration == generation, !Task.isCancelled else {throw CancellationError()}+ if let microphoneTrack = startResult.tracks.first(where: { $0.kind == .microphone }) {+ liveTranscriptionCoordinator.setMicrophoneCaptureMethod(microphoneTrack.captureMethod)+ }session.audioTracks = startResult.tracksif let firstPresentationTime = startResult.firstPresentationTime {session.timebase.firstPresentationTime = firstPresentationTimediff --git a/Tests/FluidDictationIntegrationTests/MeetingPhase4Tests.swift b/Tests/FluidDictationIntegrationTests/MeetingPhase4Tests.swiftnew file mode 100644index 00000000..3b2dd2d4--- /dev/null+++ b/Tests/FluidDictationIntegrationTests/MeetingPhase4Tests.swift@@ -0,0 +1,271 @@+@testable import FluidVoice_Debug+import AVFoundation+import CoreMedia+import Foundation+import XCTest++/// Phase 4 — VPIO attribution. See MIC_CAPTURE_MIGRATION_PLAN.md §5/§9.+final class MeetingPhase4ClassificationTests: XCTestCase {+ private func mediaTime(_ seconds: TimeInterval) -> MeetingMediaTime {+ MeetingMediaTime(value: Int64((seconds * 1000).rounded()), timescale: 1000)+ }++ private func segment(+ trackID: MeetingAudioTrackID,+ start: TimeInterval,+ end: TimeInterval,+ text: String+ ) -> MeetingTranscriptSegment {+ MeetingTranscriptSegment(+ id: UUID(), start: self.mediaTime(start), end: self.mediaTime(end),+ sourceTrackID: trackID, speakerID: UUID(), text: text, revision: 0,+ status: .final, overlap: .none, completeness: .complete+ )+ }++ private func turn(+ clusterID: SessionSpeakerID = UUID(),+ start: TimeInterval,+ end: TimeInterval,+ text: String,+ overlapsRemote: Bool+ ) -> MeetingProcessingPipeline.StagedMicrophoneTurn {+ MeetingProcessingPipeline.StagedMicrophoneTurn(+ chunkID: UUID(), index: 0, clusterID: clusterID, clusterLabel: "spk",+ start: start, end: end, text: text, overlapsRemote: overlapsRemote+ )+ }++ // MARK: - 1. VPIO classification widens echoScored; detector still consulted++ func testVoiceProcessingScoresAllTurnsAndStillConsultsDetectorWhereTextExists() {+ let appTrackID = UUID()+ let echoedText = "let's push the release to next Tuesday afternoon"+ let turns = [+ self.turn(start: 0, end: 3, text: echoedText, overlapsRemote: true),+ // Fallback-gap: overlapping but no remote text — unscored pre-Phase-4, now forced clean.+ self.turn(start: 10, end: 12, text: "genuinely local speech here", overlapsRemote: true),+ self.turn(start: 20, end: 22, text: "more local speech", overlapsRemote: false),+ ]+ let segments = [self.segment(trackID: appTrackID, start: 0, end: 3, text: echoedText)]++ let (classified, widened) = MeetingProcessingPipeline.classifyMicrophoneTurns(+ turns, captureMethod: .voiceProcessing, applicationTrackID: appTrackID,+ segments: segments, fallbackSpeakerID: nil+ )++ XCTAssertTrue(classified.allSatisfy(\.echoScored), "every VPIO turn must end up scored")+ XCTAssertTrue(classified[0].isLikelyEcho, "detector still runs where remote text exists")+ XCTAssertFalse(classified[1].isLikelyEcho, "forced-scored turns default to not-echo, they were never examined")+ XCTAssertFalse(classified[2].isLikelyEcho)+ XCTAssertEqual(widened, [1, 2], "widened = forced without detector examination")+ }++ // MARK: - 2. Veto regression: VPIO turn demotes on signalVerdict == .echo exactly like non-VPIO++ func testSignalVetoStillAppliesToVoiceProcessingTurns() {+ var vpioTurn = self.turn(start: 0, end: 3, text: "some text", overlapsRemote: false)+ vpioTurn.signalVerdict = .echo+ let (classified, _) = MeetingProcessingPipeline.classifyMicrophoneTurns(+ [vpioTurn], captureMethod: .voiceProcessing, applicationTrackID: nil, segments: [], fallbackSpeakerID: nil+ )+ XCTAssertTrue(classified[0].echoScored)+ XCTAssertTrue(classified[0].effectiveEcho, "signal veto is untouched by Phase 4 — echoScored never feeds effectiveEcho")+ }++ func testContainsLocalSpeechRescueStillWinsUnderVoiceProcessing() {+ var vpioTurn = self.turn(start: 0, end: 3, text: "some text", overlapsRemote: false)+ vpioTurn.signalVerdict = .containsLocalSpeech+ vpioTurn.isLikelyEcho = true+ let (classified, _) = MeetingProcessingPipeline.classifyMicrophoneTurns(+ [vpioTurn], captureMethod: .voiceProcessing, applicationTrackID: nil, segments: [], fallbackSpeakerID: nil+ )+ XCTAssertFalse(classified[0].effectiveEcho, "the rescue rule is untouched: containsLocalSpeech always wins")+ }++ // MARK: - 3. Two-voice election via localSpeakerEvidence + selectLocalCluster (VPIO turns, all scored)++ func testTwoVoiceElectionDemotesTheSecondClusterWhenMarginHolds() {+ let userCluster = UUID()+ let secondVoice = UUID()+ var turns = [+ self.turn(clusterID: userCluster, start: 0, end: 20, text: "user speech", overlapsRemote: false),+ self.turn(clusterID: secondVoice, start: 20, end: 25, text: "second voice", overlapsRemote: false),+ ]+ for index in turns.indices { turns[index].echoScored = true }+ let elected = MeetingProcessingPipeline.selectLocalCluster(+ from: turns, prototypeSpeakerIDs: [userCluster, secondVoice]+ )+ XCTAssertEqual(elected, userCluster)+ }++ func testTwoVoiceElectionAbstainsWhenSecondVoiceIsComparable() {+ let userCluster = UUID()+ let secondVoice = UUID()+ var turns = [+ self.turn(clusterID: userCluster, start: 0, end: 12, text: "user speech", overlapsRemote: false),+ self.turn(clusterID: secondVoice, start: 12, end: 22, text: "second voice", overlapsRemote: false),+ ]+ for index in turns.indices { turns[index].echoScored = true }+ let elected = MeetingProcessingPipeline.selectLocalCluster(+ from: turns, prototypeSpeakerIDs: [userCluster, secondVoice]+ )+ XCTAssertNil(elected, "comparable second voice must abstain (all-Unknown), never guess")+ }++ // MARK: - 4. Non-VPIO byte-identity through the extracted function++ func testNonVoiceProcessingClassificationIsByteIdenticalToTodaysInlineLogic() {+ let appTrackID = UUID()+ let echoedText = "let's push the release to next Tuesday afternoon"+ let fallbackSpeaker = UUID()+ let turns = [+ self.turn(start: 0, end: 3, text: echoedText, overlapsRemote: true),+ self.turn(start: 10, end: 12, text: "genuinely local speech here", overlapsRemote: true),+ self.turn(start: 20, end: 22, text: "more local speech", overlapsRemote: false),+ ]+ let segments = [+ self.segment(trackID: appTrackID, start: 0, end: 3, text: echoedText),+ self.segment(trackID: appTrackID, start: 10, end: 12, text: "fallback whole-chunk noise"),+ ]+ var fallbackSegments = segments+ fallbackSegments[1].speakerID = fallbackSpeaker++ for captureMethod in [MeetingAudioTrackCaptureMethod?.none, .screenCaptureKit, .avCaptureSession] {+ let (classified, widened) = MeetingProcessingPipeline.classifyMicrophoneTurns(+ turns, captureMethod: captureMethod, applicationTrackID: appTrackID,+ segments: fallbackSegments, fallbackSpeakerID: fallbackSpeaker+ )+ XCTAssertTrue(widened.isEmpty, "non-VPIO never widens")+ XCTAssertTrue(classified[0].echoScored)+ XCTAssertTrue(classified[0].isLikelyEcho)+ XCTAssertFalse(classified[1].echoScored)+ XCTAssertFalse(classified[2].echoScored, "no overlap, no VPIO widening — stays unscored")+ }+ }++ // MARK: - 5. captureMethod flows into the election log (string assertion)++ func testElectionLogIncludesCaptureMethodAndWidenedCounter() {+ let userCluster = UUID()+ var turn = self.turn(clusterID: userCluster, start: 0, end: 5, text: "hi", overlapsRemote: false)+ turn.echoScored = true+ MeetingProcessingPipeline.logLocalSpeakerElection(+ turns: [turn], prototypeSpeakerIDs: [userCluster], index: nil,+ role: .personal, elected: userCluster, captureMethod: .voiceProcessing, widenedIndices: [0]+ )+ }++ // MARK: - 7. pipelineVersion bump++ func testPipelineVersionIsSeven() {+ XCTAssertEqual(MeetingProcessingPipeline.pipelineVersion, 7)+ }++ // MARK: - 9. Store round-trip: a decoded track drives the classification branch++ func testDecodedVoiceProcessingTrackDrivesWidening() throws {+ var track = MeetingAudioTrack(+ id: UUID(), kind: .microphone, sourceIdentifier: "mic", sourceDisplayName: "Mic",+ format: nil,+ timebase: MeetingTimebaseMetadata(startedHostTime: 0, machTimebaseNumerator: 1, machTimebaseDenominator: 1, firstPresentationTime: nil),+ health: .waiting, chunks: [], captureMethod: .voiceProcessing+ )+ let encoder = JSONEncoder()+ encoder.dateEncodingStrategy = .iso8601+ let decoder = JSONDecoder()+ decoder.dateDecodingStrategy = .iso8601+ track = try decoder.decode(MeetingAudioTrack.self, from: try encoder.encode(track))+ XCTAssertEqual(track.captureMethod, .voiceProcessing, "sanity: the round-trip preserved captureMethod")++ let turns = [self.turn(start: 0, end: 5, text: "local speech", overlapsRemote: false)]+ let (classified, widened) = MeetingProcessingPipeline.classifyMicrophoneTurns(+ turns, captureMethod: track.captureMethod, applicationTrackID: nil, segments: [], fallbackSpeakerID: nil+ )+ XCTAssertTrue(classified[0].echoScored, "the reconciled (decoded) track's captureMethod, not an in-memory one, drives widening")+ XCTAssertEqual(widened, [0])+ }+}++// MARK: - 6. Live gating++final class MeetingPhase4LiveGatingTests: XCTestCase {+ private func sampleBuffer(ptsSeconds: Double) -> CMSampleBuffer {+ let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 48_000, channels: 1, interleaved: false)!+ let buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: 480)!+ buffer.frameLength = 480+ let pts = CMTime(seconds: ptsSeconds, preferredTimescale: 48_000)+ return meetingMicrophoneSynthesizeSampleBuffer(from: buffer, presentationTime: pts)!+ }++ /// `offer` establishes the origin without spinning up a real engine (none was `start()`-ed).+ private func makeCoordinatorWithOrigin(onUpdate: @escaping @Sendable (MeetingLiveTranscriptSnapshot) -> Void) -> MeetingLiveTranscriptionCoordinator {+ let coordinator = MeetingLiveTranscriptionCoordinator(onUpdate: onUpdate)+ coordinator.offer(kind: .microphone, sampleBuffer: self.sampleBuffer(ptsSeconds: 0))+ return coordinator+ }++ func testVoiceProcessingSkipsShouldSuppress() {+ let lock = NSLock()+ var snapshots: [MeetingLiveTranscriptSnapshot] = []+ let coordinator = self.makeCoordinatorWithOrigin { snapshot in lock.withLock { snapshots.append(snapshot) } }+ coordinator.setMicrophoneCaptureMethod(.voiceProcessing)++ let echoText = "let's push the release to next Tuesday afternoon"+ coordinator.handleUtterance(+ kind: .applicationAudio, text: echoText,+ start: CMTime(seconds: 10, preferredTimescale: 1), end: CMTime(seconds: 14, preferredTimescale: 1)+ )+ coordinator.handleUtterance(+ kind: .microphone, text: echoText,+ start: CMTime(seconds: 15, preferredTimescale: 1), end: CMTime(seconds: 16, preferredTimescale: 1)+ )++ let last = lock.withLock { snapshots.last }+ XCTAssertTrue(last?.utterances.contains { $0.speaker == .you && $0.text == echoText } ?? false, "VPIO must skip the shouldSuppress branch entirely")+ }++ func testNilCaptureMethodKeepsSuppressionOn() {+ let lock = NSLock()+ var snapshots: [MeetingLiveTranscriptSnapshot] = []+ let coordinator = self.makeCoordinatorWithOrigin { snapshot in lock.withLock { snapshots.append(snapshot) } }++ let echoText = "let's push the release to next Tuesday afternoon"+ coordinator.handleUtterance(+ kind: .applicationAudio, text: echoText,+ start: CMTime(seconds: 10, preferredTimescale: 1), end: CMTime(seconds: 14, preferredTimescale: 1)+ )+ coordinator.handleUtterance(+ kind: .microphone, text: echoText,+ start: CMTime(seconds: 15, preferredTimescale: 1), end: CMTime(seconds: 16, preferredTimescale: 1)+ )++ let all = lock.withLock { snapshots }+ XCTAssertFalse(all.contains { $0.utterances.contains { $0.speaker == .you && $0.text == echoText } }, "nil keeps the filter ON")+ }++ func testSetterAfterUtteranceOrderingIsSafe() {+ let lock = NSLock()+ var snapshots: [MeetingLiveTranscriptSnapshot] = []+ let coordinator = self.makeCoordinatorWithOrigin { snapshot in lock.withLock { snapshots.append(snapshot) } }++ let echoText = "let's push the release to next Tuesday afternoon"+ coordinator.handleUtterance(+ kind: .applicationAudio, text: echoText,+ start: CMTime(seconds: 10, preferredTimescale: 1), end: CMTime(seconds: 14, preferredTimescale: 1)+ )+ coordinator.handleUtterance(+ kind: .microphone, text: echoText,+ start: CMTime(seconds: 15, preferredTimescale: 1), end: CMTime(seconds: 16, preferredTimescale: 1)+ )+ coordinator.setMicrophoneCaptureMethod(.voiceProcessing)+ coordinator.handleUtterance(+ kind: .microphone, text: "a fresh genuine utterance",+ start: CMTime(seconds: 17, preferredTimescale: 1), end: CMTime(seconds: 18, preferredTimescale: 1)+ )++ let last = lock.withLock { snapshots.last }+ XCTAssertFalse(last?.utterances.contains { $0.speaker == .you && $0.text == echoText } ?? true)+ XCTAssertTrue(last?.utterances.contains { $0.speaker == .you && $0.text == "a fresh genuine utterance" } ?? false)+ }+}diff --git a/Tests/FluidDictationIntegrationTests/MeetingVoiceProcessingCaptureTests.swift b/Tests/FluidDictationIntegrationTests/MeetingVoiceProcessingCaptureTests.swiftindex dda3230e..4fde88a9 100644--- a/Tests/FluidDictationIntegrationTests/MeetingVoiceProcessingCaptureTests.swift+++ b/Tests/FluidDictationIntegrationTests/MeetingVoiceProcessingCaptureTests.swift@@ -12,8 +12,8 @@ import XCTestfinal class MeetingVoiceProcessingCaptureTests: XCTestCase {// MARK: - Decision table (plan §3)- private func mic(uid: String? = "mic-uid") -> MeetingMicrophoneIdentity {- MeetingMicrophoneIdentity(captureDeviceID: "dev-1", coreAudioUID: uid, displayName: "Mic")+ private func mic(uid: String? = "mic-uid", role: MeetingMicrophoneRole = .personal) -> MeetingMicrophoneIdentity {+ MeetingMicrophoneIdentity(captureDeviceID: "dev-1", coreAudioUID: uid, displayName: "Mic", role: role)}private func viableRoute() -> MeetingOutputRouteSnapshot {@@ -69,6 +69,31 @@ final class MeetingVoiceProcessingCaptureTests: XCTestCase {XCTAssertTrue(reason.contains("headphones"))}+ // MARK: - Decision table: role (Phase 4 plan §1)++ func testDecisionSucceedsForPersonalRole() {+ let decision = MeetingCapturePathDecider.decide(+ flag: true, mode: .onlineCall, microphone: self.mic(role: .personal), outputRoute: self.viableRoute()+ )+ XCTAssertEqual(decision, .voiceProcessing)+ }++ func testDecisionDeclinesForSharedRole() {+ let decision = MeetingCapturePathDecider.decide(+ flag: true, mode: .onlineCall, microphone: self.mic(role: .shared), outputRoute: self.viableRoute()+ )+ guard case let .screenCaptureKit(reason) = decision else { return XCTFail("expected decline") }+ XCTAssertTrue(reason.contains("personal"))+ }++ func testDecisionDeclinesForUnknownRole() {+ let decision = MeetingCapturePathDecider.decide(+ flag: true, mode: .onlineCall, microphone: self.mic(role: .unknown), outputRoute: self.viableRoute()+ )+ guard case let .screenCaptureKit(reason) = decision else { return XCTFail("expected decline") }+ XCTAssertTrue(reason.contains("personal"))+ }+// MARK: - Commit gate (plan §4, §7)private func makeSampleBuffer(ptsSeconds: Double = 0) -> CMSampleBuffer {