Phase 2.5: extract transcription-engine protocol seams - #48
Merged
Conversation
Fifth platform extraction (after SecretStore, LaunchAtLoginService, TextOutput,
HotkeyControlling). The two engines have genuinely different shapes, so they get
two focused protocols rather than one leaky abstraction:
- FileTranscriptionEngine (request/response): WhisperEngine conforms. transcribe
+ warmServer + stopServer + onTranscriptionComplete/Error/onProgress/
onWorkerStatus. A protocol extension provides the deleteWhenDone=true default so
the existing call site is unchanged (only the 7-arg overload matches it).
- StreamingTranscriptionEngine (live): AppleSpeechEngine conforms. start/stop +
onPartial/onFinal/onError/onLevelChanged.
- WhisperEngine.Backend nested enum -> top-level WhisperBackend in OpenWhispCore
(so the protocol can name it); kept `typealias Backend = WhisperBackend` so the
engine body and .cli/.serverAPI sites are untouched.
- AppState's whisperEngine/appleSpeechEngine properties are now the protocol types.
AppleSpeechEngine's authorization statics and WhisperEngine.logFileURL() stay on
the concrete types (they return/encode platform specifics) — correct boundary.
- Adversarial review confirmed exact equivalence (overload resolution, Backend
cases, stop(cancel:), statics, callback wiring).
- Tests: +5 with Fake{File,Streaming}TranscriptionEngine doubles that unlock
future AppState-orchestration tests. 112 -> 117.
- ROADMAP: mark both engines done under Phase 2.5.
swift test 117/117; ./build.sh clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fifth platform extraction (after #44 #45 #46 #47). The two engines have genuinely different shapes — request/response vs. live streaming — so they get two focused protocols rather than one leaky abstraction.
Changes
FileTranscriptionEngine(request/response) —WhisperEngineconforms.transcribe+warmServer+stopServer+ the fouron…callbacks. A protocol extension supplies thedeleteWhenDone = truedefault so the existing call site is unchanged (only the 7-arg overload matches it — verified unambiguous).StreamingTranscriptionEngine(live) —AppleSpeechEngineconforms.start/stop+onPartial/onFinal/onError/onLevelChanged.WhisperBackendmoved to OpenWhispCore (so the protocol can name it);typealias Backend = WhisperBackendkeeps the engine body and.cli/.serverAPIsites untouched.whisperEngine/appleSpeechEngineare now the protocol types.AppleSpeechEngine's authorization statics andWhisperEngine.logFileURL()stay concrete — they return/encode platform specifics, so that's the correct boundary.stop(cancel:), statics, callback wiring).Fake{File,Streaming}TranscriptionEnginedoubles that unlock future AppState-orchestration tests. 112 → 117.swift test117/117 ·./build.shclean.🤖 Generated with Claude Code