Repository navigation
Conversation
Git Bash without Developer Mode turns ln -s into a silent directory copy, so fm_lock_try_create could never verify the link and every lock failed. After the normal path fails verification, fm_lock_try_create now cleans the stray copy (known files only, so rmdir still refuses foreign content) and asks cmd.exe for a directory junction - a real filesystem link Cygwin reads as a symlink, no privileges required. Capability is probed by trying and latched per process; creation is re-verified through the same fm_lock_points_to_owner check, and a missing primitive still fails closed. //c and //J keep MSYS argument conversion from mangling the switches into paths.
…lities Native Windows herdr reports socket_path in drive-letter form (C:\Users\...\herdr.sock); canonicalize it through cygpath -u and re-check the absolute result so Windows and POSIX spellings derive one presentation lock identity instead of failing closed. The presentation lock namespace required mode 700 verbatim, but Git Bash/MSYS mounts are noacl: chmod is a silent no-op and every directory stats 755. Attempt the repair chmod first, then treat an unchanged mode as proof the filesystem cannot express mode bits and fall back to ownership + the platform ACL boundary. Also add the pane-capability primitives fm-spawn's Windows arm needs: foreground_cwd support probing, foreground process naming, and literal wait-output, since native Windows panes report foreground_cwd null.
Exact-mode invariants (600/700) are unanswerable on Git Bash/MSYS noacl mounts: chmod synthesizes non-POSIX modes (chmod 000 reports 400), so every private-file check refused forever on that host. fm_pr_mode_bits_unfaithful positively proves chmod infidelity by mutating a scratch sibling - never the caller's file - and stays false on any probe failure so undetermined cases keep refusing. The private-file validator and its two exact-mode call sites fall back to ownership + device + link-count plus the platform ACL boundary there.
…dows collect_local_firstmate_states deduplicated state dirs by raw spelling; a state dir reachable as both D:/... and /d/... was scanned twice and the self-skip read the task's own meta as a conflicting record, refusing pool-slot teardown. Dedup by canonical directory identity instead. Git Bash/MSYS has no lsof and its ps cannot express pgid or setpgrp a real process group. The lsof-absent reap arm now resolves the tmux pane leader only when ps -o pgid actually works there, and otherwise scans /proc/<pid>/cwd - which MSYS does expose - through the same identity-safe TERM-then-KILL flow. Test fixtures gain the matching MSYS emulations: wrapper scripts where ln -s copies binaries, a real-PATH lsof-absent mode where lsof is genuinely missing, /proc-backed lsof/lstart emulation for the exec- change case, and a platform skip where POSIX process groups cannot even be constructed.
… panes Native Windows herdr panes cannot report a live foreground cwd (cwd tracking there is prompt-integration only), so the interactive treehouse get discovery poll can never observe worktree entry - and the pane's native powershell/cmd shell cannot run the POSIX launch flow anyway. When the foreground_cwd capability probe fails, spawn now reverses the information flow: it takes Treehouse's durable lease firstmate-side under the project lock (get --lease --json --lease-holder fm-<id>), enters Git Bash for powershell/cmd panes, and proves the pane reached the leased slot with an output marker the echoed command line cannot fake. Every failure releases the lease through the abort cleanup while the project lock is still held; unrecognized pane shells refuse before any launch.
Three fixture gaps made the suite unbuildable on Windows: - The fake python3 was shebang-less, relying on the POSIX ENOEXEC shell fallback; noacl mounts cannot set an execute bit, so a file is runnable there only through #! and command -v skipped the fake for the real interpreter. Emit an explicit bash shebang instead. - The symlink-at-shim refusal needs a creatable symlink; MSYS without Developer Mode can only copy. Skip by capability probe. - The fail-closed retry cases need chmod 0000 to deny reads; MSYS synthesizes only 400 (still readable). Skip via a scratch-sibling mode_denial_works probe instead of uname.
… MSYS The private-spec assertion demanded a literal 600 that noacl mounts cannot express; it now accepts the shared fm_pr_mode_bits_unfaithful verdict, matching the production fallback. The unregister symlink-refusal half needs a creatable symlink; MSYS without Developer Mode only copies. Skip by capability probe while the hard-link refusal half still verifies.
… host Every case past the inert section drives a detached runner that must isolate and prove its own process group through ps -o pgid; Git Bash/MSYS perl setpgrp creates no group and MSYS ps cannot express pgid, so the runner substrate does not exist there. Gate on the capability probe the runner itself uses rather than uname, so the inert contract still verifies and the suite exits green on hosts without the substrate.
…nd ln -s cannot The ancestry suite never ran green on Git Bash/MSYS: its fixtures recorded Cygwin pids the lock world never sees, the copied fixture home lacked fm-win32-proc-lib.sh so the real lock lib could not even load there, and a per-hop ps -l -p/fields substitution chain cost ~18 process launches per ancestry walk, which pushed every fm-lock/autoarm/guard call past the fixture's phase budgets. - Probe the operative lock pid space by capability (ps -o vs the Win32 table), record operative pids in .lock/.lock-session/CLAUDE_PID, and keep Cygwin pids only for kill/wait. - Copy renamed real binaries instead of ln -s where the host cannot link. - Copy fm-win32-proc-lib.sh into fixture homes; fm-session-lock-lib.sh sources it unconditionally. - Replace the per-hop substitutions in fm_win32_ancestor_winpids with one ps -l table plus a row index built at load (fm_win32_proc_get gives callers zero-fork field reads): ~6s to ~1s per walk on this host. - Fix a latent break where the trusted-session-id path called the nonexistent _fm_win32_lookup; it now calls fm_win32_proc_fields. - Fake ps stubs answer the whole-table ps -l the lib now reads, keyed to the caller chain plus caller-declared extra rows for explicit-pid translation. - Widen the fixture's FM_CLAUDE_AUTOARM_EPOCH_FRESH: the guard's 15s rewake freshness window is sized for production timing, not spawn-taxed hosts. Evidence: tests/fm-session-lock-ancestry.test.sh 22/0 on this host for the first time; fm-win32-proc-lib 9/9; fm-devin-harness 10/10; fm-harness-precedence 13/13; fm-branch-supervision 24/0; fm-omp-harness and fm-sessionstart-nudge identical to their pre-existing baselines.
…ck lib fm-session-lock-lib.sh now sources the Win32 process-table lib unconditionally for its ancestry fallback, so every fixture checkout that copies the lock lib, fm-harness.sh, fm-branch-outcome.sh, or fm-sessionstart-nudge.sh into a fake bin/ must copy the new lib beside it or sourcing the copied script fails outright.
…cestry - fm-procevent-when: every case past the runner-free arm/retire binding needs a live detached runner, and the runner requires POSIX process-group proof (ps -o pgid=) that Git Bash/MSYS does not have; gate on the capability, matching fm-procevent's runner gate. - fm-devin-harness: the devin-helper negative ancestry case ran under ambient ancestry, so inside a real Devin session the honest verdict is the true devin.exe ancestor; fabricate the process table for that probe so the case isolates the helper's own name.
…ative WINPID lock fm-sessionstart-nudge.sh now sources fm-win32-proc-lib.sh unconditionally, so fixtures that copy the hook must stage the lib beside it (otherwise the source error leaks to stderr/captured output). The owned-lock nudge case writes this shell's WINPID where ps -o is dead, matching the pid space the Win32 walk reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Closing: this PR was opened against the wrong target. The change is being delivered on the fork (kendylx#1) instead. Apologies for the noise. |
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.
Intent
Make Firstmate's fleet tooling work correctly on Windows Git Bash/MSYS hosts so a native-Windows harness session (Devin CLI specifically) can hold the fleet lock, be ancestry-detected as its harness, spawn and supervise crewmates through herdr, and tear work down cleanly. The platform gaps closed: ln -s silently copies instead of linking on this host (no Developer Mode) so fm_lock_try_create always failed; Cygwin ps -o is dead so harness ancestry/liveness verdicts were blind; herdr's Windows build reports drive-letter socket paths, no ACL presentation namespace, and null foreground_cwd; teardown had no lsof; and the repo's own test fixtures assumed POSIX pids and real symlinks. Key scope decision: this started as a full Devin harness adapter, but upstream merged its own Devin adapter (PR #5380) mid-flight, so the captain elected to rebase ONLY the Windows/MSYS compatibility layer onto upstream main as this branch - our own adapter pieces (classification rows, launch recipe, control rows, devin.md supervision doc, pane-signature readiness gate) were deliberately DROPPED as superseded by upstream's fm-devin-config.sh/fm-busy-event.sh design and must not be re-added. What intentionally remains: mklink /J junction fallback in fm_lock_try_create gated to hosts where ln -s cannot link; shared fm-win32-proc-lib.sh Win32 process table with capability-gated ancestry/liveness fallbacks wired into fm-harness.sh, fm-session-lock-lib.sh (incl. adding ^devin$ to FM_HARNESS_RE which upstream still lacked), fm-sessionstart-nudge.sh, fm-branch-outcome.sh - all designed so healthy POSIX hosts take byte-identical verdict paths and fallbacks only fire when the ps read itself fails; herdr Windows socket/namespace/pane capability handling; cwd-blind herdr spawn worktree acquisition via durable lease with FM_WT_ marker proof; /proc//cwd teardown reaping plus canonical state-dir dedup (kills the D:/ vs /d/ self-match refusal); positive scratch-probe fallback for PR mode-bit invariants where chmod cannot express bits; Windows-capable test fixtures (operative-pid-space probe, renamed real binaries instead of symlinked fakes, fake-ps -l whole-table arms, capability-gated skips for POSIX-only cases like process groups); the noncanonical-state teardown regression opts out via config/backlog-backend=manual because it proves dedup not backlog mechanics. Delivery: push the branch to the fork remote and open a PR to upstream for the captain to review and merge - the captain retains merge authority.
What Changed
bin/fm-win32-proc-lib.sh, a shared Win32 process-table reader.fm-harness.sh,fm-session-lock-lib.sh,fm-sessionstart-nudge.shandfm-branch-outcome.shnow use it for harness ancestry and liveness checks, but only when thepsread itself fails. Healthy POSIX hosts keep their existing verdict paths. This branch also adds^devin$toFM_HARNESS_RE.fm_lock_try_createnow falls back to amklink /Jjunction. The fallback only runs on hosts whereln -scannot create a real link.bin/backends/herdr.shhandles herdr's Windows socket paths (drive letters), the missing ACL presentation namespace, and pane capabilities.foreground_cwd,fm-spawn.shclaims the worktree through a durable lease and checks theFM_WT_<id>marker.fm-teardown.shfinds processes through/proc/<pid>/cwdwhenlsofis missing. It also treatsD:/…and/d/…as the same state directory, which stops teardown from wrongly refusing on itself.fm-pr-lib.shfalls back to a scratch-file check for mode bits thatchmodcannot set on this host.ps -lthat returns the whole process table.docs/herdr-backend.mdanddocs/scripts.mddocument the changes.🤖 Generated with Claude Code
Risk Assessment
Testing
I ran the real fm-sessionstart-nudge.sh hook on a MINGW64 host where
ps -odoesn't work. A fixture staged without fm-win32-proc-lib.sh prints a 'No such file' source error into the captured output, which is the defect the fixture repair fixes; with the lib staged the output is clean. A .lock holding the MSYS $$ still triggers the nudge, a .lock holding the shell's WINPID is correctly silent, and a dead WINPID still triggers the nudge. The nudge suite passes through the owned-lock case, which fails on base. The two failures after it also fail on this host without this branch's changes: Node can't spawn a .sh directly, and the full-digest run case fails the same way on base. The cursor, calm-pi, and opencode/pi live-e2e suites could not run here because the host has no C compiler, tmux, or pi. The repairs are committed as cc5af92. This change has no visual UI, so there are no screenshots.Evidence: Live nudge hook fixture-repair demo (Git Bash)
Source: Live nudge hook fixture-repair demo (Git Bash)
Evidence: fm-sessionstart-nudge suite run (worktree)
Source: fm-sessionstart-nudge suite run (worktree)
Evidence: fm-sessionstart-nudge suite without the OpenCode Node-spawn case
Source: fm-sessionstart-nudge suite without the OpenCode Node-spawn case
Evidence: fm-cursor-primary suite run
Source: fm-cursor-primary suite run
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 5 issues found → auto-fixed (2) ✅
bin/fm-win32-proc-lib.sh:43-declare -A _FM_WIN32_ROW=()runs at source time, but stock macOS /bin/bash 3.2 has no associative arrays. The repo explicitly supports bash 3.2 (the ci.ymlmacos-stock-bashjob; fm-classify-lib.sh:604 notes 'no associative arrays so the fold runs on bash 3.2'). On 3.2 this line fails with 'declare: -A: invalid option' and a non-zero status. So every script that sources the lib breaks on macOS, even though the Win32 path can never be reached there. Failure scenario:fm-branch-outcome.shrunsset -eu(line 92) and then sources the lib at top level (line 100), so it exits right away.fm-inbox.sh(set -euo pipefail) sources fm-session-lock-lib.sh at line 850, which sources this lib (fm-session-lock-lib.sh:109). Theset -uhooks print the error to stderr on every run: fm-harness.sh:80, fm-sessionstart-nudge.sh:20, and fm-lock.sh, fm-turnend-guard.sh and fm-claude-stop-autoarm.sh through fm-session-lock-lib.sh. Fix: don't declare the associative array at source time. Create it lazily inside fm_win32_proc_load behind aBASH_VERSINFO[0] -ge 4check (for exampledeclare -gA), and have the load fail closed on older bash. Alternatively, drop the associative index and use an awk lookup.bin/fm-harness.sh:308- Intent conformance. The intent says 'healthy POSIX hosts take byte-identical verdict paths and fallbacks only fire when the ps read itself fails'. In the code, though, the Win32 fallback runs whenever a POSIX walk finds no match, or wheneverkill -0fails on an ordinary dead pid, not only when ps fails. Failure scenario: on WSL, powershell.exe is on PATH through interop. A walk that finds no harness, or a stale-lock liveness check on a dead Linux pid, then starts powershell.exe (seconds of latency). It also looks the Linux pid up in the Windows process table as if it were a Win32 pid: on Linux, fm_win32_ancestor_winpids reuses $$ as the seed becauseps -lcolumns differ. A dead Linux lock-holder pid that happens to match the pid of a Windowsclaude.exe/codexprocess (for example Claude Desktop) is then reported as a live harness, which wedges the lock. On plain Linux and macOS every miss also costs an extraps -lfork. Same invariant at: fm-harness.sh:171 (ancestry_names_omp falls back after a normal walk end); fm-session-lock-lib.sh:184 (fm_harness_ancestry_pids falls back whenever printed=0); fm-session-lock-lib.sh:223 (fm_harness_pid_alive falls back on any kill -0 failure); fm-sessionstart-nudge.sh:38 (kill -0 || fm_win32_pid_alive) and :50 (unconditional Win32 walk after the POSIX loop). Suggested fix: follow the ps_dead pattern that fm-branch-outcome.sh:412 already uses, so each walk falls back only when its ownps -oread failed. For the pid-liveness checks, fall back only when ps -o is proven unusable, not just because kill -0 failed.bin/fm-spawn.sh:4108- Every herdr spawn now probesfm_backend_herdr_foreground_cwd_supported. Any miss sends the spawn into the Windows arm, and that arm exits 1 immediately when cygpath is missing. Failure scenario: on Linux or macOS herdr, a transientpane geterror, target_ready failure, or a pane that still reports a null foreground_cwd after the 3s retry window now aborts the spawn with the misleading error 'cannot report a live foreground cwd and no cygpath exists'. Before this change, the 60streehouse getdiscovery poll tolerated that. Fix: take the Windows arm only on a host that can run it, for examplecommand -v cygpathin the gate before the probe. Otherwise fall through to the existing discovery poll.bin/backends/herdr.sh:808- Simplification / scope.fm_backend_herdr_presentation_lock_namespace_validnow repairs a non-700/tmp/firstmate-herdr-presentation(chmod 700, then accept) instead of refusing it, on every host. The intent asks only for handling Windows' lack of ACL mode bits (chmod has no effect there). Accepting a namespace that was group- or world-writable on POSIX goes beyond that. Entries another local user planted while it was open survive the chmod and are then trusted as presentation locks. Recommendation: keep only the narrower rule. Use the chmod no-op probe to detect filesystems that ignore mode bits and accept on ownership there; on hosts where chmod takes effect, keep refusing a namespace that was not 700.tests/fm-devin-harness.test.sh:55- The fabricated-table case is written asFM_TEST_OWN_WINPID=500 FM_TEST_WIN32_TABLE=... PATH="$fakebin:$PATH" out=$(...). That line only assigns variables, so FM_TEST_OWN_WINPID and FM_TEST_WIN32_TABLE become unexported shell variables and never reach the fake ps or powershell.exe. The fake ps then fails on${FM_TEST_OWN_WINPID:?}, and the fake powershell prints an empty table. The Win32 path this case claims to isolate never runs, so the negative check passes trivially. PATH also stays pointed at the fakebin (whose ps rejects -o) for the rest of the file, including the fm-busy-event.sh and fm-devin-config.sh cases. Fix: move the assignments inside the substitution as a command prefix, e.g.out=$(FM_TEST_OWN_WINPID=500 FM_TEST_WIN32_TABLE="..." PATH="$fakebin:$PATH" "$TMP_ROOT/names/devin-helper" -c ... ), or useenv.🔧 Fix applied.
2 warnings still open:
bin/fm-harness.sh:308- Intent conformance. The intent says 'healthy POSIX hosts take byte-identical verdict paths and fallbacks only fire when the ps read itself fails'. In the code, though, the Win32 fallback runs whenever a POSIX walk finds no match, or wheneverkill -0fails on an ordinary dead pid, not only when ps fails. Failure scenario: on WSL, powershell.exe is on PATH through interop. A walk that finds no harness, or a stale-lock liveness check on a dead Linux pid, then starts powershell.exe (seconds of latency). It also looks the Linux pid up in the Windows process table as if it were a Win32 pid: on Linux, fm_win32_ancestor_winpids reuses $$ as the seed becauseps -lcolumns differ. A dead Linux lock-holder pid that happens to match the pid of a Windowsclaude.exe/codexprocess (for example Claude Desktop) is then reported as a live harness, which wedges the lock. On plain Linux and macOS every miss also costs an extraps -lfork. Same invariant at: fm-harness.sh:171 (ancestry_names_omp falls back after a normal walk end); fm-session-lock-lib.sh:184 (fm_harness_ancestry_pids falls back whenever printed=0); fm-session-lock-lib.sh:223 (fm_harness_pid_alive falls back on any kill -0 failure); fm-sessionstart-nudge.sh:38 (kill -0 || fm_win32_pid_alive) and :50 (unconditional Win32 walk after the POSIX loop). Suggested fix: follow the ps_dead pattern that fm-branch-outcome.sh:412 already uses, so each walk falls back only when its ownps -oread failed. For the pid-liveness checks, fall back only when ps -o is proven unusable, not just because kill -0 failed.bin/fm-harness.sh:318- This was in the original change, not added by the fix round. On a Git Bash/MSYS host each Win32 fallback walk starts PowerShell twice, although the lib's contract says the table loads once per process. The ancestor list is built withfor winpid in $(fm_win32_ancestor_winpids ...). The command substitution is a subshell: fm_win32_ancestor_winpids calls fm_win32_proc_load there, and the cached table and _FM_WIN32_ROW are thrown away when the subshell exits. The loop body then calls fm_win32_proc_get in the parent, which finds _FM_WIN32_TABLE_LOADED=0 and runs Get-CimInstance again. Each fallback walk therefore pays about 2×200-400ms, and these walks run in hooks on every turn. Same pattern at: fm-harness.sh:181 (_fm_ancestry_names_omp_win32), fm-harness.sh:345/379 (fm_win32_proc_pairs in a substitution, then fm_win32_proc_get in the parent), and fm-session-lock-lib.sh:117 (_fm_harness_ancestry_pids_win32). fm-sessionstart-nudge.sh:50 and fm-branch-outcome.sh:424 avoid it only when an earlier parent-side fm_win32_pid_alive call has already loaded the table. Fix: callfm_win32_proc_load || return ...in the parent before each$(fm_win32_ancestor_winpids)/$(fm_win32_proc_pairs)substitution, so the subshell inherits the loaded table. That call is already gated by fm_win32_proc_available, so POSIX hosts are unaffected.🔧 Fix applied.
✅ Re-checked - no issues remain.
git -C ~\.no-mistakes\worktrees\c02c87ead702\01M38ZEEQWQH82T97JZCDWHS9X statusandgit -C ~\.no-mistakes\worktrees\c02c87ead702\01M38ZEEQWQH82T97JZCDWHS9X diff). Respond with fix to validate it, or abort.🔧 No changes applied.
2 infos still open:
tests/fm-sessionstart-nudge.test.sh:266- test_opencode_plugin_delivers_exact_nudge_once cannot pass on native Windows: Node's child_process.spawn of bin/fm-sessionstart-nudge.sh fails with EFTYPE/ENOENT because Windows cannot exec a shebang script, so no prompt is delivered. Because the suite exits at the first failure, the rest of fm-sessionstart-nudge.test.sh never runs here. This is a limitation of the host and the plugin, not of this change, and the intent does not cover OpenCode-plugin Windows support.tests/fm-sessionstart-nudge.test.sh:1160- test_run_startup_runs_the_full_digest fails on this Git Bash host ('startup did not run the full digest'), and it fails the same way at base 9284978, so this branch did not cause it. It is left for CI and any later Windows follow-up.bash tests/fm-sessionstart-nudge.test.sh(worktree): it passes through the owned-lock and Win32-walk cases, then stops at the OpenCode delivery case (Node EFTYPE, see findings)bash tests/fm-sessionstart-nudge.test.shwith only the OpenCode Node-spawn case disabled, in a temporary copy that was then deleted: all cases up to test_run_startup_runs_the_full_digest passThe same suite at base 9284978 (via git archive into /tmp): test_owned_lock_is_silent fails there ('owned lock nudge must be silent'), and test_run_startup_runs_the_full_digest fails the same way it does on the branchbash tests/fm-cursor-primary.test.sh: stops immediately because the host has no C compilerLive nudge-hook demo: a fixture primary staged with and without the lib, and .lock set to $$, the shell's WINPID, and a dead WINPIDChecked that the tools the other suites need (tmux, pi, cc/gcc/clang) are on PATH: all are missinggit commitof the five test-file repairs (cc5af92)✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.