Adds README.md to each of the 13 SPM packages (AgentCore, Bus, Config, DevOverlay, Harness, Keychain, Logging, MCP, Memory, Replay, Shell, Vision, Voice). Each covers purpose, key public types, deps, consumers, invariants (pulled from CLAUDE.md + grep-gates + audit findings), test stack, and notable files. Memory README explicitly marks the package functionally OFF until vec0.dylib + Ollama models land. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4.1 KiB
Voice
The voice loop: audio graph + wake word + VAD + STT + TTS + the state machine actor that stitches them. Local-only by user constraint — no cloud STT/TTS.
Key public types
| Type | Purpose |
|---|---|
VoiceController (actor) |
Top-level state machine — idle / listening / thinking / speaking |
VoiceState |
State enum |
AudioGraphOwner (actor) |
AVAudioEngine lifecycle + canonical six-step teardown (VOICE-10) |
BufferBroadcaster |
Multi-consumer fan-out from the Core Audio tap (Track B-7) |
RingBuffer |
SPSC ring (one consumer per ring; never read directly outside Voice) |
WakeWordDAG |
mel ring → embedding ring → classifier; openWakeWord hey_jarvis; 4-frame hysteresis |
OpenWakeWordSession |
ONNX Runtime session wrapper |
SileroVAD |
VAD on 512-sample / 32 ms / 16 kHz windows |
SpeechAnalyzerSTT |
macOS 26 Tahoe primary (gated by @available(macOS 26, *)) |
WhisperKitSTT |
Argmax large-v3-v20240930_626MB fallback (feature-flagged) |
STTProvider (protocol) |
Common contract |
TTSEngineActor |
Tier-1 / tier-2 dispatcher with serial executor (prevents Metal cmd-buffer deadlock) |
AVSpeechSynth |
Tier-1 AVSpeechSynthesizer (instant, mediocre) |
OrpheusTTS |
Tier-2 (deferred — weights download outstanding) |
TTSKitFallback |
Tier-2 fallback via Argmax TTSKit |
AudioLevelEmitter |
RMS → BusOutbound.audioLevel for HUD pulse (production wiring open) |
PushToTalk / MuteWakeWord |
Per-call control surface |
Depends on
AgentCore, Bus, Logging, Config. External: onnxruntime-swift-package-manager, argmax-oss-swift (WhisperKit + TTSKit), mlx-audio-swift (Orpheus), swift-atomics, swift-log.
Used by
App/AppDelegate, App/Voice/ (production adapters — VoiceOrchestratorAdapter, VoiceTTSAdapter, VoiceBusEmitterAdapter).
Key invariants / contracts
- VOICE-14 single
cancelAndSubmitcall site. OnlyVoiceController.bargeIn(). Grep-gated. - T-06-05-03: never log voice transcript text. Every Voice
logger.debugcall site reviewed. - T-06-05-02: AEC banner via native AppKit, never webview modal.
scripts/check-no-modal-presentation.sh. - T-06-05-04: 200 ms barge-in debounce.
BargeInTestsB4. - VOICE-12: PTT works when wake-word is muted.
pttDown()/pttUp()bypass the mute gate. - VOICE-09: AEC-off as distinct variant. If
setVoiceProcessingEnabled(true)throws, emit.aecUnavailableTHEN rebuild withaec: false. - VOICE-10: six-step teardown. All four rebuild triggers call the single
teardown()private method onAudioGraphOwner. - Multi-consumer audio:
BufferBroadcaster.subscribe(), never rawRingBufferoutside the Voice package.RingBufferis documented SPSC. BufferBroadcaster.publishis real-time-thread-safe. Lock-free / wait-freeOSAllocatedUnfairLocksnapshot — no actor hops, no Foundation locks.- VAD-gated session end. STT session ends on
.speechEnd+ 5-chunk hangover (~160 ms). Mid-utterance speech resumption cancels the pending finalize. TTSEngineActorserial executor. Prevents Metal command-buffer serialization deadlock on rapid-fire syntheses.- Test seam visibility.
_forceState,_testFireSpeechEnd,_testCurrentSttSessionIdareinternal(P2-14); tests use@testable import.
Tests
87 XCTest + 23 swift-testing (3 skipped). Includes BufferBroadcasterTests (BB-1..5 incl. concurrent stress), VoiceLoopE2ETests (E1..E3 — preset chunks → orchestrator.submit), VADGatedSessionTests (VAD-1..5), BargeInTests (B1..B4). Pre-existing 10s flake on TTSInterruptTests.testI3 (fixed in audit-2026-05-04 batch — propagates consumer cancellation in ScriptedSpeechModel).
Notable files
Sources/Voice/VoiceController.swift— top-level state machineSources/Voice/AudioGraph/AudioGraphOwner.swift— engine lifecycleSources/Voice/AudioGraph/BufferBroadcaster.swift— multi-consumer fan-outSources/Voice/STT/SpeechAnalyzerSTT.swift— macOS 26 STTSources/Voice/TTS/TTSEngineActor.swift— tier-1 / tier-2 dispatcher