Repository navigation
Description
The problem
cmd/aforge does not compile for Windows. It has not since 2026-08-20.
$ GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./cmd/aforge
# github.com/Agent-Field/aforge-v2/internal/standing
internal/standing/running.go:126:14: undefined: unix.Kill
internal/standing/running.go:127:43: undefined: unix.EPERM
internal/standing/store.go:352:17: undefined: unix.Flock
internal/standing/store.go:352:44: undefined: unix.LOCK_EX
internal/standing/store.go:355:26: undefined: unix.Flock
internal/standing/store.go:355:53: undefined: unix.LOCK_UN
internal/standing/store.go:373:17: undefined: unix.Flock
internal/standing/store.go:373:44: undefined: unix.LOCK_EX
internal/standing/store.go:373:57: undefined: unix.LOCK_NB
internal/standing/store.go:375:26: undefined: unix.EWOULDBLOCK
internal/standing imports golang.org/x/sys/unix from store.go, running.go and tick_test.go with no build tags. cmd/aforge depends on it, so the whole shipped binary is unbuildable on Windows — not just the tests.
Why it is urgent
.github/workflows/release-binaries.yml still publishes windows/amd64 and windows/arm64, with if-no-files-found: error. The next v* tag fails at the build step. v0.1.0 did ship aforge-windows-amd64.exe and aforge-windows-arm64.exe, so this is a regression against a platform that has real released artifacts.
Why nobody noticed
internal/standing landed in 1349a458 (2026-08-20), three days after v0.1.0 (fde1f1fc, 2026-08-17). Until now the only cross-platform build ran on master, which never received those commits — so no Windows compile has happened since. The new cross build job in .github/workflows/ci-full.yml (added in #82) caught it on its first run: https://github.com/Agent-Field/aforge-v2/actions/runs/33414121900
The fix — both replacements already exist in this repo
No new shim is needed; two internal packages already have _unix.go/_windows.go halves with matching semantics.
1. Locking → internal/filelock
filelock.Lock(file, exclusive, nonBlocking) / Unlock(file) / IsBusy(err) map one-to-one onto what store.go does today.
store.go:352 — underItemLock:
if err := unix.Flock(int(lock.Fd()), unix.LOCK_EX); err != nil { return err }
defer func() { _ = unix.Flock(int(lock.Fd()), unix.LOCK_UN) }()
// →
if err := filelock.Lock(lock, true, false); err != nil { return err }
defer func() { _ = filelock.Unlock(lock) }()store.go:373 — takeTickLock, the non-blocking one-ticker-at-a-time lock:
if err := unix.Flock(int(lock.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil {
lock.Close()
if errors.Is(err, unix.EWOULDBLOCK) { return nil, ErrHeld }
return nil, err
}
// →
if err := filelock.Lock(lock, true, true); err != nil {
lock.Close()
if filelock.IsBusy(err) { return nil, ErrHeld }
return nil, err
}filelock.IsBusy already checks EWOULDBLOCK and EAGAIN, so this is slightly more correct than the current code, not merely equivalent.
2. Liveness → internal/processgroup
running.go:126 — pidAlive is exactly processgroup.ProcessAlive, including the EPERM-means-alive rule the comment describes:
func pidAlive(pid int) bool {
if pid <= 0 { return false }
err := unix.Kill(pid, 0)
return err == nil || errors.Is(err, unix.EPERM)
}
// → keep the pid <= 0 guard, then: return processgroup.ProcessAlive(pid)The Windows half uses OpenProcess + GetExitCodeProcess and treats ERROR_ACCESS_DENIED as alive — the same semantics.
3. tick_test.go
Also uses unix.LOCK_NB / unix.LOCK_UN; move it to filelock the same way, or it will keep the package red on Windows even after the two source files are fixed.
Design note worth a second's thought
flock is advisory and per-open-file-description; the Windows half of filelock is LockFileEx, which is mandatory. For underItemLock and takeTickLock — both short, both guarding a whole write — that difference should not bite. Worth a glance rather than an assumption, since the standing store's whole point is that two windows must not both run a pass.
Done when
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./...
GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go build ./...
go test ./internal/standing/ # still green on macOS and Linuxand the cross build job in ci-full.yml is green on all six targets.
Scope
internal/standing only, plus its test. This was found by the CI added in #82; the branch-rules lane deliberately did not touch product code. Per docs/rules/changelog.md the fix owes a change entry — make changelog-new PR=<n> KIND=fixed SLUG=windows-standing-build, with an invalidates line saying the Windows binary was unbuildable and now is not.
If this is not wanted now
The honest alternative is dropping windows/* from the release-binaries.yml matrix until someone owns it — publishing a Windows binary that has not compiled in eleven days is the worse of the two failures. That is a one-line change and unblocks releasing.
Drafted with CodeAF · reviewed and owned by the author
Activity
session: build for windows — processgroup and filelock spell the job …
changelog: say what actually broke, and what windows gets
session: build for windows — processgroup and filelock spell the job …
session: build for windows — processgroup and filelock spell the job …
session: build for windows — processgroup and filelock spell the job …
session: make cmd/aforge build on windows (#501)
santoshkumarradha commentedon Sep 10, 2026
Closed in the 2026-09-10 triage sweep — fixed. PR #501 (
session: make cmd/aforge build on windows (#96)) merged and did not auto-close. Verified at dev@95a0d0a9b:GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./cmd/aforgesucceeds.