From 54dabd491d6217ffcbd2cfd1a330402c83573903 Mon Sep 17 00:00:00 2001 From: chaodu-agent Date: Thu, 25 Jun 2026 20:05:24 -0400 Subject: [PATCH] fix(ctl): cfg-gate Unix-socket IPC for non-Unix targets The openab set/get control socket uses tokio::net::UnixListener/UnixStream unconditionally, which fails to compile on Windows (E0432) and breaks the Build Binaries release workflow for the windows-msvc targets. Gate the Unix-socket imports and the socket I/O fns (spawn_server_at, handle_conn, send_request_to) with #[cfg(unix)], and provide #[cfg(not(unix))] stubs so main.rs's run/set/get paths compile unchanged: - spawn_server_at: no-op task (logs a warning) - send_request_to: returns an error (IPC is Unix-only) The cross-platform protocol types, registry, and RuntimeHandler are unchanged. Gate the unix-socket roundtrip test; the serialization test stays portable. --- src/ctl.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/ctl.rs b/src/ctl.rs index 32b611370..4eb467dde 100644 --- a/src/ctl.rs +++ b/src/ctl.rs @@ -11,7 +11,9 @@ use openab_core::adapter::{ChannelRef, ChatAdapter}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; use std::sync::Arc; +#[cfg(unix)] use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; +#[cfg(unix)] use tokio::net::{UnixListener, UnixStream}; use tracing::{debug, error, info, warn}; @@ -68,6 +70,7 @@ pub fn spawn_server( } /// Start the control socket server at a specific path. +#[cfg(unix)] pub fn spawn_server_at( path: PathBuf, handler: std::sync::Arc, @@ -108,6 +111,20 @@ pub fn spawn_server_at( }) } +/// Control socket IPC is Unix-only. On other platforms (e.g. Windows) the +/// `openab set`/`get` commands and the in-process control server are not +/// available; this returns a no-op task so the run path compiles unchanged. +#[cfg(not(unix))] +pub fn spawn_server_at( + path: PathBuf, + handler: std::sync::Arc, +) -> tokio::task::JoinHandle<()> { + let _ = (path, handler); + warn!("control socket (openab set/get) is only supported on Unix; skipping"); + tokio::spawn(async {}) +} + +#[cfg(unix)] async fn handle_conn( stream: UnixStream, handler: &dyn CtlHandler, @@ -312,6 +329,7 @@ pub async fn send_request(req: &Request) -> anyhow::Result { } /// Send a request to a specific socket path. +#[cfg(unix)] pub async fn send_request_to(path: &PathBuf, req: &Request) -> anyhow::Result { let stream = UnixStream::connect(&path).await.map_err(|e| { anyhow::anyhow!( @@ -335,6 +353,12 @@ pub async fn send_request_to(path: &PathBuf, req: &Request) -> anyhow::Result anyhow::Result { + anyhow::bail!("`openab set`/`get` IPC is only supported on Unix platforms") +} + #[cfg(test)] mod tests { use super::*; @@ -355,6 +379,7 @@ mod tests { assert_eq!(parsed.thread_id.as_deref(), Some("123")); } + #[cfg(unix)] #[tokio::test] async fn server_client_roundtrip() { struct MockHandler;