Skip to content

Add Windows support for IPC with TCP and port file discovery#45

Open
abnegate wants to merge 14 commits into
mainfrom
claude/add-windows-support-Aowy4
Open

Add Windows support for IPC with TCP and port file discovery#45
abnegate wants to merge 14 commits into
mainfrom
claude/add-windows-support-Aowy4

Conversation

@abnegate

Copy link
Copy Markdown
Member

Summary

This PR extends the IPC (Inter-Process Communication) system to support Windows by replacing Unix domain sockets with TCP connections on localhost, while maintaining Unix socket support on Unix-like systems.

Key Changes

IPC Module (src/ipc/mod.rs)

  • Updated module documentation to reflect cross-platform IPC support
  • Modified ipc_runtime_dir() to use platform-specific directories:
    • Windows: %LOCALAPPDATA%\claudear with fallback to %TEMP%\claudear
    • Unix: XDG_RUNTIME_DIR (Linux) or claudear-{uid} in temp directory with 0700 permissions
  • Changed default_socket_path() to return .port files on Windows and .sock files on Unix
  • Updated is_daemon_running() to check TCP connectivity on Windows (reading port from file) and Unix socket connectivity on Unix
  • Added read_port_from_file() and write_port_file() helper functions for Windows port file management
  • Enhanced cleanup_stale_files() to handle both socket and port file cleanup across platforms
  • Added Windows process checking via OpenProcess API with PROCESS_QUERY_LIMITED_INFORMATION
  • Updated tests to use platform-appropriate file extensions and paths

IPC Client (src/ipc/client.rs)

  • Updated documentation to reflect TCP support on Windows
  • Modified send_internal() to support both Unix sockets and TCP connections:
    • Unix: connects directly to Unix domain socket
    • Windows: reads port from port file, then connects via TCP to 127.0.0.1:{port}
  • Updated is_daemon_running() with platform-specific logic
  • Fixed test paths to use std::env::temp_dir() instead of hardcoded /tmp paths

IPC Server (src/ipc/server.rs)

  • Updated documentation to reflect TCP support on Windows
  • Modified run() to bind to appropriate listener:
    • Unix: UnixListener on socket path
    • Windows: TcpListener on 127.0.0.1:0 (OS-assigned port), writes port to port file
  • Added separate handle_connection() implementations for Unix (UnixStream) and Windows (TcpStream)
  • Both implementations maintain identical command handling logic

Tool Detection (src/evaluation/detector.rs)

  • Updated which_exists() to use where command on Windows instead of which
  • Updated test to check for cmd on Windows and ls on Unix

Dependencies (Cargo.toml)

  • Added windows-sys dependency with Win32_Foundation and Win32_System_Threading features for Windows process checking
  • Ensured tokio includes net feature for TCP support

Storage (src/storage/vectorlite.rs)

  • Added Windows DLL path (./vectorlite.dll) to vectorlite library search paths

Implementation Details

  • Port Discovery: On Windows, the server writes the assigned TCP port to a port file, which the client reads to establish connections
  • Security: Windows uses %LOCALAPPDATA% which is user-private by default; Unix maintains strict 0700 permissions on runtime directories
  • Backward Compatibility: Unix systems continue using Unix domain sockets; no changes to existing Unix behavior
  • Process Checking: Windows uses OpenProcess with read-only flags; Unix uses /proc or kill -0 as before

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd

- IPC: On Windows, use TCP localhost with a port file for daemon
  discovery instead of Unix domain sockets. On Unix, behavior is
  unchanged.
- Process detection: Use Windows OpenProcess API via windows-sys crate
  to check if a daemon PID is still running.
- Cross-platform fixes: Use `where` instead of `which` on Windows for
  binary detection, add Windows DLL path for vectorlite, use
  platform-appropriate temp dirs and test paths.
- All existing Unix/macOS behavior is preserved behind #[cfg] guards.

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
- ci.yml: Add Windows test job and Windows build to matrix
- release.yml: Add x86_64-pc-windows-msvc target producing .zip archive

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
Introduce two new modules that centralise all OS-specific logic:

- `platform.rs` — file permissions, process detection, command existence
- `ipc/transport.rs` — IpcStream/IpcListener type aliases, connect/bind/
  check_connection helpers

This eliminates duplicated #[cfg] blocks across env_writer, encryption,
routes, detector, and collapses the two platform-specific handle_connection
and send_internal implementations in the IPC server/client into single
platform-agnostic functions.

Net effect: -335 lines, +46 lines across 8 existing files.

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
- Add file_url() helper for git tests to produce valid file:// URLs
  on Windows (forward slashes, triple-slash prefix for drive letters)
- Normalise backslashes in find_by_vendor_path() so Windows paths
  match the /vendor/ pattern
- Add .gitattributes with eol=lf to prevent autocrlf line-ending
  issues in CI
- CI: add git autocrlf=false config and embedding model warmup step
  to the Windows test job; use runner.temp for cache paths

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
@abnegate
abnegate force-pushed the claude/add-windows-support-Aowy4 branch from 75209a8 to 163c3a2 Compare February 27, 2026 23:10
claude and others added 7 commits March 1, 2026 07:40
The `runner` context is not available in job-level `env` blocks, which
caused the entire workflow to fail with "Unrecognized named-value: runner".
Move the env var to the individual steps that need it.

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
aws-lc-sys (pulled in by rustls-acme with aws-lc-rs) requires NASM to
compile assembly on Windows. The CI runners don't have NASM installed,
so use the prebuilt NASM objects instead.

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
Fix HANDLE type comparison in platform.rs - use is_null() instead of
comparing with 0, since HANDLE is *mut c_void in windows-sys 0.59+.

Fix test_validate_model_path_directory to use std::env::temp_dir()
instead of hardcoded /tmp which doesn't exist on Windows.

Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
aws-lc-sys has known MSVC compilation issues on Windows (pthread_rwlock_t,
C11 detection failures). Switch to ring as the crypto provider for rustls
which has reliable cross-platform support.

Changes:
- rustls-acme: use ring instead of aws-lc-rs feature
- reqwest: disable default TLS (which hardcodes aws-lc-rs) and use
  rustls-no-provider so ring from rustls-acme is used
- Add 10s SMTP transport timeout to prevent test hangs on Windows
- Add timeout-minutes: 30 to Windows CI jobs
- Remove AWS_LC_SYS_PREBUILT_NASM env (no longer needed)

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
Add timeout-minutes to warmup (10min) and test run (20min) steps
to prevent indefinite hangs in the Windows CI.

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
@abnegate
abnegate force-pushed the claude/add-windows-support-Aowy4 branch from 22ce9d8 to 3fdf430 Compare March 2, 2026 22:43
abnegate and others added 3 commits March 3, 2026 14:08
…vider

The reqwest crate with rustls-no-provider requires a crypto provider to
be installed before any TLS connections. Add rustls with ring feature as
a direct dependency so that rustls auto-detects ring via
get_default_or_install_from_crate_features(). Also explicitly install
ring as the default provider in main() and e2e binary for safety.

This ensures all rustls consumers (reqwest, axum-server, rustls-acme)
use ring instead of aws-lc-rs, fixing Windows build failures caused by
aws-lc-sys compilation issues with MSVC.

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
Resolve conflicts from the monolith-to-workspace restructuring on main.
Key changes:
- Add platform.rs to claudear-core crate for cross-crate platform abstractions
- Fix crate imports (claudear_core::platform:: instead of crate::platform::)
- Keep init_tls() for ring crypto provider in root crate
- Keep Windows build/test CI jobs with workspace-compatible config
- Keep windows-sys dependency for Windows process detection
- Add rustls as direct dependency for root crate (needed by init_tls)

https://claude.ai/code/session_01Mmu98Tc4ZbqpRzMCsVCkXd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants