Skip to content

Feat: Support running Cortex natively on Windows (no WSL) #1520

Open
0 of 1 issue completed
Open

Description

@huang195

Motivation

Some users run coding agents (e.g. opencode) on locked-down Windows VDIs. These don't support virtualization, so WSL isn't an option. Today Cortex only builds and installs on Linux and macOS.

Current state (GOOS=windows GOARCH=amd64 go build on main)

  • cmd/cortex fails in one place: core/bootstrap/bootstrap.go:67 uses syscall.SIGUSR1 (the log-level toggle). With that guarded, the proxy may build as-is.
  • cmd/agentop fails on:
    • cmd_bob_launch.go:220 and setup_unsupervised.go:30: SysProcAttr{Setsid: true}
    • cmd_service_platform.go:342,421 and setup_probe.go:213: syscall.Kill, including Kill(pid, 0) used as a liveness probe

Work needed

  1. Move the Unix-only signal and process code behind _unix.go/_windows.go files:
    • Replace the SIGUSR1 toggle on Windows (e.g. a stats/admin endpoint or an agentop command).
    • Detach processes with CREATE_NEW_PROCESS_GROUP/DETACHED_PROCESS instead of Setsid.
    • Check liveness with OpenProcess instead of Kill(pid, 0).
  2. Add a service backend: agentop service install only knows launchd and systemd. Windows needs a Task Scheduler logon task or a Windows service, or should fall back to --no-service plus the built-in supervisor (cmd/cortex/supervise.go).
  3. Audit the remaining POSIX assumptions:
    • cmd_exec.go relays SIGHUP.
    • Shell-based installer (install.sh) → PowerShell installer or a release zip.
    • $HOME/~/.config paths → %APPDATA%/os.UserConfigDir.
    • File permissions and locking.
    • Trusting the CA cert for the TLS bridge in the Windows cert store.
    • Launching agents (opencode etc.) from agentop.
  4. CI: add a GOOS=windows cross-compile job so it doesn't regress, and ideally a windows-latest test run.

The build results only cover compilation. Nothing has been run on Windows yet, so step 3 is a list of things to check, not confirmed bugs.

Requested by Lucas Showerman (opencode on a client Windows VDI).

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. huang195 commented on Nov 16, 2026

    @huang195
    MemberAuthor

    Findings on main (2026-11-16)

    These results come from reading the code and from a GOOS=windows cross-compile. Nothing was run on a real Windows machine.

    Build state, compared with the issue body

    • cmd/cortex now builds for Windows with the full profile. CI's go-ci-windows job builds it and runs the bootstrap, session-archive and cost-ledger tests.
    • cmd/agentop still fails, with 10 errors in 7 files:
      • Setsid: cmd_bob_launch.go, setup_unsupervised.go
      • syscall.Kill: cmd_service_platform.go, codex_daemon.go, setup_probe.go
      • syscall.Flock: cmd_update_auto.go
      • syscall.Access: setup_step_binaries.go
    • Release binaries: release-binaries.yaml builds only linux and darwin (amd64 and arm64), as .tar.gz.

    Real blockers

    1. The proxy cannot be stopped cleanly.

    • cmd/cortex/main.go waits for SIGTERM/SIGINT before it closes ports, stops plugins and flushes its state.
    • cmd/cortex/supervise.go stops its child with cmd.Process.Signal(syscall.SIGTERM). On Windows, Go's Process.Signal can only kill a process, so this call returns an error.
    • A background process with no console also gets no Ctrl-C or Ctrl-Break events.
    • Result: every stop, restart and update kills the proxy at once. Plugin Stop, the ledger flush and the archive flush do not run.
    • Needed: a new stop path, such as a loopback shutdown endpoint or a named Windows event. cortex, the supervisor and agentop's service commands must all use it. Someone must choose the design first.

    2. The TLS bridge cannot build its trust bundle.

    • core/tlsbridge/bundle.go builds bundle.crt from the bridge CA plus the system roots. It gets the system roots only from Unix PEM files, such as /etc/ssl/cert.pem.
    • Windows has none of these files, so EnsureTrustBundle returns an error.
    • Without the bundle, agentop cannot set SSL_CERT_FILE, REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE.
    • Needed: export the Windows ROOT store through crypt32 (estimate: about 150 lines).
    • Not tested: I expect a third-party Go tool such as gh to ignore SSL_CERT_FILE on Windows, as it does on macOS.

    3. The target environment (not verified).

    • This issue is for locked-down Windows VDIs. Such machines can have:
      • AppLocker or WDAC rules that block an unsigned .exe in a user folder
      • SmartScreen and Defender warnings on downloaded binaries
      • no administrator rights
      • group policy that blocks new scheduled tasks
    • If they have these controls, our binaries cannot run there at all. Authenticode signing is a cost and a process decision, not code.
    • Question for the requester: on that VDI, can a user run an unsigned .exe from their home folder? Can they create a scheduled task? Do they have administrator rights? Does the VDI already send traffic through a corporate proxy?

    Port work (not blockers)

    Area Problem Estimate (lines)
    Compile fixes Split the 10 call sites into _unix.go and _windows.go files. 150–250
    Port and process probes setup_probe.go uses lsof, ss and /proc. Windows needs netstat or the Win32 TCP table. 200–400
    Self-update Windows does not let a program replace its own running .exe. The auto-update lock needs a Windows lock in place of Flock. 200–400
    Shell functions bob, pi and setup_files.go write to ~/.zshrc or ~/.bashrc. Windows needs the PowerShell $PROFILE. 200–400
    Service backend cmd_service_platform.go (1,106 lines, 63 launchctl/systemctl references) needs a Task Scheduler or Windows-service version, with the auto-update timer and uninstall. 800–1,500
    Installer An install.ps1 and a release .zip. 300–500, plus the workflow
    core/peerproc No Windows code (other.go returns ErrUnsupported). cmd/cortex logs a warning and turns process attribution off, so it still works, but it cannot file requests by process or show cost per project. PID and exe from the TCP table are possible. 300–600
    Reading an agent's environment codex_daemon.go and opencode.go read another process's environment. Windows needs NtQueryInformationProcess and ReadProcessMemory. small
    Tests 42 of 83 cmd/agentop test files use shell scripts or chmod. CI also needs a Windows agentop job. 500–1,000

    Total estimate: about 3,000–5,000 lines in 3–5 PRs. These numbers are estimates from file sizes, not measurements.

    Suggested order

    1. Get an answer to the VDI question above. It decides whether this work is worth starting.
    2. Compile fixes, probes and self-update, plus the stop-path design. Run the proxy with --no-service and the supervisor. This gives a first usable version.
    3. The service backend.
    4. The trust bundle, shell functions, installer and Windows release .zip.
    5. peerproc for Windows.

    Test machine

    A Windows 11 ARM VM in UTM on an Apple Silicon Mac works for interactive tests, without a product key (unactivated). For compile fixes and unit tests, the windows-latest CI runner is enough.

    Assisted-By: Claude (Anthropic AI) [email protected]

  2. huang195 commented on Nov 17, 2026

    @huang195
    MemberAuthor

    @michaljacovi assigning this to you since you started this work. If things change later, we can always make adjustments

  3. michaljacovi commented on Nov 18, 2026

    @michaljacovi
    Contributor

    Thanks @huang195, happy to own this. As we discussed on our call, I'll come back to it after the recording work (#1920), unless someone needs it sooner. I have a real Windows laptop to test on, so ping me if anything Windows-related comes up meanwhile.

  4. added a commit that references this issue on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions