Skip to content

fix(hooks): gate coordinator IPC behind cfg(unix) so Windows builds#426

Merged
avihut merged 2 commits intomasterfrom
daft-424/fix-windows-coordinator
Apr 28, 2026
Merged

fix(hooks): gate coordinator IPC behind cfg(unix) so Windows builds#426
avihut merged 2 commits intomasterfrom
daft-424/fix-windows-coordinator

Conversation

@avihut
Copy link
Copy Markdown
Owner

@avihut avihut commented Apr 28, 2026

Summary

  • Gate all Unix-only socket / libc code in src/coordinator/{client,process}.rs (and their mod tests) behind #[cfg(unix)], with a #[cfg(not(unix))] CoordinatorClient stub whose connect() returns Ok(None).
  • Add a windows-check job to .github/workflows/test.yml that runs cargo check --all-targets on windows-latest, so this class of break is caught on every PR instead of only at release tag time.

Fixes #424.

Why

The v1.10.0 release (run #25074742437) failed the build-local-artifacts (x86_64-pc-windows-msvc) job with 16 errors in the new background-hook coordinator (#411): unconditional uses of std::os::unix::net::{UnixStream, UnixListener}, libc::kill, libc::SIGTERM, libc::pid_t. The libc crate is already a [target.'cfg(unix)'.dependencies], so any reference outside a #[cfg(unix)] scope fails on Windows.

The Unix-only fork_coordinator was already #[cfg(unix)] and both invokers (hooks/yaml_executor, commands/hooks/jobs) already branch on #[cfg(unix)]. The remaining IPC helpers (start_socket_listener, handle_client_connection, cancel_single_job, send_response, build_job_list, write_pid_file) are only reached from those gated entry points, so gating them is safe and keeps the public surface unchanged. CoordinatorClient callers (commands/hooks/jobs.rs, core/worktree/prune.rs) already treat Ok(None) as "no coordinator running", which is the truthful state on Windows.

Why this slipped past CI

PR CI (test.yml) ran only on Ubuntu and macOS; the Windows target was built only by the release workflow on tag push. The new windows-check job closes that gap with a fast cargo check (no full build, no tests) so any future un-gated std::os::unix::* or libc::* reference fails the PR rather than the release.

Verification

  • mise run fmt:check
  • mise run clippy ✓ (zero warnings)
  • mise run test:unit -- coordinator:: — all 80 coordinator tests pass on macOS
  • Greppable invariant: every remaining std::os::unix:: / libc:: hit in src/coordinator/ is now inside a #[cfg(unix)] (or #[cfg(all(test, unix))]) scope.
  • Couldn't cross-compile to x86_64-pc-windows-msvc locally (aws-lc-sys needs windows.h); the new windows-check CI job is the authoritative validation.

Test plan

  • PR CI passes, including the new windows-check job on windows-latest.
  • Once merged, kick the next release and confirm build-local-artifacts (x86_64-pc-windows-msvc) succeeds end-to-end.

🤖 Generated with Claude Code

The background hook coordinator added in #411 used Unix-only APIs
(`std::os::unix::net::{UnixStream, UnixListener}`, `libc::kill`,
`libc::SIGTERM`, `libc::pid_t`) without conditional compilation. The
v1.10.0 release workflow's `build-local-artifacts (x86_64-pc-windows-msvc)`
job consequently failed with 16 errors in `src/coordinator/{client,process}.rs`.

Gate all Unix-only socket and `libc` code in `client.rs` and `process.rs`
behind `#[cfg(unix)]` (including their test modules), and provide a
`#[cfg(not(unix))]` `CoordinatorClient` stub whose `connect()` always
returns `Ok(None)`. Existing call sites in `commands/hooks/jobs.rs` and
`core/worktree/prune.rs` already handle the `None` case as "no
coordinator running", and the only invokers of `fork_coordinator` are
already gated, so the public API stays compatible.

To prevent this class of regression from slipping past PR review again,
add a `windows-check` job to `test.yml` that runs `cargo check
--all-targets` on `windows-latest`. This catches Windows compile breaks
on every PR rather than only at release tag time.

Fixes #424
@avihut avihut added this to the Public Launch milestone Apr 28, 2026
@avihut avihut added the fix Bug fix label Apr 28, 2026
@avihut avihut self-assigned this Apr 28, 2026
The new `windows-check` PR job (cargo check --all-targets) caught an
un-gated `use std::os::unix::fs::PermissionsExt;` at the top of
`src/hooks/executor.rs`'s test module. Its only consumer is already
inside a `#[cfg(unix)]` block, so the import just needs the same gate.

Pre-existing: this didn't break the release workflow because dist's
build doesn't compile the lib-test target — only the `--all-targets`
check exercises the test modules on Windows.
@avihut avihut merged commit 96535c3 into master Apr 28, 2026
9 checks passed
@avihut avihut deleted the daft-424/fix-windows-coordinator branch April 28, 2026 21:10
This was referenced Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Windows build broken by background hook coordinator module

1 participant