Repository navigation
Conversation
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.
Problem
On Windows,
bin/fm-lock.shwas refusing to acquire the fleet lock inside a real Herdr + Claude session witherror: cannot locate harness process in ancestry, even thoughclaude.exewas a few hops up the real process tree.The native Windows/MSYS failure mode
Git Bash/MSYS's
psonly sees processes inside its own emulated process table, so it cannot find a harness that launched the current shell as a native Windows process.This PR introduces
fm_harness_ancestry_pids_windows, a fallback tried only when the POSIXpswalk finds no harness, to bridge that gap.A native-only walk from
/proc/$$/winpidis not sufficient across nested MSYSfork()boundaries because intermediatebash.exeprocesses can have transient WindowsParentProcessIdvalues that no longer resolve inWin32_Process, even though MSYS still knows the correct logical parent relationship.Why /proc alone isn't enough
MSYS's
/proconly knows about processes visible to MSYS. It has no entries for native Windows ancestors above the MSYS boundary, such asclaude.exe.So a pure
/procwalk also cannot reach the harness.The fix
The Windows fallback now uses a hybrid ancestry walk:
$$via/proc/<pid>/ppid, recording/proc/<pid>/winpidat each hop, until the MSYS parent reaches PID 1 or the next proc entry is unreadable.Get-CimInstance Win32_Processquery and continue the ancestry walk there.POSIX behavior is unchanged. The Windows fallback is only attempted if the existing POSIX ancestry walk finds no harness.
Tests
Added hermetic Windows/MSYS fallback coverage using a fake
/proctree, fakepowershell.exe, and an overridable starting MSYS PID.The new tests cover:
/proc/<pid>/winpidfork()ancestry before crossing into the native Windows treeAll 7 new Windows fallback tests pass.
Also manually verified in a real Herdr + Claude Windows session that
fm_harness_ancestry_pidnow resolves the realclaude.exePID where it previously failed.Fixes #3396.
Addresses the harness-ancestry portion of #3653.
Known remaining gap
This does not make Firstmate fully ready end-to-end on Windows yet.
Full native-Windows readiness remains blocked separately by #3267, an unrelated pre-existing issue in the claim-lock primitive. This PR does not touch that behavior.