framework tools/tmux: agent-send socket default resolution + ambiguity guard (B1) #1466

Open
marcie wants to merge 7 commits from mosaic-cli-p2-socket-res into mosaic-cli-p1-wrappers
Member

Fixes the measured comms defect class from 2026-08-28/29: tasking sends without -L landed in a stale default-socket TWIN of the target seat while rc 0 reported honest delivery to the wrong pane (five lost messages, documented in the brain STATE).

Resolution order: explicit -L > MOSAIC_TMUX_SOCKET (launcher-exported on every seat) > unique socket hit. When the target session exists on MULTIPLE sockets and no -L is given, the sender refuses with exit 4 naming the sockets instead of silently picking one.

Socket test arms: A (twin session on two sockets -> rc 4 + socket list), B (unique session auto-resolves, delivers on the right socket, no cross-delivery). Test stays CI-excluded per its signed exclusion (no tmux in the CI image, #1017 burndown).

Stacked on #1464 (merge after the current chain).

Fixes the measured comms defect class from 2026-08-28/29: tasking sends without -L landed in a stale default-socket TWIN of the target seat while rc 0 reported honest delivery to the wrong pane (five lost messages, documented in the brain STATE). Resolution order: explicit -L > MOSAIC_TMUX_SOCKET (launcher-exported on every seat) > unique socket hit. When the target session exists on MULTIPLE sockets and no -L is given, the sender refuses with exit 4 naming the sockets instead of silently picking one. Socket test arms: A (twin session on two sockets -> rc 4 + socket list), B (unique session auto-resolves, delivers on the right socket, no cross-delivery). Test stays CI-excluded per its signed exclusion (no tmux in the CI image, #1017 burndown). Stacked on #1464 (merge after the current chain).
marcie added 1 commit 2026-08-29 01:42:42 +00:00
Measured defect (2026-08-28/29): tasking sends without -L landed in a
stale default-socket TWIN of the target seat; rc 0 reported honest
delivery to the wrong pane. Resolution order now: explicit -L >
MOSAIC_TMUX_SOCKET (launcher-exported) > unique socket hit; multiple
hits refuse with rc 4 naming the sockets. Local targets only; remote
pass-through unchanged.

Socket test gains arms A (twin session on two sockets -> rc 4 with the
socket list) and B (unique session auto-resolves and delivers on the
right socket, no cross-delivery). Test remains CI-excluded per its
signed exclusion (no tmux in the CI image, #1017).
marcie added 1 commit 2026-08-29 01:45:47 +00:00
- MOSAIC_TMUX_SOCKET now disambiguates BEFORE the ambiguity refusal
  (the old order told users to set the env var while never consulting
  it on multi-hit; codex blocker).
- Socket discovery scans ${TMUX_TMPDIR:-/tmp}/tmux-UID, tmux's own
  socket dir — TMPDIR was wrong wherever they diverge (codex blocker).
- Arm A2: env var beats ambiguity (twin delivers on the named socket,
  no cross-delivery); arms A/B run hermetic (env unset).
- Same precedence + dir fix applied to brain agent-watch.
marcie added 1 commit 2026-08-29 01:48:05 +00:00
- MOSAIC_TMUX_SOCKET no longer leaks into remote sends (-L on a remote
  host would target the wrong server; codex blocker).
- Socket-test outputs moved from fixed /tmp paths to mktemp artifacts
  cleaned by the trap (parallel-safe; codex should-fix).
marcie added 1 commit 2026-08-29 01:50:31 +00:00
Hits newline-delimited and counted by lines (socket names with spaces
no longer break the count; codex should-fix); ambiguity listing prints
one socket per line; exit 4 added to the public contract in the header.
marcie added 1 commit 2026-08-29 01:58:34 +00:00
tmux target syntax accepts an unambiguous PREFIX, so both the socket
discovery loop and the sender's -t could match X-old for target X.
Discovery now probes has-session -t =NAME; the sender target gets '='
prepended unless it is already exact or compound (session:win.pane).
Arm A3 proves it: a prefix-named session no longer swallows a delivery
aimed at the shorter name (sender fails target-not-found rc 1).
marcie added 1 commit 2026-08-29 02:01:01 +00:00
DST_TARGET computed BEFORE socket discovery and used for the probes
(probing '==name' for already-exact input was a false negative that
fell back to the default socket; codex blocker). Exit 4 moved into the
canonical EXIT CODES header (codex should-fix).
marcie added 1 commit 2026-08-29 02:18:07 +00:00
session:win.pane targets become =session:win.pane; without the pin the
session part still prefix-matched (agent:0.0 could resolve into
agent-old). Arm A4 proves the compound form no longer swallows
deliveries into prefix-named sessions.
Some required checks failed
ci/woodpecker/pr/ci Pipeline failed
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin mosaic-cli-p2-socket-res:mosaic-cli-p2-socket-res
git checkout mosaic-cli-p2-socket-res
Sign in to join this conversation.