Skip to content

Make the control plane's address part of the contract - #118

Merged
fylorn merged 1 commit into
mainfrom
feat/windows-control-transport
Sep 23, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/windows-control-transport

Conversation

@fylorn

@fylorn fylorn commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

UnixListener::bind was the last unix call in core with no cfg around it — so this was not "the control plane is unavailable on Windows", it was that the crate would not build. Windows gets a loopback port instead, and picking between the two is not the caller's business: Endpoint::in_dir hands back the one transport this platform has.

Why the address moves into tw-api

It is contract, not convention. Core listens there and the desktop app connects there, and until now each side built <data dir>/twcore.sock for itself — which only stayed in agreement because that line was short enough to get right twice. On Windows the answer forks, and two copies of a forking answer drift. Drifting looks like the interface failing to reach a gateway that is running perfectly well.

The token's environment variable and file names move there for the same reason, and it is the sharper case: the desktop app has to know what the variable is called in order to pass the token at all, and it depends on tw-api, not tw-control. Where #114 left them, they were unreachable from the side that needs them.

The loopback listener

Binds port 0 and writes back whatever the system gave it. A fixed port collides with other software — and a collision surfaces as core failing to start — besides saving a step for anyone who wants to connect. The file is written after the bind: only then is there a real number to write, and the other order leaves a file pointing at somebody else when the bind fails.

That transport cannot keep anyone out. A loopback port is reachable by every process on the machine and, unlike a unix socket, cannot be asked who is on the other end (SO_PEERCRED). Its only door is the token from #114 — which is why that went in first, and on both platforms.

Both transports hand their connection to the same function. What differs is how the stream is obtained; protocol negotiation and how a failure gets logged should be identical, and writing that twice is writing two things that will diverge.

default_socket_path had no callers left and is gone.

Verification — and what is not verified

Host: clippy clean, full workspace suite green, smoke script 53/0 against the real binary over the real socket.

tw-api's new module cross-checks clean against x86_64-pc-windows-msvc and aarch64-pc-windows-msvc.

serve_loopback itself is not compiled anywhere yet. tw-control cannot be cross-checked from macOS — aws-lc-sys and blake3 both want a target C toolchain — and there is no Windows runner. The scratch-crate trick used in #116 and #117 does not apply here, because this code is not self-contained.

With this merged, core should build on Windows for the first time, so the Windows CI job is the next thing to land and is what will actually prove it. Reviewing this one on the strength of the reasoning rather than a green Windows check is the honest description of where it stands.

🤖 Generated with Claude Code

`UnixListener::bind` was the last unix call in core with no cfg around it,
so this was not "the control plane is unavailable on Windows" -- the crate
would not build. Windows gets a loopback port instead, and picking between
the two is not the caller's business: `Endpoint::in_dir` gives back the one
transport this platform has.

The address moves into tw-api because it is contract, not convention. Core
listens there and the desktop app connects there, and until now each side
built `<data dir>/twcore.sock` for itself -- which only stayed in agreement
because that line was short enough to get right twice. On Windows the
answer forks, and two copies of a forking answer drift; drifting looks like
the interface failing to reach a gateway that is running perfectly well.

The token's environment variable and file names move there for the same
reason, and it is a sharper case: the desktop app has to know what the
variable is called in order to pass the token at all, and it depends on
tw-api, not on tw-control. They were unreachable where they were.

The loopback listener binds port 0 and writes back what the system gave it.
A fixed port collides with other software -- and a collision shows up as
core failing to start -- besides saving a step for anyone who wants to
connect. The file is written after the bind, not before: only then is there
a real number to write, and the other order leaves a file pointing at
somebody else when the bind fails.

That transport cannot keep anyone out. A loopback port is reachable by
every process on the machine and, unlike a unix socket, cannot be asked who
is on the other end. Its only door is the token.

Both transports hand a connection to the same function. What differs is how
the stream is obtained; everything after that -- protocol negotiation, how a
failure is logged -- should be identical, and writing it twice is writing
two things that will diverge.

`default_socket_path` had no callers left and is gone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn force-pushed the feat/windows-control-transport branch from a0b5237 to fbc0cd1 Compare September 23, 2026 05:34
@fylorn
fylorn merged commit e7332d3 into main Sep 23, 2026
1 check passed
@fylorn
fylorn deleted the feat/windows-control-transport branch September 23, 2026 05:44
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