Phases 2-6: detection, visual timeline, backend hand-off, voiceprints

Phase 2 (call detection): CallDetector using CoreAudio per-process mic
attribution (anarlog technique) — robust start+stop for Zoom/Teams/Signal/Meet,
ignoring our own recording; auto-record toggle. Built; pending live multi-app
confirmation by the user.

Phase 3 (visual timeline foundation): AppAdapter protocol + SpeakerObservation,
TimelineBuilder (hysteresis/overlap/self-merge/aliases), VisualTimeline (schema
1.1), TextRecognizer (Vision OCR), FrameSampler + GridCallAnalyzer (name OCR +
saturated-highlight active-speaker attribution), SignalAdapter, VisualObserver
(window capture; frames released, never saved; minimized->visual_gap, idle != gap).
Synthetic-frame tested; adapter geometry pending real Signal fixtures + live
VisualObserver validation.

Phase 5 (backend hand-off): SparkControlClient (multipart label-merge, sequential,
TLS-skip, 503 Retry-After/413), SessionPackager (chunk plan + WAV slice + timeline
slice/rebase), TranscriptAssembler + SpeakersFile, TranscriptPipeline. Validated
END-TO-END against the live backend (chunk -> label-merge -> speakers.json).

Phase 6 (voiceprints): VoiceprintStore (known_voiceprints, persist named
fingerprints, skip Unknown). Wired: 'Send to backend' button + transcript status,
auto-send toggle (default off) + self-name setting.

All adversarial-review findings fixed. App + XCTest suite build; tests pass.
This commit is contained in:
Grant Gilliam
2026-06-06 00:15:49 -05:00
parent fd7e1a5907
commit 863136aeec
27 changed files with 2108 additions and 22 deletions
@@ -0,0 +1,45 @@
import XCTest
@testable import Ten31Transcripts
final class VoiceprintStoreTests: XCTestCase {
private func tempURL() -> URL {
FileManager.default.temporaryDirectory.appendingPathComponent("vp_\(UUID().uuidString).json")
}
private func response() throws -> LabelMergeResponse {
let json = #"{"duration":10,"speakers":[{"cluster":"Speaker_0","name":"Grant","source":"visual","overlap_confidence":0.99,"fingerprint":[0.1,0.2,0.3]},{"cluster":"Speaker_1","name":"Sarah","source":"voiceprint","match_similarity":0.7,"fingerprint":[0.4,0.5,0.6]},{"cluster":"Speaker_2","name":"Bob","source":"visual","overlap_confidence":0.5,"fingerprint":[0.7,0.8,0.9]},{"cluster":"Speaker_3","name":"Unknown_0","source":"unmatched"}],"segments":[],"fingerprints":{"Grant":[0.1,0.2,0.3],"Sarah":[0.4,0.5,0.6]},"models":{}}"#
return try JSONDecoder().decode(LabelMergeResponse.self, from: Data(json.utf8))
}
func testStoresOnlyConfidentNamedSpeakers() throws {
let url = tempURL(); defer { try? FileManager.default.removeItem(at: url) }
let store = VoiceprintStore(fileURL: url)
store.update(with: try response())
XCTAssertNotNil(store.entries["Grant"]) // visual, high overlap
XCTAssertNotNil(store.entries["Sarah"]) // voiceprint match
XCTAssertNil(store.entries["Bob"]) // overlap 0.5 < 0.8
XCTAssertNil(store.entries["Unknown_0"])
XCTAssertEqual(store.knownVoiceprints()["Grant"], [0.1, 0.2, 0.3])
XCTAssertEqual(store.entries["Grant"]?.calls, 1)
}
func testPersistsAcrossInstancesAndIncrementsCalls() throws {
let url = tempURL(); defer { try? FileManager.default.removeItem(at: url) }
let store = VoiceprintStore(fileURL: url)
store.update(with: try response())
store.update(with: try response())
XCTAssertEqual(store.entries["Grant"]?.calls, 2)
let reopened = VoiceprintStore(fileURL: url)
XCTAssertEqual(reopened.knownVoiceprints().count, 2)
}
func testRenameRemoveReset() throws {
let url = tempURL(); defer { try? FileManager.default.removeItem(at: url) }
let store = VoiceprintStore(fileURL: url)
store.update(with: try response())
store.rename("Sarah", to: "Sarah Jones")
XCTAssertNotNil(store.entries["Sarah Jones"]); XCTAssertNil(store.entries["Sarah"])
store.remove("Grant"); XCTAssertNil(store.entries["Grant"])
store.reset(); XCTAssertTrue(store.entries.isEmpty)
}
}