fix(tmux): correct cross-socket sender identity (#808) #809

Merged
jason.woltje merged 1 commits from fix/808-agent-send-false-sender into main 2026-07-16 22:47:26 +00:00
Owner

Root cause

The sender self-lookup reused the destination tmux socket arguments. For cross-socket sends, tmux -L "$SOCKET_NAME" display-message -p '#S' therefore asked the destination server for its session and stamped a holder/garbage identity into the preamble. Because that lookup succeeded, the ? fallback never ran and flipped replies routed to a non-participant.

Fix

  • Prefer MOSAIC_AGENT_NAME, exported into every agent pane, as the authoritative sender session name.
  • When that variable is absent, query tmux display-message -p '#S' on the sender's local/default socket with no destination -L argument, preserving || echo "?" for genuinely unknown senders.
  • Leave destination dispatch and its correct -L "$SOCKET_NAME" behavior unchanged.

TDD evidence

RED against the unpatched tool:

  • bash packages/mosaic/framework/tools/tmux/agent-send.test.sh
  • PASS=12 FAIL=3
  • Failures showed both env and fallback cases incorrectly selecting destination-holder.

GREEN after the fix:

  • focused regression suite: PASS=15 FAIL=0
  • pnpm typecheck: 42/42 tasks
  • pnpm lint: 23/23 tasks
  • pnpm format:check: passed
  • shell syntax check: passed

Author-only lane: independent review and merge are intentionally left to the assigned reviewer and MS Team Lead.

Fixes #808

## Root cause The sender self-lookup reused the destination tmux socket arguments. For cross-socket sends, `tmux -L "$SOCKET_NAME" display-message -p '#S'` therefore asked the destination server for its session and stamped a holder/garbage identity into the preamble. Because that lookup succeeded, the `?` fallback never ran and flipped replies routed to a non-participant. ## Fix - Prefer `MOSAIC_AGENT_NAME`, exported into every agent pane, as the authoritative sender session name. - When that variable is absent, query `tmux display-message -p '#S'` on the sender's local/default socket with no destination `-L` argument, preserving `|| echo "?"` for genuinely unknown senders. - Leave destination dispatch and its correct `-L "$SOCKET_NAME"` behavior unchanged. ## TDD evidence RED against the unpatched tool: - `bash packages/mosaic/framework/tools/tmux/agent-send.test.sh` - `PASS=12 FAIL=3` - Failures showed both env and fallback cases incorrectly selecting `destination-holder`. GREEN after the fix: - focused regression suite: `PASS=15 FAIL=0` - `pnpm typecheck`: 42/42 tasks - `pnpm lint`: 23/23 tasks - `pnpm format:check`: passed - shell syntax check: passed Author-only lane: independent review and merge are intentionally left to the assigned reviewer and MS Team Lead. Fixes #808
jason.woltje added 1 commit 2026-07-16 22:31:51 +00:00
fix(tmux): preserve sender identity across sockets
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
4b50cc93d1
Prefer the pane's MOSAIC_AGENT_NAME and query only the local tmux server when falling back, so destination socket holders cannot corrupt reply routing. Add red-first regression coverage for env, local-session, and unknown sender paths.

Co-Authored-By: OpenAI GPT <noreply@openai.com>
jason.woltje merged commit 4f29cc604d into main 2026-07-16 22:47:26 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#809