Skip to content

Fix: Build agentop on Windows, and refuse what needs a Unix service - #2048

Merged
huang195 merged 2 commits into
rossoctl:mainfrom
michaljacovi:agentop-windows-build
Nov 21, 2026
Merged

huang195 merged 2 commits into
rossoctl:mainfrom
michaljacovi:agentop-windows-build

Conversation

@michaljacovi

Copy link
Copy Markdown
Contributor

Part of #1520. The first step of the plan in #1520 (comment): compile fixes, so agentop builds and its interactive commands run on Windows.

Problem

cmd/agentop did not build for Windows: 10 calls in 7 files used Unix-only syscalls (Setsid, syscall.Kill, Flock, Access). cmd/cortex already builds and runs there (#1878).

What changed

  • Platform helpers. The 10 calls go through 5 small helpers with a Unix and a Windows half (proc_unix.go, proc_windows.go). Unix behaviour is unchanged.
    • detached: Setsid, or a new process group with no console.
    • processAlive: kill -0, or OpenProcess + GetExitCodeProcess. Two known differences on Windows: another user's process often reads as alive (Unix's EPERM reads as gone), and one that exited with code 259 (STILL_ACTIVE) reads as running.
    • terminate / terminateGroup: SIGTERM. On Windows they refuse (errNoGracefulStop). There is no SIGTERM there, and a killed proxy skips its plugin stops and its ledger and archive flushes. The stop path is blocker 1 in the plan.
    • lockFile: Flock, or LockFileEx.
    • writable: access(W_OK), or on Windows creating and removing a temp file in a directory, and opening a file for appending (setup checks the shell profile file), which writes nothing.
  • Refused up front on Windows: agentop service, setup, uninstall and update exit 1 and say to run cortex --local in a terminal. They need a service backend, a graceful stop and a way to replace a running .exe, which are later steps.
  • Runs on Windows: observe, cost, pricing, export, import, tools, exec (including --no-record) and configure claude-code. doctor runs, but its fix lines are still Unix ones (install.sh, export PATH); that's for the next step.
  • Tests compile on Windows. The test-only Unix calls go through killPID, groupAttr, sessionAttr, getsid and mkfifo (killpid_*_test.go). Three fixtures single-quote the CA dir in YAML: in a double-quoted string, a Windows path's backslashes are escapes.
  • CI. go-ci-windows builds and vets cmd/agentop, and runs the new tests plus the exec --no-record logic tests.

Size

30 files, +377 −47. Most files are one-line call-site changes.

How it was tested

  • On Windows 11, natively:
    • go build and go vet of cmd/agentop;
    • the new tests (the refusal, processAlive with a live and an exited process, lockFile held by a second open, writable, terminate refusing) and the opt-out launch tests pass.
  • With the YAML fixture fix, the configure claude-code enable/disable and exec env tests pass natively too. They are not yet in CI, because the remaining failures in those files are Unix test stubs (launchctl, chmod, symlinks).
  • go vet for linux and darwin; the Unix tests compile.
  • The built agentop.exe:
    • --version works;
    • service status and update refuse with the message;
    • cost with no proxy says Cortex isn't running;
    • doctor runs and reports.

Tested by hand on Windows 11

With cortex.exe --local and agentop.exe built from this branch:

  • cortex.exe --local listens on 47600, 47601, 47602 and 47604, and GET /v1/sessions answers 200.
  • agentop.exe observe connects to the local Cortex on its own, shows the archived sessions, and navigates.
  • agentop.exe exec -- claude runs Claude Code through the TLS bridge, and its session is recorded.
  • exec printed that ~/.cortex/ca/bundle.crt does not exist yet. That is the known Windows trust-bundle gap (see below). Claude Code still worked, because it uses NODE_EXTRA_CA_CERTS, which exec keeps.

Not in this PR

  • A graceful stop for the proxy on Windows, then the service backend (Task Scheduler) and update. The stop path needs a design decision.
  • doctor's probes and fix lines for Windows; the remaining Unix-only tests (skips, or Windows forms).
  • The trust bundle from the Windows root store; PowerShell profile functions; install.ps1 and a Windows release .zip. release-binaries.yaml still builds only linux and darwin.
  • core/peerproc for Windows (process attribution).
  • Windows CI tests only the cmd/agentop package root, by name. The subpackages (tui, checklist, updatestatus, …) build and vet there, but their tests don't run yet.
  • The refusal is by subcommand, so agentop setup --help (and the other three with --help) is refused on Windows too.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Part of rossoctl#1520. agentop did not build for Windows: 10 calls in 7 files
used Unix-only syscalls (Setsid, Kill, Flock, Access). They now go
through small helpers with a Unix and a Windows half (proc_unix.go,
proc_windows.go):

- detached: Setsid, or a new process group with no console.
- processAlive: kill -0, or OpenProcess plus GetExitCodeProcess.
- terminate, terminateGroup: SIGTERM. On Windows they refuse: there is
  no SIGTERM, and a killed proxy skips its plugin stops and its ledger
  and archive flushes.
- lockFile: Flock, or LockFileEx.
- writable: access(W_OK), or creating and removing a temp file.

On Windows, `agentop service`, `setup`, `uninstall` and `update`
refuse up front and say to run `cortex --local` in a terminal: they
need a service backend, a graceful stop and a way to replace a running
.exe, which come later. observe, cost, export, exec, configure
claude-code and doctor run.

Tests compile on Windows: the test-only Unix calls go through killPID,
groupAttr and getsid, and three fixtures single-quote the CA dir in
YAML, where a Windows path's backslashes are escapes in double quotes.
New tests: the refusal, processAlive, lockFile, writable, terminate.
go-ci-windows builds and vets cmd/agentop and runs those tests and the
opt-out launch tests.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Michal Jacovi <michal.jacovi@il.ibm.com>
From an independent review: setup also checks the shell profile, a
file, with writable. On Windows the temp-file probe failed for a file,
so it read as not writable. A file is now opened for appending and
closed, which writes nothing; a directory keeps the probe. The
processAlive comment states its two differences from kill -0.

Test: a writable file reads as writable and is left unchanged.

Part of rossoctl#1520.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Michal Jacovi <michal.jacovi@il.ibm.com>
@michaljacovi
michaljacovi requested review from a team, huang195 and rubambiza as code owners November 21, 2026 10:13
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 29f2214d-85c5-43e0-8959-78c438addeab
Commits

Reviewing files that changed from the base of the PR and between 0847c58 and ab5c474.

Files selected for processing: 30

  • .github/workflows/ci.yaml
  • cmd/agentop/cmd_bob_launch.go
  • cmd/agentop/cmd_claudecode_test.go
  • cmd/agentop/cmd_config_migrate_pricing_test.go
  • cmd/agentop/cmd_config_migrate_test.go
  • cmd/agentop/cmd_exec_test.go
  • cmd/agentop/cmd_observe_test.go
  • cmd/agentop/cmd_service_launchd_integration_test.go
  • cmd/agentop/cmd_service_platform.go
  • cmd/agentop/cmd_service_systemd_integration_test.go
  • cmd/agentop/cmd_setup_test.go
  • cmd/agentop/cmd_uninstall_test.go
  • cmd/agentop/cmd_update_auto.go
  • cmd/agentop/cmd_update_test.go
  • cmd/agentop/codex_daemon.go
  • cmd/agentop/codex_daemon_test.go
  • cmd/agentop/killpid_unix_test.go
  • cmd/agentop/killpid_windows_test.go
  • cmd/agentop/main.go
  • cmd/agentop/platform_guard.go
  • cmd/agentop/platform_guard_test.go
  • cmd/agentop/proc_unix.go
  • cmd/agentop/proc_windows.go
  • cmd/agentop/setup_port_preflight_test.go
  • cmd/agentop/setup_prior_test.go
  • cmd/agentop/setup_probe.go
  • cmd/agentop/setup_probe_test.go
  • cmd/agentop/setup_step_binaries.go
  • cmd/agentop/setup_step_service_test.go
  • cmd/agentop/setup_unsupervised.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 21, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The Windows build claim holds. I checked it at ab5c474: base (0847c58) fails GOOS=windows go build ./... in cmd/agentop on the Setsid, Kill, Flock and Access calls. On the head, go build and go vet ./... (tests included) are clean for windows, linux and darwin. On Unix the new helpers do exactly what the code they replace did: processAlive keeps pid > 0 and reads EPERM as gone, terminateGroup keeps the ESRCH tolerance, and lockFile still maps EWOULDBLOCK to held. The full linux go test ./... passes except TestServiceInstall_RefusesABrokenConfig. That test needs a systemd user bus, which my sandbox lacks, and it fails the same way on base. The CI agentop job passes it. The Windows half also looks right: LockFileEx with FAIL_IMMEDIATELY maps ERROR_LOCK_VIOLATION to held, closing the handle releases the lock, and STILL_ACTIVE is checked through a limited-query handle. Refusing service/setup/uninstall/update before dispatch means none of the refusing terminate* paths can be reached from a command that is supposed to run on Windows.

Nits only:

  • .github/workflows/ci.yaml: the comment above go-ci-windows (around line 132) still says "agentop does not build yet". This PR adds a step to that job which builds it.
  • Not part of this PR, but worth noting for the next step: codexDaemonAlive uses os.Process.Signal(0), which always fails on Windows. So configure codex never sees a running app-server daemon there. Now that processAlive exists it could be built on that, if the Codex daemon turns out to matter on Windows.

Author: michaljacovi (CONTRIBUTOR association, admin permission on the repo, so maintainer)
Areas reviewed: Go (cmd/agentop platform helpers, call sites, tests), CI/GitHub Actions
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (the Windows job's "Build, vet and test cmd/agentop" step succeeded; the test names in its -run regex all exist and have no build constraints)

@@ -260,7 +260,7 @@ func TestServiceLifecycle_RealLaunchd(t *testing.T) {
// pid is the supervisor's, and it stays the same while a new proxy takes over.
// syscall.Kill gets a pid from childPID, which never returns one below 2: kill(2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This comment still says syscall.Kill, but the call below is now killPID. It's still accurate on Unix, since killPID is syscall.Kill there, so feel free to leave it.

@huang195 huang195 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with clawgenti's review. On Windows, terminate and terminateGroup refuse, and only service, setup, uninstall and update can get to them. Before dispatch, main refuses all four on Windows. configure codex does not get to terminateGroup either, because codexDaemonAlive is always false on Windows. I found two nits only.

Comment thread .github/workflows/ci.yaml
run: |
go build ./...
go vet ./...
go test -run 'TestRefuseUnsupported|TestProcessAlive|TestLockFile|TestWritable|TestTerminateRefusesOnWindows|TestNoRecordWanted|TestWithRecordOff|TestAddRecordOff' .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: go test -run with a name that matches no test still exits 0. If someone renames one of these tests, Windows CI stops running it and nobody sees it. You can add -v and check that each name has a --- PASS line, or you can accept the risk.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed in #2050: the step runs with -v, and fails if any listed name has no --- PASS/--- SKIP line, so a renamed test can't drop out silently.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

}

func alive(pid int) bool { return pid > 0 && syscall.Kill(pid, 0) == nil }
func alive(pid int) bool { return processAlive(pid) }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: alive now only calls processAlive. You can remove it and call processAlive directly. This is optional.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #2050: alive is gone, and its callers use processAlive directly.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

@huang195
huang195 merged commit 1adb270 into rossoctl:main Nov 21, 2026
40 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 21, 2026
huang195 pushed a commit that referenced this pull request Nov 21, 2026
Part of #1520. release-binaries.yaml builds windows/amd64 and
windows/arm64 too: agentop.exe and cortex.exe (the same profile tags as
the other cortex builds), each in its own .zip, named like the other
archives (agentop_<tag>_windows_<arch>.zip). They are required like the
other archives, listed in checksums.txt, attested, and uploaded with
them. The release notes say Windows is a preview.

docs/getting-started.md gets the Windows steps: download, check, unzip
onto PATH, `cortex --local` in one terminal and `agentop observe` in
another, and what does not run there yet. install.sh tells a Windows
shell (MINGW, MSYS, Cygwin) to use the .zip instead.

Needs #2048: agentop builds for Windows only with it.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Michal Jacovi <michal.jacovi@il.ibm.com>
huang195 pushed a commit that referenced this pull request Nov 21, 2026
…p alive

Follow-up to #2048 (review nits):

- go-ci-windows runs the listed agentop tests with -v, and fails if a
  name has no "--- PASS" or "--- SKIP" line: `go test -run` passes when
  a name matches nothing, so a renamed test dropped out silently.
- alive was a one-line wrapper for processAlive; the callers use
  processAlive directly.

Part of #1520.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Michal Jacovi <michal.jacovi@il.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants