Skip to content

fix(ctl): cfg-gate Unix-socket IPC for Windows build#1204

Open
chaodu-agent wants to merge 1 commit into
mainfrom
fix/ctl-windows-cfg-gate
Open

fix(ctl): cfg-gate Unix-socket IPC for Windows build#1204
chaodu-agent wants to merge 1 commit into
mainfrom
fix/ctl-windows-cfg-gate

Conversation

@chaodu-agent

Copy link
Copy Markdown
Collaborator

Summary

Fixes the long-standing Build Binaries failure on the windows-msvc targets (present since at least v0.9.0-beta.2). src/ctl.rs imported and used tokio::net::UnixListener/UnixStream unconditionally, so the openab binary failed to compile on Windows:

error[E0432]: unresolved imports `tokio::net::UnixListener`, `tokio::net::UnixStream`
error: could not compile `openab` (bin "openab") due to 1 previous error

Fix

Per the cross-platform rule in AGENTS.md, gate the Unix-only code with #[cfg(unix)] and provide #[cfg(not(unix))] stubs so main.rs's run/set/get paths compile unchanged:

  • Unix-socket imports (UnixListener/UnixStream, tokio io traits) → #[cfg(unix)]
  • spawn_server_at → unix impl + non-unix no-op task (logs a warning)
  • send_request_to → unix impl + non-unix error (openab set/get is Unix-only)
  • handle_conn#[cfg(unix)]
  • unix-socket roundtrip test → #[cfg(unix)]; the serialization test stays portable

The control socket (openab set/get) was already Unix-only in practice; this just makes the Windows build skip it cleanly instead of failing to compile.

Verification

  • cargo check on host (unix): clean
  • Windows MSVC build verified by dispatching the Build Binaries workflow against this branch (build-only; the release-upload step is gated to push events)

The Linux CI (ci.yml, runs clippy -- -D warnings) stays clean because the gates are no-ops on unix.

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.
@chaodu-agent

This comment has been minimized.

1 similar comment
@chaodu-agent

This comment has been minimized.

@chaodu-agent

This comment has been minimized.

@chaodu-agent

Copy link
Copy Markdown
Collaborator Author

LGTM ✅ — Clean cross-platform cfg-gating with consistent API contract.

What This PR Does

The ctl module uses Unix Domain Sockets for IPC (openab set/get), which prevents compilation on Windows. This PR gates the Unix-specific code behind #[cfg(unix)] and provides platform-appropriate stubs for non-Unix targets.

How It Works

  • spawn_server_at and send_request_to get #[cfg(unix)] gates on the real implementations
  • #[cfg(not(unix))] stubs maintain identical function signatures — callers need no platform-conditional logic
  • The non-Unix spawn_server_at returns a no-op task with a warning log; send_request_to returns a descriptive bail!
  • Unix-only imports (UnixListener, UnixStream, AsyncBufReadExt, etc.) are also gated
  • The integration test server_client_roundtrip is gated to Unix-only

Findings

# Severity Finding Location
1 🟢 API contract consistency — non-Unix stubs match Unix signatures exactly, callers remain platform-agnostic ctl.rs:113-125
2 🟢 Graceful degradation — clear error messages for unsupported platforms ctl.rs:356-358
3 🟢 No regression risk to Unix — original logic completely untouched
4 🟢 Correct test gating — roundtrip test only runs on Unix, serialization test stays portable ctl.rs:382
5 🟢 Idiomatic Rust cfg patterns — minimal stubs, no dead code on either platform
Finding Details

🟢 F1: API Contract Consistency

Callers (spawn_server, send_request) don't need any cfg-gating themselves because the stubs have identical signatures. This is the correct boundary to place the platform split.

🟢 F2: Graceful Degradation

The bail! message on non-Unix send_request_to clearly tells the user why the command is unavailable. The warn! in spawn_server_at logs the skip without panicking.

🟢 F3: Zero Regression Risk

All existing Unix logic is untouched — the cfg gates only add visibility annotations and alternative implementations for non-Unix.

🟢 F4: Test Gating

server_client_roundtrip (which uses Unix sockets directly) is correctly gated. The parse_request serialization test remains ungated and portable.

🟢 F5: Idiomatic Patterns

Uses let _ = (path, handler) to suppress unused-variable warnings in the stub — clean and zero-cost.

Baseline Check
  • PR opened: 2026-06-26
  • Main already has: Full Unix-socket IPC implementation (fails to compile on Windows MSVC)
  • Net-new value: Cross-platform compilability via cfg-gates with graceful stubs
  • CI: All checks pass (smoke tests, clippy, build-builder)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant