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
fix(meetings): resolve speaker handoffs and name unknown turns
argus-vaultd77b73d42f21
diff --git a/Sources/Fluid/Services/Meeting/Backend/MeetingParakeetNemotronBackend.swift b/Sources/Fluid/Services/Meeting/Backend/MeetingParakeetNemotronBackend.swiftindex abfec56e..fcc248ee 100644--- a/Sources/Fluid/Services/Meeting/Backend/MeetingParakeetNemotronBackend.swift+++ b/Sources/Fluid/Services/Meeting/Backend/MeetingParakeetNemotronBackend.swift@@ -13,7 +13,7 @@ import Foundationfinal class MeetingParakeetNemotronBackend: MeetingTranscriptionBackend {static let descriptor = MeetingBackendDescriptor(id: .parakeetNemotron,- version: "2",+ version: "3",execution: .local,supportedLanguageCodes: ["en"],supportedTrackKinds: Set(MeetingAudioTrackKind.allCases),@@ -417,6 +417,7 @@ final class MeetingParakeetNemotronBackend: MeetingTranscriptionBackend {guard physicalEnd > epochStart else { return [] }var wordUnits: [MeetingFinalTextUnit] = []+ var previousAssignedWord: (token: MeetingBackendSpeakerToken, end: TimeInterval)?let sortedWords = output.words.enumerated().sorted { ($0.element.start, $0.offset) < ($1.element.start, $1.offset) }for (index, word) in sortedWords {@@ -442,6 +443,19 @@ final class MeetingParakeetNemotronBackend: MeetingTranscriptionBackend {guard end > start else { continue }guard let spanIDs = Self.intersectingSpanIDs(start: start, end: end, spans: work.spans)else { continue }+ let coverageAssignment = Self.assignment(+ start: start,+ end: end,+ activity: activity,+ allowDominance: true+ )+ let speaker = Self.handoffAssignment(+ coverageAssignment,+ start: start,+ end: end,+ activity: activity,+ previousAssignedWord: previousAssignedWord+ )wordUnits.append(MeetingFinalTextUnit(id: "unit:\(attemptID.uuidString):\(work.epoch.id):\(index)",trackID: work.track.id,@@ -450,10 +464,16 @@ final class MeetingParakeetNemotronBackend: MeetingTranscriptionBackend {text: text,analysisStart: start,analysisEnd: end,- speaker: Self.assignment(start: start, end: end, activity: activity, allowDominance: true),+ speaker: speaker,analysisSpanIDs: spanIDs,confidence: nil))+ if case let .assigned(token) = speaker {+ previousAssignedWord = (token, end)+ } else {+ // An uncertain word is a hard context break; never chain a later guess through it.+ previousAssignedWord = nil+ }}if !wordUnits.isEmpty { return wordUnits }@@ -549,6 +569,8 @@ final class MeetingParakeetNemotronBackend: MeetingTranscriptionBackend {/// Nemotron emits diarization decisions on this cadence (plan §4); a boundary sliver shorter/// than one output hop is model noise, not evidence of a second speaker.private nonisolated static let nemotronCadenceMaximumFloorSeconds: TimeInterval = 0.08+ private nonisolated static let handoffMaximumWordDurationSeconds: TimeInterval = 0.8+ private nonisolated static let handoffMaximumPreviousWordGapSeconds: TimeInterval = 0.8/// Conservative initial product policy for multi-candidate words, isolated here so the ratios/// are named and covered at exact boundaries instead of living as unexplained literals.@@ -656,6 +678,61 @@ final class MeetingParakeetNemotronBackend: MeetingTranscriptionBackend {}}+ /// Deliberately simple second pass for short turn-boundary words. The user chose the more+ /// readable handoff behavior despite its known risk for genuine interruption/backchannel+ /// speech. Coverage remains the first-pass authority; this only resolves an otherwise+ /// ambiguous two-slot result with immediate assigned-word context.+ nonisolated static func handoffAssignment(+ _ coverageAssignment: MeetingBackendSpeakerAssignment,+ start: TimeInterval,+ end: TimeInterval,+ activity: [MeetingBackendSpeakerActivity],+ previousAssignedWord: (token: MeetingBackendSpeakerToken, end: TimeInterval)?+ ) -> MeetingBackendSpeakerAssignment {+ guard case let .ambiguous(candidates) = coverageAssignment,+ candidates.count == 2,+ let previousAssignedWord,+ candidates.contains(previousAssignedWord.token)+ else { return coverageAssignment }++ let duration = end - start+ let gap = start - previousAssignedWord.end+ guard duration.isFinite,+ duration > 0,+ duration <= Self.handoffMaximumWordDurationSeconds,+ gap.isFinite,+ gap >= -Self.nemotronCadenceMaximumFloorSeconds,+ gap <= Self.handoffMaximumPreviousWordGapSeconds+ else { return coverageAssignment }++ guard let other = candidates.first(where: { $0 != previousAssignedWord.token }) else {+ return coverageAssignment+ }+ let otherOnsets = activity.compactMap { entry -> TimeInterval? in+ guard entry.token == other,+ min(entry.end, end) - max(entry.start, start)+ > MeetingAnalysisManifestSchema.mappingToleranceSeconds+ else { return nil }+ return entry.start+ }+ guard let otherOnset = otherOnsets.min() else { return coverageAssignment }+ let onsetDelta = otherOnset - start+ let resolved: MeetingBackendSpeakerAssignment = abs(onsetDelta)+ <= Self.nemotronCadenceMaximumFloorSeconds+ ? .assigned(other)+ : .assigned(previousAssignedWord.token)++ #if DEBUG+ Self.logHandoffDecision(+ duration: duration,+ previousWordGap: gap,+ otherOnsetDelta: onsetDelta,+ assignedEntrant: abs(onsetDelta) <= Self.nemotronCadenceMaximumFloorSeconds+ )+ #endif+ return resolved+ }+#if DEBUG/// Structured, DEBUG-only measurement of a multi-candidate word decision. Deliberately carries/// only durations, coverage seconds and the resulting decision kind — never transcript text,@@ -682,5 +759,23 @@ final class MeetingParakeetNemotronBackend: MeetingTranscriptionBackend {source: "MeetingParakeetNemotronBackend")}++ private nonisolated static func logHandoffDecision(+ duration: TimeInterval,+ previousWordGap: TimeInterval,+ otherOnsetDelta: TimeInterval,+ assignedEntrant: Bool+ ) {+ DebugLogger.shared.info(+ String(+ format: "[speakerHandoff] duration=%.3fs previousGap=%.3fs otherOnsetDelta=%.3fs decision=%@",+ duration,+ previousWordGap,+ otherOnsetDelta,+ assignedEntrant ? "entrant" : "incumbent"+ ),+ source: "MeetingParakeetNemotronBackend"+ )+ }#endif}diff --git a/Sources/Fluid/Services/Meeting/MeetingModels.swift b/Sources/Fluid/Services/Meeting/MeetingModels.swiftindex 0f1f80b8..0f2181fa 100644--- a/Sources/Fluid/Services/Meeting/MeetingModels.swift+++ b/Sources/Fluid/Services/Meeting/MeetingModels.swift@@ -962,6 +962,44 @@ nonisolated struct MeetingSession: Codable, Identifiable, Equatable, Sendable {self.updatedAt = Date()}+ /// Gives one unresolved segment its own manual speaker identity. The identity is intentionally+ /// scoped to this segment: naming one unknown must never rename or relabel another unknown.+ @discardableResult+ mutating func nameUnknownSegment(+ id: MeetingTranscriptSegmentID,+ displayName: String+ ) throws -> SessionSpeakerID {+ let trimmed = displayName.trimmingCharacters(in: .whitespacesAndNewlines)+ guard !trimmed.isEmpty else { throw MeetingDomainError.emptySpeakerName }+ guard let segmentIndex = self.transcriptSegments.firstIndex(where: { $0.id == id }) else {+ throw MeetingDomainError.segmentNotFound+ }+ guard self.transcriptSegments[segmentIndex].speakerID == nil else {+ throw MeetingDomainError.segmentAlreadyAssigned+ }+ guard let trackKind = self.audioTracks.first(where: {+ $0.id == self.transcriptSegments[segmentIndex].sourceTrackID+ })?.kind else {+ throw MeetingDomainError.segmentTrackNotFound+ }++ let speakerID = UUID()+ self.speakers.append(MeetingSessionSpeaker(+ id: speakerID,+ displayName: trimmed,+ diarizationClusterID: nil,+ trackKind: trackKind,+ isLocalUser: false,+ identityCandidates: []+ ))+ self.transcriptSegments[segmentIndex].speakerID = speakerID+ self.transcriptSegments[segmentIndex].overlap = .none+ self.transcriptSegments[segmentIndex].attributionState = .assigned+ self.transcriptSegments[segmentIndex].revision += 1+ self.updatedAt = Date()+ return speakerID+ }+mutating func mergeSpeakers(_ sourceID: SessionSpeakerID, into targetID: SessionSpeakerID) throws {guard sourceID != targetID else { throw MeetingDomainError.cannotMergeSpeakerWithItself }guard let sourceIndex = self.speakers.firstIndex(where: { $0.id == sourceID }),@@ -1130,6 +1168,8 @@ nonisolated enum MeetingDomainError: LocalizedError, Equatable {case emptySpeakerNamecase speakerNotFoundcase segmentNotFound+ case segmentAlreadyAssigned+ case segmentTrackNotFoundcase cannotMergeSpeakerWithItselfcase cannotMergeSpeakerscase emptyMeetingTitle@@ -1142,6 +1182,10 @@ nonisolated enum MeetingDomainError: LocalizedError, Equatable {return "The speaker is no longer part of this meeting."case .segmentNotFound:return "This transcript line is no longer part of the meeting."+ case .segmentAlreadyAssigned:+ return "This transcript line already has a speaker."+ case .segmentTrackNotFound:+ return "The transcript line's audio track is no longer available."case .cannotMergeSpeakerWithItself:return "A speaker can't be merged into itself."case .cannotMergeSpeakers:diff --git a/Sources/Fluid/Services/Meeting/MeetingProcessingConfiguration.swift b/Sources/Fluid/Services/Meeting/MeetingProcessingConfiguration.swiftindex 2f88303b..13e97465 100644--- a/Sources/Fluid/Services/Meeting/MeetingProcessingConfiguration.swift+++ b/Sources/Fluid/Services/Meeting/MeetingProcessingConfiguration.swift@@ -25,7 +25,7 @@ nonisolated struct MeetingFinalProcessingConfiguration: Equatable, Sendable {static let defaultLanguageCode = "en"/// Mirrors `MeetingProcessingPipeline.pipelineVersion`; that class is `@MainActor`, so a/// MainActor test guards this literal against drift instead of referencing it here.- static let defaultPipelineVersion = 12+ static let defaultPipelineVersion = 13let asrModel: Stringlet languageCode: Stringdiff --git a/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swift b/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swiftindex 08707587..668d5b86 100644--- a/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swift+++ b/Sources/Fluid/Services/Meeting/MeetingProcessingPipeline.swift@@ -656,8 +656,8 @@ private final class MeetingProviderLanguagePin {final class MeetingProcessingPipeline: MeetingProcessingControlling {/// Bump whenever classification rules change so a resumed run can't mix rules mid-session./// Era-awareness did NOT bump this: the mic pass re-runs every time, and multi-era tracks cannot predate this build.- /// Version 12: Parakeet+Nemotron backend moved to coverage-union overlap dominance (plan §4).- static let pipelineVersion = 12+ /// Version 13: short ambiguous words receive the opted-in turn-handoff second pass.+ static let pipelineVersion = 13/// Per-turn engines starve on short turns, and an all-empty chunk collapses to unlabeled.static let perTurnTurnMergeGapSeconds = 5.0diff --git a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swiftindex ad6423b5..8223575c 100644--- a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift+++ b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift@@ -170,6 +170,13 @@ final class MeetingSessionCoordinator: ObservableObject {previousAttributionState: MeetingTranscriptAttributionState?,previousRevision: Int)+ case nameUnknown(+ segmentID: MeetingTranscriptSegmentID,+ createdSpeakerID: SessionSpeakerID,+ previousOverlap: MeetingTranscriptOverlap,+ previousAttributionState: MeetingTranscriptAttributionState?,+ previousRevision: Int+ )case merge(sourceID: SessionSpeakerID,targetID: SessionSpeakerID,@@ -873,6 +880,27 @@ final class MeetingSessionCoordinator: ObservableObject {}}+ @discardableResult+ func nameUnknownSegment(+ sessionID: MeetingSessionID,+ segmentID: MeetingTranscriptSegmentID,+ displayName: String+ ) async throws -> MeetingSession {+ try await self.performCorrection(sessionID: sessionID) { session in+ guard let segment = session.transcriptSegments.first(where: { $0.id == segmentID }) else {+ throw MeetingDomainError.segmentNotFound+ }+ let speakerID = try session.nameUnknownSegment(id: segmentID, displayName: displayName)+ return .nameUnknown(+ segmentID: segmentID,+ createdSpeakerID: speakerID,+ previousOverlap: segment.overlap,+ previousAttributionState: segment.attributionState,+ previousRevision: segment.revision+ )+ }+ }+@discardableResultfunc mergeSpeakers(sessionID: MeetingSessionID, source: SessionSpeakerID, into targetID: SessionSpeakerID) async throws -> MeetingSession {try await self.performCorrection(sessionID: sessionID) { session in@@ -1132,6 +1160,23 @@ final class MeetingSessionCoordinator: ObservableObject {session.transcriptSegments[index].attributionState = previousAttributionStatesession.transcriptSegments[index].revision = previousRevisionreturn true+ case let .nameUnknown(+ segmentID,+ createdSpeakerID,+ previousOverlap,+ previousAttributionState,+ previousRevision+ ):+ guard let segmentIndex = session.transcriptSegments.firstIndex(where: { $0.id == segmentID }),+ session.transcriptSegments[segmentIndex].speakerID == createdSpeakerID,+ let speakerIndex = session.speakers.firstIndex(where: { $0.id == createdSpeakerID })+ else { return false }+ session.speakers.remove(at: speakerIndex)+ session.transcriptSegments[segmentIndex].speakerID = nil+ session.transcriptSegments[segmentIndex].overlap = previousOverlap+ session.transcriptSegments[segmentIndex].attributionState = previousAttributionState+ session.transcriptSegments[segmentIndex].revision = previousRevision+ return truecase let .merge(sourceID, _, movedSegments):guard let index = session.speakers.firstIndex(where: { $0.id == sourceID }) else { return false }session.speakers[index].mergedIntoSpeakerID = nildiff --git a/Sources/Fluid/Services/Meeting/MeetingTranscriptExporter.swift b/Sources/Fluid/Services/Meeting/MeetingTranscriptExporter.swiftindex 702a6db8..9200224a 100644--- a/Sources/Fluid/Services/Meeting/MeetingTranscriptExporter.swift+++ b/Sources/Fluid/Services/Meeting/MeetingTranscriptExporter.swift@@ -26,17 +26,14 @@ nonisolated enum MeetingTranscriptExporter {if let name = Self.resolvedSpeakerName(segment.speakerID, in: session, speakerNames: speakerNames) {return name}- return segment.overlap == .ambiguous ? "Overlapping speakers" : "Unassigned"+ return "Unknown speaker"}switch state {case .assigned:- return Self.resolvedSpeakerName(segment.speakerID, in: session, speakerNames: speakerNames) ?? "Unassigned"- case .overlappingSpeakers:- return "Overlapping speakers"- case .unassigned:- return "Unassigned"- case .timingUncertain:- return "Timing uncertain"+ return Self.resolvedSpeakerName(segment.speakerID, in: session, speakerNames: speakerNames)+ ?? "Unknown speaker"+ case .overlappingSpeakers, .unassigned, .timingUncertain:+ return "Unknown speaker"}}diff --git a/Sources/Fluid/UI/MeetingTranscriptionView.swift b/Sources/Fluid/UI/MeetingTranscriptionView.swiftindex 7995b1aa..bac03bc9 100644--- a/Sources/Fluid/UI/MeetingTranscriptionView.swift+++ b/Sources/Fluid/UI/MeetingTranscriptionView.swift@@ -164,6 +164,7 @@ struct MeetingTranscriptionView: View {onCopyTranscript: self.copyTranscript,onExportTranscript: self.exportTranscript,onReassignSegment: self.reassignSegment,+ onNameUnknownSegment: self.nameUnknownSegment,onRenameSpeaker: self.renameSpeaker,onMergeSpeakers: self.mergeSpeakers,onUndoCorrection: self.undoTranscriptCorrection,@@ -643,6 +644,26 @@ struct MeetingTranscriptionView: View {}}+ private func nameUnknownSegment(+ sessionID: MeetingSessionID,+ segmentID: MeetingTranscriptSegmentID,+ displayName: String+ ) {+ self.actionErrorMessage = nil+ Task {+ do {+ _ = try await self.coordinator.nameUnknownSegment(+ sessionID: sessionID,+ segmentID: segmentID,+ displayName: displayName+ )+ } catch {+ self.actionErrorMessage = error.localizedDescription+ }+ await self.loadMeetingHistory()+ }+ }+private func renameSpeaker(sessionID: MeetingSessionID, speakerID: SessionSpeakerID, to displayName: String) {self.actionErrorMessage = nilTask {@@ -1125,6 +1146,7 @@ struct MeetingTranscriptionCanvas: View {let onCopyTranscript: (MeetingSession, Bool) -> Voidlet onExportTranscript: (MeetingSession, MeetingTranscriptExportFormat, Bool) -> Voidlet onReassignSegment: (MeetingSessionID, MeetingTranscriptSegmentID, SessionSpeakerID) -> Void+ let onNameUnknownSegment: (MeetingSessionID, MeetingTranscriptSegmentID, String) -> Voidlet onRenameSpeaker: (MeetingSessionID, SessionSpeakerID, String) -> Voidlet onMergeSpeakers: (MeetingSessionID, SessionSpeakerID, SessionSpeakerID) -> Voidlet onUndoCorrection: (MeetingSessionID) -> Void@@ -1212,6 +1234,9 @@ struct MeetingTranscriptionCanvas: View {onReassignSegment: { segmentID, speakerID inself.onReassignSegment(session.id, segmentID, speakerID)},+ onNameUnknownSegment: { segmentID, name in+ self.onNameUnknownSegment(session.id, segmentID, name)+ },onRenameSpeaker: { speakerID, name inself.onRenameSpeaker(session.id, speakerID, name)},@@ -2519,6 +2544,7 @@ private struct MeetingResultCanvas: View {let onCopyTranscript: (MeetingSession, Bool) -> Voidlet onExportTranscript: (MeetingSession, MeetingTranscriptExportFormat, Bool) -> Voidlet onReassignSegment: (MeetingTranscriptSegmentID, SessionSpeakerID) -> Void+ let onNameUnknownSegment: (MeetingTranscriptSegmentID, String) -> Voidlet onRenameSpeaker: (SessionSpeakerID, String) -> Voidlet onMergeSpeakers: (SessionSpeakerID, SessionSpeakerID) -> Voidlet onUndo: () -> Void@@ -2529,6 +2555,8 @@ private struct MeetingResultCanvas: View {@Environment(\.theme) private var theme@State private var pendingRenameSpeaker: MeetingSessionSpeaker?@State private var pendingRenameText = ""+ @State private var pendingNameUnknownSegmentID: MeetingTranscriptSegmentID?+ @State private var pendingUnknownSpeakerName = ""@State private var isRenamingSession = false@State private var pendingRenameSessionText = ""@State private var isShowingAssignSpeakers = false@@ -2660,8 +2688,13 @@ private struct MeetingResultCanvas: View {speakerNames: speakerNames),speakerTint: row.segment.speakerID.flatMap { speakerTints[$0] },- onRenameSpeakerTapped: row.segment.speakerID.map { speakerID in- { self.presentAssignSpeakers(focusing: speakerID) }+ onRenameSpeakerTapped: {+ if let speakerID = row.segment.speakerID {+ self.presentAssignSpeakers(focusing: speakerID)+ } else {+ self.pendingNameUnknownSegmentID = row.segment.id+ self.pendingUnknownSpeakerName = ""+ }},isLocalUser: row.isLocal,showsSpeakerLabel: row.showsLabel,@@ -2716,6 +2749,24 @@ private struct MeetingResultCanvas: View {} message: {Text("Enter a new name for this speaker.")}+ .alert(+ "Name Unknown Speaker",+ isPresented: Binding(+ get: { self.pendingNameUnknownSegmentID != nil },+ set: { if !$0 { self.pendingNameUnknownSegmentID = nil } }+ )+ ) {+ TextField("Speaker name", text: self.$pendingUnknownSpeakerName)+ Button("Cancel", role: .cancel) { self.pendingNameUnknownSegmentID = nil }+ Button("Save") {+ if let segmentID = self.pendingNameUnknownSegmentID {+ self.onNameUnknownSegment(segmentID, self.pendingUnknownSpeakerName)+ }+ self.pendingNameUnknownSegmentID = nil+ }+ } message: {+ Text("This name applies only to this transcript turn.")+ }.alert("Rename Meeting", isPresented: self.$isRenamingSession) {TextField("Meeting title", text: self.$pendingRenameSessionText)Button("Cancel", role: .cancel) {}@@ -2727,6 +2778,7 @@ private struct MeetingResultCanvas: View {.onChange(of: self.session.id) { _, _ inself.showsProbableEchoes = falseself.isShowingAssignSpeakers = false+ self.pendingNameUnknownSegmentID = nil}.sheet(isPresented: self.$isShowingAssignSpeakers) {MeetingAssignSpeakersSheet(diff --git a/Tests/FluidDictationIntegrationTests/MeetingParakeetNemotronBackendTests.swift b/Tests/FluidDictationIntegrationTests/MeetingParakeetNemotronBackendTests.swiftindex 2677c9af..24686007 100644--- a/Tests/FluidDictationIntegrationTests/MeetingParakeetNemotronBackendTests.swift+++ b/Tests/FluidDictationIntegrationTests/MeetingParakeetNemotronBackendTests.swift@@ -838,16 +838,16 @@ final class MeetingParakeetNemotronBackendTests: XCTestCase {}XCTAssertEqual(tokenA.label, "slot-0")- guard case let .ambiguous(candidates) = try XCTUnwrap(unitsByText["b"]).speaker else {- return XCTFail("word b overlaps both slots")+ guard case let .assigned(tokenB) = try XCTUnwrap(unitsByText["b"]).speaker else {+ return XCTFail("word b should inherit the continuing incumbent in the handoff pass")}- XCTAssertEqual(candidates.map(\.label), ["slot-0", "slot-1"])+ XCTAssertEqual(tokenB.label, "slot-0")guard case .unassigned = try XCTUnwrap(unitsByText["c"]).speaker else {return XCTFail("word c overlaps no activity")}- // Assembly maps ambiguity into one visible unassigned segment, never two speakers.+ // Assembly keeps the resolved handoff on the existing product speaker.let assembly = try MeetingTranscriptAssembler().assemble(MeetingAssemblyInput(plan: plan,manifest: manifest,@@ -856,8 +856,8 @@ final class MeetingParakeetNemotronBackendTests: XCTestCase {))XCTAssertEqual(assembly.segments.map(\.text), ["a", "b"])XCTAssertEqual(assembly.speakers.count, 1, "only the unambiguous assigned slot mints a speaker")- let ambiguous = try XCTUnwrap(assembly.sidecar.dispositions.first { $0.unitID == unitsByText["b"]?.id })- XCTAssertEqual(ambiguous.disposition, .ambiguousUnassigned)+ let resolved = try XCTUnwrap(assembly.sidecar.dispositions.first { $0.unitID == unitsByText["b"]?.id })+ XCTAssertEqual(resolved.disposition, .emitted)let outside = try XCTUnwrap(assembly.sidecar.dispositions.first { $0.unitID == unitsByText["c"]?.id })XCTAssertEqual(outside.disposition, .outsideActivity)}@@ -995,6 +995,64 @@ final class MeetingParakeetNemotronBackendTests: XCTestCase {XCTAssertEqual(tokens.map(\.label), ["slot-0", "slot-1"])}+ func testHandoffAssignsNewEntrantWhoseActivityStartsWithShortWord() {+ let (slot0, slot1) = self.attributionTokens()+ let decision = MeetingParakeetNemotronBackend.handoffAssignment(+ .ambiguous([slot0, slot1]),+ start: 1,+ end: 1.4,+ activity: [+ MeetingBackendSpeakerActivity(token: slot0, start: 0, end: 1.4),+ MeetingBackendSpeakerActivity(token: slot1, start: 1, end: 1.4),+ ],+ previousAssignedWord: (slot0, 0.95)+ )+ guard case let .assigned(token) = decision else { return XCTFail("new onset should win the handoff") }+ XCTAssertEqual(token, slot1)+ }++ func testHandoffKeepsIncumbentWhenOtherSpeakerDidNotStartAtBoundary() {+ let (slot0, slot1) = self.attributionTokens()+ let decision = MeetingParakeetNemotronBackend.handoffAssignment(+ .ambiguous([slot0, slot1]),+ start: 1,+ end: 1.4,+ activity: [+ MeetingBackendSpeakerActivity(token: slot0, start: 0, end: 1.4),+ MeetingBackendSpeakerActivity(token: slot1, start: 0.2, end: 1.4),+ ],+ previousAssignedWord: (slot0, 0.95)+ )+ guard case let .assigned(token) = decision else { return XCTFail("continuing incumbent should own the word") }+ XCTAssertEqual(token, slot0)+ }++ func testHandoffVetoesMissingContextLongWordsLargeGapsAndMoreThanTwoCandidates() {+ let (slot0, slot1) = self.attributionTokens()+ let epoch = slot0.analysisEpochID+ let slot2 = MeetingBackendSpeakerToken(analysisEpochID: epoch, label: "slot-2")+ let activity = [+ MeetingBackendSpeakerActivity(token: slot0, start: 0, end: 2),+ MeetingBackendSpeakerActivity(token: slot1, start: 1, end: 2),+ MeetingBackendSpeakerActivity(token: slot2, start: 1, end: 2),+ ]++ for (assignment, start, end, previous) in [+ (MeetingBackendSpeakerAssignment.ambiguous([slot0, slot1]), 1.0, 1.4, nil),+ (.ambiguous([slot0, slot1]), 1.0, 2.0, (token: slot0, end: 0.95)),+ (.ambiguous([slot0, slot1]), 1.0, 1.4, (token: slot0, end: 0.0)),+ (.ambiguous([slot0, slot1, slot2]), 1.0, 1.4, (token: slot0, end: 0.95)),+ ] {+ guard case .ambiguous = MeetingParakeetNemotronBackend.handoffAssignment(+ assignment,+ start: start,+ end: end,+ activity: activity,+ previousAssignedWord: previous+ ) else { return XCTFail("handoff veto must preserve ambiguity") }+ }+ }+private func attributionTokens() -> (MeetingBackendSpeakerToken, MeetingBackendSpeakerToken) {let epoch = MeetingAnalysisEpochID(trackID: UUID(), ordinal: 0)return (diff --git a/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swift b/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swiftindex 9a0a524a..f72776ef 100644--- a/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swift+++ b/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swift@@ -1545,6 +1545,38 @@ final class MeetingRecoveryTests: XCTestCase {XCTAssertFalse(coordinator.canUndoCorrection(sessionID: session.id))}+ func testUndoNamingUnknownRestoresOnlyThatUnknownSegment() async throws {+ let dir = self.makeTempDirectory()+ defer { try? FileManager.default.removeItem(at: dir) }+ let store = MeetingSessionStore(rootDirectory: dir)+ let fixture = self.makeCorrectionSession(state: .completed)+ var session = fixture.0+ let segmentID = fixture.3+ session.transcriptSegments[0].speakerID = nil+ session.transcriptSegments[0].overlap = .ambiguous+ session.transcriptSegments[0].attributionState = .overlappingSpeakers+ let original = session.transcriptSegments[0]+ try await store.create(session)+ let coordinator = MeetingSessionCoordinator(+ store: store,+ capture: StubCaptureController(),+ processing: StubProcessingController(),+ audioArbiter: StubArbiter()+ )++ let named = try await coordinator.nameUnknownSegment(+ sessionID: session.id,+ segmentID: segmentID,+ displayName: "Guest"+ )+ XCTAssertEqual(named.speakers.count, session.speakers.count + 1)+ XCTAssertEqual(named.transcriptSegments[0].attributionState, .assigned)++ let undone = try await coordinator.undoTranscriptCorrection(sessionID: session.id)+ XCTAssertEqual(undone.transcriptSegments[0], original)+ XCTAssertEqual(undone.speakers, session.speakers)+ }+func testFailedCorrectionSaveLeavesNoUndoEntryAndDiskUnchanged() async throws {let dir = self.makeTempDirectory()defer { try? FileManager.default.removeItem(at: dir) }diff --git a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swiftindex 5d7e3958..f989201d 100644--- a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift+++ b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift@@ -610,13 +610,13 @@ extension MeetingSessionModelTests {XCTAssertEqual(lines, ["[00:04] Speaker 1: Initial provisional text",- "[01:05] Unassigned: No speaker text",+ "[01:05] Unknown speaker: No speaker text",])}/// Legacy fallback (no `attributionState`): a nil speaker with ambiguous overlap reads as/// "Overlapping speakers" rather than plain "Unassigned".- func testLegacyNilAttributionStateWithAmbiguousOverlapFallsBackToOverlappingSpeakers() {+ func testLegacyNilAttributionStateWithAmbiguousOverlapFallsBackToUnknownSpeaker() {var session = MeetingModelFixture.makeSession()var segment = session.transcriptSegments[0]segment.id = UUID()@@ -626,7 +626,7 @@ extension MeetingSessionModelTests {segment.text = "Crosstalk"session.transcriptSegments = [segment]- XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Overlapping speakers: Crosstalk"))+ XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Unknown speaker: Crosstalk"))}/// Legacy fallback still prefers a resolvable speaker name over any overlap-derived label.@@ -648,7 +648,7 @@ extension MeetingSessionModelTests {XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Speaker 1: Initial provisional text"))}- func testOverlappingSpeakersAttributionStateLabel() {+ func testOverlappingEvidenceUsesUnknownSpeakerLabel() {var session = MeetingModelFixture.makeSession()var segment = session.transcriptSegments[0]segment.speakerID = nil@@ -656,7 +656,7 @@ extension MeetingSessionModelTests {segment.text = "Crosstalk"session.transcriptSegments = [segment]- XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Overlapping speakers: Crosstalk"))+ XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Unknown speaker: Crosstalk"))}func testUnassignedAttributionStateLabel() {@@ -667,7 +667,7 @@ extension MeetingSessionModelTests {segment.text = "No evidence"session.transcriptSegments = [segment]- XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Unassigned: No evidence"))+ XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Unknown speaker: No evidence"))}func testTimingUncertainAttributionStateLabel() {@@ -678,7 +678,7 @@ extension MeetingSessionModelTests {segment.text = "Late text"session.transcriptSegments = [segment]- XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Timing uncertain: Late text"))+ XCTAssertTrue(MeetingTranscriptExporter.text(for: session).contains("Unknown speaker: Late text"))}/// The `assigned` state still walks the alias chain, so a renamed/merged speaker resolves the@@ -1555,6 +1555,28 @@ final class MeetingSessionModelTests: XCTestCase {XCTAssertEqual(session.transcriptSegments[0].attributionState, .assigned)}+ func testNamingOneUnknownCreatesAnIndependentSpeakerForOnlyThatSegment() throws {+ var session = MeetingModelFixture.makeSession()+ var firstUnknown = session.transcriptSegments[0]+ firstUnknown.speakerID = nil+ firstUnknown.overlap = .ambiguous+ firstUnknown.attributionState = .overlappingSpeakers+ var secondUnknown = firstUnknown+ secondUnknown.id = UUID()+ secondUnknown.start = MeetingModelFixture.mediaTime(10)+ secondUnknown.end = MeetingModelFixture.mediaTime(11)+ session.transcriptSegments = [firstUnknown, secondUnknown]++ let createdID = try session.nameUnknownSegment(id: firstUnknown.id, displayName: "Guest")++ XCTAssertEqual(session.transcriptSegments[0].speakerID, createdID)+ XCTAssertEqual(session.transcriptSegments[0].attributionState, .assigned)+ XCTAssertEqual(session.transcriptSegments[0].overlap, .none)+ XCTAssertNil(session.transcriptSegments[1].speakerID)+ XCTAssertEqual(session.transcriptSegments[1].attributionState, .overlappingSpeakers)+ XCTAssertEqual(session.speakers.first(where: { $0.id == createdID })?.displayName, "Guest")+ }+func testReassignSegmentToSameSpeakerIsNoOp() throws {var session = MeetingModelFixture.makeSession()let segmentID = session.transcriptSegments[0].id