Skip to content

Windows support for MudroomCore and the CLI (Docker Desktop, Podman) - #3

Merged
Kernel-Hunter merged 15 commits into
mainfrom
windows-support
Oct 11, 2026
Merged

Kernel-Hunter merged 15 commits into
mainfrom
windows-support

Conversation

@Kernel-Hunter

@Kernel-Hunter Kernel-Hunter commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

This gets MudroomCore and the mudroom CLI building and working on Windows (x86_64 and arm64), with Docker Desktop or Podman as the sandbox. It's the same setup Linux already has: CLI only, container backend. The macOS app and the apple VM backend stay macOS-only.

What changed

Most of the port is in new *+Windows.swift files next to the POSIX code. Existing files only get small #if os(Windows) branches, so macOS and Linux behave as before.

  • File system (Win32.swift, FileNode+Windows.swift, Cloner+Windows.swift): the same safety rules as the POSIX code. Files are opened without following reparse points, folders are listed through a handle, and every path opened under work/ is checked against its final path, so a link the agent swaps in isn't followed. Symlinks are recreated as symlinks. Junctions and other reparse points show up as special files and are never applied. Paths past MAX_PATH get the \\?\ prefix. Windows has no mode bits, so files read as 0644 and folders as 0755. On ReFS the clones use block cloning (FSCTL_DUPLICATE_EXTENTS_TO_FILE); anywhere else they're plain copies.
  • POSIX calls Windows lacks: rename, unlink, mkdir, symlink, kill, usleep and a no-op chmod exist as String-path functions that are only built on Windows, so the shared code calls them as before. rename replaces the target, handles read-only targets, and retries for half a second if an antivirus scan has the file open.
  • Proxy (Socket+Windows.swift): a Winsock Sock with the same API. EgressProxy now uses a few Sock helpers (close, receive, poll, wake) instead of raw POSIX calls. On Windows the proxy listens on 127.0.0.1, as it does on macOS with Docker Desktop.
  • Processes (ProcessRunner+Windows.swift, WindowsCommandLine.swift): runAttached uses CreateProcessW and the child inherits only the console handles. Mudroom ignores Ctrl+C while the agent runs, and closing the console window stops the docker process. which searches PATH with PATHEXT. Command-line quoting and the environment block are plain string code and are tested on every platform.
  • Locks and secrets: FileLock uses LockFileEx. Tokens and API keys go to Credential Manager by default (MUDROOM_TOKEN_STORE=file still works). The store lives in %LOCALAPPDATA%\Mudroom.
  • Docker: bind mount sources are passed as Windows paths, and setup can start Docker Desktop.
  • CLI: the terminal review and the prompts use the Windows console API (UTF-8, VT sequences, raw input).
  • Atomic writes of session.json and the other store files go through a small helper. On macOS and Linux it's the same .atomic write as before. On Windows it retries the rename while another process has the file open.

How it was tested

CI has a new windows job on windows-latest (x86_64) and windows-11-arm (arm64) with Swift 6.2.4. It builds, runs the whole test suite, then runs scripts/windows-smoke.ps1. That script drives the built CLI through a full session without a sandbox: new, edit work/, diff, hunks, apply --all, undo, list, discard.

Tests that need Unix modes, FIFOs, signals or a pty are skipped on Windows, each with a reason. WindowsTests.swift adds tests for what Windows does instead:

  • Docker mount path conversion and command-line quoting (these run on every platform)
  • fixed modes, and chmod producing no diff
  • CRLF files through diff, apply and undo
  • a read-only project file replaced on apply and restored on undo
  • paths longer than MAX_PATH
  • a junction in work/ that is reported but never followed
  • a Credential Manager round trip
  • which, and exit codes from runAttached
  • block cloning on ReFS. This one is opt-in with MUDROOM_TEST_REFS because GitHub's runners failed to format a ReFS volume, so CI skips it.

macOS and Linux CI still pass.

Swift 6.2 ships Clang 19, and the Visual Studio 2026 headers on windows-latest refuse anything older than Clang 20 when compiling swift-crypto's BoringSSL. The Windows job passes -Xcxx -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH, and the README tells people building from source to do the same.

Not supported yet

  • Nobody has run a real sandbox on Windows. GitHub's Windows runners can't run Linux containers, so docker run, the forwarder and locked mode have only been exercised up to the point where Docker would start. Someone with Docker Desktop needs to run mudroom network check --backend docker and a real session. Podman on Windows hasn't been tried at all.
  • Signing in with the host's claude CLI needs a pseudo-terminal. PtyProcess on Windows is a stub that throws until someone writes the ConPTY version. mudroom agent login claude signs in inside the sandbox instead, and mudroom agent token claude still takes a pasted token.
  • The docker child doesn't inherit the runner lock the way it inherits the POSIX descriptor, so the session guard also checks whether the container is still running.
  • With no mode bits, a script the agent marks executable doesn't show up in the diff.
  • Running the Linux build inside WSL2 is untested.

The README has a Windows row in the requirements table, build steps, and a section on these differences.

This is rebased on main after #1 and #2. The signal-mask and descriptor handling from #1 is POSIX-only, so it stays off Windows, and the new ProcessRunnerTests.swift is skipped there (WindowsTests covers runAttached on Windows).

Tests that need mode bits, FIFOs, signals or a pty are skipped on Windows
with a reason. New tests cover Docker mount paths, command line quoting,
CRLF files, read-only targets, long paths, junctions, Credential Manager
and runAttached.
…e test

Folders have no execute bit on Windows, so the project check lists the
folder instead. Tests closed sockets with the C runtime's close(), which
aborts on a socket. Atomic writes retry while an antivirus scan holds the
old file. Keep LF endings for the image and shell scripts on Windows
checkouts. CI also runs a CLI session end to end and a block-clone test
on a ReFS Dev Drive.
…me tests

Closing a socket with the request unread resets the connection, and
Windows drops the 503 the client hasn't read yet, so drain it first.
The long-path test writes through Win32 (FileManager can't create such
paths), and control characters in file names are skipped on Windows,
which doesn't allow them.
PowerShell drops a bare -- passed to a function, so mudroom new got the
command as stray arguments. GitHub's runners can't format a ReFS volume,
so the block-clone test stays opt-in.
The request can arrive after the 503 is sent, and closing then resets
the connection. Read until the client closes, for at most 250 ms.
…ic write

On Windows, Foundation's atomic write failed with a sharing violation
when an antivirus scan had the new file open.
Windows has no signal masks or posix_spawn, so start() just runs the
process there, and the POSIX-only runAttached tests are skipped.
@Kernel-Hunter
Kernel-Hunter merged commit 6e58c88 into main Oct 11, 2026
5 checks passed
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.

1 participant