From 38a4c3f516f7ef0a9483ee35ea565017ab1ef306 Mon Sep 17 00:00:00 2001 From: kevin9327 Date: Mon, 31 Aug 2026 19:59:28 +0900 Subject: [PATCH] chore: restore a green `make check` on main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `make check` currently fails on main before any change is made: one `cargo fmt --all -- --check` diff and four `cargo clippy --workspace --all-targets -- -D warnings` errors. All five are pre-existing and none of them change behaviour. - `server/tests/knowledge_rules.rs:125` — rustfmt wants the long `assert!` split across lines. Applied `cargo fmt --all` verbatim. - `server/src/plugin/data.rs:206,215` — `path` is only read under `#[cfg(unix)]`, so every other target sees an unused binding. Added a `#[cfg(not(unix))] { let _ = path; }` arm, matching the `let _ = error;` idiom already used at line 189 of the same file. Windows behaviour is unchanged: these helpers stay no-ops there. - `server/src/provider/openai_responses.rs:158` — `collapsible_match`. Applied clippy's own suggestion (move `thinking_open` into a match guard). The match ends in `_ => {}`, so a failed guard falls through to a no-op exactly as the inner `if` did. - `server/src/store/models.rs:327` — `items_after_test_module`. Moved `optional_u64` and `to_i64` above `mod tests`; the bodies are untouched. Co-Authored-By: Claude Opus 4.8 --- server/src/plugin/data.rs | 8 ++++++++ server/src/provider/openai_responses.rs | 5 ++--- server/src/store/models.rs | 24 ++++++++++++------------ server/tests/knowledge_rules.rs | 5 ++++- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/server/src/plugin/data.rs b/server/src/plugin/data.rs index f9205b1..2e0d1c1 100644 --- a/server/src/plugin/data.rs +++ b/server/src/plugin/data.rs @@ -209,6 +209,10 @@ fn set_directory_permissions(path: &Path) -> Result<()> { use std::os::unix::fs::PermissionsExt; std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o700))?; } + #[cfg(not(unix))] + { + let _ = path; + } Ok(()) } @@ -218,6 +222,10 @@ fn set_file_permissions(path: &Path) -> Result<()> { use std::os::unix::fs::PermissionsExt; std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600))?; } + #[cfg(not(unix))] + { + let _ = path; + } Ok(()) } diff --git a/server/src/provider/openai_responses.rs b/server/src/provider/openai_responses.rs index 993f936..304267f 100644 --- a/server/src/provider/openai_responses.rs +++ b/server/src/provider/openai_responses.rs @@ -154,9 +154,8 @@ impl Provider for OpenAiResponsesProvider { if !thinking_open { thinking_open = true; yield ModelEvent::ThinkingStart; } if let Some(delta) = value.get("delta").and_then(Value::as_str) { yield ModelEvent::ThinkingDelta(delta.into()); } } - "response.reasoning_summary_text.done" | "response.reasoning_text.done" => { - if thinking_open { thinking_open = false; yield ModelEvent::ThinkingEnd; } - } + "response.reasoning_summary_text.done" | "response.reasoning_text.done" + if thinking_open => { thinking_open = false; yield ModelEvent::ThinkingEnd; } "response.output_item.added" => { let item = value.get("item").unwrap_or(&Value::Null); if item.get("type").and_then(Value::as_str) == Some("function_call") { diff --git a/server/src/store/models.rs b/server/src/store/models.rs index 0e6eeef..6d29d3c 100644 --- a/server/src/store/models.rs +++ b/server/src/store/models.rs @@ -323,6 +323,18 @@ fn model_from_row(row: sqlx::sqlite::SqliteRow) -> Result { }) } +fn optional_u64(row: &sqlx::sqlite::SqliteRow, column: &str) -> Result> { + row.try_get::, _>(column)? + .map(|value| { + u64::try_from(value).map_err(|_| Error::Config(format!("{column} cannot be negative"))) + }) + .transpose() +} + +fn to_i64(value: u64) -> Result { + i64::try_from(value).map_err(|_| Error::Config("token value is too large".into())) +} + #[cfg(test)] mod tests { use super::*; @@ -387,15 +399,3 @@ mod tests { assert_eq!(cleared.group_name, None); } } - -fn optional_u64(row: &sqlx::sqlite::SqliteRow, column: &str) -> Result> { - row.try_get::, _>(column)? - .map(|value| { - u64::try_from(value).map_err(|_| Error::Config(format!("{column} cannot be negative"))) - }) - .transpose() -} - -fn to_i64(value: u64) -> Result { - i64::try_from(value).map_err(|_| Error::Config("token value is too large".into())) -} diff --git a/server/tests/knowledge_rules.rs b/server/tests/knowledge_rules.rs index 1dc4bc5..14505d1 100644 --- a/server/tests/knowledge_rules.rs +++ b/server/tests/knowledge_rules.rs @@ -125,7 +125,10 @@ async fn offline_crud_round_trip_persists_markdown() { .unwrap(); let added: AddResponse = decode(response).await; assert!(added.success); - assert!(added.id.starts_with("local-"), "offline add uses a local id"); + assert!( + added.id.starts_with("local-"), + "offline add uses a local id" + ); let markdown = rules_root.join(format!("{}.md", added.id)); assert_eq!( std::fs::read_to_string(&markdown).unwrap(),