chore(gates): zero clippy warnings and a buildable sandbox example on Windows

The full-workspace gates had never run on this platform: collapsible
ifs in the Windows shell probe, a same-type cast in the crash handler,
an unused AsRawHandle import, and the sandbox smoke-test example
building its unix-only body (libc, kernel enforcement) unconditionally.
The example now stubs main off-unix; formatting reflow from cargo fmt.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSy9S31pZNWXtRZNVJ1sDf
This commit is contained in:
ZacharyZhang-NYandClaude Fable 5 committed 2026-08-27 11:55:19 -04:00
1 parent 25d1a4f980
commit 50669bf302
10 files changed
+31 -16

No files matched your search

+4 -6
View File
@@ -78,12 +78,11 @@ pub fn detect_windows_shell() -> &'static WindowsShell {
kigi_tty_utils::detach_std_command(&mut cmd); kigi_tty_utils::detach_std_command(&mut cmd);
cmd.arg("pwsh.exe").stdin(std::process::Stdio::null()); cmd.arg("pwsh.exe").stdin(std::process::Stdio::null());
cmd.output() cmd.output()
} { } && output.status.success()
if output.status.success() { {
tracing::info!("Windows shell: pwsh"); tracing::info!("Windows shell: pwsh");
return WindowsShell::Pwsh; return WindowsShell::Pwsh;
} }
}
// powershell.exe (Windows PowerShell 5.1). // powershell.exe (Windows PowerShell 5.1).
if std::path::Path::new("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe") if std::path::Path::new("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe")
@@ -131,8 +130,8 @@ fn find_git_bash() -> Option<String> {
kigi_tty_utils::detach_std_command(&mut cmd); kigi_tty_utils::detach_std_command(&mut cmd);
cmd.arg("bash.exe").stdin(std::process::Stdio::null()); cmd.arg("bash.exe").stdin(std::process::Stdio::null());
cmd.output() cmd.output()
} { } && output.status.success()
if output.status.success() { {
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
for line in stdout.lines() { for line in stdout.lines() {
let line = line.trim(); let line = line.trim();
@@ -141,7 +140,6 @@ fn find_git_bash() -> Option<String> {
} }
} }
} }
}
None None
} }
@@ -616,7 +616,7 @@ mod win {
} }
let signal = exception_to_signal(exception_code); let signal = exception_to_signal(exception_code);
let si_code = exception_code as i32; let si_code = exception_code;
// ExceptionInformation[1] holds the faulting address for ACCESS_VIOLATION. // ExceptionInformation[1] holds the faulting address for ACCESS_VIOLATION.
let si_addr = if exception_code == EXCEPTION_ACCESS_VIOLATION let si_addr = if exception_code == EXCEPTION_ACCESS_VIOLATION
@@ -388,7 +388,9 @@ mod tests {
#[test] #[test]
fn retryable_api_status_covers_edge_5xx_and_excludes_broken_tls() { fn retryable_api_status_covers_edge_5xx_and_excludes_broken_tls() {
for status in [429u16, 500, 502, 503, 504, 520, 521, 522, 523, 524, 529, 530, 599] { for status in [
429u16, 500, 502, 503, 504, 520, 521, 522, 523, 524, 529, 530, 599,
] {
assert!(is_retryable_api_status(status), "should retry {status}"); assert!(is_retryable_api_status(status), "should retry {status}");
} }
// Cloudflare 525/526: origin TLS handshake / invalid certificate — // Cloudflare 525/526: origin TLS handshake / invalid certificate —
@@ -14,9 +14,19 @@
//! cargo run -p kigi-sandbox --example sandbox_smoke_test -- read-only //! cargo run -p kigi-sandbox --example sandbox_smoke_test -- read-only
//! ``` //! ```
// Kernel enforcement is unix-only (Seatbelt / Landlock); Windows builds a
// stub so `--all-targets` stays green everywhere.
#[cfg(unix)]
use kigi_sandbox::{ProfileName, SandboxManager}; use kigi_sandbox::{ProfileName, SandboxManager};
#[cfg(unix)]
use std::path::Path; use std::path::Path;
#[cfg(not(unix))]
fn main() {
eprintln!("sandbox_smoke_test exercises kernel enforcement and only runs on Unix.");
}
#[cfg(unix)]
fn main() { fn main() {
let profile_name = std::env::args() let profile_name = std::env::args()
.nth(1) .nth(1)
@@ -121,6 +131,7 @@ fn main() {
println!("\n✅ Smoke test complete"); println!("\n✅ Smoke test complete");
} }
#[cfg(unix)]
fn test_read(label: &str, path: &Path) { fn test_read(label: &str, path: &Path) {
if path.is_file() { if path.is_file() {
match std::fs::read(path) { match std::fs::read(path) {
@@ -150,6 +161,7 @@ fn test_read(label: &str, path: &Path) {
} }
} }
#[cfg(unix)]
fn test_write(label: &str, path: &Path) { fn test_write(label: &str, path: &Path) {
match std::fs::write(path, b"sandbox-test") { match std::fs::write(path, b"sandbox-test") {
Ok(()) => { Ok(()) => {
@@ -1984,7 +1984,8 @@ fn spawn_prefetch_thread(env: PrefetchEnv) -> Option<EarlyPrefetchHandle> {
env.model_fetch_auth, env.model_fetch_auth,
&env.platform_keys, &env.platform_keys,
); );
if (env.endpoints.deployment_key.is_some() || crate::managed_config::has_active_team_auth()) if (env.endpoints.deployment_key.is_some()
|| crate::managed_config::has_active_team_auth())
&& crate::config::is_managed_config_stale_for( && crate::config::is_managed_config_stale_for(
&crate::managed_config::current_serving_identity(), &crate::managed_config::current_serving_identity(),
) )
@@ -900,8 +900,7 @@ mod write_fallback_tests {
fn atomic_write_reclaims_tmp_when_store_write_fails() { fn atomic_write_reclaims_tmp_when_store_write_fails() {
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("auth.json"); let path = dir.path().join("auth.json");
let err = let err = write_auth_json_atomic_with(&path, &sample_store(), fake_partial_write_then_fail)
write_auth_json_atomic_with(&path, &sample_store(), fake_partial_write_then_fail)
.unwrap_err(); .unwrap_err();
assert_eq!(err.kind(), std::io::ErrorKind::StorageFull); assert_eq!(err.kind(), std::io::ErrorKind::StorageFull);
@@ -33,8 +33,7 @@ pub(crate) fn ctx_with_toggle(toggle: HashMap<String, bool>) -> SubagentSpawnCon
let (tx, _rx) = mpsc::unbounded_channel(); let (tx, _rx) = mpsc::unbounded_channel();
SubagentSpawnContext { SubagentSpawnContext {
lsp: None, lsp: None,
spawn_limits: spawn_limits: kigi_tools::implementations::kigi::task::admission::SubagentLimits::default(),
kigi_tools::implementations::kigi::task::admission::SubagentLimits::default(),
spawn_permits: std::sync::Arc::new(tokio::sync::Semaphore::new( spawn_permits: std::sync::Arc::new(tokio::sync::Semaphore::new(
kigi_tools::implementations::kigi::task::admission::SubagentLimits::default() kigi_tools::implementations::kigi::task::admission::SubagentLimits::default()
.effective_max_concurrent(), .effective_max_concurrent(),
@@ -187,7 +187,10 @@ mod compaction_tool_choice_tests {
resolve(Some("bogus"), None, Some("none")), resolve(Some("bogus"), None, Some("none")),
CompactionToolChoice::None CompactionToolChoice::None
); );
assert_eq!(resolve(Some("NONE "), None, None), CompactionToolChoice::None); assert_eq!(
resolve(Some("NONE "), None, None),
CompactionToolChoice::None
);
} }
} }
+2 -1
View File
@@ -15,7 +15,8 @@ pub use kigi_tty_utils::{
pub async fn reap_killed_search_child( pub async fn reap_killed_search_child(
child: &mut tokio::process::Child, child: &mut tokio::process::Child,
) -> Option<std::process::ExitStatus> { ) -> Option<std::process::ExitStatus> {
let status = kigi_tty_utils::reap_killed_bounded(child, kigi_tty_utils::KILL_REAP_TIMEOUT).await; let status =
kigi_tty_utils::reap_killed_bounded(child, kigi_tty_utils::KILL_REAP_TIMEOUT).await;
if status.is_none() { if status.is_none() {
tracing::warn!( tracing::warn!(
reap_timeout_secs = kigi_tty_utils::KILL_REAP_TIMEOUT.as_secs(), reap_timeout_secs = kigi_tty_utils::KILL_REAP_TIMEOUT.as_secs(),
+1 -1
View File
@@ -567,7 +567,7 @@ pub fn dup_tui_stderr() -> io::Result<std::fs::File> {
// `DuplicateHandle` — avoiding the `from_raw_handle` footgun // `DuplicateHandle` — avoiding the `from_raw_handle` footgun
// where `File` would take ownership of the process stderr handle // where `File` would take ownership of the process stderr handle
// and close it on drop. // and close it on drop.
use std::os::windows::io::{AsRawHandle, FromRawHandle}; use std::os::windows::io::FromRawHandle;
let stderr_handle = unsafe { let stderr_handle = unsafe {
windows::Win32::System::Console::GetStdHandle( windows::Win32::System::Console::GetStdHandle(
windows::Win32::System::Console::STD_ERROR_HANDLE, windows::Win32::System::Console::STD_ERROR_HANDLE,