fix(bin): make tmux target_exists answer from exact membership, not the active window - #2903
Open
harmeet-1337 wants to merge 4 commits into
Open
fix(bin): make tmux target_exists answer from exact membership, not the active window#2903harmeet-1337 wants to merge 4 commits into
harmeet-1337 wants to merge 4 commits into
Conversation
…he active window fm_backend_target_exists reported an absent tmux window or session as present: its `tmux display-message -p -t <target>` probe answers from the client's active window whenever any tmux server is running, so every consumer that treats the result as authoritative (the session-start fleet digest, fm-busy-lib, fm-fleet-snapshot, the away-mode daemon's supervisor-target validation, fm-control, fm-send) could read a dead endpoint as alive. Make fm_backend_target_exists a pure per-backend dispatcher, like its composer_state/agent_state siblings, and give each adapter its own fm_backend_<backend>_target_exists: - tmux: an exact-match `tmux list-panes` probe. A session:window endpoint is anchored `=sess:=win` so a prefix cannot match (firstmate:fm-task never matches fm-task-2); bare %N/@n pane/window ids are queried directly. Never starts a server. - herdr: the former inline arm, moved verbatim (direct pane read, no server-ensure side effect). - zellij/cmux: thin aliases over their existing target_ready. - orca: a one-line capture probe. No call sites change. Tests: the session-start fake tmux now models list-panes; the tmux smoke test gains absent-window, absent-session, absent-%N, and prefix-collision cases against a real server; shared daemon/watcher fakes gain a list-panes case at parity with their old display-message presence read.
…and remote digest line
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure identified. The new dispatcher preserves prior non-tmux backend behavior, while tmux now checks exact target membership and the remote digest guard follows the repository’s established remote-endpoint contract. Reviews (1): Last reviewed commit: "no-mistakes(document): document exact-me..." | Re-trigger Greptile |
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.
Summary
Fixes audit finding F-S02-1 (P0, reproduced defect):
fm_backend_target_existsreported ABSENT tmux windows and sessions as present. Itstmux display-message -p -t <target>probe answers from the client's active window whenever any tmux server is running, so every consumer that treats the result as authoritative (session-start fleet digest, fm-busy-lib, fm-fleet-snapshot, the away-mode daemon's%Nsupervisor-target validation, fm-control, fm-send) could read a dead endpoint as alive.Change
fm_backend_target_existsis now a pure per-backend dispatcher, matching itsfm_backend_composer_state/fm_backend_agent_statesiblings, so no presence answer is derived inline.fm_backend_tmux_target_existsusing exact-matchtmux list-panes. Asession:windowendpoint is anchored=sess:=winso a prefix cannot match (firstmate:fm-tasknever matchesfm-task-2); bare%N/@Npane/window ids are queried directly. Never starts a server.fm_backend_herdr_target_exists(direct pane read, no server-ensure side effect).target_ready; orca: a one-line capture probe.fm_backend_tmux_agent_state's three-way missing/unreadable/present membership check is deliberately left untouched.window=remote:<id>with nobackend=key (defaulting to tmux), the corrected exact-match probe would otherwise flip their session-start digest line from falsely "alive" to falsely "dead". The fleet digest now special-caseswindow=remote:*and prints a distinct non-locally-probed line instead of running a local existence probe, since aremote:<id>window can never match a local backend's shape.Tests
%N, and prefix-collision cases.list-panesat parity with the old presence read; thefm-send-stricttmux stub is updated likewise.bin/fm-lint.shis clean (ShellCheck 0.11.0 + actionlint 1.7.12, both pinned).Delivery note
The account has read-only access to the upstream repository, so the branch is delivered from the fork
harmeet-1337/firstmate. Every commit on the branch is in scope — the original fix plus the pipeline's own in-scope review/test/document gate-fix commits (the approved remote-secondmate guard, thefm-send-strictstub update, and documentation/comment corrections). No out-of-scope tooling commit was injected, so none was excluded.