From c2641d377041aecc90a9e61247fb898eb28bcceb Mon Sep 17 00:00:00 2001 From: marcie Date: Fri, 28 Aug 2026 21:00:06 -0500 Subject: [PATCH] =?UTF-8?q?framework=20tools/tmux:=20B1=20=E2=80=94=20alre?= =?UTF-8?q?ady-exact=20targets=20no=20longer=20bypass=20discovery;=20rc=20?= =?UTF-8?q?4=20in=20EXIT=20CODES=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- .../mosaic/framework/tools/tmux/agent-send.sh | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/mosaic/framework/tools/tmux/agent-send.sh b/packages/mosaic/framework/tools/tmux/agent-send.sh index 7bfec682..1d0b9c09 100755 --- a/packages/mosaic/framework/tools/tmux/agent-send.sh +++ b/packages/mosaic/framework/tools/tmux/agent-send.sh @@ -66,8 +66,10 @@ # group 1 = src label group 2 = dst host:session # group 3 = class (absent => actionable) group 4 = message body # -# EXIT CODES (passed through from send-message.sh) +# EXIT CODES (passed through from send-message.sh, except 4) # 0 delivered/queued · 1 target not found · 2 still draft · 3 usage error +# 4 agent-send refusal: local target session exists on multiple socket +# servers and no -L / MOSAIC_TMUX_SOCKET disambiguated it (B1) set -uo pipefail SELF_DIR=$(cd -- "$(dirname -- "$0")" && pwd) @@ -158,6 +160,18 @@ B64=$(printf '%s' "$FULL" | base64 -w0) vflag=""; [ "$VERBOSE" = 1 ] && vflag="-v" +# Exact session matching for the sender target (codex PR #1466): without +# '=', tmux target syntax accepts an unambiguous PREFIX, so a delivery +# aimed at session X can land in X-old. Compound targets (session:win.pane) +# and already-exact ('=...') forms pass through untouched. Computed BEFORE +# socket discovery so the discovery probes use the same target semantics +# (probing '==name' for an already-exact input was a false-negative hit). +DST_TARGET="$DST_SESSION" +case "$DST_SESSION" in + =*|*:*) ;; + *) DST_TARGET="=$DST_SESSION" ;; +esac + # Socket default resolution (B1, 2026-08-29). Precedence: explicit -L > # launcher-exported MOSAIC_TMUX_SOCKET > unique socket hit > refusal on # ambiguity > tmux default socket. The ambiguity refusal fires ONLY when @@ -181,7 +195,7 @@ if [ -z "$SOCKET_NAME" ] && [ -z "$SSH_TARGET" ]; then # '=' forces exact session-name matching: tmux target syntax otherwise # accepts an unambiguous PREFIX, so a session named X-old on a socket # would count as a false hit for target X (codex PR #1466). - tmux -L "$sname" has-session -t "=$DST_SESSION" 2>/dev/null && hits="$hits$sname"$'\n' + tmux -L "$sname" has-session -t "$DST_TARGET" 2>/dev/null && hits="$hits$sname"$'\n' done hit_count=$(printf '%s' "$hits" | grep -c . || true) if [ "$hit_count" -gt 1 ]; then @@ -199,16 +213,6 @@ if [ -n "$SOCKET_NAME" ]; then socket_args=(-L "$SOCKET_NAME") fi -# Exact session matching for the sender target too (codex PR #1466): without -# '=', tmux target syntax accepts an unambiguous PREFIX, so a delivery aimed -# at session X can land in X-old. Compound targets (session:win.pane) and -# already-exact ('=...') forms pass through untouched. -DST_TARGET="$DST_SESSION" -case "$DST_SESSION" in - =*|*:*) ;; - *) DST_TARGET="=$DST_SESSION" ;; -esac - if [ -z "$SSH_TARGET" ]; then # Local pane: call the canonical sender directly. exec "$SENDER" "${socket_args[@]}" -t "$DST_TARGET" -b "$B64" -r "$RETRIES" $vflag