framework tools/tmux: compound targets pin the session component exact (codex PR #1466)
ci/woodpecker/pr/ci Pipeline failed

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.
This commit is contained in:
2026-08-28 21:17:05 -05:00
parent c2641d3770
commit 0026c0f947
2 changed files with 21 additions and 1 deletions
@@ -168,7 +168,13 @@ vflag=""; [ "$VERBOSE" = 1 ] && vflag="-v"
# (probing '==name' for an already-exact input was a false-negative hit). # (probing '==name' for an already-exact input was a false-negative hit).
DST_TARGET="$DST_SESSION" DST_TARGET="$DST_SESSION"
case "$DST_SESSION" in case "$DST_SESSION" in
=*|*:*) ;; =*) ;;
*:*)
# Compound target (session:win.pane): pin the SESSION component exact
# (=session:win.pane); unpinned, the session part still prefix-matches
# (codex PR #1466: 'agent:0.0' can resolve into 'agent-old').
DST_TARGET="=${DST_SESSION%%:*}:${DST_SESSION#*:}"
;;
*) DST_TARGET="=$DST_SESSION" ;; *) DST_TARGET="=$DST_SESSION" ;;
esac esac
@@ -139,6 +139,20 @@ fi
tmux kill-session -t "$PSEUDO" >/dev/null 2>&1 || true tmux kill-session -t "$PSEUDO" >/dev/null 2>&1 || true
rm -f "$A3_ERR" rm -f "$A3_ERR"
# Arm A4: compound targets pin the SESSION component exact (codex PR
# #1466): 'TWIN:0.0' must not resolve into the prefix-named session.
PSEUDO2="${TWIN}-old"
tmux new-session -d -s "$PSEUDO2" -c "$TMPDIR" 'PS1=" " exec bash --noprofile --norc -i'
A4_ERR=$(mktemp)
a4_rc=0
env -u MOSAIC_TMUX_SOCKET "$AGENT_SEND" -s "$TWIN:0.0" -m "compound trap" >/dev/null 2>"$A4_ERR" || a4_rc=$?
[ "$a4_rc" -eq 1 ] || fail "compound prefix false-hit: rc=$a4_rc want 1 (stderr: $(cat "$A4_ERR"))"
if tmux capture-pane -t "=$PSEUDO2:0.0" -p 2>/dev/null | grep -qF "compound trap"; then
fail "compound delivery landed in the prefix-named session"
fi
tmux kill-session -t "$PSEUDO2" >/dev/null 2>&1 || true
rm -f "$A4_ERR"
uniq_rc=0 uniq_rc=0
env -u MOSAIC_TMUX_SOCKET "$AGENT_SEND" -s "$TARGET" -m "autoresolved hello" >$UNIQ_OUT 2>$UNIQ_ERR || uniq_rc=$? env -u MOSAIC_TMUX_SOCKET "$AGENT_SEND" -s "$TARGET" -m "autoresolved hello" >$UNIQ_OUT 2>$UNIQ_ERR || uniq_rc=$?
[ "$uniq_rc" -eq 0 ] || fail "unique auto-resolution: rc=$uniq_rc (stderr: $(cat $UNIQ_ERR))" [ "$uniq_rc" -eq 0 ] || fail "unique auto-resolution: rc=$uniq_rc (stderr: $(cat $UNIQ_ERR))"