Repository navigation
Make the control plane's address part of the contract - #118
Merged
Merged
Conversation
`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
force-pushed
the
feat/windows-control-transport
branch
from
September 23, 2026 05:34
a0b5237 to
fbc0cd1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UnixListener::bindwas 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_dirhands 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.sockfor 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_pathhad 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 againstx86_64-pc-windows-msvcandaarch64-pc-windows-msvc.serve_loopbackitself is not compiled anywhere yet. tw-control cannot be cross-checked from macOS —aws-lc-sysandblake3both 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