fix(#249): broadcast on reflects committed membership (CONTRACT §14.1, §13)#367
Merged
fix(#249): broadcast on reflects committed membership (CONTRACT §14.1, §13)#367
Conversation
…, §13)
Root cause: iTerm2 silently drops broadcast domains with <2 sessions
(broadcast is mirror-input — nothing to mirror to a single target).
`broadcast on -s ONE` with no existing domain would succeed in-connection
(verify block saw the domain), then state vanished when the connection
closed, so `broadcast list` correctly showed empty — a §14.1 lie from
the writer.
Fix: reject invalid writes up front instead of racing iTerm2's silent
drop.
- `broadcast on -s SID` with no existing domain → ItaError("bad-args")
pointing at `broadcast add` / `broadcast set` / `broadcast on --window`
with ≥2 panes.
- `broadcast on --window WIN` with <2 panes → ItaError("bad-args").
- Post-write verify upgraded from ClickException to ItaError (belt+braces
for any future iTerm2 rejection path — structured rc=6 per §6).
- De-duplicate the merge branch: skip re-adding an already-present
session rather than creating a no-op write the API might reject.
Tests:
- test_issue_249_broadcast_on_single_session_rejected: rc!=0 with
actionable error, state stays empty.
- test_issue_249_broadcast_list_reflects_reality_after_rejection: §14.1
proof that a rejected write leaves no residue.
- Drop stale `known_broken` marker on
test_trust_05_broadcast_on_missing_session (it already passed via
resolve_session's not-found path).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One atomic commit. #287 out of scope (already closed under PR #338 per triage sweep).
Real root cause found: iTerm2 silently drops broadcast domains with fewer than 2 sessions. So `ita broadcast on -s ONE` passed the in-connection verify but vanished before `broadcast list` ran on the next API call. Classic time-of-check-to-time-of-use.
Fix: reject singleton writes up-front with `ItaError("bad-args")` and actionable guidance — suggest `broadcast add` / `broadcast set` / `--window` with ≥2 panes. Same guard on the `--window` branch. Post-write verify upgraded from `ClickException` → `ItaError` for structured rc=6.
Fast-lane: 557 pass / 14 fail → 583 pass / 12 fail (+2 new regression tests, -1 stale `known_broken` marker cleared on an existing test now passing; no regressions).
Flagged (not in scope):
Closes #249.
Test plan
🤖 Generated with Claude Code