Repository navigation
fix(bin): Repair remote secondmate route boundaries - #2
Merged
Merged
Conversation
…ard, recovery mutex
…m tests/fm-backend.test.sh: resolve_permissive_tmux_kill_ref searched `git log --first-parent HEAD -- bin/backends/tmux.sh` for a historical adapter with the permissive kill-window selector. This fork merges upstream via merge commits (d913576 -> 0e19df7), so all upstream history is on the second parent; the first-parent walk only sees the post-merge exact-selector adapter and the case fails with "unable to locate a historical bin/backends/tmux.sh with permissive kill-window selectors". Main's latest CI run (d913576) fails on the identical assertion, so the PR code did not cause it, but the check blocks this and every future PR in the fork. Fix: removed `--first-parent` from the resolver (content-addressed search now walks all ancestors; identical result on upstream's linear history) and updated the comment. Verified: pre-fix copy reproduces the failure locally; fixed tests/fm-backend.test.sh passes all cases including the teardown conformance case. shellcheck not installed locally. Separate flag, not changed: commit 9d1b207 re-added .agent-kit/session.lock to the tree despite the review round 2 decision to untrack it; it should be dropped from the index (git rm --cached) before merge
davidtandoh
added a commit
that referenced
this pull request
Sep 27, 2026
Bring fork main (2f9a106, the 2026-09-26 upstream sync plus fork fixes #2-#6) into the Kiro V3 crew branch so PR #8 merges cleanly. A merge, not a rebase, keeps the upstream PR kunchenguid#4679 merge and its authorship intact. Textual conflicts (1): - bin/fm-test-run.sh, family_for_basename live-e2e list: this branch added fm-kiro-signals-live-e2e.test.sh on its own line; main added fm-herdr-agent-liveness-live-e2e.test.sh beside the version-floor test. Kept both entries, so both live tests stay classified in the live-harness-optin family. Auto-merged files touched by both sides, checked by hand: - bin/fm-spawn.sh: main's agy Opus --effort omission (fork fix #5) sits in the agy arm next to this branch's new kiro effort arm; effort_flag_for_harness keeps the (harness, effort, model) signature on both sides. - agy.md, docs/configuration.md, docs/verification/runtime-backends.md: disjoint hunks. Semantic review: the Kiro adapter adds no arm to bin/backends/herdr.sh or fm_harness_pid_alive. Kiro reaches the fork's registration- independent Herdr liveness (fork fix #3) through fm_agent_process_classify_name, where kiro-cli classifies as agent. It is worker-only, so it stays out of the primary session-lock harness table. Claude-Session: https://claude.ai/code/session_01B4Krq5gHjEPXbmzMaaeTHs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Continue AK-088 by repairing the confirmed Firstmate remote-secondmate routing defects that prevent the agent-station acceptance canary. Use the accepted AK-088 task and ADR-0007 as governing contracts. Keep Firstmate as the sole fleet supervisor and Herdr as transport. Do not create another supervisor. The governing contracts require one conversational captain to dispatch and observe the configured agent-station remote secondmate through its SSH route, with Firstmate owning dispatch, supervision, and crewmate lifecycle, Herdr owning visible remote session transport, and no parallel fleet supervisor or lifecycle owner.
What Changed
bin/fm-remote-home-seed.shnow rewrites the parent steering inbox path in the published remote charter to the remote home's host-localstate/parent-route/<id>.inbox, alongside the existing status-path rewrite, so the remote charter never names the primary's inaccessible Mac-local paths.bin/fm-procevent.shtreats any empty source output as no-result, including exit 0, leaving the source registered for retry without publishing a result, adapter sidecar, or wake.bin/fm-wake-lib.shadds a non-recursive recovery mutex acquire for the.steallock: a stale or same-process owner is reclaimed at the fixed path, a live or unreadable owner refuses, and the previous recursivefm_lock_try_acquirecall that grew.steal.stealpaths and spun the EXIT path on a self-held mutex is replaced. Tests cover each behavior and the docs for remote secondmates, process-event sources, and watcher continuity are updated to match.Risk Assessment
✅ Low: The three source changes are small and each was traced end to end: the recovery-mutex rewrite still yields a single winner under concurrent stale reclaim and now reclaims the self-held mutex on the exit path, the charter inbox rewrite matches the path fm-remote-secondmate-control.sh actually writes, and the exit-zero empty-output change only affects the remote-reply poll (every other shell adapter always prints output); both prior-round fixes are present and .agent-kit/session.lock is untracked at the target commit.
Testing
Ran the three modified test files as the baseline (lock file green, procevent green except one load-sensitive timing fixture unrelated to the guard change, remote lifecycle e2e still running with 18 passes and no failures when the report was forced), then drove each altered behavior live against the real scripts on base, intermediate, and target commits: glob-metacharacter home seeding produces a correct host-local remote charter only on the target, the self-held and stale recovery mutex cases hang or grow recursive paths on earlier commits and resolve promptly on the target, and an empty exit-zero procevent result stays armed silently on the target while nonempty results still capture. No real SSH leg could be driven because Remote Login is off on this host.
bash tests/fm-remote-secondmate-lifecycle-e2e.test.shto completiongit ls-tree -r 031fc51 -- .agent-kitis empty; commit 031fc51 deletes the fileEvidence: Glob-path remote seeding on target: charter names only remote host paths
Source: Glob-path remote seeding on target: charter names only remote host paths
Evidence: Glob-path remote seeding on base and 1df13d2: parent paths retained or quote-mangled
Source: Glob-path remote seeding on base and 1df13d2: parent paths retained or quote-mangled
Evidence: Seeding driver script used for the above
Source: Seeding driver script used for the above
Evidence: Self-held mutex hang (1df13d2) and recursive path growth (base) versus target
Source: Self-held mutex hang (1df13d2) and recursive path growth (base) versus target
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-wake-lib.sh:924- The new non-recursive recovery mutex fails closed on an empty pid file (case "$pid" in ''|*[!0-9]*) return 1). At base, the recursivefm_lock_try_acquire "$steal"treated an empty pid as a mid-acquire and reclaimed it once the mutex path aged past FM_LOCK_STALE_AFTER (via fm_lock_mid_acquire_is_fresh); now a.watch.lock.stealwhose owner pid file is empty (only reachable through a crash that loses the just-written pid bytes while the symlink survives) is refused forever, so a stale primary lock behind it can only be recovered by manual removal. This sits inside the deliberate fail-closed design line the user reaffirmed in round 1 ("do not broaden the lock design") and is pinned by test_lock_unreadable_steal_mutex_fails_closed, so no action is requested; recorded so the accepted trade-off is explicit.tests/fm-procevent.test.sh:2562- tests/fm-procevent.test.sh failed once at the orphan-storm launch-floor fixture (expects 3 relaunches within 12s) while the machine load average was 13-16. That fixture's source exits nonzero with empty output, which the changed guard handles identically before and after this diff, so it reads as a load-induced flake rather than a regression; a rerun under lower contention was not completed before this report was forced. Remote CI should confirm.bash tests/fm-remote-secondmate-lifecycle-e2e.test.shto completiongit ls-tree -r 031fc51 -- .agent-kitis empty; commit 031fc51 deletes the filebash tests/fm-watcher-lock.test.sh(all lock tests including the four new recovery-mutex regressions pass)bash tests/fm-procevent.test.sh(newexit-zero empty output stays armedtest passes; one unrelated timing fixture failed under load)bash tests/fm-remote-secondmate-lifecycle-e2e.test.sh(in progress at report time: 18 passes, no failures, remote seed/charter section passed)Manual driveseed-charter-drive.shofbin/fm-remote-home-seed.shwith FM_HOME.../fm[1]over the fake-SSH boundary that execs the realfm-remote-entrypoint.sh, on base, intermediate, and targetManual drive offm_lock_acquire_wait/fm_lock_try_acquirewith a self-held recovery mutex, dead-owner mutex x3, unreadable owner, live owner, and a 244-char lock name, on base, intermediate, and target with an 8s hang timeoutManual drive ofbin/fm-procevent.sh register/startwith/bin/sh -c 'exit 0'(empty) on base and target, and with nonempty exit-0, nonempty exit-1, and empty exit-1 sources on targetgit ls-tree 031fc51 -- .agent-kitconfirms no session lock is tracked✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.