fix(tools/tmux): unique per-invocation paste buffer; track auto-submit-drafts.sh #697

Merged
jason.woltje merged 1 commits from enhance/tmux-send-buffer-race into main 2026-07-09 17:37:41 +00:00
Owner

What

Upstreams the 2026-07-09 live hot-fix on web1 into the framework SSOT, plus brings the one genuinely untracked tmux tool under source control.

  1. send-message.sh — unique per-invocation paste buffer. The script used a fixed tmux buffer name (__mosaic_send) shared by every concurrent sender on a tmux server. Concurrent invocations raced: load-buffer overwrote a peer's payload, and paste-buffer -d deleted the buffer underneath a peer — cross-delivering or dropping messages. This bit the fleet during the 2026-07-09 simultaneous restart (standing briefs swapped between agent sessions; one agent received another's role brief). Buffer name is now __mosaic_send_$$_$(date +%s%N). Also adds explicit delete-buffer cleanup when both paste attempts fail (named buffers are exempt from tmux buffer-limit eviction, so orphans would accumulate forever) — found in review.
  2. auto-submit-drafts.sh — now tracked. Coordinator draft-flush watchdog; until now existed only as a loose file in the deployed ~/.config/mosaic/tools/tmux/ with no source-control home. Verbatim import.
  3. test-send-message-socket.sh — concurrency regression lock. 5 parallel sends to 5 distinct panes on an isolated -L socket; asserts every pane got exactly its own payload (no drop, no cross-delivery). Verified to fail 3/3 runs against the pre-fix script and pass post-fix.
  4. README.md — file list updated (auto-submit-drafts.sh, agent-send.test.sh).

Why now

The fix currently exists only in the live deployed copy on web1. The next framework redeploy (already queued for the agent-send --class go-live) would overwrite it with the still-racy upstream version and silently reintroduce the cross-delivery bug. This PR makes the SSOT carry the fix before that happens.

Verification

  • bash -n + shellcheck clean on changed scripts (sole warning SC2034 attempt is pre-existing, untouched code).
  • agent-send.test.sh: 11/11 pass.
  • test-send-message-socket.sh (incl. new concurrency lock): pass; pre-fix script fails it 3/3.
  • Independent review (author ≠ reviewer): APPROVE; the one should-fix (buffer leak on failed paste) remediated and re-verified.

Notes for merge/deploy

  • Preserves the upstream -L socket / EFFECTIVE_TARGET structure — no behavior change vs. main other than the buffer naming + failure-path cleanup.
  • After merge, the framework redeploy propagates this to hosts; live web1 copy already carries the buffer fix (hot-fix by Mos), so redeploy converges rather than regresses.

🤖 Generated with Claude Code

## What Upstreams the 2026-07-09 live hot-fix on web1 into the framework SSOT, plus brings the one genuinely untracked tmux tool under source control. 1. **`send-message.sh` — unique per-invocation paste buffer.** The script used a fixed tmux buffer name (`__mosaic_send`) shared by every concurrent sender on a tmux server. Concurrent invocations raced: `load-buffer` overwrote a peer's payload, and `paste-buffer -d` deleted the buffer underneath a peer — cross-delivering or dropping messages. This bit the fleet during the 2026-07-09 simultaneous restart (standing briefs swapped between agent sessions; one agent received another's role brief). Buffer name is now `__mosaic_send_$$_$(date +%s%N)`. Also adds explicit `delete-buffer` cleanup when both paste attempts fail (named buffers are exempt from tmux `buffer-limit` eviction, so orphans would accumulate forever) — found in review. 2. **`auto-submit-drafts.sh` — now tracked.** Coordinator draft-flush watchdog; until now existed only as a loose file in the deployed `~/.config/mosaic/tools/tmux/` with no source-control home. Verbatim import. 3. **`test-send-message-socket.sh` — concurrency regression lock.** 5 parallel sends to 5 distinct panes on an isolated `-L` socket; asserts every pane got exactly its own payload (no drop, no cross-delivery). **Verified to fail 3/3 runs against the pre-fix script and pass post-fix.** 4. `README.md` — file list updated (`auto-submit-drafts.sh`, `agent-send.test.sh`). ## Why now The fix currently exists **only in the live deployed copy** on web1. The next framework redeploy (already queued for the `agent-send --class` go-live) would overwrite it with the still-racy upstream version and silently reintroduce the cross-delivery bug. This PR makes the SSOT carry the fix before that happens. ## Verification - `bash -n` + shellcheck clean on changed scripts (sole warning SC2034 `attempt` is pre-existing, untouched code). - `agent-send.test.sh`: 11/11 pass. - `test-send-message-socket.sh` (incl. new concurrency lock): pass; pre-fix script fails it 3/3. - Independent review (author ≠ reviewer): APPROVE; the one should-fix (buffer leak on failed paste) remediated and re-verified. ## Notes for merge/deploy - Preserves the upstream `-L` socket / `EFFECTIVE_TARGET` structure — no behavior change vs. main other than the buffer naming + failure-path cleanup. - After merge, the framework redeploy propagates this to hosts; live web1 copy already carries the buffer fix (hot-fix by Mos), so redeploy converges rather than regresses. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jason.woltje added 1 commit 2026-07-09 17:29:37 +00:00
fix(tools/tmux): unique per-invocation paste buffer; track auto-submit-drafts.sh
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
c9c07cdeba
Upstream the 2026-07-09 live hot-fix from web1: send-message.sh used a fixed
tmux buffer name (__mosaic_send) shared by all concurrent senders on one
server — load-buffer overwrote load-buffer and paste-buffer -d deleted
underneath peers, cross-delivering or dropping messages. Bit the fleet during
the simultaneous restart (standing briefs swapped between sessions). Buffer
name is now unique per invocation (PID + nanoseconds).

Also brings auto-submit-drafts.sh (coordinator draft-flush watchdog, until now
only a loose file in the deployed ~/.config/mosaic/tools/tmux/) under source
control, and extends test-send-message-socket.sh with a concurrency lock:
5 parallel sends to distinct panes, asserting no drop and no cross-delivery.
The lock fails 3/3 runs against the pre-fix script and passes post-fix.

Without this, the next framework redeploy would regress the live fix.
jason.woltje merged commit 4e9e053800 into main 2026-07-09 17:37:41 +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#697