Skip to content

fix(bin): accept tagged Windows session-lock holders - #7746

Merged
kunchenguid merged 3 commits into
kunchenguid:mainfrom
ironerumi:fm/up-fm-7739-winpid
Oct 27, 2026
Merged

kunchenguid merged 3 commits into
kunchenguid:mainfrom
ironerumi:fm/up-fm-7739-winpid

Conversation

@ironerumi

@ironerumi ironerumi commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Open the upstream pull request for #7739, which the maintainer confirmed against main 842eab1 and labelled ready-for-pr. On Windows/Git Bash the session lock records its holder as a tagged win:<pid> (#6300), but three readers still pass the raw lock value into the numeric-only fm_pid_alive / fm_pid_identity in bin/fm-wake-lib.sh: fm_supervision_host_main_key (bin/fm-supervision-engine-lib.sh) gets no key, so attended wakes go to main; fm_autoarm_claim_next records no lock-holder identity and drops owner_session_id; and fm_autoarm_claim_open rejects a non-numeric lock, so a live Claude Stop auto-arm claim is never seen as open and the next firing double-arms. The maintainer asked for the Cygwin-fake tests, real Git Bash evidence for the three readers, untagged values falling straight through to the current helpers so POSIX stays unchanged, and submission through git push no-mistakes.

What Changed

  • Add tagged Windows session-lock liveness and identity handling, including win:<pid> support for the supervision-host session key and Claude auto-arm claim consumers.
  • Preserve numeric helper behavior for untagged lock values and add Cygwin/Git Bash regression coverage for live, exited, and reused Windows PIDs.
  • Document Windows session-lock ownership and the expanded auto-arm regression coverage.

Risk Assessment

✅ Low: The change is contained to the existing Windows session-lock boundary, routes all four affected readers through it, preserves numeric fallback behavior, and adds behavioral fake-Cygwin coverage.

Testing

Drove the real lock, supervision, and auto-arm shell libraries with disposable Cygwin/MINGW and POSIX boundaries and captured the focused behavior log. The focused scenarios passed, but the explicit real Git Bash evidence requirement could not be exercised because this host is Darwin and has no Windows compatibility runtime; an adjacent supervision-host suite also exceeded the command timeout.

  • Live validation: ⚠️ inconclusive - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Cygwin-fake supervision host main key accepts a live win:<pid> lock and rejects gone or reused holders ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Cygwin-fake Claude auto-arm claim pins and reads back a win:<pid> holder ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Cygwin-fake auto-arm mid-turn health follows a win:<pid> holder ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Untagged lock values preserve numeric helper behavior ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Real Git Bash evidence covers all three Windows lock readers ⏸️ untested no Tried the available host toolchain and checked for known Git Bash/Cygwin/WSL entry points. No Windows Git Bash runtime or Windows host authority is available in this Darwin run. Providing a Windows ma…
Evidence: Windows session-lock consumer behavior

Source: Windows session-lock consumer behavior

ok - untagged lock values: the session-pid helpers answer exactly as fm_pid_identity and fm_pid_alive do
ok - supervision host: a win:<pid> session lock yields the main-session key only while that Windows process lives
ok - auto-arm: a claim pins a win:<pid> lock holder and reads open only while that holder lives
ok - auto-arm: mid-turn health accepts a rewake bound to a live win:<pid> holder and drops it when that holder exits
- Outcome: ⚠️ 2 warnings across 1 run (4m12s)

Readers fixed

All four numeric-only readers of the session lock now go through fm_session_pid_identity / fm_session_pid_alive in bin/fm-session-lock-lib.sh: fm_supervision_host_main_key, fm_autoarm_claim_next, fm_autoarm_claim_open, and fm_autoarm_midturn_healthy, which the issue triage also lists among the verified numeric-only readers.
A tagged win:<pid> is decoded only on a Cygwin-family host; every untagged value goes unchanged to the existing fm_pid_identity / fm_pid_alive, and the parity case in tests/fm-session-lock-windows-consumers.test.sh asserts identical exit codes and output for live, dead, empty, non-numeric, and off-Windows tagged values.

Windows evidence

Real Git Bash cannot run on the Darwin host that validated this head.
Evidence: the Cygwin-fake checks in tests/fm-session-lock-windows-consumers.test.sh plus the reporter's real MINGW64 run of the same reader fix on fork commit 55cb6d4 (session lock win:12864; each reader failed before the fix and passed after).
fm_autoarm_midturn_healthy has fake-only evidence.
A real Git Bash run on this exact head will be posted as a PR comment.

Against unfixed origin/main bin/, each Cygwin-fake reader case fails: no main-session key for a live win:7204 holder, the auto-arm claim drops owner_session_id, and mid-turn health reads a live holder as unhealthy.

Known unrelated flake

tests/fm-supervision-host.test.sh case test_undelivered_dialog_is_fed_again_on_the_next_turn (mirror boundary) is load-sensitive on a heavily loaded macOS host (load average about 20).
On this branch it failed once in the full suite and 1 of 3 isolated reruns; on unchanged origin/main bin/ it failed 3 of 3 isolated reruns under the same load, so it is not caused by this change.
Every other case in that suite passed on this branch.

Fixes #7739

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ The required real Git Bash evidence for the supervision-host main key, auto-arm claim read-back, and auto-arm mid-turn health could not be collected. This run is on Darwin, and the available environment has no Git Bash/Cygwin/WSL executable (git-bash.exe, bash.exe, cygpath, or wsl.exe) to provide that platform boundary. Re-run the three-reader scenarios on a Windows host with Git for Windows/Git Bash, or explicitly accept the Cygwin-fake evidence only.
  • ⚠️ live validation verdict: inconclusive (4 of 5 scenarios were driven live against the product); untested: Real Git Bash evidence covers all three Windows lock readers
  • Live validation: ⚠️ inconclusive - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Cygwin-fake supervision host main key accepts a live win:<pid> lock and rejects gone or reused holders ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Cygwin-fake Claude auto-arm claim pins and reads back a win:<pid> holder ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Cygwin-fake auto-arm mid-turn health follows a win:<pid> holder ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Untagged lock values preserve numeric helper behavior ✅ pass live ~/.no-mistakes/evidence/01M5S411T173NERP9JSGR0QWC3/windows-consumers.log
Real Git Bash evidence covers all three Windows lock readers ⏸️ untested no Tried the available host toolchain and checked for known Git Bash/Cygwin/WSL entry points. No Windows Git Bash runtime or Windows host authority is available in this Darwin run. Providing a Windows ma…
  • bash tests/fm-session-lock-windows-consumers.test.sh
  • bash tests/fm-session-lock-ancestry.test.sh
  • bash tests/fm-claude-stop-autoarm.test.sh
  • bash tests/fm-supervision-host.test.sh (timed out at 180 seconds)
  • command -v git-bash.exe bash.exe cygwin mintty cygpath pwsh.exe wsl.exe
  • git status --short
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…st and Claude auto-arm

On Git Bash the session lock records its holder as a tagged win:<pid>
(kunchenguid#6300), but four readers still passed that value to the numeric-only
fm_pid_identity and fm_pid_alive: fm_supervision_host_main_key produced no
key, fm_autoarm_claim_next pinned no lock-holder identity and dropped
owner_session_id, fm_autoarm_claim_open rejected the non-numeric lock so a
live claim never read as open, and fm_autoarm_midturn_healthy read a live
holder as lapsed.

Add fm_session_pid_alive and fm_session_pid_identity beside the tagged-pid
contract in fm-session-lock-lib.sh. A tagged pid is answered from the
Windows process table; every other value falls straight through to the
existing numeric helpers, so POSIX behaviour is unchanged. The claim
read-back checks the lock shape with fm_session_pid_valid.

tests/fm-session-lock-windows-consumers.test.sh covers each reader on a
faked Git Bash host, including an exited holder, a reissued Windows pid,
and the tag off Windows, plus a parity case proving untagged values get
exactly the numeric helpers' answers.

Fixes kunchenguid#7739
…res to copy fm-session-lock-lib.sh alongside fm-supervision-engine-lib.sh in all three affected paths. The focused host/latch tests and tests/fm-session-lock-windows-consumers.test.sh pass; the full afk-return suite exceeded the 180s local timeout after earlier cases passed
@ironerumi

Copy link
Copy Markdown
Contributor Author

CI on a7d42e3: 18 of 19 checks pass; Behavior portable serial 1 was cancelled at the 30-minute job limit, the known upstream portable-serial timeout that also cancelled on upstream main's runs for 147b267 and 842eab1.

The first CI round on 2f85082 had three failures, each reproduced locally on the branch and on upstream main 147b267:

CI job Test Branch upstream main 147b267 Verdict
Behavior portable serial 9 tests/fm-afk-return.test.sh - "could not compute the latch key" fails passes Caused by this change: partial-bin/ fixtures lacked fm-session-lock-lib.sh, which fm_supervision_host_main_key now loads; fixed in a7d42e3, serial 9 now passes
Behavior portable serial 4 tests/fm-watcher-lock.test.sh - "recovery drain after forced arm interruption failed" passes passes Not reproducible on either; unrelated to the changed readers
Behavior portable serial 3 tests/fm-remote-reply.test.sh - "the NUL-bearing line was not captured" passes fails ("the remote reply delta was not durably captured") Flaky on upstream main too; unrelated

Both serial 3 and serial 4 pass on a7d42e3.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @ironerumi, this is a tidy, well-tested fix and it follows the plan from #7739 closely.

What I checked on head a7d42e33 (it sits directly on main 147b2672):

  • All four readers now go through fm_session_pid_identity / fm_session_pid_alive in bin/fm-session-lock-lib.sh: fm_supervision_host_main_key, fm_autoarm_claim_next, fm_autoarm_claim_open and fm_autoarm_midturn_healthy. fm_autoarm_claim_open now uses fm_session_pid_valid where it used to have the numeric case.
  • Untagged values fall straight through to fm_pid_alive / fm_pid_identity. fm_session_pid_valid accepts exactly the same untagged values as the old case. Off Windows, a win: value is still inert through fm_win_untag_pid, so POSIX behaviour doesn't change.
  • I ran tests/fm-session-lock-windows-consumers.test.sh and tests/fm-claude-stop-autoarm.test.sh locally and both pass. tests/fm-session-lock-ancestry.test.sh and tests/fm-afk-return.test.sh each have one failure on my box, but the same failure shows up on unchanged main there, so it comes from my environment and not from this change. Serial 9 is green in CI.
  • I found no security concerns: no workflow edits and nothing that reaches the network.

VISION.md:

  • One captain, one interface: aligns. Attended wakes stop going to main by mistake on Windows.
  • Authority is explicit: aligns. A reused Windows pid is still paired with the session sidecar id, so it can't pass as the same session.
  • Scripts own the mechanics: aligns. This is deterministic helper routing.
  • A restart is a non-event: aligns. A live Windows session no longer reads as dead or unidentifiable.
  • Delegation with a spine: neutral.
  • The fleet outlives any vendor: aligns. Git Bash gets the same treatment as POSIX.
  • Scope: aligns.

Contract-class (mine): restore. Tagged Windows session locks are an existing, specified path (#6300), and these readers broke it. Unconfigured POSIX runs are unchanged.

Status:

  • The no-mistakes attestation is bound to this head.
  • CI is 18/19. Serial 1 was cancelled at the 30-minute cap, which is the known main-inherited timeout, so I've rerun it (run 40182198988, attempt 2).
  • The one thing still open is live evidence. As your body says, the real Git Bash scenario is untested on this head. When you get the chance, could you post the MINGW64 run of the three readers on a7d42e33 that you mentioned? Re-raising through git push no-mistakes from a Windows host works too. Once that's here and CI is green, this can land as a restore. For now it's waiting on you, no rush.

@ironerumi

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Here is what the real Git Bash run showed, and why it can't produce the evidence you asked for on this base.

Run on a7d42e33 (MINGW64_NT-10.0-26200, bash 5.3.9, no Developer Mode, no admin rights on the box): the probe's first check (bin/fm-lock.sh acquire) never returned and hit the 600 s timeout, so the three reader checks never ran.

Why: on main, fm_lock_try_create in bin/fm-wake-lib.sh takes the lock only through ln -s "$ownerdir" "$lockdir" followed by fm_lock_points_to_owner. Under MSYS without native symlink support, ln -s copies instead of linking, so the readlink comparison always fails, fm_lock_try_create returns 1 on every pass, and fm_lock_acquire_wait spins until the timeout. The session lock is never taken, so nothing downstream of it, including the readers this PR changes, can be exercised. This is independent of this PR's diff.

What we do have: the same reader change runs in our fork (ironerumi/firstmate) on top of a lock-publish fallback for non-symlink filesystems. On that build (55cb6d49), the same probe on the same Windows box passed:

Check Result
1 session lock acquire / refuse / reclaim (win:<pid> holder) PASS
2a node admission FAIL (expected: POSIX-only by design)
2b directory-lock contention and reclaim PASS
3a supervision key PASS (win:<pid>:<start>:<sid>)
3b auto-arm claim PASS (ledger records win-pid=)
3c mid-turn health PASS

Before this change, 3a, 3b and 3c failed on that box.

So live Git Bash evidence for this PR on upstream main is blocked by the core lock, not by the readers. If it's useful, I can open a separate issue and PR that upstream the lock-publish fallback, so Git Bash homes can take the session lock at all. After that, this PR can be re-proven live on Windows without fork code.

@kunchenguid
kunchenguid merged commit 7da4c36 into kunchenguid:main Oct 27, 2026
36 of 37 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @ironerumi — really appreciate you taking the time on this.

Thanks also for the honest Git Bash write-up. The readers are proven on your fork build (3a/3b/3c fail before and pass after), and on upstream the run stops earlier, at the ln -s session-lock acquire, which is a separate gap outside this diff. Landed as a restore of the tagged Windows session-lock path (#6300): CI green, attestation bound to a7d42e33, POSIX unchanged. A separate issue and PR for the non-symlink lock-publish fallback would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows session lock (win:<pid>) is rejected by the supervision host and the Claude auto-arm

2 participants