Skip to content

fix: read Windows-tagged session locks in the remaining lock readers - #7705

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
cr101:fix/tagged-lock-readers
Oct 24, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
cr101:fix/tagged-lock-readers

Conversation

@cr101

@cr101 cr101 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4535
Fixes #4539

Piece 2 of the #4803 split, after #6300. These readers go as their own small PR as suggested in #4803 (comment).

Scope notes

Intent

Start piece 2 of the #4803 split: the remaining tagged-lock readers (#4535, #4539) plus the one-file test cleanup fix, published upstream as one PR.

Context for reading that ask:

What Changed

  • bin/fm-turnend-guard-cursor.sh: the owner check, the stale-owner reclaim fallback, and the owner read before parking now use fm_session_pid_valid instead of numeric-only case tests. A Windows-tagged win:<pid> lock now counts as a valid identity, so the current Cursor session is recognized as owner and a dead tagged holder can be reclaimed through fm_harness_pid_alive and bin/fm-lock.sh.
  • bin/fm-wake-lib.sh: fm_extension_pair_owns_supervision checks a win:-tagged lock holder by loading fm-session-lock-lib.sh on demand and calling fm_session_pid_valid + fm_harness_pid_alive, instead of kill -0. A live tagged holder no longer gets reported as supervision-off. Untagged values still go through fm_pid_alive, so POSIX homes behave the same as before.
  • The Pi extensions (fm-branch-supervision.ts, fm-primary-pi-watch.ts, fm-primary-turnend-guard.ts) each add a lockHolderPid helper. On win32 it strips the win: tag, and any value that isn't a pid other than 1 becomes no identity. The ancestry match and liveness probe use those digits, and the branch-supervision lease still records the lock value with its tag. New regression tests for tagged locks are in the Cursor guard, turn-end guard, stale-banner, Pi branch and Pi watch suites.

Risk Assessment

✅ Low: The reader changes are small and send lock reads through fm_session_pid_valid/fm_harness_pid_alive as intended. Behaviour on POSIX is unchanged, and new behavioural tests cover owned, dead, live-other, malformed and non-Windows cases. The only gap is that the intended test-cleanup piece is missing.

Testing

Earlier Test turns already confirmed the Cursor guard, the wake-lib extension-pair verdict, and the Pi branch-supervision extension. This turn ran only the two remaining single test functions. Each one loads the real Pi extension module in Node, writes a real state/.lock with tagged values, and fakes process.platform. Both pass on the target commit. Both fail on the base extensions: the base arm refuses this session's own win: lock, and the base turn-end guard records no owner marker. That shows the fix closes the #4539 Pi reader gap. Text logs were saved to the evidence directory. There is no UI surface, so there are no screenshots. The scratch file was removed and the worktree is clean.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
On Windows, a Pi primary holding win:&lt;own pid&gt; in state/.lock can arm its watcher. It is refused for a dead tagged holder, a live foreign tagged holder, malformed tagged values, and a tagged lock of… ✅ pass live test_pi_arm_reads_a_windows_tagged_session_lock: target-pi-arm-tagged-lock.log passes; base-pi-arm-tagged-lock.log fails
On Windows, the Pi turn-end guard recognizes win:&lt;own pid&gt; as this session's lock and records its owner marker. It stays inert on non-Windows and for non-owned tagged values ✅ pass live test_pi_extension_reads_a_windows_tagged_session_lock: target-pi-turnend-tagged-lock.log passes; base-pi-turnend-tagged-lock.log fails ('owned tagged lock (win32) did not record this process's marker'…
Evidence: Target: Pi watcher arm, tagged lock (pass)

Source: Target: Pi watcher arm, tagged lock (pass)

ok - Pi watcher arm reads a Windows-tagged session lock only on Windows

ok - Pi watcher arm reads a Windows-tagged session lock only on Windows

real	0m5.233s
user	0m1.030s
sys	0m2.393s
Evidence: Target: Pi turn-end guard, tagged lock (pass)

Source: Target: Pi turn-end guard, tagged lock (pass)

ok - .pi primary extension: the turn-end guard reads a Windows-tagged session lock only on Windows

ok - .pi primary extension: the turn-end guard reads a Windows-tagged session lock only on Windows

real	0m2.110s
user	0m0.392s
sys	0m1.012s
Evidence: Base: Pi watcher arm, tagged lock (fails as expected)

Source: Base: Pi watcher arm, tagged lock (fails as expected)

not ok - Pi watcher arm must read a Windows-tagged session lock only on Windows: expected exit 0, got 1

not ok - Pi watcher arm must read a Windows-tagged session lock only on Windows: expected exit 0, got 1
Evidence: Base: Pi turn-end guard, tagged lock (fails as expected)

Source: Base: Pi turn-end guard, tagged lock (fails as expected)

Error: an owned tagged lock (win32) did not record this process's marker: ""

not ok - Pi turn-end guard misread a Windows-tagged session lock (exit 1): file:///C:~/.no-mistakes/worktrees/0667e0267d79/01M5NEYWA02FWKSDC28JQ45V79/[eval1]:46
      throw new Error(`${label} (${name}) did not record this process's marker: ${JSON.stringify(content)}`);
            ^

Error: an owned tagged lock (win32) did not record this process's marker: ""
    at file:///C:~/.no-mistakes/worktrees/0667e0267d79/01M5NEYWA02FWKSDC28JQ45V79/[eval1]:46:13
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)

Node.js v26.12.0
  • Outcome: 🔧 2 issues found → no changes applied ✅ across 2 runs (31m57s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 issues (1 warning, 1 info)
🔧 **Test** - 2 issues found → no changes applied ✅
  • ⚠️ The Test agent did not finish within its invocation budget. Reported: agent run tests timed out after 30m0s (silent budget; no still-working cap is set; ran 30m0s): agent last produced output 17s ago (102 observed); agent reported: claude exited: exit status 1:. This is a budget or provider-slowness cut, not a code failure. Re-running the same request costs another full budget, so no further attempt is made automatically. If this repository's targeted tests or evidence gathering routinely stay quiet longer than the default 30m0s, raise test_agent_timeout in global config. If the turn was still producing output or running a child process, set or raise test_agent_working_timeout there instead: a turn runs past test_agent_timeout only up to that still-working cap. Respond with fix to spend another budget: a repair turn runs only for selected findings other than this budget cut, then validation re-runs. Or abort and retry after raising the budget.
  • 🚨 Approval is refused: the run worktree at ~.no-mistakes\worktrees\0667e0267d79\01M5NEYWA02FWKSDC28JQ45V79 holds work no Test turn validated, and the steps after Test would commit and publish it. It holds uncommitted changes to tests/.one.sh (inspect with git -C ~\.no-mistakes\worktrees\0667e0267d79\01M5NEYWA02FWKSDC28JQ45V79 status and git -C ~\.no-mistakes\worktrees\0667e0267d79\01M5NEYWA02FWKSDC28JQ45V79 diff). Respond with fix to validate it, or abort.

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
On Windows, a Pi primary holding win:&lt;own pid&gt; in state/.lock can arm its watcher. It is refused for a dead tagged holder, a live foreign tagged holder, malformed tagged values, and a tagged lock of… ✅ pass live test_pi_arm_reads_a_windows_tagged_session_lock: target-pi-arm-tagged-lock.log passes; base-pi-arm-tagged-lock.log fails
On Windows, the Pi turn-end guard recognizes win:&lt;own pid&gt; as this session's lock and records its owner marker. It stays inert on non-Windows and for non-owned tagged values ✅ pass live test_pi_extension_reads_a_windows_tagged_session_lock: target-pi-turnend-tagged-lock.log passes; base-pi-turnend-tagged-lock.log fails ('owned tagged lock (win32) did not record this process's marker'…
  • rm tests/.one.sh (removed the earlier Test turn's scratch copy, as the operator asked)
  • test_pi_arm_reads_a_windows_tagged_session_lock from tests/fm-pi-watch-extension.test.sh, run alone through a temp runner that sources the suite's preamble, on the target commit: ok
  • test_pi_extension_reads_a_windows_tagged_session_lock from tests/fm-turnend-guard.test.sh, run alone the same way, on the target commit: ok
  • Both functions again with the base (47bd9a1f) versions of .pi/extensions/fm-primary-pi-watch.ts and .pi/extensions/fm-primary-turnend-guard.ts swapped in temporarily: both fail as expected, then the files were restored with git checkout -- .pi/extensions
  • git status --short afterwards: empty
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

A Windows/Git Bash home records its session in state/.lock as a tagged
win:<pid>, and fm_session_pid_valid owns whether a lock value is a usable
identity. Several readers still decided that with a private numeric test,
so a correctly locked Windows home read as malformed:

- bin/fm-turnend-guard-cursor.sh (kunchenguid#4535): the owner check, the stale-owner
  reclaim fallback, and the owner read before parking. The Cursor park now
  recognizes its own tagged lock and reclaims a dead tagged holder's lock;
  liveness was already answered by fm_harness_pid_alive.
- fm_extension_pair_owns_supervision in bin/fm-wake-lib.sh (kunchenguid#4539): a live
  tagged session read as dead, which printed the supervision-off banner
  during a healthy Pi extension hand-off. A win:-shaped value now loads the
  session-lock library and is answered by fm_session_pid_valid and
  fm_harness_pid_alive; a POSIX value keeps the existing kill -0 test.
- The three .pi/extensions lock readers (kunchenguid#4539): on win32 only, a strict
  win:<digits> value is compared and probed by its digits, because native
  Node sees Windows pids directly. pid 1 stays rejected, and the branch
  extension keeps the tagged value whole for its lease holder.

Malformed tags, and any tag off Windows, are still rejected. Regressions
cover each reader with a faked Windows process table or platform, so they
run on every host.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @cr101. Splitting #4803 into small pieces like this makes it much easier to review, and the base-fails / target-passes evidence for each Pi arm is exactly what I wanted to see.

What I checked: head a59368cb against main 98f3bd84 (mergeable; the no-mistakes attestation binds this head, live 2 of 2 go). I checked the closing claims against the issues myself:

So Fixes #4535 and Fixes #4539 hold. Leaving the .omp copies for a follow-up is reasonable, since neither issue names them. Nothing touches workflows, credentials or the network.

Contract-class (my own read): restore. #6300 already made win:<pid> a legitimate state/.lock identity, and fm_session_pid_valid was already its single owner. These readers were the specified default path that still broke on it, and nothing changes on POSIX. VISION.md per rule: One captain aligns (no captain-facing change) · Authority aligns (no new consent path; reclaim still goes through bin/fm-lock.sh) · Scripts aligns (one deterministic predicate owns lock identity) · Restart aligns (a dead tagged holder can now be reclaimed, so a Windows restart recovers) · Delegation aligns (behavioral regressions for the owned, dead, live-other, malformed and non-Windows cases) · Vendor aligns (Cursor and Pi adapters only) · Scope aligns.

Where it stands: everything is green except Behavior portable serial 1, which was cancelled at its 30-minute limit. Main is hitting that limit too right now, so it's not on you, and I've re-run the failed job. You don't need to do anything. If it comes back green, this is on the merge path.

@kunchenguid
kunchenguid merged commit f6b54af into kunchenguid:main Oct 24, 2026
37 of 38 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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

Serial 1 came back green on the re-run, so a59368cb was 19/19 green and CLEAN, with the no-mistakes attestation bound to it. Contract-class: restore (the win:<pid> lock identity was already specified, and these readers broke on it). It landed as f6b54af1. The .omp copies are still open for a follow-up if you'd like to take them on.

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

Labels

None yet

Projects

None yet

2 participants