Skip to content

feat(bin): sync upstream improvements and harden Windows support - #2

Merged
jiroamato merged 37 commits into
mainfrom
feat/upstream-sync-windows-fixes
Aug 18, 2026
Merged

jiroamato merged 37 commits into
mainfrom
feat/upstream-sync-windows-fixes

Conversation

@jiroamato

@jiroamato jiroamato commented Aug 17, 2026 •

Copy link
Copy Markdown
Owner

Intent

Optimize the firstmate fork for Windows and update the existing PR #2 (branch feat/upstream-sync-windows-fixes, do not open a new PR). The branch contains: (1) an upstream sync of 19 cherry-picks from kunchenguid/firstmate through kunchenguid#2488, deliberately excluding the Cursor CLI harness commits (kunchenguid#2238, kunchenguid#2305) and the Calm presentation commits (kunchenguid#2334, kunchenguid#2339, kunchenguid#2461); (2) Windows fixes for open upstream community requests: bin/fm-path-lib.sh path translation that refuses to guess (groundwork for upstream kunchenguid#1667), a spawn pane probe for the cwd-blind nested cmd.exe case (upstream kunchenguid#1796), lock truthfulness via procfs cross-check plus bounded lock waits that refuse loudly on timeout (upstream kunchenguid#1508), boot-tick sender identity from /proc starttime+cmdline with a legacy compare for the upgrade window (upstream kunchenguid#433), FM_HARNESS_DECLARED verified declared-identity fallback (upstream kunchenguid#2307), and capability-probed private file modes adopting the probe from upstream PR kunchenguid#2378 - strict 0600 stays wherever the filesystem provably holds POSIX modes; (3) three fixes from running the suites on a real Windows host: adapter busy-event writers now invoke bin/fm-busy-event.sh via bash because native Windows node cannot execFile a shebang .sh and the fire-and-forget callback swallowed the failure (Pi/OpenCode busy wiring was silently dead on Windows); busy-signature matching pinned to LC_ALL=C because MSYS grep 3.0 misses the Kimi moon-phase emoji alternation with -i under a UTF-8 locale (busy Kimi read as idle); and three test suites made truthful on hosts they describe (POSIX-mode sections gated on a probe-by-doing capability check, the legacy lstart identity case gated on ps -o lstart support, the settle confirm asserted as exact pane-poll count instead of a wall-clock bound), plus the Kimi capture-fallback test's subshell body now propagates its failure instead of printing not-ok while the suite reports success. Deliberate choices a reviewer should not flag: test gates skip only where the host provably lacks the capability, so Linux/macOS CI coverage is unchanged; wall-clock assertions were replaced with count assertions by design; the excluded Cursor and Calm upstream commits are intentional.

What Changed

  • Cherry-picked 19 upstream firstmate changes through feat(stow): add open-record persistence to /stow before reset kunchenguid/firstmate#2488, including the deterministic condition-to-action watcher (bin/fm-procevent-when.sh), inactive-crew reconciliation (bin/fm-inactive-reconcile.sh), decision-hold decline/repair paths, Relay conversation-chain support, and /stow open-record persistence; the Cursor CLI harness and Calm presentation commits are deliberately excluded.
  • Hardened Windows support in bin/: a new fm-path-lib.sh Windows/WSL path translation library that refuses to guess, a spawn pane probe for cwd-blind nested cmd.exe, procfs-cross-checked pid liveness with bounded lock waits that fail loudly on timeout, boot-tick sender identity from /proc starttime+cmdline with a legacy-compare upgrade window, an FM_HARNESS_DECLARED declared-identity fallback, and a new fm-state-capability-lib.sh that probes the filesystem before relaxing strict 0600 private-mode checks.
  • Fixed three real-Windows-host failures (adapter busy-event writers now invoke fm-busy-event.sh via bash since native Windows node cannot execFile a shebang script, busy-signature matching pinned to LC_ALL=C, and Windows-facing test suites gated on probe-by-doing capability checks with the settle confirm asserted as an exact pane-poll count), and updated docs plus the README badge to declare Windows support experimental.

Risk Assessment

✅ Low: The fix round correctly closes both prior findings with the branch-wide refusal contract, every caller tolerates the new failure return, a genuine fail-before/pass-after behavioral regression test covers it, and a sweep of all fm_lock_acquire_wait call sites confirms no remaining unlocked-proceed path.

Testing

Ran the full targeted suite set for the Windows fixes across both rounds: 9 suite executions plus three manual host repros, ending with fm-pending-reply and fm-busy-adapter-wiring re-run to completion at the target commit (40 ok / 0 failures) and fm-wake-queue passing 19/19 at the same tree; the one real failure found (wake-queue on Windows) was fixed in target commit fdb778f and verified, and all evidence logs are in the phase evidence directory.

Evidence: pending-reply + busy-adapter-wiring at target commit fdb778f (2 suites, 0 failed)

Source: pending-reply + busy-adapter-wiring at target commit fdb778f (2 suites, 0 failed)

FM_TEST_BEGIN 2026-08-18T16:46:09Z tests/fm-pending-reply.test.sh FM_TEST_BEGIN 2026-08-18T17:13:02Z tests/fm-busy-adapter-wiring.test.sh FM_TEST_SUMMARY total=2 failed=0 skipped_gate=0 duration_ms=1819000 EXIT=0 (40 ok / 0 not ok)

FM_TEST_BEGIN 2026-08-18T16:46:09Z tests/fm-pending-reply.test.sh family=unclassified expected_gate_skip=none
ok - normal correlated reply resolves once (idempotent)
ok - completed turn with no report triggers exactly one recovery
ok - recovery attempts reconcile without reinjection
ok - recovery reply resolves the original expectation
ok - second missed turn escalates once and remains durable
ok - escalations and replies wake; the home's own escalation close stays quiet
ok - failed escalation publication remains retryable and publishes once
ok - legacy escalation closes under the shared default key
ok - legacy escalation cannot close an unrelated default-key decision
ok - foreign correlated blocker cannot impersonate a pending-reply escalation
ok - concurrent resolution closes one keyed escalation exactly once
ok - concurrent escalation yields to a late correlated reply
ok - transport success cannot masquerade as reply success
ok - undelivered records remain immutable across scan paths
ok - delivery confirmation fallback reconciles durably
ok - unrelated events and stale correlation ids cannot resolve
ok - a procfs host records boot-tick sender identity
ok - boot-tick identity is stable and carries procfs starttime
skip: host ps lacks -o lstart (legacy identity compare)
ok - restart preserves expectation and exact parent destination
ok - wrong-home reports are detected but do not silently acknowledge
ok - direct unmarked captain input creates no expectation
ok - fm-send marked secondmate path creates pending and embeds corr
ok - status-pointed document resolves the expectation
ok - optional helper report resolves without being required for correctness
ok - backend busy/idle observation covers Pi/Claude paths without conversation scrape
ok - tmux and zellij unknown states use bounded capture fallback
ok - pending replies scope Kimi capture fallback by recorded harness
ok - tick skips terminal records and reuses target observations
ok - correlations are reused only for matching open task records
ok - tick end-to-end: miss -> one recovery -> escalate -> durable
ok - failed transport discards undelivered expectation only
ok - all pending-reply tests passed
FM_TEST_END 2026-08-18T17:13:01Z tests/fm-pending-reply.test.sh exit=0 duration_ms=1612000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T17:13:02Z tests/fm-busy-adapter-wiring.test.sh family=unclassified expected_gate_skip=none
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - pi extension reports agent_start busy, settles idle only via ctx.isIdle(), and keeps turn_end a notification
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - pi extension awaits agent_settled before the next agent_start without a test delay
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - pi extension events from a superseded incarnation are rejected as stale
ok - kimi and grok install no unverified semantic wiring and classify through their own gates
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - opencode plugin classifies from session.status, scoped to the latched worker session
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - claude hooks open on UserPromptSubmit and close on Stop, StopFailure, and SessionEnd
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - claude hook events from a superseded incarnation are rejected without breaking the hook
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - codex classifies unknown until a semantic source is verified, never idle or footer-matched
all fm-busy-adapter-wiring tests passed
FM_TEST_END 2026-08-18T17:16:27Z tests/fm-busy-adapter-wiring.test.sh exit=0 duration_ms=205000 gate_skip=false
FM_TEST_SUMMARY total=2 failed=0 skipped_gate=0 duration_ms=1819000
FM_TEST_SUMMARY_FAMILY family=unclassified count=2 duration_ms=1817000 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-pending-reply.test.sh duration_ms=1612000
FM_TEST_SLOWEST rank=2 script=tests/fm-busy-adapter-wiring.test.sh duration_ms=205000
EXIT=0
Evidence: fm-wake-queue passing run at the fdb778f tree (19 ok / 0 failed, 61 min)

Source: fm-wake-queue passing run at the fdb778f tree (19 ok / 0 failed, 61 min)

FM_TEST_BEGIN 2026-08-18T15:39:48Z tests/fm-wake-queue.test.sh family=watcher-wake-lock FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=3665000 EXIT=0

FM_TEST_BEGIN 2026-08-18T15:39:48Z tests/fm-wake-queue.test.sh family=watcher-wake-lock expected_gate_skip=none
ok - an abandoned same-process lock hold is reclaimed; a parent's live hold is not
ok - self-announced appends suppress only their own bytes and fail toward waking
ok - historical annotations replay nothing already announced and keep everything new
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 27 --recovery-generation 360802.1787067780.67OTxd
ok - concurrent append plus drain preserves durable records through acknowledgement
ok - signal written while no watcher runs is caught on next run
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 408704.1787070323.fZ5tNZ
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - stale wake is queued before suppressor state is advanced
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 410358.1787070436.iEi9R9
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - a not-provably-working stale wake is queued before its suppressor is advanced
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 411808.1787070538.RkEiF2
ok - registered custom check output is queued before cadence suppression
ok - concurrent drains replay until one post-handling acknowledgement consumes records
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 4 --recovery-generation 413203.1787070641.5ugVrC
ok - drain collapses obvious duplicate heartbeat and signal records
ok - drain asserts watcher liveness: warns on a lapse, stays silent for a live watcher with a fresh beacon
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 8 --recovery-generation 414004.1787070706.4CKxFE
ok - structural signal enrichment is separate, deduped, home-local, and tier-zero for other wakes
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 13 --recovery-generation 414956.1787070783.zVTcS4
ok - every readable unread status line is annotated in full while invalid status files preserve their raw wakes
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 416616.1787070916.RD5cGA
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 416616.1787070916.RD5cGA
ok - slow annotation releases the append lock and a deleted status file fails open
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation existing
ok - wake append publishes atomic recovery evidence before durable rows
ok - wake drain: generation-less legacy wakes are adopted and acknowledged
ok - wake drain: a stale acknowledgement cannot retire or consume a newer recovery episode
ok - wake drain: recovery acknowledgement failures are explicit and retryable
ok - interruptions preserve durable rows until post-handling acknowledgement
FM_TEST_END 2026-08-18T16:40:52Z tests/fm-wake-queue.test.sh exit=0 duration_ms=3664000 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=3665000
FM_TEST_SUMMARY_FAMILY family=watcher-wake-lock count=1 duration_ms=3664000 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-wake-queue.test.sh duration_ms=3664000
EXIT=0
Evidence: completed pre-fix batch 2 run showing the original Windows wake-queue failure that fdb778f fixed

Source: completed pre-fix batch 2 run showing the original Windows wake-queue failure that fdb778f fixed

FM_TEST_BEGIN 2026-08-18T13:05:52Z tests/fm-wake-queue.test.sh family=watcher-wake-lock expected_gate_skip=none
ok - an abandoned same-process lock hold is reclaimed; a parent's live hold is not
ok - self-announced appends suppress only their own bytes and fail toward waking
ok - historical annotations replay nothing already announced and keep everything new
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 39 --recovery-generation 136381.1787058483.mwSbC9
ok - concurrent append plus drain preserves durable records through acknowledgement
not ok - watcher did not exit for first signal
FM_TEST_END 2026-08-18T13:26:38Z tests/fm-wake-queue.test.sh exit=1 duration_ms=1246000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T13:26:39Z tests/fm-pending-reply.test.sh family=unclassified expected_gate_skip=none
ok - normal correlated reply resolves once (idempotent)
ok - completed turn with no report triggers exactly one recovery
ok - recovery attempts reconcile without reinjection
ok - recovery reply resolves the original expectation
ok - second missed turn escalates once and remains durable
ok - escalations and replies wake; the home's own escalation close stays quiet
ok - failed escalation publication remains retryable and publishes once
ok - legacy escalation closes under the shared default key
ok - legacy escalation cannot close an unrelated default-key decision
ok - foreign correlated blocker cannot impersonate a pending-reply escalation
ok - concurrent resolution closes one keyed escalation exactly once
ok - concurrent escalation yields to a late correlated reply
ok - transport success cannot masquerade as reply success
ok - undelivered records remain immutable across scan paths
ok - delivery confirmation fallback reconciles durably
ok - unrelated events and stale correlation ids cannot resolve
ok - a procfs host records boot-tick sender identity
ok - boot-tick identity is stable and carries procfs starttime
skip: host ps lacks -o lstart (legacy identity compare)
ok - restart preserves expectation and exact parent destination
ok - wrong-home reports are detected but do not silently acknowledge
ok - direct unmarked captain input creates no expectation
ok - fm-send marked secondmate path creates pending and embeds corr
ok - status-pointed document resolves the expectation
ok - optional helper report resolves without being required for correctness
ok - backend busy/idle observation covers Pi/Claude paths without conversation scrape
ok - tmux and zellij unknown states use bounded capture fallback
ok - pending replies scope Kimi capture fallback by recorded harness
ok - tick skips terminal records and reuses target observations
ok - correlations are reused only for matching open task records
ok - tick end-to-end: miss -> one recovery -> escalate -> durable
ok - failed transport discards undelivered expectation only
ok - all pending-reply tests passed
FM_TEST_END 2026-08-18T13:40:36Z tests/fm-pending-reply.test.sh exit=0 duration_ms=837000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T13:40:37Z tests/fm-busy-adapter-wiring.test.sh family=unclassified expected_gate_skip=none
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - pi extension reports agent_start busy, settles idle only via ctx.isIdle(), and keeps turn_end a notification
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - pi extension awaits agent_settled before the next agent_start without a test delay
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - pi extension events from a superseded incarnation are rejected as stale
ok - kimi and grok install no unverified semantic wiring and classify through their own gates
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - opencode plugin classifies from session.status, scoped to the latched worker session
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - claude hooks open on UserPromptSubmit and close on Stop, StopFailure, and SessionEnd
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - claude hook events from a superseded incarnation are rejected without breaking the hook
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - codex classifies unknown until a semantic source is verified, never idle or footer-matched
all fm-busy-adapter-wiring tests passed
FM_TEST_END 2026-08-18T13:42:48Z tests/fm-busy-adapter-wiring.test.sh exit=0 duration_ms=131000 gate_skip=false
FM_TEST_SUMMARY total=3 failed=1 skipped_gate=0 duration_ms=2216000
FM_TEST_SUMMARY_FAMILY family=unclassified count=2 duration_ms=968000 failed=0
FM_TEST_SUMMARY_FAMILY family=watcher-wake-lock count=1 duration_ms=1246000 failed=1
FM_TEST_SLOWEST rank=1 script=tests/fm-wake-queue.test.sh duration_ms=1246000
FM_TEST_SLOWEST rank=2 script=tests/fm-pending-reply.test.sh duration_ms=837000
FM_TEST_SLOWEST rank=3 script=tests/fm-busy-adapter-wiring.test.sh duration_ms=131000
EXIT=1
Evidence: batch 1: path-lib, harness-declared, private-mode capability, lock bounded wait, tmux busy (6 suites, 0 failed)

Source: batch 1: path-lib, harness-declared, private-mode capability, lock bounded wait, tmux busy (6 suites, 0 failed)

FM_TEST_BEGIN 2026-08-18T12:57:17Z tests/fm-path-lib.test.sh family=unclassified expected_gate_skip=none
ok - windows-form classification separates drive-letter forms from posix forms
ok - a posix path passes through fm_path_to_posix unchanged
ok - a trailing carriage return is stripped before classification
ok - empty input is refused
ok - skip: host is not posix, refusal case exercised by shim below
ok - a windows form translates through cygpath on an msys host
ok - a missing translator refuses instead of passing the windows form through
fm-path-lib: all tests passed
FM_TEST_END 2026-08-18T12:57:20Z tests/fm-path-lib.test.sh exit=0 duration_ms=3000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T12:57:20Z tests/fm-lock-bounded-wait.test.sh family=unclassified expected_gate_skip=none
ok - a live pid with a procfs entry reads alive
ok - a missing procfs entry proves death even when kill -0 says alive
ok - a host without procfs keeps the plain kill -0 answer
ok - a bounded wait refuses a live-held lock within its bound and names the holder
ok - an uncontended lock acquires immediately under the bounded wait
ok - a dead-holder lock is reclaimed within the bound
ok - fm_wake_append refuses a timed-out lock wait without touching the queue
ok - fm_wake_queued_keys refuses the unlocked read on a timed-out lock wait
fm-lock-bounded-wait: all tests passed
FM_TEST_END 2026-08-18T12:57:44Z tests/fm-lock-bounded-wait.test.sh exit=0 duration_ms=24000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T12:57:44Z tests/fm-harness-declared.test.sh family=unclassified expected_gate_skip=none
ok - a declared verified adapter outranks an inherited env marker
ok - every verified adapter name is accepted as declared identity
ok - an unverified declared name is ignored loudly and detection falls through
ok - an empty declaration leaves marker detection untouched
fm-harness-declared: all tests passed
FM_TEST_END 2026-08-18T12:57:46Z tests/fm-harness-declared.test.sh exit=0 duration_ms=2000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T12:57:46Z tests/fm-pr-private-mode-capability.test.sh family=unclassified expected_gate_skip=none
ok - the real probe on a mode-incapable Windows host substitutes the owner match
skip: state filesystem cannot hold POSIX modes (posix-strict and acl-mount sections)
ok - a provably mode-incapable filesystem substitutes the owner match
fm-pr-private-mode-capability: all tests passed
FM_TEST_END 2026-08-18T12:57:50Z tests/fm-pr-private-mode-capability.test.sh exit=0 duration_ms=4000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T12:57:50Z tests/fm-tmux-submit-busy.test.sh family=pure-contract-unit expected_gate_skip=none
ok - fm_tmux_submit_enter_core: busy pane + pending composer returns empty (message queued)
ok - fm_tmux_submit_enter_core: idle pane + pending composer stays pending (genuine swallow preserved)
ok - fm_tmux_submit_enter_core: wrapped input retains swallowed-Enter retries
ok - fm_tmux_submit_enter_core: placeholder-like bare input retains swallowed-Enter retries
ok - fm_tmux_submit_enter_core: busy pane clears composer on first Enter - returns empty
ok - fm_tmux_submit_enter_core: idle pane clears composer on first Enter - returns empty as before
ok - fm_tmux_submit_enter_core: busy conversion is limited to proven pending input
ok - fm_tmux_submit_core: failed baseline capture disables busy unknown conversion
ok - fm_tmux_submit_enter_core: pending-unproven retries without busy conversion
ok - fm_tmux_submit_enter_core: unrecognized states skip busy conversion
ok - fm_pane_is_busy: Claude spinner is scoped, multi-frame, and backward-compatible
FM_TEST_END 2026-08-18T12:58:36Z tests/fm-tmux-submit-busy.test.sh exit=0 duration_ms=46000 gate_skip=false
FM_TEST_BEGIN 2026-08-18T12:58:36Z tests/fm-spawn-worktree-settle.test.sh family=backend-dispatch expected_gate_skip=none
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - a single transient stale pane_current_path read is not accepted as the worktree
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - an already-settled pane confirms via the existing inter-poll sleep, not an extra full cycle
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - a cwd-blind pane still spawns through the git-rev-parse pane probe
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
ok - a probe that can only answer the primary checkout refuses the spawn
# all fm-spawn-worktree-settle tests passed
FM_TEST_END 2026-08-18T12:59:32Z tests/fm-spawn-worktree-settle.test.sh exit=0 duration_ms=56000 gate_skip=false
FM_TEST_SUMMARY total=6 failed=0 skipped_gate=0 duration_ms=135000
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=1 duration_ms=56000 failed=0
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=46000 failed=0
FM_TEST_SUMMARY_FAMILY family=unclassified count=4 duration_ms=33000 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-spawn-worktree-settle.test.sh duration_ms=56000
FM_TEST_SLOWEST rank=2 script=tests/fm-tmux-submit-busy.test.sh duration_ms=46000
FM_TEST_SLOWEST rank=3 script=tests/fm-lock-bounded-wait.test.sh duration_ms=24000
FM_TEST_SLOWEST rank=4 script=tests/fm-pr-private-mode-capability.test.sh duration_ms=4000
FM_TEST_SLOWEST rank=5 script=tests/fm-path-lib.test.sh duration_ms=3000
FM_TEST_SLOWEST rank=6 script=tests/fm-harness-declared.test.sh duration_ms=2000
Evidence: host repro: native Windows node cannot execFile shebang fm-busy-event.sh (EFTYPE); bash invocation works

Source: host repro: native Windows node cannot execFile shebang fm-busy-event.sh (EFTYPE); bash invocation works

# Premise + fix for the adapter busy-event writers, on the native Windows node this host runs:
$ node --version && node -p process.platform
v24.13.1
win32

# Old wiring: execFile the shebang .sh directly (what the generated Pi/OpenCode adapters did):
$ node -e "execFile('<repo>/bin/fm-busy-event.sh', ['--help'], (err) => console.log(err ? 'FAILS: ' + err.code : 'ok'))"
node:internal/child_process:421
    throw new ErrnoException(err, 'spawn');
    ^

Error: spawn EFTYPE
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at spawn (node:child_process:796:9)
    at execFile (node:child_process:349:17)
    at [eval]:1:49
    at runScriptInThisContext (node:internal/vm:219:10)
    at node:internal/process/execution:451:12
    at [eval]-wrapper:6:24
    at runScriptInContext (node:internal/process/execution:449:60)
    at evalFunction (node:internal/process/execution:283:30)
    at evalTypeScript (node:internal/process/execution:295:3) {
  errno: -4028,
  code: 'EFTYPE',
  syscall: 'spawn'
}

Node.js v24.13.1

# New wiring: execFile bash with the script as argv (this change):
$ node -e "execFile('bash', ['<repo>/bin/fm-busy-event.sh'], ...)"
runs: script executed (usage refusal below proves the writer itself ran)
usage:
  fm-busy-event.sh arm <state-dir> <id> [--state busy|idle|unknown] [--source S] [--event E]
  fm-busy-event.sh apply <state-dir> <id> <busy|idle|unknown> (--gen G | --current-gen) --source S --event E
  fm-busy-event.sh retire <state-dir> <id> (--gen G | --current-gen)
See the header comment for the full contract.
Evidence: host repro: MSYS grep -i misses Kimi moon-phase emoji busy signature under UTF-8 locale, matches under LC_ALL=C

Source: host repro: MSYS grep -i misses Kimi moon-phase emoji busy signature under UTF-8 locale, matches under LC_ALL=C

$ grep --version | head -1
grep (GNU grep) 3.0

# Kimi busy spinner line as captured from a real pane:
  🌑 · thinking (3s)

# 1) The upstream behavior (grep -iE under the default UTF-8 locale) on this host:
NO MATCH -> busy Kimi misread as idle (the Windows bug)

# 2) Same input, same regex, bytewise under LC_ALL=C (the fix):
MATCH (busy detected correctly)

# 3) The real product function fm_busy_lines_match (bin/fm-tmux-lib.sh) on this host:
busy Kimi pane classified BUSY (fixed)

# 4) Guard: bare moon glyph in ordinary output still must NOT classify busy:
correctly NOT busy
Evidence: fm-path-lib.sh CLI transcript: path translation and refuse-to-guess behavior

Source: fm-path-lib.sh CLI transcript: path translation and refuse-to-guess behavior

# bin/fm-path-lib.sh driven live on the Windows host (Git Bash / MSYS):

$ fm_path_host
msys

$ fm_path_to_posix 'C:\Users\amato\project\worktree'   # native pane answer -> POSIX
/c/Users/amato/project/worktree

$ fm_path_to_posix 'C:/Users/amato/project'               # forward-slash drive form
/c/Users/amato/project

$ fm_path_to_posix '/c/Users/amato/project'               # already POSIX: passthrough
/c/Users/amato/project

$ fm_path_to_native '/c/Users/amato/project'              # POSIX -> what a native tool needs
C:\Users\amato\project

# CRLF pane capture: trailing CR is stripped before translation (od shows no \r byte):
$ fm_path_to_posix 'C:\Users\amato\wt<CR>' | od -c
0000000   /   c   /   U   s   e   r   s   /   a   m   a   t   o   /   w
0000020   t  \n
0000022

# Refusal to guess: Windows-form path where no translator exists must fail, not guess:
$ fm_path_to_posix 'C:\Users\amato\project\worktree'   # host reports no cygpath/wslpath
refused: exit 1 (no silent guess)
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (4h21m6s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • ⚠️ bin/fm-wake-lib.sh:974 - fm_wake_append ignores the new bounded lock-wait refusal: fm_lock_acquire_wait &#34;$FM_WAKE_QUEUE_LOCK&#34; has no failure handling, so when the 120s FM_LOCK_ACQUIRE_TIMEOUT fires (the exact In windows machine, fleet lock is not working, creating zombie threads kunchenguid/firstmate#1508 contention scenario this branch fixes), the function proceeds to publish the recovery marker, bump .wake-queue.seq (truncate-rewrite), and append to the wake queue WITHOUT holding the lock, then calls fm_lock_release on a lock it never acquired (a no-op due to the ownership check). This contradicts the commit's own contract that a timeout 'REFUSES rather than proceeding unlocked' and that every caller stops the operation; a concurrent locked appender can interleave with the unlocked writer, producing duplicate seq numbers. Fix: fm_lock_acquire_wait &#34;$FM_WAKE_QUEUE_LOCK&#34; || return 1 (fm_wake_append already returns nonzero status on write failure, so callers tolerate a failure return).
  • ℹ️ bin/fm-wake-lib.sh:1003 - fm_wake_queued_keys has the same missed refusal: on bounded-wait timeout it reads the wake queue without the lock (the unlocked read the function's own comment says the lock exists to prevent - a concurrent append can be observed half-written) and then no-op releases. Same mechanical fix as fm_wake_append: fm_lock_acquire_wait &#34;$FM_WAKE_QUEUE_LOCK&#34; || return 1. Lower impact because the path is read-only.

🔧 Fix: propagate wake-queue lock timeout refusal in append and read
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • ⚠️ tests/fm-wake-queue.test.sh - The phase was closed while the second targeted batch (tests/fm-wake-queue.test.sh, tests/fm-pending-reply.test.sh, tests/fm-busy-adapter-wiring.test.sh) was still running in the background; its first assertions were passing and no failures were observed, but no completed FM_TEST_SUMMARY exists for these three suites at report time. They cover the full wake-queue suite, the boot-tick sender identity + Kimi capture-fallback subshell fix, and the end-to-end adapter busy-event wiring; the running log continues to append to test-batch2.log in the evidence directory, and the core of each fix already has completed direct evidence (fm-lock-bounded-wait passed the wake append/read lock-timeout refusals, and the native-node EFTYPE-vs-bash repro proves the adapter writer fix premise). Decide whether to accept that partial coverage or re-run the three suites to completion.
  • bash bin/fm-test-run.sh tests/fm-path-lib.test.sh tests/fm-lock-bounded-wait.test.sh tests/fm-harness-declared.test.sh tests/fm-pr-private-mode-capability.test.sh tests/fm-tmux-submit-busy.test.sh tests/fm-spawn-worktree-settle.test.sh - all 6 passed (failed=0, gate_skip=0) on Windows 11 / MSYS
  • Manual repro: Kimi moon-phase busy line vs MSYS grep (GNU grep) 3.0 - grep -qiE under UTF-8 locale NO MATCH (the bug), LC_ALL=C grep -qiE MATCH, and real fm_busy_lines_match kimi classifies busy correctly plus bare-moon-glyph over-match guard
  • Manual repro: native Windows node v24.13.1 execFile(&#39;bin/fm-busy-event.sh&#39;) throws spawn EFTYPE, execFile(&#39;bash&#39;, [&#39;bin/fm-busy-event.sh&#39;]) executes the real writer
  • Manual CLI transcript: bin/fm-path-lib.sh live on MSYS - drive-letter to POSIX, POSIX passthrough, POSIX to native, CRLF stripping (od-verified), and exit-1 refusal when no translator exists
  • bash bin/fm-test-run.sh tests/fm-wake-queue.test.sh tests/fm-pending-reply.test.sh tests/fm-busy-adapter-wiring.test.sh - launched, early assertions passing, still running when the phase was closed
  • git status --porcelain - worktree clean after testing (no transient artifacts left)

🔧 Fix: fix Windows wake-queue: md5sum hashing, snapshot modes, wait bounds
✅ Re-checked - no issues remain.

  • bin/fm-test-run.sh tests/fm-pending-reply.test.sh tests/fm-busy-adapter-wiring.test.sh (at target commit fdb778f: total=2 failed=0, 40 ok / 0 not ok, 30 min)
  • bin/fm-test-run.sh tests/fm-wake-queue.test.sh (test-wake-queue-fixed3.log: total=1 failed=0, 19 ok / 0 not ok, 61 min, run against the exact tree committed as fdb778f two minutes later)
  • bin/fm-test-run.sh tests/fm-wake-queue.test.sh tests/fm-pending-reply.test.sh tests/fm-busy-adapter-wiring.test.sh (test-batch2-rerun.log, pre-fix tree: pending-reply and busy-adapter-wiring passed; wake-queue failure led to the fdb778f fix)
  • bin/fm-test-run.sh batch 1 (test-batch1.log: 6 suites, 0 failed - fm-path-lib, fm-harness-declared, fm-pr-private-mode-capability, fm-lock-bounded-wait, fm-tmux-submit-busy and peer)
  • manual repro: native Windows node execFile of shebang bin/fm-busy-event.sh fails EFTYPE while bash invocation succeeds (windows-node-busy-event-execfile-repro.txt)
  • manual repro: MSYS grep 3.0 -i misses Kimi moon-phase emoji alternation under UTF-8 locale, matches under LC_ALL=C (msys-grep-kimi-busy-repro.txt)
  • manual CLI transcript: bin/fm-path-lib.sh translation and refuse-to-guess behavior (fm-path-lib-cli-transcript.txt)
  • git status --porcelain clean at fdb778f after all runs
🔧 **Document** - 2 issues found → auto-fixed ✅
  • ℹ️ README.md:4 - README's platform badge still advertises 'macOS | Linux' while this branch hardens Windows end to end (locks, spawn, busy wiring, path translation, Windows-truthful suites). Whether Windows is now a declared supported platform is a product-support decision the author has not stated anywhere in the change, so I did not edit the badge; if Windows support is meant to be public, update the badge and the user-facing support statement together.
  • ℹ️ docs/scripts.md:8 - Pre-existing drift, out of scope for this change: docs/scripts.md's toolbelt inventory omits roughly two dozen existing bin scripts (fm-procevent.sh, fm-lint.sh, fm-stow-cascade.sh, the fm-remote-* family, several *-lib.sh helpers) while listing their peers, so the table reads as complete but is not. Propose a follow-up to either complete the inventory or state its curation rule in the table header.

🔧 Fix: declare Windows experimental in README badge and requirements
✅ Re-checked - no issues remain.

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

✅ No issues found.

kunchenguid and others added 28 commits August 17, 2026 02:09
* fix: reconcile inactive terminal outcomes

* fix: stream secondmate summary inputs

* no-mistakes(review): Fix reconciliation locking and request delivery retries

* no-mistakes(review): Prevent retries after unknown request delivery

* no-mistakes(document): Clarify inactive reconciliation cadence and receipts

* no-mistakes(lint): Quote terminal status arguments in reconciliation tests

* refactor: simplify inactive outcome reconciliation

* no-mistakes(review): Bound inactive reconciliation scans with durable progress

* no-mistakes(review): Bound reconciliation and deduplicate recovery notices

* no-mistakes(document): Document inactive outcome reconciliation contracts

* no-mistakes(review): Reject relative local secondmate parent routes

* no-mistakes(review): Key terminal receipts by spawn incarnation

* no-mistakes(review): Stabilize legacy receipts and lock reconciliation snapshots

* no-mistakes(review): Fail closed on invalid secondmate identity markers

* no-mistakes(document): Document durable inactive-outcome reconciliation

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

(cherry picked from commit 2d550fe)
* fix(session-start): refresh drifted instructions on stale rebuilds

* test(session-start): prove Pi instruction refresh end to end

* no-mistakes(review): Fix stale instruction refresh and baseline integrity

* no-mistakes(review): Preserve true-start baselines across Pi continuations

* no-mistakes(review): Correct Pi continuation classification and live expectation

* no-mistakes(review): Correct Pi continuation coverage documentation

* no-mistakes(review): Fix read-only refresh and exact Pi session restores

* no-mistakes(review): Classify Pi create-if-missing sessions correctly

* no-mistakes(review): Classify named Pi sessions using immutable headers

* no-mistakes(review): Correct Codex interactive coverage diagnostic

* no-mistakes(document): Document immutable Pi compaction instruction refresh

* no-mistakes(document): Correct Pi refresh documentation and validation claims

(cherry picked from commit e8c7645)
* feat(bin): add deterministic condition->action watch adapter on the process-event channel

Register a (condition, action) pair once with bin/fm-procevent-when.sh and the
existing process-to-event runner polls the condition tokenlessly, fires the
action at most once on a stable true, and wakes firstmate exactly once with the
captured outcome - instead of burning an agent turn per re-check.

The pair is stored privately under state/when/ and hash-bound by a trust record
the same way fm-check-register.sh binds a custom check, so a mutated spec is
refused without executing anything. A durable exclusive fired marker claimed
before the action makes restarts and re-polls unable to double-fire; every
failure path (mutated spec, condition error past budget, expired deadline,
failed action, uncaptured earlier fire) ends in a terminal captured outcome
that wakes firstmate rather than a silent retry. Eligibility stays a firstmate
judgment: only exact, safe, reversible actions may be bound, and judgment-
needing or destructive actions keep the wake-and-decide flow.

* no-mistakes(review): Harden when watcher concurrency, deadlines, timeouts, and output

* no-mistakes(test): Bind watcher actions to registered executable bytes

* no-mistakes(document): Correct condition-action watcher documentation

* no-mistakes(document): Clarify outcome wake re-announcement

* no-mistakes: apply CI fixes

(cherry picked from commit 81ce6dc)
…id#2202)

The open-decisions fold only recognized a [key=<slug>] token between the
verb and the colon (needs-decision [key=x]: note). The common worker
shape with the colon first (needs-decision: [key=x] note) silently
folded its stated key into the shared "default" bucket, so two open
decisions could collapse into one record and fm-send --resolve-key <x>
refused to close the decision it plainly named.

A complete token at the head of the note is now an equivalent stated-key
position for every keyed verb, shared by the whole-file and incremental
folds through the one _fm_decision_key owner. The documented
before-colon position wins when both are present, a token deeper in the
note stays prose, a bare keyless line still folds to "default", and a
stated-but-malformed slug is rejected rather than rewritten to
"default". A consumed note-head token is stripped from the note so both
positions yield identical records, and the incremental fold version is
bumped so persisted cursors folded under the old interpretation are
rebuilt from the authoritative log.

Fixes kunchenguid#2109

(cherry picked from commit 614fae6)
…uid#2212)

* fix(bin): keep a recovery acknowledgement valid across republication

A watcher cycle that opened and closed while the model handled its drained
wakes minted a fresh recovery generation, which invalidated the exact
acknowledgement the drain had just printed. That acknowledgement then consumed
nothing, so the marker stayed pending and every later arm spent its whole cycle
re-announcing the same recovery instead of supervising - a livelock the home
could not leave on its own.

A downtime publication now reuses the generation of an outstanding handling
episode, so a close during the handling window cannot orphan the printed
acknowledgement. The acknowledgement itself separates its two facts: queue-row
consumption is bound to the monotonic --ack-through sequence and always
happens, while only retiring the episode is bound to --recovery-generation. A
generation that moved on is a non-fatal result that names its own remedy
instead of a refusal that consumes nothing.

* no-mistakes(review): Preserve recovery generations and consume stale acknowledgements safely

* no-mistakes(document): Document sequence-bound recovery acknowledgements

(cherry picked from commit c42cfe0)
* feat(fmx-respond): consume in_reply_to_chain conversation context

The relay's poll payload can carry in_reply_to_chain, an oldest-first
transcript of the surrounding conversation, but the mention-handling
procedure only ever read the immediate in_reply_to parent, so referents
like "this" in a standalone mention stayed unresolvable even when
context was delivered.

Teach fmx-respond to read the chain when present (optional and
backward-compatible: often absent today, kind label not required),
resolve referents against the whole transcript, and extend the
untrusted-content framing to every chain entry including the upcoming
kind=history entries. Document the field's wire shape in
docs/configuration.md as the firstmate-side owner.

* no-mistakes(document): Document Relay chain context ownership

(cherry picked from commit b5d430d)
* fix(bin): strip every bracket tag, not just [key=...], from a status verb

status_line_verb only stripped a leading "[key=...]" token before the
colon, so a remote secondmate reply's leading "[corr=...]" correlation
tag stayed glued onto the returned verb word ("needs-decision
[corr=...]" instead of "needs-decision"). The open-decisions fold's
verb match then silently failed to recognize the line at all, so
fm-send --resolve-key refused to close a decision that was plainly
open on the status line.

Generalize the parser to strip every "[name=value]" tag before the
colon, in any order and count, so local and remote replies fold
identically.

* no-mistakes(review): Invalidate stale decision cursors after parser fix

* no-mistakes(document): Clarify status metadata verb parsing

(cherry picked from commit b91016f)
* fix: collapse duplicate supervision wakes without losing legitimate updates

One remote-secondmate note produced two handling turns (a procevent check
wake published before autohandle, then a signal wake for the same mirrored
bytes), already-ingested replays such as a cursor-loss whole-log recapture
still woke with nothing to do, this home's own bookkeeping closes (fm-send
--resolve-key, the pending-reply escalation close, the captain-held
transfer) re-woke the session that wrote them, and turn-ended-only wakes
were annotated with already-announced status lines that looked like fresh
progress.

Dedup rules, each at its layer's one owner:
- fm-procevent.sh: an adapter may declare 'self-announcing'; the runner
  then applies first and publishes a check wake only for what remains
  unhandled. fm-procevent-remote-reply.sh declares it: the mirrored status
  append is the single announcement, so a fully applied capture publishes
  nothing and a byte-identical replay stays completely quiet. All other
  adapters keep strict publish-before-apply.
- fm-wake-lib.sh: fm_wake_signal_sig/seen_path/seen_current now own the
  watcher's signal signature and .seen-* marker format, plus
  fm_wake_status_append_self_announced, the guarded bookkeeping append
  that advances the marker only over exactly its own bytes and fails
  toward waking on any pending or interleaved foreign write.
- fm-send.sh, fm-pending-reply-lib.sh, fm-decision-hold.sh: bookkeeping
  closes go through that guarded append; escalation opens stay plain
  appends because a new blocker must wake.
- fm-wake-lib.sh annotations: a historical (turn-ended-only) row skips its
  status annotation only when the file's signature provably matches the
  seen marker; anything unannounced keeps annotating.
- fm-classify-lib.sh: a kind=secondmate task's status signal is never
  absorbed as provably-working, because that stream is the routed-reply
  channel the parent must read.

Also fixes a pre-existing exit-path deadlock the regression run reproduced:
a TERM inside a recovery-marker critical section left fm_lock_try_acquire
spinning against this same process's abandoned hold; a self-held lock is
now reclaimed (a subshell still waits on its parent's live hold).

Regression tests drive the real wake functions and executables in both
directions: each duplicate case collapses, while a new remote reply, new
decision, new blocker, merge result, failure, first status change, and a
later different note on the same task all still wake.

* no-mistakes(document): Document wake deduplication contracts

(cherry picked from commit b0ad61e)
* fix: raise quota-axi floor to 0.1.25 for Cursor CLI quota awareness

Homes on latest main need quota-axi kunchenguid#87 so Desktop-absent CLI machines report a fresh Cursor quota instead of a false sign-in-required.

* no-mistakes(document): Update quota floor documentation pointer

(cherry picked from commit 96876db)
…id#2304)

* fix(guard): stop the false send-time watcher-down alarm on Pi primaries

On a Pi primary the watcher process is not the liveness signal. The Pi
extension tears the watcher down on every actionable wake and spawns the
replacement itself, so the singleton lock is legitimately unheld between
cycles: every one of the 799 cycles in a live primary's ledger ends with
lock_after=pid:none, and a live capture caught the guard verdict flipping to
no-watcher during one hand-off with the beacon 63s old.

bin/fm-guard.sh classified Pi as a persistent-watcher harness, which demands a
live identity-matched lock holder at all times, so any guarded command landing
in a hand-off painted the full WATCHER DOWN - SUPERVISION IS OFF banner and
told firstmate to repair a cycle the extension already owns and is restoring.

Add an extension supervision model for pi and pi-signed. A live
identity-matched watcher stays the ordinary healthy state; an unheld lock is
healthy only while the beacon is fresh within grace AND a live Pi session
provably owns continuity - both primary extensions recorded in their state
markers at their current on-disk builds by the process named in state/.lock,
with that process still alive. Without that proof the banner fires exactly as
before, so an unloaded, version-drifted, or exited Pi session is loud
immediately and a cycle the extension never restores is loud once the beacon
passes grace. The queued-wake warning, the PID-strict turn-end guard, and
every other primary's detection are untouched.

Fold session-start's duplicate Pi marker predicate into the shared library so
the ownership contract has one owner.

* no-mistakes(review): Restrict Pi hand-off tolerance to unheld watcher locks

* no-mistakes(document): Document Pi watcher hand-off supervision

(cherry picked from commit 85cefa9)
…id#2330)

* feat(bin): add unrouted close paths to the captain decision gate

A captain who declines a held decision leaves no follow-up work to route,
so `resolve` could not express that answer: it requires at least one
`--routed-to` task. The only way to close such a hold was a direct
`tasks-axi done`, which never writes the durable resolution record the
completion gate reads, so the originating investigation could no longer
pass `verify` and its cleanup stayed blocked.

Add two close paths that route no work:

- `decline` closes an actively held hold with a recorded captain decision
  and no routed task. It refuses while any task is still blocked by the
  hold, because releasing routed work without recording it is `resolve`'s
  job.
- `repair` records the missing resolution block on a hold that was already
  closed outside this script. It never reopens a hold and never clears a
  dependency edge, and it refuses a hold that is still actively held.

Both require a non-empty captain decision file and share `resolve`'s
digest-based retry identity, so an exact retry is idempotent while a
changed decision is rejected. The recorded body now also names which path
closed the hold, and each routed entry regains its own line.

The gate itself is unchanged: an unanswered decision still fails
completion and blocks teardown, and neither new path can close a hold
without the captain's recorded word.

* fix(bin): require captain-hold provenance before repairing a decision

`repair` checked only that the backlog item was kind captain and Done, so
an ordinary captain-kind task that was never held for the captain could be
closed, repaired, and then pass the completion gate.

tasks-axi keeps `hold_kind` through a close, so it is the surviving proof
that an identity really was a captain hold. Require it before writing the
resolution record, and cover the case in the gate regression.

* no-mistakes(document): Correct decision-hold lifecycle documentation

(cherry picked from commit 5521323)
* fix(bin): surface buried status notes on wake drain

A note: answer immediately followed by a routine note was dropped because
annotations kept only the newest line and note: never enters OPEN DECISIONS.
Present every unread note and pending-reply resolution since the last drain
cursor, and annotate every unread line on a queued signal.

* no-mistakes(review): Fix unread status cursor races and overflow

* no-mistakes(review): Preserve cursors when status span reads fail

* no-mistakes(review): Make status presentation transactional under I/O failures

* no-mistakes(review): Simplify unread status cursor and presentation locking

* no-mistakes(review): Align cursor failure regressions with transactional presentation

* no-mistakes(review): Retire stale presentation cursors during task teardown

* no-mistakes(review): Preserve routine status until signal annotation

* no-mistakes(review): Correct unread status cap documentation

* no-mistakes(document): Document unread wake status presentation

* no-mistakes(lint): Fix wake surfacing ShellCheck warnings

* no-mistakes: apply CI fixes

(cherry picked from commit db0280f)
A wedged family-run step was occupying the runner until the 75-minute
job cap; bound that step so cleanup and timing artifacts still upload.

(cherry picked from commit f1a4af4)
…d mate (kunchenguid#2457)

The lightweight Relay follow-up link lives in the answering home's own
state/<task-id>.meta, so it can only bind work that home owns. When a
Relay-linked request is routed to a second mate, the task record lives in the
second mate's home, fm-x-link.sh failed with a bare "no such task ...meta", and
nothing else picked the promise up: only the soft acknowledgement was ever
posted. The typed promised-final path already supports --work-home
secondmate:<id>; the playbook simply never chose it.

- fmx-respond now states the routing rule crisply: a task in this home takes the
  lightweight link, and second-mate-routed work takes a promised-final
  commitment bound to that home, registered up front with the brief command
  carried into the routed worker's instructions.
- fm-x-link.sh refuses a task with no local record by naming the registered
  second mate whose home actually holds it and printing the promised-final
  registration command, with the exact --work-home when the match is
  unambiguous. A home with no registered second mates keeps the plain error.
- fm-backlog-handoff.sh reports, after a successful move, any moved key that
  still owes a public reply bound to main/<key>, since that binding no longer
  names the home owning the work. The move itself is never blocked.

Docs and the secondmate handoff prose follow the same rule. Tests cover the
refusal, its scoping, the unchanged local-link path, and both handoff outcomes
at the script boundary.

(cherry picked from commit 7a3259e)
…verdicts (kunchenguid#2456)

* fix(skills): hint that remote secondmate liveness verdicts false-negative

fm-crew-state and fm-send routinely misreport a live remote secondmate
as dead; confirm against the pane before relaunching, and relaunch only
through fm-spawn.sh, never raw herdr pane surgery.

* no-mistakes: apply CI fixes

(cherry picked from commit 196fb65)
…nguid#2488)

* feat(stow): persist the open records a session is holding

/stow curated memory and captured session knowledge, but never touched
record state, while AGENTS.md called it an "unfinished-work sweep" and the
receipt declared the session "safe to reset" - wording that implied a
record-correctness guarantee stow does not make. A shipped PR with no
backlog item, a queued umbrella whose phases had merged, and four decision
holds left open after their answers shipped all survived repeated stows.

Add a bounded pass that files record state from the same volatile input the
rest of stow already uses: the open threads in context, minutes before the
reset destroys them. It creates a record for an unfiled thread and corrects
one the session knows is wrong, through the owning path, and states its
boundary as part of the contract - it never enumerates the backlog, lists
holds, or queries a forge, because it cannot be a reconciliation and must
not be read as one.

Correct the wording in AGENTS.md and the completion receipt so reset-safe
means what it actually guarantees: nothing this session knew was lost.

* no-mistakes(review): correct stow decision-hold inspection to read hold via tasks-axi

* no-mistakes(document): note /stow open-record persistence in README command catalog

* refactor(stow): state open-record persistence as principle, not procedure

The first version enumerated triggers, named commands, and prescribed an
ordered procedure. That is too rigid for an agent skill: it invites literal
execution of a checklist instead of judgment, and every enumerated example
is a way for the guidance to go stale.

Reduce it to the intent - before a reset, the important open work you are
holding in context must end up durably recorded rather than dying with the
session, filing what is unfiled and correcting what is stale - and let the
agent judge importance, the record, and the owning write path.

Keep the scope bound, since it is a decided contract and not a mechanic:
this covers the open work the session is holding, never a reconciliation of
durable records against repository or forge reality. The wording
corrections in AGENTS.md and the completion receipt are unchanged.

(cherry picked from commit e518906)
Groundwork for upstream kunchenguid#1667 (Windows-hosted
repositories driven from WSL or Git Bash without losing task isolation).
On those hosts a pane, a native tool, or treehouse can answer with a
drive-letter path (C:\Users\...) while every firstmate-side comparison
and cd expects the POSIX form; comparing the wrong form silently fails,
and a silent failure at worktree-detection time is how a task loses its
isolation.

fm-path-lib.sh classifies drive-letter forms, passes POSIX paths through
unchanged, translates through cygpath (MSYS) or wslpath (WSL), strips
CRLF artifacts from captured pane output, and FAILS rather than guessing
when no translator exists, so a caller can never act on an untranslated
path.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
On Windows, treehouse get can run its subshell as a nested cmd.exe, so
the backend's structured cwd read keeps reporting the top-level shell's
directory even though the pane really did enter the worktree - the
settle loop then never sees the move and the spawn dies after 60s with
the worktree already created (upstream kunchenguid#1796).

When the settle loop times out, ask the pane itself with git rev-parse
--show-toplevel, delimited by a per-attempt marker so a stale echo can
never be parsed as this attempt's answer. A drive-letter answer is
translated by fm-path-lib, which refuses rather than guesses, so an
untranslatable answer stays a spawn error and never a silent fallback
to the primary checkout; validate_spawn_worktree still owns the final
isolation verdict. FM_SPAWN_WT_SETTLE_POLLS and
FM_SPAWN_WT_PROBE_ATTEMPTS bound both loops for tests.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
Two halves of the Git Bash lock hang reported upstream as
kunchenguid#1508 (session startup spinning forever behind a
stale lock, spawning zombie shells):

- fm_pid_alive: kill -0 alone is not proof of life on MSYS, where a
  dead pid can keep probing alive and a stale lock then never
  reclaims. Wherever the host publishes per-pid procfs entries (Linux,
  WSL, MSYS - keyed on the capability, never uname), a missing entry
  now proves death and overrules the false-positive probe; hosts
  without procfs (macOS) keep the plain answer.
- fm_lock_acquire_wait: the unbounded 0.1s spin is now bounded by
  FM_LOCK_ACQUIRE_TIMEOUT (default 120s, 0 restores the old wait). On
  timeout it refuses with the lock path and recorded holder named, and
  every caller now handles that refusal explicitly - stopping the
  operation rather than proceeding without the lock.

Blind age-based lock breaking was considered and rejected: a session
lock is legitimately held for a whole session, so age alone can never
prove staleness; truthful liveness plus a bounded, loud wait is the
safe fix.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
fm_pending_reply_pid_identity keyed on ps lstart, which is re-derived
from the wall clock on every read; WSL2's clock drifts across host
sleep and then corrects, so the SAME live sender could render two
different lstart strings and be misread as dead (the drift class
reported upstream as kunchenguid#433, already fixed for the
watcher in fm-wake-lib but not here).

Prefer /proc stat field 22 (starttime in boot ticks, immutable for a
process's lifetime) plus the full cmdline, falling back to lstart only
where procfs is absent. A record written in the legacy lstart form
before this change still compares on its own terms during the upgrade
window, so no live sender is orphaned by the format change.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
WSL2 re-parents a Herdr-launched shell to pid 1, which removes the
harness from the ancestry chain entirely; codex, opencode, kimi, and
muse publish no verified env marker either, so detection returned
unknown for a genuinely codex-run session and broke validation,
startup, spawning, and ownership checks (upstream
kunchenguid#2307).

FM_HARNESS_DECLARED is the supported fallback: the operator or launcher
states the harness explicitly. Only a verified adapter name is
accepted, so a typo or a stale multiplexer environment cannot invent a
harness, and an ignored declaration warns on stderr. It outranks the
marker layer deliberately: the variable does not exist unless someone
set it on purpose, which is stronger evidence than an inherited env
marker.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
…-mode checks

fm_pr_private_file_valid keyed its Windows owner-check substitution on
uname alone, so an acl-mounted MSYS state dir that CAN hold POSIX modes
was silently held to the weaker owner requirement. Adopt the behavioral
state-capability probe from upstream PR kunchenguid#2378
(fm-state-capability-lib.sh, taken verbatim to ease future syncs): it
proves by doing - chmod then read back inside the actual state
directory - whether owner-only modes hold there.

Where the probe proves modes enforceable, Windows now keeps the strict
0600 requirement; only a provably mode-incapable filesystem (noacl
MSYS, where chmod 0600 reads back 644) falls back to the NTFS-ACL-backed
owner match. Non-Windows behavior is unchanged.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
…-clean PowerShell splice

Adversarial review findings on the branch:

- FM_HARNESS_DECLARED: the code comment claimed a stale multiplexer
  environment could not invent a harness, but that is only true for
  INVALID names - a valid adapter name exported from a shell profile
  would reach every pane the multiplexer creates and misidentify
  crewmates on other harnesses. State the hazard honestly in the code
  and docs, and require per-launch scoping.
- fm-session-lock-lib.sh: justify and suppress SC2016 on the PowerShell
  ancestry snapshot - the single quotes are the deliberate quote-break
  splice pattern, and the info-level finding failed the first full PR
  lint run this file ever received (its commits predated PR CI on this
  fork).

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
Both new libs are sourced, never executed; the repo's sourced-lib
convention and upstream's own copy of the capability lib are 0644, and
keeping the adopted file mode-identical to upstream eases future syncs.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
FM_SPAWN_WT_SETTLE_POLLS and FM_SPAWN_WT_PROBE_ATTEMPTS entered with the
pane-probe fallback but missed the configuration reference, which
documents even test-override knobs.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71
@jiroamato

Copy link
Copy Markdown
Owner Author

@greptile

@jiroamato jiroamato changed the title Upstream sync (minus Cursor/Calm) + Windows community fixes feat(windows): sync upstream improvements and harden Windows support Aug 17, 2026
@greptile-apps

greptile-apps Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR synchronizes upstream reliability improvements and strengthens Windows support across path handling, process identity, locking, private-file validation, and watcher behavior.

  • Adds hash-validated private snapshots for condition and action executables.
  • Resolves and binds condition executables when watches are armed.
  • Closes the previous check-to-execute race by executing the validated snapshot rather than reopening the source pathname.
  • Adds regression coverage for executable mutation and watcher lifecycle behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
bin/fm-procevent-when.sh Both previously reported executable-binding issues are addressed by resolving, hashing, privately staging, revalidating, and executing the same snapshot bytes.
tests/fm-procevent-when.test.sh Adds focused regression coverage proving that mutated condition and action executables are rejected without firing.

Reviews (6): Last reviewed commit: "no-mistakes(document): declare Windows e..." | Re-trigger Greptile

Comment thread bin/fm-procevent-when.sh Resolved
Greptile's review of the synced condition-to-action watcher found the
asymmetry: the spec and the action executable are hash-bound, but the
condition executable was executed unbound, so a condition edited,
replaced, or PATH-shadowed after arming could decide when the bound
action fires.

Arm now resolves the condition to an absolute path and pins its bytes
in the spec (condition_sha256), and the runner revalidates those bytes
before every poll, refusing the watch with a rejected outcome document
instead of polling a changed condition - the same contract the action
already carries at the fire boundary. Watches must be re-armed after a
deliberate condition change, which is the safe default for a mechanism
whose whole promise is deterministic firing.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71

Copy link
Copy Markdown
Owner Author

@greptile re-review requested: the condition-executable binding flagged in round 1 is fixed in 73d1654 (condition bytes are now hash-pinned at arm and revalidated before every poll, with a regression test).


Generated by Claude Code

@jiroamato
jiroamato marked this pull request as ready for review August 17, 2026 04:17
Comment thread bin/fm-procevent-when.sh Resolved
…shots

Greptile's follow-up round found the check-to-use gap in the previous
binding: hashing the pathname and then re-opening that pathname to
execute leaves a window where replaced bytes run unvalidated - for the
condition at every poll, and for the action after the single-fire
marker is already claimed.

Close it with the same contract the watcher already applies to custom
state checks: stage the registered executable into the private 0700
watch directory, hash the STAGED bytes against the trust binding, and
execute the staged snapshot. Validated bytes and executed bytes are now
the same private file; a pathname replaced mid-watch can at worst
change what gets staged before hashing, which the hash refuses. Bound
executables must reference helpers by absolute path since snapshots run
from the watch directory; the header documents that contract.

Claude-Session: https://claude.ai/code/session_01WHMwXKfZjs1U64acBxsu71

Copy link
Copy Markdown
Owner Author

@greptile re-review requested: the check-to-use race from round 3 is closed in 829113b. Both bound executables are now staged into the private 0700 watch directory, hashed as staged bytes against the trust binding, and executed from that snapshot — validated bytes and executed bytes are the same private file, for the condition at every poll and the action at the fire boundary.


Generated by Claude Code

…s node hosts

The generated Pi extension and OpenCode plugin invoked bin/fm-busy-event.sh
directly through execFile. A native Windows node host cannot exec a shebang
.sh file, and the fire-and-forget callback swallowed the failure, so semantic
busy/idle state silently never updated on Windows (the turn-end touch worked
because touch resolves to an .exe). Invoking the writer via bash works on
every host firstmate supports.

Claude-Session: https://claude.ai/code/session_019QCE58DukRTxivTA5vMsMS
MSYS grep 3.0 fails to match Kimi's moon-phase spinner alternation with -i
under a UTF-8 locale, misreading a busy Kimi pane as idle on Windows and
risking recovery injection into a working crewmate. Bytewise matching keeps
every multibyte signature (moon phases, ellipsis, middle dot) deterministic
on any host grep; -i still folds the ASCII tokens and no signature needs
locale case folding.

Claude-Session: https://claude.ai/code/session_019QCE58DukRTxivTA5vMsMS
Three suites assumed a POSIX-capable test host and failed on real Windows
Git Bash while the product behaved as designed:

- fm-pr-private-mode-capability asserted strict-mode sections on a state
  filesystem that provably cannot hold POSIX modes (every mount here is
  noacl; chmod 600 reads back 644). The sections now gate on a probe-by-
  doing capability check, and a genuinely mode-incapable Windows host gains
  a real unshimmed assertion that the probe substitutes the owner match.
- fm-pending-reply required the legacy lstart identity compare on a host
  whose ps has no -o at all; no legacy record can exist there, so the case
  now gates on ps -o lstart support.
- fm-spawn-worktree-settle bounded the already-settled confirm at 5s of
  wall clock, which bundles the whole spawn's startup and fails under MSYS
  process-spawn overhead. It now asserts the exact pane-poll count (first
  read plus one confirming read) the comment always claimed.

Also propagate failures out of the Kimi capture-fallback test: its subshell
body exited on fail without failing the suite, so a real regression printed
'not ok' while the run still reported success.

Claude-Session: https://claude.ai/code/session_019QCE58DukRTxivTA5vMsMS
@jiroamato jiroamato changed the title feat(windows): sync upstream improvements and harden Windows support feat(bin): sync upstream improvements and harden Windows support Aug 18, 2026
@jiroamato
jiroamato merged commit e223b8a into main Aug 18, 2026
14 of 15 checks passed
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.

3 participants