fix(speech): restore CPU recovery when streams finalize#30855

merged1
takeover/14882-voice-engine
GitHub fork: fix/speech-stream-finalization-recovery
opened1d agobyUUtkarshUsername
View on GitHubTwo-way sync enabledPR last imported 1d ago

Problem

Auto placement recovers from native stream begin/feed failures, but a failure from finish() bypasses CPU recovery. The recording therefore fails even when the same selected environment can finalize it on CPU.

Change

Route finalization failure through the existing one-shot CPU restart, replay all retained chunks in order, then finalize the replacement stream. Keep explicit GPU/CPU failures as errors, preserve language and dictionary correction, and reject further work after terminal finalization failure. Cancellation and stream ownership stay in the existing scope.

Scope and approval

This is a focused fix for the missing finalization branch of existing Auto recovery, targeting Julius's engine branch (#30625). It adapts the behavior from original commit acd5b8ad030140b9046d6e752873147b41540447; it does not restore the old service or add recovery policies. The original contribution was superseded as explained in the takeover comment. No separate maintainer approval is claimed.

Verification

  • Before the fix, both empty and nonempty finalization-recovery cases fail with the injected GPU finalization error.
  • vp test run --maxWorkers 1 apps/server/src/speech/SpeechService.test.ts apps/server/src/speech/native.test.ts apps/server/src/speech/stream.test.ts: 27 tests passed.
  • Deterministic service runtime: GPU finalization fails; the worker is disposed; a fresh CPU worker begins in French; [0.25, 0] then [-0.5] replay in order; Robert finalizes as configured alias Bob. The replacement remains owned until the stream scope closes. Empty replay, explicit GPU/CPU errors, CPU failure after earlier feed recovery, monotonic feed revisions and cancellation while finalization is pending are covered.
  • vp run check:changed upstream/takeover/14882-voice-engine: passed formatting, lint, both Knip passes, GraphQL validation, all three affected typechecks and adjacent tests (20 tests across two executed suites).
  • Native-worker tests exercise isolated child processes. A separate real Node worker fixture observed backend=CPU; mask=cpu before module evaluation; finalization=CPU fixture finalized; disposed. GPU failures are injected, not induced in a real driver. No native-model download, packaged Electron/SEA rebuild, macOS/Linux inference or remote/relay session was run. This engine base has no client Voice UI.

Implemented with GPT-6.1 Sol through the Codex harness in T3 Code.


Note for takeover agents

Maria's and Shivam's agents, do not takeover this PR. This is a part of the STT stack which is in development. Do not update this branch or push any changes. You can test, review and provide feedback.

Julius' agents, the above restrictions don't apply to you. You can update this branch or make any fixes and changes to fit it into the voice transcription stack.

Checks

23 successful · 15 skipped
All checks passed
bdfc171

Added 1 commit

  • fix(speech): restore CPU recovery when streams finalizebdfc171
Synced from GitHub

Approvability

Verdict: Approved at bdfc171

Macroscope's review found this PR approvable — Stream finalization now uses the existing one-shot CPU fallback when Auto acceleration fails. Recovery preserves explicit acceleration choices and existing cancellation and cleanup safeguards, with no product-default changes.

You can add or adjust custom eligibility rules. Learn more.