agent: lumotia — pin rust toolchain + workspace clippy/fmt sweep

rust-toolchain.toml pins to stable 1.94.1 so contributors and CI runners
share the exact rustc / rustfmt / clippy versions. Without the pin, every
machine surfaces a different lint set depending on its local install — six
pre-existing lints showed up on 1.94.1 that 1.93-era HANDOVER reported clean.

Clippy fixes (all pre-existing, not introduced by feature work):

- crates/storage/src/database.rs: std::iter::repeat().take() -> repeat_n()
- crates/llm/src/lib.rs (docs): "+ frontends" was parsed as a markdown bullet
  continuation by rustdoc, breaking doc-lazy-continuation. Reworded to "and".
- crates/llm/src/lib.rs (loop): while-let-on-iterator -> for-loop.
- src-tauri/src/commands/security.rs: .iter().any(|a| *a == x) -> .contains(&x).
- src-tauri/src/lib.rs: io::Error::new(Other, e) -> io::Error::other(e).
- src-tauri/src/tauri_app_data_migration.rs: drop function-tail `return`s
  inside cfg blocks; each platform's block now ends with a tail expression.

cargo fmt sweep across the workspace. Mechanical layout-only changes;
no semantics affected.

Workspace gates after this commit:
- cargo fmt --check: clean
- cargo clippy --workspace --all-targets -- -D warnings: clean
- cargo test --workspace: 405/0 (will become 409/0 with Phase A.1+A.2)
This commit is contained in:
2026-05-14 07:19:59 +01:00
parent e4d56b831f
commit 27661c816e
24 changed files with 184 additions and 210 deletions

View File

@@ -16,8 +16,7 @@ pub(crate) const MAX_CLIPBOARD_BYTES: usize = 1024 * 1024;
/// buttons; mirror the secondary-windows capability grant in
/// `src-tauri/capabilities/secondary-windows.json` so the IPC trust
/// boundary and the permission set stay in lock-step.
const CLIPBOARD_ALLOWED_WINDOWS: &[&str] =
&["main", "transcript-viewer", "transcription-preview"];
const CLIPBOARD_ALLOWED_WINDOWS: &[&str] = &["main", "transcript-viewer", "transcription-preview"];
/// Copy text to the system clipboard via arboard. Restricted to the
/// documented "clipboard-capable" windows (main + transcript-viewer +

View File

@@ -88,9 +88,12 @@ pub(crate) fn resolve_export_path(path: &Path, bases: &[PathBuf]) -> Result<Path
path.display()
)
})?;
let file_name = path
.file_name()
.ok_or_else(|| format!("Refusing to write {}: path has no filename.", path.display()))?;
let file_name = path.file_name().ok_or_else(|| {
format!(
"Refusing to write {}: path has no filename.",
path.display()
)
})?;
let canon_parent = std::fs::canonicalize(parent).map_err(|e| {
format!(

View File

@@ -427,9 +427,7 @@ impl LiveSessionRuntime {
// the dimensions are real. Validation-window drops can fire
// before any chunk reaches `process_audio_chunk`; they get
// attributed at the next reconciliation once we know the rate.
if self.state.last_chunk_sample_rate == 0
|| self.state.last_chunk_samples_per_chan == 0
{
if self.state.last_chunk_sample_rate == 0 || self.state.last_chunk_samples_per_chan == 0 {
// Roll back the consumed delta so we re-observe it once
// we have dimensions to convert it with.
self.state.last_dropped_chunks = self.state.last_dropped_chunks.saturating_sub(delta);
@@ -1111,11 +1109,8 @@ fn maybe_dispatch_chunk(
let parent_span = tracing::Span::current();
thread::spawn(move || {
let _parent = parent_span.enter();
let inference_span = tracing::info_span!(
"inference",
chunk_id = current_chunk_id,
duration_secs,
);
let inference_span =
tracing::info_span!("inference", chunk_id = current_chunk_id, duration_secs,);
let _enter = inference_span.enter();
let audio = AudioSamples::mono_16khz(chunk_samples);
let started = Instant::now();

View File

@@ -21,15 +21,12 @@ pub fn ensure_main_window_label(label: &str) -> Result<(), String> {
/// `&[&'static str]` and should mirror an entry in
/// `src-tauri/capabilities/*.json` — keeping the IPC trust boundary and the
/// permission grant in lock-step.
pub fn ensure_window_in_set(
window: &tauri::WebviewWindow,
allowed: &[&str],
) -> Result<(), String> {
pub fn ensure_window_in_set(window: &tauri::WebviewWindow, allowed: &[&str]) -> Result<(), String> {
ensure_window_in_set_label(window.label(), allowed)
}
pub fn ensure_window_in_set_label(label: &str, allowed: &[&str]) -> Result<(), String> {
if allowed.iter().any(|a| *a == label) {
if allowed.contains(&label) {
Ok(())
} else {
Err(format!(

View File

@@ -50,10 +50,7 @@ const MAX_TRANSCRIBE_BYTES: u64 = 1024 * 1024 * 1024;
/// rejects most obvious attacks), then size (one stat call), then
/// path canonicalisation (slowest, only meaningful once the cheaper
/// gates pass).
pub(crate) fn validate_transcribe_input(
path: &Path,
metadata_len: u64,
) -> Result<(), String> {
pub(crate) fn validate_transcribe_input(path: &Path, metadata_len: u64) -> Result<(), String> {
let ext = path
.extension()
.and_then(|s| s.to_str())
@@ -67,7 +64,10 @@ pub(crate) fn validate_transcribe_input(
)
})?;
if !ALLOWED_AUDIO_EXTENSIONS.iter().any(|allowed| *allowed == ext) {
if !ALLOWED_AUDIO_EXTENSIONS
.iter()
.any(|allowed| *allowed == ext)
{
return Err(format!(
"Refusing to transcribe {}: extension '.{}' is not in the \
allowlist. Supported: {}.",
@@ -237,8 +237,7 @@ pub async fn transcribe_file(
// Trust-5: extension + size gate before we hand the path to the
// audio decoder. `std::fs::metadata` resolves symlinks so the size
// check sees the actual blob, not a symlink-target lie.
let metadata = std::fs::metadata(&path)
.map_err(|e| format!("Cannot stat {path}: {e}"))?;
let metadata = std::fs::metadata(&path).map_err(|e| format!("Cannot stat {path}: {e}"))?;
validate_transcribe_input(Path::new(&path), metadata.len())?;
let resolved_profile_id =
@@ -347,7 +346,9 @@ mod tests_trust5 {
#[test]
fn accepts_each_allowed_extension() {
for ext in ["wav", "mp3", "m4a", "mp4", "flac", "ogg", "opus", "webm", "aac"] {
for ext in [
"wav", "mp3", "m4a", "mp4", "flac", "ogg", "opus", "webm", "aac",
] {
let path_string = format!("/tmp/clip.{ext}");
let path = Path::new(&path_string);
assert!(
@@ -376,10 +377,8 @@ mod tests_trust5 {
#[test]
fn rejects_oversize_file() {
let result = validate_transcribe_input(
Path::new("/tmp/huge.wav"),
MAX_TRANSCRIBE_BYTES + 1,
);
let result =
validate_transcribe_input(Path::new("/tmp/huge.wav"), MAX_TRANSCRIBE_BYTES + 1);
let err = result.expect_err("must reject oversize file");
assert!(err.contains("1 GiB"), "unexpected error: {err}");
}

View File

@@ -17,9 +17,9 @@ use lumotia_storage::{
delete_transcript as db_delete_transcript, get_transcript as db_get_transcript,
insert_transcript as db_insert_transcript, list_transcripts_paged,
list_trashed_transcripts as db_list_trashed_transcripts,
restore_transcript as db_restore_transcript,
search_transcripts as db_search_transcripts, update_transcript as db_update_transcript,
update_transcript_meta as db_update_transcript_meta, InsertTranscriptParams, TranscriptRow,
restore_transcript as db_restore_transcript, search_transcripts as db_search_transcripts,
update_transcript as db_update_transcript, update_transcript_meta as db_update_transcript_meta,
InsertTranscriptParams, TranscriptRow,
};
use crate::AppState;