Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(windows): make clippy -D warnings pass on a Windows host\n\n`cargo clippy -p openhuman -- -D warnings` is what .husky/pre-push runs,\nand on Windows it fails with 11 errors before it reaches anything the\ndeveloper changed. Linux CI never sees them: every one is in a code path\nguarded by #[cfg(windows)] or #[cfg(not(unix))], so the lint only fires\nwhere those arms are compiled. The practical effect is that no commit can\nbe pushed from a Windows checkout.\n\nImports that only one platform uses are now gated the way the imports\nbeside them already were:\n\n- core/auth.rs, security/pairing.rs: `std::io::Write` is used solely by\n the #[cfg(unix)] arm of the token writer; the #[cfg(not(unix))] arm\n calls std::fs::write. Gated with #[cfg(unix)], matching the\n OpenOptionsExt import directly below it.\n- composio/trigger_history.rs: `fs2::FileExt` backs the\n #[cfg(not(windows))] lock/unlock path only - Windows serializes through\n the process-local Mutex above it.\n\nTwo imports were redundant rather than platform-specific:\n\n- inference/local/process_util.rs, inference/voice/local_speech.rs:\n `creation_flags` is an inherent method on tokio::process::Command under\n Windows, so importing std's CommandExt adds nothing.\n\nThe rest are ordinary lints in Windows-only code:\n\n- sandbox/cwd_jail/windows.rs: drop the unused HANDLE import, drop `mut`\n from `dacl_present` (only ever read), pass `&ea` to SetEntriesInAclW\n which takes *const, and add the Default impl clippy asks for next to\n AppContainerBackend::new().\n- security/keyring/encrypted_store.rs: the #[cfg(windows)] arm shadows\n `msg` rather than mutating it, so `mut` was unnecessary on both\n platforms and the #[cfg_attr(not(windows), allow(unused_mut))] escape\n hatch can go with it.\n- platform/doctor/core.rs: on Windows the sibling #[cfg] block is stripped,\n so the remaining block is the function tail and the `return` is noise.\n\nNo behaviour changes. cargo fmt clean, and clippy -D warnings now passes\non Windows.\n

Nguyen Thanh Datab8cbb370d44
diff --git a/app/src-tauri/src/claude_code.rs b/app/src-tauri/src/claude_code.rs
index 7ff7a98ed3..a61e957de8 100644
--- a/app/src-tauri/src/claude_code.rs
+++ b/app/src-tauri/src/claude_code.rs
@@ -30,7 +30,7 @@ pub fn claude_code_login_launch() -> Result<String, String> {
.args(["/c", "start", "", "cmd", "/k", "claude login"])
.spawn()
.map_err(|e| format!("failed to open cmd: {e}"))?;
- return Ok("cmd".into());
+ Ok("cmd".into())
}
#[cfg(target_os = "macos")]
diff --git a/app/src-tauri/src/core_process.rs b/app/src-tauri/src/core_process.rs
index 76638f1d3a..23c1c954f7 100644
--- a/app/src-tauri/src/core_process.rs
+++ b/app/src-tauri/src/core_process.rs
@@ -1001,6 +1001,7 @@ fn find_pid_on_port(port: u16) -> Option<u32> {
}
/// Pure parse of `lsof -t` output (one pid per line; first wins).
+#[cfg(unix)]
fn parse_lsof_pid(stdout: &str) -> Option<u32> {
stdout
.lines()
diff --git a/app/src-tauri/src/core_process_tests.rs b/app/src-tauri/src/core_process_tests.rs
index a505788ad0..499b77bd1e 100644
--- a/app/src-tauri/src/core_process_tests.rs
+++ b/app/src-tauri/src/core_process_tests.rs
@@ -1,8 +1,11 @@
use super::{
current_rpc_token, default_core_port, generate_rpc_token, is_expected_port_clash,
- is_openhuman_root_body, parse_lsof_pid, parse_netstat_pid, parse_ps_comm, parse_tasklist_name,
+ is_openhuman_root_body, parse_netstat_pid, parse_ps_comm, parse_tasklist_name,
validate_kill_target, CoreProcessHandle, PortOwner, RecoveryOutcome,
};
+// lsof is a unix tool, so its parser is only compiled there.
+#[cfg(unix)]
+use super::parse_lsof_pid;
use std::sync::{Mutex, MutexGuard, OnceLock};
fn env_lock() -> MutexGuard<'static, ()> {
@@ -307,6 +310,7 @@ fn expected_port_clash_classifier_rejects_unknown_probe_shapes() {
));
}
+#[cfg(unix)]
#[test]
fn parse_lsof_pid_picks_first_pid() {
assert_eq!(parse_lsof_pid("12345\n"), Some(12345));
diff --git a/app/src-tauri/src/deep_link_ipc_windows.rs b/app/src-tauri/src/deep_link_ipc_windows.rs
index 0f6676dee3..8880d82b0b 100644
--- a/app/src-tauri/src/deep_link_ipc_windows.rs
+++ b/app/src-tauri/src/deep_link_ipc_windows.rs
@@ -95,14 +95,17 @@ pub(crate) fn try_forward_deep_links() -> ForwardResult {
ForwardResult::NoPrimary
}
+/// Callback the app installs to receive deep-link URLs as they arrive.
+type LiveHandler = Box<dyn Fn(String) + Send + Sync>;
+
static PENDING_URLS: OnceLock<Arc<Mutex<Vec<String>>>> = OnceLock::new();
-static LIVE_HANDLER: OnceLock<Mutex<Option<Box<dyn Fn(String) + Send + Sync>>>> = OnceLock::new();
+static LIVE_HANDLER: OnceLock<Mutex<Option<LiveHandler>>> = OnceLock::new();
fn pending_queue() -> &'static Arc<Mutex<Vec<String>>> {
PENDING_URLS.get_or_init(|| Arc::new(Mutex::new(Vec::new())))
}
-fn live_handler() -> &'static Mutex<Option<Box<dyn Fn(String) + Send + Sync>>> {
+fn live_handler() -> &'static Mutex<Option<LiveHandler>> {
LIVE_HANDLER.get_or_init(|| Mutex::new(None))
}
diff --git a/src/core/auth.rs b/src/core/auth.rs
index 2eff5a1740..1cdee39105 100644
--- a/src/core/auth.rs
+++ b/src/core/auth.rs
@@ -55,10 +55,11 @@
//! internal bearer or a stable user-managed external API key stored under
//! `openhuman::inference::http::EXTERNAL_OPENAI_COMPAT_PROVIDER`.
-use std::io::Write as _;
use std::path::Path;
use std::sync::OnceLock;
+#[cfg(unix)]
+use std::io::Write as _;
#[cfg(unix)]
use std::os::unix::fs::OpenOptionsExt as _;
diff --git a/src/openhuman/inference/local/process_util.rs b/src/openhuman/inference/local/process_util.rs
index aa29cec265..7412728514 100644
--- a/src/openhuman/inference/local/process_util.rs
+++ b/src/openhuman/inference/local/process_util.rs
@@ -17,7 +17,6 @@ const CREATE_NO_WINDOW: u32 = 0x0800_0000;
#[cfg(windows)]
pub(crate) fn apply_no_window(cmd: &mut tokio::process::Command) {
- use std::os::windows::process::CommandExt;
cmd.creation_flags(CREATE_NO_WINDOW);
}
diff --git a/src/openhuman/inference/voice/local_speech.rs b/src/openhuman/inference/voice/local_speech.rs
index 81aed01087..485377de51 100644
--- a/src/openhuman/inference/voice/local_speech.rs
+++ b/src/openhuman/inference/voice/local_speech.rs
@@ -166,7 +166,6 @@ pub async fn synthesize_piper(
// every TTS request (piper.exe is a console subsystem binary).
#[cfg(windows)]
{
- use std::os::windows::process::CommandExt;
cmd.creation_flags(0x08000000);
}
let mut child = cmd
diff --git a/src/openhuman/integrations/composio/trigger_history.rs b/src/openhuman/integrations/composio/trigger_history.rs
index 43ac6bc37f..48b05ebb51 100644
--- a/src/openhuman/integrations/composio/trigger_history.rs
+++ b/src/openhuman/integrations/composio/trigger_history.rs
@@ -11,6 +11,7 @@ use std::sync::Mutex;
use std::sync::{Arc, OnceLock};
use chrono::Utc;
+#[cfg(not(windows))]
use fs2::FileExt;
use super::types::{ComposioTriggerHistoryEntry, ComposioTriggerHistoryResult};
diff --git a/src/openhuman/platform/doctor/core_part_01.rs b/src/openhuman/platform/doctor/core_part_01.rs
index 12d2c119be..0c6eb26a09 100644
--- a/src/openhuman/platform/doctor/core_part_01.rs
+++ b/src/openhuman/platform/doctor/core_part_01.rs
@@ -495,7 +495,7 @@ fn check_workspace(config: &Config, items: &mut Vec<DiagnosticItem>) {
fn available_disk_space_mb(path: &Path) -> Option<u64> {
#[cfg(target_os = "windows")]
{
- return available_disk_space_mb_windows(path);
+ available_disk_space_mb_windows(path)
}
#[cfg(not(target_os = "windows"))]
diff --git a/src/openhuman/sandbox/cwd_jail/windows.rs b/src/openhuman/sandbox/cwd_jail/windows.rs
index c07e0ecf2d..bc99a255a2 100644
--- a/src/openhuman/sandbox/cwd_jail/windows.rs
+++ b/src/openhuman/sandbox/cwd_jail/windows.rs
@@ -38,7 +38,7 @@ use std::process::{Child, Command};
use std::ptr;
use windows_sys::core::PWSTR;
-use windows_sys::Win32::Foundation::{CloseHandle, LocalFree, HANDLE, HLOCAL};
+use windows_sys::Win32::Foundation::{CloseHandle, LocalFree, HLOCAL};
use windows_sys::Win32::Security::Authorization::{
GetNamedSecurityInfoW, SetEntriesInAclW, SetNamedSecurityInfoW, EXPLICIT_ACCESS_W, SET_ACCESS,
SE_FILE_OBJECT, TRUSTEE_IS_GROUP, TRUSTEE_IS_SID, TRUSTEE_W,
@@ -107,6 +107,12 @@ impl AppContainerBackend {
}
}
+impl Default for AppContainerBackend {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl JailBackend for AppContainerBackend {
fn name(&self) -> &'static str {
"appcontainer"
@@ -305,7 +311,7 @@ unsafe fn grant_sid_access(path: &Path, sid: PSID, access: u32) -> io::Result<()
// locking out the owner / SYSTEM / Administrators. Merge instead.
let mut sd_ptr: *mut std::ffi::c_void = ptr::null_mut();
let mut existing_dacl: *mut ACL = ptr::null_mut();
- let mut dacl_present: i32 = 0;
+ let dacl_present: i32 = 0;
let rc = GetNamedSecurityInfoW(
path_w.as_ptr(),
SE_FILE_OBJECT,
@@ -335,7 +341,7 @@ unsafe fn grant_sid_access(path: &Path, sid: PSID, access: u32) -> io::Result<()
};
let mut new_acl: *mut ACL = ptr::null_mut();
- let rc = SetEntriesInAclW(1, &mut ea, existing_dacl, &mut new_acl);
+ let rc = SetEntriesInAclW(1, &ea, existing_dacl, &mut new_acl);
if rc != 0 {
return Err(io::Error::from_raw_os_error(rc as i32));
}
diff --git a/src/openhuman/security/keyring/encrypted_store.rs b/src/openhuman/security/keyring/encrypted_store.rs
index c13a1cf883..0b62a8c228 100644
--- a/src/openhuman/security/keyring/encrypted_store.rs
+++ b/src/openhuman/security/keyring/encrypted_store.rs
@@ -297,9 +297,9 @@ impl SecretStore {
};
let hex_key = read_result.with_context(|| {
- // `mut` is only exercised inside the #[cfg(windows)] block below.
- #[cfg_attr(not(windows), allow(unused_mut))]
- let mut msg = format!(
+ // The #[cfg(windows)] arm below shadows this binding rather than
+ // mutating it, so it does not need to be mutable on either platform.
+ let msg = format!(
"Failed to read secret key file at {}",
self.key_path.display()
);
diff --git a/src/openhuman/security/pairing.rs b/src/openhuman/security/pairing.rs
index 2b69bfba78..37e5b6fee7 100644
--- a/src/openhuman/security/pairing.rs
+++ b/src/openhuman/security/pairing.rs
@@ -4,9 +4,10 @@
// a bearer token. Tokens can be persisted in config so restarts don't require
// re-pairing.
-use std::io::Write as _;
use std::path::Path;
+#[cfg(unix)]
+use std::io::Write as _;
#[cfg(unix)]
use std::os::unix::fs::OpenOptionsExt as _;