Commit Graph
5 Commits
Author SHA1 Message Date
james.maes 4b1dd6404b fix(voice): v0.1 CRIT cluster — wake / STT / TTS / boot probes (#28, #29, #30, #31, #32, #33, #34, #36, #158)
#28 (CRIT): setCancelInFlight calls stopFeed() (preserves stream); rebuild consumer re-arms DAG against new ring. Wake-word no longer dies on audio-graph rebuild.

#29 (CRIT): sttFactory reads PerTurnSnapshot.stt.whisperKitFallback; get_self_state returns canonical snake_case backend constants. Factory signature: () -> any STTProvider → () async -> any STTProvider (existing test sites compile unchanged under Swift 6 implicit-async-closure rules).

#30 (CRIT): TTSEngineActor.synthesize emits .ttsStopped after .finished on natural completion (two-emit-site model: barge-in + natural-completion).

#31 (CRIT): VoiceTTSAdapter.tierResolver wired to read snap.tts.tier from configStore.

#32 (HIGH): Rolling-window trim in OpenWakeWordSession.runORT — mel ≤ 84, embeddings ≤ 16, nextEmbStart slides on drop.

#33 (HIGH): three new boot probes — WakeWordBootHealthProbe, STTBootHealthProbe, TTSBootHealthProbe. New WakeWordDAG.isFeedArmed + VoiceTTSAdapter.hasEngine accessors.

#34 (HIGH): vad.reset() at top of startSTTSession clears Silero VAD LSTM hidden state + wasSpeech between sessions.

#36 (HIGH): new Broadcaster.Priority.agentHud (protects stateChange/turnEnd/error); installAgent adds subscriber pumping AgentHudIntent into dormantAgentContinuation.

Voice 90 + AgentCore 242 tests pass; all 18 boundary gates green.
2026-05-13 06:31:17 -05:00
james.maesandClaude Opus 4.7 81357ca900 test(voice p1-2): production chunkPump factory extracted + integration test against real broadcaster
Per audit 2026-05-04 T2: the production chunkPump closure at AppDelegate
.installVoice was tested only end-to-end via synthetic pumps — the real
subscribe + readMono16k loop had zero coverage. Same divergence pattern
that produced BLOCKER-INT-1 (NoopBusGateway).

Extract the closure into App/Voice/ProductionChunkPump.swift as
makeProductionChunkPump(graphOwner:); AppDelegate becomes a one-line
caller. New ProductionChunkPumpTests covers three integration paths:

- PCT1: pump finishes immediately when graphOwner is nil
- PCT2: pump receives buffers via the broadcaster fan-out (publishes
        through a tap-block-capturing GraphBuilder against a real
        AudioGraphOwner)
- PCT3: pump's subscription does not steal samples from a sibling
        subscription (P1-1 / Track B-7 invariant regression guard)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-04 15:46:32 -05:00
james.maesandClaude Opus 4.7 ee7f6d2dc7 fix(track-b 1-3): bundle voice models + WakeWordDAG typo + tier-1 TTS wiring
User feedback after deep audit: voice modality reported as "F — nothing
works". The audit identified five independent fatal breaks; this commit
closes the first three under TDD discipline. B-4 (AudioGraphOwner +
LiveSpeechAnalyzerBridge) and B-5 (voice loop e2e test) are the next
session's work.

**B-1 — voice models bundled at the runtime path:**
- scripts/copy-voice-models.sh — new postBuildScript that copies
  Resources/models/{openwakeword,silero}/ → Contents/Resources/Models/
  {openWakeWord,silero}/. Maps lowercase canonical-on-disk to capital-M
  runtime path AppDelegate.installVoice expects (was off-by-case +
  no copy phase at all). Hard-fails on PLACEHOLDER_… sha256 in
  MANIFEST.json so a forgotten fetch script is a build error, not a
  silent runtime failure.
- scripts/test-copy-voice-models.sh — 6 shell-level tests for the
  copy script (real-real bundle layout, PLACEHOLDER hard-fail,
  missing manifest, soft-degrade, capital-M path matches AppDelegate).
  All 6 pass.
- project.yml — adds the copy phase to Jarvis target's postBuildScripts.
- Resources/models/silero/MANIFEST.json — populated with real
  sha256 hashes by running scripts/fetch-silero-models.sh.

**B-2 — WakeWordDAG.swift:93 production typo:**
- packages/Voice/Sources/Voice/WakeWord/WakeWordDAG.swift — was
  `session.feedTest()` (test seam, always passes empty `[Float]` to
  hysteresis). Production path now calls `session.feed(samples:)` with
  the actual ring buffer slice. Without this, the wake word literally
  could never fire in production — every frame hit the hysteresis with
  zero samples regardless of mic input.
- packages/Voice/Tests/VoiceTests/WakeWordDAGTests.swift — 2 new
  tests: WD-1 verifies the DAG forwards actual ring contents to the
  session's classifier (RED on the bug; GREEN after the fix); WD-2
  verifies an empty ring doesn't trigger wasted classifier calls.

**B-3 — tier-1 TTS engine wired:**
- packages/Voice/Sources/Voice/TTS/TTSEngineActor.swift — `orpheus`
  parameter is now `OrpheusTTS?` (was non-optional). Production
  callers can wire just AVSpeechSynthesizer without first downloading
  Orpheus 3B weights from HuggingFace. Tier-2 requested with nil
  Orpheus degrades to tier-1 transparently via a new resolvedTier
  branch; defensive guard throws TTSError.sinkUnavailable if the
  branch ever leaks through.
- packages/Voice/Tests/VoiceTests/TTSEngineActorTier1Tests.swift —
  4 new tests: TET1-1 (construction with nil Orpheus), TET1-2 (real
  AVSpeechSynthesizer emits .started → .firstAudio → .finished),
  TET1-3 (.tier2 with nil Orpheus does NOT crash), TET1-4 (rapid-fire
  cancels prior synthesis).
- App/Voice/VoiceOutputWiring.swift — new factory enum that constructs
  the tier-1 engine. Lives outside AppDelegate.swift so the VISION-03
  Layer 3 grep gate (no PresenceSignalBus + TTS engine in same file)
  stays clean.
- App/AppDelegate.swift — `VoiceTTSAdapter(engine: nil)` becomes
  `VoiceTTSAdapter(engine: VoiceOutputWiring.makeTier1Engine())`.
  Voice subsystem now has a real synthesis path on every launch.

**Verification:**
- AgentCore: 215/215.
- Voice: WakeWordDAGTests 2/2, TTSEngineActorTier1Tests 4/4.
- Replay: 33/33.
- Bus: 57/58 (F-A2-01 pre-existing).
- webview/hud: 94/94.
- All 15 boundary grep gates: PASS (including check-presence-vision-
  isolation.sh — VoiceOutputWiring.swift renamed from TTSEngineWiring
  + comment text scrubbed of PresenceSignalBus references so the
  Layer 3 substring check no longer flags it).
- scripts/check-app-builds.sh: PASS.
- Models verified at bundle path Contents/Resources/Models/
  {openWakeWord,silero}/ with real .onnx files.

**Carry-forward to next session:**
- B-4: construct AudioGraphOwner in installVoice; start AVAudioEngine;
  route mic taps to wake-word DAG. Replace LiveSpeechAnalyzerBridge.feed
  body (`_ = chunk`) with the macOS 26 SpeechAnalyzer wiring.
- B-5: voice loop e2e — feed a known WAV file at the audio graph,
  assert STT result lands on the orchestrator.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 18:16:11 -05:00
james.maes 75a4ed6991 feat(09-04): replace NullVoiceAdapters with real voice adapter triad + lock install order (D-09, D-10, BLOCKER-1, BLOCKER-2, WARNING-5)
- New App/Voice/{VoiceOrchestratorAdapter,VoiceTTSAdapter,VoiceBusEmitterAdapter,RejectReasonCopy}.swift
  replaces NullOrchestratorAdapter / NullTTSAdapter / NullBusEmitterAdapter (D-09).
- VoiceOrchestratorAdapter forwards submit/cancelAndSubmit to AgentOrchestrator,
  appends user-side text to TurnTranscriptStore (BLOCKER-1), enqueues a HUDBanner
  on every SubmitOutcome.rejected case via shared RejectReasonCopy (D-10).
- VoiceTTSAdapter wraps an optional TTSEngineActor (engine construction lands
  in a follow-on plan; nil-engine path no-ops gracefully).
- VoiceBusEmitterAdapter wraps an OutboundBatcher whose sink is the WebviewBridge
  so audio-level RMS reaches the HUD's RingMesh pulse.
- AppDelegate.installVoice now uses the production adapters; install order
  in applicationWillFinishLaunching reordered to vision -> agent -> voice
  with voiceInstallTask awaiting agentInstallTask?.value (WARNING-5).
- New broadcaster .voice subscriber in installAgent: per-turn assistantText
  accumulator + turnSourceWasVoice filter so text-originated turns NEVER drive
  emitTurnEnded on the voice adapter (BLOCKER-2).
- SubmitOutcome.superseded extended with newTurnId so cancelAndSubmit callers
  can append user text under the new turn id (BLOCKER-1 user-side closure on
  the cancel path).
- VoiceSubscriberTextTurnFilterTests proves text turns never trigger
  emitTurnEnded; VoiceOrchestratorAdapterTests covers RejectReasonCopy +
  banner id mapping + VoiceBusEmitterAdapter forwarding.
- New scripts/check-install-order.sh + scripts/check-no-null-voice-adapters.sh
  catch regressions structurally.
2026-05-01 20:39:19 -05:00
james.maes 6f4f2fb6c2 feat(07-06): four cross-plan grep gates + AppDelegate install-order test (Task 3)
- scripts/check-single-memory-mutated-emit.sh — MEM-06 single-emission-site
  for ReplayEvent.memoryMutation (allowlist: MemoryStore.swift,
  Replay/ReplayEvent.swift, Replay/Schema.swift; tests + comments excluded).
- scripts/check-single-memory-used-emit.sh — D-05 single-emission-site for
  ReplayEvent.memoryRetrieval (same allowlist shape, MemoryStore.recordRetrieval
  is the sole emit site).
- scripts/check-presence-vision-isolation.sh — VISION-03 three-layer guard:
  Layer 1 (Vision/Package.swift declares no Voice or AgentOrchestrator dep),
  Layer 2 (no `import Voice` / `import AgentOrchestrator` and no TTSEngine /
  AgentOrchestrator.runTurn / cancelAndSubmit token references in
  packages/Vision/Sources/), Layer 3 (no App/ file co-locates a
  PresenceSignalBus reference with a forbidden TTS / runTurn token).
- scripts/check-embedding-dim-literal.sh — MEM-02 invariant: no literal 768
  in packages/Memory/Sources/Memory/ outside Constants.swift; comment-only
  lines tolerated.
- All four scripts wired as Jarvis pre-build phases in project.yml; the
  generated project.pbxproj reflects the updates.
- packages/Memory/Tests/MemoryTests/PhaseSevenGrepGateTests.swift mirrors
  the four shell gates as XCTest assertions plus a fifth assertion
  (testAppDelegateInstallOrder) verifying the call order in
  applicationWillFinishLaunching: installMemory before installVoice
  before installVision.
- App/Voice/NullVoiceAdapters.swift extracted from AppDelegate.swift to
  honor the Layer 3 boundary cleanly. NullOrchestratorAdapter and
  NullTTSAdapter are placeholder no-ops mirroring the prior structure;
  Phase 7 future wiring replaces them with real bridges.
- Negative-case demonstration completed: introducing a stray
  `.memoryMutation(...)` literal in App/AppDelegate.swift made
  check-single-memory-mutated-emit.sh exit non-zero; the violation was
  reverted before commit. Documented as evidence of gate sensitivity.
2026-04-29 18:58:11 -05:00