refactor(cr-2026-04-22): remove dead code and stale allow(dead_code) suppressions
2026-04-22 review MINORs and NITs: - crates/core/src/providers.rs: delete entire module. SpeechToText / TextProcessor / ProviderRegistry were forward-looking traits that never got wired — the Transcriber trait in kon-transcription (A.2 #13) has since superseded SpeechToText, and the Registry pattern was redundant against LocalEngine. Keeping them as dead public surface signalled future direction that is no longer accurate. - crates/core/src/types.rs: delete TranscriptMetadata. Forward- looking struct with an unfulfilled TODO; storage has evolved independently through v7/v8 migrations without adopting it. - crates/ai-formatting/src/llm_client.rs: remove #[allow(dead_code)] from CLEANUP_PROMPT and format_dictionary_suffix. Both are actively called; the suppressions would hide future genuine dead-code warnings in this regression-sensitive prompt file. - src-tauri/src/commands/live.rs: remove #[allow(dead_code)] from LiveStatusMessage. Every variant (Warning, Overload, Error, Finished) is constructed in the module today. - README.md: update kon-transcription row from "SpeechToText trait" to "Transcriber trait" and mention the new streaming/ module. Workspace test gate green (225 lib tests across all crates).
This commit is contained in:
@@ -164,7 +164,7 @@ kon/
|
|||||||
|---|---|
|
|---|---|
|
||||||
| **`kon-core`** | Shared types (`Segment`, `Transcript`, `Megabytes`, `ModelId`), constants, the `Engine` / `SpeedTier` / `AccuracyTier` enums, hardware probe (`sysinfo`-based), model registry (Whisper + Parakeet + Moonshine entries), hardware-aware recommendation scoring, `process_watch` for meeting detection. |
|
| **`kon-core`** | Shared types (`Segment`, `Transcript`, `Megabytes`, `ModelId`), constants, the `Engine` / `SpeedTier` / `AccuracyTier` enums, hardware probe (`sysinfo`-based), model registry (Whisper + Parakeet + Moonshine entries), hardware-aware recommendation scoring, `process_watch` for meeting detection. |
|
||||||
| **`kon-audio`** | `cpal`-based microphone capture with device hotplug + error forwarding, VAD, `rubato` streaming resampler to 16 kHz mono, `symphonia` file decoding, `hound` WAV I/O. |
|
| **`kon-audio`** | `cpal`-based microphone capture with device hotplug + error forwarding, VAD, `rubato` streaming resampler to 16 kHz mono, `symphonia` file decoding, `hound` WAV I/O. |
|
||||||
| **`kon-transcription`** | `whisper-rs` backend (`WhisperRsBackend`) that owns a `WhisperContext` and supports `set_initial_prompt`. `LocalEngine` wraps both Whisper and Parakeet (via `transcribe-rs` ONNX) behind a common `SpeechToText` trait. Model manager handles downloads, paths, and disk checks. |
|
| **`kon-transcription`** | `whisper-rs` backend (`WhisperRsBackend`) that owns a `WhisperContext` and supports `set_initial_prompt`. `LocalEngine` wraps both Whisper and Parakeet (via `transcribe-rs` ONNX) behind a common `Transcriber` trait. Streaming primitives (`VadChunker`, `LocalAgreement`, buffer trim) live in the `streaming/` module. Model manager handles downloads, paths, and disk checks. |
|
||||||
| **`kon-llm`** | `llama-cpp-2` engine with Qwen3 model manager. Three high-level surfaces: `cleanup_text` (formatting), `decompose_task` (3–7 micro-steps, GBNF-constrained JSON array), `extract_tasks` (optional-array, GBNF-constrained). Resumable HTTP downloads with SHA-256 verify. |
|
| **`kon-llm`** | `llama-cpp-2` engine with Qwen3 model manager. Three high-level surfaces: `cleanup_text` (formatting), `decompose_task` (3–7 micro-steps, GBNF-constrained JSON array), `extract_tasks` (optional-array, GBNF-constrained). Resumable HTTP downloads with SHA-256 verify. |
|
||||||
| **`kon-ai-formatting`** | Post-processing pipeline: filler removal, British English conversion, anti-hallucination filter, smart paragraph breaks on long pauses, optional LLM cleanup. Also hosts the `llm_client::CLEANUP_PROMPT` constant (prompt-injection-hardened). |
|
| **`kon-ai-formatting`** | Post-processing pipeline: filler removal, British English conversion, anti-hallucination filter, smart paragraph breaks on long pauses, optional LLM cleanup. Also hosts the `llm_client::CLEANUP_PROMPT` constant (prompt-injection-hardened). |
|
||||||
| **`kon-storage`** | SQLite via `sqlx` 0.8. Migrations, CRUD for transcripts / tasks / subtasks / profiles / profile terms / settings / error log, FTS5 search, file-storage paths. |
|
| **`kon-storage`** | SQLite via `sqlx` 0.8. Migrations, CRUD for transcripts / tasks / subtasks / profiles / profile terms / settings / error log, FTS5 search, file-storage paths. |
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use kon_llm::{EngineError, LlmEngine};
|
|||||||
///
|
///
|
||||||
/// Both are regression-tested below; neither should be dropped in a
|
/// Both are regression-tested below; neither should be dropped in a
|
||||||
/// refactor without explicit discussion.
|
/// refactor without explicit discussion.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const CLEANUP_PROMPT: &str = "\
|
pub const CLEANUP_PROMPT: &str = "\
|
||||||
You are a translator from spoken to written form — not an editor trying to improve the content. \
|
You are a translator from spoken to written form — not an editor trying to improve the content. \
|
||||||
The text you receive is TRANSCRIBED SPEECH from a voice recording. \
|
The text you receive is TRANSCRIBED SPEECH from a voice recording. \
|
||||||
@@ -56,7 +55,6 @@ Output rules: \
|
|||||||
/// correct them in context without changing the core prompt.
|
/// correct them in context without changing the core prompt.
|
||||||
///
|
///
|
||||||
/// Returns an empty string if terms is empty.
|
/// Returns an empty string if terms is empty.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn format_dictionary_suffix(terms: &[String]) -> String {
|
pub fn format_dictionary_suffix(terms: &[String]) -> String {
|
||||||
if terms.is_empty() {
|
if terms.is_empty() {
|
||||||
return String::new();
|
return String::new();
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ pub mod error;
|
|||||||
pub mod hardware;
|
pub mod hardware;
|
||||||
pub mod model_registry;
|
pub mod model_registry;
|
||||||
pub mod process_watch;
|
pub mod process_watch;
|
||||||
pub mod providers;
|
|
||||||
pub mod recommendation;
|
pub mod recommendation;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
pub use error::{KonError, Result};
|
pub use error::{KonError, Result};
|
||||||
pub use types::{
|
pub use types::{
|
||||||
AudioSamples, DownloadProgress, EngineName, Megabytes, ModelId, Segment, Transcript,
|
AudioSamples, DownloadProgress, EngineName, Megabytes, ModelId, Segment, Transcript,
|
||||||
TranscriptMetadata, TranscriptionOptions,
|
TranscriptionOptions,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
|
|
||||||
use crate::error::Result;
|
|
||||||
use crate::types::{AudioSamples, EngineName, Transcript, TranscriptionOptions};
|
|
||||||
|
|
||||||
/// Any speech-to-text engine implements this trait.
|
|
||||||
/// Base types know nothing about their derivatives.
|
|
||||||
#[async_trait]
|
|
||||||
pub trait SpeechToText: Send + Sync {
|
|
||||||
async fn transcribe(
|
|
||||||
&self,
|
|
||||||
audio: AudioSamples,
|
|
||||||
options: &TranscriptionOptions,
|
|
||||||
) -> Result<Transcript>;
|
|
||||||
|
|
||||||
fn name(&self) -> &EngineName;
|
|
||||||
|
|
||||||
fn is_available(&self) -> bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Any text post-processor implements this trait.
|
|
||||||
#[async_trait]
|
|
||||||
pub trait TextProcessor: Send + Sync {
|
|
||||||
async fn process(&self, text: &str, instruction: &str) -> Result<String>;
|
|
||||||
|
|
||||||
fn name(&self) -> &EngineName;
|
|
||||||
|
|
||||||
fn is_available(&self) -> bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Holds the active provider instances. Constructed at startup,
|
|
||||||
/// rebuilt when user changes provider in settings.
|
|
||||||
// TODO: Wire into Tauri app state once multi-engine switching is implemented.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct ProviderRegistry {
|
|
||||||
pub stt: Arc<dyn SpeechToText>,
|
|
||||||
pub text: Option<Arc<dyn TextProcessor>>,
|
|
||||||
}
|
|
||||||
@@ -166,23 +166,6 @@ pub struct TranscriptionOptions {
|
|||||||
pub initial_prompt: Option<String>,
|
pub initial_prompt: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Full provenance metadata for a transcript.
|
|
||||||
/// Captures everything needed to reproduce the transcription.
|
|
||||||
// TODO: Attach to Transcript once the store layer persists transcription provenance.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct TranscriptMetadata {
|
|
||||||
pub engine: String,
|
|
||||||
pub model_id: ModelId,
|
|
||||||
pub inference_ms: u64,
|
|
||||||
pub sample_rate: u32,
|
|
||||||
pub audio_channels: u16,
|
|
||||||
pub format_mode: String,
|
|
||||||
pub remove_fillers: bool,
|
|
||||||
pub british_english: bool,
|
|
||||||
pub anti_hallucination: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Progress update during model download.
|
/// Progress update during model download.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct DownloadProgress {
|
pub struct DownloadProgress {
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ pub struct LiveResultMessage {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
#[serde(rename_all = "camelCase", tag = "type")]
|
#[serde(rename_all = "camelCase", tag = "type")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub enum LiveStatusMessage {
|
pub enum LiveStatusMessage {
|
||||||
Warning {
|
Warning {
|
||||||
session_id: u64,
|
session_id: u64,
|
||||||
|
|||||||
Reference in New Issue
Block a user