Repository navigation
Fix #1922: full suite on native Windows no longer stops the live Tower; fix EPERM at its cause - #1926
Merged
Merged
Conversation
…rt; update merge launch resolves claude launchers.windows.test.ts skips (naming the listening PID) when anything holds port 4100, and its teardown stops a Tower only while 4100 is still held by the PID the file started. codev update's conflict-merge launch now resolves its binary through resolveClaudeBin() (so CODEV_CLAUDE_BIN and the #1912 test guard apply) and awaits the session via spawnAgentProcess, as codev adopt does. The harness fake claude exits at once for an interactive (non -p) launch.
…and is awaited, never the real one
… marker and Tower port Run from inside a codev session on Windows, towerStart took the CIM branch, which the #1691 tests' spawn mock does not intercept, so they created a real tower-server process and failed. Same class as the CODEV_BUILDER_WORKTREE scrub.
…e Windows diff-nav's expected paths go through path.resolve like the code under test; preflight's probe fixtures are .cmd scripts on Windows, which cannot start #!/bin/sh.
…val; survivor check survives a failed cleanup The EPERM holder is unconfirmed and tracked in #1923.
…leanup no longer blocks the event loop Each fake agy records its PID as its own file: concurrent appends to a shared log clobbered one PID to 8 on Windows, hiding that process from the survivor check. afterEach waits for the lane's child handles to be reaped and removes the temp dir with async rm, replacing the synchronous 50x200ms retry.
…failures are reported, not thrown CMAP (claude) follow-ups: update and adopt share runClaudeSession (resolveClaudeBin + spawnAgentProcess, errors returned as AgentExit.error). adopt spawned a bare 'claude', the same bypass of CODEV_CLAUDE_BIN and the #1912 guard. The agy-auth-cache child-reaping wait counts only handles opened during the test.
…the started Tower with a bounded retry CMAP (claude) round 2: the stop decision is holdsOnlyOwnTower(), with the four cases tested. Listener PIDs after tower start are retried up to 15s, so the file's own Tower is never left unrecorded. The POSIX fake claude matches -p by argument, and the claude not-found message names update/adopt too.
…rded Tower; agent-process header names update CMAP (claude) round 3 nits. codev import's bare claude spawn is filed as #1927.
amrmelsayed
added a commit
that referenced
this pull request
Nov 18, 2026
amrmelsayed
added a commit
that referenced
this pull request
Nov 18, 2026
amrmelsayed
added a commit
that referenced
this pull request
Nov 18, 2026
This was referenced Nov 18, 2026
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.
Summary
Running the
packages/codevsuite on a native Windows developer machine could stop the developer's live Tower, and it failed onmainwith EPERM temp-dir cleanups. The launchers test can no longer touch a Tower it didn't start. The EPERM is fixed at its cause incodev update, and the other Windows-only failures listed in the issue are either fixed or filed.Fixes #1922
Root Cause
launchers.windows.test.tsstarts its Tower on the default port 4100, becauseworkspace start,shell,spawnanddevcan't be pointed at another port. With a live Tower already on 4100,afx tower startreported "already running", andafterAllthen ranafx tower stopwhenever its isolated state dir held alocal-key. That stopped the developer's Tower.CLAUDE.md/AGENTS.md, soupdate()sees root conflicts and launches the merge session. It did that with a barespawn('claude', …, { cwd: targetDir }), not awaited. That skipped the harness'sCODEV_CLAUDE_BINfake (consult: run the claude review lane through the installed claude CLI instead of the Agent SDK, on the user's subscription #1912), so the developer's real Claude Code started inside the temp project and was still holding it whenafterEachdeleted it. CI has noclaudeon PATH, which is why the GitHub Windows workflow stayed green. Proof: with~/.local/binremoved from PATH, all 47 tests in those files passed.bugfix-1691failure. Run from inside a builder session, the suite inheritedCODEV_SHELLPER_SESSION. On Windows that sendstowerStartdown the CIM branch, which the test'sspawnmock doesn't intercept, so the test created a real tower-server process.diff-navcompared against POSIX path literals, while the code usespath.resolve, which adds a drive letter on Windows.preflight-version-timeoutlaunched#!/bin/shscripts, which Windows can't start.Fix
launchers.windows.test.ts: before running, it checks whether anything is on 4100 (listener query plus a TCP connect). If so, it skips the file and names the listener (… port 4100 is already in use by PID 29272 …). It re-checks right beforetower startand records the PIDs of the Tower it started.afterAllstops a Tower only while 4100 is still held by exactly those PIDs.update.ts: the merge session gets the same injectable seamcodev adopthas. It resolves its binary throughresolveClaudeBin(), soCODEV_CLAUDE_BINand the consult: run the claude review lane through the installed claude CLI instead of the Agent SDK, on the user's subscription #1912 test guard apply, and it runs and awaits the session throughspawnAgentProcess. The un-awaited launch was not an intended production behaviour. Nothing depended on it, and since the child inherited stdio the CLI process stayed alive until it exited anyway. The only change for users is thatupdate()now returns after the session ends, asadoptdoes. Adjacent fix: on Windows the launch now goes throughcommandLaunch, so an npm-installedclaude.cmdstarts too. The bare spawn could only findclaude.exe.codev adopthad the same bare'claude'merge launch (found in CMAP).updateandadoptnow sharerunClaudeSessioninlib/agent-process.ts. A failure to resolve or startclaudecomes back asAgentExit.error, which both callers already report with the manual-merge fallback; it is never thrown.vitest-setup.ts: the fakeclaudeexits immediately (logging to$CODEV_TEST_CLAUDE_LOG) for an interactive, non--plaunch. The harness now stripsCODEV_SHELLPER_SESSIONandCODEV_TOWER_PORTalongside the existingCODEV_BUILDER_WORKTREEscrub.diff-nav/preflight-version-timeout: expected paths go throughpath.resolve; on Windows the probe fixtures are.cmdfiles.agy-auth-cache/fake-cli-temp-dir:8, hiding that process from the survivor check.afterEachwaits (up to 3s) for the lane's killed children to be reaped, then deletes the dir with asyncfs.promises.rm.agy-auth-cache: cause inferred, not proven
An in-run probe caught one EPERM. At that moment the worker's cwd was not the dir, but the worker still held an un-reaped
ChildProcessfor one fake agy, and that PID had been clobbered in the shared log. After the test-side changes, 3 consecutive full runs and porch's tests check were green, and the corrected survivor check never fired. The likely cause is a synchronous cleanup retry that blocked the event loop before the lane's killed children were reaped, but that is inferred, not proven. The consult agy lane still resolves right afterproc.killwithout awaiting the child'sclose. This PR leaves that alone; it is the open follow-up in #1925 (moved there from #1923).Test Plan
bugfix-1922-update-merge-claude.test.ts: the merge launch reaches the pinned claude and has finished whenupdate()returns. With no pin it refuses rather than using PATH, and an injected session is awaited. Fails on the oldupdate.ts(including the original EPERM) and passes with the fix.claudeon PATH (previously 7 failures).bugfix-1691passes when run from inside a session. vscodediff-navandpreflight-version-timeoutpass on Windows.testscheck (the full suite) passed on this branch.tower-lifecycle.windows"Phase 4 (b) … created through CIM": ECONNREFUSED on its throwaway port. This branch didn't cause it: that test deletes and then setsCODEV_SHELLPER_SESSIONitself, the harness scrub was already in the green run at cf66675, and e034d9b touches no Tower code. It's the same flaky file as tests: load-dependent failures in the packages/codev suite on a native Windows dev machine (agy-auth-cache EPERM, metrics-model-id barrier, windows-job census, worker exit) #1923's bridge-mode item.holdsOnlyOwnTowerunit test (tower-ownership.test.ts): query failed, nothing listening, foreign PID, no recorded PIDs, exact match.The launchers guard has no unit regression test. It is a guard inside a test file, so the evidence is the PID before/after across every run above.
Flaky Tests
Load-only failures seen on the owner's Windows machine across 14 full runs I could attribute. All pass when run alone, and none is caused by this branch.
agy-auth-cache(various tests)Worker exited unexpectedly(file unidentified)metrics-model-idconcurrent first-openwindows-job.windowscmd start /b orphanbugfix-1137-gitea-tea-apipage ceilingtower-lifecycle.windowsbridge modebugfix-1814-check-timeouttripwire-wiringlane COMMITSAlso filed: #1924, where the vscode preflight version probe's timeout leaves a
.cmdprobe's child running on Windows. The test now uses a 5s-bounded fixture.CMAP
agyis not installed on this machine).adopt.tsstill spawned a bareclaude; a synchronous spawn failure could escapeupdate(); the agy test's child-reaping wait counted handles from the whole worker, not just this test.claudematches-pper argument; the not-found message names update/adopt.codev import's bareclaudespawn (whose-palso contradicts its "stays interactive" comment) is filed as codev import: Claude session bypasses resolveClaudeBin, and its -p contradicts the 'stays interactive' comment #1927 rather than widening this PR. Its suggestion to tolerate EPERM like EBUSY, which would keep Windows coverage, is recorded on consult: agy-auth-cache tests hit EPERM on temp-dir cleanup under load on Windows; find the cause and re-enable #1925.