Repository navigation
feat(bin): sync upstream improvements and harden Windows support - #2
Conversation
* 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)
(cherry picked from commit 07450b9)
* 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)
(cherry picked from commit 1238402)
(cherry picked from commit 6789876)
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
Greptile SummaryThe PR synchronizes upstream reliability improvements and strengthens Windows support across path handling, process identity, locking, private-file validation, and watcher behavior.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| 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
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
|
@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 |
…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
|
@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
…odes, wait bounds
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
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.bin/: a newfm-path-lib.shWindows/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, anFM_HARNESS_DECLAREDdeclared-identity fallback, and a newfm-state-capability-lib.shthat probes the filesystem before relaxing strict 0600 private-mode checks.fm-busy-event.shvia bash since native Windows node cannot execFile a shebang script, busy-signature matching pinned toLC_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)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=0Evidence: 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
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)
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
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
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
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 "$FM_WAKE_QUEUE_LOCK"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 "$FM_WAKE_QUEUE_LOCK" || 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 "$FM_WAKE_QUEUE_LOCK" || 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 / MSYSManual repro: Kimi moon-phase busy line vs MSYSgrep (GNU grep) 3.0-grep -qiEunder UTF-8 locale NO MATCH (the bug),LC_ALL=C grep -qiEMATCH, and realfm_busy_lines_match kimiclassifies busy correctly plus bare-moon-glyph over-match guardManual repro: native Windows node v24.13.1execFile('bin/fm-busy-event.sh')throws spawn EFTYPE,execFile('bash', ['bin/fm-busy-event.sh'])executes the real writerManual CLI transcript:bin/fm-path-lib.shlive on MSYS - drive-letter to POSIX, POSIX passthrough, POSIX to native, CRLF stripping (od-verified), and exit-1 refusal when no translator existsbash 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 closedgit 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
✅ **Push** - passed
✅ No issues found.